Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: auto download skia to dependencies and clangd #112

Merged
merged 3 commits into from
Nov 15, 2024
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
144 changes: 87 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ project(blur LANGUAGES CXX)
# global settings
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
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
Expand All @@ -21,79 +23,107 @@ 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/*"
)
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>
)
target_include_directories(${target} PRIVATE src)
target_link_libraries(
${target}
PRIVATE # Gdiplus
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u can remove gdiplus im not using it anymore

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>)
endfunction()

# cli
add_executable(blur-cli
${COMMON_SOURCES}
${CLI_SOURCES}
${RESOURCES}
src/cli/cli_pch.cpp
)
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)
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-arm64)

# 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) # dont care about x64
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(WIN32)
set(SKIA_REPOSITORY
https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Windows-Release-x64.zip
)
set(SKIA_LIBRARY_DIR ${SKIA_DIR}/out/Release-x64)
endif()

FetchContent_Declare(skia URL ${SKIA_REPOSITORY} SOURCE_DIR ${SKIA_DIR})
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
)
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)
set_target_properties(blur-gui PROPERTIES LINK_FLAGS "${LAF_BACKEND_LINK_FLAGS}")
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)
setup_target(blur-gui)
6 changes: 2 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
"inherits": "win-base",
"displayName": "Debug Build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
Expand All @@ -79,8 +78,7 @@
"inherits": "unix-base",
"displayName": "Debug Build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
Expand Down