Skip to content

Commit

Permalink
Modified the R3D SDK CMake module for macOS
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Kovář <[email protected]>
  • Loading branch information
1div0 committed Apr 16, 2024
1 parent 849e138 commit faf4c96
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/cmake/modules/FindR3DSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,28 @@ include (FindPackageHandleStandardArgs)
# Assuming only C++11 and 64 bit support is needed.
# Set R3DSDK_LIB_NAME before invoking this file to override.
if (NOT DEFINED R3DSDK_LIB_NAME)
set(R3DSDK_LIB_NAME R3DSDKPIC-cpp11)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(R3DSDK_LIB_NAME R3DSDKPIC-cpp11)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(R3DSDK_LIB_NAME R3DSDK-libcpp)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(R3DSDK_LIB_NAME R3DSDK-2017MT)
endif()
endif()


if(DEFINED ENV{R3DSDK_ROOT})
set(R3DSDK_ROOT $ENV{R3DSDK_ROOT})
# message("Using R3D SDK Root: " ${R3DSDK_ROOT})
message("Using R3D SDK Root: " ${R3DSDK_ROOT})
else()
# message("Looking for R3D SDK")
message("Looking for R3D SDK")

# The R3D SDK is supplied as a zip file that you can unpack anywhere.
# So try some plausible locations and hope for the best.
# Use a glob to try and avoid dealing with exact SDK version numbers.

file(GLOB R3DSDK_PATHS "/opt/R3DSDKv*"
"/Library/R3DSDKv*"
"C:/R3DSDKv*"
${CMAKE_CURRENT_SOURCE_DIR}/../R3DSDKv*
${CMAKE_CURRENT_SOURCE_DIR}/../../R3DSDKv*
Expand All @@ -46,27 +53,36 @@ else()
endif()

set(R3DSDK_INCLUDE_DIR ${R3DSDK_ROOT}/Include)
find_library(R3DSDK_LIBRARY NAMES ${R3DSDK_LIB_NAME}
PATHS ${R3DSDK_ROOT}/Lib/linux64/
${R3DSDK_ROOT}/Lib/mac64/
${R3DSDK_ROOT}/Lib/win64/
NO_DEFAULT_PATH
)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
find_library(R3DSDK_LIBRARY NAMES ${R3DSDK_LIB_NAME}
PATHS ${R3DSDK_ROOT}/Lib/linux64/
NO_DEFAULT_PATH
)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
find_library(R3DSDK_LIBRARY NAMES ${R3DSDK_LIB_NAME}
PATHS ${R3DSDK_ROOT}/Lib/mac64/
NO_DEFAULT_PATH
)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
find_library(R3DSDK_LIBRARY NAMES ${R3DSDK_LIB_NAME}
PATHS ${R3DSDK_ROOT}/Lib/win64/
NO_DEFAULT_PATH
)
endif()

# handle the QUIETLY and REQUIRED arguments and set R3DSDK_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(R3DSDK DEFAULT_MSG R3DSDK_LIBRARY R3DSDK_INCLUDE_DIR)


# TODO : Ask somebody with a Mac to add support.
if(R3DSDK_FOUND)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(R3DSDK_LIBRARIES ${R3DSDK_LIBRARY} dl)
set(R3DSDK_RUNTIME_LIBRARIES ${R3DSDK_ROOT}/Redistributable/linux)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(R3DSDK_LIBRARIES ${R3DSDK_LIBRARY} dl)
set(R3DSDK_RUNTIME_LIBRARIES ${R3DSDK_ROOT}/Redistributable/mac)
else()
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(R3DSDK_LIBRARIES ${R3DSDK_LIBRARY})
set(R3DSDK_RUNTIME_LIBRARIES ${R3DSDK_ROOT}/Redistributable/win)
endif()
Expand Down

0 comments on commit faf4c96

Please sign in to comment.