FluentUI/src/CMakeLists.txt

76 lines
2.1 KiB
CMake
Raw Normal View History

2023-04-01 21:01:46 +08:00
cmake_minimum_required(VERSION 3.16)
2023-04-27 09:38:57 +08:00
project(fluentui LANGUAGES CXX)
2023-04-01 21:01:46 +08:00
2023-05-05 18:51:40 +08:00
#配置通用编译
2023-04-01 21:01:46 +08:00
set(CMAKE_AUTOMOC ON)
2023-04-27 14:30:10 +08:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2023-05-05 18:51:40 +08:00
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
endif()
2023-04-27 15:43:45 +08:00
2023-05-11 20:10:42 +08:00
##设置动态库输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_PREFIX_PATH}/bin)
##设置库文件输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_PREFIX_PATH}/lib)
2023-05-05 18:51:40 +08:00
#设置版本号
add_definitions(-DVERSION=1,2,9,0)
2023-04-27 09:38:57 +08:00
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
2023-04-27 17:29:39 +08:00
#遍历所有Cpp文件
2023-04-27 09:38:57 +08:00
file(GLOB_RECURSE CPP_FILES *.cpp *.h)
foreach(filepath ${CPP_FILES})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND sources_files ${filename})
endforeach(filepath)
2023-04-27 17:29:39 +08:00
#遍历所有qml文件
2023-04-27 09:38:57 +08:00
file(GLOB_RECURSE QML_PATHS *.qml)
foreach(filepath ${QML_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND qml_files ${filename})
endforeach(filepath)
2023-04-27 17:29:39 +08:00
#遍历所有资源文件
2023-05-11 18:24:58 +08:00
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.metainfo)
2023-04-27 09:38:57 +08:00
foreach(filepath ${RES_PATHS})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
list(APPEND resource_files ${filename})
endforeach(filepath)
2023-04-27 17:29:39 +08:00
#修改资源文件导出路径
2023-04-27 09:38:57 +08:00
foreach(filepath IN LISTS qml_files resource_files)
string(REPLACE "imports/FluentUI/" "" filename ${filepath})
set_source_files_properties(${filepath} PROPERTIES QT_RESOURCE_ALIAS ${filename})
endforeach()
2023-04-27 17:29:39 +08:00
#添加qml模块
2023-05-11 18:24:58 +08:00
qt_add_library(fluentui SHARED)
2023-04-27 09:38:57 +08:00
qt_add_qml_module(fluentui
2023-05-11 18:51:44 +08:00
OUTPUT_DIRECTORY ${CMAKE_PREFIX_PATH}/qml/FluentUI
2023-04-27 09:38:57 +08:00
VERSION 1.0
URI "FluentUI"
2023-04-27 15:43:45 +08:00
SOURCES ${sources_files} fluentui.rc
2023-04-27 09:38:57 +08:00
QML_FILES ${qml_files}
RESOURCES ${resource_files}
2023-04-01 21:01:46 +08:00
)
2023-04-27 17:29:39 +08:00
#链接库
2023-04-27 09:38:57 +08:00
target_link_libraries(fluentui PUBLIC
Qt::Core
Qt::Quick
Qt::Qml
)
2023-04-01 21:01:46 +08:00
2023-04-27 17:29:39 +08:00
#链接库 win32库 不然mingw会编译错误
2023-04-01 21:01:46 +08:00
if(WIN32)
2023-04-27 09:38:57 +08:00
target_link_libraries(fluentui PRIVATE dwmapi user32)
2023-04-01 21:01:46 +08:00
endif()
2023-05-11 20:10:42 +08:00
#如果是debug则生成的库文件名后面拼接d
set_target_properties(fluentui PROPERTIES DEBUG_POSTFIX "d")
set_target_properties(fluentuiplugin PROPERTIES DEBUG_POSTFIX "d")