-
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.
- Loading branch information
Showing
3 changed files
with
194 additions
and
147 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,155 +1,171 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
set(VCPKG_LIBRARY_LINKAGE static) | ||
|
||
# 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(fmt CONFIG REQUIRED) | ||
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 | ||
fmt::fmt | ||
nlohmann_json::nlohmann_json | ||
Boost::system | ||
Boost::filesystem | ||
CLI11::CLI11) | ||
target_compile_definitions( | ||
${target} | ||
PRIVATE NOMINMAX | ||
FMT_HEADER_ONLY | ||
$<$<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) | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Linux-Release-x64-libstdc++.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") | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
set(VCPKG_LIBRARY_LINKAGE static) | ||
|
||
# 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(fmt CONFIG REQUIRED) | ||
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 | ||
fmt::fmt | ||
nlohmann_json::nlohmann_json | ||
Boost::system | ||
Boost::filesystem | ||
CLI11::CLI11) | ||
target_compile_definitions( | ||
${target} | ||
PRIVATE NOMINMAX | ||
FMT_HEADER_ONLY | ||
$<$<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) | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-macOS-Release-arm64.zip | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Linux-Release-x64-libstdc++.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_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) | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-macOS-Release-x64.zip | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Windows-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) | ||
set(SKIA_REPOSITORY | ||
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Windows-Release-x64.zip | ||
|
||
FetchContent_Declare(skia | ||
URL ${SKIA_REPOSITORY} | ||
SOURCE_DIR ${SKIA_DIR} | ||
DOWNLOAD_EXTRACT_TIMESTAMP true | ||
) | ||
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-x64) | ||
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" | ||
) | ||
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) | ||
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" | ||
) | ||
|
||
# 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() | ||
|
||
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) |
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<!-- Application Metadata --> | ||
<key>CFBundleName</key> | ||
<string>Blur</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>Blur</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.f0e.blur</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleExecutable</key> | ||
<string>Blur</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleIconFile</key> | ||
<string>blur</string> | ||
|
||
<!-- High DPI Support --> | ||
<key>NSHighResolutionCapable</key> | ||
<true/> | ||
|
||
<!-- macOS Specific Settings --> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
</dict> | ||
</plist> |