Skip to content

Commit

Permalink
Only link to needed libraries
Browse files Browse the repository at this point in the history
Only link to the libraries that are actually needed by passing the `--as-needed` option to the linker.
  • Loading branch information
gmloose committed Apr 8, 2024
1 parent c8bc575 commit 693f7ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ foreach(_target ${_targets})
${CASACORE_INCLUDE_DIRS})
target_link_directories(${_target} PRIVATE ${CASACORE_LIBRARY_DIRS})
target_link_libraries(${_target} PRIVATE ${CASACORE_LIBRARIES})
target_link_options(${_target} PRIVATE "LINKER:--as-needed")
install(TARGETS ${_target} LIBRARY DESTINATION ${_destination}
COMPONENT libraries)
endforeach()
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ target_include_directories(_tConvert PRIVATE ${Boost_INCLUDE_DIRS}
${CASACORE_INCLUDE_DIRS})
target_link_directories(_tConvert PRIVATE ${CASACORE_LIBRARY_DIRS})
target_link_libraries(_tConvert PRIVATE ${CASACORE_LIBRARIES})
target_link_options(_tConvert PRIVATE "LINKER:--as-needed")
install(TARGETS _tConvert LIBRARY DESTINATION casacore COMPONENT libraries)

0 comments on commit 693f7ca

Please sign in to comment.