From b40219372efc70439cd5241aabc9c4b9cd2e9adf Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Feb 2005 09:31:55 -0500 Subject: ENH: Added full pre-build/pre-link/post-build testing for both library and executable targets. --- Tests/Complex/Executable/CMakeLists.txt | 16 +++++++++++++++ Tests/Complex/Executable/complex.cxx | 14 ++++++++++--- Tests/Complex/Library/CMakeLists.txt | 23 +++++++++++++--------- Tests/ComplexOneConfig/Executable/CMakeLists.txt | 16 +++++++++++++++ Tests/ComplexOneConfig/Executable/complex.cxx | 14 ++++++++++--- Tests/ComplexOneConfig/Library/CMakeLists.txt | 23 +++++++++++++--------- .../ComplexRelativePaths/Executable/CMakeLists.txt | 16 +++++++++++++++ Tests/ComplexRelativePaths/Executable/complex.cxx | 14 ++++++++++--- Tests/ComplexRelativePaths/Library/CMakeLists.txt | 23 +++++++++++++--------- 9 files changed, 123 insertions(+), 36 deletions(-) diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index 5ad17fc..a7ee95d 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -27,6 +27,22 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +# Test pre-build/pre-link/post-build rules for an executable. +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Executable/postbuild.txt" + "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index e0b1eae..906616e 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -734,16 +734,24 @@ int main() #endif // ---------------------------------------------------------------------- - // A post-build custom-command has been attached to the lib (see Library/). - // It runs ${CREATE_FILE_EXE} which will create a file. - // It also copies that file again using CCOMMAND. + // Some pre-build/pre-link/post-build custom-commands have been + // attached to the lib (see Library/). + // Each runs ${CREATE_FILE_EXE} which will create a file. + // It also copies that file again using cmake -E. + // Similar rules have been added to this executable. // // WARNING: if you run 'complex' manually, this *will* fail, because // the file was removed the last time 'complex' was run, and it is // only created during a build. + TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index 7c58fad..1f0b0fa 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -55,21 +55,26 @@ ENDIF(${FOO_BAR_VAR} MATCHES "BAR") # -# Attach a post-build custom-command to the lib. -# It runs ${CREATE_FILE_EXE} which will create a file. +# Attach pre-build/pre-link/post-build custom-commands to the lib. +# Each runs ${CREATE_FILE_EXE} which will create a file. # The 'complex' executable will then test if this file exists and remove it. # ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) MESSAGE("complex bin dir is ${Complex_BINARY_DIR}") -ADD_CUSTOM_COMMAND(COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt" - TARGET CMakeTestLibraryShared) - -ADD_CUSTOM_COMMAND(COMMAND ${CMAKE_COMMAND} +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${Complex_BINARY_DIR}/Library/postbuild.txt" - "${Complex_BINARY_DIR}/Library/postbuild2.txt" - TARGET CMakeTestLibraryShared) + "${Complex_BINARY_DIR}/Library/postbuild2.txt") # # Add a custom target. diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 5ad17fc..a7ee95d 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -27,6 +27,22 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +# Test pre-build/pre-link/post-build rules for an executable. +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Executable/postbuild.txt" + "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index e0b1eae..906616e 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -734,16 +734,24 @@ int main() #endif // ---------------------------------------------------------------------- - // A post-build custom-command has been attached to the lib (see Library/). - // It runs ${CREATE_FILE_EXE} which will create a file. - // It also copies that file again using CCOMMAND. + // Some pre-build/pre-link/post-build custom-commands have been + // attached to the lib (see Library/). + // Each runs ${CREATE_FILE_EXE} which will create a file. + // It also copies that file again using cmake -E. + // Similar rules have been added to this executable. // // WARNING: if you run 'complex' manually, this *will* fail, because // the file was removed the last time 'complex' was run, and it is // only created during a build. + TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index 7c58fad..1f0b0fa 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -55,21 +55,26 @@ ENDIF(${FOO_BAR_VAR} MATCHES "BAR") # -# Attach a post-build custom-command to the lib. -# It runs ${CREATE_FILE_EXE} which will create a file. +# Attach pre-build/pre-link/post-build custom-commands to the lib. +# Each runs ${CREATE_FILE_EXE} which will create a file. # The 'complex' executable will then test if this file exists and remove it. # ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) MESSAGE("complex bin dir is ${Complex_BINARY_DIR}") -ADD_CUSTOM_COMMAND(COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt" - TARGET CMakeTestLibraryShared) - -ADD_CUSTOM_COMMAND(COMMAND ${CMAKE_COMMAND} +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${Complex_BINARY_DIR}/Library/postbuild.txt" - "${Complex_BINARY_DIR}/Library/postbuild2.txt" - TARGET CMakeTestLibraryShared) + "${Complex_BINARY_DIR}/Library/postbuild2.txt") # # Add a custom target. diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index 5ad17fc..a7ee95d 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -27,6 +27,22 @@ ELSE(UNIX) ENDIF(NOT BORLAND) ENDIF (UNIX) +# Test pre-build/pre-link/post-build rules for an executable. +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Executable/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET complex POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${Complex_BINARY_DIR}/Executable/postbuild.txt" + "${Complex_BINARY_DIR}/Executable/postbuild2.txt") + SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS" OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index e0b1eae..906616e 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -734,16 +734,24 @@ int main() #endif // ---------------------------------------------------------------------- - // A post-build custom-command has been attached to the lib (see Library/). - // It runs ${CREATE_FILE_EXE} which will create a file. - // It also copies that file again using CCOMMAND. + // Some pre-build/pre-link/post-build custom-commands have been + // attached to the lib (see Library/). + // Each runs ${CREATE_FILE_EXE} which will create a file. + // It also copies that file again using cmake -E. + // Similar rules have been added to this executable. // // WARNING: if you run 'complex' manually, this *will* fail, because // the file was removed the last time 'complex' was run, and it is // only created during a build. + TestAndRemoveFile(BINARY_DIR "/Library/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Library/prelink.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prebuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/prelink.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild.txt"); + TestAndRemoveFile(BINARY_DIR "/Executable/postbuild2.txt"); // ---------------------------------------------------------------------- // A custom target has been created (see Library/). diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index 7c58fad..1f0b0fa 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -55,21 +55,26 @@ ENDIF(${FOO_BAR_VAR} MATCHES "BAR") # -# Attach a post-build custom-command to the lib. -# It runs ${CREATE_FILE_EXE} which will create a file. +# Attach pre-build/pre-link/post-build custom-commands to the lib. +# Each runs ${CREATE_FILE_EXE} which will create a file. # The 'complex' executable will then test if this file exists and remove it. # ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) MESSAGE("complex bin dir is ${Complex_BINARY_DIR}") -ADD_CUSTOM_COMMAND(COMMAND ${CREATE_FILE_EXE} - ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt" - TARGET CMakeTestLibraryShared) - -ADD_CUSTOM_COMMAND(COMMAND ${CMAKE_COMMAND} +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/prelink.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CREATE_FILE_EXE} + ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt") +ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E copy "${Complex_BINARY_DIR}/Library/postbuild.txt" - "${Complex_BINARY_DIR}/Library/postbuild2.txt" - TARGET CMakeTestLibraryShared) + "${Complex_BINARY_DIR}/Library/postbuild2.txt") # # Add a custom target. -- cgit v0.12