43 lines
1.2 KiB
CMake
43 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
||
|
||
# # 设置项目名称
|
||
# project(uart)
|
||
|
||
# # 如果是发行版本就更换Debug为Release
|
||
# set(CMAKE_BUILD_TYPE "Debug")
|
||
# if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||
# # 添加D_DEBUG编译参数
|
||
# add_definitions(-D_DEBUG)
|
||
# endif()
|
||
|
||
# 显式设置项目源代码目录
|
||
set(PROJECT_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||
|
||
|
||
#项目编译选择,通过选择开关来进行编译选项,通过这种方式去选择编译测试模块中的哪一个
|
||
option(source "main" OFF)
|
||
option(unit_test "unit_test" ON)
|
||
|
||
#添加子工程目录,PROJECT_SOURCE_DIR为项目顶级CMakeLists.txt文件所在的目录
|
||
if(Main_Source)
|
||
add_subdirectory(${PROJECT_SOURCE_DIR}/source)
|
||
endif()
|
||
|
||
#项目编译选择,unit_test目录下哪些要编译
|
||
option(board_test "board_test" OFF)
|
||
#项目编译选择,board_test目录下哪些要编译
|
||
option(uart "uart_test" OFF)
|
||
option(json "json_test" ON)
|
||
|
||
#项目编译选择,test目录下哪些要编译
|
||
option(test "test" ON)
|
||
#项目编译选择,board_test目录下哪些要编译
|
||
option(onvif "onvif" OFF)
|
||
option(hello "hello" ON)
|
||
|
||
#测试程序
|
||
if(unit_test)
|
||
add_subdirectory(${PROJECT_SOURCE_DIR}/unit_test)
|
||
endif()
|
||
|