Skip to content

Commit cab629e

Browse files
committed
ci: fix C++
1 parent 6d7acea commit cab629e

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ jobs:
120120
with:
121121
cmake-version: "3.26.x"
122122

123+
- name: Install nlohmann-json
124+
shell: bash
125+
run: |
126+
if [[ "${{ runner.os }}" == "Linux" ]]; then
127+
sudo apt-get update && sudo apt-get install -y nlohmann-json3-dev
128+
elif [[ "${{ runner.os }}" == "macOS" ]]; then
129+
brew install nlohmann-json
130+
fi
131+
132+
- name: Install nlohmann-json (Windows)
133+
if: runner.os == 'Windows'
134+
run: |
135+
vcpkg install nlohmann-json:x64-windows
136+
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
137+
shell: bash
138+
123139
- name: Install cxxbridge
124140
run: cargo install cxxbridge-cmd
125141

@@ -128,7 +144,13 @@ jobs:
128144
working-directory: ./src/rust
129145

130146
- name: Configure CMake
131-
run: cmake -B build -G "${{ matrix.cmake_generator }}" -DCMAKE_BUILD_TYPE=Release
147+
shell: bash
148+
run: |
149+
CMAKE_ARGS="-B build -G \"${{ matrix.cmake_generator }}\" -DCMAKE_BUILD_TYPE=Release"
150+
if [[ -n "${CMAKE_TOOLCHAIN_FILE}" ]]; then
151+
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
152+
fi
153+
eval cmake ${CMAKE_ARGS}
132154
working-directory: ./src/cpp
133155

134156
- name: Build C++ bindings
@@ -137,7 +159,8 @@ jobs:
137159
if [[ "${{ runner.os }}" = "Windows" ]]; then
138160
cmake --build build --config Release
139161
else
140-
cmake --build build -- -j$(nproc)
162+
NPROC=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)
163+
cmake --build build -- -j${NPROC}
141164
fi
142165
working-directory: ./src/cpp
143166

src/cpp/CMakeLists.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,23 @@ add_executable(local_fcb_example examples/local_fcb_example.cpp ${GENERATED_DIR}
9797
target_link_libraries(local_fcb_example fcb)
9898
target_include_directories(local_fcb_example PRIVATE ${GENERATED_DIR})
9999

100-
add_executable(fcb_comprehensive_example examples/comprehensive_example.cpp ${GENERATED_DIR}/lib.rs.h)
101-
target_link_libraries(fcb_comprehensive_example fcb)
102-
target_include_directories(fcb_comprehensive_example PRIVATE ${GENERATED_DIR})
103-
104100
# Roundtrip test (encode CityJSONSeq -> FCB -> read back)
105101
add_executable(fcb_roundtrip_test examples/roundtrip_test.cpp ${GENERATED_DIR}/lib.rs.h)
106102
target_link_libraries(fcb_roundtrip_test fcb)
107103
target_include_directories(fcb_roundtrip_test PRIVATE ${GENERATED_DIR})
108104

109-
# Comprehensive roundtrip tests (tests/ directory)
110-
add_executable(fcb_roundtrip_comprehensive tests/roundtrip_test.cpp ${GENERATED_DIR}/lib.rs.h)
111-
target_link_libraries(fcb_roundtrip_comprehensive fcb nlohmann_json::nlohmann_json)
112-
target_include_directories(fcb_roundtrip_comprehensive PRIVATE ${GENERATED_DIR})
113-
114-
# Link nlohmann/json for comprehensive_example if found
105+
# Targets requiring nlohmann/json
115106
if(nlohmann_json_FOUND)
116-
target_link_libraries(fcb_comprehensive_example nlohmann_json::nlohmann_json)
107+
add_executable(fcb_comprehensive_example examples/comprehensive_example.cpp ${GENERATED_DIR}/lib.rs.h)
108+
target_link_libraries(fcb_comprehensive_example fcb nlohmann_json::nlohmann_json)
109+
target_include_directories(fcb_comprehensive_example PRIVATE ${GENERATED_DIR})
110+
111+
# Comprehensive roundtrip tests (tests/ directory)
112+
add_executable(fcb_roundtrip_comprehensive tests/roundtrip_test.cpp ${GENERATED_DIR}/lib.rs.h)
113+
target_link_libraries(fcb_roundtrip_comprehensive fcb nlohmann_json::nlohmann_json)
114+
target_include_directories(fcb_roundtrip_comprehensive PRIVATE ${GENERATED_DIR})
115+
else()
116+
message(STATUS "Skipping fcb_comprehensive_example and fcb_roundtrip_comprehensive (nlohmann_json not found)")
117117
endif()
118118

119119
# Install targets

0 commit comments

Comments
 (0)