Commit 2208231a authored by Ken Martin's avatar Ken Martin

ENH: some more CMakeList cleanups

parent 0f0a83a5
......@@ -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}"
......
# 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)
# 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}")
# 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)
......@@ -24,5 +24,5 @@ CONFIGURE_FILE(
@ONLY)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
ADD_EXECUTABLE(MathTestExec MathTestExec.cxx)
ADD_EXECUTABLE(MathTest MathTestExec.cxx)
# 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)
# 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")
......@@ -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)
......@@ -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)
# 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)
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")
......
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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment