forked from Robocup-ssl-China/rocos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
55 lines (50 loc) · 1.86 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.14)
project(rocos2 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
#set(CMAKE_BUILD_TYPE Release)
if(WIN32)
add_definitions(-DPROTOBUF_USE_DLLS)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-reorder -Wno-unused-parameter -Wno-unused-variable")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/modules)
include(${PROJECT_SOURCE_DIR}/cmake/Utils.cmake)
standard_config()
standard_paths(${PROJECT_SOURCE_DIR} bin bin)
# protobuf
find_package(Protobuf REQUIRED)
function(get_pb_file H CPP)
list(APPEND PH ${ARGN})
list(APPEND PC ${ARGN})
list(TRANSFORM PH PREPEND ${CMAKE_BINARY_DIR}/proto/)
list(TRANSFORM PH APPEND .pb.h)
list(TRANSFORM PC PREPEND ${CMAKE_BINARY_DIR}/proto/)
list(TRANSFORM PC APPEND .pb.cc)
set(${H} ${PH} PARENT_SCOPE)
set(${CPP} ${PC} PARENT_SCOPE)
endfunction()
SET(PROTO_META_BASE_DIR ${CMAKE_BINARY_DIR}/proto)
file(MAKE_DIRECTORY ${PROTO_META_BASE_DIR})
list(APPEND libs ${Protobuf_LIBRARIES})
include_directories(${PROTOBUF_INCLUDE_DIRS})
LIST(APPEND PROTO_FLAGS -I${CMAKE_SOURCE_DIR}/share/proto)
file(GLOB PROTO_FILES "${CMAKE_SOURCE_DIR}/share/proto/*.proto")
FOREACH(FIL ${PROTO_FILES})
GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)
GET_FILENAME_COMPONENT(FIL_WE ${ABS_FIL} NAME_WE)
EXECUTE_PROCESS(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${PROTO_META_BASE_DIR} ${FIL}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ENDFOREACH()
#add_subdirectory(TinyCore)
add_subdirectory(Client)