From 1422bcae7d5ce7734b0d1d36c81e2fa1bef3fcaf Mon Sep 17 00:00:00 2001
From: Christophe Guillon <christophe.guillon@inria.fr>
Date: Mon, 8 Jul 2024 12:55:08 +0200
Subject: [PATCH] [Setup] Add env var for tests

Add AIDGE_TEST=OFF|ON env vars to cmake configuration.
Defaults to OFF, use AIDGE_TEST=ON to configure build of tests
in development mode.
---
 setup.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 71f04d02f..e88e10ef5 100644
--- a/setup.py
+++ b/setup.py
@@ -20,6 +20,7 @@ will not be automatically installed:
 Some envvars are available to configure the cmake build:
 - AIDGE_BUILD_MODE=Debug|Release to configure the build type, defaults to Debug.
 - AIDGE_BUILD_GEN=<build_backend>, passed as -G<build_backend>, defaults to cmake default. 
+- AIDGE_TEST=OFF|ON to build tests, defaults to OFF. 
 
 For instance to use ninja backend on linux, use AIDGE_BUILD_GEN=Ninja.
 In this case install ninja first with: pip install ninja.
@@ -113,10 +114,11 @@ class CMakeBuild(build_ext):
         cmake_type_opts = ['-G', build_gen] if build_gen else []
         cmake_job_opts = ['-j', max_jobs] if build_gen != "Ninja" else []
         compile_type = os.environ.get("AIDGE_BUILD_MODE", "Debug")
+        compile_test = os.environ.get("AIDGE_TEST", "OFF")
         install_path = os.path.join(sys.prefix, "lib", "libAidge")  if "AIDGE_INSTALL" not in os.environ else os.environ["AIDGE_INSTALL"]
 
         os.chdir(str(build_temp))
-        self.spawn(['cmake', *cmake_type_opts, str(cwd), param_py, '-DTEST=OFF', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}', f'-DCMAKE_BUILD_TYPE={compile_type}'])
+        self.spawn(['cmake', *cmake_type_opts, str(cwd), param_py, f'-DTEST={compile_test}', f'-DCMAKE_INSTALL_PREFIX:PATH={install_path}', f'-DCMAKE_BUILD_TYPE={compile_type}'])
         if not self.dry_run:
             self.spawn(['cmake', '--build', '.', '--config', compile_type, *cmake_job_opts])
             self.spawn(['cmake', '--install', '.', '--config', compile_type])
-- 
GitLab