CMakeFindEclipseCDT4.cmake 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This file is included in CMakeSystemSpecificInformation.cmake if
  4. # the Eclipse CDT4 extra generator has been selected.
  5. find_program(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse DOC "The Eclipse executable")
  6. function(_FIND_ECLIPSE_VERSION)
  7. # This code is in a function so the variables used here have only local scope
  8. # Set up a map with the names of the Eclipse releases:
  9. set(_ECLIPSE_VERSION_NAME_ "Unknown" )
  10. set(_ECLIPSE_VERSION_NAME_3.2 "Callisto" )
  11. set(_ECLIPSE_VERSION_NAME_3.3 "Europa" )
  12. set(_ECLIPSE_VERSION_NAME_3.4 "Ganymede" )
  13. set(_ECLIPSE_VERSION_NAME_3.5 "Galileo" )
  14. set(_ECLIPSE_VERSION_NAME_3.6 "Helios" )
  15. set(_ECLIPSE_VERSION_NAME_3.7 "Indigo" )
  16. set(_ECLIPSE_VERSION_NAME_4.2 "Juno" )
  17. set(_ECLIPSE_VERSION_NAME_4.3 "Kepler" )
  18. set(_ECLIPSE_VERSION_NAME_4.4 "Luna" )
  19. set(_ECLIPSE_VERSION_NAME_4.5 "Mars" )
  20. if(NOT DEFINED CMAKE_ECLIPSE_VERSION)
  21. if(CMAKE_ECLIPSE_EXECUTABLE)
  22. # use REALPATH to resolve symlinks (https://gitlab.kitware.com/cmake/cmake/issues/13036)
  23. get_filename_component(_REALPATH_CMAKE_ECLIPSE_EXECUTABLE "${CMAKE_ECLIPSE_EXECUTABLE}" REALPATH)
  24. get_filename_component(_ECLIPSE_DIR "${_REALPATH_CMAKE_ECLIPSE_EXECUTABLE}" PATH)
  25. file(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/features/org.eclipse.platform*")
  26. if(APPLE AND NOT _ECLIPSE_FEATURE_DIR)
  27. file(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/../../../features/org.eclipse.platform*")
  28. endif()
  29. if("${_ECLIPSE_FEATURE_DIR}" MATCHES ".+org.eclipse.platform_([0-9]+\\.[0-9]+).+")
  30. set(_ECLIPSE_VERSION ${CMAKE_MATCH_1})
  31. endif()
  32. endif()
  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. else()
  41. message(STATUS "Eclipse version is set to ${CMAKE_ECLIPSE_VERSION}. Adjust CMAKE_ECLIPSE_VERSION if this is wrong.")
  42. endif()
  43. set_property(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})"
  44. "3.3 (${_ECLIPSE_VERSION_NAME_3.3})"
  45. "3.4 (${_ECLIPSE_VERSION_NAME_3.4})"
  46. "3.5 (${_ECLIPSE_VERSION_NAME_3.5})"
  47. "3.6 (${_ECLIPSE_VERSION_NAME_3.6})"
  48. "3.7 (${_ECLIPSE_VERSION_NAME_3.7})"
  49. "4.2 (${_ECLIPSE_VERSION_NAME_4.2})"
  50. "4.3 (${_ECLIPSE_VERSION_NAME_4.3})"
  51. "4.4 (${_ECLIPSE_VERSION_NAME_4.4})"
  52. "4.5 (${_ECLIPSE_VERSION_NAME_4.5})"
  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 CMAKE_HOST_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. set(CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES TRUE CACHE BOOL "If disabled, CMake will not generate linked resource to the subprojects and to the source files within targets")
  68. # This variable is used by the Eclipse generator in out-of-source builds only.
  69. set(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
  70. mark_as_advanced(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT)
  71. # Determine builtin macros and include dirs:
  72. include(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)