2026-09-12 21:24:53 +10:00
|
|
|
# ANSModelPackage — reading an ANS model package (.ansmodel).
|
|
|
|
|
#
|
|
|
|
|
# Header-only apart from the vendored curves, and deliberately free of the
|
|
|
|
|
# heavy dependencies around it: no CUDA, no OpenCV, no LabVIEW. That is what
|
|
|
|
|
# lets it build — and be tested — on every platform, including the ones where
|
|
|
|
|
# the engine layer does not build at all.
|
|
|
|
|
add_library(ANSModelPackage STATIC
|
|
|
|
|
${CMAKE_SOURCE_DIR}/3rdparty/monocypher/monocypher.c
|
|
|
|
|
${CMAKE_SOURCE_DIR}/3rdparty/monocypher/monocypher-ed25519.c
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_include_directories(ANSModelPackage PUBLIC
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
${CMAKE_SOURCE_DIR}/3rdparty/monocypher
|
|
|
|
|
)
|
|
|
|
|
|
2026-09-13 08:00:51 +10:00
|
|
|
# nlohmann/json, wherever this machine keeps it: the ANSLibs tree on Windows,
|
|
|
|
|
# vcpkg, or the system elsewhere. Asked for by name rather than assumed — the
|
|
|
|
|
# Windows branch used to point at vcpkg alone, and on a real build machine the
|
|
|
|
|
# header lives under ANSLibs, so every target that linked this one failed to
|
|
|
|
|
# find it while the engines, which add ANSLibs themselves, compiled fine.
|
|
|
|
|
find_path(ANSCORE_NLOHMANN_INCLUDE nlohmann/json.hpp
|
|
|
|
|
HINTS ${ANSLIBS_DIR} ${VCPKG_INCLUDE_DIR}
|
|
|
|
|
/opt/homebrew/include /usr/local/include /usr/include)
|
|
|
|
|
if(ANSCORE_NLOHMANN_INCLUDE)
|
|
|
|
|
target_include_directories(ANSModelPackage PUBLIC ${ANSCORE_NLOHMANN_INCLUDE})
|
|
|
|
|
message(STATUS "ANSModelPackage: nlohmann/json at ${ANSCORE_NLOHMANN_INCLUDE}")
|
2026-09-12 21:24:53 +10:00
|
|
|
else()
|
2026-09-13 08:00:51 +10:00
|
|
|
message(WARNING "nlohmann/json.hpp not found — ANSModelPackage will not build")
|
2026-09-12 21:24:53 +10:00
|
|
|
endif()
|
|
|
|
|
|
2026-09-13 05:56:58 +10:00
|
|
|
# The model-package key, decided at configure time: see ANSModelKeys.h for why
|
|
|
|
|
# this is not an __has_include test. PUBLIC so every engine that opens a
|
|
|
|
|
# package is compiled with the same answer.
|
|
|
|
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ANSModelKeysGenerated.h")
|
|
|
|
|
target_compile_definitions(ANSModelPackage PUBLIC ANSCORE_HAVE_BUILTIN_MODEL_KEYS=1)
|
|
|
|
|
message(STATUS "ANSModelPackage: key present — packages can be opened")
|
|
|
|
|
else()
|
|
|
|
|
message(STATUS "ANSModelPackage: no key — packages cannot be opened "
|
|
|
|
|
"(run ansmodel-keys emit --product anscore, then re-run cmake)")
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-09-26 18:15:13 +10:00
|
|
|
# BCryptGenRandom, behind the content key and nonces pack() draws (ANSCsprng.h).
|
|
|
|
|
if(WIN32)
|
|
|
|
|
target_link_libraries(ANSModelPackage PUBLIC bcrypt)
|
|
|
|
|
endif()
|
|
|
|
|
|
2026-09-12 21:24:53 +10:00
|
|
|
set_target_properties(ANSModelPackage PROPERTIES POSITION_INDEPENDENT_CODE ON)
|