Fix monolithic build in cmake (wxBUILD_MONOLITHIC)

- Functions that set wxMONO_* vars need to set them in parent scope, from macros instead of functions (functions would need grandparent scope)
- Fix a conflict with xml library linking Mono which made core include the wrong png headers
- Fix setting of NOPCH on windows to go through the wx_lib_compile_definitions instead of target_compile_definitions so it carries to monolithic build
- Allow use of precompiled header in MSVC via calling wx_finalize_lib(mono)
- Introduce wxMONO_NONCOMPILED_CPP_FILES to deal with set_source_files_properties only applying within the current CMakeLists file
- Fix demos building against monolithic library by using wx_exe_link_libraries instead of target_link_libraries (similar to what the tests already do)

Closes #18074
This commit is contained in:
Jeff Bland
2018-05-18 14:01:02 -06:00
parent ffb44a2f38
commit fbf319641e
3 changed files with 70 additions and 47 deletions

View File

@@ -17,6 +17,7 @@ if(wxBUILD_MONOLITHIC)
set(wxMONO_LIBS_PUBLIC)
set(wxMONO_INCLUDE_DIRS_PRIVATE)
set(wxMONO_INCLUDE_DIRS_PUBLIC)
set(wxMONO_NONCOMPILED_CPP_FILES)
endif()
# Define third party libraries
@@ -39,7 +40,6 @@ endmacro()
# Define base libraries
set(LIBS base)
add_opt_lib(net wxUSE_SOCKETS)
add_opt_lib(xml wxUSE_XML)
# Define UI libraries
if(wxUSE_GUI)
@@ -62,6 +62,12 @@ if(wxUSE_GUI)
add_opt_lib(qa wxUSE_DEBUGREPORT)
endif() # wxUSE_GUI
# Include XML library last
# In the monolithic build, where all target properties (include dirs) from different targets are concatenated,
# wxml might include system expat, which might use Mono, which has it's own copy of png.
# Thus to ensure wx's core library includes the right png class, core must be processed first before xml
add_opt_lib(xml wxUSE_XML)
# Include cmake file for every library
foreach(LIB ${LIBS})
add_subdirectory(${LIB})
@@ -87,6 +93,10 @@ if(wxBUILD_MONOLITHIC)
target_compile_definitions(mono ${vis} ${wxMONO_DEFINITIONS_${vis}})
endif()
endforeach()
foreach(file ${wxMONO_NONCOMPILED_CPP_FILES})
set_source_files_properties(${file} PROPERTIES HEADER_FILE_ONLY TRUE)
endforeach()
wx_finalize_lib(mono)
endif()
# Propagate variable(s) to parent scope