diff options
author | Gaëtan Lehmann <gaetan.lehmann@gmail.com> | 2015-03-06 10:43:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-03-09 14:04:44 (GMT) |
commit | 86032ae0ebb7e86f3ff5617e080dd827dbbe98b0 (patch) | |
tree | 9eb863a0d1272156c148625f6199457b3c421b9e /Tests/CustomCommandByproducts | |
parent | a6d488f2ceb62b968c6f0a8971a3556195af80ca (diff) | |
download | CMake-86032ae0ebb7e86f3ff5617e080dd827dbbe98b0.zip CMake-86032ae0ebb7e86f3ff5617e080dd827dbbe98b0.tar.gz CMake-86032ae0ebb7e86f3ff5617e080dd827dbbe98b0.tar.bz2 |
ExternalProject: Replace placeholder tokens in BYPRODUCTS
This allows the developer to specify the byproducts relative to the
binary directory without the need to set the binary directory location
explicitly.
Diffstat (limited to 'Tests/CustomCommandByproducts')
-rw-r--r-- | Tests/CustomCommandByproducts/CMakeLists.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index 884f8c2..3289e8f 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -102,6 +102,27 @@ add_library(ExternalLibrary STATIC IMPORTED) set_property(TARGET ExternalLibrary PROPERTY IMPORTED_LOCATION ${ExternalLibrary_LIBRARY}) add_dependencies(ExternalLibrary ExternalTarget) +# Generate the library file of an imported target as a byproduct +# of an external project. The byproduct uses <BINARY_DIR> that is substituted +# by the real binary path +if(CMAKE_CONFIGURATION_TYPES) + set(cfg /${CMAKE_CFG_INTDIR}) +else() + set(cfg) +endif() +include(ExternalProject) +ExternalProject_Add(ExtTargetSubst + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/External" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + BUILD_BYPRODUCTS "<BINARY_DIR>${cfg}/${CMAKE_STATIC_LIBRARY_PREFIX}ExternalLibrary${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) +ExternalProject_Get_Property(ExtTargetSubst binary_dir) +add_library(ExternalLibraryWithSubstitution STATIC IMPORTED) +set_property(TARGET ExternalLibraryWithSubstitution PROPERTY IMPORTED_LOCATION + ${binary_dir}${cfg}/${CMAKE_STATIC_LIBRARY_PREFIX}ExternalLibrary${CMAKE_STATIC_LIBRARY_SUFFIX}) +add_dependencies(ExternalLibraryWithSubstitution ExtTargetSubst) + # Add an executable consuming all the byproducts. add_executable(CustomCommandByproducts CustomCommandByproducts.c |