From 1089ab8441b10765579d17ca519278a5c31dea0c Mon Sep 17 00:00:00 2001 From: Jonah Beckford <9566106-jonahbeckford@users.noreply.gitlab.com> Date: Mon, 2 Oct 2023 21:55:20 -0700 Subject: [PATCH] Hygiene only when project is top-level --- CHANGES.md | 1 + CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) 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()