Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 4.2)

include("${CMAKE_CURRENT_LIST_DIR}/_cmake/version.cmake")

Expand All @@ -12,11 +12,24 @@ set(NUI_JSON_DIAGNOSTICS ON CACHE BOOL "Enable json diagnostics for nlohmann_jso
set(WEBKIT_PATH "" CACHE PATH "Path to custom built WebKit, if empty, will use system WebKit")
set(WEBKIT_PACKAGE_NAME "webkitgtk-6.0" CACHE STRING "Pkg-config package name for WebKit, used if WEBKIT_PATH is set")

option(FETCH_YAML_CPP "Fetch yaml-cpp" ON)
option(BUILD_SHARED_LIBS "Do not build shared libraries" OFF)
option(BUILD_STATIC_LIBS "Build static libraries" ON)
option(NUI_SFTP_ENABLE_TESTING "Enable testing for nui-sftp" OFF)
option(FLATPAK_BUILD "Inform CMake that we are building for flatpak, this will set some additional flags and dependencies" OFF)
option(OFFLINE_BUILD "Inform CMake that we are building for offline environments (flatpak, yocto), this will set some additional flags and dependencies" OFF)
option(OMIT_FRONTEND_BUILD "Dont build the frontend, used primarily for flatpak, because using emscripten there is hell" OFF)
option(FETCH_RAPIDFUZZ "Fetch rapidfuzz" ON)
option(FETCH_SPDLOG "Fetch spdlog" ON)
option(FETCH_EFSW "Fetch efsw" ON)
option(FETCH_ICONS "Fetch icons" ON)

if (OFFLINE_BUILD)
include("${CMAKE_CURRENT_LIST_DIR}/_cmake/offline_build.cmake")
endif()

if (OMIT_FRONTEND_BUILD)
set(NUI_OMIT_FRONTEND ON CACHE BOOL "Do not build the frontend, sometimes useful for environments where emscripten is hard to use" FORCE)
endif()

include (${CMAKE_CURRENT_LIST_DIR}/_cmake/common_options.cmake)

Expand All @@ -40,10 +53,6 @@ if (NOT EMSCRIPTEN)
endif()
endif()

if (FLATPAK_BUILD)
include("${CMAKE_CURRENT_LIST_DIR}/_cmake/flatpak.cmake")
endif()

# Nui Dependency
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/Nui" EXCLUDE_FROM_ALL)

Expand Down
13 changes: 6 additions & 7 deletions _cmake/common_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ else()
target_compile_options(core-target INTERFACE -Wall -Wextra -Wpedantic)
endif()

set(MEM64 "")
set(EXCEPTIONS "")
if (EMSCRIPTEN)
if (WIN32)
set(MEM64 "-sMEMORY64=1")
target_compile_options(core-target INTERFACE -sMEMORY64=1)
target_link_options(core-target INTERFACE -sMEMORY64=1)
else()
# No support for WASM64 in webkit
set(MEM64 "-sWASM_BIGINT=1")
target_compile_options(core-target INTERFACE -sWASM_BIGINT=1)
endif()
set(EXCEPTIONS "-fexceptions")
target_link_options(core-target INTERFACE "-fexceptions")
endif()

target_compile_options(core-target INTERFACE -Wbad-function-cast -Wcast-function-type -fexceptions -pedantic $<$<CONFIG:DEBUG>:-g;-Werror=return-type> $<$<CONFIG:RELEASE>:-O3> ${MEM64} ${EXCEPTIONS})
target_link_options(core-target INTERFACE $<$<CONFIG:RELEASE>:-s;-static-libgcc;-static-libstdc++> ${MEM64} ${EXCEPTIONS})
target_compile_options(core-target INTERFACE -Wbad-function-cast -Wcast-function-type -fexceptions -pedantic $<$<CONFIG:DEBUG>:-g;-Werror=return-type> $<$<CONFIG:RELEASE>:-O3>)
target_link_options(core-target INTERFACE $<$<CONFIG:RELEASE>:-s;-static-libgcc;-static-libstdc++>)
target_compile_features(core-target INTERFACE cxx_std_23)
target_compile_definitions(core-target INTERFACE JSON_DIAGNOSTICS=1)
86 changes: 44 additions & 42 deletions _cmake/copy_styles_to_build_dir.cmake
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
add_custom_command(
OUTPUT
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/dropdown_menu.css"
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/file_grid.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/button.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/color_picker.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/resizeable_table.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/select.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/switch.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/text_input.css"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/styles/nui-file-explorer"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/dropdown_menu.css" "${CMAKE_BINARY_DIR}/styles/nui-file-explorer/dropdown_menu.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/file_grid.css" "${CMAKE_BINARY_DIR}/styles/nui-file-explorer/file_grid.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/button.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/button.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/color_picker.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/color_picker.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/resizeable_table.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/resizeable_table.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/select.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/select.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/switch.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/switch.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/text_input.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/text_input.css"
DEPENDS
"${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/dropdown_menu.css"
"${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/file_grid.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/button.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/color_picker.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/resizeable_table.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/select.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/switch.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/text_input.css"
)
if (NOT OMIT_FRONTEND_BUILD)
add_custom_command(
OUTPUT
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/dropdown_menu.css"
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/file_grid.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/button.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/color_picker.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/resizeable_table.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/select.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/switch.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/text_input.css"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/styles/nui-file-explorer"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/dropdown_menu.css" "${CMAKE_BINARY_DIR}/styles/nui-file-explorer/dropdown_menu.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/file_grid.css" "${CMAKE_BINARY_DIR}/styles/nui-file-explorer/file_grid.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/button.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/button.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/color_picker.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/color_picker.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/resizeable_table.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/resizeable_table.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/select.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/select.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/switch.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/switch.css"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/text_input.css" "${CMAKE_BINARY_DIR}/styles/5cript-nui-components/text_input.css"
DEPENDS
"${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/dropdown_menu.css"
"${CMAKE_SOURCE_DIR}/nui-file-explorer/styles/file_grid.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/button.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/color_picker.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/resizeable_table.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/select.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/switch.css"
"${CMAKE_SOURCE_DIR}/dependencies/5cript-nui-components/styles/text_input.css"
)

add_custom_target(
nui-sftp-style-copy
ALL
DEPENDS
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/dropdown_menu.css"
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/file_grid.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/button.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/color_picker.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/resizeable_table.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/select.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/switch.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/text_input.css"
)
add_custom_target(
nui-sftp-style-copy
ALL
DEPENDS
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/dropdown_menu.css"
"${CMAKE_BINARY_DIR}/styles/nui-file-explorer/file_grid.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/button.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/color_picker.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/resizeable_table.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/select.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/switch.css"
"${CMAKE_BINARY_DIR}/styles/5cript-nui-components/text_input.css"
)
endif()
17 changes: 10 additions & 7 deletions _cmake/dependencies/efsw.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
include(FetchContent)
FetchContent_Declare(
efsw
GIT_REPOSITORY https://github.com/SpartanJ/efsw.git
GIT_TAG 87abe599995d5646f5d83cf2e3a225bd73148b3a
)
if (FETCH_EFSW)
include(FetchContent)
# If you edit here, update work_dependencies.json
FetchContent_Declare(
efsw
GIT_REPOSITORY https://github.com/SpartanJ/efsw.git
GIT_TAG 87abe599995d5646f5d83cf2e3a225bd73148b3a
)

FetchContent_MakeAvailable(efsw)
FetchContent_MakeAvailable(efsw)
endif()
8 changes: 0 additions & 8 deletions _cmake/dependencies/expected.cmake

This file was deleted.

16 changes: 10 additions & 6 deletions _cmake/dependencies/rapidfuzz.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FetchContent_Declare(
rapidfuzz
GIT_REPOSITORY https://github.com/rapidfuzz/rapidfuzz-cpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(rapidfuzz)
if (FETCH_RAPIDFUZZ)
include(FetchContent)
# If you edit here, update work_dependencies.json
FetchContent_Declare(
rapidfuzz
GIT_REPOSITORY https://github.com/rapidfuzz/rapidfuzz-cpp.git
GIT_TAG b8ce411e91e01599d0697ad307933e05ddf3a723
)
FetchContent_MakeAvailable(rapidfuzz)
endif()
17 changes: 10 additions & 7 deletions _cmake/dependencies/spdlog.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "Use an external fmt library (provide it manually)" FORCE)

include(FetchContent)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.17.0
)
if (FETCH_SPDLOG)
include(FetchContent)
# If you edit here, update work_dependencies.json
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.17.0
)

