diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,9 +33,10 @@ # Find the python interpreter. This is required for several targets. find_package(PythonInterp 3.4 REQUIRED) -# Add the magic targets `check` and `check-all` +# Add the magic targets `check-*` 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,19 @@ +# 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 + "${PYTHON_EXECUTABLE}" + "${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 @@ -492,6 +492,8 @@ add_subdirectory(seeder) endif() +include(BinaryTest) + # bitcoin-cli if(BUILD_BITCOIN_CLI) add_executable(bitcoin-cli bitcoin-cli.cpp) @@ -500,6 +502,8 @@ endif() target_link_libraries(bitcoin-cli common rpcclient Event) + + add_to_symbols_check(bitcoin-cli) endif() # bitcoin-tx @@ -510,6 +514,8 @@ endif() target_link_libraries(bitcoin-tx bitcoinconsensus) + + add_to_symbols_check(bitcoin-tx) endif() # bitcoind @@ -518,6 +524,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/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/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)