Skip to content

Commit

Permalink
cmake template
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 22, 2021
1 parent 87893ba commit 5070c85
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.14...3.21)
cmake_minimum_required(VERSION 3.14...3.22)

project(RPNcalc
LANGUAGES Fortran
VERSION 1.2.1
HOMEPAGE_URL https://github.com/scivision/rpn-calc-fortran)
LANGUAGES Fortran
VERSION 1.2.1
HOMEPAGE_URL https://github.com/scivision/rpn-calc-fortran)

include(CTest)

Expand Down Expand Up @@ -31,10 +31,10 @@ endif(BUILD_TESTING)

#--- properties
foreach(t ${_targs})
target_include_directories(${t} INTERFACE
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include # IBM XL
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(${t}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
set_target_properties(${t} PROPERTIES
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
endforeach()
Expand Down
5 changes: 0 additions & 5 deletions cmake/Config.cmake.in

This file was deleted.

5 changes: 5 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)

check_required_components(@PROJECT_NAME@)
32 changes: 17 additions & 15 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

include(CMakePackageConfigHelpers)

configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION lib)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION cmake
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY SameMinorVersion)
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMinorVersion
)

install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}-targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION cmake
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME})

# instead of export() which would need duplicates everywhere of install() calls,
# just default install to build dir.
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}-config-version.cmake
DESTINATION cmake
)

# --- CPack

Expand All @@ -39,6 +40,7 @@ string(REGEX REPLACE "\n" ";" _cpack_ignore ${_cpack_ignore})
set(CPACK_SOURCE_IGNORE_FILES "${_cpack_ignore}")

install(FILES ${CPACK_RESOURCE_FILE_README} ${CPACK_RESOURCE_FILE_LICENSE}
DESTINATION share/docs/${PROJECT_NAME})
DESTINATION share/docs/${PROJECT_NAME}
)

include(CPack)

0 comments on commit 5070c85

Please sign in to comment.