This repository has been archived by the owner on Sep 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
CMakeLists.txt
81 lines (67 loc) · 2.24 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(hfsm VERSION 0.1.0 LANGUAGES CXX)
include(GNUInstallDirs)
option(HFSM_BUILD_TESTS "Enable/disable building test executable" ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
set(extra_cxx_flags "-Wall -Wno-unknown-pragmas -Werror")
set(CMAKE_CXX_FLAGS "${extra_cxx_flags} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${extra_cxx_flags} ${CMAKE_C_FLAGS}")
#-------------------------------------------------------------------------------
# hfsm target
#-------------------------------------------------------------------------------
add_library(hfsm INTERFACE)
target_include_directories(
hfsm INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
#-------------------------------------------------------------------------------
# Install & export targets
#-------------------------------------------------------------------------------
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}")
set(version_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# Generate package version file.
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
# Export hfsm target.
install(
TARGETS hfsm
EXPORT "${targets_export_name}"
INCLUDES DESTINATION "${include_install_dir}"
)
# Install hfsm headers.
install(
DIRECTORY "include/${PROJECT_NAME}"
DESTINATION "${include_install_dir}"
)
# Install project version file.
install(
FILES "${version_config}"
DESTINATION "${config_install_dir}"
)
# Install project config file.
install(
EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
FILE ${project_config}
)
# Export build directory config file.
export(
EXPORT ${targets_export_name}
NAMESPACE "${namespace}"
FILE ${project_config}
)
# Register project in CMake user registry.
export(PACKAGE ${PROJECT_NAME})
if(HFSM_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(HFSM_BUILD_TESTS)