blob: caf49d47c0cc0793795c2aaaf55d1bb57d590d1d (
plain)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2139dc0..65fc108 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,58 +27,64 @@ include(CTest)
# ============================================================================
# Find Python
-find_package(Python COMPONENTS Interpreter Development)
+find_package(Python3 COMPONENTS Interpreter Development.Module)
# ============================================================================
# Build dependencies
+include(FetchContent)
-if(USE_SYSTEM_ABSEIL)
- # Version omitted, as absl only allows EXACT version matches
- set(_absl_package_args REQUIRED)
-else()
- set(_absl_package_args 20230125)
-endif()
-if(USE_SYSTEM_PROTOBUF)
- set(_protobuf_package_args 4.23.3 REQUIRED)
-else()
- set(_protobuf_package_args 4.23.3)
-endif()
-if(USE_SYSTEM_PYBIND)
- set(_pybind11_package_args 2.11.1 REQUIRED)
-else()
- set(_pybind11_package_args 2.11.1)
+message(CHECK_START "Checking for external dependencies")
+list(APPEND CMAKE_MESSAGE_INDENT " ")
+
+if(NOT TARGET absl::base)
+ if(USE_SYSTEM_ABSEIL)
+ # Version omitted, as absl only allows EXACT version matches
+ set(_absl_package_args REQUIRED)
+ else()
+ set(_absl_package_args 20240722)
+ endif()
+ FetchContent_Declare(
+ absl
+ GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
+ GIT_TAG 20240722.0
+ FIND_PACKAGE_ARGS ${_absl_package_args} NAMES absl)
+ set(ABSL_PROPAGATE_CXX_STD ON)
+ set(ABSL_ENABLE_INSTALL ON)
+ FetchContent_MakeAvailable(absl)
endif()
-set(ABSL_PROPAGATE_CXX_STD ON)
-set(ABSL_ENABLE_INSTALL ON)
+if(NOT TARGET protobuf::libprotobuf)
+ if(USE_SYSTEM_PROTOBUF)
+ set(_protobuf_package_args 28.2.0 REQUIRED)
+ else()
+ set(_protobuf_package_args 28.2.0)
+ endif()
+ FetchContent_Declare(
+ Protobuf
+ GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
+ GIT_TAG v28.2
+ GIT_SUBMODULES ""
+ FIND_PACKAGE_ARGS ${_protobuf_package_args} NAMES protobuf)
+ set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
+ FetchContent_MakeAvailable(Protobuf)
+endif()
-include(FetchContent)
-FetchContent_Declare(
- absl
- GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
- GIT_TAG 20230125.3
- FIND_PACKAGE_ARGS ${_absl_package_args} NAMES absl)
-
-# cmake-format: off
-FetchContent_Declare(
- Protobuf
- GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
- GIT_TAG v23.3
- GIT_SUBMODULES ""
- FIND_PACKAGE_ARGS ${_protobuf_package_args} NAMES protobuf)
-set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
-# cmake-format: on
-
-FetchContent_Declare(
- pybind11
- GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
- GIT_TAG v2.11.1
- FIND_PACKAGE_ARGS ${_pybind11_package_args} NAMES pybind11)
+if(NOT TARGET pybind11::pybind11_headers)
+ if(USE_SYSTEM_PYBIND)
+ set(_pybind11_package_args 2.13.6 REQUIRED)
+ else()
+ set(_pybind11_package_args 2.13.6)
+ endif()
+ FetchContent_Declare(
+ pybind11
+ GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
+ GIT_TAG v2.13.6
+ FIND_PACKAGE_ARGS ${_pybind11_package_args} NAMES pybind11)
+ FetchContent_MakeAvailable(pybind11)
+endif()
-message(CHECK_START "Checking for external dependencies")
-list(APPEND CMAKE_MESSAGE_INDENT " ")
-FetchContent_MakeAvailable(absl Protobuf pybind11)
list(POP_BACK CMAKE_MESSAGE_INDENT)
+message(CHECK_PASS "found")
# ============================================================================
# pybind11_proto_utils pybind11 extension module
@@ -87,8 +93,10 @@ pybind11_add_module(
pybind11_protobuf/proto_utils.h)
target_link_libraries(
- pybind11_proto_utils PRIVATE absl::strings protobuf::libprotobuf
- ${Python_LIBRARIES})
+ pybind11_proto_utils PRIVATE
+ absl::strings
+ protobuf::libprotobuf
+ Python3::Module)
target_include_directories(
pybind11_proto_utils PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS}
@@ -116,10 +124,11 @@ target_link_libraries(
absl::optional
protobuf::libprotobuf
pybind11::pybind11
- ${Python_LIBRARIES})
+ Python3::Module)
target_include_directories(
pybind11_native_proto_caster
+ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
PRIVATE ${PROJECT_SOURCE_DIR} ${protobuf_INCLUDE_DIRS} ${protobuf_SOURCE_DIR}
${pybind11_INCLUDE_DIRS})
@@ -143,7 +152,7 @@ target_link_libraries(
absl::optional
protobuf::libprotobuf
pybind11::pybind11
- ${Python_LIBRARIES})
+ Python3::Module)
target_include_directories(
pybind11_wrapped_proto_caster
|