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_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}")

View File

@ -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

View File

@ -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.dllfluentuipluginplugin.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)
#qmltypesfluentuiplugin.qmltypes使import FluentUIplugins.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"
) #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}
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}
)
endif()
# #
target_link_libraries(fluentuiplugin PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC
Qt::CorePrivate Qt::CorePrivate
Qt::QuickPrivate Qt::QuickPrivate
Qt::QmlPrivate Qt::QmlPrivate