From f00e7ced27d76492988824bc734b0f193576b22d Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 9 Apr 2022 17:23:26 +0200 Subject: [PATCH] CMake: Fix monolithic build Don't target net and webview libraries directly, but use the wx_ function that will add it to the mono library when applicable. --- build/cmake/functions.cmake | 12 ++++++++++++ build/cmake/lib/CMakeLists.txt | 4 ++++ build/cmake/lib/net/CMakeLists.txt | 2 +- build/cmake/lib/webview/CMakeLists.txt | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 64ce309ec0..f08c9f09c1 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -513,6 +513,18 @@ macro(wx_lib_compile_definitions name) endif() endmacro() +# wx_add_dependencies(name dep) +# Forwards everything to add_dependencies() except for monolithic +# build where it collects all dependencies for linking with the mono lib +macro(wx_add_dependencies name) + if(wxBUILD_MONOLITHIC) + list(APPEND wxMONO_DEPENDENCIES ${ARGN}) + set(wxMONO_DEPENDENCIES ${wxMONO_DEPENDENCIES} PARENT_SCOPE) + else() + add_dependencies(${name} ${ARGN}) + endif() +endmacro() + # Set common properties for a builtin third party library function(wx_set_builtin_target_properties target_name) set(lib_unicode) diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index d270c2899a..570e2b581f 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -17,6 +17,7 @@ if(wxBUILD_MONOLITHIC) set(wxMONO_INCLUDE_DIRS) set(wxMONO_DEFINITIONS) set(wxMONO_NONCOMPILED_CPP_FILES) + set(wxMONO_DEPENDENCIES) endif() # Define third party libraries @@ -95,6 +96,9 @@ if(wxBUILD_MONOLITHIC) foreach(file ${wxMONO_NONCOMPILED_CPP_FILES}) set_source_files_properties(${file} PROPERTIES HEADER_FILE_ONLY TRUE) endforeach() + foreach(dep ${wxMONO_DEPENDENCIES}) + add_dependencies(wxmono ${dep}) + endforeach() wx_webview_copy_webview2_loader(wxmono) endif() diff --git a/build/cmake/lib/net/CMakeLists.txt b/build/cmake/lib/net/CMakeLists.txt index 57719c6c82..3043e369da 100644 --- a/build/cmake/lib/net/CMakeLists.txt +++ b/build/cmake/lib/net/CMakeLists.txt @@ -32,6 +32,6 @@ if(WIN32) endif() if (wxUSE_WEBREQUEST_CURL) - target_include_directories(wxnet PRIVATE ${CURL_INCLUDE_DIRS}) + wx_lib_include_directories(wxnet ${CURL_INCLUDE_DIRS}) wx_lib_link_libraries(wxnet PRIVATE ${CURL_LIBRARIES}) endif() diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 22409e507e..356b8458fa 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -152,5 +152,5 @@ if(WXGTK AND wxUSE_WEBVIEW_WEBKIT2) wx_install(TARGETS wxwebkit2_ext LIBRARY DESTINATION "lib/wx/${WX_WEB_EXT_VERSION}/web-extensions") - add_dependencies(wxwebview wxwebkit2_ext) + wx_add_dependencies(wxwebview wxwebkit2_ext) endif()