Skip to content

Bugfix: CMake Install paths #1516

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 1 commit into
base: main
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
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required( VERSION 3.16 )

include( cmake/GitProjectVersion.cmake )
include( GNUInstallDirs)

project(
T8CODE
Expand Down Expand Up @@ -127,8 +128,11 @@ set( BUILD_SHARED_LIBS ON CACHE BOOL "Build libsc as a shared library" )
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)

# Rpath options necessary for shared library install to work correctly in user projects.
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
file(RELATIVE_PATH relativeRpath
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
)
Comment on lines +131 to +134
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your solution may be completely right, but better safe than sorry:
According to CMake documentation, the RELATIVE_PATH argument of file works like this:

image

It seems to odd to me that we use two directories here instead; and wouldn't this mean relativePath would contain the relative path from the bin to the libfolder, so basically .../lib? 🤔

Or is this supposed to be some correction of the current state only?

set(CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/${relativeRpath})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)

if ( T8CODE_USE_SYSTEM_SC )
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function( add_t8_benchmark )
set_target_properties( ${ADD_T8_BENCHMARK_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

install( TARGETS ${ADD_T8_BENCHMARK_NAME} DESTINATION bin )
install( TARGETS ${ADD_T8_BENCHMARK_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} )
endfunction()

add_t8_benchmark( NAME t8_time_partition SOURCES t8_time_partition.cxx )
Expand Down
4 changes: 2 additions & 2 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif()
target_sources( t8example PRIVATE common/t8_example_common.cxx common/t8_example_common_functions.cxx )
target_include_directories( t8example PRIVATE ${CMAKE_CURRENT_LIST_DIR}/.. ${SC_INCLUDE_DIR} )
target_link_libraries( t8example PRIVATE T8 ${SC_LIBRARIES} m )
install( TARGETS t8example DESTINATION lib )
install( TARGETS t8example LIBRARY )

function( add_t8_example )
set( options "" )
Expand Down Expand Up @@ -36,7 +36,7 @@ function( add_t8_example )
set_target_properties( ${ADD_T8_EXAMPLE_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

install( TARGETS ${ADD_T8_EXAMPLE_NAME} DESTINATION bin )
install( TARGETS ${ADD_T8_EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be install( TARGETS ${ADD_T8_EXAMPLE_NAME} RUNTIME ) , like in the tutorials below?

endfunction()

add_t8_example( NAME t8_advection SOURCES advect/t8_advection.cxx )
Expand Down
39 changes: 20 additions & 19 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if( T8CODE_ENABLE_NETCDF )
t8_cmesh_netcdf.h
t8_forest_netcdf.h
t8_netcdf.h
DESTINATION include)
TYPE INCLUDE )
endif()

set_target_properties( T8 PROPERTIES OUTPUT_NAME t8 )
Expand Down Expand Up @@ -209,41 +209,42 @@ install( FILES
t8_types/t8_vec.hxx
t8_version.h
t8_vtk.h
DESTINATION include
TYPE INCLUDE
)

install( DIRECTORY t8_cmesh DESTINATION include FILES_MATCHING PATTERN "*.h"
install( DIRECTORY t8_cmesh TYPE INCLUDE FILES_MATCHING PATTERN "*.h"
PATTERN "t8_cmesh/t8_cmesh_copy.h" EXCLUDE
PATTERN "t8_cmesh/t8_cmesh_offset.h" EXCLUDE
PATTERN "t8_cmesh/t8_cmesh_partition.h" EXCLUDE
PATTERN "t8_cmesh/t8_cmesh_trees.h" EXCLUDE
)
install( DIRECTORY t8_data DESTINATION include FILES_MATCHING PATTERN "*.h" )
install( DIRECTORY t8_forest DESTINATION include FILES_MATCHING PATTERN "*.h"
)

install( DIRECTORY t8_data TYPE INCLUDE FILES_MATCHING PATTERN "*.h" )
install( DIRECTORY t8_forest TYPE INCLUDE FILES_MATCHING PATTERN "*.h"
PATTERN "t8_forest/t8_forest_balance.h" EXCLUDE
PATTERN "t8_forest/t8_forest_ghost.h " EXCLUDE
PATTERN "t8_forest/t8_forest_private.h" EXCLUDE
PATTERN "t8_forest/t8_forest_types.h" EXCLUDE
)
install( DIRECTORY t8_geometry DESTINATION include FILES_MATCHING PATTERN "*.h" )
install( DIRECTORY t8_schemes DESTINATION include FILES_MATCHING PATTERN "*.h" )
install( DIRECTORY t8_vtk DESTINATION include FILES_MATCHING PATTERN "*.h" )

install( DIRECTORY t8_cmesh DESTINATION include FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_data DESTINATION include FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_forest DESTINATION include FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_geometry DESTINATION include FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_schemes DESTINATION include FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_vtk DESTINATION include FILES_MATCHING PATTERN "*.hxx"
)
install( DIRECTORY t8_geometry TYPE INCLUDE FILES_MATCHING PATTERN "*.h" )
install( DIRECTORY t8_schemes TYPE INCLUDE FILES_MATCHING PATTERN "*.h" )
install( DIRECTORY t8_vtk TYPE INCLUDE FILES_MATCHING PATTERN "*.h" )

install( DIRECTORY t8_cmesh TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_data TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_forest TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_geometry TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_schemes TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_vtk TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx"
PATTERN "t8_vtk/t8_vtk_parallel.hxx" EXCLUDE
PATTERN "t8_vtk/t8_vtk_polydata.hxx" EXCLUDE
PATTERN "t8_vtk/t8_vtk_unstructured.hxx" EXCLUDE
PATTERN "t8_vtk/t8_vtk_write_ASCII.hxx" EXCLUDE
PATTERN "t8_vtk/t8_vtk_writer_helper.hxx" EXCLUDE
)
install( DIRECTORY t8_types DESTINATION include FILES_MATCHING PATTERN "*.hxx" )
install( DIRECTORY t8_types TYPE INCLUDE FILES_MATCHING PATTERN "*.hxx" )

install( TARGETS T8 DESTINATION lib )
install( TARGETS T8 LIBRARY )
install( TARGETS T8 EXPORT ${PROJECT_NAME}-targets )

include( CMakePackageConfigHelpers )
Expand Down
2 changes: 1 addition & 1 deletion tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function( add_t8_tutorial )
set_target_properties( ${ADD_T8_TUTORIAL_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
endif( T8CODE_EXPORT_COMPILE_COMMANDS )

install( TARGETS ${ADD_T8_TUTORIAL_NAME} DESTINATION bin )
install( TARGETS ${ADD_T8_TUTORIAL_NAME} RUNTIME )
endfunction()

#copy tutorial files to the exact same location in the builddir as they are in the source dir
Expand Down