diff --git a/CHANGES.md b/CHANGES.md index 2b85bd3..b1c2148 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ like `__declspec(dllexport)` - Add target variants `CapnC::Runtime-Shared`, `CapnC::Runtime-Static` and `CapnC::Runtime-StaticExports` +- Hygiene only runs when the project is top-level. ## 0.9.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index a4b2332..2c27167 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,8 @@ option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static on # we try to enforce build hygiene. # You can override with either BUILD_HYGIENE=DISABLED or # BUILD_HYGIENE=ENABLED. -if(NOT BUILD_HYGIENE STREQUAL DISABLED) +# Hygiene is only done if the project is top-level. +if(PROJECT_IS_TOP_LEVEL AND NOT BUILD_HYGIENE STREQUAL DISABLED) if(BUILD_HYGIENE STREQUAL ENABLED) set(find_program_args REQUIRED) else()