diff --git a/cmake/module/GenerateHeaders.cmake b/cmake/module/GenerateHeaders.cmake index 0aeca3112a334..35dc54eebb5d4 100644 --- a/cmake/module/GenerateHeaders.cmake +++ b/cmake/module/GenerateHeaders.cmake @@ -5,8 +5,8 @@ function(generate_header_from_json json_source_relpath) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${json_source_relpath}.h - COMMAND ${CMAKE_COMMAND} -DJSON_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${json_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${json_source_relpath}.h -P ${CMAKE_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${json_source_relpath} ${CMAKE_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake + COMMAND ${CMAKE_COMMAND} -DJSON_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${json_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${json_source_relpath}.h -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${json_source_relpath} ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake VERBATIM ) endfunction() @@ -14,8 +14,8 @@ endfunction() function(generate_header_from_raw raw_source_relpath) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h - COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h -P ${CMAKE_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} ${CMAKE_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake + COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} -DHEADER_PATH=${CMAKE_CURRENT_BINARY_DIR}/${raw_source_relpath}.h -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${raw_source_relpath} ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake VERBATIM ) endfunction() diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index 38fdf49ed7a28..c2cf2f6a9455d 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -37,8 +37,8 @@ function(add_maintenance_targets) # By concatenating these variables, we form the complete command line to be passed to a Python script via the CXX environment variable. string(STRIP "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" cxx_compiler_command) add_custom_target(test-security-check - COMMAND ${CMAKE_COMMAND} -E env CXX=${cxx_compiler_command} CXXFLAGS=${CMAKE_CXX_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/devtools/test-security-check.py TestSecurityChecks.test_${exe_format} - COMMAND ${CMAKE_COMMAND} -E env CXX=${cxx_compiler_command} CXXFLAGS=${CMAKE_CXX_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_${exe_format} + COMMAND ${CMAKE_COMMAND} -E env CXX=${cxx_compiler_command} CXXFLAGS=${CMAKE_CXX_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/devtools/test-security-check.py TestSecurityChecks.test_${exe_format} + COMMAND ${CMAKE_COMMAND} -E env CXX=${cxx_compiler_command} CXXFLAGS=${CMAKE_CXX_FLAGS} LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/devtools/test-symbol-check.py TestSymbolChecks.test_${exe_format} VERBATIM ) @@ -52,14 +52,14 @@ function(add_maintenance_targets) add_custom_target(check-symbols COMMAND ${CMAKE_COMMAND} -E echo "Running symbol and dynamic library checks..." - COMMAND ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/devtools/symbol-check.py ${executables} + COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/devtools/symbol-check.py ${executables} VERBATIM ) if(ENABLE_HARDENING) add_custom_target(check-security COMMAND ${CMAKE_COMMAND} -E echo "Checking binary security..." - COMMAND ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/devtools/security-check.py ${executables} + COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/devtools/security-check.py ${executables} VERBATIM ) else() @@ -74,19 +74,19 @@ function(add_windows_deploy_target) include(GenerateSetupNsi) generate_setup_nsi() add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/bitcoin-win64-setup.exe - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/release - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ - COMMAND makensis -V2 ${CMAKE_BINARY_DIR}/bitcoin-win64-setup.nsi + OUTPUT ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe + COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/release + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${PROJECT_BINARY_DIR}/release/$ + COMMAND makensis -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi VERBATIM ) - add_custom_target(deploy DEPENDS ${CMAKE_BINARY_DIR}/bitcoin-win64-setup.exe) + add_custom_target(deploy DEPENDS ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe) endif() endfunction() @@ -104,8 +104,8 @@ function(add_macos_deploy_target) ) add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt - COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --config $ --component GUI --prefix ${macos_app}/Contents/MacOS --strip + OUTPUT ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt + COMMAND ${CMAKE_COMMAND} --install ${PROJECT_BINARY_DIR} --config $ --component GUI --prefix ${macos_app}/Contents/MacOS --strip COMMAND ${CMAKE_COMMAND} -E rename ${macos_app}/Contents/MacOS/bin/$ ${macos_app}/Contents/MacOS/Bitcoin-Qt COMMAND ${CMAKE_COMMAND} -E rm -rf ${macos_app}/Contents/MacOS/bin VERBATIM @@ -114,37 +114,37 @@ function(add_macos_deploy_target) string(REPLACE " " "-" osx_volname ${PACKAGE_NAME}) if(CMAKE_HOST_APPLE) add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/${osx_volname}.zip - COMMAND ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip - DEPENDS ${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt + OUTPUT ${PROJECT_BINARY_DIR}/${osx_volname}.zip + COMMAND ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} -zip + DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt VERBATIM ) add_custom_target(deploydir - DEPENDS ${CMAKE_BINARY_DIR}/${osx_volname}.zip + DEPENDS ${PROJECT_BINARY_DIR}/${osx_volname}.zip ) add_custom_target(deploy - DEPENDS ${CMAKE_BINARY_DIR}/${osx_volname}.zip + DEPENDS ${PROJECT_BINARY_DIR}/${osx_volname}.zip ) else() add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt - COMMAND OBJDUMP=${CMAKE_OBJDUMP} ${PYTHON_COMMAND} ${CMAKE_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} - DEPENDS ${CMAKE_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt + OUTPUT ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt + COMMAND OBJDUMP=${CMAKE_OBJDUMP} ${PYTHON_COMMAND} ${PROJECT_SOURCE_DIR}/contrib/macdeploy/macdeployqtplus ${macos_app} ${osx_volname} -translations-dir=${QT_TRANSLATIONS_DIR} + DEPENDS ${PROJECT_BINARY_DIR}/${macos_app}/Contents/MacOS/Bitcoin-Qt VERBATIM ) add_custom_target(deploydir - DEPENDS ${CMAKE_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt + DEPENDS ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt ) find_program(ZIP_COMMAND zip REQUIRED) add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/dist/${osx_volname}.zip + OUTPUT ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip WORKING_DIRECTORY dist COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_COMMAND} ${osx_volname}.zip VERBATIM ) add_custom_target(deploy - DEPENDS ${CMAKE_BINARY_DIR}/dist/${osx_volname}.zip + DEPENDS ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip ) add_dependencies(deploy deploydir) endif() diff --git a/cmake/tests.cmake b/cmake/tests.cmake index d109e044defe5..279132980017f 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -4,12 +4,12 @@ if(TARGET bitcoin-util AND TARGET bitcoin-tx AND PYTHON_COMMAND) add_test(NAME util_test_runner - COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$ BITCOINTX=$ ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/test_runner.py + COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$ BITCOINTX=$ ${PYTHON_COMMAND} ${PROJECT_BINARY_DIR}/test/util/test_runner.py ) endif() if(PYTHON_COMMAND) add_test(NAME util_rpcauth_test - COMMAND ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/rpcauth-test.py + COMMAND ${PYTHON_COMMAND} ${PROJECT_BINARY_DIR}/test/util/rpcauth-test.py ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9df8dca6f9a39..38e18e5ab5c0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,7 @@ include(GNUInstallDirs) include(AddWindowsResources) -configure_file(${CMAKE_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY) +configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) # After the transition from Autotools to CMake, the obj/ subdirectory @@ -14,7 +14,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_custom_target(generate_build_info BYPRODUCTS ${PROJECT_BINARY_DIR}/src/obj/build.h COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/src/obj - COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/obj/build.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake + COMMAND ${CMAKE_COMMAND} -DBUILD_INFO_HEADER_PATH=${PROJECT_BINARY_DIR}/src/obj/build.h -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateBuildInfo.cmake COMMENT "Generating obj/build.h" VERBATIM ) diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt index 4e4f6314e0ef2..94b1ceb54e4d3 100644 --- a/src/ipc/CMakeLists.txt +++ b/src/ipc/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(bitcoin_ipc STATIC EXCLUDE_FROM_ALL process.cpp ) -target_capnp_sources(bitcoin_ipc ${CMAKE_SOURCE_DIR} +target_capnp_sources(bitcoin_ipc ${PROJECT_SOURCE_DIR} capnp/echo.capnp capnp/init.capnp ) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index c7a78cead201f..c97cbe32958da 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -161,7 +161,7 @@ if(WITH_MULTIPROCESS) ipc_test.cpp ) - target_capnp_sources(bitcoin_ipc_test ${CMAKE_SOURCE_DIR} + target_capnp_sources(bitcoin_ipc_test ${PROJECT_SOURCE_DIR} ipc_test.capnp )