diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2002-03-29 20:02:18 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2002-03-29 20:02:18 (GMT) |
commit | b3647fe6d3b014dc41c9b1fb735f7a70a3e003d0 (patch) | |
tree | 5624be60404ece6954b2d6c5c3d5297a92fdd9eb /Tests | |
parent | 2d5ddb07fd4c423303771a31326fd218bad99645 (diff) | |
download | CMake-b3647fe6d3b014dc41c9b1fb735f7a70a3e003d0.zip CMake-b3647fe6d3b014dc41c9b1fb735f7a70a3e003d0.tar.gz CMake-b3647fe6d3b014dc41c9b1fb735f7a70a3e003d0.tar.bz2 |
ENH: fix tests
Diffstat (limited to 'Tests')
33 files changed, 333 insertions, 237 deletions
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index eaaeed9..1c317d5 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -26,14 +26,6 @@ LOAD_CACHE(${Complex_SOURCE_DIR}/Cache CACHE_TEST_VAR_INTERNAL) # -# Configure file -# (plug vars to #define so that they can be tested) -# -CONFIGURE_FILE( - ${Complex_SOURCE_DIR}/cmTestConfigure.h.in - ${Complex_BINARY_DIR}/cmTestConfigure.h) - -# # Specify include and lib dirs # (BEFORE is for coverage) # @@ -64,16 +56,10 @@ SET (EXECUTABLE_OUTPUT_PATH "Single output directory for building all executables.") # -# Create the libs and the main exe -# -SUBDIRS(Library Executable) -SUBDIR_DEPENDS(Executable Library) - -# # Exec program (TODO: test a result) # Increase coverage. # -MESSAGE("Trying to increase coverage...") +MESSAGE("\nIgnore this message") OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0) IF (NOT NO_EXEC_PROGRAM) EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}") @@ -90,3 +76,46 @@ MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) # sadly it won't be able to remove it. # MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") + +# +# Test FIND_LIBARY +# Create a dummy empty lib +# +FOREACH (ext "${CMAKE_SHLIB_SUFFIX};.lib;.so") + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/dummylib${ext} + COPYONLY IMMEDIATE) +ENDFOREACH (ext) + +FIND_LIBRARY(FIND_DUMMY_LIB + dummylib + PATHS + ${Complex_BINARY_DIR}/Library) + +# +# Test SET_SOURCE_FILES_PROPERTIES +# +SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 + GENERATED + ABSTRACT + WRAP_EXCLUDE + COMPILE_FLAGS "-foo -bar") + +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS) + +# +# Configure file +# (plug vars to #define so that they can be tested) +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigure.h.in + ${Complex_BINARY_DIR}/cmTestConfigure.h) + +# +# Create the libs and the main exe +# +SUBDIRS(Library Executable) +SUBDIR_DEPENDS(Executable Library) diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index 9acd780..a3ad8fd 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -1,7 +1,8 @@ # # Create exe. # -SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DSET_SOURCE_FILES_PROPERTIES") +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") ADD_EXECUTABLE(complex complex) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 54f45e0..8459571 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -37,7 +37,7 @@ void ForceStringUse() void cmFailed(const char* Message, const char* m2= "") { - std::cerr << "Failed: " << Message << m2 << "\n"; + std::cerr << "FAILED: " << Message << m2 << "\n"; cm_failed++; } @@ -95,11 +95,6 @@ void TestDir(const char* filename) int main() { -#ifdef SET_SOURCE_FILES_PROPERTIES - cmPassed("SET_SOURCE_FILES_PROPERTIES set FLAGS passed on an ADD_EXECUTABLE source"); -#else - cmFailed("SET_SOURCE_FILES_PROPERTIES set FLAGS passed on an ADD_EXECUTABLE source"); -#endif if(sharedFunction() != 1) { cmFailed("Call to sharedFunction from shared library failed."); @@ -126,14 +121,6 @@ int main() { cmPassed("Call to file2 function returned 1."); } - if(PropertyTest() != 1) - { - cmFailed("Call to PropertyTest function from library failed."); - } - else - { - cmPassed("Call to PropertyTest function returned 1."); - } // ---------------------------------------------------------------------- // Test ADD_DEFINITIONS @@ -573,6 +560,59 @@ int main() TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- + // Test FIND_LIBRARY + +#ifndef FIND_DUMMY_LIB + cmFailed("the CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB is not defined."); +#else + if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL) + { + cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } + else + { + cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } +#endif + + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES + +#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#endif + +#ifndef FILE_HAS_ABSTRACT + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag"); +#endif + +#ifndef FILE_HAS_WRAP_EXCLUDE + cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag"); +#else + cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag"); +#endif + +#ifndef FILE_COMPILE_FLAGS + cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined."); +#else + if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) + { + cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ", + FILE_COMPILE_FLAGS); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS); + } +#endif + + // ---------------------------------------------------------------------- // Summary std::cout << "Passed: " << cm_passed << "\n"; diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index 5533d04..c01f501 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -23,27 +23,7 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources) # # Create shared library # - -# test SET_SOURCE_FILES_PROPERTIES -SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 GENERATED ABSTRACT WRAP_EXCLUDE COMPILE_FLAGS "-foo -bar") -GET_SOURCE_FILE_PROPERTY(ISABS nonexisting_file2 ABSTRACT) -GET_SOURCE_FILE_PROPERTY(WRAPEX nonexisting_file2 WRAP_EXCLUDE) -GET_SOURCE_FILE_PROPERTY(FLAGS nonexisting_file2 COMPILE_FLAGS) -MESSAGE("ISABS = ${ISABS} WRAPEX = ${WRAPEX} FLAGS = ${FLAGS}") - -CONFIGURE_FILE( - ${Complex_SOURCE_DIR}/Library/cmTestLibraryConfigure.h.in - ${Complex_BINARY_DIR}/Library/cmTestLibraryConfigure.h) - - - - -SOURCE_FILES(SharedLibrarySources nonexisting_file2) -SOURCE_FILES_REMOVE(SharedLibrarySources GENERATED nonexisting_file2) - - -SET_SOURCE_FILES_PROPERTIES(fileFlags COMPILE_FLAGS "-DEXTRA_FLAG" ) -SOURCE_FILES(SharedLibrarySources sharedFile fileFlags) +SOURCE_FILES(SharedLibrarySources sharedFile) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) # @@ -60,7 +40,6 @@ ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared # # Add a custom target. -# It runs ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create a file. # The 'complex' executable will then test if this file exists and remove it. # diff --git a/Tests/Complex/Library/cmTestLibraryConfigure.h.in b/Tests/Complex/Library/cmTestLibraryConfigure.h.in deleted file mode 100644 index b5c1c41..0000000 --- a/Tests/Complex/Library/cmTestLibraryConfigure.h.in +++ /dev/null @@ -1,4 +0,0 @@ -#cmakedefine ISABS -#cmakedefine WRAPEX -#define FLAGS "${FLAGS}" - diff --git a/Tests/Complex/Library/dummy b/Tests/Complex/Library/dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/Complex/Library/dummy diff --git a/Tests/Complex/Library/empty.h b/Tests/Complex/Library/empty.h index dea4b80..e69de29 100644 --- a/Tests/Complex/Library/empty.h +++ b/Tests/Complex/Library/empty.h @@ -1 +0,0 @@ -int file2(); diff --git a/Tests/Complex/Library/file2.cxx b/Tests/Complex/Library/file2.cxx index 29bc9d8..b52e547 100644 --- a/Tests/Complex/Library/file2.cxx +++ b/Tests/Complex/Library/file2.cxx @@ -1,23 +1,6 @@ -#include <Library/cmTestLibraryConfigure.h> #include <string.h> int file2() { return 1; } - -int PropertyTest() -{ - int ret = 1; -#ifndef ISABS - ret = 0; -#endif -#ifndef WRAPEX - ret = 0; -#endif - if(strcmp(FLAGS,"-foo -bar") != 0) - { - ret =0; - } - return ret; -} diff --git a/Tests/Complex/Library/file2.h b/Tests/Complex/Library/file2.h index 5e0b315..dea4b80 100644 --- a/Tests/Complex/Library/file2.h +++ b/Tests/Complex/Library/file2.h @@ -1,2 +1 @@ int file2(); -int PropertyTest(); diff --git a/Tests/Complex/Library/fileFlags.cxx b/Tests/Complex/Library/fileFlags.cxx deleted file mode 100644 index c766daa..0000000 --- a/Tests/Complex/Library/fileFlags.cxx +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef EXTRA_FLAG -syntax error EXTRA_FLAG should be defined on the command line for this file -#endif -int ALLOK; diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in index 0d4caee..e27607a 100644 --- a/Tests/Complex/cmTestConfigure.h.in +++ b/Tests/Complex/cmTestConfigure.h.in @@ -38,3 +38,13 @@ // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" + +// Test FIND_LIBRARY + +#define FIND_DUMMY_LIB "${FIND_DUMMY_LIB}" + +// Test SET_SOURCE_FILES_PROPERTIES + +#cmakedefine FILE_HAS_ABSTRACT +#cmakedefine FILE_HAS_WRAP_EXCLUDE +#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}" diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index eaaeed9..1c317d5 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -26,14 +26,6 @@ LOAD_CACHE(${Complex_SOURCE_DIR}/Cache CACHE_TEST_VAR_INTERNAL) # -# Configure file -# (plug vars to #define so that they can be tested) -# -CONFIGURE_FILE( - ${Complex_SOURCE_DIR}/cmTestConfigure.h.in - ${Complex_BINARY_DIR}/cmTestConfigure.h) - -# # Specify include and lib dirs # (BEFORE is for coverage) # @@ -64,16 +56,10 @@ SET (EXECUTABLE_OUTPUT_PATH "Single output directory for building all executables.") # -# Create the libs and the main exe -# -SUBDIRS(Library Executable) -SUBDIR_DEPENDS(Executable Library) - -# # Exec program (TODO: test a result) # Increase coverage. # -MESSAGE("Trying to increase coverage...") +MESSAGE("\nIgnore this message") OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0) IF (NOT NO_EXEC_PROGRAM) EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}") @@ -90,3 +76,46 @@ MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) # sadly it won't be able to remove it. # MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") + +# +# Test FIND_LIBARY +# Create a dummy empty lib +# +FOREACH (ext "${CMAKE_SHLIB_SUFFIX};.lib;.so") + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/dummylib${ext} + COPYONLY IMMEDIATE) +ENDFOREACH (ext) + +FIND_LIBRARY(FIND_DUMMY_LIB + dummylib + PATHS + ${Complex_BINARY_DIR}/Library) + +# +# Test SET_SOURCE_FILES_PROPERTIES +# +SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 + GENERATED + ABSTRACT + WRAP_EXCLUDE + COMPILE_FLAGS "-foo -bar") + +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS) + +# +# Configure file +# (plug vars to #define so that they can be tested) +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigure.h.in + ${Complex_BINARY_DIR}/cmTestConfigure.h) + +# +# Create the libs and the main exe +# +SUBDIRS(Library Executable) +SUBDIR_DEPENDS(Executable Library) diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 9acd780..a3ad8fd 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -1,7 +1,8 @@ # # Create exe. # -SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DSET_SOURCE_FILES_PROPERTIES") +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") ADD_EXECUTABLE(complex complex) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 54f45e0..8459571 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -37,7 +37,7 @@ void ForceStringUse() void cmFailed(const char* Message, const char* m2= "") { - std::cerr << "Failed: " << Message << m2 << "\n"; + std::cerr << "FAILED: " << Message << m2 << "\n"; cm_failed++; } @@ -95,11 +95,6 @@ void TestDir(const char* filename) int main() { -#ifdef SET_SOURCE_FILES_PROPERTIES - cmPassed("SET_SOURCE_FILES_PROPERTIES set FLAGS passed on an ADD_EXECUTABLE source"); -#else - cmFailed("SET_SOURCE_FILES_PROPERTIES set FLAGS passed on an ADD_EXECUTABLE source"); -#endif if(sharedFunction() != 1) { cmFailed("Call to sharedFunction from shared library failed."); @@ -126,14 +121,6 @@ int main() { cmPassed("Call to file2 function returned 1."); } - if(PropertyTest() != 1) - { - cmFailed("Call to PropertyTest function from library failed."); - } - else - { - cmPassed("Call to PropertyTest function returned 1."); - } // ---------------------------------------------------------------------- // Test ADD_DEFINITIONS @@ -573,6 +560,59 @@ int main() TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- + // Test FIND_LIBRARY + +#ifndef FIND_DUMMY_LIB + cmFailed("the CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB is not defined."); +#else + if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL) + { + cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } + else + { + cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } +#endif + + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES + +#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#endif + +#ifndef FILE_HAS_ABSTRACT + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag"); +#endif + +#ifndef FILE_HAS_WRAP_EXCLUDE + cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag"); +#else + cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag"); +#endif + +#ifndef FILE_COMPILE_FLAGS + cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined."); +#else + if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) + { + cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ", + FILE_COMPILE_FLAGS); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS); + } +#endif + + // ---------------------------------------------------------------------- // Summary std::cout << "Passed: " << cm_passed << "\n"; diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index 5533d04..c01f501 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -23,27 +23,7 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources) # # Create shared library # - -# test SET_SOURCE_FILES_PROPERTIES -SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 GENERATED ABSTRACT WRAP_EXCLUDE COMPILE_FLAGS "-foo -bar") -GET_SOURCE_FILE_PROPERTY(ISABS nonexisting_file2 ABSTRACT) -GET_SOURCE_FILE_PROPERTY(WRAPEX nonexisting_file2 WRAP_EXCLUDE) -GET_SOURCE_FILE_PROPERTY(FLAGS nonexisting_file2 COMPILE_FLAGS) -MESSAGE("ISABS = ${ISABS} WRAPEX = ${WRAPEX} FLAGS = ${FLAGS}") - -CONFIGURE_FILE( - ${Complex_SOURCE_DIR}/Library/cmTestLibraryConfigure.h.in - ${Complex_BINARY_DIR}/Library/cmTestLibraryConfigure.h) - - - - -SOURCE_FILES(SharedLibrarySources nonexisting_file2) -SOURCE_FILES_REMOVE(SharedLibrarySources GENERATED nonexisting_file2) - - -SET_SOURCE_FILES_PROPERTIES(fileFlags COMPILE_FLAGS "-DEXTRA_FLAG" ) -SOURCE_FILES(SharedLibrarySources sharedFile fileFlags) +SOURCE_FILES(SharedLibrarySources sharedFile) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) # @@ -60,7 +40,6 @@ ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared # # Add a custom target. -# It runs ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create a file. # The 'complex' executable will then test if this file exists and remove it. # diff --git a/Tests/ComplexOneConfig/Library/cmTestLibraryConfigure.h.in b/Tests/ComplexOneConfig/Library/cmTestLibraryConfigure.h.in deleted file mode 100644 index b5c1c41..0000000 --- a/Tests/ComplexOneConfig/Library/cmTestLibraryConfigure.h.in +++ /dev/null @@ -1,4 +0,0 @@ -#cmakedefine ISABS -#cmakedefine WRAPEX -#define FLAGS "${FLAGS}" - diff --git a/Tests/ComplexOneConfig/Library/dummy b/Tests/ComplexOneConfig/Library/dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/dummy diff --git a/Tests/ComplexOneConfig/Library/empty.h b/Tests/ComplexOneConfig/Library/empty.h index dea4b80..e69de29 100644 --- a/Tests/ComplexOneConfig/Library/empty.h +++ b/Tests/ComplexOneConfig/Library/empty.h @@ -1 +0,0 @@ -int file2(); diff --git a/Tests/ComplexOneConfig/Library/file2.cxx b/Tests/ComplexOneConfig/Library/file2.cxx index 29bc9d8..b52e547 100644 --- a/Tests/ComplexOneConfig/Library/file2.cxx +++ b/Tests/ComplexOneConfig/Library/file2.cxx @@ -1,23 +1,6 @@ -#include <Library/cmTestLibraryConfigure.h> #include <string.h> int file2() { return 1; } - -int PropertyTest() -{ - int ret = 1; -#ifndef ISABS - ret = 0; -#endif -#ifndef WRAPEX - ret = 0; -#endif - if(strcmp(FLAGS,"-foo -bar") != 0) - { - ret =0; - } - return ret; -} diff --git a/Tests/ComplexOneConfig/Library/file2.h b/Tests/ComplexOneConfig/Library/file2.h index 5e0b315..dea4b80 100644 --- a/Tests/ComplexOneConfig/Library/file2.h +++ b/Tests/ComplexOneConfig/Library/file2.h @@ -1,2 +1 @@ int file2(); -int PropertyTest(); diff --git a/Tests/ComplexOneConfig/Library/fileFlags.cxx b/Tests/ComplexOneConfig/Library/fileFlags.cxx deleted file mode 100644 index c766daa..0000000 --- a/Tests/ComplexOneConfig/Library/fileFlags.cxx +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef EXTRA_FLAG -syntax error EXTRA_FLAG should be defined on the command line for this file -#endif -int ALLOK; diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in index 0d4caee..e27607a 100644 --- a/Tests/ComplexOneConfig/cmTestConfigure.h.in +++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in @@ -38,3 +38,13 @@ // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" + +// Test FIND_LIBRARY + +#define FIND_DUMMY_LIB "${FIND_DUMMY_LIB}" + +// Test SET_SOURCE_FILES_PROPERTIES + +#cmakedefine FILE_HAS_ABSTRACT +#cmakedefine FILE_HAS_WRAP_EXCLUDE +#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}" diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt index eaaeed9..1c317d5 100644 --- a/Tests/ComplexRelativePaths/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -26,14 +26,6 @@ LOAD_CACHE(${Complex_SOURCE_DIR}/Cache CACHE_TEST_VAR_INTERNAL) # -# Configure file -# (plug vars to #define so that they can be tested) -# -CONFIGURE_FILE( - ${Complex_SOURCE_DIR}/cmTestConfigure.h.in - ${Complex_BINARY_DIR}/cmTestConfigure.h) - -# # Specify include and lib dirs # (BEFORE is for coverage) # @@ -64,16 +56,10 @@ SET (EXECUTABLE_OUTPUT_PATH "Single output directory for building all executables.") # -# Create the libs and the main exe -# -SUBDIRS(Library Executable) -SUBDIR_DEPENDS(Executable Library) - -# # Exec program (TODO: test a result) # Increase coverage. # -MESSAGE("Trying to increase coverage...") +MESSAGE("\nIgnore this message") OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0) IF (NOT NO_EXEC_PROGRAM) EXEC_PROGRAM("echo NO_EXEC_PROGRAM" "${Complex_BINARY_DIR}") @@ -90,3 +76,46 @@ MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) # sadly it won't be able to remove it. # MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") + +# +# Test FIND_LIBARY +# Create a dummy empty lib +# +FOREACH (ext "${CMAKE_SHLIB_SUFFIX};.lib;.so") + CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/Library/dummy + ${Complex_BINARY_DIR}/Library/dummylib${ext} + COPYONLY IMMEDIATE) +ENDFOREACH (ext) + +FIND_LIBRARY(FIND_DUMMY_LIB + dummylib + PATHS + ${Complex_BINARY_DIR}/Library) + +# +# Test SET_SOURCE_FILES_PROPERTIES +# +SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 + GENERATED + ABSTRACT + WRAP_EXCLUDE + COMPILE_FLAGS "-foo -bar") + +GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT) +GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE) +GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS) + +# +# Configure file +# (plug vars to #define so that they can be tested) +# +CONFIGURE_FILE( + ${Complex_SOURCE_DIR}/cmTestConfigure.h.in + ${Complex_BINARY_DIR}/cmTestConfigure.h) + +# +# Create the libs and the main exe +# +SUBDIRS(Library Executable) +SUBDIR_DEPENDS(Executable Library) diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index 9acd780..a3ad8fd 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -1,7 +1,8 @@ # # Create exe. # -SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DSET_SOURCE_FILES_PROPERTIES") +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") ADD_EXECUTABLE(complex complex) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index 54f45e0..8459571 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -37,7 +37,7 @@ void ForceStringUse() void cmFailed(const char* Message, const char* m2= "") { - std::cerr << "Failed: " << Message << m2 << "\n"; + std::cerr << "FAILED: " << Message << m2 << "\n"; cm_failed++; } @@ -95,11 +95,6 @@ void TestDir(const char* filename) int main() { -#ifdef SET_SOURCE_FILES_PROPERTIES - cmPassed("SET_SOURCE_FILES_PROPERTIES set FLAGS passed on an ADD_EXECUTABLE source"); -#else - cmFailed("SET_SOURCE_FILES_PROPERTIES set FLAGS passed on an ADD_EXECUTABLE source"); -#endif if(sharedFunction() != 1) { cmFailed("Call to sharedFunction from shared library failed."); @@ -126,14 +121,6 @@ int main() { cmPassed("Call to file2 function returned 1."); } - if(PropertyTest() != 1) - { - cmFailed("Call to PropertyTest function from library failed."); - } - else - { - cmPassed("Call to PropertyTest function returned 1."); - } // ---------------------------------------------------------------------- // Test ADD_DEFINITIONS @@ -573,6 +560,59 @@ int main() TestAndRemoveFile(BINARY_DIR "/Executable/Temp/complex-required.txt"); // ---------------------------------------------------------------------- + // Test FIND_LIBRARY + +#ifndef FIND_DUMMY_LIB + cmFailed("the CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB is not defined."); +#else + if(strstr(FIND_DUMMY_LIB, "dummylib") == NULL) + { + cmFailed("the FIND_LIBRARY or CONFIGURE_FILE command is broken, " + "FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } + else + { + cmPassed("FIND_DUMMY_LIB == ", FIND_DUMMY_LIB); + } +#endif + + // ---------------------------------------------------------------------- + // Test SET_SOURCE_FILES_PROPERTIES + +#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_HAS_EXTRA_COMPILE_FLAGS flag"); +#endif + +#ifndef FILE_HAS_ABSTRACT + cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting ABSTRACT flag"); +#else + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting ABSTRACT flag"); +#endif + +#ifndef FILE_HAS_WRAP_EXCLUDE + cmFailed("FILE_HAS_WRAP_EXCLUDE failed at setting WRAP_EXCLUDE flag"); +#else + cmPassed("FILE_HAS_WRAP_EXCLUDE succeeded in setting WRAP_EXCLUDE flag"); +#endif + +#ifndef FILE_COMPILE_FLAGS + cmFailed("the CONFIGURE_FILE command is broken, FILE_COMPILE_FLAGS is not defined."); +#else + if(strcmp(FILE_COMPILE_FLAGS, "-foo -bar") != 0) + { + cmFailed("the SET_SOURCE_FILES_PROPERTIES or CONFIGURE_FILE command is broken. FILE_COMPILE_FLAGS == ", + FILE_COMPILE_FLAGS); + } + else + { + cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting extra flags == ", FILE_COMPILE_FLAGS); + } +#endif + + // ---------------------------------------------------------------------- // Summary std::cout << "Passed: " << cm_passed << "\n"; diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index 5533d04..c01f501 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -23,27 +23,7 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources) # # Create shared library # - -# test SET_SOURCE_FILES_PROPERTIES -SET_SOURCE_FILES_PROPERTIES(nonexisting_file2 GENERATED ABSTRACT WRAP_EXCLUDE COMPILE_FLAGS "-foo -bar") -GET_SOURCE_FILE_PROPERTY(ISABS nonexisting_file2 ABSTRACT) -GET_SOURCE_FILE_PROPERTY(WRAPEX nonexisting_file2 WRAP_EXCLUDE) -GET_SOURCE_FILE_PROPERTY(FLAGS nonexisting_file2 COMPILE_FLAGS) -MESSAGE("ISABS = ${ISABS} WRAPEX = ${WRAPEX} FLAGS = ${FLAGS}") - -CONFIGURE_FILE( - ${Complex_SOURCE_DIR}/Library/cmTestLibraryConfigure.h.in - ${Complex_BINARY_DIR}/Library/cmTestLibraryConfigure.h) - - - - -SOURCE_FILES(SharedLibrarySources nonexisting_file2) -SOURCE_FILES_REMOVE(SharedLibrarySources GENERATED nonexisting_file2) - - -SET_SOURCE_FILES_PROPERTIES(fileFlags COMPILE_FLAGS "-DEXTRA_FLAG" ) -SOURCE_FILES(SharedLibrarySources sharedFile fileFlags) +SOURCE_FILES(SharedLibrarySources sharedFile) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) # @@ -60,7 +40,6 @@ ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared # # Add a custom target. -# It runs ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create a file. # The 'complex' executable will then test if this file exists and remove it. # diff --git a/Tests/ComplexRelativePaths/Library/cmTestLibraryConfigure.h.in b/Tests/ComplexRelativePaths/Library/cmTestLibraryConfigure.h.in deleted file mode 100644 index b5c1c41..0000000 --- a/Tests/ComplexRelativePaths/Library/cmTestLibraryConfigure.h.in +++ /dev/null @@ -1,4 +0,0 @@ -#cmakedefine ISABS -#cmakedefine WRAPEX -#define FLAGS "${FLAGS}" - diff --git a/Tests/ComplexRelativePaths/Library/dummy b/Tests/ComplexRelativePaths/Library/dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/dummy diff --git a/Tests/ComplexRelativePaths/Library/empty.h b/Tests/ComplexRelativePaths/Library/empty.h index dea4b80..e69de29 100644 --- a/Tests/ComplexRelativePaths/Library/empty.h +++ b/Tests/ComplexRelativePaths/Library/empty.h @@ -1 +0,0 @@ -int file2(); diff --git a/Tests/ComplexRelativePaths/Library/file2.cxx b/Tests/ComplexRelativePaths/Library/file2.cxx index 29bc9d8..b52e547 100644 --- a/Tests/ComplexRelativePaths/Library/file2.cxx +++ b/Tests/ComplexRelativePaths/Library/file2.cxx @@ -1,23 +1,6 @@ -#include <Library/cmTestLibraryConfigure.h> #include <string.h> int file2() { return 1; } - -int PropertyTest() -{ - int ret = 1; -#ifndef ISABS - ret = 0; -#endif -#ifndef WRAPEX - ret = 0; -#endif - if(strcmp(FLAGS,"-foo -bar") != 0) - { - ret =0; - } - return ret; -} diff --git a/Tests/ComplexRelativePaths/Library/file2.h b/Tests/ComplexRelativePaths/Library/file2.h index 5e0b315..dea4b80 100644 --- a/Tests/ComplexRelativePaths/Library/file2.h +++ b/Tests/ComplexRelativePaths/Library/file2.h @@ -1,2 +1 @@ int file2(); -int PropertyTest(); diff --git a/Tests/ComplexRelativePaths/Library/fileFlags.cxx b/Tests/ComplexRelativePaths/Library/fileFlags.cxx deleted file mode 100644 index c766daa..0000000 --- a/Tests/ComplexRelativePaths/Library/fileFlags.cxx +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef EXTRA_FLAG -syntax error EXTRA_FLAG should be defined on the command line for this file -#endif -int ALLOK; diff --git a/Tests/ComplexRelativePaths/cmTestConfigure.h.in b/Tests/ComplexRelativePaths/cmTestConfigure.h.in index 0d4caee..e27607a 100644 --- a/Tests/ComplexRelativePaths/cmTestConfigure.h.in +++ b/Tests/ComplexRelativePaths/cmTestConfigure.h.in @@ -38,3 +38,13 @@ // Needed to check for files #define BINARY_DIR "${Complex_BINARY_DIR}" + +// Test FIND_LIBRARY + +#define FIND_DUMMY_LIB "${FIND_DUMMY_LIB}" + +// Test SET_SOURCE_FILES_PROPERTIES + +#cmakedefine FILE_HAS_ABSTRACT +#cmakedefine FILE_HAS_WRAP_EXCLUDE +#define FILE_COMPILE_FLAGS "${FILE_COMPILE_FLAGS}" |