Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 34 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,36 +171,42 @@ if(cxxmodules)
# for glew.h to it its trick.
set(ROOT_CXXMODULES_COMMONFLAGS "${ROOT_CXXMODULES_COMMONFLAGS} -isystem ${CMAKE_SOURCE_DIR}/graf3d/glew/isystem")
endif()
endif(cxxmodules)

add_custom_target(copymodulemap DEPENDS "${CMAKE_BINARY_DIR}/include/module.modulemap")
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/include/module.modulemap"
DEPENDS build/unix/module.modulemap "${CMAKE_BINARY_DIR}/include/module.modulemap.extra"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/build/unix/module.modulemap" "${CMAKE_BINARY_DIR}/include/module.modulemap"
COMMAND cat "${CMAKE_BINARY_DIR}/include/module.modulemap.extra" >> "${CMAKE_BINARY_DIR}/include/module.modulemap"
)

add_dependencies(move_artifacts copymodulemap)

# Provide our own modulemap for implementations other than libcxx.
if (NOT libcxx)
# Write a empty overlay file to the output directory that CMake can run its compiler tests.
# We will create the actual overlay later in the configuration.
file(WRITE ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml "{'version' : 0, 'roots' : []}")
set(__vfs_overlay "-ivfsoverlay ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml")
add_custom_target(copymodulemap DEPENDS "${CMAKE_BINARY_DIR}/include/module.modulemap")
add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/include/module.modulemap"
DEPENDS build/unix/module.modulemap "${CMAKE_BINARY_DIR}/include/module.modulemap.extra"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/build/unix/module.modulemap" "${CMAKE_BINARY_DIR}/include/module.modulemap"
COMMAND cat "${CMAKE_BINARY_DIR}/include/module.modulemap.extra" >> "${CMAKE_BINARY_DIR}/include/module.modulemap"
)
install(FILES "${CMAKE_BINARY_DIR}/include/module.modulemap" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers)

add_dependencies(move_artifacts copymodulemap)

# Provide our own modulemap for implementations other than libcxx.
if (NOT libcxx)
# Write a empty overlay file to the output directory that CMake can run its compiler tests.
# We will create the actual overlay later in the configuration.
file(WRITE ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml "{'version' : 0, 'roots' : []}")
set(__vfs_overlay "-ivfsoverlay ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml")

if (cxxmodules)
set(ROOT_CXXMODULES_COMMONFLAGS "${ROOT_CXXMODULES_COMMONFLAGS} ${__vfs_overlay}")
endif(cxxmodules)

# Only use the first path from the HEADERS_LOCATION (which is separated by colons).
get_property(__libcpp_full_paths GLOBAL PROPERTY ROOT_CLING_CXX_HEADERS_LOCATION)
string(REGEX MATCHALL "[^:]+" __libcpp_full_paths_list "${__libcpp_full_paths}")
list(GET __libcpp_full_paths_list 0 __libcpp_full_path)
# Only use the first path from the HEADERS_LOCATION (which is separated by colons).
get_property(__libcpp_full_paths GLOBAL PROPERTY ROOT_CLING_CXX_HEADERS_LOCATION)
string(REGEX MATCHALL "[^:]+" __libcpp_full_paths_list "${__libcpp_full_paths}")
list(GET __libcpp_full_paths_list 0 __libcpp_full_path)

configure_file(${CMAKE_SOURCE_DIR}/build/unix/modulemap.overlay.yaml.in ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/build/unix/modulemap.overlay.yaml.in ${CMAKE_BINARY_DIR}/include/modulemap.overlay.yaml @ONLY)

configure_file(${CMAKE_SOURCE_DIR}/build/unix/stl.cppmap ${CMAKE_BINARY_DIR}/include/stl.cppmap)
configure_file(${CMAKE_SOURCE_DIR}/build/unix/libc.modulemap ${CMAKE_BINARY_DIR}/include/libc.modulemap)
endif()
configure_file(${CMAKE_SOURCE_DIR}/build/unix/stl.cppmap ${CMAKE_BINARY_DIR}/include/stl.cppmap)
configure_file(${CMAKE_SOURCE_DIR}/build/unix/libc.modulemap ${CMAKE_BINARY_DIR}/include/libc.modulemap)
endif()

