CMake: Fix using Cotire for precompiled headers

Cotire doesn't work when $<COMPILE_LANGUAGE:CXX> is used.
This commit is contained in:
Maarten Bent
2023-06-13 21:19:44 +02:00
parent d7a98a44ea
commit e1f0a938f6
3 changed files with 11 additions and 5 deletions
+8 -4
View File
@@ -154,10 +154,14 @@ function(wx_set_common_target_properties target_name)
)
endif()
target_compile_options(${target_name} PRIVATE
${common_gcc_clang_compile_options}
$<$<COMPILE_LANGUAGE:CXX>:${common_gcc_clang_cpp_compile_options}>
)
# Using $<COMPILE_LANGUAGE:CXX> breaks cotire:
# Evaluation file to be written multiple times with different content.
if(NOT USE_COTIRE)
target_compile_options(${target_name} PRIVATE
${common_gcc_clang_compile_options}
$<$<COMPILE_LANGUAGE:CXX>:${common_gcc_clang_cpp_compile_options}>
)
endif()
endif()
if(wxUSE_NO_RTTI)
+2
View File
@@ -665,5 +665,7 @@ if((wxBUILD_PRECOMP STREQUAL "ON" AND CMAKE_VERSION VERSION_LESS "3.16") OR (wxB
if(NOT RESULT_VAR)
message(WARNING "precompiled header (PCH) test failed, it will be turned off")
wx_option_force_value(wxBUILD_PRECOMP OFF)
else()
set(USE_COTIRE ON)
endif()
endif()
+1 -1
View File
@@ -20,7 +20,7 @@ endif()
macro(wx_target_enable_precomp target_name prec_header)
if(wxBUILD_PRECOMP)
target_compile_definitions(${target_name} PRIVATE WX_PRECOMP)
if(CMAKE_VERSION VERSION_LESS "3.16" OR wxBUILD_PRECOMP STREQUAL "COTIRE")
if(USE_COTIRE)
set_target_properties(${target_name} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${prec_header})
set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(${target_name})