mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 03:10:10 +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)
|
||||||
Qt6::Quick
|
target_link_libraries(example PRIVATE
|
||||||
fluentuiplugin
|
Qt6::Quick
|
||||||
FramelessHelper::Core
|
fluentui
|
||||||
FramelessHelper::Quick
|
fluentuiplugin
|
||||||
)
|
FramelessHelper::Core
|
||||||
|
FramelessHelper::Quick
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
target_link_libraries(example PRIVATE
|
||||||
|
Qt6::Quick
|
||||||
|
fluentuiplugin
|
||||||
|
FramelessHelper::Core
|
||||||
|
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,22 +55,41 @@ 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")
|
||||||
#没有下面这行代码就会生成fluentuiplugin.dll与fluentuipluginplugin.dll两个动态库
|
else()
|
||||||
PLUGIN_TARGET fluentuiplugin
|
set(LIB_TYPE "SHARED")
|
||||||
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
|
endif()
|
||||||
VERSION 1.0
|
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
||||||
URI "FluentUI"
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
#修改qmltypes文件名称。默认fluentuiplugin.qmltypes,使用默认名称有时候import FluentUI会爆红,所以修改成plugins.qmltypes
|
qt_add_qml_module(${PROJECT_NAME}
|
||||||
TYPEINFO "plugins.qmltypes"
|
#在静态库编译中使用PLUGIN_TARGET会导致链接失败
|
||||||
SOURCES ${sources_files} fluentui.rc
|
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
|
||||||
QML_FILES ${qml_files}
|
VERSION 1.0
|
||||||
RESOURCES ${resource_files}
|
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两个动态库
|
||||||
|
PLUGIN_TARGET fluentuiplugin
|
||||||
|
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}
|
||||||
|
)
|
||||||
|
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