-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove cli11 from gui dependencies & fix skia_dir configure issue
- Loading branch information
Showing
1 changed file
with
155 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,171 +1,168 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
set(VCPKG_LIBRARY_LINKAGE static) | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
set(VCPKG_LIBRARY_LINKAGE static) | ||
if (WIN32) | ||
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "") | ||
endif() | ||
|
||
# Force static runtime on Windows | ||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
|
||
project(blur LANGUAGES CXX) | ||
|
||
# global settings | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY | ||
${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) | ||
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}) | ||
|
||
# packages | ||
find_package(nlohmann_json CONFIG REQUIRED) | ||
find_package(Boost REQUIRED COMPONENTS system filesystem) | ||
find_package(CLI11 CONFIG REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
# source files | ||
file( | ||
GLOB_RECURSE | ||
COMMON_SOURCES | ||
"src/common/*.cpp" | ||
"src/common/*.hpp" | ||
"src/common/*.h") | ||
|
||
file( | ||
GLOB_RECURSE | ||
CLI_SOURCES | ||
"src/cli/*.cpp" | ||
"src/cli/*.hpp" | ||
"src/cli/*.h") | ||
|
||
file( | ||
GLOB_RECURSE | ||
GUI_SOURCES | ||
"src/gui/*.cpp" | ||
"src/gui/*.hpp" | ||
"src/gui/*.h") | ||
|
||
file(GLOB_RECURSE RESOURCES "resources/*") | ||
|
||
# common settings | ||
function(setup_target target) | ||
target_include_directories(${target} PRIVATE src) | ||
target_link_libraries( | ||
${target} | ||
PRIVATE nlohmann_json::nlohmann_json | ||
Boost::system | ||
Boost::filesystem) | ||
target_compile_definitions( | ||
${target} | ||
PRIVATE NOMINMAX | ||
$<$<CONFIG:Debug>:_DEBUG> | ||
$<$<CONFIG:Release>:NDEBUG>) | ||
if (WIN32) | ||
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "") | ||
set(${target} | ||
resources/resources_win32.rc) | ||
endif() | ||
|
||
# Force static runtime on Windows | ||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") | ||
|
||
project(blur LANGUAGES CXX) | ||
|
||
# global settings | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY | ||
${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) | ||
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}) | ||
|
||
# packages | ||
find_package(nlohmann_json CONFIG REQUIRED) | ||
find_package(Boost REQUIRED COMPONENTS system filesystem) | ||
find_package(CLI11 CONFIG REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
# source files | ||
file( | ||
GLOB_RECURSE | ||
COMMON_SOURCES | ||
"src/common/*.cpp" | ||
"src/common/*.hpp" | ||
"src/common/*.h") | ||
|
||
file( | ||
GLOB_RECURSE | ||
CLI_SOURCES | ||
"src/cli/*.cpp" | ||
"src/cli/*.hpp" | ||
"src/cli/*.h") | ||
|
||
file( | ||
GLOB_RECURSE | ||
GUI_SOURCES | ||
"src/gui/*.cpp" | ||
"src/gui/*.hpp" | ||
"src/gui/*.h") | ||
|
||
file(GLOB_RECURSE RESOURCES "resources/*") | ||
|
||
# common settings | ||
function(setup_target target) | ||
target_include_directories(${target} PRIVATE src) | ||
target_link_libraries( | ||
${target} | ||
PRIVATE # Gdiplus | ||
nlohmann_json::nlohmann_json | ||
Boost::system | ||
Boost::filesystem | ||
CLI11::CLI11) | ||
target_compile_definitions( | ||
${target} | ||
PRIVATE NOMINMAX | ||
$<$<CONFIG:Debug>:_DEBUG> | ||
$<$<CONFIG:Release>:NDEBUG>) | ||
if (WIN32) | ||
set(${target} | ||
resources/resources_win32.rc) | ||
endif() | ||
endfunction() | ||
|
||
# cli | ||
add_executable( | ||
blur-cli | ||
${COMMON_SOURCES} | ||
${CLI_SOURCES} | ||
${RESOURCES} | ||
src/cli/cli_pch.cpp) | ||
target_precompile_headers(blur-cli PRIVATE src/cli/cli_pch.h) | ||
setup_target(blur-cli) | ||
|
||
# gui | ||
set(LAF_BACKEND "skia") | ||
set(SKIA_DIR ${PROJECT_SOURCE_DIR}/dependencies/skia) | ||
|
||
# download platform specific skia to dependencies/skia | ||
include(FetchContent) | ||
|
||
if(UNIX AND NOT APPLE) | ||
endfunction() | ||
|
||
# cli | ||
add_executable( | ||
blur-cli | ||
${COMMON_SOURCES} | ||
${CLI_SOURCES} | ||
${RESOURCES} | ||
src/cli/cli_pch.cpp) | ||
target_link_libraries( | ||
blur-cli | ||
PRIVATE CLI11::CLI11) | ||
target_precompile_headers(blur-cli PRIVATE src/cli/cli_pch.h) | ||
setup_target(blur-cli) | ||
|
||
# gui | ||
set(LAF_BACKEND "skia") | ||
set(SKIA_DIR ${PROJECT_SOURCE_DIR}/dependencies/skia CACHE PATH "Path to Skia library directory") | ||
|
||
# download platform specific skia to dependencies/skia | ||
include(FetchContent) | ||
|
||
if(UNIX AND NOT APPLE) | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Linux-Release-x64-libstdc++.zip | ||
) | ||
elseif(APPLE) | ||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64") | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Linux-Release-x64-libstdc++.zip | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-macOS-Release-arm64.zip | ||
) | ||
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-x64) | ||
elseif(APPLE) | ||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64") | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-macOS-Release-arm64.zip | ||
) | ||
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-arm64) | ||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-macOS-Release-x64.zip | ||
) | ||
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-x64) | ||
else() | ||
message(FATAL_ERROR "Unsupported macOS architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}") | ||
endif() | ||
elseif(WIN32) | ||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Windows-Release-x64.zip | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-macOS-Release-x64.zip | ||
) | ||
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-x64) | ||
else() | ||
message(FATAL_ERROR "Unsupported macOS architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}") | ||
endif() | ||
|
||
FetchContent_Declare(skia | ||
URL ${SKIA_REPOSITORY} | ||
SOURCE_DIR ${SKIA_DIR} | ||
DOWNLOAD_EXTRACT_TIMESTAMP true | ||
elseif(WIN32) | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Windows-Release-x64.zip | ||
) | ||
endif() | ||
|
||
FetchContent_Declare(skia | ||
URL ${SKIA_REPOSITORY} | ||
SOURCE_DIR ${SKIA_DIR} | ||
DOWNLOAD_EXTRACT_TIMESTAMP true | ||
) | ||
|
||
FetchContent_GetProperties(skia) | ||
if(NOT skia_POPULATED) | ||
FetchContent_MakeAvailable(skia) | ||
endif() | ||
|
||
set(LAF_WITH_EXAMPLES OFF) # disable examples | ||
set(LAF_WITH_TESTS OFF) # disable tests | ||
|
||
add_subdirectory(dependencies/laf) | ||
|
||
add_executable( | ||
blur-gui WIN32 | ||
${COMMON_SOURCES} | ||
${GUI_SOURCES} | ||
${RESOURCES} | ||
src/gui/gui_pch.cpp) | ||
target_link_libraries( | ||
blur-gui | ||
PRIVATE laf-base | ||
laf-gfx | ||
laf-os | ||
ZLIB::ZLIB) | ||
target_precompile_headers(blur-gui PRIVATE src/gui/gui_pch.h) | ||
|
||
if(APPLE) | ||
target_link_libraries(blur-gui PRIVATE | ||
"-framework CoreVideo" | ||
"-framework CoreGraphics" | ||
) | ||
|
||
FetchContent_GetProperties(skia) | ||
if(NOT skia_POPULATED) | ||
FetchContent_MakeAvailable(skia) | ||
endif() | ||
# set(MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/src/Info.plist") | ||
|
||
set(LAF_WITH_EXAMPLES OFF) # disable examples | ||
set(LAF_WITH_TESTS OFF) # disable tests | ||
# set_target_properties(blur-gui PROPERTIES | ||
# MACOSX_BUNDLE TRUE | ||
# MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/Info.plist | ||
# ) | ||
|
||
add_subdirectory(dependencies/laf) | ||
# Specify the .icns file as the app icon | ||
set(MACOSX_BUNDLE_ICON_FILE blur.icns) | ||
|
||
add_executable( | ||
blur-gui WIN32 | ||
${COMMON_SOURCES} | ||
${GUI_SOURCES} | ||
${RESOURCES} | ||
src/gui/gui_pch.cpp) | ||
target_link_libraries( | ||
blur-gui | ||
PRIVATE laf-base | ||
laf-gfx | ||
laf-os | ||
ZLIB::ZLIB) | ||
target_precompile_headers(blur-gui PRIVATE src/gui/gui_pch.h) | ||
|
||
if(APPLE) | ||
target_link_libraries(blur-gui PRIVATE | ||
"-framework CoreVideo" | ||
"-framework CoreGraphics" | ||
) | ||
|
||
# set(MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/src/Info.plist") | ||
|
||
# set_target_properties(blur-gui PROPERTIES | ||
# MACOSX_BUNDLE TRUE | ||
# MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/Info.plist | ||
# ) | ||
|
||
# Specify the .icns file as the app icon | ||
set(MACOSX_BUNDLE_ICON_FILE blur.icns) | ||
|
||
# Ensure the .icns file is included in the app bundle's Resources folder | ||
set_source_files_properties(resources/blur.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") | ||
|
||
# Link the .icns file to the target | ||
target_sources(blur-gui PRIVATE resources/blur.icns) | ||
endif() | ||
# Ensure the .icns file is included in the app bundle's Resources folder | ||
set_source_files_properties(resources/blur.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") | ||
|
||
# Link the .icns file to the target | ||
target_sources(blur-gui PRIVATE resources/blur.icns) | ||
endif() | ||
|
||
set_target_properties(blur-gui PROPERTIES LINK_FLAGS | ||
"${LAF_BACKEND_LINK_FLAGS}") | ||
set_target_properties(blur-gui PROPERTIES OUTPUT_NAME "blur") | ||
setup_target(blur-gui) | ||
set_target_properties(blur-gui PROPERTIES LINK_FLAGS | ||
"${LAF_BACKEND_LINK_FLAGS}") | ||
set_target_properties(blur-gui PROPERTIES OUTPUT_NAME "blur") | ||
setup_target(blur-gui) |