-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
63 lines (52 loc) · 2.07 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
cmake_minimum_required(VERSION 2.8.12)
option(GOTCHA_ENABLE_TESTS "Enable internal tests" Off)
option(GOTCHA_ENABLE_WARNING_ERROR "Enable throw error for build warning" Off)
project(gotcha)
include(CheckCXXCompilerFlag)
include(cmake/gotcha.cmake)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
set(LIBTOOL_INTERFACE 2)
set(LIBTOOL_REVISION 3)
set(LIBTOOL_AGE 2)
set(GOTCHA_VERSION "(1, 0, 7)")
set(DEFAULT_SYMBOL_VISIBILITY hidden)
if(GOTCHA_ENABLE_TESTS)
enable_testing()
set(DEFAULT_SYMBOL_VISIBILITY default)
add_definitions("-DGOTCHA_ENABLE_TESTING")
if(CMAKE_BUILD_TYPE STREQUAL "PROFILE")
set(CMAKE_C_FLAGS_PROFILE --coverage)
set(CMAKE_CXX_FLAGS_PROFILE --coverage)
endif()
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
if(GOTCHA_ENABLE_TESTS)
add_subdirectory(test)
setup_coverage_target()
endif()
include(CMakePackageConfigHelpers)
# Configure gotcha-config-version.cmake
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/gotcha-config-version.cmake"
VERSION ${LIBTOOL_INTERFACE}.${LIBTOOL_REVISION}.${LIBTOOL_AGE}
COMPATIBILITY SameMajorVersion)
set(gotcha_INSTALL_INCLUDE_DIR include/)
set(gotcha_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
# Configure gotcha-config.cmake
configure_package_config_file(
"cmake/config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/gotcha-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/gotcha"
PATH_VARS gotcha_INSTALL_INCLUDE_DIR PATH_VARS gotcha_INSTALL_LIBRARY_DIR)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/gotcha-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/gotcha-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/gotcha")
# Write the configure file
configure_file("${CMAKE_SOURCE_DIR}/cmake/gotcha_config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/include/gotcha/gotcha_config.h" @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/include/gotcha/gotcha_config.h"
DESTINATION "${gotcha_INSTALL_INCLUDE_DIR}/gotcha")