-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
92 lines (74 loc) · 2.31 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
82
83
84
85
86
87
88
89
90
91
92
# CMakeLists.txt for afsm library
#
# @author zmij
# @date Nov 30, 2015
cmake_minimum_required(VERSION 2.6)
# Set library name here
set(lib_name afsm)
string(TOUPPER ${lib_name} LIB_NAME)
if (PROJECT_VERSION)
set(_pversion ${PROJECT_VERSION})
else()
set(_pversion 0.1.0)
endif()
if (${CMAKE_VERSION} VERSION_GREATER "3.0")
cmake_policy(SET CMP0048 NEW)
project(${lib_name} VERSION ${_pversion})
else()
project(${lib_name})
set(PROJECT_VERSION ${_pversion})
endif()
option(AFSM_BUILD_TESTS "Build test programs" ON)
option(AFSM_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(AFSM_BUILD_EXAMPLES "Build example programs" OFF)
option(USE_CCACHE "Use ccache for build" ON)
if (USE_CCACHE)
find_program(CCACHE ccache)
if (CCACHE)
message(STATUS "ccache found and enabled")
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
else()
message(WARNING "ccache enabled, but not found")
endif()
else()
message(STATUS "ccache disabled")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
message(STATUS "AFSM C++ standard ${CMAKE_CXX_STANDARD}")
add_definitions(-Wall -Werror -Wextra -pedantic -Weffc++
-Wno-non-virtual-dtor # I really know what I am exactly doing
)
set(${LIB_NAME}_LIB ${lib_name})
find_package(ExternalProjectZmijModules)
find_package(ExternalProjectMetapushkin)
message(STATUS "Metapushkin include dir ${METAPUSHKIN_INCLUDE_DIRS}")
include_directories(${METAPUSHKIN_INCLUDE_DIRS})
add_subdirectory(include)
add_subdirectory(cmake)
add_library(afsm INTERFACE)
add_dependencies(afsm libmetapushkin)
if (AFSM_BUILD_TESTS OR AFSM_BUILD_BENCHMARKS)
find_package(ExternalProjectGTest)
endif()
if (AFSM_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if (AFSM_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
if (AFSM_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
get_directory_property(has_parent PARENT_DIRECTORY)
if (has_parent)
set(${LIB_NAME}_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
${METAPUSHKIN_INCLUDE_DIRS}
CACHE INTERNAL "Path to afsm libaray includes" )
endif()