aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai Pastor <dg0yt@darc.de>2020-07-07 19:55:05 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-07-08 13:32:47 +0200
commit3dc7d7d1d1fcda60c637fb578e9d8a7140fb4cd4 (patch)
tree3946911af34bf6dd7adee3bf888f0e20d732beea /src
parentaff43892f43dce14751e4f3be7e85d233793428b (diff)
downloadPROJ-3dc7d7d1d1fcda60c637fb578e9d8a7140fb4cd4.tar.gz
PROJ-3dc7d7d1d1fcda60c637fb578e9d8a7140fb4cd4.zip
CMake build: Check "target_clones" before use
gcc's "target_clones" and "ifunc" function attributes rely on extensions to the ELF standard. Using them on MinGW causes "error: the call requires 'ifunc', which is not supported by this target". Amends 5396b72.
Diffstat (limited to 'src')
-rw-r--r--src/lib_proj.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake
index abc9cc4b..59cb9572 100644
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -303,7 +303,18 @@ source_group("CMake Files" FILES CMakeLists.txt)
# Embed PROJ_LIB data files location
add_definitions(-DPROJ_LIB="${CMAKE_INSTALL_PREFIX}/${DATADIR}")
-add_definitions(-DTARGET_CLONES_FMA_ALLOWED)
+# The gcc "target_clones" function attribute relies on an extension
+# to the ELF standard. It must not be used on MinGW.
+include(CheckCXXSourceCompiles)
+set(CMAKE_REQUIRED_QUIET TRUE)
+check_cxx_source_compiles([[
+ __attribute__((target_clones("fma","default")))
+ int clonable() { return 0; }
+ int main() { return clonable(); }
+]] TARGET_CLONES_FMA_ALLOWED)
+if(TARGET_CLONES_FMA_ALLOWED)
+ add_definitions(-DTARGET_CLONES_FMA_ALLOWED)
+endif()
#################################################
## targets: libproj and proj_config.h