Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,16 @@ include(ExternalProject)
include(cugraph)

# Install testing dependencies (gtest)
set(GTEST_ROOT ${PROJECT_BINARY_DIR}/gtest)
ExternalProject_Add(gtest-proj
PREFIX ${GTEST_ROOT}
INSTALL_DIR ${GTEST_ROOT}
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.16.0
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
set(GTEST_INCLUDE_DIR ${GTEST_ROOT}/include)
set(GTEST_LIBRARY_PATH ${GTEST_ROOT}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_DEBUG_LIBRARY_PATH ${GTEST_ROOT}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd.a)
add_library(mage_gtest STATIC IMPORTED)
set_target_properties(mage_gtest PROPERTIES
IMPORTED_LOCATION "${GTEST_LIBRARY_PATH}"
IMPORTED_LOCATION_DEBUG "${GTEST_DEBUG_LIBRARY_PATH}"
INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
include_directories("${GTEST_INCLUDE_DIR}")
add_dependencies(mage_gtest gtest-proj)
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Create an alias for consistency with existing code
add_library(mage_gtest ALIAS gtest)

# Add OpenMP compiling option
find_package(OpenMP)
Expand Down
14 changes: 6 additions & 8 deletions cpp/betweenness_centrality_module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,23 @@ endif()
set(betweenness_centrality_online_src
betweenness_centrality_online_module.cpp
algorithm/betweenness_centrality.cpp
algorithm_online/betweenness_centrality_online.cpp
../biconnected_components_module/algorithm/biconnected_components.cpp)
algorithm_online/betweenness_centrality_online.cpp)

add_query_module(betweenness_centrality_online 1 "${betweenness_centrality_online_src}")

# Link external libraries
target_link_libraries(betweenness_centrality_online PRIVATE mg_utility)
target_link_libraries(betweenness_centrality_online PRIVATE mg_utility biconnected_components_algorithm)
target_include_directories(betweenness_centrality_online PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Module tests
if (NOT MAGE_CUGRAPH_ENABLE)
include(GoogleTest)
set(betweenness_centrality_online_src
set(betweenness_centrality_online_test_src
betweenness_centrality_online_test.cpp
algorithm/betweenness_centrality.cpp
algorithm_online/betweenness_centrality_online.cpp
../biconnected_components_module/algorithm/biconnected_components.cpp)
algorithm_online/betweenness_centrality_online.cpp)

add_executable(betweenness_centrality_online_test "${betweenness_centrality_online_src}")
target_link_libraries(betweenness_centrality_online_test PRIVATE mg_utility mage_gtest)
add_executable(betweenness_centrality_online_test "${betweenness_centrality_online_test_src}")
target_link_libraries(betweenness_centrality_online_test PRIVATE mg_utility mage_gtest biconnected_components_algorithm)
gtest_add_tests(TARGET betweenness_centrality_online_test)
endif()
16 changes: 10 additions & 6 deletions cpp/biconnected_components_module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
set(biconnected_components_module_src
biconnected_components_module.cpp
# Create a static library for the shared algorithm code
add_library(biconnected_components_algorithm STATIC
algorithm/biconnected_components.cpp)
target_include_directories(biconnected_components_algorithm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(biconnected_components_algorithm PRIVATE mg_utility)

set(biconnected_components_module_src
biconnected_components_module.cpp)

add_query_module(biconnected_components 1 "${biconnected_components_module_src}")

# Link external libraries
target_link_libraries(biconnected_components PRIVATE mg_utility)
target_link_libraries(biconnected_components PRIVATE mg_utility biconnected_components_algorithm)
target_include_directories(biconnected_components PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Module tests
if (NOT MAGE_CUGRAPH_ENABLE)
include(GoogleTest)
set(biconnected_components_test_src
biconnected_components_test.cpp
algorithm/biconnected_components.cpp)
biconnected_components_test.cpp)

add_executable(biconnected_components_test "${biconnected_components_test_src}")
target_link_libraries(biconnected_components_test PRIVATE mg_utility mage_gtest)
target_link_libraries(biconnected_components_test PRIVATE mg_utility mage_gtest biconnected_components_algorithm)
gtest_add_tests(TARGET biconnected_components_test)
endif()
2 changes: 1 addition & 1 deletion cpp/cycles_module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set(cycles_test_src
algorithm/cycles.cpp)

add_executable(cycles_test "${cycles_test_src}")
target_link_libraries(cycles_test PRIVATE mg_utility mage_gtest)
target_link_libraries(cycles_test PRIVATE mg_utility mage_gtest)
9 changes: 4 additions & 5 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,23 @@ def build_and_copy_cpp_modules(args: Dict[str, Any]) -> bool:
os.makedirs(CPP_BUILD_DIRECTORY, exist_ok=True)

# Prepare CMake flags
os.chdir(CPP_BUILD_DIRECTORY)
cmake_args = [".."]
os.chdir(CPP_DIRECTORY)
cmake_args = [".", "-B", CPP_BUILD_DIRECTORY]
if args[Parameter.GPU.value]:
cmake_args.append(f"-D{MAGE_GPU_BUILD}")
if args[Parameter.CPP_BUILD_FLAGS.value] is not None:
cmake_args += [f"-D{flag}" for flag in args[Parameter.CPP_BUILD_FLAGS.value]]
else:
cmake_args += [f"-DCMAKE_BUILD_TYPE={BuildType.RELEASE}"]

cmake_command = ["cmake"] + cmake_args
cmake_command = ["cmake"] + cmake_args + ["-GNinja"]

cmake_status = run_command(cmake_command)
if not cmake_status:
logger.error("[Terminal] (1/7) Building C++ modules failed.")
return False

core_count = mp.cpu_count()
make_command = ["make", f"-j{core_count}"]
make_command = ["cmake", "--build", CPP_BUILD_DIRECTORY]

make_status = run_command(make_command)
if not make_status:
Expand Down