diff --git a/cmake/defaults/Packages.cmake b/cmake/defaults/Packages.cmake index 7ae4b287f6..c782245b80 100644 --- a/cmake/defaults/Packages.cmake +++ b/cmake/defaults/Packages.cmake @@ -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() @@ -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) diff --git a/pxr/imaging/garch/CMakeLists.txt b/pxr/imaging/garch/CMakeLists.txt index a2fefbf523..1b32198b17 100644 --- a/pxr/imaging/garch/CMakeLists.txt +++ b/pxr/imaging/garch/CMakeLists.txt @@ -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) @@ -28,7 +28,7 @@ pxr_library(garch tf ${X11_LIBRARIES} ${OPENGL_gl_LIBRARY} - ${APPKIT_LIBRARY} + ${GARCH_PLATFORM_LIBRARIES} INCLUDE_DIRS ${Boost_INCLUDE_DIRS} diff --git a/pxr/imaging/hgiInterop/CMakeLists.txt b/pxr/imaging/hgiInterop/CMakeLists.txt index 12d14cc7b8..a6cb1edad0 100644 --- a/pxr/imaging/hgiInterop/CMakeLists.txt +++ b/pxr/imaging/hgiInterop/CMakeLists.txt @@ -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) diff --git a/pxr/imaging/hgiMetal/CMakeLists.txt b/pxr/imaging/hgiMetal/CMakeLists.txt index fef4a4fe0c..a63fd72639 100644 --- a/pxr/imaging/hgiMetal/CMakeLists.txt +++ b/pxr/imaging/hgiMetal/CMakeLists.txt @@ -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