summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2020-10-07 16:06:20 +1100
committerDaniel Black <daniel@mariadb.org>2020-10-21 19:11:02 +1100
commitb4c225ac354686242b5336da84b7a758640936bd (patch)
tree73b5bb7e903a7e1b68a99d8f82a11a787396b15d /cmake
parent65b7f72b51dc81fbb6c2aca320e613b917bcc445 (diff)
downloadmariadb-git-b4c225ac354686242b5336da84b7a758640936bd.tar.gz
MDEV-23887: check_linker_flags correct for old cmake compatibility
It was only from CMake-3.14.0 that CMAKE_REQUIRED_LINK_OPTIONS was used in CHECK_CXX_SOURCE_COMPILES. Without this, it could be the case (as was on OSX) that a flag was never checked in CHECK_CXX_SOURCE_COMPILES, the CHECK successfully passed, but failed at link time. As such we use CMAKE_REQUIRED_LIBRARIES to include the flags to check as its compatible enough with the cmake versions for non-Windows compilers/linkers. Tested on x86_64 with: * 3.11.4 * 3.17.4 Corrects: 7473e1841c630d86f1873a2a7afacb53955b3f6f In the future: * cmake >=3.14.0 can use CMAKE_REQUIRED_LINK_OPTIONS * cmake >=3.18.0 can use CHECK_LINKER_FLAG (with policy CMP0057 NEW) (e.g: commit c7ac2deff9a2c965887dcc67cbf2a3a7c3e0123d) CMAKE_REQUIRED_LIBRARIES suggested by serg@mariadb.com Reviewed-by: anel@mariadb.org
Diffstat (limited to 'cmake')
-rw-r--r--cmake/check_linker_flag.cmake6
1 files changed, 3 insertions, 3 deletions
diff --git a/cmake/check_linker_flag.cmake b/cmake/check_linker_flag.cmake
index ff4b91e89f6..1ea1772d79e 100644
--- a/cmake/check_linker_flag.cmake
+++ b/cmake/check_linker_flag.cmake
@@ -6,11 +6,11 @@ FUNCTION(MY_CHECK_AND_SET_LINKER_FLAG flag_to_set)
RETURN()
ENDIF()
STRING(REGEX REPLACE "[-,= +]" "_" result "HAVE_LINK_FLAG_${flag_to_set}")
- SET(SAVE_CMAKE_REQUIRED_LINK_OPTIONS "${CMAKE_REQUIRED_LINK_OPTIONS}")
+ SET(SAVE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set})
- SET(CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} ${flag_to_check})
+ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${flag_to_check})
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result})
- SET(CMAKE_REQUIRED_LINK_OPTIONS "${SAVE_CMAKE_REQUIRED_LINK_OPTIONS}")
+ SET(CMAKE_REQUIRED_LIBRARIES "${SAVE_CMAKE_REQUIRED_LIBRARIES}")
IF (${result})
FOREACH(linktype SHARED MODULE EXE)
IF(ARGN)