#-DCMAKE_PREFIX_PATH:PATH=D:/Develop/Qt/6.4.0/msvc2019_64 -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_INSTALL_PREFIX:PATH=C:/Program Files (x86)/TEST include(common.cmake) # 设置cmake最低版本 cmake_minimum_required(VERSION 3.5) # project命令用于指定cmake工程的名称,实际上,它还可以指定cmake工程的版本号(VERSION关键字)、简短的描述(DESCRIPTION关键字)、主页URL(HOMEPAGE_URL关键字)和编译工程使用的语言(LANGUAGES关键字) # project(<PROJECT-NAME> [<language-name>...]) # project(<PROJECT-NAME> [VERSION <major>[.<minor>[.<patch>[.<tweak>]]]] [DESCRIPTION <project-description-string>][HOMEPAGE_URL <url-string>] [LANGUAGES <language-name>...]) # ${PROJECT_SOURCE_DIR} 和 <PROJECT-NAME>_SOURCE_DIR:本CMakeLists.txt所在的文件夹路径 # ${PROJECT_NAME}:本CMakeLists.txt的project名称 project(FKFramework VERSION 0.1 LANGUAGES CXX) #添加当期路径 set(CMAKE_INCLUDE_CURRENT_DIR ON) #设置C++标准 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) #将当期目录中所有目录映射变量 -- bin set(FK_BIN_DIR ${CMAKE_SOURCE_DIR}/bin) message(STATUS "FK_BIN_DIR :" ${FK_BIN_DIR}) #将当期目录中所有目录映射变量 -- common set(FK_COMMON_DIR ${CMAKE_SOURCE_DIR}/common) message(STATUS "FK_COMMON_DIR :" ${FK_COMMON_DIR}) #将当期目录中所有目录映射变量 -- include set(FK_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) message(STATUS "FK_INCLUDE_DIR :" ${FK_INCLUDE_DIR}) #将当期目录中所有目录映射变量 -- lib set(FK_LIB_DIR ${CMAKE_SOURCE_DIR}/lib) message(STATUS "FK_LIB_DIR :" ${FK_LIB_DIR}) #将当期目录中所有目录映射变量 -- Source set(FK_SOURCE_DIR ${CMAKE_SOURCE_DIR}/Source) message(STATUS "FK_SOURCE_DIR :" ${FK_SOURCE_DIR}) #设置输出目录--判断release还是debug if (CMAKE_BUILD_TYPE) string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE) if (${BUILD_TYPE} STREQUAL "debug") set (CMAKE_BUILD_TYPE "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0") elseif(CMAKE_BUILD_TYPE STREQUAL "release") set (CMAKE_BUILD_TYPE "Release") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -O3") else() set (CMAKE_BUILD_TYPE "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0") message("set Default CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") endif() else() set (CMAKE_BUILD_TYPE "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0") message("set Default CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") endif() message(STATUS "${PROJECT_NAME} CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") #设置编译链32还是64 if(CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUE "64bit") set(BUILD_PLATFORM X64) else() message(STATUE "32bit") set(BUILD_PLATFORM WIN32) endif() ################################################## # platform 不推荐 ################################################## #[[if(CMAKE_CL_64) message(STATUS "MSVC 64bit") else() message(STATUS "MSVC 32bit") endif() #]] message(STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME} ") message(STATUS "CMAKE_HOST_SYSTEM : ${CMAKE_HOST_SYSTEM} ") message(STATUS "CMAKE_SYSTEM_NAME : ${CMAKE_SYSTEM_NAME} ") message(STATUS "CMAKE_SYSTEM : ${CMAKE_SYSTEM} ") message(STATUS "CMAKE_HOST_UNIX : ${CMAKE_HOST_UNIX} ") message(STATUS "CMAKE_HOST_WIN32 : ${CMAKE_HOST_WIN32} ") #判断系统 if (CMAKE_SYSTEM_NAME MATCHES "Windows") message(STATUS "----- OS: Windows") elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") message(STATUS "----- OS: Linux") set(BUILD_PLATFORM X86) elseif(CMAKE_SYSTEM_NAME MATCHES "UNIX") message(STATUS "----- OS: UNIX") set(BUILD_PLATFORM X86) elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") message(STATUS "----- OS: MacOS X") elseif(CMAKE_SYSTEM_NAME MATCHES "Android") message(STATUS "----- OS: Android") endif() if(WIN32) message(STATUS "----- This is Windows.") ################################################## # visual studio version ################################################## if(MSVC_VERSION EQUAL 1600) set(vs_version vs2010) set(vc_version vc10) elseif(MSVC_VERSION EQUAL 1700) set(vs_version vs2012) set(vc_version vc11) elseif(MSVC_VERSION EQUAL 1800) set(vs_version vs2013) set(vc_version vc12) elseif(MSVC_VERSION EQUAL 1900) set(vs_version vs2015) set(vc_version vc14) elseif(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS_EQUAL 1920) set(vs_version vs2017) set(vc_version vc15) elseif(MSVC_VERSION GREATER_EQUAL 1920) set(vs_version vs2019) set(vc_version vc15) endif() message(STATUS "----- vs_version is: ${vs_version}") message(STATUS "----- vc_version is: ${vc_version}") elseif(UNIX) message(STATUS "----- This is UNIX.") elseif(APPLE) message(STATUS "----- This is APPLE.") elseif(ANDROID) message(STATUS "----- This is ANDROID.") endif(WIN32) #设置输出路径 set(PROJECT_BUILD_OUT_DIR ${FK_BIN_DIR}/${BUILD_PLATFORM}/${CMAKE_BUILD_TYPE}) message(STATUS "PROJECT_BUILD_OUT_DIR :${PROJECT_BUILD_OUT_DIR}")
正文
CMake设置输出目录
此篇文章发布距今已超过384天,您需要注意文章的内容或图片是否可用!
-- 展开阅读全文 --
还没有评论,来说两句吧...