CMakeFindEclipseCDT4.cmake 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. # use REALPATH to resolve symlinks (http://public.kitware.com/Bug/view.php?id=13036)
  20. GET_FILENAME_COMPONENT(_REALPATH_CMAKE_ECLIPSE_EXECUTABLE "${CMAKE_ECLIPSE_EXECUTABLE}" REALPATH)
  21. GET_FILENAME_COMPONENT(_ECLIPSE_DIR "${_REALPATH_CMAKE_ECLIPSE_EXECUTABLE}" PATH)
  22. FILE(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/features/org.eclipse.platform*")
  23. IF("${_ECLIPSE_FEATURE_DIR}" MATCHES ".+org.eclipse.platform_([0-9]+\\.[0-9]+).+")
  24. SET(_ECLIPSE_VERSION ${CMAKE_MATCH_1})
  25. ENDIF()
  26. ENDIF()
  27. # Set up a map with the names of the Eclipse releases:
  28. SET(_ECLIPSE_VERSION_NAME_ "Unknown" )
  29. SET(_ECLIPSE_VERSION_NAME_3.2 "Callisto" )
  30. SET(_ECLIPSE_VERSION_NAME_3.3 "Europa" )
  31. SET(_ECLIPSE_VERSION_NAME_3.4 "Ganymede" )
  32. SET(_ECLIPSE_VERSION_NAME_3.5 "Galileo" )
  33. SET(_ECLIPSE_VERSION_NAME_3.6 "Helios" )
  34. SET(_ECLIPSE_VERSION_NAME_3.7 "Indigo" )
  35. IF(_ECLIPSE_VERSION)
  36. MESSAGE(STATUS "Found Eclipse version ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})")
  37. ELSE()
  38. SET(_ECLIPSE_VERSION "3.6" )
  39. 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.")
  40. ENDIF()
  41. 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.")
  42. SET_PROPERTY(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})"
  43. "3.3 (${_ECLIPSE_VERSION_NAME_3.3})"
  44. "3.4 (${_ECLIPSE_VERSION_NAME_3.4})"
  45. "3.5 (${_ECLIPSE_VERSION_NAME_3.5})"
  46. "3.6 (${_ECLIPSE_VERSION_NAME_3.6})"
  47. "3.7 (${_ECLIPSE_VERSION_NAME_3.7})")
  48. ENDFUNCTION()
  49. _FIND_ECLIPSE_VERSION()
  50. # Try to find out how many CPUs we have and set the -j argument for make accordingly
  51. SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "")
  52. INCLUDE(ProcessorCount)
  53. PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT)
  54. # Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name
  55. # (we may also get here in the future e.g. for ninja)
  56. IF("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make)
  57. SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}")
  58. ENDIF()
  59. # This variable is used by the Eclipse generator and appended to the make invocation commands.
  60. 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")
  61. # This variable is used by the Eclipse generator in out-of-source builds only.
  62. SET(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
  63. MARK_AS_ADVANCED(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT)
  64. # Determine builtin macros and include dirs:
  65. INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)