CompileFlags.cmake 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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(CMAKE_GENERATOR MATCHES "Visual Studio 6")
  19. set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
  20. endif()
  21. if(WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")
  22. set(_INTEL_WINDOWS 1)
  23. endif()
  24. # Disable deprecation warnings for standard C functions.
  25. # really only needed for newer versions of VS, but should
  26. # not hurt other versions, and this will work into the
  27. # future
  28. if(MSVC OR _INTEL_WINDOWS)
  29. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  30. else()
  31. endif()
  32. #silence duplicate symbol warnings on AIX
  33. if(CMAKE_SYSTEM_NAME MATCHES "AIX")
  34. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  35. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ")
  36. endif()
  37. endif()
  38. if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
  39. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  40. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
  41. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
  42. endif()
  43. endif()
  44. if(CMAKE_SYSTEM MATCHES "OSF1-V")
  45. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  46. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
  47. endif()
  48. endif()
  49. if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP")
  50. # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
  51. # template support. It is known that version 6.25 doesn't need that flag.
  52. # Versions prior to 3.80 will not be able to build CMake. Current assumption:
  53. # it is needed for every version from 3.80 to 4 to get it working.
  54. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND
  55. NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80)
  56. # use new C++ library and improved template support
  57. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
  58. endif()
  59. endif()
  60. # use the ansi CXX compile flag for building cmake
  61. if (CMAKE_ANSI_CXXFLAGS)
  62. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
  63. endif ()
  64. if (CMAKE_ANSI_CFLAGS)
  65. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
  66. endif ()
  67. # avoid binutils problem with large binaries, e.g. when building CMake in debug mode
  68. # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230
  69. if (CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL parisc)
  70. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text._*")
  71. endif ()
  72. include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)