Modules/Sketch2D/CMakeLists.txt
agent a0bea7136b Build the Android targets
The NDK configures with -DANDROID, which collided with the OS::ANDROID
enumerator, so every translation unit that included Environment.hpp
failed; drop the macro at the top of the header. GLFW and its ImGui
backends are desktop only, so they are built under NOT ANDROID, and both
app entry points now take the android_app the backend already passes
instead of stashing it in a global. The Android executables include
AndroidEntry.hpp from GraphicApplicationBackend, so link it explicitly.
2026-11-02 11:00:51 +03:00

55 lines
4.2 KiB
CMake

project(Sketch2D)
add_subdirectory(src/libs)
if (ANDROID)
add_library(sketch2dAndroid SHARED ./src/apps/AndroidEntry.cpp ./src/apps/AndroidUpdater.cpp)
target_include_directories(sketch2dAndroid PRIVATE ${ANDROID_NDK}/sources/android/native_app_glue)
target_link_libraries(sketch2dAndroid PRIVATE ${PROJECT_NAME}Application GraphicApplicationBackend)
target_link_options(sketch2dAndroid PRIVATE "-Wl,-u,ANativeActivity_onCreate")
else ()
add_executable(sketch2dApp ./src/apps/Entry.cpp)
target_link_libraries(sketch2dApp ${PROJECT_NAME}Application)
modules_add_desktop_entry(sketch2dApp
ID online.ilushabasic.sketch2d
NAME Sketch2D
COMMENT "Raster sketching and painting"
ICON ${CMAKE_SOURCE_DIR}/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
CATEGORIES Graphics 2DGraphics RasterGraphics)
endif ()
if (NOT ANDROID)
### -------------------------- Benchmark -------------------------- ###
add_library(${PROJECT_NAME}BenchCore STATIC
./bench/BenchInput.cpp ./bench/BenchReport.cpp
./bench/BenchInput.hpp ./bench/BenchReport.hpp ./bench/BenchScenario.hpp
)
target_include_directories(${PROJECT_NAME}BenchCore PUBLIC ./bench/)
target_link_libraries(${PROJECT_NAME}BenchCore PUBLIC ${PROJECT_NAME}UI GraphicApplication)
add_executable(sketch2dBench ./bench/BenchMain.cpp ./bench/BenchRunner.cpp ./bench/BenchScenario.cpp ./bench/BenchRunner.hpp)
target_link_libraries(sketch2dBench ${PROJECT_NAME}BenchCore ${PROJECT_NAME}Application)
add_test(NAME sketch2dBenchSmoke COMMAND ${MODULES_HEADLESS_WAYLAND} $<TARGET_FILE:sketch2dBench> --quick --repeats 2 --filter "size 20" --out ${CMAKE_BINARY_DIR}/Sketch2D/bench-smoke WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
endif ()
### -------------------------- Headless UI Tests -------------------------- ###
if (NOT ANDROID)
add_executable(Test${PROJECT_NAME} ./tests/ui/Sketch2DUiTests.cpp ./tests/ui/TouchUiTests.cpp ./tests/ui/StudioUiTests.cpp ./tests/ui/ViewLockTests.cpp ./tests/engine/SketchLibraryTests.cpp ./tests/engine/UpdateTests.cpp ./tests/brush/BrushTests.cpp ./tests/brush/StabilizerTests.cpp ./tests/document/CommandTests.cpp ./tests/document/HistoryTests.cpp ./tests/document/LayerTests.cpp ./tests/color/CompositorTests.cpp ./tests/color/MipTests.cpp ./tests/color/CanvasTests.cpp ./tests/document/BenchTests.cpp ./tests/engine/SessionTests.cpp ./tests/brush/StrokePainterTests.cpp ./tests/brush/BrushCursorTests.cpp ./tests/brush/BrushToolsTests.cpp ./tests/color/ColorCommandTests.cpp ./tests/color/ColorPanelTests.cpp ./tests/color/ColorHistoryTests.cpp ./tests/tools/PickerToolTests.cpp ./tests/tools/ViewToolTests.cpp ./tests/tools/BucketToolTests.cpp ./tests/tools/GradientToolTests.cpp ./tests/tools/MoveToolTests.cpp ./tests/tools/TransformToolTests.cpp ./tests/tools/CropToolTests.cpp ./tests/tools/SelectionTests.cpp ./tests/tools/MagicWandTests.cpp ./tests/tools/SelectionEditTests.cpp ./tests/color/FilterTests.cpp ./tests/document/ClipboardTests.cpp ./tests/color/AdjustmentTests.cpp ./tests/tools/LineTests.cpp ./tests/engine/EngineScenarioTests.cpp ./tests/engine/EngineTests.cpp ./tests/brush/BrushWorkflowTests.cpp ./tests/brush/StrokePathTests.cpp ./tests/brush/DabMaskTests.cpp ./tests/brush/DabMaskBenchTests.cpp ./bench/BenchScenario.cpp ../Widgets/tests/Main.cpp)
target_include_directories(Test${PROJECT_NAME} PRIVATE ./tests/support)
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME}BenchCore WidgetsComponentsTesting UnitTest++)
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
endif ()
### -------------------------- Application Integration Tests -------------------------- ###
if (NOT ANDROID)
add_executable(Test${PROJECT_NAME}App ./tests/integration/Sketch2DAppTests.cpp ../Widgets/tests/Main.cpp)
target_include_directories(Test${PROJECT_NAME}App PRIVATE ./tests/support)
target_link_libraries(Test${PROJECT_NAME}App ${PROJECT_NAME}Application WidgetsTesting UnitTest++)
add_test(NAME Test${PROJECT_NAME}App COMMAND ${MODULES_HEADLESS_WAYLAND} $<TARGET_FILE:Test${PROJECT_NAME}App> WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
endif ()
if (NOT ANDROID)
file(COPY "${GRAPHIC_APPLICATION_RESOURCES}" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
file(COPY "rsc/icons" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/rsc/")
endif ()