-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
84 lines (63 loc) · 2.85 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
# Defines AppBase library target.
project( AppBase )
cmake_minimum_required( VERSION 3.5 )
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
include( GNUInstallDirs )
file(GLOB HEADERS "include/appbase/*.hpp")
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
if(CMAKE_CXX_STANDARD EQUAL 98 OR CMAKE_CXX_STANDARD LESS 14)
message(FATAL_ERROR "appbase requires c++14 or newer")
elseif(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads)
find_package(Boost 1.60 REQUIRED COMPONENTS filesystem program_options)
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring AppBase on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-conversion -Wno-deprecated-declarations" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring AppBase on Linux" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
if ( FULL_STATIC_BUILD )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif ( FULL_STATIC_BUILD )
endif( APPLE )
if(ENABLE_COVERAGE_TESTING)
SET(CMAKE_CXX_FLAGS "--coverage ${CMAKE_CXX_FLAGS}")
endif()
add_library( appbase
application.cpp
${HEADERS}
)
target_link_libraries( appbase Boost::program_options Boost::filesystem Threads::Threads)
target_include_directories( appbase
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
set_target_properties( appbase PROPERTIES PUBLIC_HEADER "${HEADERS}" )
option(APPBASE_ENABLE_AUTO_VERSION "enable automatic discovery of version via 'git describe'" ON)
find_package(Git)
if(APPBASE_ENABLE_AUTO_VERSION AND EXISTS ${CMAKE_SOURCE_DIR}/.git AND GIT_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/version.cmake @ONLY)
add_custom_target(appbase_version ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/version.cmake BYPRODUCTS version.cpp)
add_dependencies(appbase appbase_version)
else()
set(VERSION_STRING "Unknown")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/version.cpp @ONLY ESCAPE_QUOTES)
endif()
target_sources(appbase PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
set(CPACK_PACKAGING_INSTALL_PREFIX /)
if(APPBASE_INSTALL_COMPONENT)
set(INSTALL_COMPONENT_ARGS COMPONENT ${APPBASE_INSTALL_COMPONENT} EXCLUDE_FROM_ALL)
endif()
install( TARGETS
appbase
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} ${INSTALL_COMPONENT_ARGS}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} ${INSTALL_COMPONENT_ARGS}
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} ${INSTALL_COMPONENT_ARGS}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/appbase ${INSTALL_COMPONENT_ARGS}
)
add_subdirectory( examples )