Skip to content

Commit

Permalink
[WIP] Fedora packaging convention
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
  • Loading branch information
LecrisUT committed Feb 22, 2024
1 parent 69af8f6 commit 2ce74a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ if (WANNIER90_INSTALL)
include(CMakePackageConfigHelpers)

# CMake does not properly support fortran module installation paths.
# Adapting the standard from fortran-stdlib
# https://gitlab.kitware.com/cmake/cmake/-/issues/19608
# https://discourse.cmake.org/t/api-design-c-modules-source-listings-and-interface-properties/5389/14
cmake_path(APPEND CMAKE_INSTALL_INCLUDEDIR ${PROJECT_NAME} "${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}"
# Note: This does not follow fortran-stdlib format, instead it follows Fedora guidelines
# https://pagure.io/packaging-committee/issue/1334
cmake_path(APPEND CMAKE_INSTALL_LIBDIR "${CMAKE_Fortran_COMPILER_ID}-${CMAKE_Fortran_COMPILER_VERSION}" modules
OUTPUT_VARIABLE _DEFAULT_CMAKE_INSTALL_MODULEDIR
)
set(CMAKE_INSTALL_MODULEDIR ${_DEFAULT_CMAKE_INSTALL_MODULEDIR}
Expand Down
14 changes: 7 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ target_link_libraries(Wannier90_lib PRIVATE
target_include_directories(Wannier90_lib PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_MODULEDIR}/Wannier90>"
)
target_sources(Wannier90_lib INTERFACE
FILE_SET wannier90_C_Headers TYPE HEADERS FILES wannier90.hh
target_sources(Wannier90_lib
INTERFACE FILE_SET wannier90_C_Headers TYPE HEADERS FILES
wannier90.hh
INTERFACE FILE_SET wannier90_Fortran_Headers TYPE HEADERS BASE_DIRS ${CMAKE_Fortran_MODULE_DIRECTORY} FILES
${CMAKE_Fortran_MODULE_DIRECTORY}/w90_library.mod
)
if (WANNIER90_MPI)
target_link_libraries(Wannier90_lib PRIVATE MPI::MPI_Fortran)
Expand All @@ -55,9 +58,6 @@ if (WANNIER90_INSTALL)
PUBLIC_HEADER COMPONENT Wannier90_Development
RUNTIME COMPONENT Wannier90_Runtime
FILE_SET wannier90_C_Headers COMPONENT Wannier90_Development
FILE_SET wannier90_Fortran_Headers DESTINATION ${CMAKE_INSTALL_MODULEDIR}/Wannier90 COMPONENT Wannier90_Development
)
install(FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/w90_library.mod
DESTINATION ${CMAKE_INSTALL_MODULEDIR}
COMPONENT Wannier90_Development
)
endif ()

0 comments on commit 2ce74a7

Please sign in to comment.