-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (42 loc) · 1.75 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
cmake_minimum_required(VERSION 3.20)
project(skeleton CXX)
set(CMAKE_CXX_STANDARD 14)
enable_testing()
# Directories
set(SKELETON_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SKELETON_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
set(SKELETON_THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
set(SKELETON_GOOGLETEST_DIR ${SKELETON_THIRD_PARTY_DIR}/googletest)
# Dependencies
add_subdirectory(${SKELETON_GOOGLETEST_DIR} EXCLUDE_FROM_ALL)
# Project version
file(READ VERSION SKELETON_PROJECT_VERSION)
string(STRIP ${SKELETON_PROJECT_VERSION} SKELETON_PROJECT_VERSION)
# and commit
execute_process(COMMAND git describe --always --dirty
OUTPUT_VARIABLE SKELETON_GIT_COMMIT_HASH
ERROR_VARIABLE SKELETON_GIT_COMMIT_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE SKELETON_GIT_COMMIT_RESULT
)
if (NOT ${SKELETON_GIT_COMMIT_RESULT} STREQUAL 0)
message(WARNING "Could not retrieve git commit: " ${SKELETON_GIT_COMMIT_ERROR})
set(SKELETON_GIT_COMMIT_HASH unknown)
endif()
message("skeleton version information: " ${SKELETON_PROJECT_VERSION} " - " ${SKELETON_GIT_COMMIT_HASH})
configure_file(${SKELETON_SRC_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/version.h @ONLY)
# Source files
set(SKELETON_SRC_LIST
${SKELETON_SRC_DIR}/skeleton.cpp
)
# Test files
set(SKELETON_TEST_LIST
${SKELETON_TEST_DIR}/skeleton_test.cpp
)
add_library(skeleton-lib ${SKELETON_SRC_LIST})
target_include_directories(skeleton-lib PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gen)
set_target_properties(skeleton-lib PROPERTIES OUTPUT_NAME skeleton)
add_executable(skeleton-tests ${SKELETON_TEST_LIST})
target_include_directories(skeleton-tests PRIVATE ${SKELETON_SRC_DIR})
target_link_libraries(skeleton-tests skeleton-lib gtest_main)
add_test(unit-tests skeleton-tests)