Skip to content

Commit f77ab70

Browse files
committed
cmake: Add docs and checks to AddTargetMacros module
1 parent a77c1aa commit f77ab70

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmake/module/AddTargetMacros.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44

55
include_guard(GLOBAL)
66

7+
# Functions in this module are drop-in replacements for CMake's add_library
8+
# and add_executable functions. They are mandatory for use in the Bitcoin
9+
# Core project, except for imported and interface libraries.
10+
711
function(subtree_add_library name)
12+
if(NOT name MATCHES "^crc32c|^leveldb|^minisketch|^secp256k1")
13+
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() was called to add a non-subtree target \"${name}\".")
14+
endif()
815
cmake_parse_arguments(PARSE_ARGV 1 FWD "" "" "")
916
add_library("${name}" ${FWD_UNPARSED_ARGUMENTS})
1017
target_link_libraries("${name}" PRIVATE core_base_interface)
@@ -17,6 +24,9 @@ function(subtree_add_library name)
1724
endfunction()
1825

1926
function(bitcoincore_add_library name)
27+
if(name MATCHES "^crc32c|^leveldb|^minisketch|^secp256k1")
28+
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() was called to add a subtree target \"${name}\".")
29+
endif()
2030
cmake_parse_arguments(PARSE_ARGV 1 FWD "" "" "")
2131
add_library("${name}" ${FWD_UNPARSED_ARGUMENTS})
2232
target_link_libraries("${name}" PRIVATE core_interface)

0 commit comments

Comments
 (0)