-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
77 lines (64 loc) · 2.03 KB
/
CMakeLists.txt
File metadata and controls
77 lines (64 loc) · 2.03 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
cmake_minimum_required(VERSION 3.20)
project(proton LANGUAGES C CXX VERSION 0.0.0)
if(NOT CMAKE_CROSSCOMPILING)
# protobuf v*.23.0+ will fail to find Abseil, which is a required dependency.
# Using pkg-config to find protobuf config information instead of direct find_package, to get correct dependencies
find_package(PkgConfig REQUIRED)
if(PkgConfig_FOUND)
pkg_search_module(Protobuf protobuf CONFIG REQUIRED)
endif()
find_package(Protobuf REQUIRED)
if (Protobuf_VERSION_MINOR GREATER_EQUAL 23)
find_package(absl CONFIG QUIET)
if(NOT absl_FOUND)
message(WARNING "Abseil not found via CMake config, trying pkg-config")
if(PkgConfig_FOUND)
pkg_search_module(Abseil absl)
endif()
endif()
endif()
endif()
option(PROTON_BUILD_PROTONC "Build protonc library" ON)
option(PROTON_BUILD_PROTONCPP "Build protoncpp library" ON)
option(PROTON_BUILD_EXAMPLES "Build proton examples" ON)
option(PROTON_BUILD_TESTS "Build proton tests" ON)
option(PROTON_INSTALL "Install proton" ON)
if (PROTON_BUILD_PROTONC)
add_subdirectory(protonc)
endif()
if (PROTON_BUILD_PROTONCPP)
add_subdirectory(protoncpp)
endif()
if (PROTON_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if (PROTON_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# Export targets from both libraries
include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/protonConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/protonConfig.cmake
INSTALL_DESTINATION lib/cmake/proton
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/protonConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
if (PROTON_INSTALL)
install(
EXPORT ProtonTargets
NAMESPACE proton::
DESTINATION lib/cmake/proton
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/protonConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/protonConfigVersion.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/protonFunctions.cmake
DESTINATION lib/cmake/proton
)
endif()