From 31c471579d44b2a23ed178a0ea1d8a8cf6d23dd8 Mon Sep 17 00:00:00 2001 From: Shresth Date: Sun, 10 May 2026 16:07:46 +0530 Subject: [PATCH] CMake: auto-enable CGAL_DEV_MODE when building from CGAL source tree Fixes #9441. When cgal_detect_branch_build() returns TRUE, CGAL_DEV_MODE now defaults to ON instead of requiring developers to set the environment variable manually. Falls back to $ENV{CGAL_DEV_MODE} if set, otherwise OFF for external users. A CMake WARNING is printed when auto-enabled so users know the setting is active and how to disable it with -DCGAL_DEV_MODE=OFF. --- Installation/lib/cmake/CGAL/CGALConfig.cmake | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Installation/lib/cmake/CGAL/CGALConfig.cmake b/Installation/lib/cmake/CGAL/CGALConfig.cmake index 276c7ebb6c94..0ab86417abf2 100644 --- a/Installation/lib/cmake/CGAL/CGALConfig.cmake +++ b/Installation/lib/cmake/CGAL/CGALConfig.cmake @@ -19,6 +19,29 @@ endfunction() set(CGAL_FOUND FALSE) cgal_detect_branch_build(BRANCH_BUILD) +# Fix for issue #9441: +# When building CGAL from its own source tree (branch build), +# CGAL_DEV_MODE should default to ON so developers automatically +# get internal warnings and proper include path behavior. +# Users can override with -DCGAL_DEV_MODE=OFF. +if(BRANCH_BUILD) + set(_cgal_dev_mode_default ON) +elseif(DEFINED ENV{CGAL_DEV_MODE}) + set(_cgal_dev_mode_default "$ENV{CGAL_DEV_MODE}") +else() + set(_cgal_dev_mode_default OFF) +endif() + +option(CGAL_DEV_MODE + "Enable CGAL developer mode (auto-ON when building from CGAL source tree)" + "${_cgal_dev_mode_default}") + +if(CGAL_DEV_MODE AND _cgal_dev_mode_default) + message(WARNING + "CGAL_DEV_MODE is ON because you are building from the CGAL source " + "tree. To disable it, pass -DCGAL_DEV_MODE=OFF to CMake or unset " + "the CGAL_DEV_MODE environment variable.") +endif() if(BRANCH_BUILD) set(CGAL_ROOT ${CGAL_CONFIG_DIR}) get_filename_component(CGAL_ROOT "${CGAL_ROOT}" DIRECTORY)