Skip to content

Commit

Permalink
CMake cross-platform setup
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Dec 5, 2024
1 parent 281cd8c commit 670022f
Show file tree
Hide file tree
Showing 90 changed files with 6,596 additions and 468 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Submodules/vcpkg"]
path = Submodules/vcpkg
url = https://github.com/microsoft/vcpkg.git
[submodule "Submodules/thorvg"]
path = Submodules/thorvg
url = https://github.com/thorvg/thorvg.git
46 changes: 13 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
cmake_minimum_required(VERSION 3.29)

# toolchain
set(EXTERN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Submodules)
set(CMAKE_TOOLCHAIN_FILE ${EXTERN_PATH}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE PATH "vcpkg toolchain file")
include(${EXTERN_PATH}/cmake/toolchain.cmake)

project(ThorVGApp)
set(VERSION_MAJOR "1")
set(VERSION_MINOR "2")
set(VERSION_ALTER "2")
set(VERSION_BUILD "1")
set(PACKAGE_NAME "ru.xitrix.Moonlight")
set(PSN_VERSION "01.00")
set(PROJECT_AUTHOR "XITRIX")
set(PROJECT_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/img/moonlight_icon.jpg)
set(PROJECT_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resources)
set(CMAKE_CXX_STANDARD 17)

add_definitions(
-DSK_TRIVIAL_ABI=[[clang::trivial_abi]]
)


add_subdirectory(${EXTERN_PATH})
add_subdirectory(${EXTERN_PATH}/UIKit)

add_executable(${PROJECT_NAME}
app/main.cpp
)

target_link_libraries(${PROJECT_NAME} PRIVATE
target_link_libraries(${PROJECT_NAME} PUBLIC
UIKit
)

if (APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
# MACOSX_BUNDLE_ICON_FILE "borealis.icns"
MACOSX_BUNDLE_COPYRIGHT "Copyright 2024 ${PROJECT_AUTHOR}"
# RESOURCE "${CMAKE_SOURCE_DIR}/app/borealis.icns"
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon"
MACOSX_BUNDLE_GUI_IDENTIFIER "${PACKAGE_NAME}"
MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_BUILD}"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_ALTER}"
MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_ALTER}"
XCODE_ATTRIBUTE_INFOPLIST_KEY_LSApplicationCategoryType "public.app-category.games" # Not work
XCODE_ATTRIBUTE_INSTALL_PATH $(LOCAL_APPS_DIR)
XCODE_EMBED_RESOURCES_CODE_SIGN_ON_COPY ON # Not work
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY ON # Not work
XCODE_EMBED_FRAMEWORKS "${IOS_FRAMEWORKS}"
INSTALL_RPATH "@executable_path/../Frameworks"
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks"
)

target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Foundation" "-framework VideoToolbox" "-framework AVKit" "-framework MetalKit")
endif ()
setup_project()
96 changes: 0 additions & 96 deletions Submodules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,99 +1,3 @@
# ThorVG

#project(Skia)
#
#add_library(Skia
#
#)
#
##target_sources(${PROJECT_NAME} PRIVATE
##)
#
#target_link_libraries(Skia
# skia/out/mac-arm64/libskia.a
#)
#
#target_include_directories(Skia PUBLIC
# skia/include
#)

project(ThorVG)

add_definitions(
-DTHORVG_GL_TARGET_GLES
-DTHORVG_LOG_ENABLED
)

add_library(${PROJECT_NAME}
thorvg/src/common/tvgCompressor.cpp
thorvg/src/common/tvgMath.cpp
thorvg/src/common/tvgStr.cpp

# Renderer
thorvg/src/renderer/tvgAccessor.cpp
thorvg/src/renderer/tvgAnimation.cpp
thorvg/src/renderer/tvgCanvas.cpp
thorvg/src/renderer/tvgFill.cpp
thorvg/src/renderer/tvgGlCanvas.cpp
thorvg/src/renderer/tvgInitializer.cpp
thorvg/src/renderer/tvgLoader.cpp
thorvg/src/renderer/tvgPaint.cpp
thorvg/src/renderer/tvgPicture.cpp
thorvg/src/renderer/tvgRender.cpp
thorvg/src/renderer/tvgSaver.cpp
thorvg/src/renderer/tvgScene.cpp
thorvg/src/renderer/tvgShape.cpp
thorvg/src/renderer/tvgSwCanvas.cpp
thorvg/src/renderer/tvgTaskScheduler.cpp
thorvg/src/renderer/tvgText.cpp

# GL Renderer
thorvg/src/renderer/gl_engine/tvgGlGeometry.cpp
thorvg/src/renderer/gl_engine/tvgGlGpuBuffer.cpp
thorvg/src/renderer/gl_engine/tvgGlProgram.cpp
thorvg/src/renderer/gl_engine/tvgGlRenderer.cpp
thorvg/src/renderer/gl_engine/tvgGlRenderPass.cpp
thorvg/src/renderer/gl_engine/tvgGlRenderTarget.cpp
thorvg/src/renderer/gl_engine/tvgGlRenderTask.cpp
thorvg/src/renderer/gl_engine/tvgGlShader.cpp
thorvg/src/renderer/gl_engine/tvgGlShaderSrc.cpp
thorvg/src/renderer/gl_engine/tvgGlTessellator.cpp

# SW Renderer
thorvg/src/renderer/sw_engine/tvgSwFill.cpp
thorvg/src/renderer/sw_engine/tvgSwImage.cpp
thorvg/src/renderer/sw_engine/tvgSwMath.cpp
thorvg/src/renderer/sw_engine/tvgSwMemPool.cpp
thorvg/src/renderer/sw_engine/tvgSwPostEffect.cpp
thorvg/src/renderer/sw_engine/tvgSwRaster.cpp
thorvg/src/renderer/sw_engine/tvgSwRenderer.cpp
thorvg/src/renderer/sw_engine/tvgSwRle.cpp
thorvg/src/renderer/sw_engine/tvgSwShape.cpp
thorvg/src/renderer/sw_engine/tvgSwStroke.cpp

# Loaders
thorvg/src/loaders/raw/tvgRawLoader.cpp
)

