Skip to content

Commit

Permalink
cmake: Add docs and checks to AddTargetMacros module
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 25, 2024
1 parent a77c1aa commit f77ab70
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmake/module/AddTargetMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

include_guard(GLOBAL)

# Functions in this module are drop-in replacements for CMake's add_library
# and add_executable functions. They are mandatory for use in the Bitcoin
# Core project, except for imported and interface libraries.

function(subtree_add_library name)
if(NOT name MATCHES "^crc32c|^leveldb|^minisketch|^secp256k1")
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() was called to add a non-subtree target \"${name}\".")
endif()
cmake_parse_arguments(PARSE_ARGV 1 FWD "" "" "")
add_library("${name}" ${FWD_UNPARSED_ARGUMENTS})
target_link_libraries("${name}" PRIVATE core_base_interface)
Expand All @@ -17,6 +24,9 @@ function(subtree_add_library name)
endfunction()

function(bitcoincore_add_library name)
if(name MATCHES "^crc32c|^leveldb|^minisketch|^secp256k1")
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}() was called to add a subtree target \"${name}\".")
endif()
cmake_parse_arguments(PARSE_ARGV 1 FWD "" "" "")
add_library("${name}" ${FWD_UNPARSED_ARGUMENTS})
target_link_libraries("${name}" PRIVATE core_interface)
Expand Down

0 comments on commit f77ab70

Please sign in to comment.