diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,10 @@ "Select the configuration for the build" FORCE) endif() -# Add the magic targets `check` and `check-all` +# Add the magic targets `check`, `check-all` and `check-symbols` add_custom_target(check-all) add_custom_target(check) +add_custom_target(check-symbols) add_subdirectory(src) add_subdirectory(test) diff --git a/cmake/modules/BinaryTest.cmake b/cmake/modules/BinaryTest.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/BinaryTest.cmake @@ -0,0 +1,18 @@ +# Facilities to run tests on the executable binaries. + +macro(add_to_symbols_check BINARY) + set(CUSTOM_TARGET_NAME "check-symbols-${BINARY}") + add_custom_target("${CUSTOM_TARGET_NAME}" + COMMAND + ${CMAKE_COMMAND} -E echo "Running symbol-check.py on ${BINARY}..." + COMMAND + "${CMAKE_SOURCE_DIR}/contrib/devtools/symbol-check.py" + "${BINARY}" + DEPENDS + "${BINARY}" + ) + + if(TARGET check-symbols) + add_dependencies(check-symbols "${CUSTOM_TARGET_NAME}") + endif() +endmacro() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -448,6 +448,8 @@ add_subdirectory(seeder) endif() +include(BinaryTest) + # bitcoin-cli if(BUILD_BITCOIN_CLI) add_executable(bitcoin-cli bitcoin-cli.cpp) @@ -456,6 +458,8 @@ endif() target_link_libraries(bitcoin-cli common rpcclient Event) + + add_to_symbols_check(bitcoin-cli) endif() # bitcoin-tx @@ -466,6 +470,8 @@ endif() target_link_libraries(bitcoin-tx bitcoinconsensus) + + add_to_symbols_check(bitcoin-tx) endif() # bitcoind @@ -474,6 +480,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") target_sources(bitcoind PRIVATE bitcoind-res.rc) endif() +add_to_symbols_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 @@ -69,3 +69,6 @@ DEPENDS bitcoin-bench ) + +include(BinaryTest) +add_to_symbols_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 @@ -279,5 +279,8 @@ add_executable(bitcoin-qt WIN32 bitcoin.cpp) target_link_libraries(bitcoin-qt bitcoin-qt-base) +include(BinaryTest) +add_to_symbols_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 @@ -34,3 +34,6 @@ target_link_libraries(test_bitcoin-qt wallet) endif() + +include(BinaryTest) +add_to_symbols_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 @@ -12,3 +12,6 @@ ) target_link_libraries(bitcoin-seeder common) + +include(BinaryTest) +add_to_symbols_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 @@ -179,3 +179,6 @@ ../wallet/test/coinselector_tests.cpp ) endif() + +include(BinaryTest) +add_to_symbols_check(test_bitcoin)