Skip to content

Commit e6d39c4

Browse files
committed
[CMake] Always create rootcint and genreflex as copies of rootcling
Always create `rootcing` and `genreflex` as copies of rootcling to make the install code more robust. Right now, we use some `install(CODE "execute_process(COMMAND ln -f ...` solution on unix to install `rootcint` and `genreflex`. This does not work in all cases, either because of the usage of `\$ENV{DESTDIR}` when `DESTDIR` is not set, or because hard links are not allowed. Always copying `rootcling` - already in the build tree - makes things simpler and more robust, at very little cost (`rootcling` is only 31K, so copying two times only increases the size of ROOTs `bin` directory by 1.5 %).
1 parent 8551484 commit e6d39c4

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

main/CMakeLists.txt

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,26 @@ endif()
114114
ROOT_EXECUTABLE(rootls src/rootls.cxx LIBRARIES RIO Tree Core Rint ROOTNTuple)
115115

116116
# Create aliases: rootcint, genreflex.
117-
if(WIN32)
118-
add_custom_command(TARGET rootcling POST_BUILD
119-
COMMAND copy /y rootcling.exe rootcint.exe
120-
COMMAND copy /y rootcling.exe genreflex.exe
121-
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
122-
else()
123-
add_custom_command(TARGET rootcling POST_BUILD
124-
COMMAND ln -f rootcling rootcint
125-
COMMAND ln -f rootcling genreflex
126-
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
127-
endif()
128-
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
129-
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex")
117+
add_custom_command(
118+
TARGET rootcling POST_BUILD
119+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:rootcling> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint
120+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:rootcling> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex
121+
COMMENT "Creating copies rootcint and genreflex of rootcling"
122+
)
130123

131-
if(CMAKE_HOST_UNIX)
132-
install(CODE "execute_process(COMMAND ln -f rootcling rootcint WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})" COMPONENT applications)
133-
install(CODE "execute_process(COMMAND ln -f rootcling genreflex WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})" COMPONENT applications)
134-
else()
135-
if(MSVC)
136-
install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcling.exe DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
137-
install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint.exe DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
138-
install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex.exe DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
139-
else()
140-
install(PROGRAMS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint
141-
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex
142-
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rlibmap
143-
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT applications)
144-
endif()
145-
endif()
124+
# Ensure aliases are cleaned up by `make clean`.
125+
set_property(
126+
DIRECTORY
127+
APPEND
128+
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
129+
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint"
130+
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex"
131+
)
132+
133+
# Install the aliases
134+
install(PROGRAMS
135+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/rootcint
136+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genreflex
137+
DESTINATION ${CMAKE_INSTALL_BINDIR}
138+
COMPONENT applications
139+
)

0 commit comments

Comments
 (0)