Merge pull request #6937

8a282f6 Add RELINK_TARGETS, monero_add_target_no_relink and use monero_add_executable/monero_add_library where possible (mj-xmr) Add monero_add_minimal_executable and use in tests (mj-xmr)
This commit is contained in:
luigi1111 2020-11-29 01:49:39 -06:00
commit 7a0334742a
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
18 changed files with 54 additions and 33 deletions

View File

@ -125,6 +125,24 @@ function (add_definition_if_library_exists library function header var)
endif() endif()
endfunction() endfunction()
option(RELINK_TARGETS "Relink targets, when just a dependant .so changed, but not its header?" OFF)
function (monero_set_target_no_relink target)
if (RELINK_TARGETS MATCHES OFF)
# Will not relink the target, when just its dependant .so has changed, but not it's interface
set_target_properties("${target}" PROPERTIES LINK_DEPENDS_NO_SHARED true)
endif()
endfunction()
function (monero_add_minimal_executable name)
source_group("${name}"
FILES
${ARGN})
add_executable("${name}"
${ARGN})
monero_set_target_no_relink( ${name} )
endfunction()
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")

View File

@ -75,6 +75,8 @@ function (monero_add_executable name)
PROPERTY PROPERTY
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
enable_stack_trace("${name}") enable_stack_trace("${name}")
monero_set_target_no_relink("${name}")
endfunction () endfunction ()
function (monero_add_library name) function (monero_add_library name)
@ -92,6 +94,7 @@ function (monero_add_library_with_deps)
set(objlib obj_${MONERO_ADD_LIBRARY_NAME}) set(objlib obj_${MONERO_ADD_LIBRARY_NAME})
add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES}) add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES})
add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>) add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>)
monero_set_target_no_relink("${MONERO_ADD_LIBRARY_NAME}")
if (MONERO_ADD_LIBRARY_DEPENDS) if (MONERO_ADD_LIBRARY_DEPENDS)
add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS}) add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
endif() endif()

View File

@ -45,4 +45,4 @@ foreach(BLOB_NAME checkpoints testnet_blocks stagenet_blocks)
) )
endforeach() endforeach()
add_library(blocks STATIC blocks.cpp ${GENERATED_SOURCES}) monero_add_library(blocks blocks.cpp ${GENERATED_SOURCES})

View File

