ENH: Added full pre-build/pre-link/post-build testing for both library and executable targets.
This commit is contained in:
parent
cf8fb5c6f8
commit
b40219372e
|
@ -27,6 +27,22 @@ ELSE(UNIX)
|
||||||
ENDIF(NOT BORLAND)
|
ENDIF(NOT BORLAND)
|
||||||
ENDIF (UNIX)
|
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
|
SET_SOURCE_FILES_PROPERTIES(complex
|
||||||
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
|
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
|
||||||
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||||
|
|
|
@ -734,16 +734,24 @@ int main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// A post-build custom-command has been attached to the lib (see Library/).
|
// Some pre-build/pre-link/post-build custom-commands have been
|
||||||
// It runs ${CREATE_FILE_EXE} which will create a file.
|
// attached to the lib (see Library/).
|
||||||
// It also copies that file again using CCOMMAND.
|
// 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
|
// WARNING: if you run 'complex' manually, this *will* fail, because
|
||||||
// the file was removed the last time 'complex' was run, and it is
|
// the file was removed the last time 'complex' was run, and it is
|
||||||
// only created during a build.
|
// 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/postbuild.txt");
|
||||||
TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.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/).
|
// A custom target has been created (see Library/).
|
||||||
|
|
|
@ -55,21 +55,26 @@ ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Attach a post-build custom-command to the lib.
|
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
||||||
# It runs ${CREATE_FILE_EXE} which will create a file.
|
# Each runs ${CREATE_FILE_EXE} which will create a file.
|
||||||
# The 'complex' executable will then test if this file exists and remove it.
|
# The 'complex' executable will then test if this file exists and remove it.
|
||||||
#
|
#
|
||||||
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
|
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
|
||||||
MESSAGE("complex bin dir is ${Complex_BINARY_DIR}")
|
MESSAGE("complex bin dir is ${Complex_BINARY_DIR}")
|
||||||
ADD_CUSTOM_COMMAND(COMMAND ${CREATE_FILE_EXE}
|
ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD
|
||||||
ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
|
COMMAND ${CREATE_FILE_EXE}
|
||||||
TARGET CMakeTestLibraryShared)
|
ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt")
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD
|
||||||
ADD_CUSTOM_COMMAND(COMMAND ${CMAKE_COMMAND}
|
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
|
ARGS -E copy
|
||||||
"${Complex_BINARY_DIR}/Library/postbuild.txt"
|
"${Complex_BINARY_DIR}/Library/postbuild.txt"
|
||||||
"${Complex_BINARY_DIR}/Library/postbuild2.txt"
|
"${Complex_BINARY_DIR}/Library/postbuild2.txt")
|
||||||
TARGET CMakeTestLibraryShared)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add a custom target.
|
# Add a custom target.
|
||||||
|
|
|
@ -27,6 +27,22 @@ ELSE(UNIX)
|
||||||
ENDIF(NOT BORLAND)
|
ENDIF(NOT BORLAND)
|
||||||
ENDIF (UNIX)
|
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
|
SET_SOURCE_FILES_PROPERTIES(complex
|
||||||
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
|
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
|
||||||
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||||
|
|
|
@ -734,16 +734,24 @@ int main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// A post-build custom-command has been attached to the lib (see Library/).
|
// Some pre-build/pre-link/post-build custom-commands have been
|
||||||
// It runs ${CREATE_FILE_EXE} which will create a file.
|
// attached to the lib (see Library/).
|
||||||
// It also copies that file again using CCOMMAND.
|
// 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
|
// WARNING: if you run 'complex' manually, this *will* fail, because
|
||||||
// the file was removed the last time 'complex' was run, and it is
|
// the file was removed the last time 'complex' was run, and it is
|
||||||
// only created during a build.
|
// 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/postbuild.txt");
|
||||||
TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.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/).
|
// A custom target has been created (see Library/).
|
||||||
|
|
|
@ -55,21 +55,26 @@ ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Attach a post-build custom-command to the lib.
|
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
||||||
# It runs ${CREATE_FILE_EXE} which will create a file.
|
# Each runs ${CREATE_FILE_EXE} which will create a file.
|
||||||
# The 'complex' executable will then test if this file exists and remove it.
|
# The 'complex' executable will then test if this file exists and remove it.
|
||||||
#
|
#
|
||||||
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
|
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
|
||||||
MESSAGE("complex bin dir is ${Complex_BINARY_DIR}")
|
MESSAGE("complex bin dir is ${Complex_BINARY_DIR}")
|
||||||
ADD_CUSTOM_COMMAND(COMMAND ${CREATE_FILE_EXE}
|
ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD
|
||||||
ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
|
COMMAND ${CREATE_FILE_EXE}
|
||||||
TARGET CMakeTestLibraryShared)
|
ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt")
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD
|
||||||
ADD_CUSTOM_COMMAND(COMMAND ${CMAKE_COMMAND}
|
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
|
ARGS -E copy
|
||||||
"${Complex_BINARY_DIR}/Library/postbuild.txt"
|
"${Complex_BINARY_DIR}/Library/postbuild.txt"
|
||||||
"${Complex_BINARY_DIR}/Library/postbuild2.txt"
|
"${Complex_BINARY_DIR}/Library/postbuild2.txt")
|
||||||
TARGET CMakeTestLibraryShared)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add a custom target.
|
# Add a custom target.
|
||||||
|
|
|
@ -27,6 +27,22 @@ ELSE(UNIX)
|
||||||
ENDIF(NOT BORLAND)
|
ENDIF(NOT BORLAND)
|
||||||
ENDIF (UNIX)
|
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
|
SET_SOURCE_FILES_PROPERTIES(complex
|
||||||
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
|
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
|
||||||
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
|
||||||
|
|
|
@ -734,16 +734,24 @@ int main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// A post-build custom-command has been attached to the lib (see Library/).
|
// Some pre-build/pre-link/post-build custom-commands have been
|
||||||
// It runs ${CREATE_FILE_EXE} which will create a file.
|
// attached to the lib (see Library/).
|
||||||
// It also copies that file again using CCOMMAND.
|
// 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
|
// WARNING: if you run 'complex' manually, this *will* fail, because
|
||||||
// the file was removed the last time 'complex' was run, and it is
|
// the file was removed the last time 'complex' was run, and it is
|
||||||
// only created during a build.
|
// 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/postbuild.txt");
|
||||||
TestAndRemoveFile(BINARY_DIR "/Library/postbuild2.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/).
|
// A custom target has been created (see Library/).
|
||||||
|
|
|
@ -55,21 +55,26 @@ ENDIF(${FOO_BAR_VAR} MATCHES "BAR")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Attach a post-build custom-command to the lib.
|
# Attach pre-build/pre-link/post-build custom-commands to the lib.
|
||||||
# It runs ${CREATE_FILE_EXE} which will create a file.
|
# Each runs ${CREATE_FILE_EXE} which will create a file.
|
||||||
# The 'complex' executable will then test if this file exists and remove it.
|
# The 'complex' executable will then test if this file exists and remove it.
|
||||||
#
|
#
|
||||||
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
|
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
|
||||||
MESSAGE("complex bin dir is ${Complex_BINARY_DIR}")
|
MESSAGE("complex bin dir is ${Complex_BINARY_DIR}")
|
||||||
ADD_CUSTOM_COMMAND(COMMAND ${CREATE_FILE_EXE}
|
ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD
|
||||||
ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
|
COMMAND ${CREATE_FILE_EXE}
|
||||||
TARGET CMakeTestLibraryShared)
|
ARGS "${Complex_BINARY_DIR}/Library/prebuild.txt")
|
||||||
|
ADD_CUSTOM_COMMAND(TARGET CMakeTestLibraryShared PRE_BUILD
|
||||||
ADD_CUSTOM_COMMAND(COMMAND ${CMAKE_COMMAND}
|
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
|
ARGS -E copy
|
||||||
"${Complex_BINARY_DIR}/Library/postbuild.txt"
|
"${Complex_BINARY_DIR}/Library/postbuild.txt"
|
||||||
"${Complex_BINARY_DIR}/Library/postbuild2.txt"
|
"${Complex_BINARY_DIR}/Library/postbuild2.txt")
|
||||||
TARGET CMakeTestLibraryShared)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Add a custom target.
|
# Add a custom target.
|
||||||
|
|
Loading…
Reference in New Issue