CompileFlags.cmake 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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(CMAKE_GENERATOR MATCHES "Visual Studio 7")
  7. set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
  8. endif()
  9. if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
  10. set(_INTEL_WINDOWS 1)
  11. endif()
  12. # Disable deprecation warnings for standard C functions.
  13. # really only needed for newer versions of VS, but should
  14. # not hurt other versions, and this will work into the
  15. # future
  16. if(MSVC OR _INTEL_WINDOWS)
  17. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  18. else()
  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. if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP")
  38. # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
  39. # template support. It is known that version 6.25 doesn't need that flag.
  40. # Versions prior to 3.80 will not be able to build CMake. Current assumption:
  41. # it is needed for every version from 3.80 to 4 to get it working.
  42. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND
  43. NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80)
  44. # use new C++ library and improved template support
  45. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
  46. endif()
  47. endif()
  48. # Workaround for short jump tables on PA-RISC
  49. if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
  50. if(CMAKE_COMPILER_IS_GNUCC)
  51. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-calls")
  52. endif()
  53. if(CMAKE_COMPILER_IS_GNUCXX)
  54. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-calls")
  55. endif()
  56. endif()
  57. if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
  58. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
  59. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
  60. else()
  61. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
  62. endif()
  63. endif()
  64. foreach(lang C CXX)
  65. # Suppress warnings from PGI compiler.
  66. if (CMAKE_${lang}_COMPILER_ID STREQUAL "PGI")
  67. set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w")
  68. endif()
  69. endforeach()
  70. # use the ansi CXX compile flag for building cmake
  71. if (CMAKE_ANSI_CXXFLAGS)
  72. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
  73. endif ()
  74. if (CMAKE_ANSI_CFLAGS)
  75. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
  76. endif ()