From 0445b3eddda6c710480b9aac388c44c511e39864 Mon Sep 17 00:00:00 2001 From: Jeff Bland Date: Fri, 18 May 2018 06:50:58 -0600 Subject: [PATCH 1/6] Fix extraneous parens warning --- src/common/imagbmp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 200c4ea6c0..41e9e86dee 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -129,7 +129,7 @@ bool wxBMPHandler::SaveDib(wxImage *image, (format == wxBMP_8BPP_RED) || (format == wxBMP_8BPP_PALETTE) ) { // need to set a wxPalette to use this, HOW TO CHECK IF VALID, SIZE? - if ((format == wxBMP_8BPP_PALETTE) + if (format == wxBMP_8BPP_PALETTE #if wxUSE_PALETTE && !image->HasPalette() #endif // wxUSE_PALETTE From a3363cbbfbf7be2121356437d322c4698647314d Mon Sep 17 00:00:00 2001 From: Jeff Bland Date: Fri, 18 May 2018 06:51:40 -0600 Subject: [PATCH 2/6] Fix use of wxDateTime without check for wxUSE_DATETIME --- src/osx/cocoa/utils_base.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osx/cocoa/utils_base.mm b/src/osx/cocoa/utils_base.mm index 2e77ca9430..588392590b 100644 --- a/src/osx/cocoa/utils_base.mm +++ b/src/osx/cocoa/utils_base.mm @@ -159,6 +159,7 @@ wxString wxGetOsDescription() } /* static */ +#if wxUSE_DATETIME bool wxDateTime::GetFirstWeekDay(wxDateTime::WeekDay *firstDay) { wxCHECK_MSG( firstDay, false, wxS("output parameter must be non-null") ); @@ -169,3 +170,4 @@ bool wxDateTime::GetFirstWeekDay(wxDateTime::WeekDay *firstDay) *firstDay = wxDateTime::WeekDay(([calendar firstWeekday] - 1) % 7); return true; } +#endif // wxUSE_DATETIME From 26715a1fe03da2c487664a6d6c1090560764419b Mon Sep 17 00:00:00 2001 From: Jeff Bland Date: Fri, 18 May 2018 06:52:13 -0600 Subject: [PATCH 3/6] Fix warning with missing override --- include/wx/apptrait.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wx/apptrait.h b/include/wx/apptrait.h index 51168eb5d6..f93b90a621 100644 --- a/include/wx/apptrait.h +++ b/include/wx/apptrait.h @@ -194,7 +194,7 @@ class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits { public: #if !wxUSE_CONSOLE_EVENTLOOP - virtual wxEventLoopBase *CreateEventLoop() { return NULL; } + virtual wxEventLoopBase *CreateEventLoop() wxOVERRIDE { return NULL; } #endif // !wxUSE_CONSOLE_EVENTLOOP #if wxUSE_LOG From 8b18bbb9c72c4f75f6ec6f88c3e09b33e65e9c71 Mon Sep 17 00:00:00 2001 From: Jeff Bland Date: Fri, 18 May 2018 06:52:52 -0600 Subject: [PATCH 4/6] Fix uses of wxPalette without check for wxUSE_PALETTE --- include/wx/dcgraph.h | 3 +++ include/wx/gtk/dcclient.h | 3 +++ src/common/dcgraph.cpp | 2 ++ src/gtk/dcclient.cpp | 2 ++ 4 files changed, 10 insertions(+) diff --git a/include/wx/dcgraph.h b/include/wx/dcgraph.h index ce26481310..f9ac7461dd 100644 --- a/include/wx/dcgraph.h +++ b/include/wx/dcgraph.h @@ -83,7 +83,10 @@ public: virtual void SetBrush(const wxBrush& brush) wxOVERRIDE; virtual void SetBackground(const wxBrush& brush) wxOVERRIDE; virtual void SetBackgroundMode(int mode) wxOVERRIDE; + +#if wxUSE_PALETTE virtual void SetPalette(const wxPalette& palette) wxOVERRIDE; +#endif virtual void DestroyClippingRegion() wxOVERRIDE; diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index d4f09a984d..7911b74274 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -86,7 +86,10 @@ public: virtual void SetTextForeground( const wxColour &col ) wxOVERRIDE; virtual void SetTextBackground( const wxColour &col ) wxOVERRIDE; virtual void SetBackgroundMode( int mode ) wxOVERRIDE; + +#if wxUSE_PALETTE virtual void SetPalette( const wxPalette& palette ) wxOVERRIDE; +#endif virtual void DestroyClippingRegion() wxOVERRIDE; diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 1278a15249..6eafed2622 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -457,10 +457,12 @@ void* wxGCDCImpl::GetHandle() const return cgctx; } +#if wxUSE_PALETTE void wxGCDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) ) { } +#endif void wxGCDCImpl::SetBackgroundMode( int mode ) { diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 58b8d2f469..0f29c219f5 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1863,10 +1863,12 @@ void wxWindowDCImpl::SetBackgroundMode( int mode ) m_backgroundMode = mode; } +#if wxUSE_PALETTE void wxWindowDCImpl::SetPalette( const wxPalette& WXUNUSED(palette) ) { wxFAIL_MSG( wxT("wxWindowDCImpl::SetPalette not implemented") ); } +#endif void wxWindowDCImpl::UpdateClipBox() { From ffb44a2f3898c0abbbb885c4c33455083e5c2f27 Mon Sep 17 00:00:00 2001 From: Jeff Bland Date: Fri, 18 May 2018 06:53:30 -0600 Subject: [PATCH 5/6] Fix use of RECT in wxClientDisplayRect without including windows headers --- src/msw/display.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/msw/display.cpp b/src/msw/display.cpp index 961350a4cf..3256c65cbc 100644 --- a/src/msw/display.cpp +++ b/src/msw/display.cpp @@ -24,6 +24,8 @@ #pragma hdrstop #endif +#include "wx/msw/wrapwin.h" + #if wxUSE_DISPLAY #include "wx/display.h" @@ -38,7 +40,6 @@ #include "wx/sysopt.h" #include "wx/display_impl.h" -#include "wx/msw/wrapwin.h" #include "wx/msw/missing.h" #include "wx/msw/private.h" #include "wx/msw/private/hiddenwin.h" From fbf319641e56765d998e23a1eb09053a88071fed Mon Sep 17 00:00:00 2001 From: Jeff Bland Date: Fri, 18 May 2018 14:01:02 -0600 Subject: [PATCH 6/6] 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 --- build/cmake/demos/CMakeLists.txt | 2 +- build/cmake/functions.cmake | 103 +++++++++++++++++-------------- build/cmake/lib/CMakeLists.txt | 12 +++- 3 files changed, 70 insertions(+), 47 deletions(-) diff --git a/build/cmake/demos/CMakeLists.txt b/build/cmake/demos/CMakeLists.txt index e8f7f7d412..fe4637bb2f 100644 --- a/build/cmake/demos/CMakeLists.txt +++ b/build/cmake/demos/CMakeLists.txt @@ -35,7 +35,7 @@ function(wx_add_demo name) if(wxBUILD_SHARED) target_compile_definitions(${DEMO_NAME} PRIVATE WXUSINGDLL) endif() - target_link_libraries(${DEMO_NAME} core ${DEMO_LIBRARIES}) + wx_exe_link_libraries(${DEMO_NAME} core ${DEMO_LIBRARIES}) wx_set_common_target_properties(${DEMO_NAME}) set_target_properties(${DEMO_NAME} PROPERTIES FOLDER "Demos") set_target_properties(${DEMO_NAME} PROPERTIES diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index f0edeac4c3..e70cf91763 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -20,19 +20,24 @@ include(CMakePrintHelpers) # This function adds a list of headers to a variable while prepending # include/ to the path -function(wx_add_headers src_var) +macro(wx_add_headers src_var) set(headers) - list(REMOVE_AT ARGV 0) - foreach(header ${ARGV}) + foreach(header ${ARGN}) list(APPEND headers ${wxSOURCE_DIR}/include/${header}) if(header MATCHES "\\.cpp$") # .cpp files in include directory should not be compiled - set_source_files_properties(${wxSOURCE_DIR}/include/${header} - PROPERTIES HEADER_FILE_ONLY TRUE) + if (wxBUILD_MONOLITHIC) + # set_source_files_properties only works within the same CMakeLists.txt + list(APPEND wxMONO_NONCOMPILED_CPP_FILES ${wxSOURCE_DIR}/include/${header}) + set(wxMONO_NONCOMPILED_CPP_FILES ${wxMONO_NONCOMPILED_CPP_FILES} PARENT_SCOPE) + else() + set_source_files_properties(${wxSOURCE_DIR}/include/${header} + PROPERTIES HEADER_FILE_ONLY TRUE) + endif() endif() endforeach() - set(${src_var} ${${src_var}} ${headers} PARENT_SCOPE) -endfunction() + list(APPEND ${src_var} ${headers}) +endmacro() # Add sources from a ..._SRC variable and headers from a ..._HDR macro(wx_append_sources src_var source_base_name) @@ -269,45 +274,45 @@ endfunction() # first parameter is the name of the library # if the second parameter is set to IS_BASE a non UI lib is created # all additional parameters are source files for the library -function(wx_add_library name) +macro(wx_add_library name) cmake_parse_arguments(wxADD_LIBRARY "IS_BASE" "" "" ${ARGN}) set(src_files ${wxADD_LIBRARY_UNPARSED_ARGUMENTS}) - if(wxBUILD_MONOLITHIC AND NOT name STREQUAL "mono") + if(wxBUILD_MONOLITHIC AND NOT ${name} STREQUAL "mono") # collect all source files for mono library set(wxMONO_SRC_FILES ${wxMONO_SRC_FILES} ${src_files} PARENT_SCOPE) - return() - endif() - - if(wxBUILD_PRECOMP AND MSVC) - # Add dummy source file to be used by cotire for PCH creation - list(INSERT src_files 0 "${wxSOURCE_DIR}/src/common/dummy.cpp") - endif() - list(APPEND src_files ${wxSETUP_HEADER_FILE}) - - if(wxBUILD_SHARED) - set(wxBUILD_LIB_TYPE SHARED) - if(WIN32) - # Add WIN32 version information - list(APPEND src_files "${wxSOURCE_DIR}/src/msw/version.rc" "${wxSOURCE_DIR}/include/wx/msw/genrcdefs.h") - endif() else() - set(wxBUILD_LIB_TYPE STATIC) + + if(wxBUILD_PRECOMP AND MSVC) + # Add dummy source file to be used by cotire for PCH creation + list(INSERT src_files 0 "${wxSOURCE_DIR}/src/common/dummy.cpp") + endif() + list(APPEND src_files ${wxSETUP_HEADER_FILE}) + + if(wxBUILD_SHARED) + set(wxBUILD_LIB_TYPE SHARED) + if(WIN32) + # Add WIN32 version information + list(APPEND src_files "${wxSOURCE_DIR}/src/msw/version.rc" "${wxSOURCE_DIR}/include/wx/msw/genrcdefs.h") + endif() + else() + set(wxBUILD_LIB_TYPE STATIC) + endif() + + add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files}) + wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE}) + + # Setup install + wx_install(TARGETS ${name} + LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}" + ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}" + RUNTIME DESTINATION "lib${wxPLATFORM_LIB_DIR}" + BUNDLE DESTINATION Applications/wxWidgets + ) + + list(APPEND wxLIB_TARGETS ${name}) endif() - - add_library(${name} ${wxBUILD_LIB_TYPE} ${src_files}) - wx_set_target_properties(${name} ${wxADD_LIBRARY_IS_BASE}) - - # Setup install - wx_install(TARGETS ${name} - LIBRARY DESTINATION "lib${wxPLATFORM_LIB_DIR}" - ARCHIVE DESTINATION "lib${wxPLATFORM_LIB_DIR}" - RUNTIME DESTINATION "lib${wxPLATFORM_LIB_DIR}" - BUNDLE DESTINATION Applications/wxWidgets - ) - - set(wxLIB_TARGETS ${wxLIB_TARGETS} ${name} PARENT_SCOPE) -endfunction() +endmacro() # Enable cotire for target if precompiled headers are enabled macro(wx_target_enable_precomp target_name) @@ -336,13 +341,15 @@ endmacro() # Enable precompiled headers for wx libraries macro(wx_finalize_lib target_name) set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE) - if(wxBUILD_PRECOMP AND 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}) + 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}) + endif() elseif(MSVC) - target_compile_definitions(${target_name} PRIVATE NOPCH) + wx_lib_compile_definitions(${target_name} PRIVATE NOPCH) endif() endmacro() @@ -354,6 +361,8 @@ macro(wx_lib_link_libraries name) cmake_parse_arguments(_LIB_LINK "" "" "PUBLIC;PRIVATE" ${ARGN}) list(APPEND wxMONO_LIBS_PUBLIC ${_LIB_LINK_PUBLIC}) list(APPEND wxMONO_LIBS_PRIVATE ${_LIB_LINK_PRIVATE}) + set(wxMONO_LIBS_PUBLIC ${wxMONO_LIBS_PUBLIC} PARENT_SCOPE) + set(wxMONO_LIBS_PRIVATE ${wxMONO_LIBS_PRIVATE} PARENT_SCOPE) else() target_link_libraries(${name};${ARGN}) endif() @@ -377,6 +386,8 @@ macro(wx_lib_include_directories name) cmake_parse_arguments(_LIB_INCLUDE_DIRS "" "" "PUBLIC;PRIVATE" ${ARGN}) list(APPEND wxMONO_INCLUDE_DIRS_PUBLIC ${_LIB_INCLUDE_DIRS_PUBLIC}) list(APPEND wxMONO_INCLUDE_DIRS_PRIVATE ${_LIB_INCLUDE_DIRS_PRIVATE}) + set(wxMONO_INCLUDE_DIRS_PUBLIC ${wxMONO_INCLUDE_DIRS_PUBLIC} PARENT_SCOPE) + set(wxMONO_INCLUDE_DIRS_PRIVATE ${wxMONO_INCLUDE_DIRS_PRIVATE} PARENT_SCOPE) else() target_include_directories(${name};BEFORE;${ARGN}) endif() @@ -390,6 +401,8 @@ macro(wx_lib_compile_definitions name) cmake_parse_arguments(_LIB_DEFINITIONS "" "" "PUBLIC;PRIVATE" ${ARGN}) list(APPEND wxMONO_DEFINITIONS_PUBLIC ${_LIB_DEFINITIONS_PUBLIC}) list(APPEND wxMONO_DEFINITIONS_PRIVATE ${_LIB_DEFINITIONS_PRIVATE}) + set(wxMONO_DEFINITIONS_PUBLIC ${wxMONO_DEFINITIONS_PUBLIC} PARENT_SCOPE) + set(wxMONO_DEFINITIONS_PRIVATE ${wxMONO_DEFINITIONS_PRIVATE} PARENT_SCOPE) else() target_compile_definitions(${name};${ARGN}) endif() diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index 45a7696d01..4f8fc884c2 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -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