CMakeLists.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. ###############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. #
  17. #########################################################
  18. # Description:
  19. # ------------
  20. # This file is the top level handling for
  21. # cmake based compilation and build process.
  22. #
  23. # To build for Linux:
  24. # 1. Check out sources (for example, to directory ~/hpcc)
  25. # 2. Create a build directory - either as a child of hpcc or elsewhere
  26. # 3. cd to the build directory
  27. # 4a.To create makefiles to build native release version for local machine, run
  28. # cmake ~/hpcc
  29. # 4b.To create makefiles to build native debug version, run
  30. # cmake -DCMAKE_BUILD_TYPE=Debug ~/hpcc
  31. # 4c.To create makefiles to build 32-bit version from 64-bit host, run
  32. # cmake -DCMAKE_C_FLAGS:STRING="-m32 -march=i386" -DCMAKE_CXX_FLAGS:STRING="-m32 -march=i386" ~/hpcc
  33. # 5. To build the makefiles just created above, run
  34. # make
  35. # 6. Executables will be created in ./<releasemode>/bin and ./<releasemode>/libs
  36. #
  37. # To build for Windows:
  38. # 1. Check out sources (for example, to directory c:\hpcc)
  39. # 2. Create a build directory - either as a child of hpcc or elsewhere
  40. # 3. cd to the build directory
  41. # 4. To create a Visual Studio project, run
  42. # cmake c:\hpcc -G "Visual Studio 9 2008"
  43. # The sln file hpccsystems-platform.sln will be created in the current directory, and will support debug and release targets
  44. # 5. To build the project, load the solution into the visual studio IDE and build in the usual way.
  45. # 6. Executables will be created in .\hpcc\bin\<release_mode>
  46. #
  47. # To create a development installation on Linux:
  48. # 1. Check out sources (for example, to directory ~/hpcc)
  49. # 2. Create a build directory alongside your source
  50. # 3. To create makefiles and have the ability to run the applications as non-superuser, execute
  51. # cmake -DRUNTIME_USER=$USER -DRUNTIME_GROUP=groupname -DDESTDIR=$HOME/myruntime ~/hpcc
  52. # 4. To build the makefiles just created above, run
  53. # make
  54. # 5. To install the project under DESTDIR, run
  55. # make install
  56. # 6. To populate environment xml's and conf files necessary for running your development installation, run
  57. # make configure
  58. # 7a.To start up the platform, execute all binaries and scripts under DESTDIR as a regular user, example
  59. # $HOME/myruntime/etc/init.d/hpcc-init start
  60. # 7b.All runtime files will be under $HOME/myruntime/var/{log,lib,run,lock}
  61. # 8a.To patch your running installation, simply modify the source, and then from the build directory run
  62. # make install
  63. # Which will recompile any changes and only install files into the platform that have been modified
  64. # 8b.Restart the platform (or specific component that had modifications), example
  65. # $HOME/myruntime/etc/init.d/hpcc-init restart
  66. #
  67. #########################################################
  68. cmake_minimum_required(VERSION 3.16.0)
  69. set(HPCC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  70. include(${HPCC_SOURCE_DIR}/version.cmake)
  71. project(hpccsystems-platform LANGUAGES C CXX
  72. VERSION ${HPCC_MAJOR}.${HPCC_MINOR}.${HPCC_POINT}.${HPCC_SEQUENCE}
  73. )
  74. # Stupid workaround. See https://gitlab.kitware.com/cmake/cmake/-/issues/21378
  75. # If cmake runs twice, cmake might not correctly set the compiler version variables
  76. unset ( ENV{CC} )
  77. unset ( ENV{CXX} )
  78. set(TOP_LEVEL_PROJECT ON)
  79. if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  80. set(TOP_LEVEL_PROJECT OFF)
  81. endif(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  82. include(CTest)
  83. enable_testing()
  84. set(CMAKE_MODULE_PATH "${HPCC_SOURCE_DIR}/cmake_modules/")
  85. ###
  86. ## Build Level
  87. ###
  88. if(NOT BUILD_LEVEL)
  89. set(BUILD_LEVEL "COMMUNITY")
  90. endif(NOT BUILD_LEVEL)
  91. if ("${BUILD_LEVEL}" STREQUAL "COMMUNITY")
  92. set ( HPCC_PROJECT_ABBR "CC")
  93. endif()
  94. ###
  95. ## Config Block
  96. ###
  97. option(PREFIX "Set the install prefix")
  98. option(EXEC_PREFIX "Set the execution prefix")
  99. option(CONFIG_PREFIX "Set the configuration prefix")
  100. option(DIR_NAME "Set the install directory name")
  101. option(LIB_DIR "Set the library install dir")
  102. option(EXEC_DIR "Set the executable install dir")
  103. option(COMPONENTFILES_DIR "Set the componentfiles dir")
  104. option(ADMIN_DIR "Set the admin dir")
  105. option(PLUGINS_DIR "Set the plugins dir")
  106. option(CONFIG_SOURCE_DIR "Set the configuration source dir")
  107. option(RUNTIME_DIR "Set the runtime dir")
  108. option(HOME_DIR "Set the home dir")
  109. option(LOCK_DIR "Set the lock dir")
  110. option(PID_DIR "Set the pid dir")
  111. option(LOG_DIR "Set the log dir")
  112. option(RUNTIME_USER "Set the runtime username")
  113. option(RUNTIME_GROUP "Set the runtime group")
  114. option(ENV_XML_FILE "Set the environment xml file name.")
  115. option(ENV_CONF_FILE "Set the environment conf file name.")
  116. option(LICENSE_FILE "Set the license file to use.")
  117. option(DESTDIR "Set the alternate root installation path.")
  118. if(NOT LICENSE_FILE)
  119. if(REMBED)
  120. set(LICENSE_FILE "R-LICENSE.txt")
  121. else ()
  122. set(LICENSE_FILE "LICENSE.txt")
  123. endif()
  124. endif()
  125. include(${HPCC_SOURCE_DIR}/cmake_modules/optionDefaults.cmake)
  126. set(CMAKE_INSTALL_MESSAGE LAZY)
  127. if ( REMBED AND (NOT INCLUDE_PLUGINS) )
  128. # various components that are not needed if only making the R plugin
  129. SET(USE_LIBARCHIVE 0)
  130. SET(USE_APR 0)
  131. endif()
  132. include(${HPCC_SOURCE_DIR}/cmake_modules/commonSetup.cmake)
  133. if ( PLUGIN )
  134. HPCC_ADD_SUBDIRECTORY (system/yaml)
  135. HPCC_ADD_SUBDIRECTORY (system/aws "SQS")
  136. HPCC_ADD_SUBDIRECTORY (system/tbb_sm)
  137. HPCC_ADD_SUBDIRECTORY (roxie/roxiemem)
  138. HPCC_ADD_SUBDIRECTORY (rtl/nbcd)
  139. HPCC_ADD_SUBDIRECTORY (rtl/eclrtl)
  140. HPCC_ADD_SUBDIRECTORY (system/jlib)
  141. HPCC_ADD_SUBDIRECTORY (dali/base)
  142. HPCC_ADD_SUBDIRECTORY (plugins/Rembed "REMBED")
  143. HPCC_ADD_SUBDIRECTORY (plugins/v8embed "V8EMBED")
  144. HPCC_ADD_SUBDIRECTORY (plugins/memcached "MEMCACHED")
  145. HPCC_ADD_SUBDIRECTORY (plugins/redis "REDIS")
  146. HPCC_ADD_SUBDIRECTORY (plugins/javaembed "JAVAEMBED")
  147. HPCC_ADD_SUBDIRECTORY (plugins/kafka "KAFKA")
  148. HPCC_ADD_SUBDIRECTORY (plugins/sqs "SQS")
  149. HPCC_ADD_SUBDIRECTORY (plugins/sqlite3 "SQLITE3EMBED")
  150. HPCC_ADD_SUBDIRECTORY (plugins/mysql "MYSQLEMBED")
  151. HPCC_ADD_SUBDIRECTORY (plugins/exampleplugin "EXAMPLEPLUGIN")
  152. HPCC_ADD_SUBDIRECTORY (plugins/couchbase "COUCHBASEEMBED")
  153. HPCC_ADD_SUBDIRECTORY (plugins/spark "SPARK")
  154. HPCC_ADD_SUBDIRECTORY (plugins/h3 "H3")
  155. HPCC_ADD_SUBDIRECTORY (plugins/nlp "NLP")
  156. elseif ( NOT MAKE_DOCS_ONLY )
  157. HPCC_ADD_SUBDIRECTORY (system)
  158. HPCC_ADD_SUBDIRECTORY (initfiles)
  159. HPCC_ADD_SUBDIRECTORY (tools)
  160. HPCC_ADD_SUBDIRECTORY (common)
  161. HPCC_ADD_SUBDIRECTORY (dali)
  162. HPCC_ADD_SUBDIRECTORY (ecl)
  163. HPCC_ADD_SUBDIRECTORY (ecllibrary)
  164. HPCC_ADD_SUBDIRECTORY (esp)
  165. HPCC_ADD_SUBDIRECTORY (fs)
  166. HPCC_ADD_SUBDIRECTORY (plugins)
  167. HPCC_ADD_SUBDIRECTORY (roxie)
  168. HPCC_ADD_SUBDIRECTORY (rtl)
  169. HPCC_ADD_SUBDIRECTORY (services "PLATFORM")
  170. HPCC_ADD_SUBDIRECTORY (thorlcr "PLATFORM")
  171. HPCC_ADD_SUBDIRECTORY (system/metrics)
  172. HPCC_ADD_SUBDIRECTORY (testing)
  173. if (NOT CONTAINERIZED)
  174. HPCC_ADD_SUBDIRECTORY (deploy)
  175. HPCC_ADD_SUBDIRECTORY (deployment)
  176. HPCC_ADD_SUBDIRECTORY (configuration)
  177. endif()
  178. if ( WIN32 )
  179. HPCC_ADD_SUBDIRECTORY (clienttools/IDEPlugins "CLIENTTOOLS_ONLY")
  180. HPCC_ADD_SUBDIRECTORY (clienttools/win "CLIENTTOOLS_ONLY")
  181. else()
  182. HPCC_ADD_SUBDIRECTORY (clienttools "CLIENTTOOLS_ONLY")
  183. endif()
  184. endif()
  185. HPCC_ADD_SUBDIRECTORY(docs "PLATFORM")
  186. if (NOT VCPKG_APPLOCAL_DEPS)
  187. if(APPLE OR WIN32)
  188. HPCC_ADD_SUBDIRECTORY(lib2)
  189. endif(APPLE OR WIN32)
  190. endif()
  191. if(APPLE)
  192. HPCC_ADD_SUBDIRECTORY(package)
  193. endif(APPLE)
  194. ###
  195. ## CPack install and packaging setup.
  196. ###
  197. if ( WIN32 )
  198. set ( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE )
  199. include(InstallRequiredSystemLibraries)
  200. if (MSVC_VERSION GREATER_EQUAL 1900)
  201. message("MSVC_REDIST_DIR: ${MSVC_REDIST_DIR}")
  202. find_file(MSVC_REDIST "vcredist_${CMAKE_MSVC_ARCH}.exe" HINTS ${MSVC_REDIST_DIR})
  203. if (EXISTS "${MSVC_REDIST}")
  204. install ( PROGRAMS ${MSVC_REDIST} DESTINATION tmp )
  205. get_filename_component(MSVC_REDIST_NAME ${MSVC_REDIST} NAME)
  206. list ( APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
  207. ExecWait '$INSTDIR\\\\tmp\\\\${MSVC_REDIST_NAME} /S'
  208. ")
  209. else ()
  210. MESSAGE(FATAL_ERROR "-- Unable to locate vcredist_x86.exe")
  211. endif ()
  212. else ()
  213. MESSAGE(FATAL_ERROR "-- Unknown compiler version")
  214. endif ()
  215. endif ()
  216. set(VER_SEPARATOR "-")
  217. if("${stagever}" MATCHES "^rc[0-9]+$")
  218. set(VER_SEPARATOR "~")
  219. endif()
  220. if(TOP_LEVEL_PROJECT)
  221. if(PLUGIN)
  222. set(CPACK_PACKAGE_NAME "hpccsystems-plugin-${pluginname}")
  223. set(PACKAGE_FILE_NAME_PREFIX "hpccsystems-plugin-${pluginname}")
  224. elseif(PLATFORM)
  225. set(CPACK_PACKAGE_NAME "hpccsystems-platform")
  226. set(PACKAGE_FILE_NAME_PREFIX "hpccsystems-platform-${projname}")
  227. else()
  228. set(CPACK_PACKAGE_NAME "hpccsystems-clienttools-${majorver}.${minorver}")
  229. set(PACKAGE_FILE_NAME_PREFIX "hpccsystems-clienttools-${projname}")
  230. endif()
  231. if(NOT "${CUSTOM_PACKAGE_SUFFIX}" STREQUAL "")
  232. set(CPACK_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-${CUSTOM_PACKAGE_SUFFIX}")
  233. set(PACKAGE_FILE_NAME_PREFIX "${PACKAGE_FILE_NAME_PREFIX}-${CUSTOM_PACKAGE_SUFFIX}")
  234. endif()
  235. set(CPACK_PACKAGE_VERSION_MAJOR ${majorver})
  236. set(CPACK_PACKAGE_VERSION_MINOR ${minorver})
  237. set(CPACK_PACKAGE_VERSION_PATCH ${point}${VER_SEPARATOR}${stagever})
  238. set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
  239. set(CPACK_PACKAGE_CONTACT "HPCCSystems <ossdevelopment@lexisnexis.com>")
  240. set(CPACK_SOURCE_GENERATOR TGZ)
  241. set(CPACK_RPM_PACKAGE_VERSION "${version}")
  242. set(CPACK_RPM_PACKAGE_RELEASE "${stagever}")
  243. set(CPACK_RPM_PACKAGE_VENDOR "HPCC Systems®")
  244. set(CPACK_PACKAGE_VENDOR "HPCC Systems®")
  245. set(CPACK_PACKAGE_VENDOR_WITHOUT_TRADEMARK "HPCC Systems")
  246. if(WIN32)
  247. set(CPACK_PACKAGE_VENDOR "HPCC Systems")
  248. if(${ARCH64BIT} EQUAL 1)
  249. set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
  250. else(${ARCH64BIT} EQUAL 1)
  251. set(CPACK_RPM_PACKAGE_ARCHITECTURE "i386")
  252. endif(${ARCH64BIT} EQUAL 1)
  253. else(WIN32)
  254. set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
  255. if("${CPACK_RPM_PACKAGE_ARCHITECTURE}" STREQUAL "i686")
  256. set(CPACK_RPM_PACKAGE_ARCHITECTURE "i386")
  257. endif()
  258. endif(WIN32)
  259. set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CPACK_RPM_PACKAGE_ARCHITECTURE}")
  260. if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
  261. set(CPACK_STRIP_FILES TRUE)
  262. endif()
  263. if(UNIX AND NOT APPLE)
  264. execute_process(
  265. COMMAND ${HPCC_SOURCE_DIR}/cmake_modules/distrocheck.sh
  266. OUTPUT_VARIABLE packageManagement
  267. ERROR_VARIABLE packageManagement
  268. )
  269. execute_process(
  270. COMMAND ${HPCC_SOURCE_DIR}/cmake_modules/getpackagerevisionarch.sh
  271. OUTPUT_VARIABLE packageRevisionArch
  272. ERROR_VARIABLE packageRevisionArch
  273. )
  274. execute_process(
  275. COMMAND ${HPCC_SOURCE_DIR}/cmake_modules/getpackagerevisionarch.sh --noarch
  276. OUTPUT_VARIABLE packageRevision
  277. ERROR_VARIABLE packageRevision
  278. )
  279. message("-- Auto Detecting Packaging type")
  280. message("-- distro uses ${packageManagement}, revision is ${packageRevisionArch}")
  281. if("${packageManagement}" STREQUAL "DEB")
  282. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${stagever}${packageRevisionArch}")
  283. elseif("${packageManagement}" STREQUAL "RPM")
  284. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${stagever}.${packageRevisionArch}")
  285. else()
  286. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}_${stagever}${CPACK_SYSTEM_NAME}")
  287. endif()
  288. endif ()
  289. message("-- Current release version is ${CPACK_PACKAGE_FILE_NAME}")
  290. set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${CPACK_RPM_PACKAGE_VERSION}-${stagever}")
  291. set(CPACK_SOURCE_GENERATOR TGZ)
  292. set(CPACK_SOURCE_IGNORE_FILES
  293. "~$"
  294. "\\\\.cvsignore$"
  295. "^${PROJECT_SOURCE_DIR}.*/CVS/"
  296. "^${PROJECT_SOURCE_DIR}.*/.svn/"
  297. "^${PROJECT_SOURCE_DIR}.*/.git/"
  298. "^${PROJECT_SOURCE_DIR}/ln/"
  299. "^${PROJECT_SOURCE_DIR}/externals/"
  300. "^${PROJECT_SOURCE_DIR}.*/*.mk$"
  301. "^${PROJECT_SOURCE_DIR}/makefile$"
  302. "^${PROJECT_SOURCE_DIR}/make.common$"
  303. "^${PROJECT_SOURCE_DIR}/make.post$"
  304. "^${PROJECT_SOURCE_DIR}/build$"
  305. "^${PROJECT_SOURCE_DIR}/buildall$"
  306. "^${PROJECT_SOURCE_DIR}/lastbuilds$"
  307. "^${PROJECT_SOURCE_DIR}/imerge$"
  308. "^${PROJECT_SOURCE_DIR}/tmerge$"
  309. "^${PROJECT_SOURCE_DIR}/tmerge.bat$"
  310. "^${PROJECT_SOURCE_DIR}/tag$"
  311. "^${PROJECT_SOURCE_DIR}/tag_build$"
  312. "^${PROJECT_SOURCE_DIR}/old_tag$"
  313. "^${PROJECT_SOURCE_DIR}/ecl/regress/"
  314. "^${PROJECT_SOURCE_DIR}/testing/"
  315. )
  316. endif(TOP_LEVEL_PROJECT)
  317. ###
  318. ## Run file configuration to set build tag along with install lines for generated
  319. ## config files.
  320. ###
  321. if(NOT BUILD_TAG)
  322. set(BUILD_TAG "${projname}_${version}-${stagever}")
  323. if(USE_GIT_DESCRIBE OR CHECK_GIT_TAG)
  324. FETCH_GIT_TAG(${CMAKE_SOURCE_DIR} ${projname}_${version} GIT_BUILD_TAG)
  325. message("-- Git tag is '${GIT_BUILD_TAG}'")
  326. if(NOT "${GIT_BUILD_TAG}" STREQUAL "${BUILD_TAG}")
  327. if(CHECK_GIT_TAG)
  328. message(FATAL_ERROR "Git tag '${GIT_BUILD_TAG}' does not match source version '${BUILD_TAG}'")
  329. else()
  330. if(NOT "${GIT_BUILD_TAG}" STREQUAL "") # probably means being built from a tarball...
  331. set(BUILD_TAG "${BUILD_TAG}[${GIT_BUILD_TAG}]")
  332. endif()
  333. endif()
  334. endif()
  335. endif()
  336. endif()
  337. message("-- Build tag is '${BUILD_TAG}'")
  338. if(NOT "${BASE_BUILD_TAG}" STREQUAL "")
  339. set(BASE_BUILD_TAG "${BUILD_TAG}")
  340. endif()
  341. message("-- Base build tag is '${BASE_BUILD_TAG}'")
  342. configure_file(${HPCC_SOURCE_DIR}/build-config.h.cmake "build-config.h")
  343. if(USE_SHLIBDEPS)
  344. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  345. else()
  346. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
  347. endif()
  348. #set( CPACK_DEB_PACKAGE_COMPONENT ON )
  349. if(TOP_LEVEL_PROJECT)
  350. if(UNIX)
  351. if("${packageManagement}" STREQUAL "DEB")
  352. set(CPACK_GENERATOR "${packageManagement}")
  353. message("-- Will build DEB package")
  354. ###
  355. ## CPack instruction required for Debian
  356. ###
  357. message("-- Packing BASH installation files")
  358. if(CLIENTTOOLS_ONLY)
  359. set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  360. "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postinst;${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/prerm; ${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postrm")
  361. endif(CLIENTTOOLS_ONLY)
  362. if(PLATFORM)
  363. set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postinst;${CMAKE_CURRENT_BINARY_DIR}/initfiles/sbin/prerm;${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postrm")
  364. endif(PLATFORM)
  365. # Standard sections values:
  366. # https://www.debian.org/doc/debian-policy/ch-archive.html/#s-subsections
  367. set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
  368. elseif("${packageManagement}" STREQUAL "RPM")
  369. set(CPACK_GENERATOR "${packageManagement}")
  370. ###
  371. ## CPack instruction required for RPM
  372. ###
  373. set(CPACK_RPM_SPEC_MORE_DEFINE
  374. "%define _use_internal_dependency_generator 0
  375. %define __getdeps() while read file; do /usr/lib/rpm/rpmdeps -%{1} ${file} | %{__grep} -v libantlr3c.so | %{__grep} -v libelasticlient.so | %{__grep} -v libcpr.so | %{__grep} -v libjsoncpp.so | %{__grep} -v libtbb.so ; done | /bin/sort -u
  376. %define __find_provides /bin/sh -c '%{__getdeps P}'
  377. %define __find_requires /bin/sh -c '%{__getdeps R}'
  378. %undefine __brp_mangle_shebangs
  379. %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')")
  380. message("-- Will build RPM package")
  381. message("-- Packing BASH installation files")
  382. if(CLIENTTOOLS_ONLY)
  383. set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postinst")
  384. set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/prerm")
  385. set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/clienttools/install/postrm")
  386. set(CPACK_RPM_PACKAGE_GROUP "development/libraries")
  387. set(CPACK_RPM_PACKAGE_SUMMARY "HPCC Systems® Client Tools.")
  388. endif()
  389. if(PLATFORM)
  390. set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postinst")
  391. set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/sbin/prerm")
  392. set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/initfiles/bash/sbin/deb/postrm")
  393. # Standard group names: http://fedoraroject.org/wiki/RPMGroups
  394. set(CPACK_RPM_PACKAGE_GROUP "development/system")
  395. set(CPACK_RPM_PACKAGE_SUMMARY "${PACKAGE_FILE_NAME_PREFIX}")
  396. endif()
  397. set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/etc)
  398. else()
  399. message("WARNING: Unsupported package ${packageManagement}.")
  400. endif ()
  401. endif(UNIX)
  402. if(PLUGIN)
  403. if("${packageManagement}" STREQUAL "RPM")
  404. SET_DEPENDENCIES(CPACK_RPM_PACKAGE_REQUIRES "hpccsystems-platform = ${CPACK_RPM_PACKAGE_VERSION}")
  405. elseif("${packageManagement}" STREQUAL "DEB")
  406. SET_DEPENDENCIES(CPACK_DEBIAN_PACKAGE_DEPENDS "hpccsystems-platform (= ${CPACK_PACKAGE_VERSION})")
  407. else()
  408. message(WARNING "Plugin Static Dependencies not set")
  409. endif()
  410. else()
  411. if(EXISTS ${HPCC_SOURCE_DIR}/cmake_modules/dependencies/${packageRevision}.cmake)
  412. include(${HPCC_SOURCE_DIR}/cmake_modules/dependencies/${packageRevision}.cmake)
  413. else()
  414. message("-- WARNING: DEPENDENCY FILE FOR ${packageRevision} NOT FOUND, Using deps template.")
  415. include(${HPCC_SOURCE_DIR}/cmake_modules/dependencies/template.cmake)
  416. endif()
  417. endif()
  418. if(UNIX)
  419. set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  420. endif(UNIX)
  421. if(PLATFORM OR PLUGIN)
  422. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_FILE_NAME_PREFIX}")
  423. else()
  424. if(APPLE OR WIN32)
  425. set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME_PREFIX}_${version}-${stagever}${CPACK_SYSTEM_NAME}")
  426. endif()
  427. set(CPACK_MONOLITHIC_INSTALL TRUE)
  428. file(WRITE "${PROJECT_BINARY_DIR}/welcome.txt"
  429. "HPCC Systems® - Client Tools\r"
  430. "===========================\r\r"
  431. "This installer will install the HPCC Systems® Client Tools.")
  432. set(CPACK_RESOURCE_FILE_README "${PROJECT_BINARY_DIR}/welcome.txt")
  433. set(CPACK_RESOURCE_FILE_LICENSE "${HPCC_SOURCE_DIR}/${LICENSE_FILE}")
  434. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HPCC Systems® Client Tools.")
  435. if(WIN32)
  436. if("${SIGN_DIRECTORY}" STREQUAL "")
  437. set(SIGN_DIRECTORY "${HPCC_SOURCE_DIR}/../sign")
  438. endif()
  439. set(CPACK_NSIS_DISPLAY_NAME "Client Tools")
  440. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${DIR_NAME}\\\\${version}\\\\clienttools")
  441. set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "clienttools_${version}")
  442. set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
  443. set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\hpccsystems.com")
  444. set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
  445. set(CPACK_NSIS_DEFINES "
  446. !define MUI_STARTMENUPAGE_DEFAULTFOLDER \\\"${CPACK_PACKAGE_VENDOR_WITHOUT_TRADEMARK}\\\\${version}\\\\${CPACK_NSIS_DISPLAY_NAME}\\\"
  447. !define MUI_FINISHPAGE_NOAUTOCLOSE
  448. ")
  449. list ( APPEND CPACK_NSIS_CREATE_ICONS_EXTRA "
  450. CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\ECL Command Prompt.lnk\\\" '%comspec%' '/k \\\"$INSTDIR\\\\ECLCmd.bat\\\"'
  451. ")
  452. list ( APPEND CPACK_NSIS_DELETE_ICONS_EXTRA "
  453. Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\ECL CMD.lnk\\\"
  454. ")
  455. set(CPACK_NSIS_MODIFY_PATH "ON")
  456. if (EXISTS "${SIGN_DIRECTORY}/passphrase.txt")
  457. file(STRINGS "${SIGN_DIRECTORY}/passphrase.txt" PFX_PASSWORD LIMIT_COUNT 1)
  458. add_custom_target(SIGN
  459. COMMAND signtool sign /f "${SIGN_DIRECTORY}/hpcc_code_signing.pfx" /fd "SHA256" /p "${PFX_PASSWORD}" /tr "http://timestamp.digicert.com" "${CMAKE_BINARY_DIR}/${PACKAGE_FILE_NAME_PREFIX}*.exe"
  460. COMMENT "Digital Signature"
  461. )
  462. add_dependencies(SIGN PACKAGE)
  463. set_property(TARGET SIGN PROPERTY FOLDER "CMakePredefinedTargets")
  464. endif()
  465. endif()
  466. endif(PLATFORM OR PLUGIN)
  467. endif(TOP_LEVEL_PROJECT)
  468. ###
  469. ## Below are the non-compile based install scripts required for
  470. ## the hpcc platform.
  471. ###
  472. if(PLATFORM OR CLIENTTOOLS OR REMBED)
  473. install(FILES ${HPCC_SOURCE_DIR}/${LICENSE_FILE} DESTINATION "." COMPONENT Runtime)
  474. endif()
  475. add_subdirectory(devel)
  476. #uninstall target
  477. configure_file(
  478. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  479. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  480. IMMEDIATE @ONLY)
  481. add_custom_target(uninstall
  482. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
  483. add_custom_target(localinstall
  484. COMMAND ${CMAKE_MAKE_PROGRAM} install
  485. )
  486. include(CPack)