CmakeLists.txt 语法作用
1.add_library()
该指令主要作用是将指定的源文件生成链接文件,然后添加到工程中.
2.link_directories()
该指令的作用是指定链接的库文件的路径.
3.target_link_libraries()
将目标文件与库文件进行链接.
4.find_package(PCL 1.2 REQUIRED)
5.include_directories()
添加头文件目录
6.find_library()
查找库所在目录
7.link_libraries()
添加需要链接的库文件路径
cmake_minimum_required (VERSION 2.6)
INCLUDE_DIRECTORIES(../../thirdparty/comm)
FIND_LIBRARY(COMM_LIB comm ../../thirdparty/comm/lib NO_DEFAULT_PATH)
FIND_LIBRARY(RUNTIME_LIB rt /usr/lib /usr/local/lib NO_DEFAULT_PATH)
link_libraries(${COMM_LIB} ${RUNTIME_LIB})
ADD_DEFINITIONS(
-O3 -g -W -Wall
-Wunused-variable -Wunused-parameter -Wunused-function -Wunused
-Wno-deprecated -Woverloaded-virtual -Wwrite-strings
-D__WUR= -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DTIXML_USE_STL
)
add_library(lib_demo
cmd.cpp
global.cpp
md5.cpp
)
link_libraries(lib_demo)
add_executable(demo
main.cpp
)
# link library in static mode
target_link_libraries(demo libuuid.a)