cmake: don't do enable_language(OBJC)

When SDL is included as a subproject, the following error might appear:
```
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_OBJC_COMPILE_OBJECT
```

This is probably because the master project does not see certain OBJC related variables
This commit is contained in:
Anonymous Maarten 2022-10-29 03:14:54 +02:00 committed by Anonymous Maarten
parent b50e429354
commit 04bcc910e9
1 changed files with 5 additions and 1 deletions

View File

@ -92,7 +92,11 @@ macro(LISTTOSTRREV _LIST _OUTPUT)
endforeach() endforeach()
endmacro() endmacro()
if(${CMAKE_VERSION} VERSION_LESS "3.16.0") if(CMAKE_VERSION VERSION_LESS 3.16.0 OR SDL2_SUBPROJECT)
# - CMake versions <3.16 do not support the OBJC language
# - When SDL is built as a subproject and when the main project does not enable OBJC,
# CMake fails due to missing internal CMake variables (CMAKE_OBJC_COMPILE_OBJECT)
# (reproduced with CMake 3.24.2)
macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}") set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}")
set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}") set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}")