# 定义cmake的最低版本 cmake_minimum_required(VERSION 3.5) # 定义工程名称 project(Project) option(MeasureTest "Enable test" OFF) option(GFLAGS "Enable Google Flags." ON) option(DataToCloud "Enable collect data to mqtt server." ON) option(AlgAddTest "Enable test alg module." OFF) option(ClampSafety "Enable clamp safety." OFF) option(WatchDog "Enable watch dog." ON) option(MeasureNode "Enable Measure node." ON) option(LidarICP "Enable LidarICP" OFF) option(ExecutorTest "Enable ExecutorTest" OFF) option(Cloud2Mat "Enable ExecutorTest" OFF) # 指定安装目录 message(${CMAKE_BUILD_TYPE}) if (${CMAKE_BUILD_TYPE} STREQUAL "Release") set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/build/out ) message("ON test, set install path to ${PROJECT_SOURCE_DIR}/build/out") add_definitions(-DETC_PATH="${PROJECT_SOURCE_DIR}/etc/") else () set(CMAKE_INSTALL_PREFIX # /out ${PROJECT_SOURCE_DIR}/build/out ) message("OFF test, set install path to ${PROJECT_SOURCE_DIR}/build/out") add_definitions(-DETC_PATH="${CMAKE_INSTALL_PREFIX}/etc/") endif () SET (CMAKE_EXPORT_COMPILE_COMMANDS ON) set (CMAKE_BUILD_TYPE "RELEASE") # 打印工程定级目录(非必要) message("project path: " ${PROJECT_SOURCE_DIR}) execute_process(COMMAND bash ${PROJECT_SOURCE_DIR}/proto.sh ${PROJECT_SOURCE_DIR}) # 第三方库 find_package(PkgConfig REQUIRED) pkg_check_modules(nanomsg REQUIRED nanomsg) pkg_check_modules(YAML_CPP REQUIRED yaml-cpp) find_path(YAML_CPP_INCLUDE_DIR NAMES yaml_cpp.h PATHS ${YAML_CPP_INCLUDE_DIRS}) find_library(YAML_CPP_LIBRARY NAMES YAML_CPP PATHS ${YAML_CPP_LIBRARY_DIRS}) if (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5") add_definitions(-DHAVE_NEW_YAMLCPP) endif (NOT ${YAML_CPP_VERSION} VERSION_LESS "0.5") add_subdirectory(thirdpart/rs_driver) # Don't search with REQUIRED as we can continue without gflags. find_package(gflags 2.2.0) if (gflags_FOUND) if (TARGET gflags) message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${gflags_DIR}") message("-- Found Google Flags (gflags) version ${gflags_VERSION}: ${GFLAGS_LIBRARIES}") else() message("-- Detected version of gflags: ${gflags_VERSION} does not define " "expected gflags CMake target which should be exported by gflags 2.2+. " "Building without gflags.") update_cache_variable(GFLAGS OFF) endif() else (gflags_FOUND) message("-- Did not find Google Flags (gflags), Building without gflags.") update_cache_variable(GFLAGS OFF) endif (gflags_FOUND) find_package(PCL REQUIRED) find_package(Eigen3 REQUIRED) find_package(Ceres REQUIRED) find_package(OpenCV REQUIRED) find_package(rs_driver REQUIRED) find_package(Protobuf REQUIRED) include_directories( ${rs_driver_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${CERES_INCLUDE_DIR} ${PCL_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/Modules ) # 添加子目录CMAKE add_subdirectory(include) if(DataToCloud) add_subdirectory(Modules/DataToCloud) endif () if(AlgAddTest) add_subdirectory(Modules/AlgAddTest) endif () if(ClampSafety) add_subdirectory(Modules/ClampSafety) endif () if(WatchDog) add_subdirectory(Modules/WatchDog) endif () if(MeasureNode) include_directories(${PROJECT_SOURCE_DIR}/Modules/MeasureNode) add_subdirectory(Modules/MeasureNode) add_subdirectory(Modules/MeasureNodeAlgTest) endif () if(LidarICP) include_directories(${PROJECT_SOURCE_DIR}/Modules/LidarICP) add_subdirectory(Modules/LidarICP) endif () if(ExecutorTest) include_directories(${PROJECT_SOURCE_DIR}/Modules/ExecutorTest) add_subdirectory(Modules/ExecutorTest) endif () if(Cloud2Mat) add_subdirectory(Modules/Cloud2Mat) endif () install(DIRECTORY ${PROJECT_SOURCE_DIR}/etc DESTINATION ${CMAKE_INSTALL_PREFIX} )