diff options
Diffstat (limited to 'Tests/Complex/Executable')
-rw-r--r-- | Tests/Complex/Executable/A.cxx | 5 | ||||
-rw-r--r-- | Tests/Complex/Executable/A.h | 4 | ||||
-rw-r--r-- | Tests/Complex/Executable/A.hh | 2 | ||||
-rw-r--r-- | Tests/Complex/Executable/A.txt | 1 | ||||
-rw-r--r-- | Tests/Complex/Executable/CMakeLists.txt | 21 | ||||
-rw-r--r-- | Tests/Complex/Executable/complex.cxx | 27 | ||||
-rw-r--r-- | Tests/Complex/Executable/notInAllExe.cxx | 10 | ||||
-rw-r--r-- | Tests/Complex/Executable/testSystemDir.cxx | 3 |
8 files changed, 69 insertions, 4 deletions
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(); } |