Skip to content

Commit aa46a2f

Browse files
committed
fix(ci): build packaged examples as x64 for VS2017 on Windows
Visual Studio 15/16 generators default to Win32 while the SDK is x64, causing LNK1112. Pass -A x64 in the verify step and set CMAKE_GENERATOR_PLATFORM in examples CMakeLists.
1 parent b43d1e1 commit aa46a2f

4 files changed

Lines changed: 48 additions & 1 deletion

File tree

.github/scripts/local-verify-packaged-examples-windows.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ EXAMPLE_BUILD="${TEMP_BASE}/client-cpp-example-smoke"
3535
rm -rf "${EXAMPLE_BUILD}"
3636
CMAKE_ARGS=(-S "${PKG_ROOT}/examples" -B "${EXAMPLE_BUILD}" -DIOTDB_SDK_ROOT="${PKG_ROOT}")
3737
if [ -n "${CMAKE_GENERATOR}" ]; then
38-
CMAKE_ARGS+=(-G "${CMAKE_GENERATOR}")
38+
CMAKE_ARGS+=(-G "${CMAKE_GENERATOR}" -A x64)
3939
fi
4040
cmake "${CMAKE_ARGS[@]}"
4141
cmake --build "${EXAMPLE_BUILD}" --config Release
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
PKG_ZIP="${1:-/c/Users/76141/Downloads/iotdb-session-cpp-2.0.7-SNAPSHOT-windows-x86_64-msvc14.3.zip}"
5+
REPO_EXAMPLES="${2:-/d/workspace/iotdb/iotdb-client/client-cpp/examples}"
6+
GEN='Visual Studio 15 2017'
7+
8+
TMP=/tmp/vs2017-smoke
9+
rm -rf "${TMP}" && mkdir -p "${TMP}/outer"
10+
unzip -q -o "${PKG_ZIP}" -d "${TMP}/outer"
11+
INNER=$(find "${TMP}/outer" -maxdepth 1 -name 'iotdb-session-cpp-*.zip' ! -name '*.sha512' -print -quit)
12+
unzip -q -o "${INNER}" -d "${TMP}"
13+
PKG_ROOT=$(find "${TMP}" -mindepth 1 -maxdepth 1 -type d -name 'iotdb-session-cpp-*' -print -quit)
14+
echo "PKG_ROOT=${PKG_ROOT}"
15+
16+
cl_path_from_cache() {
17+
grep -m1 'CMAKE_CXX_COMPILER:FILEPATH=' "$1/CMakeCache.txt" | cut -d= -f2 || true
18+
}
19+
20+
echo "=== without -A x64 (packaged examples, reproduces CI bug) ==="
21+
B1=/tmp/vs2017-no-a
22+
rm -rf "${B1}"
23+
cmake -S "${PKG_ROOT}/examples" -B "${B1}" -DIOTDB_SDK_ROOT="${PKG_ROOT}" -G "${GEN}"
24+
echo "cl: $(cl_path_from_cache "${B1}")"
25+
26+
echo "=== with -A x64 (workflow fix on packaged examples) ==="
27+
B2=/tmp/vs2017-a-x64
28+
rm -rf "${B2}"
29+
cmake -S "${PKG_ROOT}/examples" -B "${B2}" -DIOTDB_SDK_ROOT="${PKG_ROOT}" -G "${GEN}" -A x64
30+
echo "cl: $(cl_path_from_cache "${B2}")"
31+
cmake --build "${B2}" --config Release --target SessionExample
32+
33+
echo "=== repo examples CMakeLists (CMAKE fix, no -A on cmd) ==="
34+
B3=/tmp/vs2017-cmakefix
35+
rm -rf "${B3}"
36+
cmake -S "${REPO_EXAMPLES}" -B "${B3}" -DIOTDB_SDK_ROOT="${PKG_ROOT}" -G "${GEN}"
37+
echo "cl: $(cl_path_from_cache "${B3}")"
38+
cmake --build "${B3}" --config Release --target SessionExample
39+
40+
echo "OK: VS2017 x64 example build verified"

.github/workflows/client-cpp-package.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ jobs:
505505
CMAKE_ARGS=(-S "${PKG_ROOT}/examples" -B "${EXAMPLE_BUILD}" -DIOTDB_SDK_ROOT="${PKG_ROOT}")
506506
if [ -n "${CMAKE_GENERATOR:-}" ]; then
507507
CMAKE_ARGS+=(-G "${CMAKE_GENERATOR}")
508+
# windows-x86_64 SDK; VS2017/2019 default to Win32 without -A x64 (see client-cpp pom).
509+
CMAKE_ARGS+=(-A x64)
508510
fi
509511
cmake "${CMAKE_ARGS[@]}"
510512
cmake --build "${EXAMPLE_BUILD}" --config Release

iotdb-client/client-cpp/examples/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
2020
CMAKE_POLICY(SET CMP0091 NEW)
2121

22+
# Windows SDK zips are x86_64; Visual Studio generators (especially VS2017) default to Win32.
23+
IF(CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_GENERATOR_PLATFORM)
24+
SET(CMAKE_GENERATOR_PLATFORM "x64" CACHE STRING "IoTDB C++ SDK is x64-only" FORCE)
25+
ENDIF()
26+
2227
PROJECT(iotdb_cpp_client_examples)
2328

2429
SET(CMAKE_CXX_STANDARD 11)

0 commit comments

Comments
 (0)