2020-02-12 20:41:20 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
2020-02-20 21:19:40 +01:00
|
|
|
project(foo)
|
|
|
|
|
2020-02-12 20:41:20 +01:00
|
|
|
find_package(libfort)
|
|
|
|
|
|
|
|
# Assert exports of libfort
|
|
|
|
if (NOT libfort_FOUND)
|
|
|
|
message(FATAL_ERROR "libfort was not found")
|
|
|
|
endif()
|
|
|
|
if (NOT TARGET libfort::fort)
|
|
|
|
message(FATAL_ERROR "TARGET libfort::fort not found")
|
|
|
|
endif()
|
|
|
|
if (NOT DEFINED libfort_LIBRARIES)
|
|
|
|
message(FATAL_ERROR "libfort_LIBRARIES are not defined")
|
|
|
|
endif()
|
|
|
|
if (NOT ${libfort_VERSION} EQUAL "0.4.0")
|
|
|
|
message(FATAL_ERROR "libfort_VERSION is incorrect")
|
|
|
|
endif()
|
|
|
|
|
2020-02-20 21:19:40 +01:00
|
|
|
# Create target that depend on libfort and check they'll compile ok
|
|
|
|
add_executable(foo-app
|
|
|
|
foo-app.cpp)
|
|
|
|
target_link_libraries(foo-app
|
|
|
|
PRIVATE libfort::fort
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(foo-lib
|
|
|
|
foo-lib.cpp)
|
|
|
|
target_link_libraries(foo-lib
|
|
|
|
PRIVATE libfort::fort)
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
install(
|
|
|
|
TARGETS foo-lib
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
install(
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
NAMESPACE ${PROJECT_NAME}::
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
|
|
|
)
|
2020-02-12 20:41:20 +01:00
|
|
|
|