-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
55 lines (49 loc) · 1.59 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.10)
# set compiler path
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
# get git version
set(COMMIT_HASH "")
set(BRANCH_NAME "")
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%H
OUTPUT_VARIABLE COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} symbolic-ref --short -q HEAD
OUTPUT_VARIABLE BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
string(SUBSTRING ${COMMIT_HASH} 0 8 COMMIT_HASH)
string(TIMESTAMP BUILD_TIMESTAMP "%Y-%m-%dT%H:%M:%S")
message(STATUS "Git version is ${BRANCH_NAME}:${COMMIT_HASH}")
message(STATUS "Build time: ${BUILD_TIMESTAMP}")
add_definitions(-DCOMMIT_HASH=\"${COMMIT_HASH}\")
add_definitions(-DBRANCH_NAME=\"${BRANCH_NAME}\")
add_definitions(-DBUILD_TIMESTAMP=\"${BUILD_TIMESTAMP}\")
project(repo_c)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# gdb debug
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb -lpthread")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -lpthread")
IF (CMAKE_BUILD_TYPE STREQUAL Release)
ADD_DEFINITIONS(-DNDEBUG)
ENDIF()
add_subdirectory(debug)
add_subdirectory(apps/hello_world)
add_subdirectory(apps/datastruct_test)
add_subdirectory(apps/opencv_sample)
add_subdirectory(apps/qt5-project)
add_subdirectory(apps/opencv_qt_test)
add_subdirectory(apps/ImageTools)
add_subdirectory(common)