From 526649127e5e19076d7837d15095f47c64015fb5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 13 Dec 2002 17:35:00 -0500 Subject: ENH: Added test for generated header included by non-generated source. --- Tests/Complex/CMakeLists.txt | 2 +- Tests/Complex/Executable/CMakeLists.txt | 18 ++++++++++++++++-- Tests/Complex/Executable/complex.cxx | 7 +++++++ Tests/Complex/cmTestGeneratedHeader.h.in | 1 + Tests/ComplexOneConfig/CMakeLists.txt | 2 +- Tests/ComplexOneConfig/Executable/CMakeLists.txt | 18 ++++++++++++++++-- Tests/ComplexOneConfig/Executable/complex.cxx | 7 +++++++ Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in | 1 + Tests/ComplexRelativePaths/CMakeLists.txt | 2 +- Tests/ComplexRelativePaths/Executable/CMakeLists.txt | 18 ++++++++++++++++-- Tests/ComplexRelativePaths/Executable/complex.cxx | 7 +++++++ Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in | 1 + 12 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 Tests/Complex/cmTestGeneratedHeader.h.in create mode 100644 Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in create mode 100644 Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index f42ac45..532f725 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -61,7 +61,7 @@ INCLUDE_DIRECTORIES(BEFORE ${Complex_BINARY_DIR} ) -INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" ".*") +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" "^$") LINK_DIRECTORIES( ${Complex_BINARY_DIR}/Library diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index 8d3c11d..2011feb 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -3,8 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.3) # Create exe. # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS") -SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS - "-DFILE_HAS_EXTRA_COMPILE_FLAGS") + # Link to CMake lib LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to @@ -22,6 +21,21 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" + OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h +) + +ADD_CUSTOM_COMMAND( + TARGET complex + SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + DEPENDS ${CMAKE_COMMAND} +) + # # Output the files required by 'complex' to a file. # diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 7aa4140..d6d3839 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -1,5 +1,6 @@ #include "cmTestConfigure.h" #include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" #include "cmVersion.h" #include "ExtraSources/file1.h" #include "file2.h" @@ -808,6 +809,12 @@ int main() #else cmFailed("IF inside a FOREACH block is broken"); #endif + +#if defined(GENERATED_HEADER_INCLUDED) + cmPassed("Generated header included by non-generated source works."); +#else + cmFailed("Generated header included by non-generated source failed."); +#endif #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); diff --git a/Tests/Complex/cmTestGeneratedHeader.h.in b/Tests/Complex/cmTestGeneratedHeader.h.in new file mode 100644 index 0000000..0e9dd3f --- /dev/null +++ b/Tests/Complex/cmTestGeneratedHeader.h.in @@ -0,0 +1 @@ +#define GENERATED_HEADER_INCLUDED diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index f42ac45..532f725 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -61,7 +61,7 @@ INCLUDE_DIRECTORIES(BEFORE ${Complex_BINARY_DIR} ) -INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" ".*") +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" "^$") LINK_DIRECTORIES( ${Complex_BINARY_DIR}/Library diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 8d3c11d..2011feb 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -3,8 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.3) # Create exe. # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS") -SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS - "-DFILE_HAS_EXTRA_COMPILE_FLAGS") + # Link to CMake lib LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to @@ -22,6 +21,21 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" + OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h +) + +ADD_CUSTOM_COMMAND( + TARGET complex + SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + DEPENDS ${CMAKE_COMMAND} +) + # # Output the files required by 'complex' to a file. # diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 7aa4140..d6d3839 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -1,5 +1,6 @@ #include "cmTestConfigure.h" #include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" #include "cmVersion.h" #include "ExtraSources/file1.h" #include "file2.h" @@ -808,6 +809,12 @@ int main() #else cmFailed("IF inside a FOREACH block is broken"); #endif + +#if defined(GENERATED_HEADER_INCLUDED) + cmPassed("Generated header included by non-generated source works."); +#else + cmFailed("Generated header included by non-generated source failed."); +#endif #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); diff --git a/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in b/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in new file mode 100644 index 0000000..0e9dd3f --- /dev/null +++ b/Tests/ComplexOneConfig/cmTestGeneratedHeader.h.in @@ -0,0 +1 @@ +#define GENERATED_HEADER_INCLUDED diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt index f42ac45..532f725 100644 --- a/Tests/ComplexRelativePaths/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -61,7 +61,7 @@ INCLUDE_DIRECTORIES(BEFORE ${Complex_BINARY_DIR} ) -INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" ".*") +INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" "^$") LINK_DIRECTORIES( ${Complex_BINARY_DIR}/Library diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index 8d3c11d..2011feb 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -3,8 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.3) # Create exe. # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS") -SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS - "-DFILE_HAS_EXTRA_COMPILE_FLAGS") + # Link to CMake lib LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to @@ -22,6 +21,21 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +SET_SOURCE_FILES_PROPERTIES(complex + COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" + OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h +) + +ADD_CUSTOM_COMMAND( + TARGET complex + SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in + ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + OUTPUTS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h + DEPENDS ${CMAKE_COMMAND} +) + # # Output the files required by 'complex' to a file. # diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index 7aa4140..d6d3839 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -1,5 +1,6 @@ #include "cmTestConfigure.h" #include "cmTestConfigureEscape.h" +#include "cmTestGeneratedHeader.h" #include "cmVersion.h" #include "ExtraSources/file1.h" #include "file2.h" @@ -808,6 +809,12 @@ int main() #else cmFailed("IF inside a FOREACH block is broken"); #endif + +#if defined(GENERATED_HEADER_INCLUDED) + cmPassed("Generated header included by non-generated source works."); +#else + cmFailed("Generated header included by non-generated source failed."); +#endif #ifdef FORCE_TEST cmFailed("CMake SET CACHE FORCE"); diff --git a/Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in b/Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in new file mode 100644 index 0000000..0e9dd3f --- /dev/null +++ b/Tests/ComplexRelativePaths/cmTestGeneratedHeader.h.in @@ -0,0 +1 @@ +#define GENERATED_HEADER_INCLUDED -- cgit v0.12