diff --git a/CMakeLists.txt b/CMakeLists.txt index 40dc64b8f..c78c45bec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,6 +414,15 @@ else() set(DFHACK_TINYXML "dfhack-tinyxml") endif() +if(BUILD_TESTING) + message("BUILD TESTS: Core, Scripts") + set(BUILD_SCRIPT_TESTS ON FORCE) + set(BUILD_CORE_TESTS ON FORCE) +endif() + +if(BUILD_CORE_TESTS) + include_directories(depends/googletest/googletest/include) +endif() include_directories(depends/lodepng) include_directories(depends/tthread) include_directories(${ZLIB_INCLUDE_DIRS}) @@ -421,44 +430,41 @@ include_directories(depends/clsocket/src) include_directories(depends/xlsxio/include) add_subdirectory(depends) -find_package(Git REQUIRED) -if(NOT GIT_FOUND) - message(SEND_ERROR "could not find git") -endif() # Testing with CTest -include(CTest) +if(BUILD_TESTING OR BUILD_CORE_TESTS) + message("Including CTest") + include(CTest) +endif() include(CMakeDependentOption) cmake_dependent_option( - BUILD_TEST_SCRIPTS "Install integration tests in hack/scripts/test" OFF + BUILD_SCRIPT_TESTS "Install integration tests in hack/scripts/test" OFF "BUILD_TESTING" OFF) mark_as_advanced(FORCE BUILD_TESTS) - # Handle deprecated BUILD_TESTS option -option(BUILD_TESTS "Deprecated option; please use BUILD_TEST_SCRIPTS=ON" OFF) -if(BUILD_TESTING AND BUILD_TESTS) - set(BUILD_TEST_SCRIPTS ON FORCE) -endif() +option(BUILD_TESTS "Deprecated option; please use BUILD_SCRIPT_TESTS=ON" OFF) -if(BUILD_TESTING) - include_directories(depends/googletest/googletest/include) - if(BUILD_TEST_SCRIPTS) - if(EXISTS "${dfhack_SOURCE_DIR}/test/scripts") - message(SEND_ERROR "test/scripts must not exist in the dfhack repo since it would conflict with the tests installed from the scripts repo.") - endif() - install(DIRECTORY ${dfhack_SOURCE_DIR}/test - DESTINATION ${DFHACK_DATA_DESTINATION}/scripts) - install(FILES ci/test.lua DESTINATION ${DFHACK_DATA_DESTINATION}/scripts) +if(BUILD_TESTING OR BUILD_SCRIPT_TESTS) + if(EXISTS "${dfhack_SOURCE_DIR}/test/scripts") + message(SEND_ERROR "test/scripts must not exist in the dfhack repo since it would conflict with the tests installed from the scripts repo.") endif() + install(DIRECTORY ${dfhack_SOURCE_DIR}/test + DESTINATION ${DFHACK_DATA_DESTINATION}/scripts) + install(FILES ci/test.lua DESTINATION ${DFHACK_DATA_DESTINATION}/scripts) else() add_custom_target(test - COMMENT "Nothing to do: CMake option BUILD_TESTS is OFF" + COMMENT "Nothing to do: CMake option BUILD_TESTING is OFF" # Portable NOOP; need to put something here or the comment isn't displayed COMMAND cd ) endif() +find_package(Git REQUIRED) +if(NOT GIT_FOUND) + message(SEND_ERROR "could not find git") +endif() + # build the lib itself if(BUILD_LIBRARY) add_subdirectory(library) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 412ffa347..8cf6bb2ca 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -21,7 +21,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/blueprints/ FILES_MATCHING PATTERN "*" PATTERN blueprints/library/test EXCLUDE) -if(BUILD_TESTS) +if(BUILD_SCRIPT_TESTS) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/blueprints/library/test/ DESTINATION blueprints/library/test ) diff --git a/depends/CMakeLists.txt b/depends/CMakeLists.txt index 13a8cc466..f5e77ad8a 100644 --- a/depends/CMakeLists.txt +++ b/depends/CMakeLists.txt @@ -3,7 +3,7 @@ add_subdirectory(lodepng) add_subdirectory(lua) add_subdirectory(md5) add_subdirectory(protobuf) -if(BUILD_TESTING) +if(BUILD_CORE_TESTS) add_subdirectory(googletest EXCLUDE_FROM_ALL) set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-Wno-maybe-uninitialized -Wno-sign-compare") endif() diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index f8a60cfc0..035fcda73 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -90,7 +90,7 @@ macro(dfhack_test name files) set_target_properties(${name} PROPERTIES COMPILE_FLAGS "-Wno-sign-compare") endmacro() -if(BUILD_TESTING) +if(BUILD_CORE_TESTS) file(GLOB_RECURSE TEST_SOURCES LIST_DIRECTORIES false *.test.cpp) dfhack_test(test-all ${TEST_SOURCES}) dfhack_test(test-MiscUtils MiscUtils.test.cpp)