Skip to content

Commit 0c1a893

Browse files
committed
Persist STRICT_APPLE_COMPATIBILITY in config.h
On Windows, the value of `STRICT_APPLE_COMPATIBILITY` determines whether `BOOL` is a char or an int. This value must be consistent across all libraries that use libobjc2. Rather than requiring all libraries to explicitly define `STRICT_APPLE_COMPATIBILITY`, persist the value of `STRICT_APPLE_COMPATIBILITY` in `objc-config.h` and include that in `runtime.h`.
1 parent a069727 commit 0c1a893

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ set(libobjc_HDRS
9999
objc/objc.h
100100
objc/runtime-deprecated.h
101101
objc/runtime.h
102-
objc/slot.h)
102+
objc/slot.h
103+
${PROJECT_BINARY_DIR}/objc/objc-config.h)
103104

104105
set(libobjc_CXX_SRCS
105106
selector_table.cc
@@ -150,6 +151,9 @@ add_compile_definitions($<$<BOOL:${ENABLE_TRACING}>:WITH_TRACING=1>)
150151
add_compile_definitions($<$<BOOL:${DEBUG_ARC_COMPAT}>:DEBUG_ARC_COMPAT>)
151152
add_compile_definitions($<$<BOOL:${STRICT_APPLE_COMPATIBILITY}>:STRICT_APPLE_COMPATIBILITY>)
152153

154+
configure_file(objc/objc-config.h.in objc/objc-config.h @ONLY)
155+
include_directories("${PROJECT_BINARY_DIR}/objc/")
156+
153157
if (OLDABI_COMPAT)
154158
list(APPEND libobjc_C_SRCS legacy.c abi_version.c statics_loader.c)
155159
add_definitions(-DOLDABI_COMPAT=1)

Test/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ remove_definitions(-D__OBJC_RUNTIME_INTERNAL__=1)
9898

9999
add_library(test_runtime_legacy OBJECT Test.m)
100100
set_target_properties(test_runtime_legacy PROPERTIES
101-
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
101+
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
102102
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-1.7"
103103
LINKER_LANGUAGE C
104104
)
105105

106106
add_library(test_runtime OBJECT Test.m)
107107
set_target_properties(test_runtime PROPERTIES
108-
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
108+
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
109109
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-2.0"
110110
LINKER_LANGUAGE C
111111
)
@@ -123,7 +123,7 @@ function(addtest_flags TEST_NAME FLAGS TEST_SOURCE)
123123
add_test(${TEST_NAME} ${TEST_NAME})
124124
set(ARC "")
125125
set_target_properties(${TEST_NAME} PROPERTIES
126-
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
126+
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
127127
COMPILE_FLAGS "-Xclang -fblocks -Xclang -fobjc-exceptions ${FLAGS}"
128128
LINK_FLAGS ${INCREMENTAL}
129129
LINKER_LANGUAGE C

objc/objc-config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#cmakedefine STRICT_APPLE_COMPATIBILITY @STRICT_APPLE_COMPATIBILITY@

objc/runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#pragma clang system_header
33
#endif
44
#include "objc-visibility.h"
5+
#include "objc-config.h"
56

67
#ifndef __LIBOBJC_RUNTIME_H_INCLUDED__
78
#define __LIBOBJC_RUNTIME_H_INCLUDED__

0 commit comments

Comments
 (0)