-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (49 loc) · 1.86 KB
/
CMakeLists.txt
File metadata and controls
59 lines (49 loc) · 1.86 KB
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
# Collect source files into the "sources" variable and unit test files into the
# "gtest_sources" variable.
gz_get_libsources_and_unittests(sources gtest_sources)
# Create the library target.
gz_create_core_library(SOURCES ${sources} CXX_STANDARD 17)
# Link the libraries that we always need.
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PUBLIC
gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER}
gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER}
CPPZMQ::CPPZMQ
PRIVATE
${ZeroMQ_TARGET}
)
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME}
SYSTEM PUBLIC
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:CPPZMQ::CPPZMQ,INTERFACE_INCLUDE_DIRECTORIES>)
# Windows system library provides UUID
if (NOT MSVC)
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PUBLIC
UUID::UUID
)
endif()
# Build the unit tests.
gz_build_tests(TYPE UNIT SOURCES ${gtest_sources}
TEST_LIST test_list
LIB_DEPS ${EXTRA_TEST_LIB_DEPS})
foreach(test ${test_list})
# Inform each test of its output directory so it knows where to call the
# auxiliary files from. Using a generator expression here is useful for
# multi-configuration generators, like Visual Studio.
target_compile_definitions(${test} PRIVATE
"DETAIL_GZ_TRANSPORT_TEST_DIR=\"$<TARGET_FILE_DIR:${test}>\""
"GZ_TEST_LIBRARY_PATH=\"$<TARGET_FILE_DIR:${PROJECT_LIBRARY_TARGET_NAME}>\"")
endforeach()
if(MSVC)
# On Windows, UNIT_Discovery_TEST uses some socket functions and therefore
# needs to link to the Windows socket library. An easy, maintainable way to
# do that is to tell it to link to the ZeroMQ target, and let it get the
# socket library dependency transitively.
if(TARGET UNIT_Discovery_TEST)
target_link_libraries(UNIT_Discovery_TEST
${ZeroMQ_TARGET})
endif()
endif()
# Command line support.
add_subdirectory(cmd)