diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,12 @@ "Select the configuration for the build" FORCE) endif() -# Add the magic targets `check`, `check-all` and `check-symbols` +# Add the magic targets `check`, `check-all`, `check-symbols` and +# `check-security` add_custom_target(check-all) add_custom_target(check) add_custom_target(check-symbols) +add_custom_target(check-security) add_subdirectory(src) add_subdirectory(test) diff --git a/cmake/modules/BinaryTest.cmake b/cmake/modules/BinaryTest.cmake --- a/cmake/modules/BinaryTest.cmake +++ b/cmake/modules/BinaryTest.cmake @@ -16,3 +16,20 @@ add_dependencies(check-symbols "${CUSTOM_TARGET_NAME}") endif() endmacro() + +macro(add_to_security_check BINARY) + set(CUSTOM_TARGET_NAME "check-security-${BINARY}") + add_custom_target("${CUSTOM_TARGET_NAME}" + COMMAND + ${CMAKE_COMMAND} -E echo "Running security-check.py on ${BINARY}..." + COMMAND + "${CMAKE_SOURCE_DIR}/contrib/devtools/security-check.py" + "${BINARY}" + DEPENDS + "${BINARY}" + ) + + if(TARGET check-security) + add_dependencies(check-security "${CUSTOM_TARGET_NAME}") + endif() +endmacro() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -460,6 +460,7 @@ target_link_libraries(bitcoin-cli common rpcclient Event) add_to_symbols_check(bitcoin-cli) + add_to_security_check(bitcoin-cli) endif() # bitcoin-tx @@ -472,6 +473,7 @@ target_link_libraries(bitcoin-tx bitcoinconsensus) add_to_symbols_check(bitcoin-tx) + add_to_security_check(bitcoin-tx) endif() # bitcoind @@ -481,6 +483,7 @@ target_sources(bitcoind PRIVATE bitcoind-res.rc) endif() add_to_symbols_check(bitcoind) +add_to_security_check(bitcoind) # Bitcoin-qt if(BUILD_BITCOIN_QT) diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -72,3 +72,4 @@ include(BinaryTest) add_to_symbols_check(bitcoin-bench) +add_to_security_check(bitcoin-bench) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -281,6 +281,7 @@ include(BinaryTest) add_to_symbols_check(bitcoin-qt) +add_to_security_check(bitcoin-qt) # Test tests add_subdirectory(test) diff --git a/src/qt/test/CMakeLists.txt b/src/qt/test/CMakeLists.txt --- a/src/qt/test/CMakeLists.txt +++ b/src/qt/test/CMakeLists.txt @@ -37,3 +37,4 @@ include(BinaryTest) add_to_symbols_check(test_bitcoin-qt) +add_to_security_check(test_bitcoin-qt) diff --git a/src/seeder/CMakeLists.txt b/src/seeder/CMakeLists.txt --- a/src/seeder/CMakeLists.txt +++ b/src/seeder/CMakeLists.txt @@ -15,3 +15,4 @@ include(BinaryTest) add_to_symbols_check(bitcoin-seeder) +add_to_security_check(bitcoin-seeder) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -182,3 +182,4 @@ include(BinaryTest) add_to_symbols_check(test_bitcoin) +add_to_security_check(test_bitcoin)