1
- # find_package(Protobuf QUIET)
2
- # if("${yaLanTingLibs_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
3
- # # If this is a subproject in ylt
4
- # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/tests)
5
- # else()
6
- # # else find installed yalantinglibs
7
- # cmake_minimum_required(VERSION 3.15)
8
- # project(struct_pb_test)
9
- # set(CMAKE_CXX_STANDARD 17)
10
- # set(CMAKE_CXX_STANDARD_REQUIRED ON)
11
- # set(CMAKE_INCLUDE_CURRENT_DIR ON)
12
- # # if you have install ylt
13
- # find_package(yalantinglibs REQUIRED)
14
- # link_libraries(yalantinglibs::yalantinglibs)
15
- # # else
16
- # # include_directories(include)
17
- # # include_directories(include/ylt/thirdparty)
18
- # endif()
1
+ find_package (Protobuf QUIET )
2
+ if ("${yaLanTingLibs_SOURCE_DIR} " STREQUAL "${CMAKE_SOURCE_DIR} " )
3
+ # If this is a subproject in ylt
4
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /output/tests )
5
+ else ()
6
+ # else find installed yalantinglibs
7
+ cmake_minimum_required (VERSION 3.15 )
8
+ project (struct_pb_test )
9
+ set (CMAKE_CXX_STANDARD 17 )
10
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
11
+ set (CMAKE_INCLUDE_CURRENT_DIR ON )
12
+ # if you have install ylt
13
+ find_package (yalantinglibs REQUIRED )
14
+ link_libraries (yalantinglibs::yalantinglibs )
15
+ # else
16
+ # include_directories(include)
17
+ # include_directories(include/ylt/thirdparty)
18
+ endif ()
19
19
20
- # set(TEST_PROTO main.cpp)
20
+ set (TEST_PROTO main.cpp )
21
21
22
- # if (TEST_STRUCT_PB_WITH_PROTO)
23
- # message(STATUS "Gen proto files")
24
- # add_definitions(-DSTRUCT_PB_WITH_PROTO)
25
- # message(STATUS "Found Protobuf: ${Protobuf_VERSION}")
26
- # include_directories(${Protobuf_INCLUDE_DIRS})
27
- # include_directories(${CMAKE_CURRENT_BINARY_DIR})
28
- # set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/)
29
- # file(GLOB PROTO_FILES ${PROTO_SRC_DIR}/*.proto)
22
+ if (TEST_STRUCT_PB_WITH_PROTO )
23
+ message (STATUS "Gen proto files" )
24
+ add_definitions (-DSTRUCT_PB_WITH_PROTO )
25
+ message (STATUS "Found Protobuf: ${Protobuf_VERSION} " )
26
+ include_directories (${Protobuf_INCLUDE_DIRS} )
27
+ include_directories (${CMAKE_CURRENT_BINARY_DIR} )
28
+ set (PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} / )
29
+ file (GLOB PROTO_FILES ${PROTO_SRC_DIR} /*.proto )
30
30
31
- # protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
32
- # # message(STATUS "Proto source files: ${PROTO_SRCS}")
33
- # # message(STATUS "Proto header files: ${PROTO_HDRS}")
34
- # add_executable(struct_pb_test ${PROTO_SRCS} ${TEST_PROTO})
35
- # target_link_libraries(struct_pb_test PRIVATE protobuf::libprotobuf)
36
- # add_test(NAME struct_pb_test COMMAND struct_pb_test)
37
- # else()
38
- # add_executable(struct_pb_test ${TEST_PROTO})
39
- # add_test(NAME struct_pb_test COMMAND struct_pb_test)
40
- # endif()
31
+ protobuf_generate_cpp (PROTO_SRCS PROTO_HDRS ${PROTO_FILES} )
32
+ # message(STATUS "Proto source files: ${PROTO_SRCS}")
33
+ # message(STATUS "Proto header files: ${PROTO_HDRS}")
34
+ add_executable (struct_pb_test ${PROTO_SRCS} ${TEST_PROTO} )
35
+ target_link_libraries (struct_pb_test PRIVATE protobuf::libprotobuf )
36
+ add_test (NAME struct_pb_test COMMAND struct_pb_test )
37
+ else ()
38
+ add_executable (struct_pb_test ${TEST_PROTO} )
39
+ add_test (NAME struct_pb_test COMMAND struct_pb_test )
40
+ endif ()
0 commit comments