if (cxxmodules)
# These vars are useful when we want to compile things without cxxmodules.
set(ROOT_CXXMODULES_CXXFLAGS "${ROOT_CXXMODULES_COMMONFLAGS} -fcxx-modules" CACHE STRING "Useful to filter out the modules-related cxxflags.")
if (NOT APPLE)
Expand Down Expand Up @@ -248,11 +254,10 @@ ROOT_ADD_TEST_SUBDIRECTORY(tutorials)
# Take all the modulemap contents we collected from the packages and append them to our modulemap.
# We have to delay this because the ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT is filled in the
# add_subdirectory calls above.
if(cxxmodules)
get_property(__modulemap_extra_content GLOBAL PROPERTY ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT)
string(REPLACE ";" "" __modulemap_extra_content "${__modulemap_extra_content}")
file(WRITE "${CMAKE_BINARY_DIR}/include/module.modulemap.extra" "${__modulemap_extra_content}")
endif(cxxmodules)
get_property(__modulemap_extra_content GLOBAL PROPERTY ROOT_CXXMODULES_EXTRA_MODULEMAP_CONTENT)
string(REPLACE ";" "" __modulemap_extra_content "${__modulemap_extra_content}")
file(WRITE "${CMAKE_BINARY_DIR}/include/module.modulemap.extra" "${__modulemap_extra_content}")


get_property(__allHeaders GLOBAL PROPERTY ROOT_HEADER_TARGETS)
add_custom_target(move_headers ALL DEPENDS ${__allHeaders})
Expand Down
26 changes: 10 additions & 16 deletions cmake/modules/RootNewMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -404,28 +404,22 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
endif()
endif()
if(cxxmodules)
# FIXME: Support mulptiple dictionaries. In some cases (libSMatrix and
# libGenVector) we have to have two or more dictionaries (eg. for math,
# we need the two for double vs Double32_t template specializations).
# In some other cases, eg. libTreePlayer.so we add in a separate dictionary
# files which for some reason (temporarily?) cannot be put in the PCH. Eg.
# all rest of the first dict is in the PCH but this file is not and it
# cannot be present in the original dictionary.
if(NOT ARG_MULTIDICT)
ROOT_CXXMODULES_APPEND_TO_MODULEMAP("${library_name}" "${headerfiles}")
endif()
endif(cxxmodules)
# FIXME: Support mulptiple dictionaries. In some cases (libSMatrix and
# libGenVector) we have to have two or more dictionaries (eg. for math,
# we need the two for double vs Double32_t template specializations).
# In some other cases, eg. libTreePlayer.so we add in a separate dictionary
# files which for some reason (temporarily?) cannot be put in the PCH. Eg.
# all rest of the first dict is in the PCH but this file is not and it
# cannot be present in the original dictionary.
if(NOT ARG_MULTIDICT)
ROOT_CXXMODULES_APPEND_TO_MODULEMAP("${library_name}" "${headerfiles}")
endif()
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_CXXMODULES_APPEND_TO_MODULEMAP( library library_headers )
#---------------------------------------------------------------------------------------------------
function (ROOT_CXXMODULES_APPEND_TO_MODULEMAP library library_headers)
if(NOT cxxmodules)
message(FATAL_ERROR "Calling ROOT_CXXMODULES_APPEND_TO_MODULEMAP on non-modules build.")
endif()

ROOT_FIND_DIRS_WITH_HEADERS(dirs)

# Variable 'dirs' is the return result of ROOT_FIND_DIRS_WITH_HEADERS.
Expand Down
4 changes: 1 addition & 3 deletions interpreter/cling/lib/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,7 @@ if (UNIX)

# In modules builds we 'mount' our own stl modulemap for libstdc++. In order to do this,
# we need to know where is ROOT/cling STL.
if (cxxmodules)
set_property(GLOBAL PROPERTY ROOT_CLING_CXX_HEADERS_LOCATION "${CLING_CXX_HEADERS}")
endif(cxxmodules)
set_property(GLOBAL PROPERTY ROOT_CLING_CXX_HEADERS_LOCATION "${CLING_CXX_HEADERS}")

if (CLING_CXX_PATH)
MESSAGE(STATUS "And if not found, will invoke: '${CLING_CXX_PATH}' for them.")
Expand Down