Skip to content

[CMake] Avoid unneeded artifacts in the library installation directory #19044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
37 changes: 22 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -515,28 +515,33 @@ else()
install(DIRECTORY ${CMAKE_BINARY_DIR}/etc/dictpch DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
endif()

# FIXME: move installation of PCMS in ROOT_GENERATE_DICTIONARY().
# We are excluding directories, which are accidentaly copied via unxpected behaviour of install(DIRECTORY ..)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/lib/
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILES_MATCHING
PATTERN "*.pcm"
PATTERN "modules.idx"
PATTERN "JupyROOT" EXCLUDE
PATTERN "JsMVA" EXCLUDE
PATTERN "python*" EXCLUDE
PATTERN "cmake" EXCLUDE
PATTERN "pkgconfig" EXCLUDE
)

if(Vc_INCLUDE_DIR)
set(MODULES_ROOT_INCPATH "ROOT_INCLUDE_PATH=${Vc_INCLUDE_DIR}:${ROOT_INCLUDE_PATH}")
endif()

# modules.idx
if(runtime_cxxmodules)

ROOT_GET_LIBRARY_OUTPUT_DIR(library_output_dir)

# Explicitly install the the modules that are built by Clang implicitly. See
# also the comment in rootcling_impl.cxx about the "horrible workaround" to
# fix the incremental builds. The list needs to be kept up to date manually,
# it is better than globbing for all pcm files from the library output
# directory.
set(implicit_pcm_files
Cling_Runtime.pcm
Cling_Runtime_Extra.pcm
ROOT_Config.pcm
_Builtin_stddef.pcm
libc.pcm
std.pcm
)
foreach(implicit_pcm_file ${implicit_pcm_files})
install(FILES ${library_output_dir}/${implicit_pcm_file} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endforeach()
unset(implicit_pcm_files)

get_property(modules_idx_deps GLOBAL PROPERTY modules_idx_deps_property)
if(WIN32)
set(modules_idx_cmd COMMAND ${CMAKE_COMMAND} -E env PATH="${library_output_dir}\\\;%PATH%"
Expand All @@ -555,6 +560,8 @@ if(runtime_cxxmodules)
add_dependencies(modules_idx ${modules_idx_deps})
set_property(TARGET modules_idx PROPERTY modules_idx_file ${library_output_dir}/modules.idx)
set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${library_output_dir}/modules.timestamp")

install(FILES ${library_output_dir}/modules.idx DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

#---hsimple.root---------(use the executable for clearer dependencies and proper return code)---
Expand Down
14 changes: 3 additions & 11 deletions bindings/pyroot/cppyy/CPyCppyy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ set(sources
src/Utility.cxx
)

file(RELATIVE_PATH PYTHONDIR_TO_LIBDIR "${CMAKE_INSTALL_FULL_PYTHONDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}")

set(libname cppyy)

add_library(${libname} SHARED ${headers} ${sources})
Expand Down Expand Up @@ -106,15 +104,9 @@ set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${libname})

# Install library
install(TARGETS ${libname} EXPORT ${CMAKE_PROJECT_NAME}Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
if (NOT MSVC AND NOT CMAKE_INSTALL_LIBDIR STREQUAL CMAKE_INSTALL_PYTHONDIR)
# add a symlink to ${libname} in CMAKE_INSTALL_PYTHONDIR
set(LIB_FILE_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}.so)
install(CODE "file(CREATE_LINK ${PYTHONDIR_TO_LIBDIR}/${LIB_FILE_NAME}
\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_PYTHONDIR}/${LIB_FILE_NAME} SYMBOLIC)")
endif()
RUNTIME DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)

file(COPY ${headers} DESTINATION ${CMAKE_BINARY_DIR}/include/CPyCppyy)
install(FILES ${headers}
Expand Down
14 changes: 3 additions & 11 deletions bindings/pyroot/cppyy/cppyy-backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ file(COPY ${cppyy_backendPySrcDir}
PATTERN "cmake" EXCLUDE
PATTERN "pkg_templates" EXCLUDE)

file(RELATIVE_PATH PYTHONDIR_TO_LIBDIR "${CMAKE_INSTALL_FULL_PYTHONDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}")

set(libname cppyy_backend)

add_library(${libname} SHARED clingwrapper/src/clingwrapper.cxx)
Expand All @@ -40,15 +38,9 @@ set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${libname})

# Install library
install(TARGETS ${libname} EXPORT ${CMAKE_PROJECT_NAME}Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
if (NOT MSVC AND NOT CMAKE_INSTALL_LIBDIR STREQUAL CMAKE_INSTALL_PYTHONDIR)
# add a symlink to ${libname} in CMAKE_INSTALL_PYTHONDIR
set(LIB_FILE_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}.so)
install(CODE "file(CREATE_LINK ${PYTHONDIR_TO_LIBDIR}/${LIB_FILE_NAME}
\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_PYTHONDIR}/${LIB_FILE_NAME} SYMBOLIC)")
endif()
RUNTIME DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)

# Compile .py files
foreach(py_source ${py_sources})
Expand Down
15 changes: 11 additions & 4 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,17 @@ target_compile_definitions(Core PRIVATE
if (runtime_cxxmodules)
list(APPEND core_implicit_modules "-mSystemByproducts")
# Force generation of _Builtin_intrinsics from Core.
list(APPEND core_implicit_modules "-m" "_Builtin_intrinsics" "-mByproduct" "_Builtin_intrinsics")
list(APPEND core_implicit_modules "-mByproduct" "ROOT_Foundation_Stage1_NoRTTI")
list(APPEND core_implicit_modules "-mByproduct" "ROOT_Foundation_C")
list(APPEND core_implicit_modules "-mByproduct" "ROOT_Rtypes")
list(APPEND core_implicit_modules "-m" "_Builtin_intrinsics")

set(byproducts _Builtin_intrinsics ROOT_Foundation_Stage1_NoRTTI ROOT_Foundation_C ROOT_Rtypes)
foreach(byproduct ${byproducts})
list(APPEND core_implicit_modules "-mByproduct" "${byproduct}")
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${byproduct}.pcm DESTINATION ${CMAKE_INSTALL_LIBDIR})
endforeach()

list(APPEND core_implicit_modules "-mByproduct" "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the semantic of those additions?

list(APPEND core_implicit_modules "-mByproduct" "")
list(APPEND core_implicit_modules "-mByproduct" "")
endif(runtime_cxxmodules)

get_target_property(CORE_DICT_HEADERS Core DICT_HEADERS)
Expand Down
Loading