0100-cmake-backport-from-LEDE-17.01-d1e0cc8cd5b460df47a2316653c273e27ebf93b1.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Tue, 9 May 2017 18:37:17 +0200
  3. Subject: cmake: backport from LEDE 17.01 d1e0cc8cd5b460df47a2316653c273e27ebf93b1
  4. diff --git a/include/cmake.mk b/include/cmake.mk
  5. index 4207a4dcee8444ac1472b2b78a068e5ed811c7ae..68dccc969f54e0d84e04404711dc2724120a23d3 100644
  6. --- a/include/cmake.mk
  7. +++ b/include/cmake.mk
  8. @@ -1,10 +1,15 @@
  9. +cmake_bool = $(patsubst %,-D%:BOOL=$(if $($(1)),ON,OFF),$(2))
  10. +
  11. PKG_INSTALL:=1
  12. ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
  13. MAKE_FLAGS+=VERBOSE=1
  14. endif
  15. -CMAKE_SOURCE_DIR:=.
  16. +CMAKE_BINARY_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR))
  17. +CMAKE_SOURCE_DIR = $(PKG_BUILD_DIR)
  18. +HOST_CMAKE_SOURCE_DIR = $(HOST_BUILD_DIR)
  19. +MAKE_PATH = $(firstword $(CMAKE_BINARY_SUBDIR) .)
  20. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  21. cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1)
  22. @@ -18,10 +23,7 @@ ifeq ($(CONFIG_CCACHE),)
  23. CMAKE_C_COMPILER_ARG1:=
  24. CMAKE_CXX_COMPILER_ARG1:=
  25. else
  26. - CCACHE:=$(shell which ccache)
  27. - ifeq ($(CCACHE),)
  28. - CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
  29. - endif
  30. + CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
  31. CMAKE_C_COMPILER:=$(CCACHE)
  32. CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
  33. CMAKE_CXX_COMPILER:=$(CCACHE)
  34. @@ -31,14 +33,15 @@ CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
  35. CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
  36. CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
  37. -CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR);$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
  38. -CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR_HOST)
  39. +CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_TOOLCHAIN),;$(CONFIG_TOOLCHAIN_ROOT))
  40. +CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOST)
  41. CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
  42. define Build/Configure/Default
  43. - (cd $(PKG_BUILD_DIR); \
  44. + mkdir -p $(CMAKE_BINARY_DIR)
  45. + (cd $(CMAKE_BINARY_DIR); \
  46. CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  47. - CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  48. + CXXFLAGS="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
  49. LDFLAGS="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
  50. cmake \
  51. -DCMAKE_SYSTEM_NAME=Linux \
  52. @@ -101,6 +104,10 @@ define Host/Configure/Default
  53. -DCMAKE_PREFIX_PATH=$(STAGING_DIR_HOST) \
  54. -DCMAKE_SKIP_RPATH=TRUE \
  55. $(CMAKE_HOST_OPTIONS) \
  56. - $(CMAKE_SOURCE_DIR) \
  57. + $(HOST_CMAKE_SOURCE_DIR) \
  58. )
  59. endef
  60. +
  61. +MAKE_FLAGS += \
  62. + CMAKE_COMMAND='$$(if $$(CMAKE_DISABLE_$$@),:,$(STAGING_DIR_HOST)/bin/cmake)' \
  63. + CMAKE_DISABLE_cmake_check_build_system=1
  64. diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile
  65. index 08e2b028150dd4f496e3a8ebccf27bd49b6937c2..e14cd7c4b2d5bc92d50a66f1c95599b5049db10d 100644
  66. --- a/tools/cmake/Makefile
  67. +++ b/tools/cmake/Makefile
  68. @@ -1,5 +1,5 @@
  69. #
  70. -# Copyright (C) 2006-2014 OpenWrt.org
  71. +# Copyright (C) 2006-2016 OpenWrt.org
  72. #
  73. # This is free software, licensed under the GNU General Public License v2.
  74. # See /LICENSE for more information.
  75. @@ -7,11 +7,12 @@
  76. include $(TOPDIR)/rules.mk
  77. PKG_NAME:=cmake
  78. -PKG_VERSION:=2.8.12.2
  79. +PKG_VERSION:=3.7.1
  80. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  81. -PKG_SOURCE_URL:=http://www.cmake.org/files/v2.8/
  82. -PKG_MD5SUM:=17c6513483d23590cbce6957ec6d1e66
  83. +PKG_SOURCE_URL:=https://cmake.org/files/v3.7/ \
  84. + https://fossies.org/linux/misc/
  85. +PKG_MD5SUM:=d031d5a06e9f1c5367cdfc56fbd2a1c8
  86. HOST_BUILD_PARALLEL:=1
  87. HOST_CONFIGURE_PARALLEL:=1
  88. @@ -21,7 +22,11 @@ include $(INCLUDE_DIR)/host-build.mk
  89. HOST_CONFIGURE_VARS :=
  90. HOST_CONFIGURE_ARGS := \
  91. - --prefix=$(STAGING_DIR_HOST) \
  92. - $(if $(MAKE_JOBSERVER),--parallel="$(MAKE_JOBSERVER)")
  93. + $(if $(MAKE_JOBSERVER),--parallel="$(MAKE_JOBSERVER)") \
  94. + --prefix=$(STAGING_DIR_HOST)
  95. +
  96. +define Host/Configure
  97. + $(call Host/Configure/Default,$(1),$(2) MAKEFLAGS="$(HOST_JOBS)" CXXFLAGS="$(HOST_CFLAGS)",$(3))
  98. +endef
  99. $(eval $(call HostBuild))
  100. diff --git a/tools/cmake/patches/100-disable_qt_tests.patch b/tools/cmake/patches/100-disable_qt_tests.patch
  101. index 3d44dac53f27c5cf2b1c1c03689255c0825a65b9..6f28c435e018f53fedc3ba840298b6aaf8a07e9b 100644
  102. --- a/tools/cmake/patches/100-disable_qt_tests.patch
  103. +++ b/tools/cmake/patches/100-disable_qt_tests.patch
  104. @@ -1,8 +1,8 @@
  105. --- a/Tests/RunCMake/CMakeLists.txt
  106. +++ b/Tests/RunCMake/CMakeLists.txt
  107. -@@ -101,16 +101,6 @@
  108. - add_RunCMake_test(TargetPolicies)
  109. - add_RunCMake_test(alias_targets)
  110. +@@ -225,15 +225,6 @@ add_RunCMake_test(no_install_prefix)
  111. + add_RunCMake_test(configure_file)
  112. + add_RunCMake_test(CTestTimeoutAfterMatch)
  113. -find_package(Qt4 QUIET)
  114. -find_package(Qt5Core QUIET)
  115. @@ -10,21 +10,20 @@
  116. - add_RunCMake_test(IncompatibleQt)
  117. -endif()
  118. -if (QT4_FOUND)
  119. -- set(ObsoleteQtMacros_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE})
  120. -- add_RunCMake_test(ObsoleteQtMacros)
  121. +- add_RunCMake_test(ObsoleteQtMacros -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE})
  122. -endif()
  123. -
  124. - if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
  125. - add_RunCMake_test(include_external_msproject)
  126. - add_RunCMake_test(SolutionGlobalSections)
  127. + find_package(PkgConfig QUIET)
  128. + if(PKG_CONFIG_FOUND)
  129. + add_RunCMake_test(FindPkgConfig)
  130. --- a/Tests/CMakeLists.txt
  131. +++ b/Tests/CMakeLists.txt
  132. -@@ -262,10 +262,6 @@
  133. +@@ -393,10 +393,6 @@ if(BUILD_TESTING)
  134. list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
  135. - if(NOT QT4_FOUND)
  136. -- find_package(Qt4)
  137. +- find_package(Qt4 QUIET)
  138. - endif()
  139. -
  140. if(QT4_FOUND)
  141. diff --git a/tools/cmake/patches/110-freebsd-compat.patch b/tools/cmake/patches/110-freebsd-compat.patch
  142. index d4133b9049059f1b1cfa0c63be1308b4c235c981..c1d4a274d61c3c0b81288ba4260abd34ce76063c 100644
  143. --- a/tools/cmake/patches/110-freebsd-compat.patch
  144. +++ b/tools/cmake/patches/110-freebsd-compat.patch
  145. @@ -19,11 +19,9 @@ Change-Id: I3b91ed7ac0e6878035aee202b3336c536cc6d2ff
  146. Source/kwsys/SystemInformation.cxx | 9 +++++++++
  147. 1 file changed, 9 insertions(+)
  148. -diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
  149. -index 7c31f3a..2672730 100644
  150. --- a/Source/kwsys/SystemInformation.cxx
  151. +++ b/Source/kwsys/SystemInformation.cxx
  152. -@@ -88,6 +88,15 @@ typedef int siginfo_t;
  153. +@@ -89,6 +89,15 @@ typedef int siginfo_t;
  154. # include <ifaddrs.h>
  155. # define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
  156. # endif
  157. @@ -38,7 +36,4 @@ index 7c31f3a..2672730 100644
  158. +# endif
  159. #endif
  160. - #if defined(__OpenBSD__) || defined(__NetBSD__)
  161. ---
  162. -1.7.10.4
  163. -
  164. + #if defined(KWSYS_SYS_HAS_MACHINE_CPU_H)
  165. diff --git a/tools/cmake/patches/120-alpine_musl-compat.patch b/tools/cmake/patches/120-alpine_musl-compat.patch
  166. new file mode 100644
  167. index 0000000000000000000000000000000000000000..ae93201e53659514e2a63fc813622302bde5be59
  168. --- /dev/null
  169. +++ b/tools/cmake/patches/120-alpine_musl-compat.patch
  170. @@ -0,0 +1,17 @@
  171. +--- a/Utilities/cmjsoncpp/include/json/assertions.h
  172. ++++ b/Utilities/cmjsoncpp/include/json/assertions.h
  173. +@@ -6,12 +6,12 @@
  174. + #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
  175. + #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
  176. +
  177. ++#include <stdlib.h>
  178. ++
  179. + #if !defined(JSON_IS_AMALGAMATION)
  180. + #include "config.h"
  181. + #endif // if !defined(JSON_IS_AMALGAMATION)
  182. +
  183. +-#include <stdlib.h>
  184. +-
  185. + #if JSON_USE_EXCEPTION
  186. + #include <stdexcept>
  187. + #define JSON_ASSERT(condition) \
  188. diff --git a/tools/cmake/patches/130-libarchive-fix-libressl-compat.patch b/tools/cmake/patches/130-libarchive-fix-libressl-compat.patch
  189. new file mode 100644
  190. index 0000000000000000000000000000000000000000..a56ac2ed0c96dd90707e582e83320fd408f90dab
  191. --- /dev/null
  192. +++ b/tools/cmake/patches/130-libarchive-fix-libressl-compat.patch
  193. @@ -0,0 +1,22 @@
  194. +--- a/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h
  195. ++++ b/Utilities/cmlibarchive/libarchive/archive_openssl_evp_private.h
  196. +@@ -28,7 +28,7 @@
  197. + #include <openssl/evp.h>
  198. + #include <openssl/opensslv.h>
  199. +
  200. +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
  201. ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  202. + #include <stdlib.h> /* malloc, free */
  203. + #include <string.h> /* memset */
  204. + static inline EVP_MD_CTX *EVP_MD_CTX_new(void)
  205. +--- a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
  206. ++++ b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
  207. +@@ -28,7 +28,7 @@
  208. + #include <openssl/hmac.h>
  209. + #include <openssl/opensslv.h>
  210. +
  211. +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
  212. ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  213. + #include <stdlib.h> /* malloc, free */
  214. + #include <string.h> /* memset */
  215. + static inline HMAC_CTX *HMAC_CTX_new(void)
  216. diff --git a/tools/cmake/patches/140-curl-fix-libressl-linking.patch b/tools/cmake/patches/140-curl-fix-libressl-linking.patch
  217. new file mode 100644
  218. index 0000000000000000000000000000000000000000..5b57172eb4a147d25be01b105dd49599f1add4e6
  219. --- /dev/null
  220. +++ b/tools/cmake/patches/140-curl-fix-libressl-linking.patch
  221. @@ -0,0 +1,32 @@
  222. +From: Jo-Philipp Wich <jo@mein.io>
  223. +Date: Wed, 11 Jan 2017 03:36:04 +0100
  224. +Subject: [PATCH] cmcurl: link librt
  225. +
  226. +When cmake is linked against LibreSSL, there might be an indirect
  227. +dependency on librt on certain systems if LibreSSL's libcrypto uses
  228. +clock_gettime() from librt:
  229. +
  230. + [ 28%] Linking C executable LIBCURL
  231. + .../lib/libcrypto.a(getentropy_linux.o): In function `getentropy_fallback':
  232. + getentropy_linux.c:(.text+0x16d): undefined reference to `clock_gettime'
  233. + getentropy_linux.c:(.text+0x412): undefined reference to `clock_gettime'
  234. + collect2: error: ld returned 1 exit status
  235. + make[5]: *** [Utilities/cmcurl/LIBCURL] Error 1
  236. +
  237. +Modify the cmcurl CMakeLists.txt to check for clock_gettime() in librt
  238. +and unconditionally link the rt library when the symbol is found.
  239. +
  240. +Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  241. +--- a/Utilities/cmcurl/CMakeLists.txt
  242. ++++ b/Utilities/cmcurl/CMakeLists.txt
  243. +@@ -362,6 +362,10 @@ set(HAVE_LIBSSL OFF)
  244. + if(CMAKE_USE_OPENSSL)
  245. + find_package(OpenSSL)
  246. + if(OPENSSL_FOUND)
  247. ++ check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
  248. ++ if(HAVE_LIBRT)
  249. ++ list(APPEND OPENSSL_LIBRARIES rt)
  250. ++ endif()
  251. + list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
  252. + set(USE_OPENSSL ON)
  253. + set(HAVE_LIBCRYPTO ON)
  254. diff --git a/tools/cmake/patches/150-bootstrap_parallel_make_flag.patch b/tools/cmake/patches/150-bootstrap_parallel_make_flag.patch
  255. new file mode 100644
  256. index 0000000000000000000000000000000000000000..6970b83b327c348d31d74dc5facba4fad46fe700
  257. --- /dev/null
  258. +++ b/tools/cmake/patches/150-bootstrap_parallel_make_flag.patch
  259. @@ -0,0 +1,14 @@
  260. +--- a/bootstrap
  261. ++++ b/bootstrap
  262. +@@ -958,7 +958,10 @@ int main(){ printf("1%c", (char)0x0a); r
  263. + ' > "test.c"
  264. + cmake_original_make_flags="${cmake_make_flags}"
  265. + if [ "x${cmake_parallel_make}" != "x" ]; then
  266. +- cmake_make_flags="${cmake_make_flags} -j ${cmake_parallel_make}"
  267. ++ case "$cmake_paralle_make" in
  268. ++ [0-9]*) cmake_parallel_make="-j ${cmake_parallel_make}";;
  269. ++ esac
  270. ++ cmake_make_flags="${cmake_make_flags} ${cmake_parallel_make}"
  271. + fi
  272. + for a in ${cmake_make_processors}; do
  273. + if [ -z "${cmake_make_processor}" ] && cmake_try_make "${a}" "${cmake_make_flags}" >> ../cmake_bootstrap.log 2>&1; then