From ad4365cbd44c9c483c9c8164083e457869f067fd Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 22 Dec 2025 10:52:40 +0800 Subject: [PATCH 01/30] build static --- cpp/CMakeLists.txt | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index be080cd8a..5dea6817b 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -104,10 +104,18 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") +# [Modified]: Modern RPATH handling +# This ensures that when linking dynamically against system libs, the RPATH is correctly set. +# Also handles the $ORIGIN requirement for relocatable builds. +set(CMAKE_MACOSX_RPATH ON) +set(CMAKE_SKIP_BUILD_RPATH OFF) +set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + if (APPLE) - set(CMAKE_MACOSX_RPATH ON) + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") else () - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ORIGIN") + set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") endif () set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fno-omit-frame-pointer -fsanitize=address") @@ -212,7 +220,7 @@ function(graphar_create_merged_static_lib output_target) if(APPLE) set(BUNDLE_COMMAND "libtool" "-no_warning_for_no_symbols" "-static" "-o" - ${output_lib_path} ${all_library_paths}) + ${output_lib_path} ${all_library_paths}) elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel)$") set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar) @@ -245,7 +253,7 @@ function(graphar_create_merged_static_lib output_target) endif() endif() set(BUNDLE_COMMAND ${BUNDLE_TOOL} /NOLOGO /OUT:${output_lib_path} - ${all_library_paths}) + ${all_library_paths}) else() message(FATAL_ERROR "Unknown bundle scenario!") endif() @@ -277,31 +285,38 @@ macro(build_graphar) target_include_directories(graphar PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty) target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS}) + # [Modified]: Logic separated for Static vs Dynamic Arrow if(APPLE) if(USE_STATIC_ARROW) + # Static linking with force load to keep symbols target_link_libraries(graphar PRIVATE -Wl,-force_load Arrow::arrow_static Parquet::parquet_static ArrowDataset::arrow_dataset_static ArrowAcero::arrow_acero_static) else() - target_link_libraries(graphar PRIVATE -Wl,-force_load Arrow::arrow_shared + # Dynamic linking: Standard link, RPATH handled globally + target_link_libraries(graphar PRIVATE + Arrow::arrow_shared Parquet::parquet_shared ArrowDataset::arrow_dataset_shared ArrowAcero::arrow_acero_shared) endif() else() if(USE_STATIC_ARROW) + # Static linking with whole-archive target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive Arrow::arrow_static Parquet::parquet_static ArrowDataset::arrow_dataset_static ArrowAcero::arrow_acero_static -Wl,--no-whole-archive) else() - target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive Arrow::arrow_shared + # Dynamic linking: Standard link, no whole-archive needed + target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL + Arrow::arrow_shared Parquet::parquet_shared ArrowDataset::arrow_dataset_shared - ArrowAcero::arrow_acero_shared -Wl,--no-whole-archive) + ArrowAcero::arrow_acero_shared) endif() endif() endmacro() @@ -444,7 +459,7 @@ if (BUILD_EXAMPLES) else() target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive ${GAR_ARROW_STATIC_LIB} "${GAR_PARQUET_STATIC_LIB}" - "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive) + "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive) endif() else() if(APPLE) @@ -453,15 +468,17 @@ if (BUILD_EXAMPLES) Arrow::arrow_static Parquet::parquet_static) else() + # Dynamic Linking: No force_load target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared Parquet::parquet_shared) endif() else() if(USE_STATIC_ARROW) - target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive - Arrow::arrow_static + target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive + Arrow::arrow_static Parquet::parquet_static -Wl,--no-whole-archive) else() + # Dynamic Linking: No whole-archive target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared Parquet::parquet_shared) endif() @@ -527,15 +544,16 @@ if (BUILD_TESTS) else() target_link_libraries(${target} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive gar_arrow_static "${GAR_PARQUET_STATIC_LIB}" - "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive) + "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive) endif() else() if(APPLE) if(USE_STATIC_ARROW) - target_link_libraries(${target} PRIVATE -Wl,-force_load + target_link_libraries(${target} PRIVATE -Wl,-force_load Arrow::arrow_static Parquet::parquet_static) else() + # Dynamic Linking: No force_load target_link_libraries(${target} PRIVATE Arrow::arrow_shared Parquet::parquet_shared) endif() @@ -545,6 +563,7 @@ if (BUILD_TESTS) Arrow::arrow_static Parquet::parquet_static -Wl,--no-whole-archive) else() + # Dynamic Linking: No whole-archive target_link_libraries(${target} PRIVATE Arrow::arrow_shared Parquet::parquet_shared) endif() From 1a9d17d05152ed95c72a5726eeed95f1ba12dd6d Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 29 Dec 2025 14:38:01 +0800 Subject: [PATCH 02/30] try to improve cmakelist --- cpp/CMakeLists.txt | 705 +++++++++++++++++---------------------------- 1 file changed, 260 insertions(+), 445 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 5dea6817b..9c1e7a06b 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -15,22 +15,22 @@ # specific language governing permissions and limitations # under the License. -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.10) -# Avoid mixing plain and keyword signature of target_link_libraries +# Policies if (POLICY CMP0023) cmake_policy(SET CMP0023 NEW) endif() - if(POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif() - -# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() +# ------------------------------------------------------------------------------ +# Project Info +# ------------------------------------------------------------------------------ set(GRAPHAR_MAJOR_VERSION 0) set(GRAPHAR_MINOR_VERSION 13) set(GRAPHAR_PATCH_VERSION 0) @@ -38,9 +38,8 @@ set(GRAPHAR_VERSION ${GRAPHAR_MAJOR_VERSION}.${GRAPHAR_MINOR_VERSION}.${GRAPHAR_ project(graphar-cpp LANGUAGES C CXX VERSION ${GRAPHAR_VERSION}) # ------------------------------------------------------------------------------ -# cmake options +# Options # ------------------------------------------------------------------------------ - option(BUILD_TESTS "Build unit tests" OFF) option(BUILD_EXAMPLES "Build examples" OFF) option(BUILD_BENCHMARKS "Build benchmarks" OFF) @@ -50,142 +49,127 @@ option(USE_STATIC_ARROW "Link arrow static library" OFF) option(GRAPHAR_BUILD_STATIC "Build GraphAr as static libraries" OFF) option(BUILD_ARROW_FROM_SOURCE "Build Arrow from source" OFF) -if (USE_STATIC_ARROW) +# Consistency Logic +if (USE_STATIC_ARROW OR BUILD_ARROW_FROM_SOURCE) set(GRAPHAR_BUILD_STATIC ON) endif() -if (ENABLE_DOCS OR BUILD_DOCS_ONLY) - set(PROJECT_DOCUMENT_SOURCE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/README.md) - string(REPLACE ";" " " PROJECT_DOCUMENT_SOURCE "${PROJECT_DOCUMENT_SOURCE}") - file(DOWNLOAD https://cdn.jsdelivr.net/gh/jothepro/doxygen-awesome-css@2.2.1/doxygen-awesome.min.css ${CMAKE_BINARY_DIR}/doxygen-awesome.css) - find_package(Doxygen REQUIRED) - set(DOXYGEN_IN ${PROJECT_SOURCE_DIR}/Doxyfile) - set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile.out) - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - # Copy disclaimer_footer.html to the build directory - configure_file(${PROJECT_SOURCE_DIR}/disclaimer_footer.html ${CMAKE_BINARY_DIR}/disclaimer_footer.html COPYONLY) - add_custom_target(docs - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM) - - if (BUILD_DOCS_ONLY) - return() - endif() -endif() - # ------------------------------------------------------------------------------ -# setting default cmake type to Release +# Build Type & RPATH Configuration # ------------------------------------------------------------------------------ set(DEFAULT_BUILD_TYPE "Release") if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") - set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE - STRING "Choose the type of build." FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif () -if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")) - find_program(ccache_EXECUTABLE ccache) - if(ccache_EXECUTABLE) - set(CMAKE_C_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) - set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) - add_custom_target(graphar-ccache-stats - COMMAND ${ccache_EXECUTABLE} --show-stats - ) - else() - add_custom_target(graphar-ccache-stats - COMMAND echo "ccache not found." - ) - endif(ccache_EXECUTABLE) -endif() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") - -# [Modified]: Modern RPATH handling -# This ensures that when linking dynamically against system libs, the RPATH is correctly set. -# Also handles the $ORIGIN requirement for relocatable builds. -set(CMAKE_MACOSX_RPATH ON) +# RPATH handling (relocatable install) set(CMAKE_SKIP_BUILD_RPATH OFF) set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) if (APPLE) - set(CMAKE_INSTALL_RPATH "@loader_path/../lib") + set(CMAKE_MACOSX_RPATH ON) + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") else () - set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") + set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") endif () +# Compiler Flags +if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")) + find_program(ccache_EXECUTABLE ccache) + if(ccache_EXECUTABLE) + set(CMAKE_C_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) + endif() +endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fno-omit-frame-pointer -fsanitize=address") set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g") -message(STATUS "[graphar] will build in type: ${CMAKE_BUILD_TYPE}") +message(STATUS "[graphar] Build Type: ${CMAKE_BUILD_TYPE}") +message(STATUS "[graphar] Build Static: ${GRAPHAR_BUILD_STATIC}") +message(STATUS "[graphar] Build Arrow from Source: ${BUILD_ARROW_FROM_SOURCE}") # ------------------------------------------------------------------------------ -# cmake configs +# Dependencies & Configuration # ------------------------------------------------------------------------------ include(CheckLibraryExists) include(GNUInstallDirs) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_library(${PROJECT_NAME} INTERFACE) -target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) -target_include_directories( - ${PROJECT_NAME} - INTERFACE - $ + +# Define Interface Library for properties +# FIX 1: Added ${PROJECT_SOURCE_DIR}/src to BUILD_INTERFACE +add_library(${PROJECT_NAME}_interface INTERFACE) +target_compile_features(${PROJECT_NAME}_interface INTERFACE cxx_std_17) +target_include_directories(${PROJECT_NAME}_interface INTERFACE + $ + $ + $ $ ) - # ------------------------------------------------------------------------------ -# macro functions +# Utility Macros & Functions # ------------------------------------------------------------------------------ -macro(add_subdirectory_shared directory) - set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") - set(BUILD_SHARED_LIBS ON) - set(CMAKE_BUILD_TYPE_SAVED "${CMAKE_BUILD_TYPE}") - set(CMAKE_BUILD_TYPE Release) - add_subdirectory(${directory} ${ARGN}) - set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") - set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_SAVED}") -endmacro() -macro(add_subdirectory_static directory) - set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") - set(BUILD_SHARED_LIBS OFF) - set(CMAKE_BUILD_TYPE_SAVED "${CMAKE_BUILD_TYPE}") - set(CMAKE_BUILD_TYPE Release) - add_subdirectory(${directory} ${ARGN}) - set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}") - set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_SAVED}") -endmacro() +# Helper to Link Arrow/Parquet Correctly +function(target_link_arrow_dependencies _TARGET _VISIBILITY) + if(BUILD_ARROW_FROM_SOURCE) + # CASE 1: Build from Source -> MUST be Static Linkage + target_include_directories(${_TARGET} SYSTEM BEFORE PRIVATE ${GAR_ARROW_INCLUDE_DIR}) + + set(_DEPS + ${GAR_ARROW_STATIC_LIB} + "${GAR_PARQUET_STATIC_LIB}" + "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" + ) -macro(find_yaml_cpp) - set(MESSAGE_QUIET ON) - set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE) - set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "" FORCE) - add_subdirectory_static(thirdparty/yaml-cpp EXCLUDE_FROM_ALL) - unset(MESSAGE_QUIET) - set(CMAKE_WARN_DEPRECATED ON CACHE BOOL "" FORCE) -endmacro() + if(APPLE) + target_link_libraries(${_TARGET} ${_VISIBILITY} -Wl,-force_load ${_DEPS}) + else() + target_link_libraries(${_TARGET} ${_VISIBILITY} + -Wl,--exclude-libs,ALL -Wl,--whole-archive ${_DEPS} -Wl,--no-whole-archive) + endif() -macro(install_graphar_target target) - # install - install(TARGETS ${target} - EXPORT graphar-targets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) -endmacro() + elseif(USE_STATIC_ARROW) + # CASE 2: System Install -> Static Linkage requested + set(_DEPS + Arrow::arrow_static + Parquet::parquet_static + ArrowDataset::arrow_dataset_static + ) + if(TARGET ArrowAcero::arrow_acero_static) + list(APPEND _DEPS ArrowAcero::arrow_acero_static) + endif() -# Implementations of lisp "car" and "cdr" functions + if(APPLE) + target_link_libraries(${_TARGET} ${_VISIBILITY} -Wl,-force_load ${_DEPS}) + else() + target_link_libraries(${_TARGET} ${_VISIBILITY} + -Wl,--exclude-libs,ALL -Wl,--whole-archive ${_DEPS} -Wl,--no-whole-archive) + endif() + + else() + # CASE 3: System Install -> Dynamic Linkage + set(_DEPS + Arrow::arrow_shared + Parquet::parquet_shared + ArrowDataset::arrow_dataset_shared + ) + if(TARGET ArrowAcero::arrow_acero_shared) + list(APPEND _DEPS ArrowAcero::arrow_acero_shared) + endif() + + target_link_libraries(${_TARGET} ${_VISIBILITY} ${_DEPS}) + endif() +endfunction() + +# Macros for List Processing macro(GRAPHAR_CAR var) set(${var} ${ARGV1}) endmacro() @@ -194,25 +178,14 @@ macro(GRAPHAR_CDR var rest) set(${var} ${ARGN}) endmacro() -# Based on MIT-licensed -# https://gist.github.com/cristianadam/ef920342939a89fae3e8a85ca9459b49 +# Function to merge static libraries (for bundling) function(graphar_create_merged_static_lib output_target) set(options) set(one_value_args NAME ROOT) set(multi_value_args TO_MERGE) - cmake_parse_arguments(ARG - "${options}" - "${one_value_args}" - "${multi_value_args}" - ${ARGN}) - if(ARG_UNPARSED_ARGUMENTS) - message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}") - endif() - - set(output_lib_path - ${BUILD_OUTPUT_ROOT_DIRECTORY}${CMAKE_STATIC_LIBRARY_PREFIX}${ARG_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} - ) - + cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) + + set(output_lib_path ${BUILD_OUTPUT_ROOT_DIRECTORY}${CMAKE_STATIC_LIBRARY_PREFIX}${ARG_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) set(all_library_paths $) foreach(lib ${ARG_TO_MERGE}) list(APPEND all_library_paths $) @@ -220,409 +193,251 @@ function(graphar_create_merged_static_lib output_target) if(APPLE) set(BUNDLE_COMMAND "libtool" "-no_warning_for_no_symbols" "-static" "-o" - ${output_lib_path} ${all_library_paths}) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel)$") - set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar) + ${output_lib_path} ${all_library_paths}) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel)$") + set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar) - file(WRITE ${ar_script_path}.in "CREATE ${output_lib_path}\n") - file(APPEND ${ar_script_path}.in "ADDLIB $\n") + file(WRITE ${ar_script_path}.in "CREATE ${output_lib_path}\n") + file(APPEND ${ar_script_path}.in "ADDLIB $\n") - foreach(lib ${ARG_TO_MERGE}) - file(APPEND ${ar_script_path}.in "ADDLIB $\n") - endforeach() + foreach(lib ${ARG_TO_MERGE}) + file(APPEND ${ar_script_path}.in "ADDLIB $\n") + endforeach() - file(APPEND ${ar_script_path}.in "SAVE\nEND\n") - file(GENERATE - OUTPUT ${ar_script_path} - INPUT ${ar_script_path}.in) - set(ar_tool ${CMAKE_AR}) + file(APPEND ${ar_script_path}.in "SAVE\nEND\n") + file(GENERATE + OUTPUT ${ar_script_path} + INPUT ${ar_script_path}.in) - if(CMAKE_INTERPROCEDURAL_OPTIMIZATION) - set(ar_tool ${CMAKE_CXX_COMPILER_AR}) - endif() - - set(BUNDLE_COMMAND ${ar_tool} -M < ${ar_script_path}) + set(ar_tool ${CMAKE_AR}) + if(CMAKE_INTERPROCEDURAL_OPTIMIZATION) + set(ar_tool ${CMAKE_CXX_COMPILER_AR}) + endif() + set(BUNDLE_COMMAND ${ar_tool} -M < ${ar_script_path}) elseif(MSVC) if(CMAKE_LIBTOOL) set(BUNDLE_TOOL ${CMAKE_LIBTOOL}) else() find_program(BUNDLE_TOOL lib HINTS "${CMAKE_CXX_COMPILER}/..") - if(NOT BUNDLE_TOOL) - message(FATAL_ERROR "Cannot locate lib.exe to bundle libraries") - endif() endif() - set(BUNDLE_COMMAND ${BUNDLE_TOOL} /NOLOGO /OUT:${output_lib_path} - ${all_library_paths}) + set(BUNDLE_COMMAND ${BUNDLE_TOOL} /NOLOGO /OUT:${output_lib_path} ${all_library_paths}) else() - message(FATAL_ERROR "Unknown bundle scenario!") + # Linux/Unix AR Script + set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar) + file(WRITE ${ar_script_path}.in "CREATE ${output_lib_path}\n") + file(APPEND ${ar_script_path}.in "ADDLIB $\n") + foreach(lib ${ARG_TO_MERGE}) + file(APPEND ${ar_script_path}.in "ADDLIB $\n") + endforeach() + file(APPEND ${ar_script_path}.in "SAVE\nEND\n") + file(GENERATE OUTPUT ${ar_script_path} INPUT ${ar_script_path}.in) + + set(ar_tool ${CMAKE_AR}) + if(CMAKE_INTERPROCEDURAL_OPTIMIZATION) + set(ar_tool ${CMAKE_CXX_COMPILER_AR}) + endif() + set(BUNDLE_COMMAND ${ar_tool} -M < ${ar_script_path}) endif() add_custom_target(${output_target}_merge ALL ${BUNDLE_COMMAND} DEPENDS ${ARG_ROOT} ${ARG_TO_MERGE} BYPRODUCTS ${output_lib_path} - COMMENT "Bundling ${output_lib_path}" - VERBATIM) - - message(STATUS "Creating bundled static library target ${output_target} at ${output_lib_path}" - ) + COMMENT "Bundling ${output_lib_path}" VERBATIM) add_library(${output_target} STATIC IMPORTED) set_target_properties(${output_target} PROPERTIES IMPORTED_LOCATION ${output_lib_path}) add_dependencies(${output_target} ${output_target}_merge) endfunction() +# ------------------------------------------------------------------------------ +# Dependency Acquisition +# ------------------------------------------------------------------------------ -macro(build_graphar) - file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc" ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp) - if(GRAPHAR_BUILD_STATIC) - add_library(graphar STATIC ${CORE_SRC_FILES}) - else() - add_library(graphar SHARED ${CORE_SRC_FILES}) +if (BUILD_ARROW_FROM_SOURCE) + find_package(OpenSSL REQUIRED) + find_package(CURL REQUIRED) + include(apache-arrow) + build_arrow() + add_definitions(-DARROW_ORC) +else() + # Find System Arrow + find_package(Arrow QUIET) + if (NOT Arrow_FOUND) + message(FATAL_ERROR "apache-arrow is required. Install it or set BUILD_ARROW_FROM_SOURCE=ON") endif() - install_graphar_target(graphar) - target_compile_features(graphar PRIVATE cxx_std_17) - target_include_directories(graphar PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty) - target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS}) - - # [Modified]: Logic separated for Static vs Dynamic Arrow - if(APPLE) - if(USE_STATIC_ARROW) - # Static linking with force load to keep symbols - target_link_libraries(graphar PRIVATE -Wl,-force_load - Arrow::arrow_static - Parquet::parquet_static - ArrowDataset::arrow_dataset_static - ArrowAcero::arrow_acero_static) - else() - # Dynamic linking: Standard link, RPATH handled globally - target_link_libraries(graphar PRIVATE - Arrow::arrow_shared - Parquet::parquet_shared - ArrowDataset::arrow_dataset_shared - ArrowAcero::arrow_acero_shared) - endif() - else() - if(USE_STATIC_ARROW) - # Static linking with whole-archive - target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive - Arrow::arrow_static - Parquet::parquet_static - ArrowDataset::arrow_dataset_static - ArrowAcero::arrow_acero_static -Wl,--no-whole-archive) - else() - # Dynamic linking: Standard link, no whole-archive needed - target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL - Arrow::arrow_shared - Parquet::parquet_shared - ArrowDataset::arrow_dataset_shared - ArrowAcero::arrow_acero_shared) - endif() + find_package(ArrowDataset QUIET REQUIRED) + find_package(Parquet QUIET REQUIRED) + + if (${Arrow_VERSION} VERSION_GREATER_EQUAL "12.0.0") + find_package(ArrowAcero QUIET REQUIRED) endif() -endmacro() -macro(build_graphar_with_arrow_bundled) - file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc" ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp) - if(GRAPHAR_BUILD_STATIC) - add_library(graphar STATIC ${CORE_SRC_FILES}) - else() - add_library(graphar SHARED ${CORE_SRC_FILES}) + if (ARROW_ORC) + add_definitions(-DARROW_ORC) endif() - install_graphar_target(graphar) - target_compile_features(graphar PRIVATE cxx_std_17) - target_include_directories(graphar PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty) - target_include_directories(graphar SYSTEM BEFORE PRIVATE ${GAR_ARROW_INCLUDE_DIR}) - target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS}) - - set(GAR_BUNDLED_DEPS_STATIC_LIBS) - list(APPEND GAR_BUNDLED_DEPS_STATIC_LIBS - gar_arrow_static - gar_parquet_static - gar_dataset_static - gar_acero_static - gar_arrow_bundled_dependencies_static) - graphar_car(_FIRST_LIB ${GAR_BUNDLED_DEPS_STATIC_LIBS}) - graphar_cdr(_OTHER_LIBS ${GAR_BUNDLED_DEPS_STATIC_LIBS}) +endif() - graphar_create_merged_static_lib(graphar_bundled_dependencies - NAME - graphar_bundled_dependencies - ROOT - ${_FIRST_LIB} - TO_MERGE - ${_OTHER_LIBS}) - # We can't use install(TARGETS) here because - # graphar_bundled_dependencies is an IMPORTED library. - get_target_property(graphar_bundled_dependencies_path graphar_bundled_dependencies - IMPORTED_LOCATION) - install(FILES ${CMAKE_BINARY_DIR}/${graphar_bundled_dependencies_path} ${INSTALL_IS_OPTIONAL} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - string(APPEND ARROW_PC_LIBS_PRIVATE " -lgraphar_bundled_dependencies") - list(INSERT ARROW_STATIC_INSTALL_INTERFACE_LIBS 0 "graphar_bundled_dependencies") +# ------------------------------------------------------------------------------ +# Main Target: GraphAr +# ------------------------------------------------------------------------------ +file(GLOB_RECURSE CORE_SRC_FILES + "src/graphar/*.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp" +) +if(GRAPHAR_BUILD_STATIC) + add_library(graphar STATIC ${CORE_SRC_FILES}) +else() + add_library(graphar SHARED ${CORE_SRC_FILES}) +endif() + +# Link the interface (includes/definitions) +target_link_libraries(graphar PUBLIC ${PROJECT_NAME}_interface) +target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS}) + +# Dependency Linking Logic +if(BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC) + set(GAR_BUNDLED_DEPS_STATIC_LIBS + gar_arrow_static + gar_parquet_static + gar_dataset_static + gar_acero_static + gar_arrow_bundled_dependencies_static + ) + GRAPHAR_CAR(_FIRST_LIB ${GAR_BUNDLED_DEPS_STATIC_LIBS}) + GRAPHAR_CDR(_OTHER_LIBS ${GAR_BUNDLED_DEPS_STATIC_LIBS}) + + graphar_create_merged_static_lib(graphar_bundled_dependencies + NAME graphar_bundled_dependencies + ROOT ${_FIRST_LIB} + TO_MERGE ${_OTHER_LIBS} + ) + if(APPLE) - target_link_libraries(graphar PRIVATE -Wl,-force_load - graphar_bundled_dependencies - "-framework CoreFoundation" - "-framework Security") + target_link_libraries(graphar PRIVATE -Wl,-force_load graphar_bundled_dependencies "-framework CoreFoundation" "-framework Security") else() - target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL - graphar_bundled_dependencies) + target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL graphar_bundled_dependencies) endif() - # if OpenSSL library exists, link the OpenSSL library. - # OpenSSL has to be linked after GAR_ARROW_BUNDLED_DEPS_STATIC_LIB if(OPENSSL_FOUND) target_link_libraries(graphar PUBLIC OpenSSL::SSL) endif() - if (CURL_FOUND) + if(CURL_FOUND) target_link_libraries(graphar PUBLIC ${CURL_LIBRARIES}) endif() -endmacro() + + get_target_property(bundled_lib_path graphar_bundled_dependencies IMPORTED_LOCATION) + install(FILES ${bundled_lib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR}) +else() + target_link_arrow_dependencies(graphar PRIVATE) +endif() # ------------------------------------------------------------------------------ -# building or find third party library +# Installation # ------------------------------------------------------------------------------ -include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) -include_directories(src) +install(TARGETS graphar ${PROJECT_NAME}_interface + EXPORT graphar-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) -if (BUILD_ARROW_FROM_SOURCE) - # the necessary dependencies for building arrow from source - find_package(OpenSSL REQUIRED) - if(OPENSSL_FOUND) - if(OPENSSL_VERSION LESS "1.1.0") - message(ERROR "The OpenSSL must be greater than or equal to 1.1.0, current version is ${OPENSSL_VERSION}") - endif() - endif() - find_package(CURL REQUIRED) +# FIX 2: Correctly install from src/graphar since that's where headers are +install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/graphar + DESTINATION include + FILES_MATCHING PATTERN "*.h" +) - include(apache-arrow) - build_arrow() - add_definitions(-DARROW_ORC) # Add macro, otherwise inconsistent in build phase with not from source. - build_graphar_with_arrow_bundled() -else() - # check if arrow is installed - find_package(Arrow QUIET) - if (NOT ${Arrow_FOUND}) - message(FATAL_ERROR "apache-arrow is required, please install it and retry") - endif() - find_package(ArrowDataset QUIET) - if (NOT ${ArrowDataset_FOUND}) - message(FATAL_ERROR "apache-arrow-dataset is required, please install it and retry") - endif() - if (${Arrow_VERSION} VERSION_GREATER_EQUAL "12.0.0") - # ArrowAcero is available in Arrow 12.0.0 and later - find_package(ArrowAcero QUIET) - if (NOT ${ArrowAcero_FOUND}) - message(FATAL_ERROR "apache-arrow-acero is required, please install it and retry") - endif() - endif() - # Check if ORC is enabled. - if (NOT ${ARROW_ORC}) - message(WARNING "apache-arrow is built without ORC extension, ORC related functionalities will be disabled.") - else() - add_definitions(-DARROW_ORC) # Add macro, otherwise inconsistent in build phase on ubuntu. - endif() +install(DIRECTORY ${PROJECT_SOURCE_DIR}/thirdparty/result DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp") - find_package(Parquet QUIET) - if (NOT ${Parquet_FOUND}) - message(FATAL_ERROR "parquet is required, please install it and retry") - endif() +configure_file(graphar-config.in.cmake "${PROJECT_BINARY_DIR}/graphar-config.cmake" @ONLY) +configure_file(graphar-config-version.in.cmake "${PROJECT_BINARY_DIR}/graphar-config-version.cmake" @ONLY) - build_graphar() -endif() +install(FILES "${PROJECT_BINARY_DIR}/graphar-config.cmake" "${PROJECT_BINARY_DIR}/graphar-config-version.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/graphar) +install(EXPORT graphar-targets FILE graphar-targets.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/graphar) # ------------------------------------------------------------------------------ -# build example +# Examples & Tests # ------------------------------------------------------------------------------ if (BUILD_EXAMPLES) find_package(Boost REQUIRED COMPONENTS graph) - file(GLOB EXAMPLE_FILES RELATIVE "${PROJECT_SOURCE_DIR}/examples" "${PROJECT_SOURCE_DIR}/examples/*.cc") + foreach(f ${EXAMPLE_FILES}) string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${f}) set(E_NAME ${CMAKE_MATCH_1}) - message(STATUS "Found example - " ${E_NAME}) add_executable(${E_NAME} examples/${E_NAME}.cc) - target_include_directories(${E_NAME} PRIVATE examples - ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty - ) + target_include_directories(${E_NAME} PRIVATE examples) target_include_directories(${E_NAME} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) target_link_libraries(${E_NAME} PRIVATE graphar ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) - if (BUILD_ARROW_FROM_SOURCE) - target_include_directories(${E_NAME} SYSTEM BEFORE PRIVATE ${GAR_ARROW_INCLUDE_DIR}) - if (APPLE) - target_link_libraries(${E_NAME} PRIVATE -Wl,-force_load ${GAR_ARROW_STATIC_LIB} - "${GAR_PARQUET_STATIC_LIB}" - "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}") - else() - target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive ${GAR_ARROW_STATIC_LIB} - "${GAR_PARQUET_STATIC_LIB}" - "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive) - endif() - else() - if(APPLE) - if(USE_STATIC_ARROW) - target_link_libraries(${E_NAME} PRIVATE -Wl,-force_load - Arrow::arrow_static - Parquet::parquet_static) - else() - # Dynamic Linking: No force_load - target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared - Parquet::parquet_shared) - endif() - else() - if(USE_STATIC_ARROW) - target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive - Arrow::arrow_static - Parquet::parquet_static -Wl,--no-whole-archive) - else() - # Dynamic Linking: No whole-archive - target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared - Parquet::parquet_shared) - endif() - endif() + + # When GraphAr is static, consumers must also link Arrow/Parquet. + if(GRAPHAR_BUILD_STATIC) + target_link_arrow_dependencies(${E_NAME} PRIVATE) endif() endforeach() endif() -# ------------------------------------------------------------------------------ -# Install -# ------------------------------------------------------------------------------ -install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/graphar - DESTINATION include - FILES_MATCHING - PATTERN "*.h" -) - -install(DIRECTORY ${PROJECT_SOURCE_DIR}/thirdparty/result - DESTINATION include - FILES_MATCHING - PATTERN "*.hpp" -) - -configure_file(graphar-config.in.cmake - "${PROJECT_BINARY_DIR}/graphar-config.cmake" @ONLY -) - -configure_file(graphar-config-version.in.cmake - "${PROJECT_BINARY_DIR}/graphar-config-version.cmake" @ONLY -) - -install(FILES "${PROJECT_BINARY_DIR}/graphar-config.cmake" - "${PROJECT_BINARY_DIR}/graphar-config-version.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/graphar -) - -install(EXPORT graphar-targets - FILE graphar-targets.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/graphar -) - -# ------------------------------------------------------------------------------ -# Test targets -# ------------------------------------------------------------------------------ if (BUILD_TESTS) find_package(Catch2 3 REQUIRED) - - macro(add_test target) - set(options) - set(oneValueArgs) - set(multiValueArgs SRCS) - cmake_parse_arguments(add_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - add_executable(${target} ${add_test_SRCS}) + include(CTest) + include(Catch) + macro(add_graphar_test target src_file) + add_executable(${target} ${src_file}) target_compile_features(${target} PRIVATE cxx_std_17) target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR}/thirdparty) target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain graphar ${CMAKE_DL_LIBS}) - if (BUILD_ARROW_FROM_SOURCE) - target_include_directories(${target} SYSTEM BEFORE PRIVATE ${GAR_ARROW_INCLUDE_DIR}) - if (APPLE) - target_link_libraries(${target} PRIVATE -Wl,-force_load gar_arrow_static - "${GAR_PARQUET_STATIC_LIB}" - "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}") - else() - target_link_libraries(${target} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive gar_arrow_static - "${GAR_PARQUET_STATIC_LIB}" - "${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive) - endif() - else() - if(APPLE) - if(USE_STATIC_ARROW) - target_link_libraries(${target} PRIVATE -Wl,-force_load - Arrow::arrow_static - Parquet::parquet_static) - else() - # Dynamic Linking: No force_load - target_link_libraries(${target} PRIVATE Arrow::arrow_shared - Parquet::parquet_shared) - endif() - else() - if(USE_STATIC_ARROW) - target_link_libraries(${target} PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive - Arrow::arrow_static - Parquet::parquet_static -Wl,--no-whole-archive) - else() - # Dynamic Linking: No whole-archive - target_link_libraries(${target} PRIVATE Arrow::arrow_shared - Parquet::parquet_shared) - endif() - endif() + + # When GraphAr is static, consumers must also link Arrow/Parquet. + if(GRAPHAR_BUILD_STATIC) + target_link_arrow_dependencies(${target} PRIVATE) endif() - target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR}/include $) - include(CTest) - include(Catch) catch_discover_tests(${target}) endmacro() - add_test(test_info SRCS test/test_info.cc) - add_test(test_arrow_chunk_writer SRCS test/test_arrow_chunk_writer.cc) - add_test(test_builder SRCS test/test_builder.cc) - add_test(test_chunk_info_reader SRCS test/test_chunk_info_reader.cc) - add_test(test_arrow_chunk_reader SRCS test/test_arrow_chunk_reader.cc) - add_test(test_graph SRCS test/test_graph.cc) - add_test(test_multi_label SRCS test/test_multi_label.cc) - add_test(test_multi_property SRCS test/test_multi_property.cc) - - # enable_testing() + add_graphar_test(test_info test/test_info.cc) + add_graphar_test(test_arrow_chunk_writer test/test_arrow_chunk_writer.cc) + add_graphar_test(test_builder test/test_builder.cc) + add_graphar_test(test_chunk_info_reader test/test_chunk_info_reader.cc) + add_graphar_test(test_arrow_chunk_reader test/test_arrow_chunk_reader.cc) + add_graphar_test(test_graph test/test_graph.cc) + add_graphar_test(test_multi_label test/test_multi_label.cc) + add_graphar_test(test_multi_property test/test_multi_property.cc) endif() if (BUILD_BENCHMARKS) find_package(benchmark REQUIRED) - - macro(add_benchmark target) - set(options) - set(oneValueArgs) - set(multiValueArgs SRCS) - cmake_parse_arguments(add_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - add_executable(${target} ${add_test_SRCS}) - target_compile_features(${target} PRIVATE cxx_std_17) - target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR}/thirdparty) - target_link_libraries(${target} PRIVATE benchmark::benchmark_main graphar ${CMAKE_DL_LIBS}) + macro(add_benchmark target src_file) + add_executable(${target} ${src_file}) + target_link_libraries(${target} PRIVATE benchmark::benchmark_main graphar) endmacro() - add_benchmark(arrow_chunk_reader_benchmark SRCS benchmarks/arrow_chunk_reader_benchmark.cc) - add_benchmark(label_filter_benchmark SRCS benchmarks/label_filter_benchmark.cc) - add_benchmark(graph_info_benchmark SRCS benchmarks/graph_info_benchmark.cc) + add_benchmark(arrow_chunk_reader_benchmark benchmarks/arrow_chunk_reader_benchmark.cc) + add_benchmark(label_filter_benchmark benchmarks/label_filter_benchmark.cc) + add_benchmark(graph_info_benchmark benchmarks/graph_info_benchmark.cc) endif() # ------------------------------------------------------------------------------ -# Format code & cpplint +# Documentation & Formatting # ------------------------------------------------------------------------------ -file(GLOB_RECURSE FILES_NEED_FORMAT "src/graphar/*.h" "src/graphar/*.cc" - "test/*.h" "test/*.cc" - "examples/*.h" "examples/*.cc" - "benchmarks/*.h" "benchmarks/*.cc") -file(GLOB_RECURSE FILES_NEED_LINT "src/graphar/*.h" "src/graphar/*.cc" - "test/*.h" "test/*.cc" - "examples/*.h" "examples/*.cc" - "benchmarks/*.h" "benchmarks/*.cc") - -add_custom_target(graphar-clformat - COMMAND clang-format --style=file -i ${FILES_NEED_FORMAT} - COMMENT "Running clang-format." - VERBATIM) - -add_custom_target(graphar-cpplint - COMMAND ${PROJECT_SOURCE_DIR}/misc/cpplint.py --root=${PROJECT_SOURCE_DIR}/include ${FILES_NEED_LINT} - COMMENT "Running cpplint check." - VERBATIM) \ No newline at end of file +if (ENABLE_DOCS OR BUILD_DOCS_ONLY) + set(PROJECT_DOCUMENT_SOURCE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/README.md) + string(REPLACE ";" " " PROJECT_DOCUMENT_SOURCE "${PROJECT_DOCUMENT_SOURCE}") + file(DOWNLOAD https://cdn.jsdelivr.net/gh/jothepro/doxygen-awesome-css@2.2.1/doxygen-awesome.min.css ${CMAKE_BINARY_DIR}/doxygen-awesome.css) + find_package(Doxygen REQUIRED) + set(DOXYGEN_IN ${PROJECT_SOURCE_DIR}/Doxyfile) + set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile.out) + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + configure_file(${PROJECT_SOURCE_DIR}/disclaimer_footer.html ${CMAKE_BINARY_DIR}/disclaimer_footer.html COPYONLY) + add_custom_target(docs COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} VERBATIM) + if (BUILD_DOCS_ONLY) + return() + endif() +endif() + +file(GLOB_RECURSE FILES_NEED_FORMAT "src/graphar/*.h" "src/graphar/*.cc" "test/*.h" "test/*.cc" "examples/*.h" "examples/*.cc" "benchmarks/*.h" "benchmarks/*.cc") +add_custom_target(graphar-clformat COMMAND clang-format --style=file -i ${FILES_NEED_FORMAT} VERBATIM) +add_custom_target(graphar-cpplint COMMAND ${PROJECT_SOURCE_DIR}/misc/cpplint.py --root=${PROJECT_SOURCE_DIR}/include ${FILES_NEED_FORMAT} VERBATIM) \ No newline at end of file From 8c9152717661b9452faa65f03d1dcb7d8e4dd190 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 14:36:00 +0800 Subject: [PATCH 03/30] test build from arrow source --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 222ca3662..5f4d7d611 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -270,6 +270,17 @@ jobs: ctest --output-on-failure popd + - name: Build with Arrow from Source + working-directory: "cpp" + run: | + mkdir build-bundled + pushd build-bundled + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON + make -j$(nproc) + export ASAN_OPTIONS=detect_leaks=0 + ctest --output-on-failure + popd + - name: Upload libgraphar.a artifact if: github.event_name == 'push' uses: actions/upload-artifact@v4 From 6cef3b18c1bed62344d5880ebe7da5239738ee8e Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 14:41:50 +0800 Subject: [PATCH 04/30] Asynchronous build --- .github/workflows/ci.yml | 152 +++++++++++++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f4d7d611..bb52a5d97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ on: # but only for the main branch push: branches: - - main + - "**" paths: - 'cpp/**' - '.github/workflows/ci.yml' @@ -38,9 +38,9 @@ concurrency: cancel-in-progress: true jobs: - ubuntu: + ubuntu-normal: # TODO use ubuntu-latest - name: Ubuntu 22.04 C++ + name: Ubuntu 22.04 C++ (normal + baseline) runs-on: ubuntu-22.04 if: ${{ !contains(github.event.pull_request.title, 'WIP') && !github.event.pull_request.draft }} env: @@ -188,6 +188,48 @@ jobs: ./arrow_chunk_reader_benchmark ./label_filter_benchmark + ubuntu-static: + # TODO use ubuntu-latest + name: Ubuntu 22.04 C++ (static) + runs-on: ubuntu-22.04 + if: ${{ !contains(github.event.pull_request.title, 'WIP') && !github.event.pull_request.draft }} + env: + GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Install dependencies + run: | + + # install the latest arrow deb to test arrow + wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \ + -P /tmp/ + sudo apt-get install -y /tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb + sudo apt-get update -y + sudo apt install -y libarrow-dev=17.0.0-1 \ + libarrow-dataset-dev=17.0.0-1 \ + libarrow-acero-dev=17.0.0-1 \ + libparquet-dev=17.0.0-1 + sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev + + # install benchmark + git clone --branch v1.8.3 https://github.com/google/benchmark.git --depth 1 + pushd benchmark + cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_TESTING=OFF -DBENCHMARK_ENABLE_GTEST_TESTS=OFF . + sudo make install + popd + + # install Catch2 v3 + git clone --branch v3.6.0 https://github.com/catchorg/Catch2.git --depth 1 + pushd Catch2 + cmake -Bbuild -H. -DBUILD_TESTING=OFF + sudo cmake --build build/ --target install + popd + + git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 + - name: Use Static Arrow working-directory: "cpp" run: | @@ -206,8 +248,54 @@ jobs: name: ubuntu-libgraphar.a path: cpp/build-static/libgraphar.a - macos: - name: macos latest C++ + ubuntu-arrow-source: + # TODO use ubuntu-latest + name: Ubuntu 22.04 C++ (arrow from source) + runs-on: ubuntu-22.04 + if: ${{ !contains(github.event.pull_request.title, 'WIP') && !github.event.pull_request.draft }} + env: + GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Install dependencies + run: | + + # install the latest arrow deb to test arrow + wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \ + -P /tmp/ + sudo apt-get install -y /tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb + sudo apt-get update -y + sudo apt install -y libarrow-dev=17.0.0-1 \ + libarrow-dataset-dev=17.0.0-1 \ + libarrow-acero-dev=17.0.0-1 \ + libparquet-dev=17.0.0-1 + sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev + + # install Catch2 v3 + git clone --branch v3.6.0 https://github.com/catchorg/Catch2.git --depth 1 + pushd Catch2 + cmake -Bbuild -H. -DBUILD_TESTING=OFF + sudo cmake --build build/ --target install + popd + + git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 + + - name: Build with Arrow from Source + working-directory: "cpp" + run: | + mkdir build-bundled + pushd build-bundled + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON + make -j$(nproc) + export ASAN_OPTIONS=detect_leaks=0 + ctest --output-on-failure + popd + + macos-normal: + name: macos latest C++ (normal + baseline) runs-on: macos-latest if: ${{ !contains(github.event.pull_request.title, 'WIP') && github.event.pull_request.draft == false }} env: @@ -258,6 +346,25 @@ jobs: ./arrow_chunk_reader_benchmark ./label_filter_benchmark + macos-static: + name: macos latest C++ (static) + runs-on: macos-latest + if: ${{ !contains(github.event.pull_request.title, 'WIP') && github.event.pull_request.draft == false }} + env: + GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Install dependencies + run: | + brew bundle --file=cpp/Brewfile + git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 + - name: Use Static Arrow working-directory: "cpp" run: | @@ -270,6 +377,32 @@ jobs: ctest --output-on-failure popd + - name: Upload libgraphar.a artifact + if: github.event_name == 'push' + uses: actions/upload-artifact@v4 + with: + name: macos-libgraphar.a + path: cpp/build-static/libgraphar.a + + macos-arrow-source: + name: macos latest C++ (arrow from source) + runs-on: macos-latest + if: ${{ !contains(github.event.pull_request.title, 'WIP') && github.event.pull_request.draft == false }} + env: + GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Install dependencies + run: | + brew bundle --file=cpp/Brewfile + git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 + - name: Build with Arrow from Source working-directory: "cpp" run: | @@ -279,11 +412,4 @@ jobs: make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure - popd - - - name: Upload libgraphar.a artifact - if: github.event_name == 'push' - uses: actions/upload-artifact@v4 - with: - name: macos-${{ matrix.macos-version }}-libgraphar.a - path: cpp/build-static/libgraphar.a \ No newline at end of file + popd \ No newline at end of file From d67b590b4dedf2a3432c26596ef879771d335f3a Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 14:45:08 +0800 Subject: [PATCH 05/30] update --- .github/workflows/ci.yml | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb52a5d97..3bc6166b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,35 +260,12 @@ jobs: with: submodules: true - - name: Install dependencies - run: | - - # install the latest arrow deb to test arrow - wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \ - -P /tmp/ - sudo apt-get install -y /tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb - sudo apt-get update -y - sudo apt install -y libarrow-dev=17.0.0-1 \ - libarrow-dataset-dev=17.0.0-1 \ - libarrow-acero-dev=17.0.0-1 \ - libparquet-dev=17.0.0-1 - sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev - - # install Catch2 v3 - git clone --branch v3.6.0 https://github.com/catchorg/Catch2.git --depth 1 - pushd Catch2 - cmake -Bbuild -H. -DBUILD_TESTING=OFF - sudo cmake --build build/ --target install - popd - - git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 - - name: Build with Arrow from Source working-directory: "cpp" run: | mkdir build-bundled pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure @@ -398,17 +375,12 @@ jobs: with: submodules: true - - name: Install dependencies - run: | - brew bundle --file=cpp/Brewfile - git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 - - name: Build with Arrow from Source working-directory: "cpp" run: | mkdir build-bundled pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure From edbda663de061b78672f021ebe3884d9b293349f Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 14:51:27 +0800 Subject: [PATCH 06/30] fix dependencies --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bc6166b5..f6ec3ca46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,6 +260,10 @@ jobs: with: submodules: true + - name: Install dependencies + run: | + sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev libssl-dev pkg-config doxygen lcov + - name: Build with Arrow from Source working-directory: "cpp" run: | From cc4da7a09e28815f4b8e4267f8aab0e417f41e35 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 15:07:41 +0800 Subject: [PATCH 07/30] fix link arrow --- .github/workflows/ci.yml | 12 ++++++++++-- cpp/CMakeLists.txt | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6ec3ca46..eebee3f31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -238,9 +238,13 @@ jobs: cmake .. -DUSE_STATIC_ARROW=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 - ctest --output-on-failure popd + - name: Test + working-directory: "cpp/build-static" + run: | + ctest --output-on-failure + - name: Upload libgraphar.a artifact if: github.event_name == 'push' uses: actions/upload-artifact@v4 @@ -355,9 +359,13 @@ jobs: make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_container_overflow=0 - ctest --output-on-failure popd + - name: Test + working-directory: "cpp/build-static" + run: | + ctest --output-on-failure + - name: Upload libgraphar.a artifact if: github.event_name == 'push' uses: actions/upload-artifact@v4 diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9c1e7a06b..95852b872 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -330,7 +330,11 @@ if(BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC) get_target_property(bundled_lib_path graphar_bundled_dependencies IMPORTED_LOCATION) install(FILES ${bundled_lib_path} DESTINATION ${CMAKE_INSTALL_LIBDIR}) else() - target_link_arrow_dependencies(graphar PRIVATE) + if(BUILD_ARROW_FROM_SOURCE OR USE_STATIC_ARROW) + target_link_arrow_dependencies(graphar PRIVATE) + else() + target_link_arrow_dependencies(graphar PUBLIC) + endif() endif() # ------------------------------------------------------------------------------ From 80fad16a78555c0ff829a5b04a5ab7ec41f968f0 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 15:09:49 +0800 Subject: [PATCH 08/30] upgrade arrow source version --- cpp/cmake/apache-arrow.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake/apache-arrow.cmake b/cpp/cmake/apache-arrow.cmake index ca6e63bfe..5f58f42be 100644 --- a/cpp/cmake/apache-arrow.cmake +++ b/cpp/cmake/apache-arrow.cmake @@ -111,7 +111,7 @@ function(build_arrow) if(DEFINED ENV{GAR_ARROW_SOURCE_URL}) set(GAR_ARROW_SOURCE_URL "$ENV{GAR_ARROW_SOURCE_URL}") else() - set(ARROW_VERSION_TO_BUILD "15.0.0" CACHE INTERNAL "arrow version") + set(ARROW_VERSION_TO_BUILD "17.0.0" CACHE INTERNAL "arrow version") if (Arrow_FOUND) # arrow is installed, build the same version as the installed one set(ARROW_VERSION_TO_BUILD "${Arrow_VERSION}" CACHE INTERNAL "arrow version") endif() From b00e305acfe560f085c83c657afba3b5aef34596 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 15:34:16 +0800 Subject: [PATCH 09/30] try to fix build from source --- cpp/CMakeLists.txt | 9 +++++++++ cpp/cmake/apache-arrow.cmake | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 95852b872..bed82be8f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -296,6 +296,15 @@ endif() target_link_libraries(graphar PUBLIC ${PROJECT_NAME}_interface) target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS}) +# When building Arrow/Parquet from source, GraphAr's sources (and often its public +# headers) include Arrow/Parquet headers. Ensure the build tree can find them. +# Use BUILD_INTERFACE so we don't leak the build directory into installed targets. +if(BUILD_ARROW_FROM_SOURCE) + target_include_directories(graphar SYSTEM BEFORE + PUBLIC $ + ) +endif() + # Dependency Linking Logic if(BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC) set(GAR_BUNDLED_DEPS_STATIC_LIBS diff --git a/cpp/cmake/apache-arrow.cmake b/cpp/cmake/apache-arrow.cmake index 5f58f42be..dc01379d7 100644 --- a/cpp/cmake/apache-arrow.cmake +++ b/cpp/cmake/apache-arrow.cmake @@ -158,5 +158,12 @@ function(build_arrow) IMPORTED_LOCATION ${GAR_ARROW_ACERO_STATIC_LIB}) endif() + # Ensure imported targets wait for the ExternalProject build/install step. add_dependencies(${GAR_ARROW_LIBRARY_TARGET} arrow_ep) + add_dependencies(${GAR_PARQUET_LIBRARY_TARGET} arrow_ep) + add_dependencies(${GAR_DATASET_LIBRARY_TARGET} arrow_ep) + add_dependencies(${GAR_ARROW_BUNDLED_DEPS_TARGET} arrow_ep) + if (TARGET ${GAR_ARROW_ACERO_LIBRARY_TARGET}) + add_dependencies(${GAR_ARROW_ACERO_LIBRARY_TARGET} arrow_ep) + endif() endfunction() \ No newline at end of file From 4f40bce3713d1dabb5c138bd96140aa9fe221dba Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 15:42:39 +0800 Subject: [PATCH 10/30] use release build type --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eebee3f31..6f41e7b68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -217,7 +217,7 @@ jobs: # install benchmark git clone --branch v1.8.3 https://github.com/google/benchmark.git --depth 1 pushd benchmark - cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_TESTING=OFF -DBENCHMARK_ENABLE_GTEST_TESTS=OFF . + cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBENCHMARK_ENABLE_TESTING=OFF -DBENCHMARK_ENABLE_GTEST_TESTS=OFF . sudo make install popd @@ -355,7 +355,7 @@ jobs: run: | mkdir build-static pushd build-static - cmake .. -DUSE_STATIC_ARROW=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON + cmake .. -DUSE_STATIC_ARROW=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_container_overflow=0 From d61c1796464186ba85ecd29ba745f8972e8abdb2 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 16:05:15 +0800 Subject: [PATCH 11/30] fix orc in macos --- .github/workflows/ci.yml | 26 ++++---------------------- cpp/CMakeLists.txt | 5 ++++- cpp/cmake/apache-arrow.cmake | 2 +- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f41e7b68..a8461b399 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,9 +38,9 @@ concurrency: cancel-in-progress: true jobs: - ubuntu-normal: + ubuntu: # TODO use ubuntu-latest - name: Ubuntu 22.04 C++ (normal + baseline) + name: Ubuntu 22.04 C++ runs-on: ubuntu-22.04 if: ${{ !contains(github.event.pull_request.title, 'WIP') && !github.event.pull_request.draft }} env: @@ -279,8 +279,8 @@ jobs: ctest --output-on-failure popd - macos-normal: - name: macos latest C++ (normal + baseline) + macos: + name: macos latest C++ runs-on: macos-latest if: ${{ !contains(github.event.pull_request.title, 'WIP') && github.event.pull_request.draft == false }} env: @@ -313,24 +313,6 @@ jobs: export ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure - - name: test release build type - working-directory: "cpp" - run: | - mkdir build-release - pushd build-release - cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON - make -j$(nproc) - export ASAN_OPTIONS=detect_leaks=0 - ctest --output-on-failure - popd - - - name: Benchmark-release - working-directory: "cpp/build-release" - run: | - ./graph_info_benchmark - ./arrow_chunk_reader_benchmark - ./label_filter_benchmark - macos-static: name: macos latest C++ (static) runs-on: macos-latest diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index bed82be8f..b317301b4 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -48,6 +48,7 @@ option(BUILD_DOCS_ONLY "Build docs only" OFF) option(USE_STATIC_ARROW "Link arrow static library" OFF) option(GRAPHAR_BUILD_STATIC "Build GraphAr as static libraries" OFF) option(BUILD_ARROW_FROM_SOURCE "Build Arrow from source" OFF) +option(GRAPHAR_ENABLE_ORC "Enable Arrow ORC support (build-from-source)" OFF) # Consistency Logic if (USE_STATIC_ARROW OR BUILD_ARROW_FROM_SOURCE) @@ -259,7 +260,9 @@ if (BUILD_ARROW_FROM_SOURCE) find_package(CURL REQUIRED) include(apache-arrow) build_arrow() - add_definitions(-DARROW_ORC) + if (GRAPHAR_ENABLE_ORC) + add_definitions(-DARROW_ORC) + endif() else() # Find System Arrow find_package(Arrow QUIET) diff --git a/cpp/cmake/apache-arrow.cmake b/cpp/cmake/apache-arrow.cmake index dc01379d7..0169b6128 100644 --- a/cpp/cmake/apache-arrow.cmake +++ b/cpp/cmake/apache-arrow.cmake @@ -89,7 +89,7 @@ function(build_arrow) "-DARROW_BUILD_TESTS=OFF" "-DARROW_BUILD_INTEGRATION=OFF" "-DBoost_SOURCE=BUNDLED" - "-DARROW_ORC=ON" + "-DARROW_ORC=${GRAPHAR_ENABLE_ORC}" "-DARROW_COMPUTE=ON" "-DARROW_ACERO=ON" "-DARROW_DATASET=ON" From d4d6146046d5b2e82f3fd7e289fe7cf267ddc1f9 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 16:34:46 +0800 Subject: [PATCH 12/30] pin cmake version to fix macos build from source --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8461b399..f72771bf1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -369,6 +369,12 @@ jobs: with: submodules: true + - name: Pin CMake 3.29 (avoid CMake 4 incompat) + run: | + brew install cmake@3.29 + echo "$(brew --prefix cmake@3.29)/bin" >> "$GITHUB_PATH" + cmake --version + - name: Build with Arrow from Source working-directory: "cpp" run: | From e89a3c405c6e29259c4b8267b9dfcc4a08f3f115 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 16:38:35 +0800 Subject: [PATCH 13/30] pin cmake version to fix macos build from source --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f72771bf1..67851591d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -369,11 +369,13 @@ jobs: with: submodules: true - - name: Pin CMake 3.29 (avoid CMake 4 incompat) - run: | - brew install cmake@3.29 - echo "$(brew --prefix cmake@3.29)/bin" >> "$GITHUB_PATH" - cmake --version + - name: Setup CMake 3.29.x + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.29.6' + + - name: Show CMake version + run: cmake --version - name: Build with Arrow from Source working-directory: "cpp" From e96d44e4bafc43595de2f2f5a1dd19ae85b51120 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 16:56:19 +0800 Subject: [PATCH 14/30] try build test --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67851591d..3ba2ff614 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,7 +273,7 @@ jobs: run: | mkdir build-bundled pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure @@ -382,7 +382,7 @@ jobs: run: | mkdir build-bundled pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 ctest --output-on-failure From b65e289273598b767e520579f3415fe78d236af9 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 17:19:26 +0800 Subject: [PATCH 15/30] run exmaple --- .github/workflows/ci.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ba2ff614..a1da2215b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,12 +273,18 @@ jobs: run: | mkdir build-bundled pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 - ctest --output-on-failure popd + - name: Run examples + working-directory: "cpp/build-bundled" + run: | + git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 + bash high_level_reader_example + bash high_level_writer_example + macos: name: macos latest C++ runs-on: macos-latest @@ -382,8 +388,14 @@ jobs: run: | mkdir build-bundled pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON + cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON make -j$(nproc) export ASAN_OPTIONS=detect_leaks=0 - ctest --output-on-failure - popd \ No newline at end of file + popd + + - name: Run examples + working-directory: "cpp/build-bundled" + run: | + git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 + bash high_level_reader_example + bash high_level_writer_example \ No newline at end of file From 36b7b79156d8968fffe072a9c787a3a5b3b64d87 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 17:26:27 +0800 Subject: [PATCH 16/30] try to fix --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1da2215b..e37d8b542 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -380,8 +380,9 @@ jobs: with: cmake-version: '3.29.6' - - name: Show CMake version - run: cmake --version + - name: Install dependencies + run: | + brew install boost - name: Build with Arrow from Source working-directory: "cpp" From 16702f3ffee949d7ea5f8a351dc5cd71f2970ee2 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Wed, 7 Jan 2026 18:00:03 +0800 Subject: [PATCH 17/30] try to fix --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e37d8b542..0e0a12e96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -282,8 +282,8 @@ jobs: working-directory: "cpp/build-bundled" run: | git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 - bash high_level_reader_example - bash high_level_writer_example + ./high_level_reader_example + ./high_level_writer_example macos: name: macos latest C++ @@ -398,5 +398,5 @@ jobs: working-directory: "cpp/build-bundled" run: | git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 - bash high_level_reader_example - bash high_level_writer_example \ No newline at end of file + ./high_level_reader_example + ./high_level_writer_example \ No newline at end of file From dccb7dc2e408ae3d16a033455f93d890bc044959 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Thu, 8 Jan 2026 11:06:28 +0800 Subject: [PATCH 18/30] update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e0a12e96..2c6937d2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ on: # but only for the main branch push: branches: - - "**" + - "main" paths: - 'cpp/**' - '.github/workflows/ci.yml' From c7e97119b4667293d83184e5b4e0c6f4ef05b570 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Thu, 8 Jan 2026 11:43:39 +0800 Subject: [PATCH 19/30] set up cmake in macos --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c6937d2c..2651aabc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -376,9 +376,9 @@ jobs: submodules: true - name: Setup CMake 3.29.x - uses: jwlawson/actions-setup-cmake@v2 - with: - cmake-version: '3.29.6' + run: | + curl -L https://github.com/Kitware/CMake/releases/download/v3.29.6/cmake-3.29.6-macos-universal.tar.gz | tar xz + sudo cp -r cmake-3.29.6-macos-universal/CMake.app/Contents/bin/* /usr/local/bin/ - name: Install dependencies run: | From 8ab752234480801e0c30fffae8c736af0c2d2b18 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Thu, 8 Jan 2026 16:40:53 +0800 Subject: [PATCH 20/30] try install cmake in macos --- .github/workflows/ci.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2651aabc1..46c414c18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -375,10 +375,24 @@ jobs: with: submodules: true - - name: Setup CMake 3.29.x + - name: Setup CMake 3.29.6 + shell: bash run: | - curl -L https://github.com/Kitware/CMake/releases/download/v3.29.6/cmake-3.29.6-macos-universal.tar.gz | tar xz - sudo cp -r cmake-3.29.6-macos-universal/CMake.app/Contents/bin/* /usr/local/bin/ + set -euo pipefail + CMAKE_VERSION="3.29.6" + CMAKE_TARBALL="cmake-${CMAKE_VERSION}-macos-universal.tar.gz" + CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_TARBALL}" + + DEST_DIR="${RUNNER_TEMP}/cmake-${CMAKE_VERSION}" + rm -rf "${DEST_DIR}" + mkdir -p "${DEST_DIR}" + + curl -fsSL "${CMAKE_URL}" | tar -xz -C "${DEST_DIR}" + + # Prepend to PATH for subsequent steps in this job + echo "${DEST_DIR}/cmake-${CMAKE_VERSION}-macos-universal/CMake.app/Contents/bin" >> "${GITHUB_PATH}" + + cmake --version - name: Install dependencies run: | From aea1ae2f2730be20c81a69714a43f4b86c73f108 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Fri, 9 Jan 2026 15:07:36 +0800 Subject: [PATCH 21/30] fix add twice case --- cpp/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index b0831c6a6..ff770c540 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -87,14 +87,13 @@ if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_ endif() endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fno-omit-frame-pointer -fsanitize=address") -set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") if(MSVC) # Avoid GCC/Clang-specific flags on MSVC. # C++17 is already enforced via CMAKE_CXX_STANDARD/target features. else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") + # NOTE: Do not add -std=c++17 here (already enforced via target features). + # Keep warnings consistent for GCC/Clang only. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") endif() if (APPLE) @@ -103,6 +102,7 @@ elseif(UNIX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,$ORIGIN") endif () +# Debug flags (base) - added once. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fno-omit-frame-pointer") if (GRAPHAR_ENABLE_SANITIZER) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address") From 07aa864991da4c1c5883037e23d4845cfb443a29 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Fri, 9 Jan 2026 16:28:23 +0800 Subject: [PATCH 22/30] move build from arrow source to nightly workflow --- .github/workflows/ci-nightly.yml | 93 +++++++++++++++++++++++++++++++- .github/workflows/ci.yml | 87 ------------------------------ 2 files changed, 92 insertions(+), 88 deletions(-) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index a41b73fbf..e3bf49591 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -17,7 +17,13 @@ name: GraphAr C++ CI Nightly -on: +on: + pull_request: + branches: + - main + paths: + - 'cpp/**' + - '.github/workflows/ci.yml' workflow_dispatch: schedule: # The notifications for scheduled workflows are sent to the user who @@ -78,6 +84,91 @@ jobs: popd + - name: CMake-release + run: | + mkdir build-release + pushd build-release + cmake ../cpp -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_ARROW_FROM_SOURCE=ON + popd + + - name: Build GraphAr-release + run: | + pushd build-release + make -j$(nproc) + make graphar-ccache-stats + popd + + - name: Test-release + run: | + pushd build-release + ctest --output-on-failure + popd + + GraphAr-macos-arrow-from-source: + if: ${{ github.ref == 'refs/heads/main' && github.repository == 'apache/incubator-graphar' }} + runs-on: macos-latest + env: + GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Cache for ccache + uses: actions/cache@v3 + with: + path: ~/.ccache + key: ${{ matrix.os }}-build-ccache-${{ hashFiles('**/git-modules.txt') }} + restore-keys: | + ${{ matrix.os }}-build-ccache- + + - name: Setup CMake 3.29.6 + shell: bash + run: | + set -euo pipefail + CMAKE_VERSION="3.29.6" + CMAKE_TARBALL="cmake-${CMAKE_VERSION}-macos-universal.tar.gz" + CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_TARBALL}" + + DEST_DIR="${RUNNER_TEMP}/cmake-${CMAKE_VERSION}" + rm -rf "${DEST_DIR}" + mkdir -p "${DEST_DIR}" + + curl -fsSL "${CMAKE_URL}" | tar -xz -C "${DEST_DIR}" + + # Prepend to PATH for subsequent steps in this job + echo "${DEST_DIR}/cmake-${CMAKE_VERSION}-macos-universal/CMake.app/Contents/bin" >> "${GITHUB_PATH}" + + cmake --version + + + - name: Install dependencies + run: | + brew install boost + brew install ccache + brew install catch2 + + - name: CMake-debug + run: | + mkdir build-debug + pushd build-debug + cmake ../cpp -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_ARROW_FROM_SOURCE=ON + popd + + - name: Build GraphAr-debug + run: | + pushd build-debug + make -j$(nproc) + make graphar-ccache-stats + popd + + - name: Test-debug + run: | + pushd build-debug + ctest --output-on-failure + popd + + - name: CMake-release run: | mkdir build-release diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46c414c18..e2a30878a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -252,39 +252,6 @@ jobs: name: ubuntu-libgraphar.a path: cpp/build-static/libgraphar.a - ubuntu-arrow-source: - # TODO use ubuntu-latest - name: Ubuntu 22.04 C++ (arrow from source) - runs-on: ubuntu-22.04 - if: ${{ !contains(github.event.pull_request.title, 'WIP') && !github.event.pull_request.draft }} - env: - GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install dependencies - run: | - sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev libssl-dev pkg-config doxygen lcov - - - name: Build with Arrow from Source - working-directory: "cpp" - run: | - mkdir build-bundled - pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON - make -j$(nproc) - export ASAN_OPTIONS=detect_leaks=0 - popd - - - name: Run examples - working-directory: "cpp/build-bundled" - run: | - git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 - ./high_level_reader_example - ./high_level_writer_example - macos: name: macos latest C++ runs-on: macos-latest @@ -360,57 +327,3 @@ jobs: with: name: macos-libgraphar.a path: cpp/build-static/libgraphar.a - - macos-arrow-source: - name: macos latest C++ (arrow from source) - runs-on: macos-latest - if: ${{ !contains(github.event.pull_request.title, 'WIP') && github.event.pull_request.draft == false }} - env: - GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Setup CMake 3.29.6 - shell: bash - run: | - set -euo pipefail - CMAKE_VERSION="3.29.6" - CMAKE_TARBALL="cmake-${CMAKE_VERSION}-macos-universal.tar.gz" - CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_TARBALL}" - - DEST_DIR="${RUNNER_TEMP}/cmake-${CMAKE_VERSION}" - rm -rf "${DEST_DIR}" - mkdir -p "${DEST_DIR}" - - curl -fsSL "${CMAKE_URL}" | tar -xz -C "${DEST_DIR}" - - # Prepend to PATH for subsequent steps in this job - echo "${DEST_DIR}/cmake-${CMAKE_VERSION}-macos-universal/CMake.app/Contents/bin" >> "${GITHUB_PATH}" - - cmake --version - - - name: Install dependencies - run: | - brew install boost - - - name: Build with Arrow from Source - working-directory: "cpp" - run: | - mkdir build-bundled - pushd build-bundled - cmake .. -DBUILD_ARROW_FROM_SOURCE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON - make -j$(nproc) - export ASAN_OPTIONS=detect_leaks=0 - popd - - - name: Run examples - working-directory: "cpp/build-bundled" - run: | - git clone https://github.com/apache/incubator-graphar-testing.git $GAR_TEST_DATA --depth 1 - ./high_level_reader_example - ./high_level_writer_example \ No newline at end of file From 89c7e5e959e3974280374194b43e05680b8db819 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Fri, 9 Jan 2026 16:32:18 +0800 Subject: [PATCH 23/30] try nightly workflow --- .github/workflows/ci-nightly.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index e3bf49591..21d32ccdb 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -32,7 +32,7 @@ on: - cron: '00 19 * * *' jobs: GraphAr-ubuntu-arrow-from-source: - if: ${{ github.ref == 'refs/heads/main' && github.repository == 'apache/incubator-graphar' }} + # if: ${{ github.ref == 'refs/heads/main' && github.repository == 'apache/incubator-graphar' }} runs-on: ubuntu-latest env: GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ @@ -105,7 +105,7 @@ jobs: popd GraphAr-macos-arrow-from-source: - if: ${{ github.ref == 'refs/heads/main' && github.repository == 'apache/incubator-graphar' }} + # if: ${{ github.ref == 'refs/heads/main' && github.repository == 'apache/incubator-graphar' }} runs-on: macos-latest env: GAR_TEST_DATA: ${{ github.workspace }}/graphar-testing/ From d6d8c6468f1129e4edce9ca0973351b7bf64d5a5 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 11:14:06 +0800 Subject: [PATCH 24/30] try to fix ccache --- cpp/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ff770c540..100a4d727 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -79,12 +79,19 @@ else () endif () # Compiler Flags -if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")) +if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache"))Add a comment on line R82Add diff commentMarkdown input: edit mode selected.WritePreviewAdd a suggestionHeadingBoldItalicQuoteCodeLinkUnordered listNumbered listTask listMentionReferenceSaved repliesAdd FilesPaste, drop, or click to add filesCancelCommentStart a reviewReturn to code find_program(ccache_EXECUTABLE ccache) if(ccache_EXECUTABLE) set(CMAKE_C_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) - endif() + add_custom_target(graphar-ccache-stats + COMMAND ${ccache_EXECUTABLE} --show-stats + ) + else() + add_custom_target(graphar-ccache-stats + COMMAND echo "ccache not found." + ) + endif(ccache_EXECUTABLE) endif() if(MSVC) From 0c69253c5b395d3028f893c0677494b4a137d9fc Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 11:20:05 +0800 Subject: [PATCH 25/30] fix --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 100a4d727..5070e462e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -79,7 +79,7 @@ else () endif () # Compiler Flags -if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache"))Add a comment on line R82Add diff commentMarkdown input: edit mode selected.WritePreviewAdd a suggestionHeadingBoldItalicQuoteCodeLinkUnordered listNumbered listTask listMentionReferenceSaved repliesAdd FilesPaste, drop, or click to add filesCancelCommentStart a reviewReturn to code +if(NOT (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") AND NOT (CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")) find_program(ccache_EXECUTABLE ccache) if(ccache_EXECUTABLE) set(CMAKE_C_COMPILER_LAUNCHER ${ccache_EXECUTABLE}) From c6b9f8526f77bdb642f733299df81614b7849115 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 12:00:06 +0800 Subject: [PATCH 26/30] print message --- cpp/test/test_builder.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cpp/test/test_builder.cc b/cpp/test/test_builder.cc index ab1d73649..ca6c08839 100644 --- a/cpp/test/test_builder.cc +++ b/cpp/test/test_builder.cc @@ -118,7 +118,9 @@ TEST_CASE_METHOD(GlobalFixture, "Test_vertices_builder") { REQUIRE(builder->GetNum() == lines); // dump to files - REQUIRE(builder->Dump().ok()); + auto st1 = builder->Dump(); + std::cout << st1.message() << std::endl; + REQUIRE(st1.ok()); // can not add new vertices after dumping REQUIRE(builder->AddVertex(v).IsInvalid()); @@ -217,7 +219,9 @@ TEST_CASE_METHOD(GlobalFixture, "test_edges_builder") { REQUIRE(builder->GetNum() == lines); // dump to files - REQUIRE(builder->Dump().ok()); + auto st1 = builder->Dump(); + std::cout << st1.message() << std::endl; + REQUIRE(st1.ok()); // can not add new edges after dumping REQUIRE(builder->AddEdge(e).IsInvalid()); From cebc766dab902ab2810f0dc94b6b99d600175396 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 16:44:17 +0800 Subject: [PATCH 27/30] try to fix --- cpp/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 5070e462e..8b41f202f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -431,7 +431,10 @@ if (BUILD_EXAMPLES) target_link_libraries(${E_NAME} PRIVATE graphar ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) # When GraphAr is static, consumers must also link Arrow/Parquet. - if(GRAPHAR_BUILD_STATIC) + # But when we build Arrow from source and bundle it into GraphAr's + # merged static deps archive, linking Arrow again can duplicate Arrow + # object code in the final executable (ODR/global-state issues). + if(GRAPHAR_BUILD_STATIC AND NOT (BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC)) target_link_arrow_dependencies(${E_NAME} PRIVATE) endif() endforeach() @@ -448,7 +451,10 @@ if (BUILD_TESTS) target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain graphar ${CMAKE_DL_LIBS}) # When GraphAr is static, consumers must also link Arrow/Parquet. - if(GRAPHAR_BUILD_STATIC) + # But when we build Arrow from source and bundle it into GraphAr's + # merged static deps archive, linking Arrow again can duplicate Arrow + # object code in the final executable (ODR/global-state issues). + if(GRAPHAR_BUILD_STATIC AND NOT (BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC)) target_link_arrow_dependencies(${target} PRIVATE) endif() catch_discover_tests(${target}) From 5e7a50b7fa4fdf8e85643c9b48fa7c829f743651 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 17:02:32 +0800 Subject: [PATCH 28/30] Revert "try to fix" This reverts commit cebc766dab902ab2810f0dc94b6b99d600175396. --- cpp/CMakeLists.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 8b41f202f..5070e462e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -431,10 +431,7 @@ if (BUILD_EXAMPLES) target_link_libraries(${E_NAME} PRIVATE graphar ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) # When GraphAr is static, consumers must also link Arrow/Parquet. - # But when we build Arrow from source and bundle it into GraphAr's - # merged static deps archive, linking Arrow again can duplicate Arrow - # object code in the final executable (ODR/global-state issues). - if(GRAPHAR_BUILD_STATIC AND NOT (BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC)) + if(GRAPHAR_BUILD_STATIC) target_link_arrow_dependencies(${E_NAME} PRIVATE) endif() endforeach() @@ -451,10 +448,7 @@ if (BUILD_TESTS) target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain graphar ${CMAKE_DL_LIBS}) # When GraphAr is static, consumers must also link Arrow/Parquet. - # But when we build Arrow from source and bundle it into GraphAr's - # merged static deps archive, linking Arrow again can duplicate Arrow - # object code in the final executable (ODR/global-state issues). - if(GRAPHAR_BUILD_STATIC AND NOT (BUILD_ARROW_FROM_SOURCE AND GRAPHAR_BUILD_STATIC)) + if(GRAPHAR_BUILD_STATIC) target_link_arrow_dependencies(${target} PRIVATE) endif() catch_discover_tests(${target}) From bb5f8aca7fef885530cf2cc2083cc397ce773b9b Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 17:03:12 +0800 Subject: [PATCH 29/30] test --- .github/workflows/ci-nightly.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 21d32ccdb..d8f150a48 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -80,6 +80,7 @@ jobs: - name: Test-debug run: | pushd build-debug + ./test_builder ctest --output-on-failure popd From 5259a51ff469599a2013ece733c42eaab847bab0 Mon Sep 17 00:00:00 2001 From: yxk485490 <1320342065@qq.com> Date: Mon, 12 Jan 2026 17:56:32 +0800 Subject: [PATCH 30/30] try arrow 15 --- cpp/cmake/apache-arrow.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake/apache-arrow.cmake b/cpp/cmake/apache-arrow.cmake index 0169b6128..fe7ee6294 100644 --- a/cpp/cmake/apache-arrow.cmake +++ b/cpp/cmake/apache-arrow.cmake @@ -111,7 +111,7 @@ function(build_arrow) if(DEFINED ENV{GAR_ARROW_SOURCE_URL}) set(GAR_ARROW_SOURCE_URL "$ENV{GAR_ARROW_SOURCE_URL}") else() - set(ARROW_VERSION_TO_BUILD "17.0.0" CACHE INTERNAL "arrow version") + set(ARROW_VERSION_TO_BUILD "15.0.0" CACHE INTERNAL "arrow version") if (Arrow_FOUND) # arrow is installed, build the same version as the installed one set(ARROW_VERSION_TO_BUILD "${Arrow_VERSION}" CACHE INTERNAL "arrow version") endif()