安装
使用源码安装CMake可以对版本进行指定。
首先从Installing | CMake下载对应平台的源码,并进行解压。解压后执行如下命令:
1 2 3
| ./bootstrap make sudo make install
|
上述第三条指令为可选指令,仅当拥有超级权限且准备为所有用户安装新版本的CMake时推荐使用,负责使用如下命令在CMake添加到PATH
即可。
1
| export PATH=/home/sukie/cmake-3.20.2/bin:$PATH
|
常用命令
编译选项
1 2
| cmake -DCMAKE_INSTALL_PREFIX=../install .. cmake --install .. --prefix ../install
|
Interface Changing
CMake 3.12
中将add_definitions
修改为``add_compile_definitions()` 。
1 2
| add_definitions(-DQURL_NO_CAST_FROM_STRING) add_compile_definitions(QURL_NO_CAST_FROM_STRING)
|
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| cmake_minimum_required(VERSION 3.5) project(LOAM) set(CMAKE_CXX_STANDARD 14) set(CMAKE_BUILD_TYPE Debug)
find_package(OpenCV REQUIRED) find_package(PCL REQUIRED) find_package(Boost 1.6 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS}) ${PCL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} . ./DsvLoading ./ScanRegistration ./LaserOdometry ./LaserMapping) link_directories(${PCL_LIBRARY_DIRS})
AUX_SOURCE_DIRECTORY(. DIR_SRCS) AUX_SOURCE_DIRECTORY(./DsvLoading DIR_DL_SRCS) AUX_SOURCE_DIRECTORY(./ScanRegistration DIR_SR_SRCS) AUX_SOURCE_DIRECTORY(./LaserOdometry DIR_LO_SRCS) AUX_SOURCE_DIRECTORY(./LaserMapping DIR_LM_SRCS)
add_executable(LOAM ${DIR_SRCS} ${DIR_DL_SRCS} ${DIR_SR_SRCS} ${DIR_LO_SRCS} ${DIR_LM_SRCS}) target_link_libraries(LOAM ${PCL_LIBRARIES} ${OpenCV_LIBS} ${Boost_LIBRARIES})
|