From 2208231aac6e5702d7143cc8de1836f7d02d9987 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Fri, 11 May 2007 10:22:20 -0400 Subject: ENH: some more CMakeList cleanups --- CMakeLists.txt | 1 - Tests/CMakeLists.txt | 169 ++++++--------------------------- Tests/COnly/CMakeLists.txt | 6 +- Tests/CxxOnly/CMakeLists.txt | 6 +- Tests/MathTest/CMakeLists.txt | 2 +- Tests/NewlineArgs/CMakeLists.txt | 14 +-- Tests/ObjC++/CMakeLists.txt | 6 +- Tests/PreOrder/CMakeLists.txt | 4 +- Tests/SetLang/CMakeLists.txt | 6 +- Tests/Simple/CMakeLists.txt | 6 +- Tests/SystemInformation/CMakeLists.txt | 14 +-- Tests/TarTest/CMakeLists.txt | 4 +- 12 files changed, 65 insertions(+), 173 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c027b6..4422a44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,6 @@ ADD_SUBDIRECTORY(Modules) ADD_SUBDIRECTORY(Templates) ADD_SUBDIRECTORY(Utilities) ADD_SUBDIRECTORY(Tests) -ADD_SUBDIRECTORY(Tests/CMakeTests) # add a test ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ec1583d..d4a98e2 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,3 +1,18 @@ +# a macro for tests that have a simple format where the name matches the +# directory and project +MACRO(ADD_TEST_MACRO NAME) + ADD_TEST(${NAME} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/${NAME}" + "${CMake_BINARY_DIR}/Tests/${NAME}" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project ${NAME} + --test-command ${NAME}) +ENDMACRO(ADD_TEST_MACRO) + + # Testing IF(BUILD_TESTING) # Should the long tests be run? @@ -12,25 +27,19 @@ IF(BUILD_TESTING) MARK_AS_ADVANCED(CTEST_TEST_CTEST) ENDIF (CMAKE_RUN_LONG_TESTS) - ADD_TEST(CommandLineTest ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/CommandLineTest" - "${CMake_BINARY_DIR}/Tests/CommandLineTest" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-project CommandLineTest - --test-command CommandLineTest) - - ADD_TEST(TarTest ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/TarTest" - "${CMake_BINARY_DIR}/Tests/TarTest" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-project TestTar - --test-command TestTarExec) + ADD_TEST_MACRO(CommandLineTest CommandLineTest) + ADD_TEST_MACRO(FindPackageTest FindPackageTest) + ADD_TEST_MACRO(StringFileTest StringFileTest) + ADD_TEST_MACRO(TryCompile TryCompile) + ADD_TEST_MACRO(TarTest TarTest) + ADD_TEST_MACRO(SystemInformation SystemInformation) + ADD_TEST_MACRO(MathTest MathTest) + ADD_TEST_MACRO(Simple Simple) + ADD_TEST_MACRO(PreOrder PreOrder) + ADD_TEST_MACRO(COnly COnly) + ADD_TEST_MACRO(CxxOnly CxxOnly) + ADD_TEST_MACRO(NewlineArgs NewlineArgs) + ADD_TEST_MACRO(SetLang SetLang) ADD_TEST(TargetName ${CMAKE_CTEST_COMMAND} --build-and-test @@ -92,66 +101,6 @@ IF(BUILD_TESTING) --test-command working ) - ADD_TEST(FindPackageTest ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindPackageTest" - "${CMake_BINARY_DIR}/Tests/FindPackageTest" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project FindPackageTest - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --test-command FindPackageTest) - - ADD_TEST(SystemInformation ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/SystemInformation" - "${CMake_BINARY_DIR}/Tests/SystemInformation" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project DumpInformation - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --test-command DumpInformation) - - ADD_TEST(StringFileTest ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/StringFileTest" - "${CMake_BINARY_DIR}/Tests/StringFileTest" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project StringFileTest - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --test-command StringFileTest) - - ADD_TEST(MathTest ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/MathTest" - "${CMake_BINARY_DIR}/Tests/MathTest" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project MathTest - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --test-command MathTestExec) - - ADD_TEST(TryCompile ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/TryCompile" - "${CMake_BINARY_DIR}/Tests/TryCompile" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project TryCompile - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --test-command TryCompile) - - ADD_TEST(simple ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Simple" - "${CMake_BINARY_DIR}/Tests/Simple" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project Simple - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --test-command simple) - ADD_TEST(SimpleExclude ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SimpleExclude" @@ -188,46 +137,6 @@ IF(BUILD_TESTING) --test-command "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple") - ADD_TEST(PreOrder ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/PreOrder" - "${CMake_BINARY_DIR}/Tests/PreOrder" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project PreOrder - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --test-command simple) - - ADD_TEST(conly ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/COnly" - "${CMake_BINARY_DIR}/Tests/COnly" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project conly - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --test-command conly) - - ADD_TEST(CxxOnly ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/CxxOnly" - "${CMake_BINARY_DIR}/Tests/CxxOnly" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project cxxonly - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --test-command cxxonly) - - ADD_TEST(NewlineArgs ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/NewlineArgs" - "${CMake_BINARY_DIR}/Tests/NewlineArgs" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project newlineargs - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --test-command cxxonly) - ADD_TEST(MacroTest ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MacroTest" @@ -338,16 +247,6 @@ IF(BUILD_TESTING) -DCMAKE_TEST_SYSTEM_LIBRARIES:BOOL=${CMAKE_TEST_SYSTEM_LIBRARIES} --test-command complex) - ADD_TEST(SetLang ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/SetLang" - "${CMake_BINARY_DIR}/Tests/SetLang" - --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-project SetLang - --test-command bar) - # ADD_TEST(ConvLibrary ${CMAKE_CTEST_COMMAND} # --build-and-test # "${CMake_SOURCE_DIR}/Tests/ConvLibrary" @@ -789,15 +688,7 @@ IF(BUILD_TESTING) --test-command ${BundleTestInstallDir}/Application/SecondBundleExe.app/Contents/MacOS/SecondBundleExe) - ADD_TEST(objc++ ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/ObjC++" - "${CMake_BINARY_DIR}/Tests/ObjC++" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-project objc++ - --test-command objc++ - ) + ADD_TEST_MACRO(ObjC++ ObjC++) ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX) IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS) @@ -947,3 +838,5 @@ IF(BUILD_TESTING) ENDIF(UNIX) ENDIF(BUILD_TESTING) + +ADD_SUBDIRECTORY(CMakeTests) diff --git a/Tests/COnly/CMakeLists.txt b/Tests/COnly/CMakeLists.txt index 020a842..6b28fec 100644 --- a/Tests/COnly/CMakeLists.txt +++ b/Tests/COnly/CMakeLists.txt @@ -1,11 +1,11 @@ # a simple C only test case -project (conly C) +project (COnly C) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") add_library(testc1 STATIC libc1.c) add_library(testc2 SHARED libc2.c) -add_executable (conly conly.c foo.c foo.h) -target_link_libraries(conly testc1 testc2) +add_executable (COnly conly.c foo.c foo.h) +target_link_libraries(COnly testc1 testc2) string(ASCII 35 32 67 77 97 107 101 ASCII_STRING) message(STATUS "String: ${ASCII_STRING}") diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index cf31474..bfc8271 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -1,8 +1,8 @@ # a simple CXX only test case -project (cxxonly CXX) +project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") add_library(testcxx1 STATIC libcxx1.cxx) add_library(testcxx2 SHARED libcxx2.cxx) -add_executable (cxxonly cxxonly.cxx) -target_link_libraries(cxxonly testcxx1 testcxx2) +add_executable (CxxOnly cxxonly.cxx) +target_link_libraries(CxxOnly testcxx1 testcxx2) diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt index ef6c4f9..bff35f7 100644 --- a/Tests/MathTest/CMakeLists.txt +++ b/Tests/MathTest/CMakeLists.txt @@ -24,5 +24,5 @@ CONFIGURE_FILE( @ONLY) INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}") -ADD_EXECUTABLE(MathTestExec MathTestExec.cxx) +ADD_EXECUTABLE(MathTest MathTestExec.cxx) diff --git a/Tests/NewlineArgs/CMakeLists.txt b/Tests/NewlineArgs/CMakeLists.txt index ed9a341..eb618a3 100644 --- a/Tests/NewlineArgs/CMakeLists.txt +++ b/Tests/NewlineArgs/CMakeLists.txt @@ -1,15 +1,15 @@ # a simple CXX only test case -project (newlineargs CXX) +project (NewlineArgs CXX) add_definitions("-DTEST_FLAG_1 -DTEST_FLAG_2") -include_directories(" ${newlineargs_BINARY_DIR} - ${newlineargs_SOURCE_DIR} ") +include_directories(" ${NewlineArgs_BINARY_DIR} + ${NewlineArgs_SOURCE_DIR} ") -configure_file("${newlineargs_SOURCE_DIR}/libcxx2.h.in" - "${newlineargs_BINARY_DIR}/libcxx2.h") +configure_file("${NewlineArgs_SOURCE_DIR}/libcxx2.h.in" + "${NewlineArgs_BINARY_DIR}/libcxx2.h") add_library(testcxx1 libcxx1.cxx) -add_executable (cxxonly cxxonly.cxx) -target_link_libraries(cxxonly testcxx1) +add_executable (NewlineArgs cxxonly.cxx) +target_link_libraries(NewlineArgs testcxx1) diff --git a/Tests/ObjC++/CMakeLists.txt b/Tests/ObjC++/CMakeLists.txt index a7b46eb..c892bd0 100644 --- a/Tests/ObjC++/CMakeLists.txt +++ b/Tests/ObjC++/CMakeLists.txt @@ -1,6 +1,6 @@ # a simple objc++ test case that uses Cocoa framework -PROJECT (objc++) +PROJECT (ObjC++) -ADD_EXECUTABLE (objc++ objc++.mm) -TARGET_LINK_LIBRARIES(objc++ "-framework Cocoa") +ADD_EXECUTABLE (ObjC++ objc++.mm) +TARGET_LINK_LIBRARIES(ObjC++ "-framework Cocoa") diff --git a/Tests/PreOrder/CMakeLists.txt b/Tests/PreOrder/CMakeLists.txt index dce1d92..29720e4 100644 --- a/Tests/PreOrder/CMakeLists.txt +++ b/Tests/PreOrder/CMakeLists.txt @@ -2,5 +2,5 @@ PROJECT (PreOrder) SET(CMAKE_IGNORE_DEPENDENCIES_ORDERING 1) ADD_SUBDIRECTORY(Library) -ADD_EXECUTABLE (simple simple.cxx) -TARGET_LINK_LIBRARIES(simple simpleLib) +ADD_EXECUTABLE (PreOrder simple.cxx) +TARGET_LINK_LIBRARIES(PreOrder simpleLib) diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt index f3ed86e..dda13c1 100644 --- a/Tests/SetLang/CMakeLists.txt +++ b/Tests/SetLang/CMakeLists.txt @@ -3,7 +3,7 @@ project(SetLang) # force this to be verbose so I can debug a dashboard entry SET(CMAKE_VERBOSE_MAKEFILE 1) add_library(foo foo.c) -add_executable(bar bar.c) +add_executable(SetLang bar.c) set_source_files_properties(foo.c bar.c PROPERTIES LANGUAGE CXX) -target_link_libraries(bar foo) -set_target_properties(bar PROPERTIES LINKER_LANGUAGE CXX) +target_link_libraries(SetLang foo) +set_target_properties(SetLang PROPERTIES LINKER_LANGUAGE CXX) diff --git a/Tests/Simple/CMakeLists.txt b/Tests/Simple/CMakeLists.txt index c098224..dc965a7 100644 --- a/Tests/Simple/CMakeLists.txt +++ b/Tests/Simple/CMakeLists.txt @@ -1,7 +1,7 @@ # a simple test case project (Simple) -add_executable (simple simple.cxx) +add_executable (Simple simple.cxx) add_library (simpleLib STATIC simpleLib.cxx @@ -9,9 +9,9 @@ add_library (simpleLib STATIC simpleWe.cpp ) -target_link_libraries (simple simpleLib) +target_link_libraries (Simple simpleLib) # make sure optimized libs are not used by debug builds if(CMAKE_BUILD_TYPE MATCHES Debug) - target_link_libraries(simple optimized c:/not/here.lib ) + target_link_libraries(Simple optimized c:/not/here.lib ) endif(CMAKE_BUILD_TYPE MATCHES Debug) diff --git a/Tests/SystemInformation/CMakeLists.txt b/Tests/SystemInformation/CMakeLists.txt index 76907b0..5e015ce 100644 --- a/Tests/SystemInformation/CMakeLists.txt +++ b/Tests/SystemInformation/CMakeLists.txt @@ -1,17 +1,17 @@ -PROJECT(DumpInformation) +PROJECT(SystemInformation) INCLUDE_DIRECTORIES("This does not exists") GET_DIRECTORY_PROPERTY(incl INCLUDE_DIRECTORIES) -SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${DumpInformation_BINARY_DIR};${DumpInformation_SOURCE_DIR}") +SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${SystemInformation_BINARY_DIR};${SystemInformation_SOURCE_DIR}") MESSAGE("To prevent CTest from stripping output, you have to display: CTEST_FULL_OUTPUT") -CONFIGURE_FILE(${DumpInformation_SOURCE_DIR}/SystemInformation.in -${DumpInformation_BINARY_DIR}/SystemInformation.out) -CONFIGURE_FILE(${DumpInformation_SOURCE_DIR}/DumpInformation.h.in -${DumpInformation_BINARY_DIR}/DumpInformation.h) -ADD_EXECUTABLE(DumpInformation DumpInformation.cxx) +CONFIGURE_FILE(${SystemInformation_SOURCE_DIR}/SystemInformation.in +${SystemInformation_BINARY_DIR}/SystemInformation.out) +CONFIGURE_FILE(${SystemInformation_SOURCE_DIR}/DumpInformation.h.in +${SystemInformation_BINARY_DIR}/DumpInformation.h) +ADD_EXECUTABLE(SystemInformation DumpInformation.cxx) MACRO(FOO args) MESSAGE("Test macro") diff --git a/Tests/TarTest/CMakeLists.txt b/Tests/TarTest/CMakeLists.txt index b48bd62..cfb26bf 100644 --- a/Tests/TarTest/CMakeLists.txt +++ b/Tests/TarTest/CMakeLists.txt @@ -1,4 +1,4 @@ -PROJECT(TestTar) +PROJECT(TarTest) # this is macro that we will be running MACRO(EXEC_TAR_COMMAND DIR ARGS) @@ -54,5 +54,5 @@ ENDMACRO(CHECK_DIR_STRUCTURE) CHECK_DIR_STRUCTURE("${CMAKE_CURRENT_BINARY_DIR}/test_output_tar/tar_dir") -ADD_EXECUTABLE(TestTarExec TestTarExec.cxx) +ADD_EXECUTABLE(TarTest TestTarExec.cxx) -- cgit v0.12