diff --git a/core/ANSModelPackage/ANSModelKeys.h b/core/ANSModelPackage/ANSModelKeys.h index 7b1c050..3f7bafc 100644 --- a/core/ANSModelPackage/ANSModelKeys.h +++ b/core/ANSModelPackage/ANSModelKeys.h @@ -13,11 +13,14 @@ // package is refused with a sentence that says why. That is what keeps the key // out of a developer's checkout without keeping developers out of the code. -#if defined(__has_include) -#if __has_include("ANSModelKeysGenerated.h") +// ANSCORE_HAVE_BUILTIN_MODEL_KEYS is set by CMake when the ceremony's +// generated header is there. It is not tested with __has_include on purpose: +// that test leaves no dependency for the build system, so a key emitted after +// a build would not take effect until someone cleaned — and the failure looks +// exactly like a missing key, which on a release machine means shipping an +// engine that silently cannot open a package. +#if defined(ANSCORE_HAVE_BUILTIN_MODEL_KEYS) #include "ANSModelKeysGenerated.h" -#define ANSCORE_HAVE_BUILTIN_MODEL_KEYS 1 -#endif #endif #include "ANSModelPackage.h" diff --git a/core/ANSModelPackage/CMakeLists.txt b/core/ANSModelPackage/CMakeLists.txt index 7ee0c6a..8451ae0 100644 --- a/core/ANSModelPackage/CMakeLists.txt +++ b/core/ANSModelPackage/CMakeLists.txt @@ -28,4 +28,15 @@ else() endif() endif() +# 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() + set_target_properties(ANSModelPackage PROPERTIES POSITION_INDEPENDENT_CODE ON)