Skip to content

Commit 5df6e80

Browse files
committed
Fix libc++ headers for older macOS SDKs
1 parent d51bc5e commit 5df6e80

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,21 @@ if(APPLE)
5252
find_path(IOKit_INCLUDE_DIR NAMES IOKitLib.h HINTS ${IOKit_INC_SEARCH_PATH} ${IOKit_PKGC_INCLUDE_DIRS} PATH_SUFFIXES IOKit)
5353
list(APPEND JSSC_ADDITIONAL_INCLUDES ${IOKit_INCLUDE_DIR})
5454
endif()
55+
# Handle edge-case with legacy versioned SDK headers (e.g. usr/include/c++/4.2.1)
56+
if(CMAKE_OSX_SYSROOT)
57+
file(GLOB std_versions "${CMAKE_OSX_SYSROOT}/usr/include/c++/*")
58+
foreach(std_version IN LISTS std_versions)
59+
if("${std_version}" MATCHES "/v[0-9]*$")
60+
# Ignore c++/v1 (should already be included)
61+
continue()
62+
elseif(IS_DIRECTORY "${std_version}")
63+
message(STATUS "Adding legacy include path: ${std_version}")
64+
list(APPEND JSSC_ADDITIONAL_INCLUDES "${std_version}")
65+
endif()
66+
endforeach()
67+
endif()
5568
endif()
5669

57-
set(CMAKE_CXX_STANDARD 11)
58-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
59-
6070
# Statically link gcc/c++
6171
if(MSVC)
6272
# /MT = Multithread, static version of the run-time library

0 commit comments

Comments
 (0)