aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2019-04-18 11:28:44 +0200
committerGitHub <noreply@github.com>2019-04-18 11:28:44 +0200
commitab22c860e6e5356eb96ce41f49ec763f4df053e1 (patch)
treeb35752c8f8e4c3d00518a60e0ae2b03f1baf0450
parent4760c708ed7697178d55eac76332cdd63c54eb8c (diff)
parent421653b9c61f253e800ca749e9b1a9ba0688d72a (diff)
downloadPROJ-ab22c860e6e5356eb96ce41f49ec763f4df053e1.tar.gz
PROJ-ab22c860e6e5356eb96ce41f49ec763f4df053e1.zip
Merge pull request #1426 from mwtoews/intel
CMake: better support for Intel compiler
-rw-r--r--CMakeLists.txt20
-rw-r--r--cmake/ProjSystemInfo.cmake11
-rw-r--r--include/proj/internal/internal.hpp2
-rw-r--r--src/lib_proj.cmake36
4 files changed, 49 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68c941c6..12a24b7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,24 +68,20 @@ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
/wd4996 # Suppress warning about sprintf, etc., being unsafe
)
set(PROJ_CXX_WARN_FLAGS /EHsc ${PROJ_C_WARN_FLAGS})
+elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
+ if(MSVC)
+ set(PROJ_C_WARN_FLAGS /Wall)
+ set(PROJ_CXX_WARN_FLAGS /Wall)
+ else()
+ set(PROJ_C_WARN_FLAGS -Wall)
+ set(PROJ_CXX_WARN_FLAGS -Wall)
+ endif()
endif()
set(PROJ_C_WARN_FLAGS "${PROJ_C_WARN_FLAGS}"
CACHE STRING "C flags used to compile PROJ targets")
set(PROJ_CXX_WARN_FLAGS "${PROJ_CXX_WARN_FLAGS}"
CACHE STRING "C++ flags used to compile PROJ targets")
-# Tell Intel compiler to do arithmetic accurately. This is needed to
-# stop the compiler from ignoring parentheses in expressions like
-# (a + b) + c and from simplifying 0.0 + x to x (which is wrong if
-# x = -0.0).
-if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
- if(MSVC)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:precise")
- else()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise")
- endif()
-endif()
-
################################################################################
# PROJ CMake modules
################################################################################
diff --git a/cmake/ProjSystemInfo.cmake b/cmake/ProjSystemInfo.cmake
index 4265bacf..0ad4a077 100644
--- a/cmake/ProjSystemInfo.cmake
+++ b/cmake/ProjSystemInfo.cmake
@@ -62,6 +62,10 @@ if(WIN32)
set(PROJ_COMPILER_NAME "mingw-${GCC_VERSION}")
endif()
+ if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ set(PROJ_COMPILER_NAME "intel-win")
+ endif()
+
if(CMAKE_GENERATOR MATCHES "Win64")
set(PROJ_PLATFORM_NAME "x64")
else()
@@ -70,7 +74,12 @@ if(WIN32)
endif() # WIN32
if(UNIX)
- set(PROJ_COMPILER_NAME "gcc-${GCC_VERSION}")
+ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ set(PROJ_COMPILER_NAME "gcc-${GCC_VERSION}")
+ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
+ set(PROJ_COMPILER_NAME "intel-linux")
+ endif()
+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(PROJ_PLATFORM_NAME "x64")
else()
diff --git a/include/proj/internal/internal.hpp b/include/proj/internal/internal.hpp
index 84fc1c2b..220c137b 100644
--- a/include/proj/internal/internal.hpp
+++ b/include/proj/internal/internal.hpp
@@ -53,7 +53,7 @@
#if ((defined(__clang__) && \
(__clang_major__ > 3 || \
(__clang_major__ == 3 && __clang_minor__ >= 7))) || \
- __GNUC__ >= 7)
+ (__GNUC__ >= 7 && !__INTEL_COMPILER))
/** Macro for fallthrough in a switch case construct */
#define PROJ_FALLTHROUGH [[clang::fallthrough]];
#else
diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake
index 635992e4..f52f5327 100644
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -37,11 +37,16 @@ endif()
option(ENABLE_LTO "Build library with LTO optimization (if available)." OFF)
if(ENABLE_LTO)
- if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ # TODO: CMake v3.9 use CheckIPOSupported and set property; see
+ # https://cmake.org/cmake/help/v3.9/module/CheckIPOSupported.html
+ if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "-Wl,-flto")
check_cxx_source_compiles("int main(){ return 0; }"
COMPILER_SUPPORTS_FLTO_FLAG)
+ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
+ # Set INTERPROCEDURAL_OPTIMIZATION property later
+ set(COMPILER_SUPPORTS_FLTO_FLAG TRUE)
else()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-flto" COMPILER_SUPPORTS_FLTO_FLAG)
@@ -350,12 +355,31 @@ target_compile_options(${PROJ_CORE_TARGET}
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${PROJ_CXX_WARN_FLAGS}>
)
+# Tell Intel compiler to do arithmetic accurately. This is needed to stop the
+# compiler from ignoring parentheses in expressions like (a + b) + c and from
+# simplifying 0.0 + x to x (which is wrong if x = -0.0).
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
+ if(MSVC)
+ set(FP_PRECISE "/fp:precise")
+ else()
+ set(FP_PRECISE "-fp-model precise")
+ endif()
+ # Apply to source files that require this option
+ set_source_files_properties(
+ geodesic.c
+ PROPERTIES COMPILE_FLAGS ${FP_PRECISE})
+endif()
+
if(COMPILER_SUPPORTS_FLTO_FLAG)
- # See https://gitlab.kitware.com/cmake/cmake/issues/15245
- # CMake v3.9:
- # set_property(TARGET ${PROJ_CORE_TARGET}
- # PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
- target_compile_options(${PROJ_CORE_TARGET} PRIVATE -flto)
+ if("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
+ # Intel supported only, before v3.9
+ set_property(TARGET ${PROJ_CORE_TARGET}
+ PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+ else()
+ # Pre CMake v3.9 needs to set flag for other compilers
+ # see https://gitlab.kitware.com/cmake/cmake/issues/15245
+ target_compile_options(${PROJ_CORE_TARGET} PRIVATE -flto)
+ endif()
endif()
if(NOT CMAKE_VERSION VERSION_LESS 2.8.11)