Skip to content

Commit 2466c57

Browse files
committed
Windows: Support building with strict compatibility
This commit adds the `STRICT_APPLE_COMPATIBILITY` CMake option which will force `BOOL` to defined as an `signed char` on Windows instead of an `int`, as having different types for `BOOL` on different platforms creates serialization issues. On MSYS, the `BOOL` type is defined in` minwindef` like this: ``` typedef int BOOL; ``` To prevent this header from defining a conflicting `BOOL` type, this commit also defines `__OBJC_BOOL`.
1 parent a9d0313 commit 2466c57

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ jobs:
213213
os: [ windows-2019 ]
214214
msystem: [ ucrt64, mingw64, clang64 ]
215215
build-type: [ Release, Debug ]
216+
strict-apple-compatibility: [ ON, OFF ]
216217
include:
217218
- msystem: ucrt64
218219
package-prefix: ucrt-x86_64
@@ -226,7 +227,7 @@ jobs:
226227
# Don't abort runners if a single one fails
227228
fail-fast: false
228229
runs-on: ${{ matrix.os }}
229-
name: ${{ matrix.os }} ${{ matrix.msystem }} ${{ matrix.build-type}}
230+
name: ${{ matrix.os }} ${{ matrix.msystem }} ${{ matrix.build-type}} (Strict Apple compatibility ${{ matrix.strict-apple-compatibility }})
230231
defaults:
231232
run:
232233
shell: msys2 {0}
@@ -241,7 +242,7 @@ jobs:
241242
run: |
242243
mkdir build
243244
cd build
244-
${{ matrix.cmake-flags }} cmake .. -DTESTS=ON -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
245+
${{ matrix.cmake-flags }} cmake .. -DTESTS=ON -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DSTRICT_APPLE_COMPATIBILITY=${{ matrix.strict-apple-compatibility }}
245246
- name: Build
246247
working-directory: build
247248
run: |
@@ -256,7 +257,7 @@ jobs:
256257
cmake --install . --prefix=../dist
257258
- uses: actions/upload-artifact@v4
258259
with:
259-
name: ${{ matrix.msystem }}-${{ matrix.build-type }}
260+
name: ${{ matrix.msystem }}-${{ matrix.build-type }}-compat-${{ matrix.strict-apple-compatibility }}
260261
path: dist/
261262

262263
android:

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ endif()
4545
message(STATUS "Architecture as detected by CMake: ${CMAKE_SYSTEM_PROCESSOR}")
4646

4747
# Build configuration
48-
add_compile_definitions(GNUSTEP __OBJC_RUNTIME_INTERNAL__=1)
48+
add_compile_definitions(GNUSTEP __OBJC_RUNTIME_INTERNAL__=1 __OBJC_BOOL)
4949

5050
set(CMAKE_CXX_STANDARD 17)
5151

@@ -140,13 +140,15 @@ option(DEBUG_ARC_COMPAT
140140
option(ENABLE_OBJCXX "Enable support for Objective-C++" ON)
141141
option(TESTS "Enable building the tests")
142142
option(EMBEDDED_BLOCKS_RUNTIME "Include an embedded blocks runtime, rather than relying on libBlocksRuntime to supply it" ON)
143+
option(STRICT_APPLE_COMPATIBILITY "Use strict Apple compatibility, always defining BOOL as signed char" OFF)
143144

144145
# For release builds, we disable spamming the terminal with warnings about
145146
# selector type mismatches
146147
add_compile_definitions($<$<CONFIG:Release>:NO_SELECTOR_MISMATCH_WARNINGS>)
147148
add_compile_definitions($<$<BOOL:${TYPE_DEPENDENT_DISPATCH}>:TYPE_DEPENDENT_DISPATCH>)
148149
add_compile_definitions($<$<BOOL:${ENABLE_TRACING}>:WITH_TRACING=1>)
149150
add_compile_definitions($<$<BOOL:${DEBUG_ARC_COMPAT}>:DEBUG_ARC_COMPAT>)
151+
add_compile_definitions($<$<BOOL:${STRICT_APPLE_COMPATIBILITY}>:STRICT_APPLE_COMPATIBILITY>)
150152

151153
if (OLDABI_COMPAT)
152154
list(APPEND libobjc_C_SRCS legacy.c abi_version.c statics_loader.c)

0 commit comments

Comments
 (0)