110 lines
3.9 KiB
CMake
110 lines
3.9 KiB
CMake
|
|
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>"
|
||
|
|
)
|
||
|
|
add_link_options(
|
||
|
|
"$<$<NOT:$<CONFIG:DEBUG>>:/DEBUG:FULL>"
|
||
|
|
"$<$<NOT:$<CONFIG:DEBUG>>:/OPT:REF>"
|
||
|
|
"$<$<NOT:$<CONFIG:DEBUG>>:/OPT:ICF>"
|
||
|
|
)
|
||
|
|
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()
|
||
|
|
|
||
|
|
# ── External Dependencies ───────────────────────────────────────
|
||
|
|
include(cmake/Dependencies.cmake)
|
||
|
|
|
||
|
|
# ── Subprojects (ordered by dependency) ─────────────────────────
|
||
|
|
|
||
|
|
# Licensing SDK (built from source — cross-platform)
|
||
|
|
add_subdirectory(anslicensing)
|
||
|
|
|
||
|
|
# Infrastructure (depend on anslicensing)
|
||
|
|
add_subdirectory(ANSLicensingSystem)
|
||
|
|
add_subdirectory(ANSLibsLoader)
|
||
|
|
|
||
|
|
# Core modules (minimal deps — most are cross-platform)
|
||
|
|
add_subdirectory(ANSMOT)
|
||
|
|
add_subdirectory(ANSUtilities)
|
||
|
|
add_subdirectory(ANSODTrainingEngine)
|
||
|
|
|
||
|
|
if(WIN32)
|
||
|
|
# Windows-only modules (LabVIEW, DirectX, ONVIF, etc.)
|
||
|
|
add_subdirectory(ANNHUB)
|
||
|
|
add_subdirectory(ANSIO)
|
||
|
|
add_subdirectory(ANSONVIF)
|
||
|
|
endif()
|
||
|
|
|
||
|
|
add_subdirectory(ANSLLM)
|
||
|
|
|
||
|
|
# Messaging — cross-platform if libs are available
|
||
|
|
add_subdirectory(ANSPulsar)
|
||
|
|
add_subdirectory(ANSRabbitMQ)
|
||
|
|
|
||
|
|
# Engine layer (CUDA + inference frameworks)
|
||
|
|
if(ANSCORE_HAS_CUDA)
|
||
|
|
add_subdirectory(ANSODEngine)
|
||
|
|
add_subdirectory(ANSOCR)
|
||
|
|
add_subdirectory(ANSFR)
|
||
|
|
add_subdirectory(ANSLPR)
|
||
|
|
endif()
|
||
|
|
|
||
|
|
add_subdirectory(ANSCV)
|
||
|
|
|
||
|
|
# Facade
|
||
|
|
add_subdirectory(ANSLIB)
|