diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /cmake/check_linker_flag.cmake | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/check_linker_flag.cmake')
-rw-r--r-- | cmake/check_linker_flag.cmake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/check_linker_flag.cmake b/cmake/check_linker_flag.cmake new file mode 100644 index 00000000..1ea1772d --- /dev/null +++ b/cmake/check_linker_flag.cmake @@ -0,0 +1,27 @@ +include(CheckCXXSourceCompiles) + +FUNCTION(MY_CHECK_AND_SET_LINKER_FLAG flag_to_set) + # Let's avoid expensive compiler tests on Windows: + IF(WIN32) + RETURN() + ENDIF() + STRING(REGEX REPLACE "[-,= +]" "_" result "HAVE_LINK_FLAG_${flag_to_set}") + SET(SAVE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${flag_to_check}) + CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result}) + SET(CMAKE_REQUIRED_LIBRARIES "${SAVE_CMAKE_REQUIRED_LIBRARIES}") + IF (${result}) + FOREACH(linktype SHARED MODULE EXE) + IF(ARGN) + FOREACH(type ${ARGN}) + SET(CMAKE_${linktype}_LINKER_FLAGS_${type} + "${CMAKE_${linktype}_LINKER_FLAGS_${type}} ${flag_to_set}" PARENT_SCOPE) + ENDFOREACH() + ELSE() + SET(CMAKE_${linktype}_LINKER_FLAGS + "${CMAKE_${linktype}_LINKER_FLAGS} ${flag_to_set}" PARENT_SCOPE) + ENDIF() + ENDFOREACH() + ENDIF() +ENDFUNCTION() |