-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
69 lines (57 loc) · 2.17 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 设置 CMake 的最低版本要求
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# 设定项目
project(Qtaichi VERSION 1.0)
message(STATUS "[Project] ${PROJECT_NAME}")
# 修改默认的安装路径前缀
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} CACHE PATH "install prefix" FORCE)
endif()
# 在 Debug 模式下自动对 dll 和 lib 文件名后边加 d,但 exe 仍然需要手动设置
set(CMAKE_DEBUG_POSTFIX d)
# 确定 C++ 版本
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
endif()
# 将生成的 exe, dll, lib 等放置在 bin, lib 目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/lib")
# 开启 VS 的文件夹功能
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(FetchContent)
FetchContent_Declare(
UCMake
GIT_REPOSITORY https://github.com/Ubpa/UCMake
GIT_TAG fcde6ae
)
FetchContent_MakeAvailable(UCMake)
# 获取 Qt5
# set(Qt5_DIR "D:/Qt/5.11.2/winrt_x64_msvc2017/lib/cmake/Qt5")
# set(Qt5Core_DIR "D:/Qt/5.11.2/winrt_x64_msvc2017/lib/cmake/Qt5Core")
# set(QT_QMAKE_EXECUTABLE "D:/Qt/5.11.2/winrt_x64_msvc2017/bin/qmake.exe")
find_package(Qt5 REQUIRED Widgets)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories (
${PROJECT_SOURCE_DIR}/include
# $ENV{XXX_INCLUDE_PATH}
# ...
)
link_directories (
${PROJECT_SOURCE_DIR}/lib
# $ENV{XXX_LIB_PATH}
# ...
)
add_subdirectory (src)
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}")
include (CPack)