Merge pull request #193 from mentalfl0w/main

Add Build static lib option and fix the bug of static lib build.
This commit is contained in:
zhuzichu 2023-07-10 09:18:55 +08:00 committed by GitHub
commit e2ff752ed9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 22 deletions

View File

@ -4,6 +4,7 @@ project(FluentUI VERSION 0.1 LANGUAGES CXX)
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
add_subdirectory(src)
@ -20,3 +21,4 @@ endif ()
message("------------------------ FluentUI ------------------------")
message("Build FluentUI demo applications.: ${FLUENTUI_BUILD_EXAMPLES}")
message("Build FramelessHelper.: ${FLUENTUI_BUILD_FRAMELESSHEPLER}")
message("Build static library.: ${FLUENTUI_BUILD_STATIC_LIB}")

View File

@ -98,12 +98,22 @@ set_target_properties(example PROPERTIES
)
#
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
fluentuiplugin
FramelessHelper::Core
FramelessHelper::Quick
)
endif()
#
install(TARGETS example

View File

@ -1,7 +1,10 @@
cmake_minimum_required(VERSION 3.20)
if (FLUENTUI_BUILD_STATIC_LIB)
project(fluentui LANGUAGES CXX)
else()
project(fluentuiplugin LANGUAGES CXX)
endif()
#
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE)
@ -52,8 +55,26 @@ foreach(filepath IN LISTS qml_files resource_files)
endforeach()
#qml
qt_add_library(fluentuiplugin SHARED)
qt_add_qml_module(fluentuiplugin
if (FLUENTUI_BUILD_STATIC_LIB)
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"
#qmltypesfluentuiplugin.qmltypes使import FluentUIplugins.qmltypes
TYPEINFO "plugins.qmltypes"
SOURCES ${sources_files} fluentui.rc
QML_FILES ${qml_files}
RESOURCES ${resource_files}
)
else()
qt_add_qml_module(${PROJECT_NAME}
#fluentuiplugin.dllfluentuipluginplugin.dll
PLUGIN_TARGET fluentuiplugin
OUTPUT_DIRECTORY ${QML_PLUGIN_DIRECTORY}
@ -65,9 +86,10 @@ qt_add_qml_module(fluentuiplugin
QML_FILES ${qml_files}
RESOURCES ${resource_files}
)
endif()
#
target_link_libraries(fluentuiplugin PUBLIC
target_link_libraries(${PROJECT_NAME} PUBLIC
Qt::CorePrivate
Qt::QuickPrivate
Qt::QmlPrivate