]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: hack to build most unit tests under cmake
authorDan Fandrich <dan@coneharvesters.com>
Thu, 9 Mar 2023 21:17:44 +0000 (13:17 -0800)
committerDan Fandrich <dan@coneharvesters.com>
Sun, 12 Mar 2023 02:54:21 +0000 (18:54 -0800)
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

tests/unit/CMakeLists.txt

index 5e8a2712c7c8229e5e3017f505db4b4189fc8d8f..fe630422c2e524fe9467cc153550466143e7dac1 100644 (file)
@@ -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()