Skip to content

Commit

Permalink
Symlinks to reproduce the directory structure (AliceO2Group#2217)
Browse files Browse the repository at this point in the history
* Symlinks to reproduce the directiory structure

* License and documentation

* Remove trailing spaces

* Use portable ln option
  • Loading branch information
pzhristov authored Mar 17, 2023
1 parent 149d046 commit f557aa5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmake/O2PhysicsAddHeaderOnlyLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,10 @@ function(o2physics_add_header_only_library baseTargetName)
FILE_SET HEADERS
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Link subdirectories
install(
SCRIPT ${CMAKE_SOURCE_DIR}/cmake/O2PhysicsLinkAllSubDirs.cmake
CODE " o2physics_link_all_subdirs(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) "
)

endfunction()
6 changes: 6 additions & 0 deletions cmake/O2PhysicsAddLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,10 @@ function(o2physics_add_library baseTargetName)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()

# Link subdirectories
install(
SCRIPT ${CMAKE_SOURCE_DIR}/cmake/O2PhysicsLinkAllSubDirs.cmake
CODE " o2physics_link_all_subdirs(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) "
)

endfunction()
29 changes: 29 additions & 0 deletions cmake/O2PhysicsLinkAllSubDirs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.

function(o2physics_link_all_subdirs mainDir currentDir installDir)
# Find the relative subdirectory of currentDir wrt mainDir
# and create for each of the subdirectory levels a symlink in installDir

# Find the relative subdirectory
string(REPLACE "${mainDir}" "" relDir "${currentDir}")
# Splite the relative directory to a list of subdirectories
string(REPLACE "/" ";" listDirs "${relDir}")
foreach(dir ${listDirs})
# Link each subdirectory inside include
# This helps to use #include "A/B/C/x.h" from the flat installation of header files
message("Linking ${dir} in ${installDir}")
execute_process(
COMMAND ln -sfn . ${dir}
WORKING_DIRECTORY ${installDir}
)
endforeach()
endfunction()

0 comments on commit f557aa5

Please sign in to comment.