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
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,12 @@ endif()
ROOT_ADD_TEST_SUBDIRECTORY(test)
ROOT_ADD_TEST_SUBDIRECTORY(tutorials)

# Each subdirectory added above will register headers to be copied to the build tree.
# Here, the copy targets are created:
ROOT_CREATE_HEADER_COPY_TARGETS()

get_property(__allHeaders GLOBAL PROPERTY ROOT_HEADER_TARGETS)
get_property(__allBuiltins GLOBAL PROPERTY ROOT_BUILTIN_TARGETS)
add_custom_target(move_headers ALL DEPENDS ${__allHeaders} ${__allBuiltins} gitinfotxt)
add_custom_target(move_headers DEPENDS ${__allHeaders} gitinfotxt)

#---CXX MODULES-----------------------------------------------------------------------------------
if(MSVC)
Expand Down
2 changes: 0 additions & 2 deletions builtins/davix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,3 @@ target_link_libraries(davix INTERFACE $<BUILD_INTERFACE:${DAVIX_LIBRARIES}>)
add_dependencies(davix DAVIX)

add_library(Davix::Davix ALIAS davix)

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS DAVIX)
2 changes: 0 additions & 2 deletions builtins/glew/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ target_link_libraries(GLEW::GLEW INTERFACE GLEW)
set(GLEW_LIBRARY $<TARGET_FILE:GLEW> CACHE INTERNAL "")
set(GLEW_LIBRARIES GLEW::GLEW CACHE INTERNAL "")

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS GLEW::GLEW)

install(TARGETS GLEW
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
Expand Down
2 changes: 0 additions & 2 deletions builtins/lz4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,3 @@ add_library(LZ4::LZ4 ALIAS lz4)

set(LZ4_LIBRARY $<TARGET_FILE:lz4> CACHE INTERNAL "")
set(LZ4_LIBRARIES LZ4::LZ4 CACHE INTERNAL "")

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS LZ4::LZ4)
6 changes: 0 additions & 6 deletions builtins/nlohmann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ unset(JSON_H)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/include/nlohmann/json.hpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json.hpp ${CMAKE_BINARY_DIR}/include/nlohmann/json.hpp
COMMENT "Copying nlohmann/json.hpp header to ${CMAKE_BINARY_DIR}/include"
DEPENDS ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json.hpp)

add_custom_target(builtin_nlohmann_json_incl DEPENDS ${CMAKE_BINARY_DIR}/include/nlohmann/json.hpp)

set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_TARGETS builtin_nlohmann_json_incl)

install(FILES ${CMAKE_SOURCE_DIR}/builtins/nlohmann/json.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nlohmann/)


2 changes: 0 additions & 2 deletions builtins/openssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,3 @@ find_package_handle_standard_args(OpenSSL
VERSION_VAR
OPENSSL_VERSION_STRING
)

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS OPENSSL)
2 changes: 0 additions & 2 deletions builtins/pcre/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,3 @@ target_include_directories(pcre_builtin INTERFACE $<BUILD_INTERFACE:${PCRE_INCLU
target_link_libraries(pcre_builtin INTERFACE $<BUILD_INTERFACE:${PCRE_LIBRARIES}>)
add_library(PCRE::PCRE ALIAS pcre_builtin)
add_dependencies(pcre_builtin PCRE)

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS PCRE)
2 changes: 0 additions & 2 deletions builtins/xrootd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ set(XROOTD_UTILS_LIBRARIES ${XROOTD_UTILS_LIBRARIES} CACHE INTERNAL "" FORCE)
list(APPEND CMAKE_BUILD_RPATH ${XROOTD_PREFIX}/lib)
add_dependencies(XRootD BUILTIN_XROOTD)

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS BUILTIN_XROOTD)

install(DIRECTORY ${XROOTD_PREFIX}/lib/ DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries FILES_MATCHING PATTERN "libXrd*")
install(DIRECTORY ${XROOTD_PREFIX}/include/xrootd/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xrootd COMPONENT headers)
if(APPLE)
Expand Down
2 changes: 0 additions & 2 deletions builtins/xxhash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ add_library(xxHash::xxHash ALIAS xxhash)

set(xxHash_LIBRARY $<TARGET_FILE:xxhash> CACHE INTERNAL "")
set(xxHash_LIBRARIES xxHash::xxHash CACHE INTERNAL "")

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS xxHash::xxHash)
2 changes: 0 additions & 2 deletions builtins/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,3 @@ endif()
if(DEFINED ZLIB_LIBRARY_RELEASE)
set(ZLIB_LIBRARY_RELEASE ${ZLIB_LIBRARY} CACHE INTERNAL "")
endif()

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS ZLIB::ZLIB)
2 changes: 0 additions & 2 deletions builtins/zstd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,3 @@ add_library(ZSTD::ZSTD ALIAS zstd)

set(ZSTD_LIBRARY $<TARGET_FILE:ZSTD> CACHE INTERNAL "")
set(ZSTD_LIBRARIES ZSTD::ZSTD CACHE INTERNAL "")

set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS ZSTD::ZSTD)
82 changes: 63 additions & 19 deletions cmake/modules/RootMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,9 @@ function(ROOT_FIND_DIRS_WITH_HEADERS result_dirs)
endfunction()

