CompileFlags.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. # set some special flags for different compilers
  5. #
  6. if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
  7. set(_INTEL_WINDOWS 1)
  8. endif()
  9. # Disable deprecation warnings for standard C functions.
  10. # really only needed for newer versions of VS, but should
  11. # not hurt other versions, and this will work into the
  12. # future
  13. if(MSVC OR _INTEL_WINDOWS)
  14. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  15. else()
  16. endif()
  17. if(MSVC)
  18. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stack:10000000")
  19. endif()
  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. if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
  27. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  28. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
  29. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
  30. endif()
  31. endif()
  32. if(CMAKE_SYSTEM MATCHES "OSF1-V")
  33. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  34. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
  35. endif()
  36. endif()
  37. # Workaround for short jump tables on PA-RISC
  38. if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
  39. if(CMAKE_COMPILER_IS_GNUCC)
  40. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-calls")
  41. endif()
  42. if(CMAKE_COMPILER_IS_GNUCXX)
  43. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-calls")
  44. endif()
  45. endif()
  46. if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND
  47. NOT DEFINED CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION)
  48. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
  49. if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD EQUAL 98)
  50. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
  51. elseif(CMAKE_VERSION VERSION_LESS 3.8.20170502)
  52. # CMake knows how to add this flag for compilation as C++11,
  53. # but has not been taught that SunPro needs it for linking too.
  54. # Add it in a place that will be used for both.
  55. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  56. endif()
  57. else()
  58. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
  59. endif()
  60. endif()
  61. foreach(lang C CXX)
  62. # Suppress warnings from PGI compiler.
  63. if (CMAKE_${lang}_COMPILER_ID STREQUAL "PGI")
  64. set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w")
  65. endif()
  66. endforeach()
  67. # use the ansi CXX compile flag for building cmake
  68. if (CMAKE_ANSI_CXXFLAGS)
  69. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
  70. endif ()
  71. if (CMAKE_ANSI_CFLAGS)
  72. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
  73. endif ()