cmake: add libcurlu/libcurltool for unit tests

Add a `libcurlu`/`libcurltool` static library that is compiled only for
unit tests. We use `EXCLUDE_FROM_ALL` to make sure that they're not
built by default, they're only built if unit tests are built.

These libraries allow us to compile every unit test with CMake.

Closes #11446
This commit is contained in:
Alois Klink 2023-07-16 06:32:45 +01:00 committed by Daniel Stenberg
parent c42c6eb245
commit 39e7c22bb4
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 19 additions and 10 deletions

View file

@ -76,6 +76,14 @@ add_executable(
ALIAS ${EXE_NAME}
)
add_library(
curltool # special libcurltool library just for unittests
STATIC
EXCLUDE_FROM_ALL
${CURL_CFILES} ${CURLX_CFILES} ${CURL_HFILES}
)
target_compile_definitions(curltool PUBLIC UNITTESTS CURL_STATICLIB)
if(CURL_HAS_LTO)
set_target_properties(${EXE_NAME} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE