Changeset View
Changeset View
Standalone View
Standalone View
src/CMakeLists.txt
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | |||||
add_subdirectory(config) | add_subdirectory(config) | ||||
# libraries | # libraries | ||||
add_subdirectory(crypto) | add_subdirectory(crypto) | ||||
add_subdirectory(leveldb) | add_subdirectory(leveldb) | ||||
add_subdirectory(secp256k1) | add_subdirectory(secp256k1) | ||||
add_subdirectory(univalue) | add_subdirectory(univalue) | ||||
# Find the git root, and returns the full path to the .git/logs/HEAD file if | |||||
# it exists. | |||||
function(find_git_head_logs_file RESULT) | |||||
find_package(Git) | |||||
if(GIT_FOUND) | |||||
execute_process( | |||||
COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--show-toplevel" | |||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | |||||
OUTPUT_VARIABLE GIT_ROOT | |||||
RESULT_VARIABLE GIT_RESULT | |||||
OUTPUT_STRIP_TRAILING_WHITESPACE | |||||
) | |||||
if(GIT_RESULT EQUAL 0) | |||||
set(GIT_LOGS_DIR "${GIT_ROOT}/.git/logs") | |||||
set(GIT_HEAD_LOGS_FILE "${GIT_LOGS_DIR}/HEAD") | |||||
# If the .git/logs/HEAD, create it | |||||
if(NOT EXISTS "${GIT_HEAD_LOGS_FILE}") | |||||
# FIXME No longer needed once cmake > 3.10 get enforced. | |||||
file(MAKE_DIRECTORY "${GIT_LOGS_DIR}") | |||||
# FIXME Replace with file(TOUCH) when cmake > 3.12 get enforced. | |||||
file(APPEND "${GIT_HEAD_LOGS_FILE}" "") | |||||
endif() | |||||
set(${RESULT} "${GIT_HEAD_LOGS_FILE}" PARENT_SCOPE) | |||||
endif() | |||||
endif() | |||||
endfunction() | |||||
find_git_head_logs_file(GIT_HEAD_LOGS_FILE) | |||||
set(OBJ_DIR "${CMAKE_CURRENT_BINARY_DIR}/obj") | set(OBJ_DIR "${CMAKE_CURRENT_BINARY_DIR}/obj") | ||||
file(MAKE_DIRECTORY "${OBJ_DIR}") | file(MAKE_DIRECTORY "${OBJ_DIR}") | ||||
add_custom_target(build_header | set(BUILD_HEADER "${OBJ_DIR}/build.h") | ||||
set(BUILD_HEADER_TMP "${BUILD_HEADER}.tmp") | |||||
add_custom_command( | |||||
DEPENDS | |||||
"${GIT_HEAD_LOGS_FILE}" | |||||
"${CMAKE_SOURCE_DIR}/share/genbuild.sh" | |||||
OUTPUT | |||||
"${BUILD_HEADER}" | |||||
COMMAND | COMMAND | ||||
"${CMAKE_SOURCE_DIR}/share/genbuild.sh" | "${CMAKE_SOURCE_DIR}/share/genbuild.sh" | ||||
"${OBJ_DIR}/build.h" | "${BUILD_HEADER_TMP}" | ||||
"${CMAKE_SOURCE_DIR}" | "${CMAKE_SOURCE_DIR}" | ||||
COMMAND | |||||
${CMAKE_COMMAND} -E copy_if_different "${BUILD_HEADER_TMP}" "${BUILD_HEADER}" | |||||
COMMAND | |||||
${CMAKE_COMMAND} -E remove "${BUILD_HEADER_TMP}" | |||||
) | ) | ||||
# Because the Bitcoin ABc source code is disorganised, we | # Because the Bitcoin ABc source code is disorganised, we | ||||
# end up with a bunch of libraries without any apparent | # end up with a bunch of libraries without any apparent | ||||
# cohesive structure. This is inherited from Bitcoin Core | # cohesive structure. This is inherited from Bitcoin Core | ||||
# and reflecting this. | # and reflecting this. | ||||
# TODO: Improve the structure once cmake is rocking. | # TODO: Improve the structure once cmake is rocking. | ||||
Show All 15 Lines | add_library(util | ||||
sync.cpp | sync.cpp | ||||
threadinterrupt.cpp | threadinterrupt.cpp | ||||
uint256.cpp | uint256.cpp | ||||
util/system.cpp | util/system.cpp | ||||
util/moneystr.cpp | util/moneystr.cpp | ||||
util/strencodings.cpp | util/strencodings.cpp | ||||
util/time.cpp | util/time.cpp | ||||
util/bytevectorhash.cpp | util/bytevectorhash.cpp | ||||
# obj/build.h | |||||
"${BUILD_HEADER}" | |||||
) | ) | ||||
add_dependencies(util build_header) | |||||
target_compile_definitions(util PUBLIC HAVE_CONFIG_H HAVE_BUILD_INFO) | target_compile_definitions(util PUBLIC HAVE_CONFIG_H HAVE_BUILD_INFO) | ||||
target_include_directories(util | target_include_directories(util | ||||
PUBLIC | PUBLIC | ||||
. | . | ||||
# To access the config/ and obj/ directories | # To access the config/ and obj/ directories | ||||
${CMAKE_CURRENT_BINARY_DIR} | ${CMAKE_CURRENT_BINARY_DIR} | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |