Skip to content

Commit

Permalink
Using try_run to get __MAC_OS_X_VERSION_MAX_ALLOWED
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Nov 4, 2024
1 parent f90887e commit e50f286
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CMake/macosMaxAllowd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <AvailabilityMacros.h>
#include <stdio.h>

int main(int argc, char **argv) {
unsigned int ver = __MAC_OS_X_VERSION_MAX_ALLOWED;
printf("%d.%d.%d", ver/10000, (ver/100)%100, ver%100);
return 0;
}
13 changes: 12 additions & 1 deletion CMake/setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ if(APPLE)
set(HAVE_VSNPRINTF 1)
set(HAVE_SCANDIR 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
try_run(
RUN_RESULT COMPILE_RESULT
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/CMake/macosMaxAllowd.c
RUN_OUTPUT_VARIABLE MAC_OS_X_VERSION_MAX_ALLOWED
)
if (COMPILE_RESULT STREQUAL "FALSE")
set(MAC_OS_X_VERSION_MAX_ALLOWED ${CURRENT_OSX_VERSION})
endif()
# message("MAC_OS_X_VERSION_MAX_ALLOWED: ${MAC_OS_X_VERSION_MAX_ALLOWED}")
# message("COMPILE_RESULT: ${COMPILE_RESULT}")
# message("RUN_RESULT: ${RUN_RESULT}")
if(FLTK_BACKEND_X11)
if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0)) # a.k.a. macOS version ≥ 10.13
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_HAS_THREAD_API_PTHREAD")
Expand All @@ -127,7 +138,7 @@ if(APPLE)
if(${CMAKE_SYSTEM_VERSION} VERSION_GREATER_EQUAL 20.0) # a.k.a. macOS version ≥ 11.0
list(APPEND FLTK_COCOA_FRAMEWORKS "-weak_framework UniformTypeIdentifiers")
endif()
if(${CMAKE_SYSTEM_VERSION} VERSION_GREATER_EQUAL 24.0) # a.k.a. macOS version ≥ 15.0
if(${MAC_OS_X_VERSION_MAX_ALLOWED} VERSION_GREATER_EQUAL 15.0)
list(APPEND FLTK_COCOA_FRAMEWORKS "-weak_framework ScreenCaptureKit")
endif()
endif()
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,5 @@ if(0) # debug built library and fluid targets
endforeach()
message(STATUS "---------------------------------------------------------")
endif()


0 comments on commit e50f286

Please sign in to comment.