Skip to content

Commit

Permalink
Persist STRICT_APPLE_COMPATIBILITY in config.h
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
qmfrederik committed Nov 18, 2024
1 parent 47d02a8 commit bd0e34a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ set(libobjc_HDRS
objc/objc.h
objc/runtime-deprecated.h
objc/runtime.h
objc/slot.h)
objc/slot.h
${PROJECT_BINARY_DIR}/objc/objc-config.h)

set(libobjc_CXX_SRCS
selector_table.cc
Expand Down Expand Up @@ -150,6 +151,9 @@ add_compile_definitions($<$<BOOL:${ENABLE_TRACING}>:WITH_TRACING=1>)
add_compile_definitions($<$<BOOL:${DEBUG_ARC_COMPAT}>:DEBUG_ARC_COMPAT>)
add_compile_definitions($<$<BOOL:${STRICT_APPLE_COMPATIBILITY}>:STRICT_APPLE_COMPATIBILITY>)

configure_file(objc/objc-config.h.in objc/objc-config.h @ONLY)
include_directories("${PROJECT_BINARY_DIR}/objc/")

if (OLDABI_COMPAT)
list(APPEND libobjc_C_SRCS legacy.c abi_version.c statics_loader.c)
add_definitions(-DOLDABI_COMPAT=1)
Expand Down
6 changes: 3 additions & 3 deletions Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ remove_definitions(-D__OBJC_RUNTIME_INTERNAL__=1)

add_library(test_runtime_legacy OBJECT Test.m)
set_target_properties(test_runtime_legacy PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-1.7"
LINKER_LANGUAGE C
)

add_library(test_runtime OBJECT Test.m)
set_target_properties(test_runtime PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-2.0"
LINKER_LANGUAGE C
)
Expand All @@ -123,7 +123,7 @@ function(addtest_flags TEST_NAME FLAGS TEST_SOURCE)
add_test(${TEST_NAME} ${TEST_NAME})
set(ARC "")
set_target_properties(${TEST_NAME} PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR};${PROJECT_BINARY_DIR}/objc/"
COMPILE_FLAGS "-Xclang -fblocks -Xclang -fobjc-exceptions ${FLAGS}"
LINK_FLAGS ${INCREMENTAL}
LINKER_LANGUAGE C
Expand Down
1 change: 1 addition & 0 deletions objc/objc-config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#cmakedefine STRICT_APPLE_COMPATIBILITY @STRICT_APPLE_COMPATIBILITY@
1 change: 1 addition & 0 deletions objc/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma clang system_header
#endif
#include "objc-visibility.h"
#include "objc-config.h"

#ifndef __LIBOBJC_RUNTIME_H_INCLUDED__
#define __LIBOBJC_RUNTIME_H_INCLUDED__
Expand Down

0 comments on commit bd0e34a

Please sign in to comment.