Skip to content

Commit f10f5eb

Browse files
committed
WL15064 Possibility to use external 3rd-party dependencies
By default, it will still use the bundled sources to build Change-Id: If624fd626ec2a2f1157311d51519e3f58f99e5ee
1 parent 534eac1 commit f10f5eb

File tree

8 files changed

+383
-176
lines changed

8 files changed

+383
-176
lines changed

cdk/cmake/DepFindCompression.cmake

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,50 @@
2626
# along with this program; if not, write to the Free Software Foundation, Inc.,
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

29-
##############################################################################
29+
# #############################################################################
3030
#
3131
# Targets:
3232
#
3333
# (re)build-{zlib,lz4,zstd}
3434
#
3535
# Imported/alias targets:
3636
#
37-
# ext::zlib
37+
# ext::z
3838
# ext::lz4
3939
# ext::zstd
4040
#
41-
# TODO:
42-
# - allow use of external, dynamic libraries instead of static linking
43-
#
4441

45-
if(TARGET ext::zlib)
42+
if(TARGET ext::z)
4643
return()
4744
endif()
4845

4946
message(STATUS "Setting up compression libraries.")
5047

51-
# Use external builds from the bundled sources
48+
#######
49+
# ZLIB
50+
#
51+
add_ext(zlib zlib.h z ext_zlib)
52+
if(NOT ZLIB_FOUND)
53+
message(FATAL_ERROR "Can't build without zlib support")
54+
endif()
55+
5256

53-
add_ext(zlib)
54-
add_ext_targets(zlib zlib ext_zlib)
57+
#######
58+
# LZ4
59+
#
60+
add_ext(lz4 lz4frame.h lz4 ext_lz4)
5561

56-
add_ext(lz4)
57-
add_ext_targets(lz4 lz4 ext_lz4)
62+
if(NOT LZ4_FOUND)
63+
message(FATAL_ERROR "Can't build without lz4 support")
64+
endif()
65+
66+
67+
#######
68+
# ZSTD
69+
#
70+
add_ext(zstd zstd.h zstd ext_zstd)
71+
72+
if(NOT LZ4_FOUND)
73+
message(FATAL_ERROR "Can't build without zstd support")
74+
endif()
5875

59-
add_ext(zstd)
60-
add_ext_targets(zstd zstd ext_zstd)

cdk/cmake/DepFindProtobuf.cmake

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# along with this program; if not, write to the Free Software Foundation, Inc.,
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

29-
##############################################################################
29+
# #############################################################################
3030
#
3131
# Targets:
3232
#
@@ -42,36 +42,32 @@
4242
#
4343
# mysqlx_protobuf_generate_cpp()
4444
#
45-
# TODO:
46-
# - Allow using external install of protobuf instead of building it from
47-
# bundled sources
4845
#
4946

50-
5147
if(TARGET ext::protobuf)
5248
return()
5349
endif()
5450

5551
message(STATUS "Setting up Protobuf.")
5652

5753
# Setup extrnal project that builds protobuf from bundled sources
54+
add_ext(protobuf google/protobuf/api.pb.h)
5855

59-
add_ext(protobuf)
56+
if(NOT PROTOBUF_FOUND)
57+
message(FATAL_ERROR "Can't build without protobuf support")
58+
endif()
6059

61-
# import targets from the external project
60+
# import targets from the external project
6261
# Note: The pb_ targets are created by protobuf/exports.cmake
63-
6462
add_ext_targets(protobuf
65-
pb-lite pb_libprotobuf-lite
66-
pb-full pb_libprotobuf
67-
protoc pb_protoc
63+
LIBRARY protobuf-lite pb_libprotobuf-lite
64+
LIBRARY protobuf pb_libprotobuf
65+
EXECUTABLE protoc pb_protoc
6866
)
6967

7068

7169
# Standard PROTOBUF_GENERATE_CPP modified to our usage
72-
7370
function(mysqlx_protobuf_generate_cpp SRCS HDRS)
74-
7571
IF(NOT ARGN)
7672
MESSAGE(SEND_ERROR
7773
"Error: MYSQLX_PROTOBUF_GENERATE_CPP() called without any proto files")
@@ -82,7 +78,6 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
8278
SET(hdrs)
8379

8480
FOREACH(FIL ${ARGN})
85-
8681
GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)
8782
GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE)
8883
GET_FILENAME_COMPONENT(ABS_PATH ${ABS_FIL} PATH)
@@ -92,18 +87,18 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
9287

9388
ADD_CUSTOM_COMMAND(
9489
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.cc"
95-
"${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.h"
90+
"${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.h"
9691
COMMAND ${CMAKE_COMMAND}
97-
-E make_directory "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
92+
-E make_directory "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
9893
COMMAND ext::protoc
9994
ARGS --cpp_out "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
100-
-I ${ABS_PATH} ${ABS_FIL}
101-
#--proto_path=${PROTOBUF_INCLUDE_DIR}
95+
-I ${ABS_PATH} ${ABS_FIL}
96+
97+
# --proto_path=${PROTOBUF_INCLUDE_DIR}
10298
DEPENDS ${ABS_FIL}
10399
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
104100
VERBATIM
105101
)
106-
107102
ENDFOREACH()
108103

109104
SET_SOURCE_FILES_PROPERTIES(
@@ -113,7 +108,6 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
113108
#
114109
# Disable compile warnings in code generated by Protobuf
115110
#
116-
117111
IF(UNIX)
118112
set_source_files_properties(${srcs}
119113
APPEND_STRING PROPERTY COMPILE_FLAGS "-w"
@@ -125,8 +119,6 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
125119
)
126120
ENDIF()
127121

128-
129122
SET(${SRCS} ${srcs} PARENT_SCOPE)
130123
SET(${HDRS} ${hdrs} PARENT_SCOPE)
131-
132124
endfunction(mysqlx_protobuf_generate_cpp)

0 commit comments

Comments
 (0)