Skip to content

Commit

Permalink
CMake for macOS platform: improve handling of -framework link arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ManoloFLTK committed Mar 24, 2024
1 parent 1434bc2 commit 4742d83
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
9 changes: 3 additions & 6 deletions CMake/fl_add_library.cmake
Expand Up @@ -153,12 +153,9 @@ function(fl_add_library LIBNAME LIBTYPE SOURCES)
)

if(APPLE AND NOT FLTK_BACKEND_X11)
target_link_libraries(${TARGET_NAME} PUBLIC "-framework Cocoa")
if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 20.0.0)) # a.k.a. macOS version ≥ 11.0
if (NOT (CMAKE_OSX_ARCHITECTURES STREQUAL "ppc" OR CMAKE_OSX_ARCHITECTURES STREQUAL "i386"))
target_link_libraries(${TARGET_NAME} PUBLIC "-framework UniformTypeIdentifiers")
endif()
endif()
foreach(item ${FLTK_COCOA_FRAMEWORKS})
target_link_libraries(${TARGET_NAME} PUBLIC "${item}")
endforeach()
endif()

# we must link fltk with cairo if Cairo or Wayland is enabled (or both)
Expand Down
6 changes: 2 additions & 4 deletions CMake/setup.cmake
Expand Up @@ -124,12 +124,10 @@ if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_HAS_THREAD_API_PTHREAD")
endif(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 17.0.0))
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Cocoa")
set(FLTK_COCOA_FRAMEWORKS "-framework Cocoa")
if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 20.0.0)) # a.k.a. macOS version ≥ 11.0
if (NOT (CMAKE_OSX_ARCHITECTURES STREQUAL "ppc" OR CMAKE_OSX_ARCHITECTURES STREQUAL "i386"))
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework UniformTypeIdentifiers")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework UniformTypeIdentifiers")
list(APPEND FLTK_COCOA_FRAMEWORKS "-framework UniformTypeIdentifiers")
endif()
endif()
endif(FLTK_BACKEND_X11)
Expand Down
7 changes: 1 addition & 6 deletions CMake/variables.cmake
Expand Up @@ -43,12 +43,7 @@ endif(DEBUG_VARIABLES_CMAKE)
if(WIN32)
list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32 -lws2_32)
elseif(APPLE AND NOT FLTK_BACKEND_X11)
list(APPEND FLTK_LDLIBS "-framework Cocoa")
if(NOT(${CMAKE_SYSTEM_VERSION} VERSION_LESS 20.0.0)) # a.k.a. macOS version ≥ 11.0
if (NOT (CMAKE_OSX_ARCHITECTURES STREQUAL "ppc" OR CMAKE_OSX_ARCHITECTURES STREQUAL "i386"))
list(APPEND FLTK_LDLIBS "-framework UniformTypeIdentifiers")
endif()
endif()
list(APPEND FLTK_LDLIBS ${FLTK_COCOA_FRAMEWORKS})
elseif(FLTK_BACKEND_WAYLAND)
list(APPEND FLTK_LDLIBS "-lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1")
if(USE_SYSTEM_LIBDECOR)
Expand Down

0 comments on commit 4742d83

Please sign in to comment.