cmake.mk 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ################################################################################
  2. #
  3. # cmake
  4. #
  5. ################################################################################
  6. # When updating the version, please also update BR2_HOST_CMAKE_AT_LEAST_X_Y
  7. CMAKE_VERSION_MAJOR = 3.28
  8. CMAKE_VERSION = $(CMAKE_VERSION_MAJOR).3
  9. CMAKE_SITE = https://cmake.org/files/v$(CMAKE_VERSION_MAJOR)
  10. CMAKE_LICENSE = BSD-3-Clause
  11. CMAKE_LICENSE_FILES = Copyright.txt
  12. CMAKE_CPE_ID_VALID = YES
  13. # Tool download MITM attack warning if using npm package to install cmake
  14. CMAKE_IGNORE_CVES = CVE-2016-10642
  15. # CMake is a particular package:
  16. # * CMake can be built using the generic infrastructure or the cmake one.
  17. # Since Buildroot has no requirement regarding the host system cmake
  18. # program presence, it uses the generic infrastructure to build the
  19. # host-cmake package, then the (target-)cmake package can be built
  20. # using the cmake infrastructure;
  21. # * CMake bundles its dependencies within its sources. This is the
  22. # reason why the host-cmake package has no dependencies:, whereas
  23. # the (target-)cmake package has a lot of dependencies, using only
  24. # the system-wide libraries instead of rebuilding and statically
  25. # linking with the ones bundled into the CMake sources.
  26. CMAKE_DEPENDENCIES = zlib jsoncpp libcurl libarchive expat bzip2 xz libuv rhash
  27. CMAKE_CONF_OPTS = \
  28. -DKWSYS_LFS_WORKS=TRUE \
  29. -DKWSYS_CHAR_IS_SIGNED=TRUE \
  30. -DCMAKE_USE_SYSTEM_LIBRARIES=1 \
  31. -DCTEST_USE_XMLRPC=OFF \
  32. -DCMake_ENABLE_DEBUGGER=0 \
  33. -DBUILD_CursesDialog=OFF
  34. # Get rid of -I* options from $(HOST_CPPFLAGS) to prevent that a
  35. # header available in $(HOST_DIR)/include is used instead of a
  36. # CMake internal header, e.g. lzma* headers of the xz package
  37. HOST_CMAKE_CFLAGS = $(shell echo $(HOST_CFLAGS) | sed -r "s%$(HOST_CPPFLAGS)%%")
  38. HOST_CMAKE_CXXFLAGS = $(shell echo $(HOST_CXXFLAGS) | sed -r "s%$(HOST_CPPFLAGS)%%")
  39. # We may be a ccache dependency, so we can't use ccache
  40. HOST_CMAKE_CONFIGURE_OPTS = \
  41. $(HOST_CONFIGURE_OPTS) \
  42. CC="$(HOSTCC_NOCCACHE)" \
  43. GCC="$(HOSTCC_NOCCACHE)" \
  44. CXX="$(HOSTCXX_NOCCACHE)"
  45. define HOST_CMAKE_CONFIGURE_CMDS
  46. (cd $(@D); \
  47. $(HOST_CMAKE_CONFIGURE_OPTS) \
  48. CFLAGS="$(HOST_CMAKE_CFLAGS)" \
  49. ./bootstrap --prefix=$(HOST_DIR) \
  50. --parallel=$(PARALLEL_JOBS) -- \
  51. -DCMAKE_C_FLAGS="$(HOST_CMAKE_CFLAGS)" \
  52. -DCMAKE_CXX_FLAGS="$(HOST_CMAKE_CXXFLAGS)" \
  53. -DCMAKE_EXE_LINKER_FLAGS="$(HOST_LDFLAGS)" \
  54. -DCMAKE_USE_OPENSSL:BOOL=OFF \
  55. -DBUILD_CursesDialog=OFF \
  56. )
  57. endef
  58. define HOST_CMAKE_BUILD_CMDS
  59. $(HOST_MAKE_ENV) $(MAKE) -C $(@D)
  60. endef
  61. define HOST_CMAKE_INSTALL_CMDS
  62. $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install/fast
  63. endef
  64. define CMAKE_REMOVE_EXTRA_DATA
  65. rm $(TARGET_DIR)/usr/bin/{cmake,cpack}
  66. rm -fr $(TARGET_DIR)/usr/share/cmake-$(CMAKE_VERSION_MAJOR)/{completions,editors}
  67. rm -fr $(TARGET_DIR)/usr/share/cmake-$(CMAKE_VERSION_MAJOR)/{Help,include}
  68. endef
  69. define CMAKE_INSTALL_CTEST_CFG_FILE
  70. $(INSTALL) -m 0644 -D $(@D)/Modules/CMake.cmake \
  71. $(TARGET_DIR)/usr/share/cmake-$(CMAKE_VERSION_MAJOR)/Modules/CMake.cmake.ctest
  72. endef
  73. CMAKE_POST_INSTALL_TARGET_HOOKS += CMAKE_REMOVE_EXTRA_DATA
  74. CMAKE_POST_INSTALL_TARGET_HOOKS += CMAKE_INSTALL_CTEST_CFG_FILE
  75. define CMAKE_INSTALL_TARGET_CMDS
  76. (cd $(@D); \
  77. $(HOST_MAKE_ENV) DESTDIR=$(TARGET_DIR) \
  78. cmake -P cmake_install.cmake \
  79. )
  80. endef
  81. $(eval $(cmake-package))
  82. $(eval $(host-generic-package))