FetchContent_MakeAvailable(spdlog)
FetchContent_MakeAvailable(spdlog)
endif()
17 changes: 10 additions & 7 deletions _cmake/dependencies/yaml-cpp.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
include(FetchContent)
if (FETCH_YAML_CPP)
include(FetchContent)

FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 89ff142b991af432b5d7a7cee55282f082a7e629
)
FetchContent_MakeAvailable(yaml-cpp)
# If you edit here, update work_dependencies.json
FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG 89ff142b991af432b5d7a7cee55282f082a7e629
)
FetchContent_MakeAvailable(yaml-cpp)
endif()
14 changes: 0 additions & 14 deletions _cmake/flatpak.cmake

This file was deleted.

43 changes: 43 additions & 0 deletions _cmake/offline_build.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# When this file is included its a build requiring to be offline (flatpak, yocto).
if(NOT EMSCRIPTEN)
# Installed into sytem:
set(NUI_FETCH_BOOST_PREPROCESSOR OFF CACHE BOOL "Do not fetch boost preprocessor, assume it is provided by the system" FORCE)
set(NUI_FETCH_INTERVAL_TREE OFF CACHE BOOL "Do not fetch interval tree, assume it is provided by the system" FORCE)
set(NUI_FETCH_BOOST_DESCRIBE OFF CACHE BOOL "Do not fetch boost describe, assume it is provided by the system" FORCE)
set(NUI_FETCH_BOOST_MP11 OFF CACHE BOOL "Do not fetch boost mp11, assume it is provided by the system" FORCE)
set(NUI_FETCH_NLOHMANN_JSON OFF CACHE BOOL "Do not fetch nlohmann_json, assume it is provided by the system" FORCE)
set(NUI_FETCH_BINARYEN OFF CACHE BOOL "Do not fetch binaryen, assume it is provided by the system" FORCE)
set(NUI_FETCH_FMT OFF CACHE BOOL "Do not fetch fmt, assume it is provided by the system" FORCE)
set(NUI_FIND_FMT OFF CACHE BOOL "Do not find fmt, assume it is provided by the system" FORCE)
set(ROAR_EXTERNAL_NLOHMANN_JSON ON CACHE BOOL "Use external nlohmann_json for roar, assume it is provided by the system" FORCE)

