mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-09 12:12:41 +01:00
cmake: Add introspection module
Co-authored-by: Cory Fields <cory-nospam-@coryfields.com> Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
39
cmake/module/CheckSourceCompilesAndLinks.cmake
Normal file
39
cmake/module/CheckSourceCompilesAndLinks.cmake
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright (c) 2023-present The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://opensource.org/license/mit/.
|
||||
|
||||
include_guard(GLOBAL)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
# This avoids running the linker.
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
macro(check_cxx_source_links source)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
|
||||
check_cxx_source_compiles("${source}" ${ARGN})
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
endmacro()
|
||||
|
||||
macro(check_cxx_source_compiles_with_flags flags source)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_FLAGS ${flags})
|
||||
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS)
|
||||
check_cxx_source_compiles("${source}" ${ARGN})
|
||||
cmake_pop_check_state()
|
||||
endmacro()
|
||||
|
||||
macro(check_cxx_source_links_with_flags flags source)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_FLAGS ${flags})
|
||||
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS)
|
||||
check_cxx_source_links("${source}" ${ARGN})
|
||||
cmake_pop_check_state()
|
||||
endmacro()
|
||||
|
||||
macro(check_cxx_source_links_with_libs libs source)
|
||||
cmake_push_check_state(RESET)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${libs}")
|
||||
check_cxx_source_links("${source}" ${ARGN})
|
||||
cmake_pop_check_state()
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user