Skip to content

Commit c58e7af

Browse files
committed
Fix: Build got some error with -DBUILD_GTEST=OFF
The target stats_generate_protobuf contained by if (BUILD_GTEST AND NOT BUILD_PAX_FORMAT) If pax build without GTEST, then target stats_generate_protobuf will be missed.
1 parent a497b81 commit c58e7af

1 file changed

Lines changed: 57 additions & 59 deletions

File tree

contrib/pax_storage/src/cpp/CMakeLists.txt

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ set(orc_proto_src "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/orc_proto.pb.h" "${
7474
set(pax_proto_file "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/pax.proto")
7575
set(pax_proto_src "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/pax.pb.h" "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/pax.pb.cc")
7676

77+
set(catalog_proto_file "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/micro_partition_stats.proto")
78+
set(stats_proto_src "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/micro_partition_stats.pb.h" "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/micro_partition_stats.pb.cc")
79+
7780
add_custom_command(OUTPUT ${orc_proto_src}
7881
COMMAND ${PROTOBUF_EXECUTABLE}
7982
-I ${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/
@@ -85,31 +88,27 @@ add_custom_command(OUTPUT ${pax_proto_src}
8588
-I ${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/
8689
--cpp_out="${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/"
8790
${pax_proto_file})
88-
add_custom_target(generate_protobuf DEPENDS ${orc_proto_src} ${pax_proto_src})
89-
90-
if (BUILD_GTEST AND NOT BUILD_PAX_FORMAT)
91-
92-
set(catalog_proto_file "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/micro_partition_stats.proto")
93-
set(stats_proto_src "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/micro_partition_stats.pb.h" "${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/micro_partition_stats.pb.cc")
9491

9592
add_custom_command(OUTPUT ${stats_proto_src}
9693
COMMAND ${PROTOBUF_EXECUTABLE}
9794
-I ${CMAKE_CURRENT_SOURCE_DIR}/storage/proto/
9895
--cpp_out="${CMAKE_CURRENT_SOURCE_DIR}/storage/proto"
9996
${catalog_proto_file})
100-
add_custom_target(stats_generate_protobuf DEPENDS ${stats_proto_src})
10197

102-
add_subdirectory(contrib/googletest)
103-
ADD_DEFINITIONS(-DRUN_GTEST)
104-
file(GLOB TEST_CASE_SOURCES
105-
${CMAKE_CURRENT_SOURCE_DIR}/*/*_test.cc
106-
${CMAKE_CURRENT_SOURCE_DIR}/*/*/*_test.cc)
98+
add_custom_target(generate_protobuf DEPENDS ${orc_proto_src} ${pax_proto_src} ${stats_proto_src})
10799

108-
link_directories($ENV{GPHOME}/lib)
109-
add_executable(test_main ${TEST_CASE_SOURCES})
110-
add_dependencies(test_main gtest gmock gtest_main)
111-
target_include_directories(test_main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${gtest_SOURCE_DIR}/include)
112-
target_link_libraries(test_main gtest gmock gtest_main postgres pax)
100+
if (BUILD_GTEST AND NOT BUILD_PAX_FORMAT)
101+
add_subdirectory(contrib/googletest)
102+
ADD_DEFINITIONS(-DRUN_GTEST)
103+
file(GLOB TEST_CASE_SOURCES
104+
${CMAKE_CURRENT_SOURCE_DIR}/*/*_test.cc
105+
${CMAKE_CURRENT_SOURCE_DIR}/*/*/*_test.cc)
106+
107+
link_directories($ENV{GPHOME}/lib)
108+
add_executable(test_main ${TEST_CASE_SOURCES})
109+
add_dependencies(test_main gtest gmock gtest_main)
110+
target_include_directories(test_main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${gtest_SOURCE_DIR}/include)
111+
target_link_libraries(test_main gtest gmock gtest_main postgres pax)
113112
endif(BUILD_GTEST AND NOT BUILD_PAX_FORMAT)
114113

115114
# ztsd
@@ -119,7 +118,6 @@ set(ZSTD_BUILD_CONTRIB)
119118
add_subdirectory(contrib/zstd/build/cmake/)
120119
set(ZTSD_HEADER contrib/zstd/lib)
121120

122-
123121
set(pax_comm_src
124122
comm/bitmap.cc
125123
comm/paxc_wrappers.cc
@@ -158,8 +156,6 @@ set(pax_storage_src
158156
if(NOT BUILD_PAX_FORMAT)
159157
set(pax_storage_src ${pax_storage_src} storage/pax.cc)
160158
endif(NOT BUILD_PAX_FORMAT)
161-
162-
163159

164160
set(pax_access_src
165161
access/pax_access_handle.cc
@@ -179,49 +175,49 @@ set(pax_vec_src
179175
link_directories($ENV{GPHOME}/lib)
180176

181177
if(BUILD_PAX_FORMAT)
182-
# paxformat.so
183-
ADD_DEFINITIONS(-DBUILD_PAX_FORMAT)
184-
add_library(paxformat SHARED ${orc_proto_src} ${pax_proto_src} ${pax_storage_src} ${pax_exceptions_src} ${pax_comm_src} )
185-
target_include_directories(paxformat PUBLIC ${ZTSD_HEADER} ${CMAKE_CURRENT_SOURCE_DIR} "${CBDB_INCLUDE_DIR}")
186-
target_link_libraries(paxformat PUBLIC uuid orc_protobuf zstd z)
187-
set_target_properties(paxformat PROPERTIES
188-
OUTPUT_NAME paxformat)
189-
add_dependencies(paxformat generate_protobuf)
190-
191-
# export headers
192-
set(PAX_COMM_HEADERS
193-
comm/cbdb_api.h
194-
)
178+
# paxformat.so
179+
ADD_DEFINITIONS(-DBUILD_PAX_FORMAT)
180+
add_library(paxformat SHARED ${orc_proto_src} ${pax_proto_src} ${pax_storage_src} ${pax_exceptions_src} ${pax_comm_src} )
181+
target_include_directories(paxformat PUBLIC ${ZTSD_HEADER} ${CMAKE_CURRENT_SOURCE_DIR} ${CBDB_INCLUDE_DIR})
182+
target_link_libraries(paxformat PUBLIC uuid orc_protobuf zstd z)
183+
set_target_properties(paxformat PROPERTIES
184+
OUTPUT_NAME paxformat)
185+
add_dependencies(paxformat generate_protobuf)
186+
187+
# export headers
188+
set(PAX_COMM_HEADERS
189+
comm/cbdb_api.h
190+
)
195191

196-
## install dynamic libraray
197-
install(TARGETS paxformat
198-
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
199-
200-
# TODO(gongxun):
201-
# We should explicitly specify the headers
202-
# that need to be exported, and use the syntax of
203-
# install(FILES,...) to install the header files
204-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/storage
205-
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pax
206-
FILES_MATCHING
207-
PATTERN "*.h"
192+
## install dynamic libraray
193+
install(TARGETS paxformat
194+
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
195+
196+
# TODO(gongxun):
197+
# We should explicitly specify the headers
198+
# that need to be exported, and use the syntax of
199+
# install(FILES,...) to install the header files
200+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/storage
201+
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pax
202+
FILES_MATCHING
203+
PATTERN "*.h"
208204
)
209205

210206
install(FILES ${PAX_COMM_HEADERS}
211-
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pax/comm
207+
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pax/comm
212208
)
213209

214210
else()
215-
add_library(pax SHARED ${orc_proto_src} ${pax_proto_src} ${pax_storage_src} ${stats_proto_src} ${pax_exceptions_src} ${pax_access_src} ${pax_comm_src} ${pax_catalog_src} ${pax_vec_src})
216-
set_target_properties(pax PROPERTIES
217-
OUTPUT_NAME pax)
218-
target_include_directories(pax PUBLIC ${ZTSD_HEADER} ${CMAKE_CURRENT_SOURCE_DIR} ${CBDB_INCLUDE_DIR})
219-
target_link_libraries(pax PUBLIC uuid orc_protobuf zstd z postgres)
220-
add_dependencies(pax generate_protobuf)
221-
add_dependencies(pax stats_generate_protobuf)
222-
add_custom_command(TARGET pax POST_BUILD
223-
COMMAND ${CMAKE_COMMAND} -E
224-
copy_if_different $<TARGET_FILE:pax> ${CMAKE_CURRENT_SOURCE_DIR}/../data/pax.so)
211+
212+
add_library(pax SHARED ${orc_proto_src} ${pax_proto_src} ${pax_storage_src} ${stats_proto_src} ${pax_exceptions_src}
213+
${pax_access_src} ${pax_comm_src} ${pax_catalog_src} ${pax_vec_src})
214+
set_target_properties(pax PROPERTIES OUTPUT_NAME pax)
215+
target_include_directories(pax PUBLIC ${ZTSD_HEADER} ${CMAKE_CURRENT_SOURCE_DIR} ${CBDB_INCLUDE_DIR})
216+
target_link_libraries(pax PUBLIC uuid orc_protobuf zstd z postgres)
217+
add_dependencies(pax generate_protobuf)
218+
add_custom_command(TARGET pax POST_BUILD
219+
COMMAND ${CMAKE_COMMAND} -E
220+
copy_if_different $<TARGET_FILE:pax> ${CMAKE_CURRENT_SOURCE_DIR}/../data/pax.so)
225221
endif(BUILD_PAX_FORMAT)
226222

227223
# vec build
@@ -236,8 +232,10 @@ if (VEC_BUILD)
236232
${CBDB_ROOT_INCLUDE_DIR} # for arrow-glib/arrow-glib.h and otehr arrow interface
237233
${GLIB_INCLUDE_DIRS} # for glib-object.h
238234
)
239-
if(BUILD_GTEST)
240-
target_include_directories(test_main PRIVATE ${VEC_HEADER} ${CBDB_ROOT_INCLUDE_DIR} ${GLIB_INCLUDE_DIRS})
241-
endif(BUILD_GTEST)
235+
236+
if(BUILD_GTEST)
237+
target_include_directories(test_main PRIVATE ${VEC_HEADER} ${CBDB_ROOT_INCLUDE_DIR} ${GLIB_INCLUDE_DIRS})
238+
endif(BUILD_GTEST)
239+
242240
target_link_libraries(pax PRIVATE arrow)
243241
endif(VEC_BUILD)

0 commit comments

Comments
 (0)