forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin-core/secp256k1#1240: cmake: Improve and document compil…
…er flag checks a8d059f cmake, doc: Document compiler flags (Hennadii Stepanov) 6ece150 cmake, refactor: Rename `try_add_compile_option` to `try_append_cflags` (Hennadii Stepanov) 19516ed cmake: Use `add_compile_options()` in `try_add_compile_option()` (Hennadii Stepanov) Pull request description: This PR: - drops tinkering with the `COMPILE_OPTIONS` directory property in `try_add_compile_option()` and renames it to `try_append_cflags()` - copies related comments from `configure.ac` ACKs for top commit: theuni: ACK bitcoin-core/secp256k1@a8d059f . Tree-SHA512: 7ac011c135e12a65c45f4feb7cd74fd2d961ed77252afecf3a66e2af1d57facab446120c63696507b5ecd5bdb3eee1521760a53028b914c429652d00d03a4462
- Loading branch information
Showing
3 changed files
with
43 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
include(CheckCCompilerFlag) | ||
|
||
function(secp256k1_check_c_flags_internal flags output) | ||
string(MAKE_C_IDENTIFIER "${flags}" result) | ||
string(TOUPPER "${result}" result) | ||
set(result "C_SUPPORTS_${result}") | ||
if(NOT MSVC) | ||
set(CMAKE_REQUIRED_FLAGS "-Werror") | ||
endif() | ||
|
||
# This avoids running a linker. | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
check_c_compiler_flag("${flags}" ${result}) | ||
|
||
set(${output} ${${result}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# Append flags to the COMPILE_OPTIONS directory property if CC accepts them. | ||
macro(try_append_c_flags) | ||
secp256k1_check_c_flags_internal("${ARGV}" result) | ||
if(result) | ||
add_compile_options(${ARGV}) | ||
endif() | ||
endmacro() |