-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (92 loc) · 4.09 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#CMAKE版本
cmake_minimum_required(VERSION 3.16.3)
#输出提示信息
message(STATUS "******************************************************************")
message(STATUS "CMAKE_SOURCE_DIR->" ${CMAKE_SOURCE_DIR})
message(STATUS "PROJECT_SOURCE_DIR->)" ../../..)
message(STATUS "******************************************************************")
#设置项目名
project(Application)
find_package(Git)
function(REDEFINE_FILE_MACRO targetname)
#获取当前目标的所有源文件
get_target_property(SOURCE_FILE "${targetname}" SOURCES)
#遍历源文件
foreach(sourcefile ${SOURCE_FILE})
#获取当前源文件的编译参数
get_property(defs SOURCE "${sourcefile}"
PROPERTY COMPILE_DEFINITIONS)
#获取当前文件的绝对路径
get_filename_component(filepath "${sourcefile}" ABSOLUTE)
#将绝对路径中的项目路径替换成空,得到源文件相对于项目路径的相对路径
string(REPLACE ${PROJECT_SOURCE_DIR}/ "" relpath ${filepath})
#将我们要加的编译参数(__FILE__定义)添加到原来的编译参数里面
list(APPEND defs "__FILE__=\"${relpath}\"")
#重新设置源文件的编译参数
set_property(
SOURCE "${sourcefile}"
PROPERTY COMPILE_DEFINITIONS ${defs}
)
endforeach()
endfunction()
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format="%h"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REPO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "GIT_REPOSITORY_VERSION ${GIT_REPO_VERSION}")
set(CMAKE_CXX_STANDARD 14)
set(GUI_XML)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Lib/)
SET(CMAKE_C_COMPILER "gcc")
SET(CMAKE_CXX_COMPILER "g++")
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
##线程调试工具打开
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
add_compile_options(-std=c++11 -pthread -g -ggdb -O0 -Wall
-fstack-protector-all -march=native -fnon-call-exceptions)
#SET(CMAKE_CXX_FLAGS "-std=c++14")
#add_definitions(-D__LOG_CONSOLE -D__GNU_SOURCE)
include_directories(${PROJECT_SOURCE_DIR}/Include)
include_directories(${PROJECT_SOURCE_DIR}/Include/uuid)
include_directories(${PROJECT_SOURCE_DIR}/Include/opencv2)
include_directories(${PROJECT_SOURCE_DIR}/Include/MeadiaFrame)
include_directories(${PROJECT_SOURCE_DIR}/Include/AlgArcSoft)
include_directories(${PROJECT_SOURCE_DIR}/Include/json)
include_directories(${PROJECT_SOURCE_DIR}/Include/Utils)
include_directories(${PROJECT_SOURCE_DIR}/Include/Infra)
include_directories(${PROJECT_SOURCE_DIR}/Include/curl)
include_directories(${PROJECT_SOURCE_DIR}/Include/ssl)
include_directories(${PROJECT_SOURCE_DIR}/Include/HttpClient)
include_directories(${PROJECT_SOURCE_DIR}/Include/Logger)
include_directories(${PROJECT_SOURCE_DIR}/Include/spdlog)
include_directories(${PROJECT_SOURCE_DIR}/Include/System)
include_directories(${PROJECT_SOURCE_DIR}/Include/easySqllite)
include_directories(${PROJECT_SOURCE_DIR}/Include/Storage)
include_directories(${PROJECT_SOURCE_DIR}/Include/Client)
file(GLOB_RECURSE SRC_LIST ${PROJECT_SOURCE_DIR}/Src/*.cpp
${PROJECT_SOURCE_DIR}/Src/*.cc
${PROJECT_SOURCE_DIR}/Src/*.c)
link_directories(${PROJECT_SOURCE_DIR}/Lib/json)
link_directories(${PROJECT_SOURCE_DIR}/Lib/uuid)
link_directories(${PROJECT_SOURCE_DIR}/Lib/opencv)
link_directories(${PROJECT_SOURCE_DIR}/Lib/ssl)
link_directories(${PROJECT_SOURCE_DIR}/Lib/curl)
link_directories(${PROJECT_SOURCE_DIR}/Lib/spdlog)
link_directories(${PROJECT_SOURCE_DIR}/Lib/easySqllite)
link_directories(${PROJECT_SOURCE_DIR}/Lib/algArc)
add_definitions(-Wno-builtin-macro-redefined -D__GNU_SOURCE)
add_executable(neutron ${SRC_LIST})
REDEFINE_FILE_MACRO(neutron)
target_link_libraries(neutron
arcsoft_face
arcsoft_face_engine
spdlog
opencv_core opencv_highgui opencv_videoio opencv_imgcodecs opencv_imgproc
uuid crypto ssl curl
jsoncpp easysqlite
pthread
)
add_compile_options(-Wall -fdata-sections -ffunction-sections -fstack-protector-all -frtti -fexceptions -D__GNU_SOURCE)
add_definitions(-DREPOSITORY_VERSION=${GIT_REPO_VERSION})