-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
79 lines (63 loc) · 2.13 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
cmake_minimum_required(VERSION 3.5.1)
cmake_policy(SET CMP0048 NEW) # enable project VERSION
cmake_policy(SET CMP0056 NEW) # honor link flags in try_compile()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
project(schmutz VERSION 0.0.0)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
set(CMAKE_CXX_EXTENSIONS off)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
endif()
# Options
# =======
option(ENABLE_SANITIZE "compile with sanitizers enabled")
option(ENABLE_COVERAGE "compile with test coverage support")
set(GUILE_EXTENSION_DIR ${CMAKE_BINARY_DIR})
if (ENABLE_SANITIZE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak")
endif()
include(SchmutzUtils)
# Dependencies
# ============
find_package(CallableTraits)
find_package(PkgConfig)
pkg_check_modules(Guile guile-2.2)
find_program(CCACHE ccache)
if (CCACHE)
message(STATUS "Using ccache: ${CCACHE}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE})
else()
message(STATUS "Could not find ccache")
endif()
# Targets
# =======
add_library(schmutz INTERFACE)
target_include_directories(schmutz INTERFACE
$<BUILD_INTERFACE:${immer_BINARY_DIR}/>
$<BUILD_INTERFACE:${schmutz_SOURCE_DIR}/>
$<INSTALL_INTERFACE:include>
${Guile_INCLUDE_DIRS})
target_link_libraries(schmutz INTERFACE
${Guile_LIBRARIES}
callable_traits)
install(TARGETS schmutz EXPORT SchmutzConfig)
install(EXPORT SchmutzConfig DESTINATION lib/cmake/Schmutz)
install(DIRECTORY scm DESTINATION include)
if (ENABLE_COVERAGE)
target_compile_options(schmutz INTERFACE "--coverage")
target_link_libraries(schmutz INTERFACE "--coverage")
endif()
# Testing
# =======
enable_testing()
add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Buld and run all the tests and examples.")
add_subdirectory(test)
add_subdirectory(example)
add_subdirectory(doc)