It turns out, as of CMake 3.11, this works.

Thanks to Beren Minor's commit 48f7e2d3, CMake 3.11 has a new 
CMakeInitializeConfigs.cmake module that handles all _INIT variables, even 
custom configuration ones, correctly.

Yay!

[0] 
https://gitlab.kitware.com/cmake/cmake/commit/48f7e2d30000dc57c31d3e3ab81077950704a587

> Hi,
> 
> Do CMAKE_<LANG>_FLAGS_<CONFIG>_INIT variables not automatically populate 
> CMAKE_<LANG>_FLAGS_<CONFIG> variables for *custom* > configurations? 
> 
> When I use the _INIT variables for one of the default configuration names, 
> e.g. CMAKE_C_FLAGS_DEBUG_INIT or > CMAKE_C_FLAGS_RELEASE_INIT, they correctly 
> populate their "usage" counterparts, i.e. CMAKE_C_FLAGS_DEBUG and > 
> CMAKE_C_FLAGS_RELEASE respectively.
> 
> But when I set the _INIT variables for a custom configuration name (created 
> through CMAKE_CONFIGURATION_TYPES), e.g. > CMAKE_C_FLAGS_LALALAND_INIT, CMake 
> fails the compiler tests, because CMAKE_C_FLAGS_LALALAND does not exist.
> 
> My setup:
> 
> *CMakeLists.txt*
> set( CMAKE_USER_MAKE_RULES_OVERRIDE 
> "${CMAKE_CURRENT_LIST_DIR}/CompilerOptions.cmake" )
> project( Test )
> add_executable( "${CMAKE_CURRENT_LIST_DIR}/main.c" )
> 
> *CompilerOptions.cmake*
> set( CMAKE_CONFIGURATION_TYPES "Debug" "Release" "Lalaland" )
> 
> set( CMAKE_C_FLAGS_DEBUG_INIT "/Od" )
> set( CMAKE_C_FLAGS_RELEASE_INIT "/Ox" )
> set( CMAKE_C_FLAGS_LALALAND_INIT "/Ob2" )
> 
> set( CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/machine:x64" )
> set( CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/machine:x64" )
> set( CMAKE_EXE_LINKER_FLAGS_LALALAND_INIT "/machine:x64" )
> 
> The error I get is:
> 
> > CMake Error: Error required internal CMake variable not set, cmake may not 
> > be built correctly.
> > Missing variable is:
> > CMAKE_C_FLAGS_LALALAND
> 
> > CMake Error: Error required internal CMake variable not set, cmake may not 
> > be built correctly.
> > Missing variable is:
> > CMAKE_EXE_LINKER_FLAGS_LALALAND
> 
> > CMake Error at C:/Program 
> > Files/CMake/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:37 
> > (try_compile):
> > Failed to generate test project build system.
> 
> This is just a simplified example, in my actual usecase I have two custom 
> configurations and both fail to populate their > CMAKE_<LANG>_FLAGS_<CONFIG> 
> variables from their CMAKE_<LANG>_FLAGS_<CONFIG>_INIT variables.
> 
> Do I have to set the CMAKE_<LANG>_FLAGS_<CONFIG>_INIT variables for the 
> default CMake configuration names, but set the > actual 
> CMAKE_<LANG>_FLAGS_<CONFIG> variables for any custom configurations?
> 
> I am using CMake 3.10.3 and Visual Studio 11/14 Win64 generator.
> 
> Thanks,
> Marek

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to