diff options
Diffstat (limited to 'Tests')
64 files changed, 850 insertions, 23 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 81ade768c4..fa3ee417d0 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -100,8 +100,9 @@ INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(BEFORE ${Complex_BINARY_DIR} ) +INCLUDE_DIRECTORIES(SYSTEM Library/SystemDir) -INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" "^cmMissing") +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile|test).*$" "^cmMissing") LINK_DIRECTORIES( ${Complex_BINARY_DIR}/Library @@ -271,6 +272,44 @@ ENDWHILE(while_var LESS 1000) SET(SHOULD_BE_ZERO ) SET(SHOULD_BE_ONE 1) + +# test elseif functionality, the mess below tries to catch problem +# of clauses being executed early or late etc +set (RESULT 3) +if (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) +elseif (RESULT EQUAL 3) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + if (NOT ELSEIF_RESULT EQUAL 1) + set (ELSEIF_RESULT 2) + endif (NOT ELSEIF_RESULT EQUAL 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 4) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +else (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +endif (RESULT EQUAL 1) + +if (NOT ELSEIF_RESULT EQUAL 2) + set (ELSEIF_RESULT 0) +endif (NOT ELSEIF_RESULT EQUAL 2) + # # Configure file # (plug vars to #define so that they can be tested) @@ -303,6 +342,7 @@ IF(NOT STRING_REGEX_PASSED) "STRING(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")") ENDIF(NOT STRING_REGEX_PASSED) + # # Create the libs and the main exe # diff --git a/Tests/Complex/Executable/A.cxx b/Tests/Complex/Executable/A.cxx index 7f98319781..0cc995af0d 100644 --- a/Tests/Complex/Executable/A.cxx +++ b/Tests/Complex/Executable/A.cxx @@ -1,4 +1,7 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + int main() { - return 10; + return A(); } diff --git a/Tests/Complex/Executable/A.h b/Tests/Complex/Executable/A.h new file mode 100644 index 0000000000..25c45fcbf8 --- /dev/null +++ b/Tests/Complex/Executable/A.h @@ -0,0 +1,4 @@ +// This header should not be compiled directly but through inclusion +// in A.cxx through A.hh. +extern int A(); +int A() { return 10; } diff --git a/Tests/Complex/Executable/A.hh b/Tests/Complex/Executable/A.hh new file mode 100644 index 0000000000..e6bab022e7 --- /dev/null +++ b/Tests/Complex/Executable/A.hh @@ -0,0 +1,2 @@ +// This header should not be compiled directly but through inclusion in A.cxx +#include "A.h" diff --git a/Tests/Complex/Executable/A.txt b/Tests/Complex/Executable/A.txt new file mode 100644 index 0000000000..8ee9462be0 --- /dev/null +++ b/Tests/Complex/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index dae57753e2..28db54ea5c 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -19,7 +19,7 @@ ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) -ADD_EXECUTABLE(A A.cxx) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) ADD_EXECUTABLE(complex complex testcflags.c ) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c) ADD_EXECUTABLE(complex.file complex.file.cxx) @@ -37,6 +37,12 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +# Test linking to static lib when a shared lib has the same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC) + TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + # can we get the path to a source file GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION) IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") @@ -95,6 +101,14 @@ ADD_CUSTOM_COMMAND( DEPENDS ${CMAKE_COMMAND} ) +# Test creating an executable that is not built by default. +ADD_EXECUTABLE(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx) +TARGET_LINK_LIBRARIES(notInAllExe notInAllLib) + +# Test creating a custom target that builds not-in-all targets. +ADD_CUSTOM_TARGET(notInAllCustom) +ADD_DEPENDENCIES(notInAllCustom notInAllExe) + # # Output the files required by 'complex' to a file. # @@ -104,6 +118,11 @@ ADD_CUSTOM_COMMAND( # ADD_SUBDIRECTORY(Temp) +IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + ADD_EXECUTABLE(testSystemDir testSystemDir.cxx) + SET_TARGET_PROPERTIES(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror") +ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + # # Extra coverage.Not used. # diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 816414c7cc..273e8a267a 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -23,6 +23,12 @@ extern "C" { #include <string.h> #endif +#ifdef COMPLEX_TEST_LINK_STATIC +extern "C" +{ + int TestLinkGetType(); +} +#endif int cm_passed = 0; int cm_failed = 0; @@ -102,7 +108,7 @@ bool TestLibraryOrder(bool shouldFail) orderLibs.DebugOn(); orderLibs.AddLinkExtension(".so"); orderLibs.AddLinkExtension(".a"); - orderLibs.SetLinkPrefix("lib"); + orderLibs.AddLinkPrefix("lib"); cmTargetManifest manifest; orderLibs.SetLinkInformation("test", linkLibraries, linkDirectories, manifest, ""); @@ -438,6 +444,12 @@ int main() cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES"); #endif +#ifdef ELSEIF_RESULT + cmPassed("ELSEIF did work"); +#else + cmFailed("ELSEIF did not work"); +#endif + if(file2() != 1) { cmFailed("Call to file2 function from library failed."); @@ -1270,7 +1282,18 @@ int main() // Test the generated file stream. TestCMGeneratedFileSTream(); #endif - + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared failed."); + } +#endif + // ---------------------------------------------------------------------- // Summary diff --git a/Tests/Complex/Executable/notInAllExe.cxx b/Tests/Complex/Executable/notInAllExe.cxx new file mode 100644 index 0000000000..70275cd513 --- /dev/null +++ b/Tests/Complex/Executable/notInAllExe.cxx @@ -0,0 +1,10 @@ +extern int notInAllLibFunc(); + +int main() +{ + return notInAllLibFunc(); +} + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/Complex/Executable/testSystemDir.cxx b/Tests/Complex/Executable/testSystemDir.cxx new file mode 100644 index 0000000000..e4815c679a --- /dev/null +++ b/Tests/Complex/Executable/testSystemDir.cxx @@ -0,0 +1,3 @@ +#include <testSystemDir.h> + +int main() { return foo(); } diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index 3eeb1ea0fd..b0ea7a3a15 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -53,6 +53,13 @@ ELSE(${FOO_BAR_VAR} MATCHES "BAR") MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}") ENDIF(${FOO_BAR_VAR} MATCHES "BAR") +# Create static and shared lib of same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c) + ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c) + SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared + PROPERTIES OUTPUT_NAME CMakeTestLink CLEAN_DIRECT_OUTPUT 1) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) # # Attach pre-build/pre-link/post-build custom-commands to the lib. @@ -96,3 +103,27 @@ SET_SOURCE_FILES_PROPERTIES(file2 PROPERTIES ABSTRACT 1) INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h) INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) +# Test creating a library that is not built by default. +ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) + +# Test generation of preprocessed sources. +IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) + IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) + # Skip running this part of the test on certain platforms + # until they are fixed. + SET(MAYBE_ALL ALL) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_COUNT) + IF(ARCH_COUNT GREATER 1) + # OSX does not support preprocessing more than one architecture. + SET(MAYBE_ALL) + ENDIF(ARCH_COUNT GREATER 1) + + # Custom target to try preprocessing invocation. + ADD_CUSTOM_TARGET(test_preprocess ${MAYBE_ALL} + COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + ENDIF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) +ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) diff --git a/Tests/Complex/Library/SystemDir/testSystemDir.h b/Tests/Complex/Library/SystemDir/testSystemDir.h new file mode 100644 index 0000000000..73be3538ef --- /dev/null +++ b/Tests/Complex/Library/SystemDir/testSystemDir.h @@ -0,0 +1,2 @@ +// Purposely leave off the return type to create a warning. +foo() { return 0; } diff --git a/Tests/Complex/Library/TestLink.c b/Tests/Complex/Library/TestLink.c new file mode 100644 index 0000000000..25dee082f4 --- /dev/null +++ b/Tests/Complex/Library/TestLink.c @@ -0,0 +1,8 @@ +int TestLinkGetType() +{ +#ifdef CMakeTestLinkShared_EXPORTS + return 0; +#else + return 1; +#endif +} diff --git a/Tests/Complex/Library/notInAllLib.cxx b/Tests/Complex/Library/notInAllLib.cxx new file mode 100644 index 0000000000..5d928f44a6 --- /dev/null +++ b/Tests/Complex/Library/notInAllLib.cxx @@ -0,0 +1,5 @@ +int notInAllLibFunc() { return 0; } + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/Complex/Library/test_preprocess.cmake b/Tests/Complex/Library/test_preprocess.cmake new file mode 100644 index 0000000000..d2d9fc652a --- /dev/null +++ b/Tests/Complex/Library/test_preprocess.cmake @@ -0,0 +1,7 @@ +SET(TEST_FILE CMakeFiles/create_file.dir/create_file.i) +FILE(READ ${TEST_FILE} CONTENTS) +IF("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(STATUS "${TEST_FILE} created successfully!") +ELSE("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(FATAL_ERROR "${TEST_FILE} creation failed!") +ENDIF("${CONTENTS}" MATCHES "Unable to close") diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in index c8600cb203..0b1e181a30 100644 --- a/Tests/Complex/cmTestConfigure.h.in +++ b/Tests/Complex/cmTestConfigure.h.in @@ -77,3 +77,6 @@ #define CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_MODULE_PREFIX}" #define CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}" + +// test elseif +#cmakedefine ELSEIF_RESULT diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 81ade768c4..fa3ee417d0 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -100,8 +100,9 @@ INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(BEFORE ${Complex_BINARY_DIR} ) +INCLUDE_DIRECTORIES(SYSTEM Library/SystemDir) -INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" "^cmMissing") +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile|test).*$" "^cmMissing") LINK_DIRECTORIES( ${Complex_BINARY_DIR}/Library @@ -271,6 +272,44 @@ ENDWHILE(while_var LESS 1000) SET(SHOULD_BE_ZERO ) SET(SHOULD_BE_ONE 1) + +# test elseif functionality, the mess below tries to catch problem +# of clauses being executed early or late etc +set (RESULT 3) +if (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) +elseif (RESULT EQUAL 3) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + if (NOT ELSEIF_RESULT EQUAL 1) + set (ELSEIF_RESULT 2) + endif (NOT ELSEIF_RESULT EQUAL 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 4) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +else (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +endif (RESULT EQUAL 1) + +if (NOT ELSEIF_RESULT EQUAL 2) + set (ELSEIF_RESULT 0) +endif (NOT ELSEIF_RESULT EQUAL 2) + # # Configure file # (plug vars to #define so that they can be tested) @@ -303,6 +342,7 @@ IF(NOT STRING_REGEX_PASSED) "STRING(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")") ENDIF(NOT STRING_REGEX_PASSED) + # # Create the libs and the main exe # diff --git a/Tests/ComplexOneConfig/Executable/A.cxx b/Tests/ComplexOneConfig/Executable/A.cxx index 7f98319781..0cc995af0d 100644 --- a/Tests/ComplexOneConfig/Executable/A.cxx +++ b/Tests/ComplexOneConfig/Executable/A.cxx @@ -1,4 +1,7 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + int main() { - return 10; + return A(); } diff --git a/Tests/ComplexOneConfig/Executable/A.h b/Tests/ComplexOneConfig/Executable/A.h new file mode 100644 index 0000000000..25c45fcbf8 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.h @@ -0,0 +1,4 @@ +// This header should not be compiled directly but through inclusion +// in A.cxx through A.hh. +extern int A(); +int A() { return 10; } diff --git a/Tests/ComplexOneConfig/Executable/A.hh b/Tests/ComplexOneConfig/Executable/A.hh new file mode 100644 index 0000000000..e6bab022e7 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.hh @@ -0,0 +1,2 @@ +// This header should not be compiled directly but through inclusion in A.cxx +#include "A.h" diff --git a/Tests/ComplexOneConfig/Executable/A.txt b/Tests/ComplexOneConfig/Executable/A.txt new file mode 100644 index 0000000000..8ee9462be0 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index dae57753e2..28db54ea5c 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -19,7 +19,7 @@ ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) -ADD_EXECUTABLE(A A.cxx) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) ADD_EXECUTABLE(complex complex testcflags.c ) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c) ADD_EXECUTABLE(complex.file complex.file.cxx) @@ -37,6 +37,12 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +# Test linking to static lib when a shared lib has the same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC) + TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + # can we get the path to a source file GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION) IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") @@ -95,6 +101,14 @@ ADD_CUSTOM_COMMAND( DEPENDS ${CMAKE_COMMAND} ) +# Test creating an executable that is not built by default. +ADD_EXECUTABLE(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx) +TARGET_LINK_LIBRARIES(notInAllExe notInAllLib) + +# Test creating a custom target that builds not-in-all targets. +ADD_CUSTOM_TARGET(notInAllCustom) +ADD_DEPENDENCIES(notInAllCustom notInAllExe) + # # Output the files required by 'complex' to a file. # @@ -104,6 +118,11 @@ ADD_CUSTOM_COMMAND( # ADD_SUBDIRECTORY(Temp) +IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + ADD_EXECUTABLE(testSystemDir testSystemDir.cxx) + SET_TARGET_PROPERTIES(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror") +ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + # # Extra coverage.Not used. # diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 816414c7cc..273e8a267a 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -23,6 +23,12 @@ extern "C" { #include <string.h> #endif +#ifdef COMPLEX_TEST_LINK_STATIC +extern "C" +{ + int TestLinkGetType(); +} +#endif int cm_passed = 0; int cm_failed = 0; @@ -102,7 +108,7 @@ bool TestLibraryOrder(bool shouldFail) orderLibs.DebugOn(); orderLibs.AddLinkExtension(".so"); orderLibs.AddLinkExtension(".a"); - orderLibs.SetLinkPrefix("lib"); + orderLibs.AddLinkPrefix("lib"); cmTargetManifest manifest; orderLibs.SetLinkInformation("test", linkLibraries, linkDirectories, manifest, ""); @@ -438,6 +444,12 @@ int main() cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES"); #endif +#ifdef ELSEIF_RESULT + cmPassed("ELSEIF did work"); +#else + cmFailed("ELSEIF did not work"); +#endif + if(file2() != 1) { cmFailed("Call to file2 function from library failed."); @@ -1270,7 +1282,18 @@ int main() // Test the generated file stream. TestCMGeneratedFileSTream(); #endif - + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared failed."); + } +#endif + // ---------------------------------------------------------------------- // Summary diff --git a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx new file mode 100644 index 0000000000..70275cd513 --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx @@ -0,0 +1,10 @@ +extern int notInAllLibFunc(); + +int main() +{ + return notInAllLibFunc(); +} + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/ComplexOneConfig/Executable/testSystemDir.cxx b/Tests/ComplexOneConfig/Executable/testSystemDir.cxx new file mode 100644 index 0000000000..e4815c679a --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/testSystemDir.cxx @@ -0,0 +1,3 @@ +#include <testSystemDir.h> + +int main() { return foo(); } diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index 3eeb1ea0fd..b0ea7a3a15 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -53,6 +53,13 @@ ELSE(${FOO_BAR_VAR} MATCHES "BAR") MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}") ENDIF(${FOO_BAR_VAR} MATCHES "BAR") +# Create static and shared lib of same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c) + ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c) + SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared + PROPERTIES OUTPUT_NAME CMakeTestLink CLEAN_DIRECT_OUTPUT 1) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) # # Attach pre-build/pre-link/post-build custom-commands to the lib. @@ -96,3 +103,27 @@ SET_SOURCE_FILES_PROPERTIES(file2 PROPERTIES ABSTRACT 1) INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h) INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) +# Test creating a library that is not built by default. +ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) + +# Test generation of preprocessed sources. +IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) + IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) + # Skip running this part of the test on certain platforms + # until they are fixed. + SET(MAYBE_ALL ALL) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_COUNT) + IF(ARCH_COUNT GREATER 1) + # OSX does not support preprocessing more than one architecture. + SET(MAYBE_ALL) + ENDIF(ARCH_COUNT GREATER 1) + + # Custom target to try preprocessing invocation. + ADD_CUSTOM_TARGET(test_preprocess ${MAYBE_ALL} + COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + ENDIF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) +ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) diff --git a/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h b/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h new file mode 100644 index 0000000000..73be3538ef --- /dev/null +++ b/Tests/ComplexOneConfig/Library/SystemDir/testSystemDir.h @@ -0,0 +1,2 @@ +// Purposely leave off the return type to create a warning. +foo() { return 0; } diff --git a/Tests/ComplexOneConfig/Library/TestLink.c b/Tests/ComplexOneConfig/Library/TestLink.c new file mode 100644 index 0000000000..25dee082f4 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/TestLink.c @@ -0,0 +1,8 @@ +int TestLinkGetType() +{ +#ifdef CMakeTestLinkShared_EXPORTS + return 0; +#else + return 1; +#endif +} diff --git a/Tests/ComplexOneConfig/Library/notInAllLib.cxx b/Tests/ComplexOneConfig/Library/notInAllLib.cxx new file mode 100644 index 0000000000..5d928f44a6 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/notInAllLib.cxx @@ -0,0 +1,5 @@ +int notInAllLibFunc() { return 0; } + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/ComplexOneConfig/Library/test_preprocess.cmake b/Tests/ComplexOneConfig/Library/test_preprocess.cmake new file mode 100644 index 0000000000..d2d9fc652a --- /dev/null +++ b/Tests/ComplexOneConfig/Library/test_preprocess.cmake @@ -0,0 +1,7 @@ +SET(TEST_FILE CMakeFiles/create_file.dir/create_file.i) +FILE(READ ${TEST_FILE} CONTENTS) +IF("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(STATUS "${TEST_FILE} created successfully!") +ELSE("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(FATAL_ERROR "${TEST_FILE} creation failed!") +ENDIF("${CONTENTS}" MATCHES "Unable to close") diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in index c8600cb203..0b1e181a30 100644 --- a/Tests/ComplexOneConfig/cmTestConfigure.h.in +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -77,3 +77,6 @@ #define CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_MODULE_PREFIX}" #define CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}" + +// test elseif +#cmakedefine ELSEIF_RESULT diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt index 81ade768c4..fa3ee417d0 100644 --- a/Tests/ComplexRelativePaths/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -100,8 +100,9 @@ INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(BEFORE ${Complex_BINARY_DIR} ) +INCLUDE_DIRECTORIES(SYSTEM Library/SystemDir) -INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" "^cmMissing") +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile|test).*$" "^cmMissing") LINK_DIRECTORIES( ${Complex_BINARY_DIR}/Library @@ -271,6 +272,44 @@ ENDWHILE(while_var LESS 1000) SET(SHOULD_BE_ZERO ) SET(SHOULD_BE_ONE 1) + +# test elseif functionality, the mess below tries to catch problem +# of clauses being executed early or late etc +set (RESULT 3) +if (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) +elseif (RESULT EQUAL 3) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + if (NOT ELSEIF_RESULT EQUAL 1) + set (ELSEIF_RESULT 2) + endif (NOT ELSEIF_RESULT EQUAL 1) + endif (RESULT EQUAL 2) +elseif (RESULT EQUAL 4) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +else (RESULT EQUAL 1) + if (RESULT EQUAL 2) + set (ELSEIF_RESULT 1) + elseif (RESULT EQUAL 3) + set (ELSEIF_RESULT 1) + endif (RESULT EQUAL 2) +endif (RESULT EQUAL 1) + +if (NOT ELSEIF_RESULT EQUAL 2) + set (ELSEIF_RESULT 0) +endif (NOT ELSEIF_RESULT EQUAL 2) + # # Configure file # (plug vars to #define so that they can be tested) @@ -303,6 +342,7 @@ IF(NOT STRING_REGEX_PASSED) "STRING(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")") ENDIF(NOT STRING_REGEX_PASSED) + # # Create the libs and the main exe # diff --git a/Tests/ComplexRelativePaths/Executable/A.cxx b/Tests/ComplexRelativePaths/Executable/A.cxx index 7f98319781..0cc995af0d 100644 --- a/Tests/ComplexRelativePaths/Executable/A.cxx +++ b/Tests/ComplexRelativePaths/Executable/A.cxx @@ -1,4 +1,7 @@ +// Include code from a header that should not be compiled separately. +#include "A.hh" + int main() { - return 10; + return A(); } diff --git a/Tests/ComplexRelativePaths/Executable/A.h b/Tests/ComplexRelativePaths/Executable/A.h new file mode 100644 index 0000000000..25c45fcbf8 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/A.h @@ -0,0 +1,4 @@ +// This header should not be compiled directly but through inclusion +// in A.cxx through A.hh. +extern int A(); +int A() { return 10; } diff --git a/Tests/ComplexRelativePaths/Executable/A.hh b/Tests/ComplexRelativePaths/Executable/A.hh new file mode 100644 index 0000000000..e6bab022e7 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/A.hh @@ -0,0 +1,2 @@ +// This header should not be compiled directly but through inclusion in A.cxx +#include "A.h" diff --git a/Tests/ComplexRelativePaths/Executable/A.txt b/Tests/ComplexRelativePaths/Executable/A.txt new file mode 100644 index 0000000000..8ee9462be0 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index dae57753e2..28db54ea5c 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -19,7 +19,7 @@ ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) -ADD_EXECUTABLE(A A.cxx) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) ADD_EXECUTABLE(complex complex testcflags.c ) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c) ADD_EXECUTABLE(complex.file complex.file.cxx) @@ -37,6 +37,12 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +# Test linking to static lib when a shared lib has the same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_DEFINITIONS(-DCOMPLEX_TEST_LINK_STATIC) + TARGET_LINK_LIBRARIES(complex CMakeTestLinkStatic) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + # can we get the path to a source file GET_SOURCE_FILE_PROPERTY(A_LOCATION A.cxx LOCATION) IF ("${A_LOCATION}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/A.cxx") @@ -95,6 +101,14 @@ ADD_CUSTOM_COMMAND( DEPENDS ${CMAKE_COMMAND} ) +# Test creating an executable that is not built by default. +ADD_EXECUTABLE(notInAllExe EXCLUDE_FROM_ALL notInAllExe.cxx) +TARGET_LINK_LIBRARIES(notInAllExe notInAllLib) + +# Test creating a custom target that builds not-in-all targets. +ADD_CUSTOM_TARGET(notInAllCustom) +ADD_DEPENDENCIES(notInAllCustom notInAllExe) + # # Output the files required by 'complex' to a file. # @@ -104,6 +118,11 @@ ADD_CUSTOM_COMMAND( # ADD_SUBDIRECTORY(Temp) +IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + ADD_EXECUTABLE(testSystemDir testSystemDir.cxx) + SET_TARGET_PROPERTIES(testSystemDir PROPERTIES COMPILE_FLAGS "-Werror") +ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + # # Extra coverage.Not used. # diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index 816414c7cc..273e8a267a 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -23,6 +23,12 @@ extern "C" { #include <string.h> #endif +#ifdef COMPLEX_TEST_LINK_STATIC +extern "C" +{ + int TestLinkGetType(); +} +#endif int cm_passed = 0; int cm_failed = 0; @@ -102,7 +108,7 @@ bool TestLibraryOrder(bool shouldFail) orderLibs.DebugOn(); orderLibs.AddLinkExtension(".so"); orderLibs.AddLinkExtension(".a"); - orderLibs.SetLinkPrefix("lib"); + orderLibs.AddLinkPrefix("lib"); cmTargetManifest manifest; orderLibs.SetLinkInformation("test", linkLibraries, linkDirectories, manifest, ""); @@ -438,6 +444,12 @@ int main() cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES"); #endif +#ifdef ELSEIF_RESULT + cmPassed("ELSEIF did work"); +#else + cmFailed("ELSEIF did not work"); +#endif + if(file2() != 1) { cmFailed("Call to file2 function from library failed."); @@ -1270,7 +1282,18 @@ int main() // Test the generated file stream. TestCMGeneratedFileSTream(); #endif - + +#ifdef COMPLEX_TEST_LINK_STATIC + if(TestLinkGetType()) + { + cmPassed("Link to static over shared worked."); + } + else + { + cmFailed("Link to static over shared failed."); + } +#endif + // ---------------------------------------------------------------------- // Summary diff --git a/Tests/ComplexRelativePaths/Executable/notInAllExe.cxx b/Tests/ComplexRelativePaths/Executable/notInAllExe.cxx new file mode 100644 index 0000000000..70275cd513 --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/notInAllExe.cxx @@ -0,0 +1,10 @@ +extern int notInAllLibFunc(); + +int main() +{ + return notInAllLibFunc(); +} + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/ComplexRelativePaths/Executable/testSystemDir.cxx b/Tests/ComplexRelativePaths/Executable/testSystemDir.cxx new file mode 100644 index 0000000000..e4815c679a --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/testSystemDir.cxx @@ -0,0 +1,3 @@ +#include <testSystemDir.h> + +int main() { return foo(); } diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index 3eeb1ea0fd..b0ea7a3a15 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -53,6 +53,13 @@ ELSE(${FOO_BAR_VAR} MATCHES "BAR") MESSAGE(SEND_ERROR "SET_TARGET_PROPERTIES or GET_TARGET_PROPERTY failed, FOO_BAR_VAR should be BAR, but is ${FOO_BAR_VAR}") ENDIF(${FOO_BAR_VAR} MATCHES "BAR") +# Create static and shared lib of same name. +IF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) + ADD_LIBRARY(CMakeTestLinkStatic STATIC TestLink.c) + ADD_LIBRARY(CMakeTestLinkShared SHARED TestLink.c) + SET_TARGET_PROPERTIES(CMakeTestLinkStatic CMakeTestLinkShared + PROPERTIES OUTPUT_NAME CMakeTestLink CLEAN_DIRECT_OUTPUT 1) +ENDIF(CMAKE_EXE_LINK_STATIC_CXX_FLAGS) # # Attach pre-build/pre-link/post-build custom-commands to the lib. @@ -96,3 +103,27 @@ SET_SOURCE_FILES_PROPERTIES(file2 PROPERTIES ABSTRACT 1) INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h) INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) +# Test creating a library that is not built by default. +ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) + +# Test generation of preprocessed sources. +IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) + IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) + # Skip running this part of the test on certain platforms + # until they are fixed. + SET(MAYBE_ALL ALL) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES ARCH_COUNT) + IF(ARCH_COUNT GREATER 1) + # OSX does not support preprocessing more than one architecture. + SET(MAYBE_ALL) + ENDIF(ARCH_COUNT GREATER 1) + + # Custom target to try preprocessing invocation. + ADD_CUSTOM_TARGET(test_preprocess ${MAYBE_ALL} + COMMAND ${CMAKE_COMMAND} -E remove CMakeFiles/create_file.dir/create_file.i + COMMAND ${CMAKE_MAKE_PROGRAM} create_file.i + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/test_preprocess.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + ENDIF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) +ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) diff --git a/Tests/ComplexRelativePaths/Library/SystemDir/testSystemDir.h b/Tests/ComplexRelativePaths/Library/SystemDir/testSystemDir.h new file mode 100644 index 0000000000..73be3538ef --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/SystemDir/testSystemDir.h @@ -0,0 +1,2 @@ +// Purposely leave off the return type to create a warning. +foo() { return 0; } diff --git a/Tests/ComplexRelativePaths/Library/TestLink.c b/Tests/ComplexRelativePaths/Library/TestLink.c new file mode 100644 index 0000000000..25dee082f4 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/TestLink.c @@ -0,0 +1,8 @@ +int TestLinkGetType() +{ +#ifdef CMakeTestLinkShared_EXPORTS + return 0; +#else + return 1; +#endif +} diff --git a/Tests/ComplexRelativePaths/Library/notInAllLib.cxx b/Tests/ComplexRelativePaths/Library/notInAllLib.cxx new file mode 100644 index 0000000000..5d928f44a6 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/notInAllLib.cxx @@ -0,0 +1,5 @@ +int notInAllLibFunc() { return 0; } + +#if 1 +# error "This target should not be compiled by ALL." +#endif diff --git a/Tests/ComplexRelativePaths/Library/test_preprocess.cmake b/Tests/ComplexRelativePaths/Library/test_preprocess.cmake new file mode 100644 index 0000000000..d2d9fc652a --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/test_preprocess.cmake @@ -0,0 +1,7 @@ +SET(TEST_FILE CMakeFiles/create_file.dir/create_file.i) +FILE(READ ${TEST_FILE} CONTENTS) +IF("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(STATUS "${TEST_FILE} created successfully!") +ELSE("${CONTENTS}" MATCHES "Unable to close") + MESSAGE(FATAL_ERROR "${TEST_FILE} creation failed!") +ENDIF("${CONTENTS}" MATCHES "Unable to close") diff --git a/Tests/ComplexRelativePaths/cmTestConfigure.h.in b/Tests/ComplexRelativePaths/cmTestConfigure.h.in index c8600cb203..0b1e181a30 100644 --- a/Tests/ComplexRelativePaths/cmTestConfigure.h.in +++ b/Tests/ComplexRelativePaths/cmTestConfigure.h.in @@ -77,3 +77,6 @@ #define CMAKE_SHARED_MODULE_PREFIX "${CMAKE_SHARED_MODULE_PREFIX}" #define CMAKE_SHARED_MODULE_SUFFIX "${CMAKE_SHARED_MODULE_SUFFIX}" + +// test elseif +#cmakedefine ELSEIF_RESULT diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 2fb4725dae..7685031514 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -68,10 +68,12 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/doc1.dvi ) ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h - DEPENDS ${PROJECT_BINARY_DIR}/doc1.dvi COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1.dvi to doc1temp.h." COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.dvi ${PROJECT_BINARY_DIR}/doc1temp.h + ) +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/doc1.h APPEND + DEPENDS ${PROJECT_BINARY_DIR}/doc1.dvi COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1temp.h to doc1.h." COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1temp.h ${PROJECT_BINARY_DIR}/doc1.h @@ -96,6 +98,7 @@ ADD_CUSTOM_TARGET(TDocument ALL COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.h ${PROJECT_BINARY_DIR}/doc2.h DEPENDS ${PROJECT_BINARY_DIR}/doc1.h + COMMENT "Running top-level TDocument commands" ) # Setup a pre- and post-build pair that will fail if not run in the @@ -164,3 +167,78 @@ TARGET_LINK_LIBRARIES(CustomCommand GeneratedHeader) # the CustomCommand executable really needs doc1.h ADD_DEPENDENCIES(CustomCommand TDocument) +############################################################################## +# Test non-trivial command line arguments in custom commands. +SET(EXPECTED_ARGUMENTS) +SET(CHECK_ARGS + c:/posix/path + c:\\windows\\path + 'single-quotes' + single'quote + \"double-quotes\" + double\"quote + "\\;semi-colons\\;" + "semi\\;colon" + `back-ticks` + back`tick + "(parens)" + "(lparen" + "rparen)" + $dollar-signs$ + dollar$sign + &ersands& + amper&sand + @two-ats@ + one@at + "c:/posix/path/with space" + "c:\\windows\\path\\with space" + "'single quotes with space'" + "single'quote with space" + "\"double-quotes with space\"" + "double\"quote with space" + "\\;semi-colons with space\\;" + "semi\\;colon with space" + "`back-ticks` with space" + "back`tick with space" + "(parens) with space" + "(lparen with space" + "rparen) with space" + "$dollar-signs$ with space" + "dollar$sign with space" + "&ersands& with space" + "amper&sand with space" + "@two-ats@ with space" + "one@at with space" + ) +FOREACH(arg ${CHECK_ARGS}) + SET(ARG "${arg}") + STRING(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}") + STRING(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}") + SET(EXPECTED_ARGUMENTS + "${EXPECTED_ARGUMENTS} \"${ARG}\", +") +ENDFOREACH(arg) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in + ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c + @ONLY IMMEDIATE) +ADD_EXECUTABLE(check_command_line + ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c) +ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/command_line_check + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line + ${CHECK_ARGS} + VERBATIM + COMMENT "Checking custom command line escapes (single'quote)" + ) +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/command_line_check + PROPERTIES SYMBOLIC 1) +ADD_CUSTOM_TARGET(do_check_command_line ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check + COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes" + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line + ${CHECK_ARGS} + VERBATIM + COMMENT "Checking custom target command line escapes ($dollar-signs$)" + ) +ADD_DEPENDENCIES(do_check_command_line check_command_line) diff --git a/Tests/CustomCommand/check_command_line.c.in b/Tests/CustomCommand/check_command_line.c.in new file mode 100644 index 0000000000..72b34c7f03 --- /dev/null +++ b/Tests/CustomCommand/check_command_line.c.in @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <string.h> + +const char* expected_arguments[] = +{ +@EXPECTED_ARGUMENTS@ 0 +}; + +int main(int argc, const char* argv[]) +{ + const char** a = argv+1; + const char** e = expected_arguments; + (void)argc; + for(;*a && *e; ++a, ++e) + { + if(strcmp(*a, *e) != 0) + { + fprintf(stderr, "Argument [%s] does not match expected [%s].\n", + *a, *e); + return 1; + } + else + { + /*printf("[%s]\n", *a);*/ + } + } + if(*a || *e) + { + fprintf(stderr, "Number of arguments does not match expected.\n"); + return 1; + } + printf("Command line escapes work!\n"); + return 0; +} diff --git a/Tests/OutOfBinary/CMakeLists.txt b/Tests/OutOfBinary/CMakeLists.txt new file mode 100644 index 0000000000..fcf90bd0d0 --- /dev/null +++ b/Tests/OutOfBinary/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_LIBRARY(outlib outlib.c) + diff --git a/Tests/OutOfBinary/outlib.c b/Tests/OutOfBinary/outlib.c new file mode 100644 index 0000000000..9ea579b7ae --- /dev/null +++ b/Tests/OutOfBinary/outlib.c @@ -0,0 +1,2 @@ +int outlib() { return 456; } + diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index 02ab4f6ea2..bbdaa557e9 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -4,7 +4,7 @@ IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") SET(BUILD_SHARED_LIBS 1) ADD_LIBRARY(testlib testlib.cxx) ADD_EXECUTABLE (simple simple.cxx ../simple.cxx) - TARGET_LINK_LIBRARIES(simple testlib) + TARGET_LINK_LIBRARIES(simple testlib outlib) ENDIF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") # test getting a definition from a subdir diff --git a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx index c883ddcb5d..124b7f98e1 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx +++ b/Tests/OutOfSource/OutOfSourceSubdir/simple.cxx @@ -5,9 +5,10 @@ #include "testdp.h" extern int simple(); +extern "C" int outlib(); int main () -{ +{ if(simple() != 123) { return -3; @@ -21,5 +22,9 @@ int main () { return -1; } + if(outlib() != 456) + { + return -4; + } return 0; } diff --git a/Tests/OutOfSource/SubDir/CMakeLists.txt b/Tests/OutOfSource/SubDir/CMakeLists.txt index 47fa54b6dc..4fc48e13d2 100644 --- a/Tests/OutOfSource/SubDir/CMakeLists.txt +++ b/Tests/OutOfSource/SubDir/CMakeLists.txt @@ -1,3 +1,8 @@ PROJECT(ANOTHER_PROJ) + +# subdir to an out of source and out of binary directory +ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/../OutOfBinary + ${OutOfSource_BINARY_DIR}/../OutOfBinary) + # subdir to a sibling dir ADD_SUBDIRECTORY(${OutOfSource_SOURCE_DIR}/${KEN}OutOfSourceSubdir OutOfSourceSubdir ) diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index c2de5b1c6c..3d8cdb8e18 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -80,6 +80,42 @@ IF(STAGE2) MESSAGE(FATAL_ERROR "Release-configuration file installed for Debug!") ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + # Check for failure of directory installation. + IF(WIN32 AND NOT CYGWIN) + SET(BAT .bat) + ELSE(WIN32 AND NOT CYGWIN) + SET(BAT) + ENDIF(WIN32 AND NOT CYGWIN) + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + MESSAGE(FATAL_ERROR "Directory installation did not install TSD.h") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + EXECUTE_PROCESS( + COMMAND "${CMAKE_INSTALL_PREFIX}/MyTest/share/sample_script${BAT}" + RESULT_VARIABLE SAMPLE_SCRIPT_RESULT + OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT + ) + IF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + MESSAGE(FATAL_ERROR "Sample script failed: [${SAMPLE_SCRIPT_RESULT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + IF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + MESSAGE(FATAL_ERROR "Bad sample script output: [${SAMPLE_SCRIPT_OUTPUT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + + # Check for failure of empty directory installation. + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + MESSAGE(FATAL_ERROR "Empty directory installation did not install.") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + FILE(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*") + IF(EMPTY_FILES) + MESSAGE(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].") + ENDIF(EMPTY_FILES) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -130,6 +166,9 @@ ELSE(STAGE2) ) INSTALL_FILES(/MyTest/include FILES lib3.h) + # Test optional installation. + INSTALL(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL) + # Test configuration-specific installation. INSTALL(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release DESTINATION MyTest/include/Release @@ -138,6 +177,18 @@ ELSE(STAGE2) DESTINATION MyTest/include/Debug ) + # Test directory installation. + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + INSTALL( + DIRECTORY TestSubDir scripts/ DESTINATION MyTest/share + PATTERN "CVS" EXCLUDE + PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + ) + + # Test empty directory installation. + INSTALL(DIRECTORY DESTINATION MyTest/share/empty) + # Test user-specified install scripts. INSTALL( SCRIPT InstallScript1.cmake @@ -154,7 +205,8 @@ ELSE(STAGE2) ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) - SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3) + SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3 + INSTALL_NAME_DIR @executable_path/../lib) ENDIF(STAGE2) IF(CMAKE_CONFIGURATION_TYPES) @@ -176,6 +228,39 @@ IF(WIN32 AND NOT UNIX) SET(CPACK_GENERATOR TGZ) ENDIF(NOT NSIS_MAKENSIS) ENDIF(WIN32 AND NOT UNIX) +IF(UNIX AND NOT APPLE) + # SET(CPACK_GENERATOR "TGZ;STGZ") + # FIND_PROGRAM(found_compress + # NAMES compress) + # IF(found_compress) + # FIND_PROGRAM(file_command NAMES file) + # IF(NOT file_command) + # set(file_command file) + # ENDIF(NOT file_command) + # EXECUTE_PROCESS(COMMAND ${file_command} ${found_compress} + # OUTPUT_VARIABLE output) + # set(SKIP_TZ FALSE) + # if("${output}" MATCHES "script") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "script") + # if("${output}" MATCHES "dummy.sh") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "dummy.sh") + # if(NOT SKIP_TZ) + # message("compress found and it was not a script") + # message("output from file command: [${output}]") + # SET(CPACK_GENERATOR "${CPACK_GENERATOR};TZ") + # else(NOT SKIP_TZ) + # message("compress found, but it was a script so dont use it") + # message("output from file command: [${output}]") + # endif(NOT SKIP_TZ) + # ENDIF(found_compress) + FIND_PROGRAM(found_bz2 + NAMES bzip2) + IF(found_bz2) + SET(CPACK_GENERATOR "${CPACK_GENERATOR};TBZ2") + ENDIF(found_bz2) +ENDIF(UNIX AND NOT APPLE) SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") SET(CMAKE_INSTALL_MFC_LIBRARIES 1) diff --git a/Tests/SimpleInstall/PackageScript.cmake b/Tests/SimpleInstall/PackageScript.cmake new file mode 100644 index 0000000000..3567a2f43b --- /dev/null +++ b/Tests/SimpleInstall/PackageScript.cmake @@ -0,0 +1,10 @@ +MESSAGE("This is packaging script") +MESSAGE("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt") + +FILE(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt + "${var} \"${${var}}\"\n") +ENDFOREACH(var ${res}) + diff --git a/Tests/SimpleInstall/scripts/.gitattributes b/Tests/SimpleInstall/scripts/.gitattributes new file mode 100644 index 0000000000..5e3db2fb3a --- /dev/null +++ b/Tests/SimpleInstall/scripts/.gitattributes @@ -0,0 +1 @@ +sample_script crlf=input diff --git a/Tests/SimpleInstall/scripts/sample_script b/Tests/SimpleInstall/scripts/sample_script new file mode 100755 index 0000000000..81f9f53153 --- /dev/null +++ b/Tests/SimpleInstall/scripts/sample_script @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Sample Script Output" diff --git a/Tests/SimpleInstall/scripts/sample_script.bat b/Tests/SimpleInstall/scripts/sample_script.bat new file mode 100755 index 0000000000..64a77b5b0f --- /dev/null +++ b/Tests/SimpleInstall/scripts/sample_script.bat @@ -0,0 +1 @@ +@echo Sample Script Output
diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index c2de5b1c6c..3d8cdb8e18 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -80,6 +80,42 @@ IF(STAGE2) MESSAGE(FATAL_ERROR "Release-configuration file installed for Debug!") ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h") + # Check for failure of directory installation. + IF(WIN32 AND NOT CYGWIN) + SET(BAT .bat) + ELSE(WIN32 AND NOT CYGWIN) + SET(BAT) + ENDIF(WIN32 AND NOT CYGWIN) + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + MESSAGE(FATAL_ERROR "Directory installation did not install TSD.h") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + IF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + MESSAGE(FATAL_ERROR "Directory installation installed CVS directory.") + ENDIF(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + EXECUTE_PROCESS( + COMMAND "${CMAKE_INSTALL_PREFIX}/MyTest/share/sample_script${BAT}" + RESULT_VARIABLE SAMPLE_SCRIPT_RESULT + OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT + ) + IF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + MESSAGE(FATAL_ERROR "Sample script failed: [${SAMPLE_SCRIPT_RESULT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_RESULT}" MATCHES "^0$") + IF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + MESSAGE(FATAL_ERROR "Bad sample script output: [${SAMPLE_SCRIPT_OUTPUT}]") + ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output") + + # Check for failure of empty directory installation. + IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + MESSAGE(FATAL_ERROR "Empty directory installation did not install.") + ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty") + FILE(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*") + IF(EMPTY_FILES) + MESSAGE(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].") + ENDIF(EMPTY_FILES) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -130,6 +166,9 @@ ELSE(STAGE2) ) INSTALL_FILES(/MyTest/include FILES lib3.h) + # Test optional installation. + INSTALL(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL) + # Test configuration-specific installation. INSTALL(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release DESTINATION MyTest/include/Release @@ -138,6 +177,18 @@ ELSE(STAGE2) DESTINATION MyTest/include/Debug ) + # Test directory installation. + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS") + FILE(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS") + INSTALL( + DIRECTORY TestSubDir scripts/ DESTINATION MyTest/share + PATTERN "CVS" EXCLUDE + PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + ) + + # Test empty directory installation. + INSTALL(DIRECTORY DESTINATION MyTest/share/empty) + # Test user-specified install scripts. INSTALL( SCRIPT InstallScript1.cmake @@ -154,7 +205,8 @@ ELSE(STAGE2) ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake) - SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3) + SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3 + INSTALL_NAME_DIR @executable_path/../lib) ENDIF(STAGE2) IF(CMAKE_CONFIGURATION_TYPES) @@ -176,6 +228,39 @@ IF(WIN32 AND NOT UNIX) SET(CPACK_GENERATOR TGZ) ENDIF(NOT NSIS_MAKENSIS) ENDIF(WIN32 AND NOT UNIX) +IF(UNIX AND NOT APPLE) + # SET(CPACK_GENERATOR "TGZ;STGZ") + # FIND_PROGRAM(found_compress + # NAMES compress) + # IF(found_compress) + # FIND_PROGRAM(file_command NAMES file) + # IF(NOT file_command) + # set(file_command file) + # ENDIF(NOT file_command) + # EXECUTE_PROCESS(COMMAND ${file_command} ${found_compress} + # OUTPUT_VARIABLE output) + # set(SKIP_TZ FALSE) + # if("${output}" MATCHES "script") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "script") + # if("${output}" MATCHES "dummy.sh") + # set(SKIP_TZ TRUE) + # endif("${output}" MATCHES "dummy.sh") + # if(NOT SKIP_TZ) + # message("compress found and it was not a script") + # message("output from file command: [${output}]") + # SET(CPACK_GENERATOR "${CPACK_GENERATOR};TZ") + # else(NOT SKIP_TZ) + # message("compress found, but it was a script so dont use it") + # message("output from file command: [${output}]") + # endif(NOT SKIP_TZ) + # ENDIF(found_compress) + FIND_PROGRAM(found_bz2 + NAMES bzip2) + IF(found_bz2) + SET(CPACK_GENERATOR "${CPACK_GENERATOR};TBZ2") + ENDIF(found_bz2) +ENDIF(UNIX AND NOT APPLE) SET(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") SET(CMAKE_INSTALL_MFC_LIBRARIES 1) diff --git a/Tests/SimpleInstallS2/PackageScript.cmake b/Tests/SimpleInstallS2/PackageScript.cmake new file mode 100644 index 0000000000..3567a2f43b --- /dev/null +++ b/Tests/SimpleInstallS2/PackageScript.cmake @@ -0,0 +1,10 @@ +MESSAGE("This is packaging script") +MESSAGE("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt") + +FILE(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + FILE(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt + "${var} \"${${var}}\"\n") +ENDFOREACH(var ${res}) + diff --git a/Tests/SimpleInstallS2/scripts/.gitattributes b/Tests/SimpleInstallS2/scripts/.gitattributes new file mode 100644 index 0000000000..5e3db2fb3a --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/.gitattributes @@ -0,0 +1 @@ +sample_script crlf=input diff --git a/Tests/SimpleInstallS2/scripts/sample_script b/Tests/SimpleInstallS2/scripts/sample_script new file mode 100755 index 0000000000..81f9f53153 --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/sample_script @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Sample Script Output" diff --git a/Tests/SimpleInstallS2/scripts/sample_script.bat b/Tests/SimpleInstallS2/scripts/sample_script.bat new file mode 100755 index 0000000000..64a77b5b0f --- /dev/null +++ b/Tests/SimpleInstallS2/scripts/sample_script.bat @@ -0,0 +1 @@ +@echo Sample Script Output
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt index 044f2716aa..3376a38663 100644 --- a/Tests/StringFileTest/CMakeLists.txt +++ b/Tests/StringFileTest/CMakeLists.txt @@ -75,10 +75,16 @@ FOREACH(var FILE(APPEND "${file}" "#define ${var} \"${${var}}\"\n") ENDFOREACH(var) +# Verify that the file was created recently. +IF(NOT FILE_IS_NEWER "${file}" "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in") + MESSAGE(FATAL_ERROR "IF(FILE_IS_NEWER) does not seem to work.") +ENDIF(NOT FILE_IS_NEWER "${file}" "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in") + # Test configuration of the string SET(TEST_DEFINED 123) SET(TEST_NOT_DEFINED) -STRING(CONFIGURE "${infile}" infile @ONLY) +STRING(CONFIGURE "${infile}" infile+-/out @ONLY) +SET(infile "${infile+-/out}") # Write include file to a file STRING(REGEX REPLACE "includefile" "${file}" outfile "${infile}") diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index 5734b807ce..c6018a87e4 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -24,13 +24,20 @@ CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS == "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}" CMAKE_SHARED_LIBRARY_LINK_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_FLAGS}" CMAKE_SHARED_LIBRARY_RUNTIME_FLAG == "${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG}" CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP}" +CMAKE_SHARED_LIBRARY_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_STATIC_C_FLAGS}" +CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS}" // C shared module flags CMAKE_SHARED_MODULE_C_FLAGS == "${CMAKE_SHARED_MODULE_C_FLAGS}" CMAKE_SHARED_MODULE_CREATE_C_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}" -CMAKE_SHARED_MODULE_LINK_FLAGS == "${CMAKE_SHARED_MODULE_LINK_FLAGS}" CMAKE_SHARED_MODULE_RUNTIME_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG}" CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP}" +CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_C_FLAGS}" +CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_C_FLAGS}" + +// C exe flags +CMAKE_EXE_LINK_STATIC_C_FLAGS == "${CMAKE_EXE_LINK_STATIC_C_FLAGS}" +CMAKE_EXE_LINK_DYNAMIC_C_FLAGS == "${CMAKE_EXE_LINK_DYNAMIC_C_FLAGS}" // CXX shared library flags CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}" @@ -38,13 +45,20 @@ CMAKE_SHARED_LIBRARY_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}" CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG}" CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP}" +CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS}" +CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS}" // CXX shared module flags CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS}" CMAKE_SHARED_MODULE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CXX_FLAGS}" -CMAKE_SHARED_MODULE_LINK_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_CXX_FLAGS}" CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG}" CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP}" +CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_STATIC_CXX_FLAGS}" +CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_MODULE_LINK_DYNAMIC_CXX_FLAGS}" + +// CXX exe flags +CMAKE_EXE_LINK_STATIC_CXX_FLAGS == "${CMAKE_EXE_LINK_STATIC_CXX_FLAGS}" +CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS}" CMAKE_USER_MAKE_RULES_OVERRIDE == "${CMAKE_USER_MAKE_RULES_OVERRIDE}" CMAKE_VERBOSE_MAKEFILE == "${CMAKE_VERBOSE_MAKEFILE}" |