Skip to content

Commit

Permalink
Update cmake files for 3.30
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Jul 7, 2024
1 parent 36fbcce commit bb5f13f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 36 deletions.
6 changes: 1 addition & 5 deletions cmake/dependencies/binaryen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 5 additions & 0 deletions cmake/dependencies/boost.cmake
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 1 addition & 4 deletions cmake/dependencies/libcpppre.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/dependencies/nlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/dependencies/roar.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
44 changes: 26 additions & 18 deletions cmake/dependencies/webview.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,52 @@ 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 $<TARGET_PROPERTY:webview,INTERFACE_INCLUDE_DIRECTORIES>)
set_target_properties(webview-iface PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:webview-iface,INTERFACE_INCLUDE_DIRECTORIES>)

target_link_libraries(
webview
webview-iface
INTERFACE
$<$<PLATFORM_ID:Linux>:
PkgConfig::webkit2
>
)
target_link_libraries(
webview
webview-iface
INTERFACE
$<$<PLATFORM_ID:Windows>:
Version.lib
WebView2Loader.lib
>
)
target_link_libraries(
webview
webview-iface
INTERFACE
$<$<PLATFORM_ID:Darwin>:
"-framework WebKit"
Expand All @@ -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)
Expand All @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions nui/src/nui/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ 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
PRIVATE
project-settings
PUBLIC
fmt
webview
webview-iface
portable_file_dialogs
nlohmann_json
roar
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nui/src/nui/frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb5f13f

Please sign in to comment.