cmake-plugin: 为引用在线构建的开关设置 online 别名

This commit is contained in:
zinface 2024-03-21 15:51:38 +08:00
parent 8c68f8b8dc
commit 1770af797d
2 changed files with 11 additions and 4 deletions

View File

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

View File

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