CMakeFindEclipseCDT4.cmake 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(APPLE AND NOT _ECLIPSE_FEATURE_DIR)
  24. file(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/../../../features/org.eclipse.platform*")
  25. endif()
  26. if("${_ECLIPSE_FEATURE_DIR}" MATCHES ".+org.eclipse.platform_([0-9]+\\.[0-9]+).+")
  27. set(_ECLIPSE_VERSION ${CMAKE_MATCH_1})
  28. endif()
  29. endif()
  30. # Set up a map with the names of the Eclipse releases:
  31. set(_ECLIPSE_VERSION_NAME_ "Unknown" )
  32. set(_ECLIPSE_VERSION_NAME_3.2 "Callisto" )
  33. set(_ECLIPSE_VERSION_NAME_3.3 "Europa" )
  34. set(_ECLIPSE_VERSION_NAME_3.4 "Ganymede" )
  35. set(_ECLIPSE_VERSION_NAME_3.5 "Galileo" )
  36. set(_ECLIPSE_VERSION_NAME_3.6 "Helios" )
  37. set(_ECLIPSE_VERSION_NAME_3.7 "Indigo" )
  38. set(_ECLIPSE_VERSION_NAME_4.2 "Juno" )
  39. if(_ECLIPSE_VERSION)
  40. message(STATUS "Found Eclipse version ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})")
  41. else()
  42. set(_ECLIPSE_VERSION "3.6" )
  43. 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.")
  44. endif()
  45. 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.")
  46. set_property(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})"
  47. "3.3 (${_ECLIPSE_VERSION_NAME_3.3})"
  48. "3.4 (${_ECLIPSE_VERSION_NAME_3.4})"
  49. "3.5 (${_ECLIPSE_VERSION_NAME_3.5})"
  50. "3.6 (${_ECLIPSE_VERSION_NAME_3.6})"
  51. "3.7 (${_ECLIPSE_VERSION_NAME_3.7})"
  52. "4.2 (${_ECLIPSE_VERSION_NAME_4.2})"
  53. )
  54. endfunction()
  55. _FIND_ECLIPSE_VERSION()
  56. # Try to find out how many CPUs we have and set the -j argument for make accordingly
  57. set(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "")
  58. include(ProcessorCount)
  59. PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT)
  60. # Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name
  61. # (we may also get here in the future e.g. for ninja)
  62. if("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make)
  63. set(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}")
  64. endif()
  65. # This variable is used by the Eclipse generator and appended to the make invocation commands.
  66. 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")
  67. # This variable is used by the Eclipse generator in out-of-source builds only.
  68. set(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
  69. mark_as_advanced(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT)
  70. # Determine builtin macros and include dirs:
  71. include(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)