target_include_directories(${PROJECT_NAME} PUBLIC
thorvg/inc
)

target_include_directories(${PROJECT_NAME} PRIVATE
thorvg_config
thorvg/inc
thorvg/src/common
thorvg/src/renderer
thorvg/src/renderer/gl_engine
thorvg/src/renderer/sw_engine
thorvg/src/loaders/raw
)


target_include_directories(${PROJECT_NAME} PUBLIC
angle/mac/Headers
)

project(GLAD)

add_library(GLAD
Expand Down
65 changes: 44 additions & 21 deletions Submodules/UIKit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,62 @@
project(UIKit)

find_package(SDL2 REQUIRED)

add_definitions(
-DSK_TRIVIAL_ABI=[[clang::trivial_abi]]
)

add_library(${PROJECT_NAME}
# APPLE
if (APPLE)
list(APPEND platform_sources
lib/platforms/apple/SkiaInit.mm
)

# MAC
if (PLATFORM_DESKTOP)
list(APPEND google_angle_libs
${EXTERN_PATH}/angle/mac/libEGL.dylib
${EXTERN_PATH}/angle/mac/libGLESv2.dylib
)

list(APPEND platform_libs
${google_angle_libs}
${EXTERN_PATH}/skia/out/mac-arm64-angle/libskia.a
${EXTERN_PATH}/skia/out/mac-arm64-angle/libwindow.a
)
# IOS
elseif (PLATFORM_IOS)
list(APPEND FRAMEWORKS ${EXTERN_PATH}/angle/ios/MetalANGLE.framework)

list(APPEND platform_libs
${google_angle_libs}
${EXTERN_PATH}/skia/out/ios-arm64-angle/libskia.a
${EXTERN_PATH}/skia/out/ios-arm64-angle/libwindow.a
)
endif ()

set_property(
SOURCE ${google_angle_libs}
PROPERTY MACOSX_PACKAGE_LOCATION "Frameworks"
)
endif ()

add_library(UIKit
lib/Application.cpp
lib/platforms/mac/SkiaInit.mm
${platform_sources}
)

target_include_directories(${PROJECT_NAME} PUBLIC
target_include_directories(UIKit PUBLIC
${EXTERN_PATH}/skia
include
lib
)


list(APPEND google_angle_libs
${EXTERN_PATH}/angle/mac/libEGL.dylib
${EXTERN_PATH}/angle/mac/libGLESv2.dylib
)

find_package(SDL2 REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC
${google_angle_libs}
${EXTERN_PATH}/skia/out/mac-arm64-angle/libskia.a
${EXTERN_PATH}/skia/out/mac-arm64-angle/libwindow.a
target_link_libraries(UIKit PUBLIC
${platform_libs}
SDL2::SDL2
GLAD
ThorVG
)

set_property(
SOURCE ${google_angle_libs}
PROPERTY MACOSX_PACKAGE_LOCATION "Frameworks"
)
if (APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
XCODE_EMBED_FRAMEWORKS "${FRAMEWORKS}")
endif ()
8 changes: 8 additions & 0 deletions Submodules/UIKit/include/platforms/SkiaInit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "tools/window/WindowContext.h"

#include <functional>
#include <SDL.h>

std::unique_ptr<skwindow::WindowContext> skiaMakeWindow(SDL_Window* window);

bool platformRunLoop(const std::function<bool()>& runLoop);
12 changes: 0 additions & 12 deletions Submodules/UIKit/include/platforms/mac/SkiaInit.h

This file was deleted.

3 changes: 1 addition & 2 deletions Submodules/UIKit/lib/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
#include <include/core/SkCanvas.h>

// SKIA METAL GPU
#include "include/gpu/ganesh/GrDirectContext.h"
#include "include/gpu/ganesh/GrBackendSurface.h"

#include "platforms/mac/SkiaInit.h"
#include "platforms/SkiaInit.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkImageFilters.h"

Expand Down
Loading

0 comments on commit 670022f

Please sign in to comment.