From: Dan Fandrich Date: Thu, 9 Mar 2023 21:17:44 +0000 (-0800) Subject: tests: hack to build most unit tests under cmake X-Git-Tag: curl-8_0_0~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13b4d050aa98ed8726c4b69fe9668e904a86e72b;p=thirdparty%2Fcurl.git tests: hack to build most unit tests under cmake These are only built when a libcurl static library is available, since we're not building a special libcurlu library yet and these tests rely on private symbols that aren't available in the shared library. A few unit tests do require libcurlu, so those are not built. Closes #10722 --- diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 5e8a2712c7..fe630422c2 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -22,9 +22,6 @@ # ########################################################################### -# TODO build a special libcurlu library for unittests. -#return() - transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) @@ -36,10 +33,18 @@ include_directories( ${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h" ) -foreach(_testfile ${UNITPROGS}) - add_executable(${_testfile} EXCLUDE_FROM_ALL ${_testfile}.c ${UNITFILES}) - add_dependencies(testdeps ${_testfile}) - target_link_libraries(${_testfile} libcurl ${CURL_LIBS}) - set_target_properties(${_testfile} - PROPERTIES COMPILE_DEFINITIONS "UNITTESTS") -endforeach() +# TODO build a special libcurlu library for unittests. +# Until that happens, only build the unit tests when creating a static libcurl +# or else they will fail to link. Some of the tests require the special libcurlu +# build, so filter those out until we get libcurlu. +list(FILTER UNITPROGS EXCLUDE REGEX + "unit1394|unit1395|unit1604|unit1608|unit1621|unit1650|unit1653|unit1655|unit1660|unit2600") +if(NOT BUILD_SHARED_LIBS) + foreach(_testfile ${UNITPROGS}) + add_executable(${_testfile} EXCLUDE_FROM_ALL ${_testfile}.c ${UNITFILES}) + add_dependencies(testdeps ${_testfile}) + target_link_libraries(${_testfile} libcurl ${CURL_LIBS}) + set_target_properties(${_testfile} + PROPERTIES COMPILE_DEFINITIONS "UNITTESTS") + endforeach() +endif()