-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
50 lines (38 loc) · 1.68 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
cmake_minimum_required(VERSION 3.14)
project(QCloudMusicApiProject VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
option(MUSICAPI_TEST "Build Test" ON)
option(MUSICAPI_SERVER "Build ApiServer" ON)
option(MUSICAPI_SETOUTPUTPATH "Set default output path" ON)
if(ANDROID OR IOS)
set(MUSICAPI_SETOUTPUTPATH OFF)
endif()
# 生成动态库
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
if(MUSICAPI_SETOUTPUTPATH)
# set default output path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/lib)
set(CMAKE_HEADER_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/include)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
# 设置安装前缀为二进制目录
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
endif()
add_subdirectory(QCloudMusicApi)
if(MUSICAPI_TEST)
add_subdirectory(Test)
endif()
find_package(QT NAMES Qt6 Qt5)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS HttpServer)
if(Qt${QT_VERSION_MAJOR}HttpServer_FOUND)
# Qt6.4后才支持QHttpServer库
if(MUSICAPI_SERVER)
add_subdirectory(ApiServer)
endif()
endif()