MarkSchofield / WindowsToolchain

A repository containing a CMake toolchain for using MSVC
MIT License
106 stars 19 forks source link

Wrap add_compile_options options into $<$<COMPILE_LANGUAGE:CXX>:option> #70

Closed bebuch closed 1 year ago

bebuch commented 1 year ago
# Module support
if(VS_EXPERIMENTAL_MODULE)
    add_compile_options(/experimental:module)
    add_compile_options(/stdIfcDir "${VS_TOOLSET_PATH}/ifc/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}")
endif()

These options are forwareded to all compilers, including the NASM assambler in my case. Wrapping the options into a language specific generator expression should solve the problem.

# Module support
if(VS_EXPERIMENTAL_MODULE)
    add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/experimental:module>)
    add_compile_options($<$<COMPILE_LANGUAGE:CXX>:/stdIfcDir> $<$<COMPILE_LANGUAGE:CXX>:"${VS_TOOLSET_PATH}/ifc/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}">)
endif()
MarkSchofield commented 1 year ago

Thanks! I think I should actually be using CMAKE_CXX_FLAGS_INIT.

bebuch commented 1 year ago

I adjusted my own toolchain to use CMAKE_CXX_FLAGS_INIT instead and it worked as expected. Looks to be the right solution. ;-)