Skip to content

Commit a9da30b

Browse files
Teemperorvgvassilev
authored andcommitted
[cxxmodules] Fix absolute paths for v7 headers in modulemap
Our CMake code for making path to headers relative is broken for the v7 headers (as they don't have the 'CURRENT_SOURCE/inc' prefix we check for). This caused that we have absolute paths for those headers in the modulemap we ship with ROOT. As the paths are only valid on the same system in the specific build folder, they prevent anyone from successfully building any ROOT module with this modulemap. This patch adds the additional check for v7 headers and also adds a fallback where we always remove the current source dir from the paths (which is necessary for all the tests which don't follow any directory structure). Also adds a sanity check that should prevent this error in the future by checking that paths are not absolute before we write them to the modulemap.
1 parent bea06e8 commit a9da30b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

cmake/modules/RootNewMacros.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
262262
endif()
263263
endforeach()
264264
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/inc/" "" headerfiles "${headerfiles}")
265+
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/v7/inc/" "" headerfiles "${headerfiles}")
266+
265267
# Replace the non-standard folder layout of Core.
266268
if (ARG_STAGE1 AND ARG_MODULE STREQUAL "Core")
267269
# FIXME: Glob these folders.
@@ -273,6 +275,22 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
273275
endforeach()
274276
endif()
275277

278+
# Check that each path here is relative so that it no longer points to the build folder.
279+
# If we don't do this, then for example the modulemap might contain absolute paths to the
280+
# build folder which would break module compilation.
281+
if(PROJECT_NAME STREQUAL ROOT)
282+
foreach(hf ${headerfiles})
283+
string(REPLACE "${PROJECT_SOURCE_DIR}" "" hfrel "${hf}")
284+
# Test folders don't follow this pattern and need absolute paths,
285+
# so we don't run our sanity check on them.
286+
if(NOT "${hfrel}" MATCHES "/test/")
287+
if(IS_ABSOLUTE "${hf}")
288+
message(SEND_ERROR "Header path '${hf}' ${hfrel} is not relative!")
289+
endif()
290+
endif()
291+
endforeach()
292+
endif()
293+
276294
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
277295
set(includedirs -I${CMAKE_SOURCE_DIR}
278296
-I${CMAKE_SOURCE_DIR}/interpreter/cling/include # This is for the RuntimeUniverse

0 commit comments

Comments
 (0)