Skip to content

Commit 4e0a2ce

Browse files
committed
Fix cputypetest for iOS.
1 parent 5a1f9e6 commit 4e0a2ce

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
88
find_package(Bash REQUIRED)
99

1010
include(cmake/version.cmake)
11-
include(cmake/cputypetest.cmake)
1211

1312
project(KTX-Software
1413
VERSION ${KTX_VERSION}
@@ -23,6 +22,8 @@ include(CMakeDependentOption)
2322
include(cmake/mkvk.cmake)
2423
include(cmake/xcode.cmake)
2524

25+
include(cmake/cputypetest.cmake)
26+
2627
# OPTIONS
2728

2829
if( IOS OR EMSCRIPTEN )

cmake/cputypetest.cmake

+18-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ x86
3434
x86
3535
3636
#elif TARGET_CPU_X86_64
37-
3837
#undef x86_64
3938
x86_64
4039
@@ -124,12 +123,24 @@ function(set_target_processor_type out)
124123
ERROR_QUIET
125124
)
126125
else()
127-
set(C_PREPROCESS ${CMAKE_C_COMPILER} -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -E -P)
128-
execute_process(
129-
COMMAND ${C_PREPROCESS} "${CMAKE_BINARY_DIR}/cputypetest.c"
130-
OUTPUT_VARIABLE processor
131-
OUTPUT_STRIP_TRAILING_WHITESPACE
132-
)
126+
if(APPLE AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
127+
# No other Apple systems are x64_64. When configuring for iOS, etc.
128+
# CMAKE_C_COMPILER points at the HOST compiler - I can't find
129+
# definitive documentation of what is supposed to happen - the
130+
# test program above returns x86_64. Since we don't care what
131+
# type of ARM processor arbitrarily set armv8 for these systems.
132+
set(processor armv8)
133+
else()
134+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
135+
set(TC_INCLUDE_DIR -I ${CMAKE_OSX_SYSROOT}/usr/include)
136+
endif()
137+
set(C_PREPROCESS ${CMAKE_C_COMPILER} ${TC_INCLUDE_DIR} -E -P)
138+
execute_process(
139+
COMMAND ${C_PREPROCESS} "${CMAKE_BINARY_DIR}/cputypetest.c"
140+
OUTPUT_VARIABLE processor
141+
OUTPUT_STRIP_TRAILING_WHITESPACE
142+
)
143+
endif()
133144
endif()
134145

135146
string(STRIP "${processor}" processor)

0 commit comments

Comments
 (0)