Skip to content

Instantly share code, notes, and snippets.

@tresf
Created April 28, 2025 18:59
Show Gist options
  • Save tresf/9e5043d431e5f9089a9b2f00c0a6fb64 to your computer and use it in GitHub Desktop.
Save tresf/9e5043d431e5f9089a9b2f00c0a6fb64 to your computer and use it in GitHub Desktop.
MacOSX10.9.sdk: Find c++ standard headers in legacy location
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7ab0cb..6114abf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,19 @@ if(APPLE)
find_path(IOKit_INCLUDE_DIR NAMES IOKitLib.h HINTS ${IOKit_INC_SEARCH_PATH} ${IOKit_PKGC_INCLUDE_DIRS} PATH_SUFFIXES IOKit)
list(APPEND JSSC_ADDITIONAL_INCLUDES ${IOKit_INCLUDE_DIR})
endif()
+ # Handle edge-case with legacy versioned SDK headers (e.g. usr/include/c++/4.2.1)
+ if(CMAKE_OSX_SYSROOT)
+ file(GLOB std_versions "${CMAKE_OSX_SYSROOT}/usr/include/c++/*")
+ foreach(std_version IN LISTS std_versions)
+ if("${std_version}" MATCHES "/v[0-9]*$")
+ # Ignore c++/v1 (should already be included)
+ continue()
+ elseif(IS_DIRECTORY "${std_version}")
+ message(STATUS "Adding legacy include path: ${std_version}")
+ list(APPEND JSSC_ADDITIONAL_INCLUDES "${std_version}")
+ endif()
+ endforeach()
+ endif()
endif()
# Statically link gcc/c++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment