project(NitroThor) cmake_minimum_required(VERSION 3.9.0) set (PACKAGE_NAME NitroThor) set (CMAKE_VERBOSE_MAKEFILE ON) set (CMAKE_CXX_STANDARD 20) # --- ThorVG: CPU (software) engine --- set (THORVG ${CMAKE_SOURCE_DIR}/../cpp/thorvg) file (GLOB THORVG_SOURCES "${THORVG}/src/common/*.cpp" "${THORVG}/src/renderer/*.cpp" "${THORVG}/src/renderer/cpu_engine/*.cpp" "${THORVG}/src/loaders/raw/*.cpp" ) # --- ThorVG: GL (OpenGL ES) engine — Android only --- file (GLOB THORVG_GL_SOURCES "${THORVG}/src/renderer/gpu_engine/*.cpp" "${THORVG}/src/renderer/gpu_engine/gl/*.cpp" ) # Define C++ library and add all sources add_library(${PACKAGE_NAME} SHARED src/main/cpp/cpp-adapter.cpp src/main/cpp/ThorJni.cpp ../cpp/ThorRenderer.cpp ../cpp/android/ThorGlRenderer.cpp ${THORVG_SOURCES} ${THORVG_GL_SOURCES} ) # ThorVG emits internal warnings; don't let them fail the build. set_source_files_properties(${THORVG_SOURCES} ${THORVG_GL_SOURCES} PROPERTIES COMPILE_FLAGS "-w") # Enable the ThorVG GL engine targeting OpenGL ES (Android). target_compile_definitions(${PACKAGE_NAME} PRIVATE THORVG_GL_ENGINE_SUPPORT THORVG_GL_TARGET_GLES ) # --- SIMD note --- # ThorVG ships a hand-written NEON rasterizer (THORVG_NEON_VECTOR_SUPPORT), but a # measured A/B on the Moto G35 (arm64, -O3) showed it *neutral* vs leaving it off: # at -O3 clang already auto-vectorizes ThorVG's C blend/fill loops with NEON, so # the explicit intrinsics add nothing (they were marginally slower for the small- # shape workload tested). We therefore rely on -O3 auto-vectorization and do not # define THORVG_NEON_VECTOR_SUPPORT. (Re-enable + A/B if a large-fill-dominated # workload turns out to benefit; armv7 would additionally need -mfpu=neon.) # Hot rasterizer/geometry math benefits from aggressive, but still IEEE-safe, # float codegen. (-ffast-math is intentionally avoided: it breaks NaN handling # ThorVG relies on for degenerate paths.) target_compile_options(${PACKAGE_NAME} PRIVATE -fno-math-errno -fomit-frame-pointer) # Add Nitrogen specs :) include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroThor+autolinking.cmake) # Set up local includes include_directories( "src/main/cpp" "../cpp" "../cpp/thorvg-config" "${THORVG}/inc" "${THORVG}/src/common" "${THORVG}/src/renderer" "${THORVG}/src/renderer/cpu_engine" "${THORVG}/src/renderer/gpu_engine" "${THORVG}/src/renderer/gpu_engine/gl" "${THORVG}/src/loaders/raw" ) find_library(LOG_LIB log) find_library(JNIGRAPHICS_LIB jnigraphics) find_library(GLES_LIB GLESv3) find_library(EGL_LIB EGL) # Link all libraries together target_link_libraries( ${PACKAGE_NAME} ${LOG_LIB} ${JNIGRAPHICS_LIB} # <-- AndroidBitmap_lockPixels ${GLES_LIB} # <-- OpenGL ES 3 ${EGL_LIB} # <-- EGL context android # <-- Android core )