# 设置cmake的最低版本
cmake_minimum_required(VERSION 3.10)
# 设置工程名称 和版本
project(tutorial VERSION 1.0)
# 指定版本号的配置文件
configure_file(include/TutorialConfig.h.in TutorialConfig.h)
# 设置指定C++编译器版本。
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") # set C++ 11
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
message( STATUS "The comipler ${CMAKE_CXX_COMIPLER} has no C++ 11 suport. Please use a different C++ comipler.")
endif()
# 增加生成可执行文件,生成的程序名称为:tutorial_first
add_executable(tutorial src/tutorial.cpp)
# 为指定项目添加 include 路径
target_include_directories(tutorial PUBLIC
"${PROJECT_BINARY_DIR}"
)