From bb5f13f11fd0e340ae77565a534117f03f2f13b3 Mon Sep 17 00:00:00 2001 From: 5cript Date: Sun, 7 Jul 2024 02:59:26 +0200 Subject: [PATCH] Update cmake files for 3.30 --- cmake/dependencies/binaryen.cmake | 6 +--- cmake/dependencies/boost.cmake | 5 +++ cmake/dependencies/libcpppre.cmake | 5 +-- cmake/dependencies/nlohmann_json.cmake | 2 +- cmake/dependencies/roar.cmake | 2 +- cmake/dependencies/webview.cmake | 44 +++++++++++++++----------- nui/src/nui/backend/CMakeLists.txt | 12 +++---- nui/src/nui/frontend/CMakeLists.txt | 2 +- 8 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 cmake/dependencies/boost.cmake diff --git a/cmake/dependencies/binaryen.cmake b/cmake/dependencies/binaryen.cmake index d8cb21b4..1d7c85d8 100644 --- a/cmake/dependencies/binaryen.cmake +++ b/cmake/dependencies/binaryen.cmake @@ -13,9 +13,5 @@ if (NUI_FETCH_BINARYEN) DOWNLOAD_EXTRACT_TIMESTAMP TRUE URL "${NUI_BINARYEN_URL}" ) - FetchContent_GetProperties(binaryen_release) - if (binaryen_release_POPULATED) - else() - FetchContent_Populate(binaryen_release) - endif() + FetchContent_MakeAvailable(binaryen_release) endif() \ No newline at end of file diff --git a/cmake/dependencies/boost.cmake b/cmake/dependencies/boost.cmake new file mode 100644 index 00000000..5aa1b22a --- /dev/null +++ b/cmake/dependencies/boost.cmake @@ -0,0 +1,5 @@ +if (CMAKE_VERSION VERSION_LESS "3.30") + find_package(Boost 1.81.0 REQUIRED COMPONENTS system) +else() + find_package(Boost CONFIG 1.81.0 REQUIRED COMPONENTS system) +endif() \ No newline at end of file diff --git a/cmake/dependencies/libcpppre.cmake b/cmake/dependencies/libcpppre.cmake index ca0153a6..b43144db 100644 --- a/cmake/dependencies/libcpppre.cmake +++ b/cmake/dependencies/libcpppre.cmake @@ -10,10 +10,7 @@ if(NUI_FETCH_LIBCPPPRE) GIT_TAG ffc013750515f9e73342eb2a51efed284826ead3 ) - FetchContent_GetProperties(libcpppre) - if(NOT libcpppre_POPULATED) - FetchContent_Populate(libcpppre) - endif() + FetchContent_MakeAvailable(libcpppre) add_library(libcpppre INTERFACE) target_include_directories(libcpppre INTERFACE ${CMAKE_BINARY_DIR}/_deps/libcpppre-src) diff --git a/cmake/dependencies/nlohmann_json.cmake b/cmake/dependencies/nlohmann_json.cmake index fbf9920f..ad164eea 100644 --- a/cmake/dependencies/nlohmann_json.cmake +++ b/cmake/dependencies/nlohmann_json.cmake @@ -1,6 +1,6 @@ option(NUI_FETCH_NLOHMANN_JSON "Fetch nlohmann_json" ON) set(NUI_NLOHMANN_JSON_GIT_REPOSITORY "https://github.com/nlohmann/json.git" CACHE STRING "nlohmann_json git repository") -set(NUI_NLOHMANN_JSON_GIT_TAG "9dfa7226693012ed5bcf5ab3bc5d8e69d58006ab" CACHE STRING "nlohmann_json git tag") +set(NUI_NLOHMANN_JSON_GIT_TAG "8c391e04fe4195d8be862c97f38cfe10e2a3472e" CACHE STRING "nlohmann_json git tag") if(NUI_FETCH_NLOHMANN_JSON) include(FetchContent) diff --git a/cmake/dependencies/roar.cmake b/cmake/dependencies/roar.cmake index 8f352c8d..5eab5439 100644 --- a/cmake/dependencies/roar.cmake +++ b/cmake/dependencies/roar.cmake @@ -1,6 +1,6 @@ option(NUI_FETCH_ROAR "Fetch roar" ON) set(NUI_ROAR_REPOSITORY "https://github.com/5cript/roar.git" CACHE STRING "roar repository") -set(NUI_ROAR_TAG "f88b5f46e145376d392c43dc621690f58278582c" CACHE STRING "roar tag") +set(NUI_ROAR_TAG "45230b49703e8bb29cecb07c65927eb905b7c7fe" CACHE STRING "roar tag") if(NUI_FETCH_ROAR) include(FetchContent) diff --git a/cmake/dependencies/webview.cmake b/cmake/dependencies/webview.cmake index b8dd9ef4..b19daf57 100644 --- a/cmake/dependencies/webview.cmake +++ b/cmake/dependencies/webview.cmake @@ -13,35 +13,44 @@ set(NUI_WEBVIEW_TAG "c962bbe343c82d58ecfdfb2942d49cc2c1410705" CACHE STRING "Web if (NUI_FETCH_WEBVIEW) include(FetchContent) - FetchContent_Declare( - webview_raw - GIT_REPOSITORY ${NUI_WEBVIEW_REPOSITORY} - GIT_TAG ${NUI_WEBVIEW_TAG} - ) - FetchContent_Populate(webview_raw) - add_library(webview INTERFACE) + if (CMAKE_VERSION VERSION_LESS "3.28.0") + FetchContent_Declare( + webview_raw + GIT_REPOSITORY ${NUI_WEBVIEW_REPOSITORY} + GIT_TAG ${NUI_WEBVIEW_TAG} + ) + else() + FetchContent_Declare( + webview_raw + EXCLUDE_FROM_ALL + GIT_REPOSITORY ${NUI_WEBVIEW_REPOSITORY} + GIT_TAG ${NUI_WEBVIEW_TAG} + ) + endif() + FetchContent_MakeAvailable(webview_raw) + add_library(webview-iface INTERFACE) add_custom_target( - webview-prep + webview-nui-prep COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/include" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_BINARY_DIR}/_deps/webview_raw-src/webview.h" "${CMAKE_BINARY_DIR}/include/webview.h" COMMAND_EXPAND_LISTS ) - target_include_directories(webview INTERFACE "${CMAKE_BINARY_DIR}/include") - add_dependencies(webview webview-prep) + target_include_directories(webview-iface INTERFACE "${CMAKE_BINARY_DIR}/include") + add_dependencies(webview-iface webview-nui-prep) - set_target_properties(webview PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $) + set_target_properties(webview-iface PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $) target_link_libraries( - webview + webview-iface INTERFACE $<$: PkgConfig::webkit2 > ) target_link_libraries( - webview + webview-iface INTERFACE $<$: Version.lib @@ -49,7 +58,7 @@ if (NUI_FETCH_WEBVIEW) > ) target_link_libraries( - webview + webview-iface INTERFACE $<$: "-framework WebKit" @@ -65,7 +74,6 @@ if (NUI_FETCH_WEBVIEW) FetchContent_Declare( webview_binary URL ${NUI_WEBVIEW_BINARY_URL} - DOWNLOAD_EXTRACT_TIMESTAMP true ) FetchContent_GetProperties(webview_binary) if (webview_binary_POPULATED) @@ -79,14 +87,14 @@ if (NUI_FETCH_WEBVIEW) set(WEBVIEW_DLL_SUBDIRECTORY "x86") endif() - target_include_directories(webview INTERFACE "${CMAKE_BINARY_DIR}/_deps/webview_binary-src/build/native/include") + target_include_directories(webview-iface INTERFACE "${CMAKE_BINARY_DIR}/_deps/webview_binary-src/build/native/include") target_link_directories( - webview + webview-iface INTERFACE "${CMAKE_BINARY_DIR}/_deps/webview_binary-src/build/native/${WEBVIEW_DLL_SUBDIRECTORY}" "${CMAKE_BINARY_DIR}/lib" ) - add_dependencies(webview webview2-win) + add_dependencies(webview-iface webview2-win) add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/bin/WebView2Loader.dll" diff --git a/nui/src/nui/backend/CMakeLists.txt b/nui/src/nui/backend/CMakeLists.txt index f55d0fa5..0a62e8f8 100644 --- a/nui/src/nui/backend/CMakeLists.txt +++ b/nui/src/nui/backend/CMakeLists.txt @@ -17,13 +17,13 @@ add_library(Nui::backend ALIAS nui-backend) target_include_directories( nui-backend PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/../../../include - ${CMAKE_CURRENT_LIST_DIR}/../../../windows - ${CMAKE_BINARY_DIR}/include + "${CMAKE_CURRENT_LIST_DIR}/../../../include" + "${CMAKE_CURRENT_LIST_DIR}/../../../windows" + "${CMAKE_BINARY_DIR}/include" ) nui_set_project_warnings(nui-backend) -find_package(Boost 1.80.0 REQUIRED COMPONENTS system) +find_package(Boost CONFIG 1.80.0 REQUIRED COMPONENTS system) target_link_libraries( nui-backend @@ -31,7 +31,7 @@ target_link_libraries( project-settings PUBLIC fmt - webview + webview-iface portable_file_dialogs nlohmann_json roar @@ -47,7 +47,7 @@ if (APPLE) endif() if (WIN32) - target_include_directories(nui-backend PUBLIC ${CMAKE_BINARY_DIR}/libs/webview2/build/native/include) + target_include_directories(nui-backend PUBLIC "${CMAKE_BINARY_DIR}/libs/webview2/build/native/include") target_link_libraries(nui-backend PUBLIC WebView2Loader.dll ole32 shell32 shlwapi user32) target_sources(nui-backend PRIVATE diff --git a/nui/src/nui/frontend/CMakeLists.txt b/nui/src/nui/frontend/CMakeLists.txt index e0816389..749b6179 100644 --- a/nui/src/nui/frontend/CMakeLists.txt +++ b/nui/src/nui/frontend/CMakeLists.txt @@ -4,7 +4,7 @@ add_library(Nui::frontend ALIAS nui-frontend) target_include_directories( nui-frontend PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/../../../include + "${CMAKE_CURRENT_LIST_DIR}/../../../include" ) target_link_libraries( nui-frontend