#---------------------------------------------------------------------------------------------------
#---ROOT_INSTALL_HEADERS([dir1 dir2 ...] OPTIONS [options])
#---ROOT_INSTALL_HEADERS([dir1 dir2 ...] [FILTER <regex>])
# Glob for headers in the folder where this target is defined, and install them in
# <buildDir>/include
#---------------------------------------------------------------------------------------------------
function(ROOT_INSTALL_HEADERS)
CMAKE_PARSE_ARGUMENTS(ARG "OPTIONS" "" "FILTER" ${ARGN})
Expand All @@ -1232,35 +1234,77 @@ function(ROOT_INSTALL_HEADERS)
set (options ${options} REGEX "${f}" EXCLUDE)
endforeach()
set (filter "(${filter})")
set(include_files "")
foreach(d ${dirs})
install(DIRECTORY ${d} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT headers
${options})
string(REGEX REPLACE "(.*)/$" "\\1" d ${d})
ROOT_GLOB_FILES(include_files
ROOT_GLOB_FILES(globbed_files
RECURSE
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${d}
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
FILTER ${filter}
${d}/*.h ${d}/*.hxx ${d}/*.icc )
foreach (include_file ${include_files})
set (src ${CMAKE_CURRENT_SOURCE_DIR}/${d}/${include_file})
set (dst ${CMAKE_BINARY_DIR}/include/${include_file})
add_custom_command(
OUTPUT ${dst}
COMMAND ${CMAKE_COMMAND} -E copy ${src} ${dst}
COMMENT "Copying header ${src} to ${CMAKE_BINARY_DIR}/include"
DEPENDS ${src})
list(APPEND dst_list ${dst})
endforeach()
list(APPEND include_files ${globbed_files})
endforeach()

string(REPLACE ${CMAKE_SOURCE_DIR} "" target_name ${CMAKE_CURRENT_SOURCE_DIR})
string(REPLACE / _ target_name "copy_header_${target_name}")
string(REGEX REPLACE "_$" "" target_name ${target_name})

# Register the files to be copied for each target directory (e.g. include/ include/ROOT include/v7/inc/ ...)
list(REMOVE_DUPLICATES include_files)
list(TRANSFORM include_files REPLACE "(.*)/[^/]*" "\\1/" OUTPUT_VARIABLE subdirs)
list(REMOVE_DUPLICATES subdirs)
foreach(subdir ${subdirs})
set(input_files ${include_files})
list(FILTER input_files INCLUDE REGEX "^${subdir}[^/]*$")
set(output_files ${input_files})

string(REGEX REPLACE ".*/*inc/" "" destination ${subdir})

list(TRANSFORM input_files PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
list(TRANSFORM output_files REPLACE ".*/" "${CMAKE_BINARY_DIR}/include/${destination}")

set(destination destination_${destination})

set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_COPY_LISTS ${destination})
set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_INPUT_${destination} ${input_files})
set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_OUTPUT_${destination} ${output_files})
endforeach()
if (dst_list)
string(REPLACE ${CMAKE_SOURCE_DIR} "" tgt ${CMAKE_CURRENT_SOURCE_DIR})
string(MAKE_C_IDENTIFIER move_header${tgt} tgt)
set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_TARGETS ${tgt})
add_custom_target(${tgt} DEPENDS ${dst_list})
endif()
endfunction()

#---------------------------------------------------------------------------------------------------
#--- ROOT_CREATE_HEADER_COPY_TARGETS
# Creates a target to copy all headers that have been registered for copy in ROOT_INSTALL_HEADERS
#---------------------------------------------------------------------------------------------------
macro(ROOT_CREATE_HEADER_COPY_TARGETS)
get_property(HEADER_COPY_LISTS GLOBAL PROPERTY ROOT_HEADER_COPY_LISTS)
list(REMOVE_DUPLICATES HEADER_COPY_LISTS)
foreach(copy_list ${HEADER_COPY_LISTS})
get_property(inputs GLOBAL PROPERTY ROOT_HEADER_INPUT_${copy_list})
get_property(outputs GLOBAL PROPERTY ROOT_HEADER_OUTPUT_${copy_list})

string(REPLACE "destination_" "${CMAKE_BINARY_DIR}/include/" destination ${copy_list})

list(LENGTH inputs LIST_LENGTH)
# Windows doesn't support long command lines, so split them in packs:
foreach(range_start RANGE 0 ${LIST_LENGTH} 100)
list(SUBLIST outputs ${range_start} 100 sub_outputs)
list(SUBLIST inputs ${range_start} 100 sub_inputs)
list(LENGTH sub_outputs SUB_LENGTH)
if(NOT SUB_LENGTH EQUAL 0)
add_custom_command(OUTPUT ${sub_outputs}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${sub_inputs} ${destination}
COMMENT "Copy headers for ${destination} ${range_start}"
DEPENDS ${sub_inputs})
endif()
endforeach()
file(MAKE_DIRECTORY ${destination})
set_property(GLOBAL APPEND PROPERTY ROOT_HEADER_TARGETS ${outputs})
endforeach()
endmacro()

#---------------------------------------------------------------------------------------------------
#---ROOT_STANDARD_LIBRARY_PACKAGE(libname
# [NO_INSTALL_HEADERS] : don't install headers for this package
Expand Down
1 change: 0 additions & 1 deletion cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,6 @@ if(vdt OR builtin_vdt)
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/vdt
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT extra-headers)
set(vdt ON CACHE BOOL "Enabled because builtin_vdt enabled (${vdt_description})" FORCE)
set_property(GLOBAL APPEND PROPERTY ROOT_BUILTIN_TARGETS VDT)
add_library(VDT::VDT STATIC IMPORTED GLOBAL)
set_target_properties(VDT::VDT
PROPERTIES
Expand Down
Loading