mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 06:49:38 -04:00
cmake: Check user-defined APPEND_*
variables early
This change improves usability in cases where the user provides `APPEND_*` variables that are incompatible with the compiler for some reason.
This commit is contained in:
parent
8287a7670b
commit
eb2a943504
1 changed files with 16 additions and 0 deletions
|
@ -27,6 +27,22 @@ macro(bitcoincore_enable_language language)
|
|||
string(APPEND CMAKE_${language}_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
|
||||
string(APPEND CMAKE_${language}_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}")
|
||||
string(APPEND CMAKE_${language}_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")
|
||||
|
||||
# CMake's `enable_language()` command internally checks
|
||||
# whether the compiler is able to compile a simple test program.
|
||||
# However, it does not take into consideration the contents
|
||||
# of the user-defined `APPEND_*FLAGS` variables, because they
|
||||
# modify CMake's compiler configuration variables, which in turn
|
||||
# become available only after `enable_language()` is invoked.
|
||||
# Therefore, we test the compiler again at this point.
|
||||
include(CheckSourceCompiles)
|
||||
check_source_compiles("${language}" "int main() { return 0; }" ${language}_COMPILER_WORKS)
|
||||
if(NOT ${language}_COMPILER_WORKS)
|
||||
unset(${language}_COMPILER_WORKS CACHE)
|
||||
message(FATAL_ERROR "The ${language} compiler is not able to compile a simple test program.\n"
|
||||
"Check that the \"APPEND_*FLAGS\" variables are set correctly.\n\n"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
unset(_description)
|
||||
endif()
|
||||
|
|
Loading…
Add table
Reference in a new issue