From b69a0fbcba45e442be70fde5383b225ace68dcf1 Mon Sep 17 00:00:00 2001 From: Tuan Nghia Nguyen Date: Sun, 13 Sep 2026 08:00:51 +1000 Subject: [PATCH] fix(build): find nlohmann/json where the machine actually keeps it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The package library's Windows branch pointed at vcpkg alone. On a real Windows build machine the header lives in the ANSLibs tree, so anything linking this library failed with "Cannot open include file: 'nlohmann/json.hpp'" while the engines compiled fine — they add ANSLibs to their own include path and never noticed. Now it is searched for by name, with the ANSLibs tree, vcpkg and the usual system paths as hints, and the configure says where it found it. One code path for every platform instead of an assumption per platform. Co-Authored-By: Claude Opus 5 --- core/ANSModelPackage/CMakeLists.txt | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core/ANSModelPackage/CMakeLists.txt b/core/ANSModelPackage/CMakeLists.txt index 8451ae0..0aaac8f 100644 --- a/core/ANSModelPackage/CMakeLists.txt +++ b/core/ANSModelPackage/CMakeLists.txt @@ -14,18 +14,19 @@ target_include_directories(ANSModelPackage PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty/monocypher ) -# nlohmann/json comes from vcpkg on Windows and the system elsewhere, the same -# way ANSFR already takes it. -if(WIN32) - target_include_directories(ANSModelPackage PUBLIC ${VCPKG_INCLUDE_DIR}) +# 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}") else() - find_path(ANSCORE_NLOHMANN_INCLUDE nlohmann/json.hpp - HINTS /opt/homebrew/include /usr/local/include /usr/include) - if(ANSCORE_NLOHMANN_INCLUDE) - target_include_directories(ANSModelPackage PUBLIC ${ANSCORE_NLOHMANN_INCLUDE}) - else() - message(WARNING "nlohmann/json.hpp not found — ANSModelPackage will not build") - endif() + message(WARNING "nlohmann/json.hpp not found — ANSModelPackage will not build") endif() # The model-package key, decided at configure time: see ANSModelKeys.h for why