Skip to content

Instantly share code, notes, and snippets.

@SolemnJoker
Last active November 7, 2020 06:50
Show Gist options
  • Save SolemnJoker/4b90f21b26d75fcab7cd7c9b741a621b to your computer and use it in GitHub Desktop.
Save SolemnJoker/4b90f21b26d75fcab7cd7c9b741a621b to your computer and use it in GitHub Desktop.
[cmake] #CMakelist #cmake
find_package(Boost REQUIRED COMPONENTS regex filesystem) #要使用的boost库
if(NOT Boost_FOUND)
message("Not found Boost")
endif()
include_directories(${Boost_INCLUDE_DIRS})
ADD_DEFINITIONS(-O3 -g -W -Wall -Wunused-variable -D_FILE_OFFSET_BITS=64 -DTIXML_USE_STL)
librarylink_directories(${LIB_DIR})
target_link_libraries(exe ${LIB})
# find required opencv
find_package(OpenCV REQUIRED)
# directory of opencv headers
include_directories(${OpenCV_INCLUDE_DIRS})
# name of executable file and path of source file
add_executable(opencv_test src/opencv_test.cpp)
# directory of opencv
librarylink_directories(${OpenCV_LIBRARY_DIRS})
# opencv libraries
target_link_libraries(opencv_test ${OpenCV_LIBS})
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)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 14)
project(project_name)
file(GLOB SRC *.cpp)
add_executable(SeamlessCloning ${SRC} )
cmake_minimum_required (VERSION 2.8)
# 项目信息
project (Demo2)
# 查找当前目录下的所有源文件
# 并将名称保存到 DIR_SRCS 变量
aux_source_directory(. DIR_SRCS)
# 指定生成目标
add_executable(Demo ${DIR_SRCS})
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 14)
project(project_name)
#不用添加.h
set(SRC a.cpp b.cpp)
add_executable(exe_name ${SRC} )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment