mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 21:37:04 +08:00
Add Build static lib option and fix the bug of static lib build.
This commit is contained in:
parent
112bb6e07a
commit
ea88707366
@ -4,6 +4,7 @@ project(FluentUI VERSION 0.1 LANGUAGES CXX)
|
|||||||
|
|
||||||
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
||||||
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
||||||
|
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
@ -20,3 +21,4 @@ endif ()
|
|||||||
message("------------------------ FluentUI ------------------------")
|
message("------------------------ FluentUI ------------------------")
|
||||||
message("Build FluentUI demo applications.: ${FLUENTUI_BUILD_EXAMPLES}")
|
message("Build FluentUI demo applications.: ${FLUENTUI_BUILD_EXAMPLES}")
|
||||||
message("Build FramelessHelper.: ${FLUENTUI_BUILD_FRAMELESSHEPLER}")
|
message("Build FramelessHelper.: ${FLUENTUI_BUILD_FRAMELESSHEPLER}")
|
||||||
|
message("Build static library.: ${FLUENTUI_BUILD_STATIC_LIB}")
|
||||||
|
@ -98,12 +98,22 @@ set_target_properties(example PROPERTIES
|
|||||||
)
|
)
|
||||||
|
|
||||||
#链接库
|
#链接库
|
||||||
target_link_libraries(example PRIVATE
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
target_link_libraries(example PRIVATE
|
||||||
|
Qt6::Quick
|
||||||
|
fluentui
|
||||||
|
fluentuiplugin
|
||||||
|
FramelessHelper::Core
|
||||||
|
FramelessHelper::Quick
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(example PRIVATE
|
||||||
Qt6::Quick
|
Qt6::Quick
|
||||||
fluentuiplugin
|
fluentuiplugin
|
||||||
FramelessHelper::Core
|
FramelessHelper::Core
|
||||||
FramelessHelper::Quick
|
FramelessHelper::Quick
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
#安装
|
#安装
|
||||||
install(TARGETS example
|
install(TARGETS example
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(fluentuiplugin LANGUAGES CXX)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
project(fluentui LANGUAGES CXX)
|
||||||
|
else()
|
||||||
|
project(fluentuiplugin LANGUAGES CXX)
|
||||||
|
endif()
|
||||||
#配置通用编译
|
#配置通用编译
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
@ -52,8 +55,26 @@ foreach(filepath IN LISTS qml_files resource_files)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
#添加qml模块
|
#添加qml模块
|
||||||
qt_add_library(fluentuiplugin SHARED)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
qt_add_qml_module(fluentuiplugin
|
set(LIB_TYPE "STATIC")
|
||||||
|
else()
|
||||||
|
set(LIB_TYPE "SHARED")
|
||||||
|
endif()
|
||||||
|
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
||||||
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
|
qt_add_qml_module(${PROJECT_NAME}
|
||||||
|
#在静态库编译中使用PLUGIN_TARGET会导致链接失败
|
||||||
|
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
|
||||||
|
VERSION 1.0
|
||||||
|
URI "FluentUI"
|
||||||
|
#修改qmltypes文件名称。默认fluentuiplugin.qmltypes,使用默认名称有时候import FluentUI会爆红,所以修改成plugins.qmltypes
|
||||||
|
TYPEINFO "plugins.qmltypes"
|
||||||
|
SOURCES ${sources_files} fluentui.rc
|
||||||
|
QML_FILES ${qml_files}
|
||||||
|
RESOURCES ${resource_files}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
qt_add_qml_module(${PROJECT_NAME}
|
||||||
#没有下面这行代码就会生成fluentuiplugin.dll与fluentuipluginplugin.dll两个动态库
|
#没有下面这行代码就会生成fluentuiplugin.dll与fluentuipluginplugin.dll两个动态库
|
||||||
PLUGIN_TARGET fluentuiplugin
|
PLUGIN_TARGET fluentuiplugin
|
||||||
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
|
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
|
||||||
@ -64,10 +85,11 @@ qt_add_qml_module(fluentuiplugin
|
|||||||
SOURCES ${sources_files} fluentui.rc
|
SOURCES ${sources_files} fluentui.rc
|
||||||
QML_FILES ${qml_files}
|
QML_FILES ${qml_files}
|
||||||
RESOURCES ${resource_files}
|
RESOURCES ${resource_files}
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
#链接库
|
#链接库
|
||||||
target_link_libraries(fluentuiplugin PUBLIC
|
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||||
Qt::CorePrivate
|
Qt::CorePrivate
|
||||||
Qt::QuickPrivate
|
Qt::QuickPrivate
|
||||||
Qt::QmlPrivate
|
Qt::QmlPrivate
|
||||||
|
Loading…
Reference in New Issue
Block a user