summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-05 19:18:01 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-05 19:43:16 (GMT)
commit1b9d15c1e7adff5170f10d488483e1dc4e99d507 (patch)
treeb191064ac37e028602be180c5ba9107e22cb536f /Modules
parenta5a5a6857241c21d306661d723b749839f4c6e1a (diff)
downloadCMake-1b9d15c1e7adff5170f10d488483e1dc4e99d507.zip
CMake-1b9d15c1e7adff5170f10d488483e1dc4e99d507.tar.gz
CMake-1b9d15c1e7adff5170f10d488483e1dc4e99d507.tar.bz2
ExternalProject: Be compatible with projects setting CMAKE_CFG_INTDIR
Since commit v3.5.0-rc1~32^2~1 (ExternalProject: Simplify `cmake --build` configuration passing, 2016-01-19) we use the `$<CONFIG>` generator expression to generate the `cmake --build . --config <config>` value for the default BUILD_COMMAND instead of the CMAKE_CFG_INTDIR placeholder value provided by multi-config generators. However, some projects have been abusing the old implementation detail by setting CMAKE_CFG_INTDIR themselves to get a specific configuration. Those projects should be updated to set their own BUILD_COMMAND to get non-default behavior. Meanwhile we can be compatible with their existing releases by detecting when CMAKE_CFG_INTDIR is not a generator-provided placeholder and using its value instead.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/ExternalProject.cmake19
1 files changed, 17 insertions, 2 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 7070dc4..249658d 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1231,7 +1231,22 @@ function(_ep_get_build_command name step cmd_var)
endif()
set(args --build ".")
if(CMAKE_CONFIGURATION_TYPES)
- list(APPEND args --config $<CONFIG>)
+ if (CMAKE_CFG_INTDIR AND
+ NOT CMAKE_CFG_INTDIR STREQUAL "." AND
+ NOT CMAKE_CFG_INTDIR MATCHES "\\$")
+ # CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value
+ # provided by multi-configuration generators. Some projects were
+ # taking advantage of that undocumented implementation detail to
+ # specify a specific configuration here. They should use
+ # BUILD_COMMAND to change the default command instead, but for
+ # compatibility honor the value.
+ set(config ${CMAKE_CFG_INTDIR})
+ message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n"
+ "To get a non-default build command, use the BUILD_COMMAND option.")
+ else()
+ set(config $<CONFIG>)
+ endif()
+ list(APPEND args --config ${config})
endif()
if(step STREQUAL "INSTALL")
list(APPEND args --target install)
@@ -1241,7 +1256,7 @@ function(_ep_get_build_command name step cmd_var)
string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
set(args "")
if(CMAKE_CONFIGURATION_TYPES)
- list(APPEND args -C $<CONFIG>)
+ list(APPEND args -C ${config})
endif()
endif()
endif()