makefile

makefiel.config file
cd dir_makefile_config
make clean
make
./bin/project_exe

cmake

CMakeLists.txt file
cd dir_cmakelists
mkdir build
cmake ..
make
./project_exe

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_CXX_FLAGS "-std=c++11 -O3 -DNDEBUG -fopenmp -ffast-math -Wall")
project(save_video)
# set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include_directories(include)
aux_source_directory(src DIR_SRCS)
find_package(OpenCV 3.4.5 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${DIR_SRCS})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
# # build shared lib.
# set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
# list(APPEND CURRENT_INCLUDE ${OpenCV_INCLUDE_DIRS} include)
# add_library(${PROJECT_NAME} SHARED ${DIR_SRCS} ${CURRENT_INCLUDE})
message("project_name: ${PROJECT_NAME}")
message("DIR_SRCS: ${DIR_SRCS}")
message("OpenCV_INCLUDE_DIRS: ${OpenCV_INCLUDE_DIRS}")
message("OpenCV_LIBS: ${OpenCV_LIBS}")

参考

1. cmake_guide_tutorial官网;

12-14 16:46