-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
65 lines (54 loc) · 1.82 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
CMAKE_MINIMUM_REQUIRED(VERSION 3.12.1)
PROJECT(openfsm)
# Define the library target
add_library(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/openfsm.cpp)
target_include_directories( ${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/openfsm>
)
# Install rules
include(GNUInstallDirs)
if(DEFINED ENV{PREFIX})
message(STATUS "Set install prefix: $ENV{PREFIX}")
file(TO_CMAKE_PATH "$ENV{PREFIX}" PREFIX_PATH)
set(CMAKE_INSTALL_PREFIX ${PREFIX_PATH})
endif()
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Install include directory
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openfsm/
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)
# Package configuration
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/openfsmConfigVersion.cmake"
VERSION 1.0
COMPATIBILITY AnyNewerVersion
)
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE openfsm::
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/openfsmConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE openfsm::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/openfsmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/openfsmConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)