-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
95 lines (76 loc) · 2.29 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
93
94
95
cmake_minimum_required(VERSION 3.20)
set (CMAKE_CXX_STANDARD 20)
include(ExternalProject)
project (shelter)
set(VERSION 2.0.12)
option(USE_LTO "Use link time optimization" TRUE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION USE_LTO)
if (MSVC)
add_compile_options(/W4 /DNDEBUG)
else()
find_library(GIT2_LIBRARY NAMES git2)
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
# this needs for clang-tidy to get include paths etc
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
ExternalProject_Add(lyra
GIT_REPOSITORY "https://github.com/bfgroup/Lyra.git"
GIT_TAG "develop"
SOURCE_DIR lyra
INSTALL_DIR "${CMAKE_BINARY_DIR}"
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
if (MSVC)
set(YAML_CPP_SHARED_LIBS ON)
else()
set(YAML_CPP_SHARED_LIBS OFF)
endif()
ExternalProject_Add(yaml_cpp
GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
GIT_TAG "master"
SOURCE_DIR yaml-cpp
BINARY_DIR yaml-cpp-build
INSTALL_DIR "${CMAKE_BINARY_DIR}"
CMAKE_ARGS
-DYAML_CPP_BUILD_TESTS=OFF
-DYAML_BUILD_SHARED_LIBS=${YAML_CPP_SHARED_LIBS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_LIBDIR:PATH=<INSTALL_DIR>/lib
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
add_library(yaml-cpp STATIC IMPORTED)
set_target_properties(yaml-cpp PROPERTIES
IMPORTED_LOCATION ${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cpp${CMAKE_STATIC_LIBRARY_SUFFIX})
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/src"
"${PROJECT_BINARY_DIR}/include")
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Get the latest commit hash
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_definitions( -DVERSION_CMAKE=${VERSION} )
add_definitions( -DBRANCH_CMAKE=${GIT_BRANCH} )
add_definitions( -DHASH_CMAKE=${GIT_COMMIT_HASH} )
add_executable(shelter src/main.cxx)
add_dependencies(shelter yaml_cpp lyra)
target_precompile_headers(shelter
PRIVATE
src/stdafx.hpp
)
if (MSVC)
target_link_libraries(shelter
yaml-cpp
)
else()
target_link_libraries(shelter
yaml-cpp ${GIT2_LIBRARY}
)
endif()