Skip to content

Commit 650a43b

Browse files
committed
Allow including and excluding dependencies via pragmas
This supports comments in CMLs like: ``` # Boost-Include: Boost::add_this # Boost-Exclude Boost::remove_this ``` Whitespace is ignored and the colon is optional
1 parent 44c75fb commit 650a43b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

include/BoostRoot.cmake

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,18 @@ function(__boost_scan_dependencies lib var sub_folder)
214214
if(NOT EXISTS "${cml_file}")
215215
CONTINUE()
216216
endif()
217+
set(libs_to_exclude "")
217218

218219
file(STRINGS "${cml_file}" data)
219220

220221
foreach(line IN LISTS data)
221-
222-
if(line MATCHES "^[^#]*(Boost::[A-Za-z0-9_]+[^#]*)(#.*)?$")
222+
if(line MATCHES "^ *# *Boost-(Include|Exclude):? *(.*)$")
223+
set(type ${CMAKE_MATCH_1})
224+
set(line ${CMAKE_MATCH_2})
225+
else()
226+
set(type "Include")
227+
endif()
228+
if(line MATCHES "^([^#]*Boost::[A-Za-z0-9_]+[^#]*)(#.*)?$")
223229
string(REGEX MATCHALL "Boost::[A-Za-z0-9_]+" libs "${CMAKE_MATCH_1}")
224230

225231
foreach(dep IN LISTS libs)
@@ -243,7 +249,11 @@ function(__boost_scan_dependencies lib var sub_folder)
243249
endforeach()
244250
endif()
245251
if(NOT dep STREQUAL lib)
246-
list(APPEND result ${dep})
252+
if(type STREQUAL "Exclude")
253+
list(APPEND libs_to_exclude ${dep})
254+
else()
255+
list(APPEND result ${dep})
256+
endif()
247257
endif()
248258
endforeach()
249259

@@ -253,6 +263,7 @@ function(__boost_scan_dependencies lib var sub_folder)
253263

254264
endforeach()
255265

266+
list(REMOVE_ITEM result ${libs_to_exclude})
256267
list(REMOVE_DUPLICATES result)
257268
set(${var} ${result} PARENT_SCOPE)
258269

0 commit comments

Comments
 (0)