You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
3.9 KiB

1 year ago
  1. # Find the Vision Labs TrackEngine SDK.
  2. # Sets the usual variables expected for find_package scripts:
  3. # TSDK_INCLUDE_DIRS - headers location
  4. # TSDK_LIBRARIES - libraries to link against
  5. # TSDK_FOUND - true if TrackEngine SDK was found.
  6. # This is the directory where the TrackEngine SDK is located.
  7. # By default TSDKDIR environment variable value is taken.
  8. set(TSDK_ROOT "$ENV{TSDKDIR}" CACHE PATH "Vision Labs TrackEngine SDK root directory.")
  9. # Look for headers.
  10. find_path(TSDK_INCLUDE_DIRS
  11. NAMES tsdk/ITrackEngine.h tsdk/ITrackCallbacks tsdk/IStream.h tsdk/TrackEngineDefs.h tsdk/TrackEngineTypes.h
  12. HINTS $ENV{TSDKDIR}
  13. PATHS ${TSDK_ROOT}
  14. PATH_SUFFIXES include)
  15. #message(STATUS "TSDK: TSDK_INCLUDE_DIRS = ${TSDK_INCLUDE_DIRS}.")
  16. # Determine compiler version and architecture.
  17. # ios has no architechture/compiler branching, because only can only use clang
  18. # and if you need multiple architechtures there still compiled into single universal binary
  19. if(MSVC10)
  20. set(TSDK_COMPILER_NAME vs2010)
  21. elseif(MSVC11)
  22. set(TSDK_COMPILER_NAME vs2012)
  23. elseif(MSVC12)
  24. set(TSDK_COMPILER_NAME vs2013)
  25. elseif(MSVC14)
  26. set(TSDK_COMPILER_NAME vs2015)
  27. elseif(CMAKE_COMPILER_IS_GNUCXX)
  28. set(TSDK_COMPILER_NAME gcc4)
  29. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  30. set(TSDK_COMPILER_NAME clang)
  31. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
  32. set(TSDK_COMPILER_NAME clang)
  33. else()
  34. message(SEND_ERROR "Unsupported compiler: ${TSDK_COMPILER_NAME}")
  35. endif()
  36. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  37. set(TSDK_TARGET_NAME x64)
  38. else()
  39. set(TSDK_TARGET_NAME x86)
  40. endif()
  41. # What version of TrackEngine SDK to use.
  42. if(ANDROID)
  43. set(TSDK_LIB_PREFIX ${TSDK_COMPILER_NAME}/${ANDROID_ABI})
  44. else()
  45. set(TSDK_LIB_PREFIX ${TSDK_COMPILER_NAME}/${TSDK_TARGET_NAME})
  46. endif()
  47. # List of all SDK libraries.
  48. set(TSDK_LIB_NAMES
  49. TrackEngineSDK)
  50. set(TSDK_LIB_PATH_SUFFIX lib/${TSDK_LIB_PREFIX})
  51. set(TSDK_BIN_PATH_SUFFIX bin/${TSDK_LIB_PREFIX})
  52. set(TSDK_LIB)
  53. foreach(LIB ${TSDK_LIB_NAMES})
  54. set(LIB_PATH ${LIB}-NOTFOUND)
  55. find_library(LIB_PATH
  56. NAMES ${LIB}
  57. HINTS $ENV{TSDKDIR}
  58. PATHS ${TSDK_ROOT}
  59. PATH_SUFFIXES ${TSDK_LIB_PATH_SUFFIX}
  60. ${TSDK_BIN_PATH_SUFFIX}
  61. NO_DEFAULT_PATH)
  62. list(APPEND TSDK_LIB ${LIB_PATH})
  63. endforeach()
  64. # Find debug libraries (may be missing in your distribution).
  65. set(TSDK_LIBD)
  66. foreach(LIB ${TSDK_LIB_NAMES})
  67. set(LIB_PATH ${LIB}-NOTFOUND)
  68. find_library(LIB_PATH
  69. NAMES ${LIB}d
  70. HINTS $ENV{TSDKDIR}
  71. PATHS ${TSDK_ROOT}
  72. PATH_SUFFIXES ${TSDK_LIB_PATH_SUFFIX}
  73. ${TSDK_BIN_PATH_SUFFIX}
  74. NO_DEFAULT_PATH)
  75. list(APPEND TSDK_LIBD ${LIB_PATH})
  76. endforeach()
  77. # Support the REQUIRED and QUIET arguments, and set TSDK_FOUND if found.
  78. include(FindPackageHandleStandardArgs)
  79. FIND_PACKAGE_HANDLE_STANDARD_ARGS(TSDK DEFAULT_MSG
  80. TSDK_INCLUDE_DIRS)
  81. set(TSDK_LIBRARIES)
  82. if(TSDK_FOUND)
  83. if(TSDK_LIB)
  84. foreach(LIB ${TSDK_LIB})
  85. list(APPEND TSDK_LIBRARIES optimized ${LIB})
  86. endforeach()
  87. message(STATUS "TSDK [INFO]: Release libraries are available.")
  88. elseif(TSDK_LIBD)
  89. message(STATUS "TSDK [WARN]: Release libraries are NOT available.")
  90. else()
  91. message(FATAL_ERROR "TSDK [ERROR]: TrackEngine libraries are NOT available.")
  92. endif()
  93. if(TSDK_LIBD)
  94. foreach(LIB ${TSDK_LIBD})
  95. list(APPEND TSDK_LIBRARIES debug ${LIB})
  96. endforeach()
  97. message(STATUS "TSDK [INFO]: Debug libraries are available.")
  98. elseif(TSDK_LIB)
  99. message(STATUS "TSDK [WARN]: Debug libraries are NOT available.")
  100. else()
  101. message(FATAL_ERROR "TSDK [ERROR]: TrackEngine libraries are NOT available.")
  102. endif()
  103. message(STATUS "TSDK [INFO]: Found TDK in ${TSDK_ROOT}.")
  104. else()
  105. message(STATUS "TSDK [WARN]: TrackEngineSDK was NOT found.")
  106. endif(TSDK_FOUND)
  107. #message(STATUS "TSDK [DEBUG]: TSDK_LIBRARIES = ${TSDK_LIBRARIES}.")
  108. # Don't show in GUI
  109. mark_as_advanced(
  110. TSDK_INCLUDE_DIRS
  111. TSDK_LIBRARIES
  112. TSDK_COMPILER_NAME
  113. TSDK_TARGET_NAME
  114. TSDK_LIB_PREFIX
  115. TSDK_LIB_NAMES
  116. TSDK_LIB_NAMESD
  117. TSDK_LIB
  118. TSDK_LIBD
  119. LIB_PATH
  120. )