Skip to content

Commit

Permalink
Merge pull request #2772 from dgovil/remove-macos-sdk-versions-pxrTar…
Browse files Browse the repository at this point in the history
…gets

Use macOS linkage style for frameworks and system libs

(Internal change: 2303853)
  • Loading branch information
pixar-oss committed Nov 16, 2023
2 parents 1954b02 + fc94305 commit e4248cb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
9 changes: 8 additions & 1 deletion cmake/defaults/Packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ add_definitions(${TBB_DEFINITIONS})
if(WIN32)
# Math functions are linked automatically by including math.h on Windows.
set(M_LIB "")
elseif (APPLE)
# On Apple platforms, its idiomatic to just provide the -l linkage for sdk libs to be portable across SDK versions
set(M_LIB "-lm")
else()
find_library(M_LIB m)
endif()
Expand Down Expand Up @@ -228,7 +231,11 @@ if (PXR_BUILD_IMAGING)
if (POLICY CMP0072)
cmake_policy(SET CMP0072 OLD)
endif()
find_package(OpenGL REQUIRED)
if (APPLE)
set(OPENGL_gl_LIBRARY "-framework OpenGL")
else ()
find_package(OpenGL REQUIRED)
endif()
endif()
# --Metal
if (PXR_ENABLE_METAL_SUPPORT)
Expand Down
4 changes: 2 additions & 2 deletions pxr/imaging/garch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(APPLE)
set(GARCH_GLPLATFORMCONTEXT glPlatformContextDarwin)
set(GARCH_GLPLATFORMDEBUGWINDOW glPlatformDebugWindowDarwin)
set(GARCH_SOURCE_EXTENSION mm)
FIND_LIBRARY(APPKIT_LIBRARY AppKit)
set(GARCH_PLATFORM_LIBRARIES "-framework AppKit")
elseif(X11_FOUND)
set(GARCH_GLPLATFORMCONTEXT glPlatformContextGLX)
set(GARCH_GLPLATFORMDEBUGWINDOW glPlatformDebugWindowGLX)
Expand All @@ -28,7 +28,7 @@ pxr_library(garch
tf
${X11_LIBRARIES}
${OPENGL_gl_LIBRARY}
${APPKIT_LIBRARY}
${GARCH_PLATFORM_LIBRARIES}

INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
Expand Down
3 changes: 1 addition & 2 deletions pxr/imaging/hgiInterop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ list(APPEND optionalLibraries garch)

if (PXR_ENABLE_METAL_SUPPORT)
add_compile_options(-x objective-c++)
FIND_LIBRARY(COREVIDEO_LIBRARY CoreVideo)
list(APPEND optionalLibraries ${COREVIDEO_LIBRARY} hgiMetal)
list(APPEND optionalLibraries "-framework CoreVideo" hgiMetal)
list(APPEND optionalCppFiles metal.mm)
list(APPEND optionalPrivateHeaders metal.h)
elseif(PXR_ENABLE_VULKAN_SUPPORT)
Expand Down
7 changes: 2 additions & 5 deletions pxr/imaging/hgiMetal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ if (NOT ${PXR_BUILD_GPU_SUPPORT} OR NOT ${PXR_ENABLE_METAL_SUPPORT})
return()
endif()

FIND_LIBRARY(METAL_LIBRARY Metal)
FIND_LIBRARY(APPUIKIT_LIBRARY AppKit)

pxr_library(hgiMetal
LIBRARIES
arch
hgi
tf
trace
${METAL_LIBRARY}
${APPUIKIT_LIBRARY}
"-framework Metal"
"-framework AppKit"

PUBLIC_HEADERS
api.h
Expand Down

0 comments on commit e4248cb

Please sign in to comment.