CMakeFindEclipseCDT4.cmake 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #=============================================================================
  2. # Copyright 2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # This file is included in CMakeSystemSpecificInformation.cmake if
  14. # the Eclipse CDT4 extra generator has been selected.
  15. FIND_PROGRAM(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse DOC "The Eclipse executable")
  16. FUNCTION(_FIND_ECLIPSE_VERSION)
  17. # This code is in a function so the variables used here have only local scope
  18. IF(CMAKE_ECLIPSE_EXECUTABLE)
  19. GET_FILENAME_COMPONENT(_ECLIPSE_DIR "${CMAKE_ECLIPSE_EXECUTABLE}" PATH)
  20. FILE(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/features/org.eclipse.platform*")
  21. IF("${_ECLIPSE_FEATURE_DIR}" MATCHES ".+org.eclipse.platform_([0-9]+\\.[0-9]+).+")
  22. SET(_ECLIPSE_VERSION ${CMAKE_MATCH_1})
  23. ENDIF()
  24. ENDIF()
  25. # Set up a map with the names of the Eclipse releases:
  26. SET(_ECLIPSE_VERSION_NAME_ "Unknown" )
  27. SET(_ECLIPSE_VERSION_NAME_3.2 "Callisto" )
  28. SET(_ECLIPSE_VERSION_NAME_3.3 "Europa" )
  29. SET(_ECLIPSE_VERSION_NAME_3.4 "Ganymede" )
  30. SET(_ECLIPSE_VERSION_NAME_3.5 "Galileo" )
  31. SET(_ECLIPSE_VERSION_NAME_3.6 "Helios" )
  32. SET(_ECLIPSE_VERSION_NAME_3.7 "Indigo" )
  33. IF(_ECLIPSE_VERSION)
  34. MESSAGE(STATUS "Found Eclipse version ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})")
  35. ELSE()
  36. SET(_ECLIPSE_VERSION "3.6" )
  37. MESSAGE(STATUS "Could not determine Eclipse version, assuming at least ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}}). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.")
  38. ENDIF()
  39. SET(CMAKE_ECLIPSE_VERSION "${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})" CACHE STRING "The version of Eclipse. If Eclipse has not been found, 3.6 (Helios) is assumed.")
  40. SET_PROPERTY(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})"
  41. "3.3 (${_ECLIPSE_VERSION_NAME_3.3})"
  42. "3.4 (${_ECLIPSE_VERSION_NAME_3.4})"
  43. "3.5 (${_ECLIPSE_VERSION_NAME_3.5})"
  44. "3.6 (${_ECLIPSE_VERSION_NAME_3.6})"
  45. "3.7 (${_ECLIPSE_VERSION_NAME_3.7})")
  46. ENDFUNCTION()
  47. _FIND_ECLIPSE_VERSION()
  48. # Try to find out how many CPUs we have and set the -j argument for make accordingly
  49. SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "")
  50. INCLUDE(ProcessorCount)
  51. PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT)
  52. # Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name
  53. # (we may also get here in the future e.g. for ninja)
  54. IF("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make)
  55. SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}")
  56. ENDIF()
  57. # This variable is used by the Eclipse generator and appended to the make invocation commands.
  58. SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds")
  59. # This variable is used by the Eclipse generator in out-of-source builds only.
  60. SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
  61. MARK_AS_ADVANCED(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT)
  62. # Determine builtin macros and include dirs:
  63. INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)