]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CMake: do not build test programs by default
authorPeter Wu <peter@lekensteyn.nl>
Sun, 10 May 2020 00:10:20 +0000 (02:10 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 12 May 2020 06:50:07 +0000 (08:50 +0200)
The default target should only build libcurl and curl. Add a dedicated
'testdeps' target which will be used later when running tests. Note that
unittests are currently broken in CMake and already excluded.

Closes #5368

tests/CMakeLists.txt
tests/libtest/CMakeLists.txt
tests/server/CMakeLists.txt
tests/unit/CMakeLists.txt

index a145b2b04c0f0f0990bf3bcea39fbd16a1d05cd8..caba3c86a6e32caaebfd9d4df58b6c23b7c23884 100644 (file)
@@ -19,6 +19,7 @@
 # KIND, either express or implied.
 #
 ###########################################################################
+add_custom_target(testdeps)
 add_subdirectory(data)
 add_subdirectory(libtest)
 add_subdirectory(server)
index 1fdfc0da2e04add60f40211529d70ebb1ebdfd4b..cc38a97c6d878d47285a5b3d057d1ea59a98281f 100644 (file)
@@ -22,7 +22,8 @@
 set(TARGET_LABEL_PREFIX "Test ")
 
 function(setup_test TEST_NAME)          # ARGN are the files in the test
-  add_executable( ${TEST_NAME} ${ARGN} )
+  add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
+  add_dependencies(testdeps ${TEST_NAME})
   string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
 
   include_directories(
@@ -58,7 +59,8 @@ endforeach()
 # Allows for hostname override to make tests machine independent.
 # TODO this cmake build assumes a shared build, detect static linking here!
 if(NOT WIN32)
-  add_library(hostname MODULE sethostname.c sethostname.h)
+  add_library(hostname MODULE EXCLUDE_FROM_ALL sethostname.c sethostname.h)
+  add_dependencies(testdeps hostname)
   # Output to .libs for compatibility with autotools, the test data expects a
   # library at (tests)/libtest/.libs/libhostname.so
   set_target_properties(hostname PROPERTIES
index 7c64f0a8db123582720efed9b465de986dfd0219..3bfa64921366c9e50b95522c4b63e91313bd2496 100644 (file)
@@ -26,7 +26,8 @@ if(MSVC)
 endif()
 
 function(SETUP_EXECUTABLE TEST_NAME)    # ARGN are the files in the test
-  add_executable(${TEST_NAME} ${ARGN})
+  add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
+  add_dependencies(testdeps ${TEST_NAME})
   string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
 
   include_directories(
index a8c462b82667ee6f0dd496c3765bdbbb8d352934..a18ea18e087c48ded02b3486f917af77fab5554a 100644 (file)
@@ -58,7 +58,8 @@ include_directories(
 foreach(_testfile ${UT_SRC})
 
   get_filename_component(_testname ${_testfile} NAME_WE)
-  add_executable(${_testname} ${_testfile} ${UT_COMMON_FILES})
+  add_executable(${_testname} EXCLUDE_FROM_ALL ${_testfile} ${UT_COMMON_FILES})
+  #add_dependencies(testdeps ${_testname})
   target_link_libraries(${_testname} libcurl ${CURL_LIBS})
   set_target_properties(${_testname}
       PROPERTIES COMPILE_DEFINITIONS "UNITTESTS")