CMakeLists.txt 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # minimum required cmake version: 3.1.0
  2. cmake_minimum_required(VERSION 3.1.0)
  3. project(3d-scanner)
  4. # Save the command line compile commands in the build output
  5. set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
  6. # Make project require C++11
  7. include(CheckCXXCompilerFlag)
  8. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  9. CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
  10. if(COMPILER_SUPPORTS_CXX11)
  11. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
  12. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  13. elseif(COMPILER_SUPPORTS_CXX0X)
  14. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
  15. endif()
  16. # commented all Windows related lines, might add later for Windows support
  17. # Simple non robust way to find the librealsense library
  18. # if(WIN32)
  19. # if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
  20. # set(LIBRARY_DIR "C:\\Program Files (x86)\\Intel RealSense SDK 2.0\\lib\\x64") # TODO: Update this variable to correct path - folder where realsense2.lib is found
  21. # set(DLL_DIR "C:\\Program Files (x86)\\Intel RealSense SDK 2.0\\bin\\x64") # TODO: Update this variable to correct path - folder where realsense2.dll is found
  22. # else()
  23. # set(LIBRARY_DIR "C:\\Program Files (x86)\\Intel RealSense SDK 2.0\\lib\\x86") # TODO: Update this variable to correct path - folder where realsense2.lib is found
  24. # set(DLL_DIR "C:\\Program Files (x86)\\Intel RealSense SDK 2.0\\bin\\x86") # TODO: Update this variable to correct path - folder where realsense2.dll is found
  25. # endif()
  26. # set(PROJECT_BINARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/\$\(Configuration\)") # TODO: Update this variable to correct path - folder to which your project will compile
  27. # set(ADDITIONAL_INCLUDE_DIRS "C:\\Program Files (x86)\\Intel RealSense SDK 2.0\\include") # TODO: Update this variable to correct path - folder where librealsense2 folder is found
  28. # endif()
  29. # find_library(REALSENSE2_FOUND realsense2 HINTS ${LIBRARY_DIR} REQUIRED)
  30. # if(NOT REALSENSE2_FOUND)
  31. # SET(REALSENSE2_FOUND "realsense2")
  32. # message(WARN "Failed to find_library(realsense2)")
  33. # endif()
  34. find_package(realsense2 REQUIRED)
  35. find_package(PCL 1.3 REQUIRED)
  36. # find_package(GLFW3 REQUIRED)
  37. # set(SOURCES 3d-scanner.cpp ${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/openglHelper.hpp)
  38. include_directories(${PCL_INCLUDE_DIRS})
  39. link_directories(${PCL_LIBRARY_DIRS})
  40. add_definitions(${PCL_DEFINITIONS})
  41. add_executable(3d-scanner 3d-scanner.cpp pcl-converter.cpp)
  42. include_directories(3d-scanner ${realsense2_INCLUDE_DIR})
  43. # include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdParty)
  44. # include_directories(/opt/homebrew/include/)
  45. # target_link_libraries(3d-scanner ${DEPENDENCIES})
  46. target_link_libraries(3d-scanner ${PCL_LIBRARIES})
  47. target_link_libraries(3d-scanner ${realsense2_LIBRARY})
  48. # target_link_libraries(3d-scanner glfw)
  49. # set_target_properties (3d-scanner PROPERTIES FOLDER Examples)s
  50. # Post Build script to copy realsense2.dll
  51. # if(WIN32)
  52. # message(STATUS "Adding Post build script to copy realsense2.dll to project's binary folder")
  53. # message(STATUS "Will try to copy from ${DLL_DIR} to ${PROJECT_BINARY_OUTPUT_PATH}")
  54. # add_custom_command(TARGET 3d-scanner POST_BUILD # Adds a post-build event to 3d-scanner
  55. # COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
  56. # "${DLL_DIR}/realsense2.dll" # <--this is in-file
  57. # ${PROJECT_BINARY_OUTPUT_PATH}) # <--this is out-file path
  58. # endif()
  59. install(
  60. TARGETS
  61. 3d-scanner
  62. RUNTIME DESTINATION
  63. ${CMAKE_INSTALL_PREFIX}/bin
  64. )