Skip to content

Commit 3a59067

Browse files
committed
[CMake] Simplify ROOTTEST_COMPILE_MACRO to shorten test command
* Remove preprocessor variables that were always defined and hence carried no information * Add include path and library path via environment variables * Remove redundant `gROOT->SetMacroPath()` call with path to source directory, because the `${realfp}` variable passed to the `build.C` script already contains the full path
1 parent a967cef commit 3a59067

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

cmake/modules/RootMacros.cmake

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,17 +2318,14 @@ macro(ROOTTEST_COMPILE_MACRO filename)
23182318
list(APPEND RootMacroDirDefines "-e;#define ${d}")
23192319
endforeach()
23202320

2321-
set(RootMacroBuildDefines
2322-
-e "#define CMakeEnvironment"
2323-
-e "#define CMakeBuildDir \"${CMAKE_CURRENT_BINARY_DIR}\""
2324-
-e "gSystem->AddDynamicPath(\"${CMAKE_CURRENT_BINARY_DIR}\")"
2325-
-e "gROOT->SetMacroPath(\"${CMAKE_CURRENT_SOURCE_DIR}\")"
2326-
-e "gInterpreter->AddIncludePath(\"-I${CMAKE_CURRENT_BINARY_DIR}\")"
2327-
-e "gSystem->AddIncludePath(\"-I${CMAKE_CURRENT_BINARY_DIR}\")"
2328-
-e "gSystem->SetBuildDir(\"${CMAKE_CURRENT_BINARY_DIR}\", true)"
2329-
${RootMacroDirDefines})
2330-
2331-
set(root_compile_macro ${ROOT_root_CMD} ${RootMacroBuildDefines} -q -l -b)
2321+
set(root_compile_macro ${CMAKE_COMMAND} -E env
2322+
ROOT_LIBRARY_PATH="${CMAKE_CURRENT_BINARY_DIR}"
2323+
ROOT_INCLUDE_PATH="${CMAKE_CURRENT_BINARY_DIR}"
2324+
${ROOT_root_CMD}
2325+
-e "gSystem->SetBuildDir(\"${CMAKE_CURRENT_BINARY_DIR}\", true)"
2326+
${RootMacroDirDefines}
2327+
-q -l -b
2328+
)
23322329

23332330
get_filename_component(realfp ${filename} ABSOLUTE)
23342331
if(MSVC)

roottest/scripts/build.C

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ void build(const char *filename, const char *lib = 0, const char *obj = 0, const
7575
}
7676
// fprintf(stderr,"from %s to %s\n",filename,fname.Data());
7777
int result = gSystem->CompileMacro(fname,"kc");
78-
#elif defined(CMakeEnvironment) && defined(CMakeBuildDir)
79-
// fprintf(stderr,"CmakeBuildDir: %s filename: %s", CMakeBuildDir, filename);
80-
int result = gSystem->CompileMacro(filename,"kc-", libname, CMakeBuildDir);
8178
#else
8279
int result = gSystem->CompileMacro(filename,"kc", libname);
8380
#endif

0 commit comments

Comments
 (0)