# Checked out in dependencies directory in source dir:
set(NUI_FETCH_TRAITS OFF CACHE BOOL "Do not fetch nui traits, assume it is in dependencies/traits" FORCE)
set(NUI_FETCH_WEBVIEW OFF CACHE BOOL "Do not fetch webview, assume it is in dependencies/webview" FORCE)
set(NUI_FETCH_PORTABLE_FILE_DIALOG OFF CACHE BOOL "Do not fetch portable file dialog, assume it is in dependencies/portable-file-dialogs" FORCE)
set(NUI_FETCH_ROAR OFF CACHE BOOL "Do not fetch roar, assume it is in dependencies/roar" FORCE)
set(ROAR_EXTERNAL_PROMISE ON CACHE BOOL "Use external promise-cpp for roar, assume it is in dependencies/promise-cpp" FORCE)
set(FETCH_YAML_CPP OFF CACHE BOOL "Do not fetch yaml-cpp, assume it is in dependencies/yml-cpp" FORCE)
set(FETCH_RAPIDFUZZ OFF CACHE BOOL "Do not fetch rapidfuzz, assume it is in dependencies/rapidfuzz" FORCE)
set(FETCH_SPDLOG OFF CACHE BOOL "Do not fetch spdlog, assume it is in dependencies/spdlog" FORCE)
set(FETCH_EFSW OFF CACHE BOOL "Do not fetch efsw, assume it is in dependencies/efsw" FORCE)
set(FETCH_ICONS OFF CACHE BOOL "Do not fetch icons, assume it is in dependencies/icons" FORCE)

set(OMIT_FRONTEND_BUILD ON CACHE BOOL "Do not build the frontend, in offline environments emscripten is hard to use" FORCE)

find_package(nlohmann_json REQUIRED)
find_package(fmt REQUIRED)

add_library(boost_preprocessor INTERFACE IMPORTED GLOBAL)
add_library(interval-tree INTERFACE IMPORTED GLOBAL)
add_library(boost_describe INTERFACE IMPORTED GLOBAL)
add_library(boost_mp11 INTERFACE IMPORTED GLOBAL)

add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/portable-file-dialogs" EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/webview" EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/yaml-cpp" EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/rapidfuzz" EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/spdlog" EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/efsw" EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/promise-cpp" EXCLUDE_FROM_ALL)
endif()
Loading