@ -106,7 +106,7 @@ set(hash_targets_sources
set(hash_targets_headers) set(hash_targets_headers)
add_executable(hash-target-tests monero_add_minimal_executable(hash-target-tests
${hash_targets_sources} ${hash_targets_sources}
${hash_targets_headers}) ${hash_targets_headers})
target_link_libraries(hash-target-tests target_link_libraries(hash-target-tests
@ -149,7 +149,7 @@ foreach(BENCH IN LISTS MONERO_WALLET_CRYPTO_BENCH)
endforeach () endforeach ()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/benchmark.h.in" "${MONERO_GENERATED_HEADERS_DIR}/tests/benchmark.h") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/benchmark.h.in" "${MONERO_GENERATED_HEADERS_DIR}/tests/benchmark.h")
add_executable(monero-wallet-crypto-bench benchmark.cpp ${BENCH_OBJECTS}) monero_add_minimal_executable(monero-wallet-crypto-bench benchmark.cpp ${BENCH_OBJECTS})
target_link_libraries(monero-wallet-crypto-bench cncrypto) target_link_libraries(monero-wallet-crypto-bench cncrypto)
add_test(NAME wallet-crypto-bench COMMAND monero-wallet-crypto-bench) add_test(NAME wallet-crypto-bench COMMAND monero-wallet-crypto-bench)

View File

@ -31,7 +31,7 @@ set(block_weight_sources
set(block_weight_headers) set(block_weight_headers)
add_executable(block_weight monero_add_minimal_executable(block_weight
${block_weight_sources} ${block_weight_sources}
${block_weight_headers}) ${block_weight_headers})
target_link_libraries(block_weight target_link_libraries(block_weight

View File

@ -32,7 +32,7 @@ set(core_proxy_sources
set(core_proxy_headers set(core_proxy_headers
core_proxy.h) core_proxy.h)
add_executable(core_proxy monero_add_minimal_executable(core_proxy
${core_proxy_sources} ${core_proxy_sources}
${core_proxy_headers}) ${core_proxy_headers})
target_link_libraries(core_proxy target_link_libraries(core_proxy

View File

@ -68,7 +68,7 @@ set(core_tests_headers
rct2.h rct2.h
wallet_tools.h) wallet_tools.h)
add_executable(core_tests monero_add_minimal_executable(core_tests
${core_tests_sources} ${core_tests_sources}
${core_tests_headers}) ${core_tests_headers})
target_link_libraries(core_tests target_link_libraries(core_tests

View File

@ -37,7 +37,7 @@ set(crypto_sources
set(crypto_headers set(crypto_headers
crypto-tests.h) crypto-tests.h)
add_executable(cncrypto-tests monero_add_minimal_executable(cncrypto-tests
${crypto_sources} ${crypto_sources}
${crypto_headers}) ${crypto_headers})
target_link_libraries(cncrypto-tests target_link_libraries(cncrypto-tests
@ -53,7 +53,7 @@ add_test(
NAME cncrypto NAME cncrypto
COMMAND cncrypto-tests "${CMAKE_CURRENT_SOURCE_DIR}/tests.txt") COMMAND cncrypto-tests "${CMAKE_CURRENT_SOURCE_DIR}/tests.txt")
add_executable(cnv4-jit-tests cnv4-jit.c) monero_add_minimal_executable(cnv4-jit-tests cnv4-jit.c)
target_link_libraries(cnv4-jit-tests target_link_libraries(cnv4-jit-tests
PRIVATE PRIVATE
common common

View File

@ -31,7 +31,7 @@ set(transfers_sources
set(transfers_headers) set(transfers_headers)
add_executable(transfers monero_add_minimal_executable(transfers
${transfers_sources} ${transfers_sources}
${transfers_headers}) ${transfers_headers})
target_link_libraries(transfers target_link_libraries(transfers

View File

@ -31,7 +31,7 @@ set(difficulty_sources
set(difficulty_headers) set(difficulty_headers)
add_executable(difficulty-tests monero_add_minimal_executable(difficulty-tests
${difficulty_sources} ${difficulty_sources}
${difficulty_headers}) ${difficulty_headers})
target_link_libraries(difficulty-tests target_link_libraries(difficulty-tests

View File

@ -35,7 +35,7 @@ set(functional_tests_headers
transactions_flow_test.h transactions_flow_test.h
transactions_generation_from_blockchain.h) transactions_generation_from_blockchain.h)
add_executable(functional_tests monero_add_minimal_executable(functional_tests
${functional_tests_sources} ${functional_tests_sources}
${functional_tests_headers}) ${functional_tests_headers})
target_link_libraries(functional_tests target_link_libraries(functional_tests
@ -53,7 +53,7 @@ target_link_libraries(functional_tests
set(make_test_signature_sources set(make_test_signature_sources
make_test_signature.cc) make_test_signature.cc)
add_executable(make_test_signature monero_add_minimal_executable(make_test_signature
${make_test_signature_sources}) ${make_test_signature_sources})
target_link_libraries(make_test_signature target_link_libraries(make_test_signature

View File

@ -26,7 +26,7 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
add_executable(block_fuzz_tests block.cpp fuzzer.cpp) monero_add_minimal_executable(block_fuzz_tests block.cpp fuzzer.cpp)
target_link_libraries(block_fuzz_tests target_link_libraries(block_fuzz_tests
PRIVATE PRIVATE
cryptonote_core cryptonote_core
@ -40,7 +40,7 @@ set_property(TARGET block_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(transaction_fuzz_tests transaction.cpp fuzzer.cpp) monero_add_minimal_executable(transaction_fuzz_tests transaction.cpp fuzzer.cpp)
target_link_libraries(transaction_fuzz_tests target_link_libraries(transaction_fuzz_tests
PRIVATE PRIVATE
cryptonote_core cryptonote_core
@ -54,7 +54,7 @@ set_property(TARGET transaction_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(signature_fuzz_tests signature.cpp fuzzer.cpp) monero_add_minimal_executable(signature_fuzz_tests signature.cpp fuzzer.cpp)
target_link_libraries(signature_fuzz_tests target_link_libraries(signature_fuzz_tests
PRIVATE PRIVATE
wallet wallet
@ -69,7 +69,7 @@ set_property(TARGET signature_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(cold-outputs_fuzz_tests cold-outputs.cpp fuzzer.cpp) monero_add_minimal_executable(cold-outputs_fuzz_tests cold-outputs.cpp fuzzer.cpp)
target_link_libraries(cold-outputs_fuzz_tests target_link_libraries(cold-outputs_fuzz_tests
PRIVATE PRIVATE
wallet wallet
@ -84,7 +84,7 @@ set_property(TARGET cold-outputs_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(cold-transaction_fuzz_tests cold-transaction.cpp fuzzer.cpp) monero_add_minimal_executable(cold-transaction_fuzz_tests cold-transaction.cpp fuzzer.cpp)
target_link_libraries(cold-transaction_fuzz_tests target_link_libraries(cold-transaction_fuzz_tests
PRIVATE PRIVATE
wallet wallet
@ -99,7 +99,7 @@ set_property(TARGET cold-transaction_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(load-from-binary_fuzz_tests load_from_binary.cpp fuzzer.cpp) monero_add_minimal_executable(load-from-binary_fuzz_tests load_from_binary.cpp fuzzer.cpp)
target_link_libraries(load-from-binary_fuzz_tests target_link_libraries(load-from-binary_fuzz_tests
PRIVATE PRIVATE
common common
@ -112,7 +112,7 @@ set_property(TARGET load-from-binary_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(load-from-json_fuzz_tests load_from_json.cpp fuzzer.cpp) monero_add_minimal_executable(load-from-json_fuzz_tests load_from_json.cpp fuzzer.cpp)
target_link_libraries(load-from-json_fuzz_tests target_link_libraries(load-from-json_fuzz_tests
PRIVATE PRIVATE
common common
@ -125,7 +125,7 @@ set_property(TARGET load-from-json_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(base58_fuzz_tests base58.cpp fuzzer.cpp) monero_add_minimal_executable(base58_fuzz_tests base58.cpp fuzzer.cpp)
target_link_libraries(base58_fuzz_tests target_link_libraries(base58_fuzz_tests
PRIVATE PRIVATE
common common
@ -138,7 +138,7 @@ set_property(TARGET base58_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(parse-url_fuzz_tests parse_url.cpp fuzzer.cpp) monero_add_minimal_executable(parse-url_fuzz_tests parse_url.cpp fuzzer.cpp)
target_link_libraries(parse-url_fuzz_tests target_link_libraries(parse-url_fuzz_tests
PRIVATE PRIVATE
epee epee
@ -152,7 +152,7 @@ set_property(TARGET parse-url_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(http-client_fuzz_tests http-client.cpp fuzzer.cpp) monero_add_minimal_executable(http-client_fuzz_tests http-client.cpp fuzzer.cpp)
target_link_libraries(http-client_fuzz_tests target_link_libraries(http-client_fuzz_tests
PRIVATE PRIVATE
epee epee
@ -168,7 +168,7 @@ set_property(TARGET http-client_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(levin_fuzz_tests levin.cpp fuzzer.cpp) monero_add_minimal_executable(levin_fuzz_tests levin.cpp fuzzer.cpp)
target_link_libraries(levin_fuzz_tests target_link_libraries(levin_fuzz_tests
PRIVATE PRIVATE
common common
@ -184,7 +184,7 @@ set_property(TARGET levin_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(bulletproof_fuzz_tests bulletproof.cpp fuzzer.cpp) monero_add_minimal_executable(bulletproof_fuzz_tests bulletproof.cpp fuzzer.cpp)
target_link_libraries(bulletproof_fuzz_tests target_link_libraries(bulletproof_fuzz_tests
PRIVATE PRIVATE
common common
@ -200,7 +200,7 @@ set_property(TARGET bulletproof_fuzz_tests
PROPERTY PROPERTY
FOLDER "tests") FOLDER "tests")
add_executable(tx-extra_fuzz_tests tx-extra.cpp fuzzer.cpp) monero_add_minimal_executable(tx-extra_fuzz_tests tx-extra.cpp fuzzer.cpp)
target_link_libraries(tx-extra_fuzz_tests target_link_libraries(tx-extra_fuzz_tests
PRIVATE PRIVATE
cryptonote_basic cryptonote_basic

View File

@ -31,7 +31,7 @@ set(hash_sources
set(hash_headers) set(hash_headers)
add_executable(hash-tests monero_add_minimal_executable(hash-tests
${hash_sources} ${hash_sources}
${hash_headers}) ${hash_headers})
target_link_libraries(hash-tests target_link_libraries(hash-tests

View File

@ -33,7 +33,7 @@ set(libwallet_api_tests_sources
set(libwallet_api_tests_headers set(libwallet_api_tests_headers
) )
add_executable(libwallet_api_tests monero_add_minimal_executable(libwallet_api_tests
${libwallet_api_tests_sources} ${libwallet_api_tests_sources}
${libwallet_api_tests_headers}) ${libwallet_api_tests_headers})

View File

@ -32,7 +32,7 @@ set(clt_sources
set(clt_headers set(clt_headers
net_load_tests.h) net_load_tests.h)
add_executable(net_load_tests_clt monero_add_minimal_executable(net_load_tests_clt
${clt_sources} ${clt_sources}
${clt_headers}) ${clt_headers})
target_link_libraries(net_load_tests_clt target_link_libraries(net_load_tests_clt
@ -54,7 +54,7 @@ set(srv_sources
set(srv_headers set(srv_headers
net_load_tests.h) net_load_tests.h)
add_executable(net_load_tests_srv monero_add_minimal_executable(net_load_tests_srv
${srv_sources} ${srv_sources}
${srv_headers}) ${srv_headers})
target_link_libraries(net_load_tests_srv target_link_libraries(net_load_tests_srv

View File

@ -55,7 +55,7 @@ set(performance_tests_headers
performance_utils.h performance_utils.h
single_tx_test_base.h) single_tx_test_base.h)
add_executable(performance_tests monero_add_minimal_executable(performance_tests
${performance_tests_sources} ${performance_tests_sources}
${performance_tests_headers}) ${performance_tests_headers})
target_link_libraries(performance_tests target_link_libraries(performance_tests

View File

@ -40,7 +40,7 @@ set(trezor_tests_headers
../core_tests/chaingen.h ../core_tests/chaingen.h
../core_tests/wallet_tools.h) ../core_tests/wallet_tools.h)
add_executable(trezor_tests monero_add_minimal_executable(trezor_tests
${trezor_tests_sources} ${trezor_tests_sources}
${trezor_tests_headers}) ${trezor_tests_headers})

View File

@ -101,7 +101,7 @@ set(unit_tests_sources
set(unit_tests_headers set(unit_tests_headers
unit_tests_utils.h) unit_tests_utils.h)
add_executable(unit_tests monero_add_minimal_executable(unit_tests
${unit_tests_sources} ${unit_tests_sources}
${unit_tests_headers}) ${unit_tests_headers})
target_link_libraries(unit_tests target_link_libraries(unit_tests
@ -144,6 +144,6 @@ add_test(
NAME unit_tests NAME unit_tests
COMMAND unit_tests --data-dir "${TEST_DATA_DIR}") COMMAND unit_tests --data-dir "${TEST_DATA_DIR}")
add_executable(test_notifier test_notifier.cpp) monero_add_minimal_executable(test_notifier test_notifier.cpp)
target_link_libraries(test_notifier ${EXTRA_LIBRARIES}) target_link_libraries(test_notifier ${EXTRA_LIBRARIES})
set_property(TARGET test_notifier PROPERTY FOLDER "tests") set_property(TARGET test_notifier PROPERTY FOLDER "tests")