From 1006dd54dee37793428043ad296836d7f323c7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Thu, 28 Apr 2022 19:03:13 +0200 Subject: [PATCH] Add BUILD_TESTING to standard CMake arguments (#30374) CTest determines whether to enable tests using the BUILD_TESTING variable. This should be used by projects to conditionally enable the compilation of tests. Spack knowns which packages have to run tests and can thus automatically define this variable. --- lib/spack/spack/build_systems/cmake.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/spack/spack/build_systems/cmake.py b/lib/spack/spack/build_systems/cmake.py index f934947604d..105e9d5ab85 100644 --- a/lib/spack/spack/build_systems/cmake.py +++ b/lib/spack/spack/build_systems/cmake.py @@ -176,6 +176,7 @@ def _std_args(pkg): '-G', generator, define('CMAKE_INSTALL_PREFIX', convert_to_posix_path(pkg.prefix)), define('CMAKE_BUILD_TYPE', build_type), + define('BUILD_TESTING', pkg.run_tests), ] # CMAKE_INTERPROCEDURAL_OPTIMIZATION only exists for CMake >= 3.9 @@ -361,6 +362,7 @@ def cmake_args(self): * CMAKE_INSTALL_PREFIX * CMAKE_BUILD_TYPE + * BUILD_TESTING which will be set automatically.