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