CMakeLists.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. cmake_minimum_required(VERSION 3.5)
  2. project(AllProject)
  3. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
  4. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
  5. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  6. if (NOT DEFINED ${CMAKE_BUILD_TYPE} OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
  7. add_definitions(-DETC_PATH="${CMAKE_SOURCE_DIR}/etc/")
  8. else ()
  9. add_definitions(-DETC_PATH="${CMAKE_INSTALL_PREFIX}/etc/")
  10. endif ()
  11. set(CMAKE_BUILD_TYPE "Debug")
  12. # 第三方库
  13. find_package(PkgConfig REQUIRED)
  14. # pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
  15. # find_path(YAML_CPP_INCLUDE_DIR
  16. # NAMES yaml_cpp.h
  17. # PATHS ${YAML_CPP_INCLUDE_DIRS})
  18. # find_library(YAML_CPP_LIBRARY
  19. # NAMES YAML_CPP
  20. # PATHS ${YAML_CPP_LIBRARY_DIRS})
  21. # if (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5")
  22. # add_definitions(-DHAVE_NEW_YAMLCPP)
  23. # endif (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5")
  24. # add_subdirectory(thirdpart/rs_driver)
  25. # Don't search with REQUIRED as we can continue without gflags.
  26. find_package(gflags 2.2.0)
  27. if (gflags_FOUND)
  28. if (TARGET gflags)
  29. message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${gflags_DIR}")
  30. message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${GFLAGS_LIBRARIES}")
  31. else()
  32. message("-- Detected version of gflags: ${gflags_VERSION} does not define "
  33. "expected gflags CMake target which should be exported by gflags 2.2+. "
  34. "Building without gflags.")
  35. update_cache_variable(GFLAGS OFF)
  36. endif()
  37. else (gflags_FOUND)
  38. message("-- Did not find Google Flags (gflags), Building without gflags.")
  39. update_cache_variable(GFLAGS OFF)
  40. endif (gflags_FOUND)
  41. find_package(Glog)
  42. find_package(PCL REQUIRED)
  43. find_package(Eigen3 REQUIRED)
  44. find_package(OpenCV REQUIRED)
  45. find_package(Protobuf CONFIG)
  46. #if(NOT Protobuf_FOUND)
  47. # find_package(Protobuf REQUIRED)
  48. #endif()
  49. find_package(absl REQUIRED)
  50. set(absl_LIBRARIES
  51. absl::algorithm
  52. absl::base
  53. absl::debugging
  54. absl::flat_hash_map
  55. absl::memory
  56. absl::meta
  57. absl::numeric
  58. absl::str_format
  59. absl::strings
  60. absl::synchronization
  61. absl::time
  62. absl::utility
  63. )
  64. #execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/protoc.sh ${CMAKE_CURRENT_LIST_DIR})
  65. if (EXISTS "${CMAKE_SOURCE_DIR}/include/CMakeLists.txt")
  66. include_directories(${CMAKE_SOURCE_DIR}/include)
  67. add_subdirectory(${CMAKE_SOURCE_DIR}/include)
  68. else ()
  69. message("Can't find dir: " "${CMAKE_SOURCE_DIR}/include/CMakeLists.txt")
  70. endif ()
  71. if (EXISTS "${CMAKE_SOURCE_DIR}/project/CMakeLists.txt")
  72. add_subdirectory(${CMAKE_SOURCE_DIR}/project)
  73. else ()
  74. message("Can't find dir: " "${CMAKE_SOURCE_DIR}/project/CMakeLists.txt")
  75. endif ()