2026-03-28 16:54:11 +11:00
|
|
|
|
cmake_minimum_required(VERSION 3.28)
|
|
|
|
|
|
cmake_policy(SET CMP0167 NEW) # Suppress FindBoost removal warning
|
|
|
|
|
|
|
|
|
|
|
|
# ── CUDA is optional (not available on macOS) ───────────────────
|
|
|
|
|
|
include(CheckLanguage)
|
|
|
|
|
|
check_language(CUDA)
|
|
|
|
|
|
if(CMAKE_CUDA_COMPILER)
|
|
|
|
|
|
project(ANSCORE LANGUAGES C CXX CUDA)
|
|
|
|
|
|
set(ANSCORE_HAS_CUDA ON)
|
|
|
|
|
|
set(CMAKE_CUDA_STANDARD 20)
|
|
|
|
|
|
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
|
|
|
|
|
|
set(CMAKE_CUDA_ARCHITECTURES 75 80 86 87 88 89 90 100)
|
|
|
|
|
|
if(MSVC)
|
|
|
|
|
|
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use-fast-math -Xcompiler=/utf-8")
|
|
|
|
|
|
else()
|
|
|
|
|
|
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use-fast-math")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
else()
|
|
|
|
|
|
project(ANSCORE LANGUAGES C CXX)
|
|
|
|
|
|
set(ANSCORE_HAS_CUDA OFF)
|
|
|
|
|
|
message(WARNING "CUDA not found — GPU-accelerated modules will be limited")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# ── Platform detection ──────────────────────────────────────────
|
|
|
|
|
|
if(WIN32)
|
|
|
|
|
|
set(ANSCORE_PLATFORM "windows")
|
|
|
|
|
|
elseif(APPLE)
|
|
|
|
|
|
set(ANSCORE_PLATFORM "macos")
|
|
|
|
|
|
else()
|
|
|
|
|
|
set(ANSCORE_PLATFORM "linux")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
message(STATUS "ANSCORE platform: ${ANSCORE_PLATFORM}, CUDA: ${ANSCORE_HAS_CUDA}")
|
|
|
|
|
|
|
|
|
|
|
|
# ── Global Settings ──────────────────────────────────────────────
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
|
|
|
|
|
|
|
# Output all binaries to a single directory
|
|
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
|
|
|
|
|
|
|
|
# ── Compiler Configuration ──────────────────────────────────────
|
|
|
|
|
|
if(MSVC)
|
|
|
|
|
|
# Dynamic CRT (/MD) — matches original VS projects and prebuilt libs like HWiNFO
|
|
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
|
|
|
|
|
|
|
|
|
|
|
# Apply MSVC flags only to C/C++ (not CUDA — nvcc doesn't understand them)
|
|
|
|
|
|
add_compile_options(
|
|
|
|
|
|
"$<$<COMPILE_LANGUAGE:C,CXX>:/W3>"
|
|
|
|
|
|
"$<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>"
|
|
|
|
|
|
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<NOT:$<CONFIG:MINSIZEREL>>>:/Zi>"
|
2026-04-20 12:18:43 +10:00
|
|
|
|
# RelWithDebInfo: keep /O2 but disable inlining so debuggers can land
|
|
|
|
|
|
# breakpoints on small dispatch functions (e.g. avframeToCVMat).
|
|
|
|
|
|
"$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:RelWithDebInfo>>:/Ob0>"
|
2026-03-28 16:54:11 +11:00
|
|
|
|
)
|
|
|
|
|
|
add_link_options(
|
|
|
|
|
|
"$<$<NOT:$<CONFIG:DEBUG>>:/DEBUG:FULL>"
|
2026-04-20 12:18:43 +10:00
|
|
|
|
# /OPT:REF and /OPT:ICF improve Release size/perf but confuse the
|
|
|
|
|
|
# debugger (folds identical functions, strips unused ones). Apply
|
|
|
|
|
|
# them to Release only, not RelWithDebInfo.
|
|
|
|
|
|
"$<$<CONFIG:Release>:/OPT:REF>"
|
|
|
|
|
|
"$<$<CONFIG:Release>:/OPT:ICF>"
|
|
|
|
|
|
"$<$<CONFIG:RelWithDebInfo>:/OPT:NOREF>"
|
|
|
|
|
|
"$<$<CONFIG:RelWithDebInfo>:/OPT:NOICF>"
|
2026-03-28 16:54:11 +11:00
|
|
|
|
)
|
|
|
|
|
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS)
|
|
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
|
|
|
|
|
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
|
|
|
|
|
|
if(NOT APPLE)
|
|
|
|
|
|
add_link_options(-Wl,--as-needed)
|
|
|
|
|
|
endif()
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
2026-04-12 17:16:16 +10:00
|
|
|
|
# ── DebugView logging toggle ────────────────────────────────────
|
|
|
|
|
|
# When ON, every ANS_DBG(...) call across the whole tree expands to an
|
|
|
|
|
|
# OutputDebugStringA() call visible in Sysinternals DebugView (Dbgview.exe).
|
|
|
|
|
|
# This is the single switch for verbose runtime diagnostics in ANSLPR,
|
|
|
|
|
|
# ANSCV (RTSP lifecycle, HW decoder auto-config), ANSODEngine (NV12 fast
|
|
|
|
|
|
# path, ORT/TRT engine selection), ANSFR (face recognizer state), etc.
|
|
|
|
|
|
#
|
|
|
|
|
|
# Enable it to diagnose field issues (e.g. "ALPR worked for a while then
|
|
|
|
|
|
# stopped"), then turn it back OFF for production because every ANS_DBG
|
|
|
|
|
|
# call adds a kernel round-trip and string formatting cost.
|
|
|
|
|
|
#
|
|
|
|
|
|
# Usage:
|
|
|
|
|
|
# cmake -B build -DANSCORE_DEBUGVIEW=ON # enable
|
|
|
|
|
|
# cmake -B build -DANSCORE_DEBUGVIEW=OFF # disable (default)
|
|
|
|
|
|
#
|
|
|
|
|
|
# Or toggle in CLion/VS: edit the cache variable ANSCORE_DEBUGVIEW.
|
|
|
|
|
|
option(ANSCORE_DEBUGVIEW "Enable ANS_DBG OutputDebugString logging for DebugView" OFF)
|
|
|
|
|
|
if(ANSCORE_DEBUGVIEW)
|
|
|
|
|
|
add_compile_definitions(ANSCORE_DEBUGVIEW=1)
|
|
|
|
|
|
message(STATUS "ANSCORE_DEBUGVIEW = ON — ANS_DBG verbose logging ENABLED (DebugView)")
|
|
|
|
|
|
else()
|
|
|
|
|
|
message(STATUS "ANSCORE_DEBUGVIEW = OFF — ANS_DBG verbose logging disabled (production)")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
2026-04-20 12:18:43 +10:00
|
|
|
|
# ── Vendored libyuv (submodule: 3rdparty/libyuv) ────────────────
|
|
|
|
|
|
# SIMD-optimized YUV conversion library. Only genuinely fast on toolchains
|
|
|
|
|
|
# that understand GCC inline assembly (Clang/clang-cl/GCC) — 144 of its
|
|
|
|
|
|
# SIMD row functions live in row_gcc.cc. MSVC (cl.exe) can only compile the
|
|
|
|
|
|
# 8 routines in row_win.cc, so on MSVC libyuv silently falls back to the
|
|
|
|
|
|
# scalar C code in row_common.cc and runs ~10× slower than OpenCV+IPP's
|
|
|
|
|
|
# cv::cvtColor(COLOR_YUV2BGR_I420). Do NOT enable on MSVC builds.
|
|
|
|
|
|
#
|
|
|
|
|
|
# Default: OFF. Enable with `-DANSCORE_USE_LIBYUV=ON` only after switching
|
|
|
|
|
|
# the project's compiler to clang-cl / clang / gcc.
|
|
|
|
|
|
option(ANSCORE_USE_LIBYUV "Use libyuv for YUV→BGR conversion (only effective on Clang/GCC, NOT MSVC)" OFF)
|
|
|
|
|
|
if(ANSCORE_USE_LIBYUV AND EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/libyuv/CMakeLists.txt")
|
|
|
|
|
|
if(MSVC AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
|
|
message(WARNING "ANSCORE_USE_LIBYUV=ON but compiler is MSVC cl.exe — "
|
|
|
|
|
|
"libyuv's SIMD paths (row_gcc.cc) won't compile. "
|
|
|
|
|
|
"Expect ~10× slowdown vs cv::cvtColor. "
|
|
|
|
|
|
"Use clang-cl (LLVM) instead, or keep ANSCORE_USE_LIBYUV=OFF.")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
# Prevent libyuv from finding a system libjpeg and enabling HAVE_JPEG
|
|
|
|
|
|
# (we don't use libyuv's MJPEG codepaths; avoids an unnecessary runtime dep).
|
|
|
|
|
|
set(CMAKE_DISABLE_FIND_PACKAGE_JPEG TRUE)
|
|
|
|
|
|
add_subdirectory(3rdparty/libyuv EXCLUDE_FROM_ALL)
|
|
|
|
|
|
set(ANSCORE_HAS_LIBYUV ON)
|
|
|
|
|
|
message(STATUS "libyuv: ENABLED (vendored from 3rdparty/libyuv, static target 'yuv')")
|
|
|
|
|
|
else()
|
|
|
|
|
|
set(ANSCORE_HAS_LIBYUV OFF)
|
|
|
|
|
|
message(STATUS "libyuv: DISABLED — using cv::cvtColor+IPP path (fast on MSVC)")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
2026-03-28 16:54:11 +11:00
|
|
|
|
# ── External Dependencies ───────────────────────────────────────
|
|
|
|
|
|
include(cmake/Dependencies.cmake)
|
|
|
|
|
|
|
|
|
|
|
|
# ── Subprojects (ordered by dependency) ─────────────────────────
|
|
|
|
|
|
|
2026-03-28 19:56:39 +11:00
|
|
|
|
# Core — licensing & infrastructure
|
|
|
|
|
|
add_subdirectory(core/anslicensing)
|
|
|
|
|
|
add_subdirectory(core/ANSLicensingSystem)
|
|
|
|
|
|
add_subdirectory(core/ANSLibsLoader)
|
|
|
|
|
|
|
|
|
|
|
|
# Modules — feature DLLs (cross-platform)
|
|
|
|
|
|
add_subdirectory(modules/ANSMOT)
|
|
|
|
|
|
add_subdirectory(modules/ANSUtilities)
|
|
|
|
|
|
add_subdirectory(modules/ANSTrainingEngine)
|
|
|
|
|
|
add_subdirectory(modules/ANSLLM)
|
|
|
|
|
|
|
|
|
|
|
|
# Integrations — hardware & protocol DLLs
|
2026-03-28 16:54:11 +11:00
|
|
|
|
if(WIN32)
|
2026-03-28 19:56:39 +11:00
|
|
|
|
add_subdirectory(integrations/ANNHUB)
|
|
|
|
|
|
add_subdirectory(integrations/ANSIO)
|
|
|
|
|
|
add_subdirectory(integrations/ANSONVIF)
|
2026-03-28 16:54:11 +11:00
|
|
|
|
endif()
|
2026-03-28 19:56:39 +11:00
|
|
|
|
add_subdirectory(integrations/ANSPulsar)
|
|
|
|
|
|
add_subdirectory(integrations/ANSRabbitMQ)
|
2026-03-28 16:54:11 +11:00
|
|
|
|
|
2026-03-28 19:56:39 +11:00
|
|
|
|
# Modules — engine layer (CUDA + inference frameworks)
|
2026-03-28 16:54:11 +11:00
|
|
|
|
if(ANSCORE_HAS_CUDA)
|
2026-03-28 19:56:39 +11:00
|
|
|
|
add_subdirectory(modules/ANSODEngine)
|
|
|
|
|
|
add_subdirectory(modules/ANSOCR)
|
|
|
|
|
|
add_subdirectory(modules/ANSFR)
|
|
|
|
|
|
add_subdirectory(modules/ANSLPR)
|
2026-03-28 16:54:11 +11:00
|
|
|
|
endif()
|
2026-03-28 19:56:39 +11:00
|
|
|
|
add_subdirectory(modules/ANSCV)
|
2026-03-28 16:54:11 +11:00
|
|
|
|
|
|
|
|
|
|
# Facade
|
|
|
|
|
|
add_subdirectory(ANSLIB)
|
2026-03-28 19:56:39 +11:00
|
|
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
|
|
add_subdirectory(tests)
|