[cmake-developers] Generator Expressions in CPack (Module) variables

Nils Gladitz nilsgladitz at gmail.com
Tue Apr 28 05:05:37 EDT 2015


On 04/28/2015 10:57 AM, Gregor Jasny wrote:
> Unfortunately the CPACK_BUILD_CONFIG approach does only work for
> multi-config generators. As far as I understand CPACK_BUILD_CONFIG gets
> only set if the -C command line option was given to cpack. But this
> option is only added conditionally and omitted for Makefile builds:
>
>> void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
>> ...
>>   if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
>>     {
>>     singleLine.push_back("-C");
>>     singleLine.push_back(cmakeCfgIntDir);
>>     }
>
> Now I'm just wondering if conditionally setting -C / CPACK_BUILD_CONFIG
> is the right thing to do?

I don't know ... but as a local workaround you might be able to set 
CPACK_BUILD_CONFIG before include(CPack) conditionally when using 
single-configuration generators.

Assuming nothing else messes with CMAKE_BUILD_TYPE when using 
multi-configuration generators e.g.:

   if(CMAKE_BUILD_TYPE)
     set(CPACK_BUILD_TYPE ${CMAKE_BUILD_TYPE})
   endif()

   include(CPack)

Nils


More information about the cmake-developers mailing list