Skip to content

Commit 5f3d5bb

Browse files
lethosormyk002
authored andcommitted
Add new plugins/external subdirectory for external/untracked plugins
This is more convenient for some devs than the old CMakeLists.custom.txt solution because it allows the plugins themselves (files or folders) to be ignored, rather than needing to remember to leave them unstaged.
1 parent bf60879 commit 5f3d5bb

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ tags
7171
# CLion
7272
.idea
7373

74-
# custom plugins
74+
# external plugins
75+
/plugins/external/
7576
/plugins/CMakeLists.custom.txt

plugins/CMakeLists.txt

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ set_source_files_properties( Brushes.h PROPERTIES HEADER_FILE_ONLY TRUE )
7777
# Plugins
7878
option(BUILD_SUPPORTED "Build the supported plugins (reveal, probe, etc.)." ON)
7979
if(BUILD_SUPPORTED)
80+
# If you are adding a plugin that you do not intend to commit to the DFHack repo,
81+
# see instructions for adding "external" plugins at the end of this file.
82+
8083
dfhack_plugin(3dveins 3dveins.cpp)
8184
dfhack_plugin(add-spatter add-spatter.cpp)
8285
# dfhack_plugin(advtools advtools.cpp)
@@ -175,6 +178,9 @@ if(BUILD_SUPPORTED)
175178
dfhack_plugin(workNow workNow.cpp)
176179
dfhack_plugin(xlsxreader xlsxreader.cpp LINK_LIBRARIES lua xlsxio_read_STATIC zip expat)
177180
dfhack_plugin(zone zone.cpp LINK_LIBRARIES lua)
181+
182+
# If you are adding a plugin that you do not intend to commit to the DFHack repo,
183+
# see instructions for adding "external" plugins at the end of this file.
178184
endif()
179185

180186
# this is the skeleton plugin. If you want to make your own, make a copy and then change it
@@ -183,12 +189,34 @@ if(BUILD_SKELETON)
183189
add_subdirectory(skeleton)
184190
endif()
185191

186-
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.custom.txt")
187-
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.custom.txt" "# You can add custom plugins here to avoid touching plugins/CMakeLists.txt,
188-
# This can be useful if you've made modifications to that file and try to
189-
# switch between branches that have also made modifications to it.
190192

193+
# To add "external" plugins without committing them to the DFHack repo:
194+
#
195+
# 1. run CMake as you normally do (this is only necessary once if
196+
# `external/CMakeLists.txt` does not exist yet)
197+
# 2. add the plugin to the `external` folder (relative to this file).
198+
# - for a multi-file plugin, either clone the repository inside of the
199+
# `external` folder, or add the folder there manually.
200+
# - for a single-file plugin, simply add the file there.
201+
# 3. add an entry to `external/CMakeLists.txt`:
202+
# - add_subdirectory() for multi-file plugins in a subdirectory
203+
# - dfhack_plugin() for single-file plugins
204+
# 4. build DFHack as normal. The plugins you added will be built as well.
205+
206+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeLists.txt")
207+
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeLists.txt"
208+
"# Add external plugins here - this file is ignored by git
209+
210+
# Recommended: use add_subdirectory() for folders that you have created within
211+
# this folder, or dfhack_plugin() for single files that you have added here.
212+
213+
# See the end of /plugins/CMakeLists.txt for more details.
191214
")
192215
endif()
193216

194-
include(CMakeLists.custom.txt)
217+
include("${CMAKE_CURRENT_SOURCE_DIR}/external/CMakeLists.txt")
218+
219+
# for backwards compatibility
220+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.custom.txt")
221+
include("${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.custom.txt")
222+
endif()

0 commit comments

Comments
 (0)