Skip to content
Open
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
11 changes: 5 additions & 6 deletions bindings/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ option(OPENDAL_DEV "Enable dev mode" OFF)
option(OPENDAL_ENABLE_ASYNC "Enable async mode (requires C++20)" OFF)

if(OPENDAL_ENABLE_ASYNC)
set(CMAKE_CXX_STANDARD 20)

if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")))
message(FATAL_ERROR "currently C++ compiler must be clang for async mode")
endif()
else()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to require C++17, because many projects cannot directly support C++20 for the time being, and it is necessary to retain this practice.

set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (OPENDAL_DEV)
Expand Down Expand Up @@ -83,7 +80,9 @@ endif()
execute_process(COMMAND cargo locate-project --workspace --message-format plain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I am considering whether we can first simply add a CI for Windows platform compilation and C++ unit test execution, so as to initially and easily ensure that compilation changes are reliable.

OUTPUT_VARIABLE CARGO_TARGET_DIR
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string(REGEX REPLACE "/Cargo.toml\n$" "/target" CARGO_TARGET_DIR "${CARGO_TARGET_DIR}")
cmake_path(GET CARGO_TARGET_DIR PARENT_PATH CARGO_TARGET_DIR)
cmake_path(APPEND CARGO_TARGET_DIR "target" )

set(CARGO_MANIFEST ${PROJECT_SOURCE_DIR}/Cargo.toml)
set(RUST_SOURCE_FILE ${PROJECT_SOURCE_DIR}/src/lib.rs)
list(APPEND RUST_BRIDGE_CPP ${CARGO_TARGET_DIR}/cxxbridge/opendal-cpp/src/lib.rs.cc)
Expand Down Expand Up @@ -171,7 +170,7 @@ endif()

# Platform-specific test configuration
if(WIN32)
target_link_libraries(opendal_cpp userenv ws2_32 bcrypt)
target_link_libraries(opendal_cpp PRIVATE userenv ws2_32 bcrypt Ntdll.lib)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

System libraries (such as userenv/ws2_32) should use PUBLIC, as they are interface dependencies, while internal libraries (Ntdll.lib) should use PRIVATE.

set_target_properties(
opendal_cpp
PROPERTIES
Expand Down
Loading