bitcoin/cmake/module/CheckSourceCompilesAndLinks.cmake
Hennadii Stepanov 09e8fd25b1
build: Don't override CMake's default try_compile target
CMake assumes the default value internally, so overriding this causes
problems. The minimal speedup of skipping the linker isn't worth the
complexity of setting it to static.
2025-02-20 12:38:35 +00:00

30 lines
1,017 B
CMake

# 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)
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_compiles("${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_compiles("${source}" ${ARGN})
cmake_pop_check_state()
endmacro()