mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-04 13:55:23 -05:00
cmake: Add support for builtin codegen
target
Additionally, this change removes unnecessary braces in the `if()` command for improved robustness, readability and consistency with CMake guidelines.
This commit is contained in:
parent
a8c78a0574
commit
ecf54a32ed
2 changed files with 17 additions and 1 deletions
|
@ -9,10 +9,16 @@
|
|||
# - CMake 3.26.5, https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||
message(FATAL_ERROR "In-source builds are not allowed.")
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0171)
|
||||
# `codegen` is a reserved target name.
|
||||
# See: https://cmake.org/cmake/help/latest/policy/CMP0171.html
|
||||
cmake_policy(SET CMP0171 NEW)
|
||||
endif()
|
||||
|
||||
#=============================
|
||||
# Project / Package metadata
|
||||
#=============================
|
||||
|
|
|
@ -7,6 +7,14 @@ macro(set_add_custom_command_options)
|
|||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.27)
|
||||
set(DEPENDS_EXPLICIT_OPT DEPENDS_EXPLICIT_ONLY)
|
||||
endif()
|
||||
set(CODEGEN_OPT "")
|
||||
if(POLICY CMP0171)
|
||||
cmake_policy(GET CMP0171 _cmp0171_status)
|
||||
if(_cmp0171_status STREQUAL "NEW")
|
||||
set(CODEGEN_OPT CODEGEN)
|
||||
endif()
|
||||
unset(_cmp0171_status)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Specifies JSON data files to be processed into corresponding
|
||||
|
@ -20,6 +28,7 @@ function(target_json_data_sources target)
|
|||
COMMAND ${CMAKE_COMMAND} -DJSON_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${json_file} -DHEADER_PATH=${header} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${json_file} ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromJson.cmake
|
||||
VERBATIM
|
||||
${CODEGEN_OPT}
|
||||
${DEPENDS_EXPLICIT_OPT}
|
||||
)
|
||||
target_sources(${target} PRIVATE ${header})
|
||||
|
@ -38,6 +47,7 @@ function(target_raw_data_sources target)
|
|||
COMMAND ${CMAKE_COMMAND} -DRAW_SOURCE_PATH=${CMAKE_CURRENT_SOURCE_DIR}/${raw_file} -DHEADER_PATH=${header} -DRAW_NAMESPACE=${__NAMESPACE} -P ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${raw_file} ${PROJECT_SOURCE_DIR}/cmake/script/GenerateHeaderFromRaw.cmake
|
||||
VERBATIM
|
||||
${CODEGEN_OPT}
|
||||
${DEPENDS_EXPLICIT_OPT}
|
||||
)
|
||||
target_sources(${target} PRIVATE ${header})
|
||||
|
|
Loading…
Add table
Reference in a new issue