CMake: Improve precompiled headers for wxscintilla
The auto-generated header causes undefined members and identifiers in the standard c++ headers when using clang on macOS or Windows. Do not disable precompiled headers entirely but use the main Scintilla header as prefix header so there is at least a small speedup.
This commit is contained in:
parent
41d6bc579a
commit
61500907ee
@ -314,25 +314,21 @@ macro(wx_add_library name)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Enable cotire for target if precompiled headers are enabled
|
||||
# Enable cotire for target, use optional second argument for prec. header
|
||||
macro(wx_target_enable_precomp target_name)
|
||||
if(wxBUILD_PRECOMP)
|
||||
if(APPLE AND ${target_name} STREQUAL "wxscintilla")
|
||||
# TODO: workaround/fix cotire issue with wxscintilla when using Xcode
|
||||
else()
|
||||
set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
|
||||
cotire(${target_name})
|
||||
endif()
|
||||
target_compile_definitions(${target_name} PRIVATE WX_PRECOMP)
|
||||
if(NOT ${ARGV1} STREQUAL "")
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
COTIRE_CXX_PREFIX_HEADER_INIT ${ARGV1})
|
||||
endif()
|
||||
set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
|
||||
cotire(${target_name})
|
||||
endmacro()
|
||||
|
||||
# Enable precompiled headers for tests
|
||||
macro(wx_test_enable_precomp target_name)
|
||||
if(wxBUILD_PRECOMP)
|
||||
target_compile_definitions(${target_name} PRIVATE WX_PRECOMP)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
COTIRE_CXX_PREFIX_HEADER_INIT "${wxSOURCE_DIR}/tests/testprec.h")
|
||||
wx_target_enable_precomp(${target_name})
|
||||
wx_target_enable_precomp(${target_name} "${wxSOURCE_DIR}/tests/testprec.h")
|
||||
elseif(MSVC)
|
||||
target_compile_definitions(${target_name} PRIVATE NOPCH)
|
||||
endif()
|
||||
@ -341,10 +337,7 @@ endmacro()
|
||||
# Enable precompiled headers for samples
|
||||
macro(wx_sample_enable_precomp target_name)
|
||||
if(wxBUILD_PRECOMP)
|
||||
target_compile_definitions(${target_name} PRIVATE WX_PRECOMP)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
COTIRE_CXX_PREFIX_HEADER_INIT "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
||||
wx_target_enable_precomp(${target_name})
|
||||
wx_target_enable_precomp(${target_name} "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
||||
elseif(MSVC)
|
||||
target_compile_definitions(${target_name} PRIVATE NOPCH)
|
||||
endif()
|
||||
@ -355,10 +348,7 @@ macro(wx_finalize_lib target_name)
|
||||
set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE)
|
||||
if(wxBUILD_PRECOMP)
|
||||
if(TARGET ${target_name})
|
||||
target_compile_definitions(${target_name} PRIVATE WX_PRECOMP)
|
||||
set_target_properties(${target_name} PROPERTIES
|
||||
COTIRE_CXX_PREFIX_HEADER_INIT "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
||||
wx_target_enable_precomp(${target_name})
|
||||
wx_target_enable_precomp(${target_name} "${wxSOURCE_DIR}/include/wx/wxprec.h")
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
wx_lib_compile_definitions(${target_name} PRIVATE NOPCH)
|
||||
|
@ -164,7 +164,17 @@ target_compile_definitions(wxscintilla PUBLIC
|
||||
NO_CXX11_REGEX
|
||||
__WX__
|
||||
)
|
||||
wx_target_enable_precomp(wxscintilla)
|
||||
|
||||
if(wxBUILD_PRECOMP)
|
||||
# The auto-generated header causes undefined members and identifiers in the
|
||||
# standard c++ headers when using clang on macOS or Windows.
|
||||
# Do not disable precompiled headers entirely but use the main Scintilla
|
||||
# header as prefix header so there is at least a small speedup.
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND (APPLE OR WIN32))
|
||||
set(wxSCINTILLA_PREC_HEADER "${wxSOURCE_DIR}/src/stc/scintilla/include/Scintilla.h")
|
||||
endif()
|
||||
wx_target_enable_precomp(wxscintilla ${wxSCINTILLA_PREC_HEADER})
|
||||
endif()
|
||||
|
||||
wx_add_library(stc ${STC_FILES})
|
||||
wx_lib_include_directories(stc PRIVATE
|
||||
|
Loading…
Reference in New Issue
Block a user