From 54959b0f2c4950d97d94c03810b3b5185be0d69e Mon Sep 17 00:00:00 2001 From: David Callu Date: Mon, 14 Sep 2020 12:39:13 +0200 Subject: cmake: add BUILD_TESTING option (ON by default) (#1839) option provided by cmake's Module CTest enable_testing() is call by this Module --- CMakeLists.txt | 80 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0c0911..8e6bdd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,45 +149,47 @@ if(platform_supports_ninja_browse) ) endif() -# Tests all build into ninja_test executable. -add_executable(ninja_test - src/build_log_test.cc - src/build_test.cc - src/clean_test.cc - src/clparser_test.cc - src/depfile_parser_test.cc - src/deps_log_test.cc - src/disk_interface_test.cc - src/dyndep_parser_test.cc - src/edit_distance_test.cc - src/graph_test.cc - src/lexer_test.cc - src/manifest_parser_test.cc - src/ninja_test.cc - src/state_test.cc - src/string_piece_util_test.cc - src/subprocess_test.cc - src/test.cc - src/util_test.cc -) -if(WIN32) - target_sources(ninja_test PRIVATE src/includes_normalize_test.cc src/msvc_helper_test.cc) +include(CTest) +if(BUILD_TESTING) + # Tests all build into ninja_test executable. + add_executable(ninja_test + src/build_log_test.cc + src/build_test.cc + src/clean_test.cc + src/clparser_test.cc + src/depfile_parser_test.cc + src/deps_log_test.cc + src/disk_interface_test.cc + src/dyndep_parser_test.cc + src/edit_distance_test.cc + src/graph_test.cc + src/lexer_test.cc + src/manifest_parser_test.cc + src/ninja_test.cc + src/state_test.cc + src/string_piece_util_test.cc + src/subprocess_test.cc + src/test.cc + src/util_test.cc + ) + if(WIN32) + target_sources(ninja_test PRIVATE src/includes_normalize_test.cc src/msvc_helper_test.cc) + endif() + target_link_libraries(ninja_test PRIVATE libninja libninja-re2c) + + foreach(perftest + build_log_perftest + canon_perftest + clparser_perftest + depfile_parser_perftest + hash_collision_bench + manifest_parser_perftest + ) + add_executable(${perftest} src/${perftest}.cc) + target_link_libraries(${perftest} PRIVATE libninja libninja-re2c) + endforeach() + + add_test(NinjaTest ninja_test) endif() -target_link_libraries(ninja_test PRIVATE libninja libninja-re2c) - -foreach(perftest - build_log_perftest - canon_perftest - clparser_perftest - depfile_parser_perftest - hash_collision_bench - manifest_parser_perftest -) - add_executable(${perftest} src/${perftest}.cc) - target_link_libraries(${perftest} PRIVATE libninja libninja-re2c) -endforeach() - -enable_testing() -add_test(NinjaTest ninja_test) install(TARGETS ninja DESTINATION bin) -- cgit v0.12