Changeset View
Changeset View
Standalone View
Standalone View
src/CMakeLists.txt
Show All 9 Lines | |||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden) | set(CMAKE_CXX_VISIBILITY_PRESET hidden) | ||||
option(BUILD_BITCOIN_WALLET "Activate the wallet functionality" ON) | option(BUILD_BITCOIN_WALLET "Activate the wallet functionality" ON) | ||||
option(BUILD_BITCOIN_ZMQ "Activate the ZeroMQ functionalities" ON) | option(BUILD_BITCOIN_ZMQ "Activate the ZeroMQ functionalities" ON) | ||||
option(BUILD_BITCOIN_SEEDER "Build bitcoin-seeder" ON) | option(BUILD_BITCOIN_SEEDER "Build bitcoin-seeder" ON) | ||||
option(BUILD_BITCOIN_CLI "Build bitcoin-cli" ON) | option(BUILD_BITCOIN_CLI "Build bitcoin-cli" ON) | ||||
option(BUILD_BITCOIN_TX "Build bitcoin-tx" ON) | option(BUILD_BITCOIN_TX "Build bitcoin-tx" ON) | ||||
option(BUILD_BITCOIN_QT "Build bitcoin-qt" ON) | option(BUILD_BITCOIN_QT "Build bitcoin-qt" ON) | ||||
option(ENABLE_HARDENING "Harden the executables" ON) | |||||
# Cmake uses the CMAKE_BUILD_TYPE variable to select the build configuration. | # Cmake uses the CMAKE_BUILD_TYPE variable to select the build configuration. | ||||
# By default it supports more configurations that needed for Bitcoin ABC, and | # By default it supports more configurations that needed for Bitcoin ABC, and | ||||
# all the releases types set NDEBUG which is unwanted as it disables the assert | # all the releases types set NDEBUG which is unwanted as it disables the assert | ||||
# completely. | # completely. | ||||
# Remove the -DNDEBUG flag from the CFLAGS/CXXFLAGS in all the configurations | # Remove the -DNDEBUG flag from the CFLAGS/CXXFLAGS in all the configurations | ||||
include(AddCompilerFlags) | include(AddCompilerFlags) | ||||
remove_compiler_flags(-DNDEBUG) | remove_compiler_flags(-DNDEBUG) | ||||
# Ensure that WINDRES_PREPROC is enabled when using windres. | # Ensure that WINDRES_PREPROC is enabled when using windres. | ||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
list(APPEND CMAKE_RC_FLAGS "-DWINDRES_PREPROC") | list(APPEND CMAKE_RC_FLAGS "-DWINDRES_PREPROC") | ||||
endif() | endif() | ||||
# All windows code is PIC, forcing it on just adds useless compile warnings | |||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | |||||
add_compiler_flag(-fPIC) | |||||
endif() | |||||
if(ENABLE_HARDENING) | |||||
# CMake provides the POSITION_INDEPENDENT_CODE property to set PIC/PIE. | # CMake provides the POSITION_INDEPENDENT_CODE property to set PIC/PIE. | ||||
# Unfortunately setting the -pie linker flag this way required CMake >= 3.14, | # Unfortunately setting the -pie linker flag this way require CMake >= 3.14, | ||||
# which is not widely distributed at the time of writing. | # which is not widely distributed at the time of writing. | ||||
# FIXME: use the POSITION_INDEPENDENT_CODE property instead | # FIXME: use the POSITION_INDEPENDENT_CODE property instead | ||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
add_compiler_flag(-fPIC -fPIE) | add_compiler_flag(-fPIE) | ||||
add_linker_flag(-pie) | add_linker_flag(-pie) | ||||
endif() | endif() | ||||
endif() | |||||
# Enable warning | # Enable warning | ||||
add_c_compiler_flag(-Wnested-externs -Wstrict-prototypes) | add_c_compiler_flag(-Wnested-externs -Wstrict-prototypes) | ||||
add_compiler_flag( | add_compiler_flag( | ||||
-Wall | -Wall | ||||
-Wextra | -Wextra | ||||
-Wformat | -Wformat | ||||
-Wvla | -Wvla | ||||
▲ Show 20 Lines • Show All 268 Lines • Show Last 20 Lines |