CompileFlags.cmake 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #=============================================================================
  2. # CMake - Cross Platform Makefile Generator
  3. # Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. #
  5. # Distributed under the OSI-approved BSD License (the "License");
  6. # see accompanying file Copyright.txt for details.
  7. #
  8. # This software is distributed WITHOUT ANY WARRANTY; without even the
  9. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See the License for more information.
  11. #=============================================================================
  12. #-----------------------------------------------------------------------------
  13. # set some special flags for different compilers
  14. #
  15. if(CMAKE_GENERATOR MATCHES "Visual Studio 7")
  16. set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
  17. endif()
  18. if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
  19. set(_INTEL_WINDOWS 1)
  20. endif()
  21. # Disable deprecation warnings for standard C functions.
  22. # really only needed for newer versions of VS, but should
  23. # not hurt other versions, and this will work into the
  24. # future
  25. if(MSVC OR _INTEL_WINDOWS)
  26. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  27. else()
  28. endif()
  29. #silence duplicate symbol warnings on AIX
  30. if(CMAKE_SYSTEM_NAME MATCHES "AIX")
  31. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  32. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ")
  33. endif()
  34. endif()
  35. if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
  36. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  37. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
  38. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
  39. endif()
  40. endif()
  41. if(CMAKE_SYSTEM MATCHES "OSF1-V")
  42. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  43. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
  44. endif()
  45. endif()
  46. if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP")
  47. # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
  48. # template support. It is known that version 6.25 doesn't need that flag.
  49. # Versions prior to 3.80 will not be able to build CMake. Current assumption:
  50. # it is needed for every version from 3.80 to 4 to get it working.
  51. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND
  52. NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80)
  53. # use new C++ library and improved template support
  54. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
  55. endif()
  56. endif()
  57. # Workaround for short jump tables on PA-RISC
  58. if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
  59. if(CMAKE_COMPILER_IS_GNUC)
  60. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-calls")
  61. endif()
  62. if(CMAKE_COMPILER_IS_GNUCXX)
  63. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-calls")
  64. endif()
  65. endif()
  66. if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
  67. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
  68. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
  69. else()
  70. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
  71. endif()
  72. endif()
  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. if (CMAKE_ANSI_CFLAGS)
  78. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
  79. endif ()