From 6b3cd64d42740618e0df6507194076185c1d91e2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 3 Oct 2017 15:06:08 -0400 Subject: ExternalProject: Propagate the generator instance When the `CMAKE_GENERATOR` option is given to `ExternalProject_Add`, look also for option `CMAKE_GENERATOR_INSTANCE` to pass on to cmake as a cache definition. When no `CMAKE_GENERATOR` option is given explicitly then use the current project's `CMAKE_GENERATOR_INSTANCE` (since we already use its CMAKE_GENERATOR). --- Modules/ExternalProject.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 5897e74..67aac4f 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -381,6 +381,11 @@ External Project Definition :variable:`CMAKE_GENERATOR_TOOLSET`). It is an error to provide this option without the ``CMAKE_GENERATOR`` option. + ``CMAKE_GENERATOR_INSTANCE `` + Pass a generator-specific instance selection to the CMake command (see + :variable:`CMAKE_GENERATOR_INSTANCE`). It is an error to provide this + option without the ``CMAKE_GENERATOR`` option. + ``CMAKE_ARGS ...`` The specified arguments are passed to the ``cmake`` command line. They can be any argument the ``cmake`` command understands, not just cache @@ -2754,6 +2759,7 @@ function(_ep_extract_configure_command var name) endif() get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) + get_target_property(cmake_generator_instance ${name} _EP_CMAKE_GENERATOR_INSTANCE) get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM) get_target_property(cmake_generator_toolset ${name} _EP_CMAKE_GENERATOR_TOOLSET) if(cmake_generator) @@ -2764,6 +2770,9 @@ function(_ep_extract_configure_command var name) if(cmake_generator_toolset) list(APPEND cmd "-T${cmake_generator_toolset}") endif() + if(cmake_generator_instance) + list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}") + endif() else() if(CMAKE_EXTRA_GENERATOR) list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") @@ -2782,6 +2791,12 @@ function(_ep_extract_configure_command var name) if(CMAKE_GENERATOR_TOOLSET) list(APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}") endif() + if(cmake_generator_instance) + message(FATAL_ERROR "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR.") + endif() + if(CMAKE_GENERATOR_INSTANCE) + list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") + endif() endif() list(APPEND cmd "") -- cgit v0.12