From 3be637c48ced2285f13604cb9d6f393c3b508395 Mon Sep 17 00:00:00 2001 From: Merlin Nimier-David Date: Thu, 24 Apr 2025 10:39:43 +0200 Subject: [PATCH] CMake: add option to disable leak warnings --- CMakeLists.txt | 17 ++++++++++++----- src/python/CMakeLists.txt | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9070f1a8..ad744011a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,11 +13,18 @@ else() set(DRJIT_ENABLE_CUDA_DEFAULT ON) endif() -option(DRJIT_ENABLE_LLVM "Build the Dr.Jit LLVM backend?" ON) -option(DRJIT_ENABLE_CUDA "Build the Dr.Jit CUDA backend?" ${DRJIT_ENABLE_CUDA_DEFAULT}) -option(DRJIT_ENABLE_AUTODIFF "Build Dr.Jit automatic differentation library?" ON) -option(DRJIT_ENABLE_PYTHON "Build Python extension library?" ON) -option(DRJIT_ENABLE_TESTS "Build Dr.Jit test suite? (Warning, this takes *very* long to compile)" OFF) +if (SKBUILD) + set(DRJIT_ENABLE_LEAK_WARNINGS_DEFAULT OFF) +else() + set(DRJIT_ENABLE_LEAK_WARNINGS_DEFAULT ON) +endif() + +option(DRJIT_ENABLE_LLVM "Build the Dr.Jit LLVM backend?" ON) +option(DRJIT_ENABLE_CUDA "Build the Dr.Jit CUDA backend?" ${DRJIT_ENABLE_CUDA_DEFAULT}) +option(DRJIT_ENABLE_AUTODIFF "Build Dr.Jit automatic differentation library?" ON) +option(DRJIT_ENABLE_PYTHON "Build Python extension library?" ON) +option(DRJIT_ENABLE_TESTS "Build Dr.Jit test suite? (Warning, this takes *very* long to compile)" OFF) +option(DRJIT_ENABLE_LEAK_WARNINGS "Emit DrJit and nanobind leak warnings? By default, leak warnings are disabled automatically when building PyPi wheels." ${DRJIT_ENABLE_LEAK_WARNINGS_DEFAULT}) option(DRJIT_STABLE_ABI "Build Python extension using the CPython stable ABI? (Only relevant when using scikit-build)" OFF) mark_as_advanced(DRJIT_STABLE_ABI) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 9886323d8..781347a27 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -141,8 +141,8 @@ if (DRJIT_ENABLE_CUDA) target_compile_definitions(drjit-python PRIVATE -DDRJIT_ENABLE_CUDA) endif() -# Disable leak warnings by default in PyPI release builds -if (SKBUILD) +# Disable DrJit and nanobind leak warnings (disabled by default in PyPi builds) +if (NOT DRJIT_ENABLE_LEAK_WARNINGS) target_compile_definitions(drjit-python PRIVATE -DDRJIT_DISABLE_LEAK_WARNINGS) endif()