From 1770af797dfd43442c5861e6017090b0ba06f6ee Mon Sep 17 00:00:00 2001 From: zinface Date: Thu, 21 Mar 2024 15:51:38 +0800 Subject: [PATCH] =?UTF-8?q?cmake-plugin:=20=E4=B8=BA=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E6=9E=84=E5=BB=BA=E7=9A=84=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20online=20=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin/CMakeLists.txt | 2 +- src/plugin/framework/framework.cmake | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 0c351bc..0ddf186 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -40,7 +40,7 @@ if(USE_NOTEPAD_PLUGIN) # 一个使用引用构建的插件 # include(path/to/plugin.cmake) - # # 一个简单的 plantuml 预览插件 + # 一个 plantuml 预览插件(使用 with_git 引用的在线构建) # add_framework_plugin_with_git(https://gitee.com/ndd-community/notepad--plugin.plantuml-preview --branch=cmake-plugins-dev) diff --git a/src/plugin/framework/framework.cmake b/src/plugin/framework/framework.cmake index cc9d939..dfde813 100644 --- a/src/plugin/framework/framework.cmake +++ b/src/plugin/framework/framework.cmake @@ -5,10 +5,16 @@ # 基于提供的包含源代码文件的的路径,或指定的要构建的源代码 macro(add_framework_plugin _target) - option(${_target}_ENABLE "是否确认构建 ${_target} 插件" OFF) + set(${_target}_ALIAS ${_target}) + if(WITH_GIT) + set(${_target}_ALIAS online-${_target}) + unset(WITH_GIT) + endif(WITH_GIT) -if(${${_target}_ENABLE}) + option(${${_target}_ALIAS}_ENABLE "是否确认构建 ${_target} 插件" OFF) +if(${${${_target}_ALIAS}_ENABLE}) + set(${_target}_ENABLE ON) set(${_target}_ARGN ${ARGN}) # set(${_target}_DIR_OR_SOURCES) foreach(arg IN LISTS ${_target}_ARGN) @@ -84,7 +90,7 @@ if(${${_target}_ENABLE}) ">>>>>>>>>>>>>>>>>>>>>>>>>>> ${_target} CMake Debug <<<<<<<<<<<<<<<<<<<<<<<<<<<" ) -endif(${${_target}_ENABLE}) +endif(${${${_target}_ALIAS}_ENABLE}) endmacro(add_framework_plugin _target) @@ -135,6 +141,7 @@ macro(add_framework_plugin_with_git GIT_REPO_URL) # 6. 处理加入构建,如果这个仓库里有 plugin.cmake 的话 if(EXISTS ${CMAKE_BINARY_DIR}/${URL_USER}_${URL_REPO}_git/plugin.cmake) message("-- [GIT_PLUGIN] Found new plugin with git: ${CMAKE_BINARY_DIR}/${URL_USER}_${URL_REPO}_git/plugin.cmake") + set(WITH_GIT ON) include(${CMAKE_BINARY_DIR}/${URL_USER}_${URL_REPO}_git/plugin.cmake) else() return()