Skip to content

Commit 4b002a4

Browse files
authored
[BugFix] Hide the interface of dependencies of GraphAr with PRIVATE link type (#71)
1 parent d61ba9d commit 4b002a4

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: |
5454
mkdir build
5555
pushd build
56-
cmake .. -DBUILD_TESTS=ON
56+
cmake .. -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
5757
popd
5858
5959
- name: Cpp Format and lint

CMakeLists.txt

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ endmacro()
143143
# ------------------------------------------------------------------------------
144144
find_package(Threads REQUIRED)
145145
find_yaml_cpp()
146+
find_package(OpenSSL QUIET)
147+
if(OPENSSL_FOUND)
148+
if(OPENSSL_VERSION LESS "1.1.0")
149+
message(ERROR "The OpenSSL must be greater than or equal to 1.1.0, current version is ${OPENSSL_VERSION}")
150+
endif()
151+
endif()
146152

147153
include(apache-arrow)
148154
build_arrow()
@@ -165,28 +171,23 @@ macro(build_gar)
165171
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
166172
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/yaml-cpp/include>
167173
)
168-
target_link_libraries(gar Threads::Threads ${CMAKE_DL_LIBS})
174+
target_link_libraries(gar PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
169175
if(APPLE)
170-
target_link_libraries(gar -Wl,-force_load arrow_static
176+
target_link_libraries(gar PRIVATE -Wl,-force_load arrow_static
171177
"${PROJECT_BINARY_DIR}/thirdparty/yaml-cpp/libyaml-cpp.a"
172178
"${PARQUET_STATIC_LIB}"
173179
"${ARROW_BUNDLED_DEPS_STATIC_LIB}")
174180
else()
175-
target_link_libraries(gar -Wl,--exclude-libs,ALL -Wl,--whole-archive arrow_static
181+
target_link_libraries(gar PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive arrow_static
176182
"${PROJECT_BINARY_DIR}/thirdparty/yaml-cpp/libyaml-cpp.a"
177183
"${PARQUET_STATIC_LIB}"
178184
"${ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive)
179185
endif()
180186

181187
# if OpenSSL library exists, link the OpenSSL library.
182188
# OpenSSL has to be linked after ARROW_BUNDLED_DEPS_STATIC_LIB
183-
find_package(OpenSSL QUIET)
184189
if(OPENSSL_FOUND)
185-
message(STATUS "OpenSSL found with ${OPENSSL_VERSION} version")
186-
if(OPENSSL_VERSION LESS "1.1.0")
187-
message(ERROR "The OpenSSL must be greater than or equal to 1.1.0")
188-
endif()
189-
target_link_libraries(gar OpenSSL::SSL)
190+
target_link_libraries(gar PRIVATE OpenSSL::SSL)
190191
endif()
191192
endmacro()
192193

@@ -206,7 +207,22 @@ if (BUILD_EXAMPLES)
206207
add_executable(${E_NAME} examples/${E_NAME}.cc)
207208
target_include_directories(${E_NAME} PRIVATE examples ${PROJECT_SOURCE_DIR}/include $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Catch2/single_include>)
208209
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
209-
target_link_libraries(${E_NAME} PRIVATE gar ${Boost_LIBRARIES})
210+
target_link_libraries(${E_NAME} PRIVATE gar ${Boost_LIBRARIES} Threads::Threads ${CMAKE_DL_LIBS})
211+
if(APPLE)
212+
target_link_libraries(${E_NAME} PRIVATE -Wl,-force_load arrow_static
213+
"${PARQUET_STATIC_LIB}"
214+
"${ARROW_BUNDLED_DEPS_STATIC_LIB}")
215+
else()
216+
target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive arrow_static
217+
"${PARQUET_STATIC_LIB}"
218+
"${ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive)
219+
endif()
220+
221+
# if OpenSSL library exists, link the OpenSSL library.
222+
# OpenSSL has to be linked after ARROW_BUNDLED_DEPS_STATIC_LIB
223+
if(OPENSSL_FOUND)
224+
target_link_libraries(${E_NAME} PRIVATE OpenSSL::SSL)
225+
endif()
210226
endforeach()
211227
endif()
212228

@@ -248,8 +264,6 @@ install(EXPORT gar-targets
248264
# ------------------------------------------------------------------------------
249265
if (BUILD_TESTS)
250266
find_catch2()
251-
add_compile_options(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
252-
find_package(Boost REQUIRED COMPONENTS graph)
253267

254268
macro(add_test target)
255269
set(options)
@@ -258,12 +272,27 @@ if (BUILD_TESTS)
258272
cmake_parse_arguments(add_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
259273
add_executable(${target} ${add_test_SRCS})
260274
target_compile_features(${target} PRIVATE cxx_std_17)
261-
target_link_libraries(${target} PRIVATE Catch2::Catch2 gar ${Boost_LIBRARIES})
275+
target_link_libraries(${target} PRIVATE Catch2::Catch2 gar Threads::Threads ${CMAKE_DL_LIBS})
276+
if(APPLE)
277+
target_link_libraries(${target} PRIVATE -Wl,-force_load arrow_static
278+
"${PARQUET_STATIC_LIB}"
279+
"${ARROW_BUNDLED_DEPS_STATIC_LIB}")
280+
else()
281+
target_link_libraries(${target} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive arrow_static
282+
"${PARQUET_STATIC_LIB}"
283+
"${ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive)
284+
endif()
262285
target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR}/include $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Catch2/single_include>)
263286
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
264287
include(CTest)
265288
include(Catch)
266289
catch_discover_tests(${target})
290+
291+
# if OpenSSL library exists, link the OpenSSL library.
292+
# OpenSSL has to be linked after ARROW_BUNDLED_DEPS_STATIC_LIB
293+
if(OPENSSL_FOUND)
294+
target_link_libraries(${target} PRIVATE OpenSSL::SSL)
295+
endif()
267296
endmacro()
268297

269298
add_test(test_info SRCS test/test_info.cc)

examples/construct_info_example.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
*/
1515

16+
#include <cassert>
17+
1618
#include "gar/graph_info.h"
1719

1820

@@ -24,10 +26,8 @@ int main(int argc, char* argv[]) {
2426
// validate
2527
assert(graph_info.GetName() == name);
2628
assert(graph_info.GetPrefix() == prefix);
27-
const auto& vertex_infos = graph_info.GetVertexInfos();
28-
const auto& edge_infos = graph_info.GetEdgeInfos();
29-
assert(vertex_infos.size() == 0);
30-
assert(edge_infos.size() == 0);
29+
assert(graph_info.GetVertexInfos().size() == 0);
30+
assert(graph_info.GetEdgeInfos().size() == 0);
3131

3232
/*------------------construct vertex info------------------*/
3333
std::string vertex_label = "person", vertex_prefix = "vertex/person/";

include/gar/utils/file_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ limitations under the License.
1414
*/
1515

1616
#include <map>
17+
#include <stdexcept>
1718
#include <string>
1819

1920
#include "gar/utils/macros.h"

0 commit comments

Comments
 (0)