-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: Add
--no-undefined
linker option
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 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 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,32 @@ | ||
include_guard(GLOBAL) | ||
|
||
include(CheckCSourceCompiles) | ||
|
||
function(secp256k1_check_linker_flags_internal flags output) | ||
string(MAKE_C_IDENTIFIER "${flags}" result) | ||
string(TOUPPER "${result}" result) | ||
set(result "LINKER_SUPPORTS_${result}") | ||
set(CMAKE_REQUIRED_FLAGS "${flags}") | ||
if(MSVC) | ||
string(APPEND " /WX") | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
string(APPEND " -Wl,-fatal_warnings") | ||
else() | ||
string(APPEND " -Wl,--fatal-warnings") | ||
endif() | ||
|
||
# This ensures running a linker. | ||
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) | ||
check_c_source_compiles("int main() { return 0; }" ${result}) | ||
|
||
set(${output} ${${result}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# Append flags to the LINK_OPTIONS directory property if a linker accepts them. | ||
macro(try_append_linker_flags) | ||
secp256k1_check_linker_flags_internal("${ARGV}" result) | ||
if(result) | ||
add_link_options(${ARGV}) | ||
endif() | ||
unset(result) | ||
endmacro() |