Imported Upstream version 3.10.3
[platform/upstream/cmake.git] / CompileFlags.cmake
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4 #-----------------------------------------------------------------------------
5 # set some special flags for different compilers
6 #
7 if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
8   set(_INTEL_WINDOWS 1)
9 endif()
10
11 # Disable deprecation warnings for standard C functions.
12 # really only needed for newer versions of VS, but should
13 # not hurt other versions, and this will work into the
14 # future
15 if(MSVC OR _INTEL_WINDOWS)
16   add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
17 else()
18 endif()
19
20 #silence duplicate symbol warnings on AIX
21 if(CMAKE_SYSTEM_NAME MATCHES "AIX")
22   if(NOT CMAKE_COMPILER_IS_GNUCXX)
23     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ")
24   endif()
25 endif()
26
27 if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
28   if(NOT CMAKE_COMPILER_IS_GNUCXX)
29     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
30     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
31   endif()
32 endif()
33
34 if(CMAKE_SYSTEM MATCHES "OSF1-V")
35   if(NOT CMAKE_COMPILER_IS_GNUCXX)
36     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
37   endif()
38 endif()
39
40 # Workaround for short jump tables on PA-RISC
41 if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
42   if(CMAKE_COMPILER_IS_GNUCC)
43     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-calls")
44   endif()
45   if(CMAKE_COMPILER_IS_GNUCXX)
46     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-calls")
47   endif()
48 endif()
49
50 if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND
51     NOT DEFINED CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION)
52   if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
53     if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD EQUAL 98)
54       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
55     elseif(CMAKE_VERSION VERSION_LESS 3.8.20170502)
56       # CMake knows how to add this flag for compilation as C++11,
57       # but has not been taught that SunPro needs it for linking too.
58       # Add it in a place that will be used for both.
59       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
60     endif()
61   else()
62     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
63   endif()
64 endif()
65
66 foreach(lang C CXX)
67   # Suppress warnings from PGI compiler.
68   if (CMAKE_${lang}_COMPILER_ID STREQUAL "PGI")
69     set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w")
70   endif()
71 endforeach()
72
73 # use the ansi CXX compile flag for building cmake
74 if (CMAKE_ANSI_CXXFLAGS)
75   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
76 endif ()
77
78 if (CMAKE_ANSI_CFLAGS)
79   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
80 endif ()