|
| 1 | +############################################################################## |
| 2 | +# CMAKE CONFIGURATION |
| 3 | +############################################################################## |
| 4 | +cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) |
| 5 | + |
| 6 | +# set project name |
| 7 | +project(pcl-visualizer VERSION 1.0.0) |
| 8 | + |
| 9 | +# set build type = Debug mode |
| 10 | +set(CMAKE_BUILD_TYPE Release) |
| 11 | + |
| 12 | +message("\n" "=========================================") |
| 13 | +message("Project: ${PROJECT_NAME} ") |
| 14 | +message("=========================================") |
| 15 | + |
| 16 | +# set the include directive in the same project folder |
| 17 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 18 | + |
| 19 | +# set corresponding package directories |
| 20 | +set(PCL_DIR /opt/pcl-1.8.1/build) |
| 21 | + |
| 22 | +# Include dependencies of pcl 1.8.1 in project directorie |
| 23 | +set(CMAKE_MODULE_PATH ${PCL_DIR}/../cmake/Modules) |
| 24 | + |
| 25 | +# set cmake for use std c++11 and output executable folder to bin |
| 26 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
| 27 | +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) |
| 28 | + |
| 29 | +############################################################################## |
| 30 | +# PACKAGES |
| 31 | +############################################################################## |
| 32 | +message("Finding PCL package...") |
| 33 | + |
| 34 | +message("***********************") |
| 35 | +message("PCL PACKAGE") |
| 36 | +message("***********************") |
| 37 | + |
| 38 | +find_package(PCL 1.8 PATHS ${PCL_DIR}) |
| 39 | +if(PCL_FOUND) |
| 40 | + message(STATUS "PCL status:") |
| 41 | + message(STATUS " version: ${PCL_VERSION}") |
| 42 | + message(STATUS " pcl directorie: ${PCL_INCLUDE_DIRS}") |
| 43 | +else() |
| 44 | + message(WARNING " PCL 1.8 not found, attempting 1.7...") |
| 45 | + find_package(PCL 1.7 REQUIRED) |
| 46 | + if(PCL_FOUND) |
| 47 | + message(STATUS "PCL status:") |
| 48 | + message(STATUS " version: ${PCL_VERSION}") |
| 49 | + message(STATUS " pcl directorie: ${PCL_INCLUDE_DIRS}") |
| 50 | + else() |
| 51 | + message(FATAL_ERROR " ERROR: PCL minimum required version 1.7. Not found") |
| 52 | + endif() |
| 53 | +endif() |
| 54 | + |
| 55 | +############################################################################## |
| 56 | +# HEADERS |
| 57 | +############################################################################## |
| 58 | +include_directories(${PCL_INCLUDE_DIRS}) |
| 59 | +include(CheckFunctionExists) |
| 60 | + |
| 61 | +# Use the compile definitions defined in PCL |
| 62 | +add_definitions(${PCL_DEFINITIONS}) |
| 63 | + |
| 64 | +############################################################################## |
| 65 | +# LIBRARIES PATH |
| 66 | +############################################################################## |
| 67 | +link_directories(${PCL_LIBRARY_DIRS}) |
| 68 | + |
| 69 | +############################################################################## |
| 70 | +# SOURCE CODE |
| 71 | +############################################################################## |
| 72 | +set(MAIN_SOURCE "main.cpp") |
| 73 | + |
| 74 | +############################################################################## |
| 75 | +# EXECUTABLES |
| 76 | +############################################################################## |
| 77 | +add_executable(${PROJECT_NAME} ${MAIN_SOURCE}) |
| 78 | + |
| 79 | +############################################################################## |
| 80 | +# TARGET LIBRARIES |
| 81 | +############################################################################## |
| 82 | +target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES}) |
| 83 | + |
| 84 | +message("=========================================") |
| 85 | +message("Project: ${PROJECT_NAME} COMPILED WITH CMAKE " ${CMAKE_VERSION}) |
| 86 | +message("=========================================") |
0 commit comments