Skip to content

Commit ef5a8be

Browse files
author
Aliaksandr Adziareika
committed
Move 32-bits Linux specific flags to CMakeLists
1 parent d27fb0f commit ef5a8be

File tree

3 files changed

+133
-46
lines changed

3 files changed

+133
-46
lines changed

.github/actions/build-sdk/action.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,38 @@ runs:
159159
CMAKE_BUILD_TYPE: ${{ inputs.cmake-build-type }}
160160
CMAKE_GENERATOR: ${{ inputs.cmake-generator }}
161161
CI_GIT_BRANCH: ${{ github.head_ref }}
162+
ENABLE_32BIT: ${{ inputs.enable-32bit }}
162163
run: |
163164
CMAKE_BUILD_PATH="build"
164165
mkdir -p "$CMAKE_BUILD_PATH"
165166
CMAKE_BUILD_PATH=$(cd "$CMAKE_BUILD_PATH" && pwd)
166167
echo "build-path=$CMAKE_BUILD_PATH" >> "$GITHUB_OUTPUT"
167168
169+
# Detect Visual Studio generator
170+
IS_VISUAL_STUDIO=false
171+
if [[ "$CMAKE_GENERATOR" == "Visual Studio"* ]]; then
172+
IS_VISUAL_STUDIO=true
173+
fi
174+
168175
CMAKE_ARGS=""
169176
if [ -n "${{ inputs.cmake-config-preset }}" ]; then
170177
CMAKE_ARGS="--preset ${{ inputs.cmake-config-preset }}"
171178
fi
172179
173180
# Visual Studio specific options
174-
if [[ "$CMAKE_GENERATOR" == "Visual Studio"* ]]; then
181+
if [ "$IS_VISUAL_STUDIO" == "true" ]; then
175182
CMAKE_ARGS="$CMAKE_ARGS -DOPENDAQ_MSVC_SINGLE_PROCESS_BUILD=ON"
176183
fi
177184
185+
# 32-bit build configuration
186+
if [ "$ENABLE_32BIT" == "true" ]; then
187+
if [ "$IS_VISUAL_STUDIO" == "true" ]; then
188+
CMAKE_ARGS="$CMAKE_ARGS -A Win32"
189+
else
190+
CMAKE_ARGS="$CMAKE_ARGS -DOPENDAQ_FORCE_COMPILE_32BIT=ON"
191+
fi
192+
fi
193+
178194
if [ -n "$CMAKE_BUILD_TYPE" ]; then
179195
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE"
180196
fi
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index c26f3257..d9e4223c 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -22,6 +22,34 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
6+
message(FATAL_ERROR "In-source build is not supported! Please choose a separate build directory e.g.: /build/x64/msvc")
7+
endif()
8+
9+
+# 32-bit Linux cross-compilation setup (must be before project())
10+
+if(OPENDAQ_FORCE_COMPILE_32BIT AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
11+
+ message(STATUS "Configuring 32-bit Linux build")
12+
+ message(STATUS " CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
13+
+ message(STATUS " CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
14+
+ message(STATUS " CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
15+
+
16+
+ set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -m32" CACHE STRING "" FORCE)
17+
+ set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -m32" CACHE STRING "" FORCE)
18+
+ set(CMAKE_ASM_FLAGS_INIT "${CMAKE_ASM_FLAGS_INIT} -m32" CACHE STRING "" FORCE)
19+
+
20+
+ # Help CMake find 32-bit libraries
21+
+ list(APPEND CMAKE_LIBRARY_PATH /usr/lib/i386-linux-gnu)
22+
+
23+
+ if(NOT CMAKE_SYSTEM_NAME)
24+
+ set(CMAKE_SYSTEM_NAME Linux CACHE STRING "" FORCE)
25+
+ message(STATUS " -> Set CMAKE_SYSTEM_NAME=Linux")
26+
+ endif()
27+
+ if(NOT CMAKE_SYSTEM_PROCESSOR)
28+
+ set(CMAKE_SYSTEM_PROCESSOR i686 CACHE STRING "" FORCE)
29+
+ message(STATUS " -> Set CMAKE_SYSTEM_PROCESSOR=i686")
30+
+ endif()
31+
+
32+
+ message(STATUS " CMAKE_C_FLAGS_INIT: ${CMAKE_C_FLAGS_INIT}")
33+
+ message(STATUS " CMAKE_CXX_FLAGS_INIT: ${CMAKE_CXX_FLAGS_INIT}")
34+
+ message(STATUS " CMAKE_ASM_FLAGS_INIT: ${CMAKE_ASM_FLAGS_INIT}")
35+
+endif()
36+
+
37+
project(${SDK_NAME}
38+
LANGUAGES CXX
39+
VERSION ${OPENDAQ_PACKAGE_VERSION}
40+
@@ -369,9 +397,15 @@ if ((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) AND NOT MSVC)
41+
endif()
42+
43+
if(OPENDAQ_FORCE_COMPILE_32BIT)
44+
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
45+
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
46+
set(BUILD_64Bit OFF)
47+
+
48+
+ # Linux GCC 32-bit specific flags (note: -m32 is set before project() via CMAKE_*_FLAGS_INIT)
49+
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCXX)
50+
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -ffloat-store -Wno-error=stringop-overflow")
51+
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
52+
+ # Disable bcrypt ASM for i386 (x86.S not compatible)
53+
+ add_compile_definitions(OPENDAQ_BCRYPT_BF_ASM_DISABLE)
54+
+ endif()
55+
endif()
56+
57+
# The flag -fuse-ld=lld is needed on MinGW where the default linker is hardly usable.

.github/workflows/ci-sandbox.yml

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ jobs:
5050
runs-on: windows-latest
5151
name: ${{ matrix.name }}
5252
# if: ${{ ! github.event.pull_request.draft }}
53-
if: false
5453

5554
concurrency:
5655
group: ${{ github.workflow }}-${{ github.head_ref }}-${{ matrix.name }}
@@ -68,6 +67,9 @@ jobs:
6867
cmake-defines:
6968
cmake-generator: "Visual Studio 17 2022"
7069
enable-tests: true
70+
cc:
71+
cxx:
72+
disable-ccache : true
7173
# - name: Windows VS 2022 x64 Debug
7274
# cmake-build-type: Debug
7375
# cmake-defines:
@@ -76,22 +78,24 @@ jobs:
7678
# disable-ccache : true
7779
- name: Windows VS 2022 Win32 Release
7880
cmake-build-type: Release
79-
cmake-defines: -A Win32
81+
cmake-defines:
8082
cmake-generator: "Visual Studio 17 2022"
8183
enable-32bit: true
8284
enable-tests: true
85+
cc:
86+
cxx:
8387
disable-ccache : true
8488

85-
- name: Windows Clang Release
86-
cc: clang
87-
cxx: clang++
88-
cmake-build-type: Release
89-
cmake-defines: >-
90-
-DCMAKE_C_COMPILER_LAUNCHER=ccache
91-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
92-
cmake-generator: Ninja
93-
enable-tests: true
94-
disable-ccache : false
89+
# - name: Windows Clang Release
90+
# cc: clang
91+
# cxx: clang++
92+
# cmake-build-type: Release
93+
# cmake-defines: >-
94+
# -DCMAKE_C_COMPILER_LAUNCHER=ccache
95+
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
96+
# cmake-generator: Ninja
97+
# enable-tests: true
98+
# disable-ccache : false
9599

96100
# - name: Windows GCC Release
97101
# cc: gcc
@@ -107,31 +111,31 @@ jobs:
107111
# enable-tests: false
108112
# disable-ccache: true
109113

110-
- name: Windows Intel oneAPI Release
111-
cc: icx
112-
cxx: icx
113-
cmake-build-type: Release
114-
cmake-defines: >-
115-
-DCMAKE_C_COMPILER_LAUNCHER=ccache
116-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
117-
cmake-generator: Ninja
118-
enable-32bit: false
119-
enable-tests: true
120-
disable-ccache: false
114+
# - name: Windows Intel oneAPI Release
115+
# cc: icx
116+
# cxx: icx
117+
# cmake-build-type: Release
118+
# cmake-defines: >-
119+
# -DCMAKE_C_COMPILER_LAUNCHER=ccache
120+
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
121+
# cmake-generator: Ninja
122+
# enable-32bit: false
123+
# enable-tests: true
124+
# disable-ccache: false
121125

122-
- name: Windows Intel oneAPI Release (No bindings)
123-
cc: icx
124-
cxx: icx
125-
cmake-build-type: Release
126-
cmake-defines: >-
127-
-DCMAKE_C_COMPILER_LAUNCHER=ccache
128-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
129-
-DOPENDAQ_GENERATE_PYTHON_BINDINGS=OFF
130-
-DOPENDAQ_GENERATE_CSHARP_BINDINGS=OFF
131-
cmake-generator: Ninja
132-
enable-32bit: false
133-
enable-tests: true
134-
disable-ccache: false
126+
# - name: Windows Intel oneAPI Release (No bindings)
127+
# cc: icx
128+
# cxx: icx
129+
# cmake-build-type: Release
130+
# cmake-defines: >-
131+
# -DCMAKE_C_COMPILER_LAUNCHER=ccache
132+
# -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
133+
# -DOPENDAQ_GENERATE_PYTHON_BINDINGS=OFF
134+
# -DOPENDAQ_GENERATE_CSHARP_BINDINGS=OFF
135+
# cmake-generator: Ninja
136+
# enable-32bit: false
137+
# enable-tests: true
138+
# disable-ccache: false
135139

136140

137141
steps:
@@ -218,24 +222,34 @@ jobs:
218222
fail-fast: false
219223
matrix:
220224
include:
221-
- name: Ubuntu Latest gcc 32-bit Release
225+
- name: Ubuntu Latest gcc x86_32 Release
222226
cc: gcc
223227
cxx: g++
224-
additional-packages: g++-9
228+
additional-packages:
225229
cmake-generator: Ninja
226230
cmake-build-type: Release
227231
cmake-defines: >-
228232
-DOPENDAQ_GENERATE_PYTHON_BINDINGS=OFF
229233
-DOPENDAQ_GENERATE_CSHARP_BINDINGS=OFF
230-
-DCMAKE_SYSTEM_NAME=Linux
231-
-DCMAKE_SYSTEM_PROCESSOR=i686
232-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
233-
"-DCMAKE_C_FLAGS_INIT=-m32 -fPIC -DOPENDAQ_BCRYPT_BF_ASM_DISABLE"
234-
"-DCMAKE_CXX_FLAGS_INIT=-m32 -fPIC -Wno-error=stringop-overflow -ffloat-store"
235-
-DCMAKE_ASM_FLAGS_INIT=-m32
236-
disable-ccache : true
234+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
235+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
236+
disable-ccache : false
237237
enable_32bit: true
238238

239+
- name: Ubuntu Latest gcc x86_64 Release
240+
cc: gcc
241+
cxx: g++
242+
additional-packages:
243+
cmake-generator: Ninja
244+
cmake-build-type: Release
245+
cmake-defines: >-
246+
-DOPENDAQ_GENERATE_PYTHON_BINDINGS=OFF
247+
-DOPENDAQ_GENERATE_CSHARP_BINDINGS=OFF
248+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
249+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
250+
disable-ccache : false
251+
enable_32bit: false
252+
239253
# - name: Ubuntu Latest gcc-9 Release
240254
# cc: gcc-9
241255
# cxx: g++-9

0 commit comments

Comments
 (0)