Commit 0beb84be authored by Andrew Wood's avatar Andrew Wood

Install as a CMake package

...so that other CMake projects can use a pre-built version with
'find_package(SDF)' and 'find_package(PackSDF)'.
parent d8fca09a
Pipeline #5783 failed with stage
in 0 seconds
find_package(PythonInterp)
find_file(PACK_PY pack.py
PATHS ${CMAKE_CURRENT_LIST_DIR}/../src
PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/../src
DOC "Path to pack.py")
find_file(PACK_CMAKE_IN pack.cmake.in build_scripts
PATHS ${CMAKE_CURRENT_LIST_DIR}
......
project(SDF Fortran)
cmake_minimum_required(VERSION 2.8.8)
cmake_minimum_required(VERSION 3.14)
project(SDF VERSION 1.5.16 LANGUAGES Fortran)
find_package(MPI REQUIRED)
find_package(PackSDF REQUIRED PATHS CMake)
include(CMake/CheckMPIVersion.cmake)
......@@ -56,3 +56,13 @@ set(F77_OUTPUT 0)
include_directories(${MPI_Fortran_INCLUDE_PATH})
add_subdirectory(src lib)
install(
FILES
CMake/PackSDFConfig.cmake
CMake/pack.cmake.in
CMake/ConfigurePackTarget.cmake
src/pack.py
DESTINATION lib/PackSDF
COMPONENT develop
)
......@@ -72,13 +72,43 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
${INFO_FLAGS})
endif()
if(NOT TARGET sdf)
add_library(sdf ${SOURCES})
set_target_properties(
sdf
PROPERTIES
COMPILE_FLAGS ${MCMODEL}
Fortran_MODULE_DIRECTORY include)
install(TARGETS sdf DESTINATION lib COMPONENT develop)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include DESTINATION . COMPONENT develop)
endif()
add_library(sdf ${SOURCES})
set_target_properties(
sdf
PROPERTIES
COMPILE_FLAGS ${MCMODEL}
Fortran_MODULE_DIRECTORY include
)
target_include_directories(
sdf
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
)
install(
TARGETS sdf
EXPORT SDFConfig
COMPONENT develop
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
TYPE INCLUDE
COMPONENT develop
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/SDFConfigVersion.cmake
VERSION ${SDF_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/SDFConfigVersion.cmake
DESTINATION lib/SDF
COMPONENT develop
)
export(TARGETS sdf FILE ${CMAKE_CURRENT_BINARY_DIR}/SDFConfig.cmake)
install(EXPORT SDFConfig DESTINATION lib/SDF COMPONENT develop)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment