cmake-plugin: 使用 spark_file_glob 提升 QtCreator 中的显示

spark_file_glob(LocalSources
    ./*.h ./*.cpp ./*.ui
)
This commit is contained in:
zinface 2023-03-30 15:47:52 +08:00
parent c9d84a4749
commit a5a270944c
9 changed files with 42 additions and 23 deletions

View File

@ -174,8 +174,9 @@ macro(spark_add_library_realpaths)
endmacro(spark_add_library_realpaths)
# spark_aux_source_paths
# spark_aux_source_paths <var> [paths]...
# AUX
# <var>_PATHS
macro(spark_aux_source_paths AUX_VAR)
set(${AUX_VAR} "")
set(${AUX_VAR}_PATHS ${ARGN})
@ -187,8 +188,9 @@ macro(spark_aux_source_paths AUX_VAR)
endmacro(spark_aux_source_paths AUX_VAR)
# spark_file_glob
#
# spark_file_glob <var> [regexp]...
# 使 file(GLOB)
# <var>_PATHS
macro(spark_file_glob FGLOB_VAR)
set(${FGLOB_VAR} "")
set(${FGLOB_VAR}_PATHS ${ARGN})
@ -206,9 +208,9 @@ macro(spark_file_glob FGLOB_VAR)
endmacro(spark_file_glob FGLOB_VAR)
# spark_add_source_paths
#
#
# spark_add_source_paths <var> [paths]...
# spark_aux_source_paths ui
# <var>_PATHS
macro(spark_add_source_paths SOURCE_VAR)
set(${SOURCE_VAR} "")
set(${SOURCE_VAR}_PATHS ${ARGN})
@ -235,3 +237,19 @@ macro(spark_add_source_paths SOURCE_VAR)
endforeach(ui_src IN LISTS UI_SRCS)
endforeach(source_path IN LISTS ${SOURCE_VAR}_PATHS)
endmacro(spark_add_source_paths SOURCE_VAR)
# spark_add_library_file_glob <var> <STATIC|SHARED|regexp> [regexp]...
# regexp
# macros
macro(spark_add_library_file_glob _lib_name _lib_type)
if(${_lib_type} STREQUAL SHARED OR ${_lib_type} STREQUAL STATIC)
spark_file_glob(${_lib_name}_SOURCES ${ARGN})
spark_add_library(${_lib_name} ${_lib_type} ${${_lib_name}_SOURCES})
else()
spark_file_glob(${_lib_name}_SOURCES ${_lib_type} ${ARGN})
spark_add_library(${_lib_name} ${${_lib_name}_SOURCES})
endif(${_lib_type} STREQUAL SHARED OR ${_lib_type} STREQUAL STATIC)
endmacro(spark_add_library_file_glob _lib_name _lib_type)

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "external-plugin")
if(TRUE)
# external-plugin
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE
@ -83,7 +83,8 @@ endif(UNIX)
# ----------------- external-plugin ----------------- #
add_library(external-plugin-base SHARED external-plugin/base.cpp)
add_library(external-plugin-base SHARED
external-plugin/base.cpp external-plugin/interface/external.h)
if(WIN32)
target_compile_features(external-plugin-base PUBLIC cxx_std_20)

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "helloworld-next")
if(TRUE)
# helloworld-next
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "opencc-demo-plugin")
if(TRUE)
# opencc-demo-plugin
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "base-plugin")
if(TRUE)
# base-plugin
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "base-secondary-menu-plugin-v1")
if(TRUE)
# base-secondary-menu-plugin-v1
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "base-secondary-menu-plugin")
if(TRUE)
# base-secondary-menu-plugin
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "base-widget-plugin")
if(TRUE)
# base-widget-plugin
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE

View File

@ -15,8 +15,8 @@ set(LOCAL_PLUGIN_NAME "base-widget-ui-plugin")
if(TRUE)
# base-widget-ui-plugin
spark_aux_source_paths(LocalSources
.
spark_file_glob(LocalSources
./*.h ./*.cpp ./*.ui
)
spark_add_library(${LOCAL_PLUGIN_NAME} SHARED ${LocalSources})
target_include_directories(${LOCAL_PLUGIN_NAME} PRIVATE