1.路径
_mkdir(ROOT_DIR "/data/");
if (NOT ROOT_DIR_DEFINED)
add_definitions(-DROOT_DIR="${PROJECT_SOURCE_DIR}")
set(ROOT_DIR_DEFINED ON)
endif()
if (NOT ROOT_DIR_DEFINED)
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (ARM)
add_definitions(-DROOT_DIR="./")
else()
add_definitions(-DROOT_DIR="${PROJECT_SOURCE_DIR}")
endif()
set(ROOT_DIR_DEFINED ON)
endif()
多个源文件工程编译
cmake_minimum_required(VERSION 3.5)project(ssca)set(CMAKE_CXX_STANDARD 14)set(WINDOWS TRUE CACHE INTERNAL "")
set(PLATFORM_PREFIX "win64" CACHE INTERNAL "")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)set(OpenCV_STATIC ON)
set(OpenCV_DIR D:/thirdparty/build/install/win64)find_package(OpenCV REQUIRED)FILE(GLOB_RECURSE src_SRC_LIST "src/*.cpp src/*.h")
FILE(GLOB_RECURSE CAFilter_SRC_LIST "CAFilter/*.cpp CAFilter/*.h")
FILE(GLOB_RECURSE CANLC_SRC_LIST "CANLC/*.cpp CANLC/*.h")
FILE(GLOB_RECURSE CAST_SRC_LIST "CAST/*.cpp CAST/*.h")
FILE(GLOB_RECURSE CC_SRC_LIST "CC/*.cpp CC/*.h")
FILE(GLOB_RECURSE PPSG_SRC_LIST "PPSG/*.cpp PSG/*.h")
FILE(GLOB_RECURSE PPWM_SRC_LIST "PPWM/*.cpp PPWM/*.h")add_executable(ssca main.cpp ${src_SRC_LIST} ${CAFilter_SRC_LIST} ${CANLC_SRC_LIST} ${CAST_SRC_LIST} ${CC_SRC_LIST} ${PPSG_SRC_LIST} ${PPWM_SRC_LIST})
target_link_libraries(ssca ${OpenCV_LIBS})
3.多个编译子文件家
add_subdirectory(sample/image_cv_gpumat)
4 .switch:
option(ENABLE_REALSENSE "Build with xxx" OFF)
if (ENABLE_REALSENSE)
add_definitions(-DENABLE_REALSENSE)
add_subdirectory(common)
endif()