CMakeLists.txt 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. cmake_minimum_required ( VERSION 3.17 )
  2. FOREACH (policy CMP0012 CMP0013 CMP0014 CMP0048 CMP0074 CMP0077 CMP0091 CMP0110)
  3. IF (POLICY ${policy})
  4. CMAKE_POLICY ( SET ${policy} NEW )
  5. ENDIF ()
  6. ENDFOREACH ()
  7. if (DEFINED ENV{CMAKE_INTERPROCEDURAL_OPTIMIZATION})
  8. set ( CMAKE_INTERPROCEDURAL_OPTIMIZATION $ENV{CMAKE_INTERPROCEDURAL_OPTIMIZATION} )
  9. endif ()
  10. set ( CMAKE_ENABLE_EXPORTS ON )
  11. set ( _CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} )
  12. PROJECT ( MANTICORE )
  13. # sometimes CMAKE_BUILD_TYPE became set after PROJECT statement, undo it.
  14. if (NOT _CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE)
  15. unset ( CMAKE_BUILD_TYPE CACHE )
  16. endif ()
  17. SET ( CMAKE_CXX_STANDARD 17 )
  18. SET ( MANTICORE_CMAKE_DIR "${MANTICORE_SOURCE_DIR}/cmake" )
  19. SET ( CMAKE_MODULE_PATH "${MANTICORE_SOURCE_DIR}/cmake" )
  20. SET ( MANTICORE_MODULE_PATH "${CMAKE_MODULE_PATH}" )
  21. include ( init_cache_settings ) # set libs_bundle, cacheb, diagnostic. etc.
  22. include ( helpers )
  23. # Set a default build type for single-configuration CMake generators if no build type is set.
  24. get_property ( isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
  25. if (NOT isMultiConfig AND NOT CMAKE_BUILD_TYPE)
  26. set ( CMAKE_BUILD_TYPE RelWithDebInfo )
  27. message ( STATUS "Automatically set build type to RelWithDebInfo since no other provided" )
  28. endif ()
  29. if (WIN32 AND WIN_BUNDLE)
  30. list ( APPEND CMAKE_PREFIX_PATH "${WIN_BUNDLE}" )
  31. set ( CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE )
  32. endif ()
  33. if (NOT DEFINED BUILD_TAG AND DEFINED ENV{BUILD_TAG})
  34. set ( BUILD_TAG $ENV{BUILD_TAG} CACHE STRING "The tag which will be added to build" )
  35. elseif (NOT DEFINED BUILD_TAG)
  36. set ( BUILD_TAG "" CACHE STRING "The tag which will be added to build" )
  37. endif()
  38. set ( PACKAGE_NAME "manticore" )
  39. set ( COMPANY_NAME "Manticore Software LTD" )
  40. set ( CPACK_PACKAGE_NAME "${PACKAGE_NAME}" )
  41. include ( setup_distribution_build ) # process PACK, DISTR_BUILD and ENV{DISTR}
  42. include ( FeatureSummary )
  43. # Option to build Source RPMs (SRPMs) - provides instructions for proper SRPM generation
  44. set ( BUILD_SRPMS OFF CACHE BOOL "Show instructions for building Source RPMs (SRPMs)" )
  45. if (BUILD_SRPMS)
  46. set ( CPACK_RPM_PACKAGE_SOURCES ON )
  47. message ( STATUS "SRPM generation requested - will provide instructions for proper SRPM creation" )
  48. endif ()
  49. add_feature_info ( "SRPM generation" BUILD_SRPMS "Show instructions for building Source RPM packages" )
  50. # cast away too old gcc compiler (Minspec is 4.7.2)
  51. if (CXX_COMPILER_ID STREQUAL GNU AND CXX_COMPILER_VERSION VERSION_LESS 4.7.2)
  52. message ( FATAL_ERROR "Gcc version error. Minspec is 4.7.2" )
  53. endif ()
  54. # Collect string information which will be included into binaries
  55. include ( banner )
  56. bannervar ( DISTR_BUILD )
  57. add_library ( lextra INTERFACE ) # main interface lib to collect all build-wide libs and options
  58. # Looking for threads library
  59. set ( THREADS_PREFER_PTHREAD_FLAG ON )
  60. find_package ( Threads REQUIRED )
  61. target_link_libraries ( lextra INTERFACE Threads::Threads )
  62. if (QFUZZER)
  63. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  64. target_compile_options ( lextra INTERFACE -g -fsanitize=address,fuzzer )
  65. target_compile_definitions ( lextra INTERFACE DISABLE_MEMROUTINES=1 )
  66. set ( DISABLE_MEMROUTINES ON CACHE BOOL "If the build is broken because new/delete override, this option will disable the overriding" FORCE )
  67. else()
  68. message(FATAL_ERROR "QFUZZER requires Clang compiler")
  69. endif()
  70. endif()
  71. # Checking for specific headers
  72. include ( CheckIncludeFile )
  73. # that part is safe on windows, however these libs are absent there, so no reason to spend time on them
  74. if (NOT WIN32)
  75. # Checking if mincore has unsigned 3-rd param
  76. include ( mincore_test )
  77. add_lib_for ( getaddrinfo_a anl lextra )
  78. add_lib_for ( setsockopt socket lextra )
  79. add_lib_for ( getaddrinfo "nsl;socket;resolv" lextra )
  80. add_lib_for ( clock_gettime rt lextra )
  81. add_lib_for ( logf m lextra )
  82. set ( CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} )
  83. check_function_exists ( poll HAVE_POLL )
  84. check_function_exists ( pthread_mutex_timedlock HAVE_PTHREAD_MUTEX_TIMEDLOCK )
  85. check_function_exists ( pthread_cond_timedwait HAVE_PTHREAD_COND_TIMEDWAIT )
  86. check_function_exists ( pread HAVE_PREAD )
  87. check_function_exists ( backtrace HAVE_BACKTRACE )
  88. check_function_exists ( backtrace_symbols HAVE_BACKTRACE_SYMBOLS )
  89. check_function_exists ( mremap HAVE_MREMAP )
  90. check_function_exists ( eventfd HAVE_EVENTFD )
  91. check_function_exists ( kqueue HAVE_KQUEUE )
  92. check_function_exists ( pthread_getname_np HAVE_PTHREAD_GETNAME_NP )
  93. check_function_exists ( getrlimit HAVE_GETRLIMIT )
  94. check_function_exists ( setrlimit HAVE_SETRLIMIT )
  95. check_function_exists ( epoll_ctl HAVE_EPOLL )
  96. # Checking for few other flags
  97. include ( CheckSymbolExists )
  98. check_symbol_exists ( F_SETLKW "fcntl.h" HAVE_F_SETLKW )
  99. check_symbol_exists ( SO_REUSEPORT "sys/types.h;sys/socket.h" HAVE_SO_REUSEPORT )
  100. check_symbol_exists ( malloc_trim "malloc.h" HAVE_MALLOC_TRIM )
  101. check_symbol_exists ( malloc_stats "malloc.h" HAVE_MALLOC_STATS )
  102. # Checking for PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP flag
  103. include ( check_rwlock_prefer_writer )
  104. # Check availabiliby of pthread_setname_np and whether it pick 1 or 2 params
  105. include ( check_vitable_pthread_setname_np )
  106. set ( STATIC_BINARY OFF CACHE BOOL "Produce statically linked ELF" )
  107. add_feature_info ( Static STATIC_BINARY "make pure static build undependent of any local libraries" )
  108. endif ()
  109. if (STATIC_BINARY)
  110. # options for clang/gcc c and c++
  111. target_compile_options ( lextra INTERFACE $<${ONLYGNUCLANGC_CXX}:-static> )
  112. set ( HAVE_DLOPEN 0 CACHE BOOL "" FORCE )
  113. set ( HAVE_GETADDRINFO_A 0 CACHE BOOL "" FORCE )
  114. set ( WITH_ODBC 0 CACHE BOOL "" FORCE )
  115. set ( WITH_MYSQL 0 CACHE BOOL "" FORCE )
  116. set ( WITH_POSTGRESQL 0 CACHE BOOL "" FORCE )
  117. set ( WITH_GALERA 0 CACHE BOOL "" FORCE )
  118. set ( WITH_SSL 0 CACHE BOOL "" FORCE )
  119. set ( WITH_ZSTD 0 CACHE BOOL "" FORCE )
  120. set ( WITH_CURL 0 CACHE BOOL "" FORCE )
  121. SET ( BUILD_TESTING 0 CACHE BOOL "" FORCE )
  122. elseif (NOT WIN32)
  123. if (CMAKE_DL_LIBS) # CMAKE internal, usually '-ldl' on most UNIX machines
  124. target_link_libraries ( lextra INTERFACE ${CMAKE_DL_LIBS} )
  125. endif ()
  126. set ( CMAKE_REQUIRED_LIBRARIES "${CMAKE_DL_LIBS}" )
  127. check_symbol_exists ( dlopen "dlfcn.h" HAVE_DLOPEN )
  128. else ()
  129. set ( HAVE_DLOPEN 1 CACHE BOOL "Use emulated dlopen" FORCE )
  130. endif ()
  131. include ( TestBigEndian ) # fixme! That is deprecated in cmake 3.20 in favor to CMAKE_<LANG>_BYTE_ORDER var
  132. test_big_endian ( USE_BIG_ENDIAN )
  133. target_compile_options ( lextra INTERFACE $<$<COMPILE_LANG_AND_ID:CXX,MSVC>:-D_CRT_SECURE_NO_WARNINGS -wd4996 -wd4706 -wd4244 -wd4702 -wd4577> )
  134. include ( CheckFunctionExists )
  135. check_function_exists ( strnlen HAVE_STRNLEN )
  136. # Checking for atomic function
  137. include ( check_atomic_intrinsics )
  138. set ( DISABLE_MEMROUTINES OFF CACHE BOOL "If the build is broken because new/delete override, this option will disable the overriding" )
  139. mark_as_advanced ( DISABLE_MEMROUTINES )
  140. # Option USE_SYSLOG
  141. check_include_file ( "syslog.h" HAVE_SYSLOG_H )
  142. set ( USE_SYSLOG ${HAVE_SYSLOG_H} CACHE BOOL "compile with possibility to use syslog for logging" )
  143. bannervar ( USE_SYSLOG )
  144. # options for clang/gcc c and c++
  145. target_compile_options ( lextra INTERFACE $<${ONLYGNUCLANGC_CXX}:-D_FILE_OFFSET_BITS=64 -Wall -Wstrict-aliasing> )
  146. target_compile_options ( lextra INTERFACE $<${CLANGWIN}:-Wstrict-aliasing -Wno-format -Wno-uninitialized-const-reference -Wno-unneeded-internal-declaration
  147. -Wno-deprecated-declarations -Wno-implicit-const-int-float-conversion -Wno-missing-braces -Wno-unused-function> )
  148. # disable rtti
  149. target_compile_options ( lextra INTERFACE $<${ONLYGNUCLANGCXX}:-fno-rtti>$<${MSCXX}:/GR-> ) # no rtti
  150. if (WIN32)
  151. target_compile_definitions ( lextra INTERFACE
  152. _CRT_SECURE_NO_DEPRECATE=1
  153. _CRT_NONSTDC_NO_DEPRECATE=1
  154. )
  155. # that is necessary only for IDE correct highlighting. Note, that is only global (not target-located) definitions, global-wide
  156. # add_compile_definitions ( _WIN32=1 )
  157. endif()
  158. if (COVERAGE_TEST)
  159. target_compile_options ( lextra INTERFACE $<${ONLYGNUCLANGC_CXX}:-fprofile-arcs -ftest-coverage> )
  160. target_link_options ( lextra INTERFACE
  161. $<$<LINK_LANG_AND_ID:CXX,GNU>:-lgcov --coverage>
  162. $<$<LINK_LANG_AND_ID:C,GNU>:-lgcov --coverage>
  163. $<$<LINK_LANG_AND_ID:CXX,Clang,AppleClang>: --coverage>
  164. $<$<LINK_LANG_AND_ID:C,Clang,AppleClang>: --coverage>
  165. )
  166. endif (COVERAGE_TEST)
  167. # options for clang in C++
  168. target_compile_options ( lextra INTERFACE $<${CLANGCXX}:
  169. -Wno-deprecated-register -Wno-missing-exception-spec -Wno-implicit-exception-spec-mismatch -Wno-invalid-offsetof -Wc++11-narrowing> )
  170. # Checking for unaligned RAM access
  171. if (CMAKE_CROSSCOMPILING)
  172. string ( TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" _PROC )
  173. if (_PROC MATCHES "^(i.86|x86(_64)?)$"
  174. OR _PROC STREQUAL amd64
  175. OR _PROC STREQUAL arm64
  176. OR _PROC STREQUAL aarch64
  177. OR _PROC STREQUAL s390x)
  178. set ( UNALIGNED_RAM_ACCESS_EXITCODE "0" CACHE STRING "Result from TRY_RUN" )
  179. set ( UNALIGNED_RAM_ACCESS_EXITCODE__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" )
  180. endif ()
  181. endif ()
  182. include ( check_unaligned_ram_access )
  183. option ( USE_SMALLALLOC "Use 'small allocator' derived from loki lib. Bench! Glibc allocator now is fast enough!" )
  184. bannervar ( WITH_SMALLALLOC )
  185. mark_as_advanced ( WITH_SMALLALLOC )
  186. #check galera, as it is not available on win, to fail early
  187. if (WIN32)
  188. if (WITH_GALERA)
  189. message ( FATAL_ERROR "Galera is not supported on win; reconfigure with WITH_GALERA=FALSE" )
  190. endif ()
  191. else ()
  192. include ( GetGALERA )
  193. if (WITH_GALERA)
  194. cache_galera_module_name () # write GALERA_SONAME as var to cache
  195. endif ()
  196. diag ( WITH_GALERA )
  197. bannervar ( WITH_GALERA )
  198. endif ()
  199. # Check for RE2 build
  200. set ( WITH_RE2_FORCE_STATIC 1 CACHE BOOL "force to compile re2 from sources" )
  201. with_get ( re2 "RE2" "a regular expression library" )
  202. # Check for Libstemmer build
  203. set ( WITH_STEMMER_FORCE_STATIC 1 CACHE BOOL "force to compile stemmer from sources" )
  204. with_get ( stemmer "Stemmer" "stemming library (Snowball)" )
  205. get_dep ( nlohmann_json NLJSON "JSON for Modern C++ library" )
  206. get_dep ( uni-algo UniAlgo "unicode algorithm implementation for C/C++" )
  207. # Check for ICU build
  208. set ( WITH_ICU_FORCE_STATIC 1 CACHE BOOL "force to compile ICU from sources" )
  209. if (STATIC_BINARY)
  210. set ( WITH_ICU_FORCE_STATIC ON CACHE BOOL "force to compile ICU from sources" FORCE )
  211. set ( WITH_ICU_FORCE_BUILD ON )
  212. endif ()
  213. with_get ( icu "ICU" "International Components for Unicode" )
  214. include ( GetCCTZ )
  215. target_link_libraries ( lextra INTERFACE cctz::cctz )
  216. include ( GetxxHash )
  217. target_link_libraries ( lextra INTERFACE xxHash::xxhash )
  218. with_get ( jieba "Jieba" "Chinese text segmentation tool" )
  219. # Support for OpenSSL
  220. set ( OPENSSL_USE_STATIC_LIBS ON )
  221. include ( GetSSL )
  222. with_menu_comp ( OpenSSL SSL "OpenSSL" "for encrypted networking" )
  223. win_install_c ( OpenSSL SSL daemon )
  224. trace ( OpenSSL::Crypto )
  225. # Support for ZLIB
  226. with_menu ( ZLIB "zlib" "for compressed data and networking" )
  227. win_install ( ZLIB common )
  228. with_menu ( ZSTD "libzstd" "for compressed networking" )
  229. dl_package ( ZSTD "zstd" )
  230. win_install ( ZSTD daemon )
  231. with_menu_libname ( CURL libcurl "libCURL" "for enhanced network communication" )
  232. dl_package_comp ( CURL libcurl "curl" )
  233. win_install_lib ( CURL libcurl daemon )
  234. # ODBC and it's dynamic linking
  235. with_menu ( ODBC "ODBC/UnixODBC/iODBC" "for indexing MSSQL (windows) and generic ODBC sources with indexer" )
  236. dl_package ( ODBC "ODBC/UnixODBC/iODBC" )
  237. # EXPAT and it's dynamic linking
  238. with_menu ( EXPAT "expat" "for indexing xmlpipe sources with indexer" )
  239. dl_package ( EXPAT "expat" )
  240. win_install ( EXPAT common )
  241. # test for ICONV
  242. if (WITH_EXPAT)
  243. with_menu ( Iconv "iconv" "for support different encodings when indexing xmlpipe sources with indexer" )
  244. if (Iconv_IS_BUILT_IN)
  245. set_target_properties ( Iconv::Iconv PROPERTIES INTERFACE_COMPILE_DEFINITIONS LIBICONV_PLUG )
  246. else ()
  247. dl_package ( Iconv "iconv" )
  248. win_install ( Iconv common )
  249. endif ()
  250. include ( check_const_iconv )
  251. diag ( Iconv_IS_BUILT_IN )
  252. endif ()
  253. # MYSQL and it's dynamic linking
  254. set ( WITH_STATIC_MYSQL OFF CACHE BOOL "link to mysql library statically" )
  255. if (WITH_STATIC_MYSQL)
  256. set ( MYSQL_USE_STATIC_LIBS ON )
  257. endif ()
  258. with_menu ( Mysql "mysql" "for indexing mysql sources with indexer" )
  259. dl_package ( Mysql "mysql" )
  260. # roll-back to 'unversioned' mysql dylib on macos (#2997)
  261. if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
  262. if (TARGET Mysql::Mysql_ld)
  263. if ( DL_MYSQL )
  264. GET_FILENAME_COMPONENT ( __mysql_21_dylib_name ${MYSQL_LIB} NAME )
  265. get_target_property ( _mysql_dylib Mysql::Mysql LOCATION )
  266. GET_FILENAME_COMPONENT ( __mysql_dylib_name ${_mysql_dylib} NAME )
  267. if ( NOT __mysql_21_dylib_name STREQUAL ${__mysql_dylib_name} )
  268. GET_FILENAME_COMPONENT ( __mysql_dir ${MYSQL_LIB} DIRECTORY )
  269. set ( MYSQL_LIB "${__mysql_dir}/${__mysql_dylib_name}" CACHE FILEPATH "Library file of Mysql" FORCE )
  270. infomsg ( "Mysql lib name fixed from ${__mysql_21_dylib_name} to ${__mysql_dylib_name} (${MYSQL_LIB})" )
  271. endif()
  272. endif ()
  273. endif ()
  274. endif ()
  275. win_install ( Mysql indexer )
  276. # PostgreSQL and it's dynamic linking
  277. with_menu ( PostgreSQL "pgsql" "for indexing postgresql sources with indexer" )
  278. dl_package ( PostgreSQL "pgsql" )
  279. win_install ( PostgreSQL indexer )
  280. # Storing compiler version
  281. set ( COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}" )
  282. diag ( COMPILER )
  283. # Storing system name
  284. set ( HOST_SYSTEM "${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}" )
  285. set ( TARGET_SYSTEM "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}" )
  286. set ( HOST_DISTRO "${HOST_SYSTEM}" )
  287. set ( TARGET_DISTRO "${TARGET_SYSTEM}" )
  288. if (DISTR)
  289. set ( HOST_DISTRO "${HOST_DISTRO} (${DISTR})" )
  290. set ( TARGET_DISTRO "${TARGET_DISTRO} (${DISTR})" )
  291. endif ()
  292. if (CMAKE_CROSSCOMPILING)
  293. if (HOST_SYSTEM STREQUAL "${TARGET_SYSTEM}")
  294. SET ( OS_UNAME "${HOST_DISTRO} (cross-compiled)" )
  295. else ()
  296. SET ( OS_UNAME "${HOST_SYSTEM} for ${TARGET_DISTRO}" )
  297. endif ()
  298. else ()
  299. SET ( OS_UNAME "${HOST_DISTRO}" )
  300. endif ()
  301. diag ( OS_UNAME )
  302. diag ( SPLIT )
  303. configure_file ( "LICENSE" "${MANTICORE_BINARY_DIR}/LICENSE" COPYONLY )
  304. # Common all-packages info
  305. include ( ${MANTICORE_SOURCE_DIR}/sphinxrev.cmake )
  306. include ( CommonInfo )
  307. include( builds/VersionDeps )
  308. message("EXECUTOR image: manticoresearch/manticore-executor:${EXECUTOR_VERNUM}")
  309. # set final paths for build
  310. set ( only_set_paths ON )
  311. include ( SetBuildType )
  312. diag ( installed )
  313. if (NOT installed) # GNUInstallDirs wasn't yet included...
  314. include ( GNUInstallDirs )
  315. SET ( LOCALDATADIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}" ) # will be used also in the app
  316. if (WIN32)
  317. set ( CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc" )
  318. SET ( FULL_SHARE_DIR "${CMAKE_INSTALL_FULL_DATADIR}" )
  319. SET ( CMAKE_INSTALL_FULL_LOCALLIBDIR "usr/local/lib" )
  320. install ( DIRECTORY api doc contrib DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT common )
  321. install ( FILES example.sql DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT tools )
  322. install ( DIRECTORY misc/stopwords DESTINATION ${CMAKE_INSTALL_DATADIR} COMPONENT common )
  323. install ( FILES LICENSE INSTALL manticore.conf.in DESTINATION . COMPONENT common )
  324. install ( DIRECTORY DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/log COMPONENT searchd )
  325. install ( DIRECTORY DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR} COMPONENT common )
  326. if (WITH_ICU AND WITH_ICU_FORCE_STATIC)
  327. install_icudata ( ${CMAKE_INSTALL_DATADIR}/icu )
  328. endif ()
  329. else ()
  330. set ( CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/manticore" )
  331. configure_config ( lib/manticore )
  332. SET ( FULL_SHARE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/manticore" )
  333. SET ( CMAKE_INSTALL_FULL_LOCALLIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" )
  334. install ( FILES ${MANTICORE_BINARY_DIR}/manticore.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/manticoresearch COMPONENT common )
  335. install ( DIRECTORY misc/stopwords DESTINATION ${CMAKE_INSTALL_DATADIR}/manticore COMPONENT common )
  336. install ( DIRECTORY DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib/manticore COMPONENT common )
  337. install ( DIRECTORY DESTINATION ${CMAKE_INSTALL_RUNSTATEDIR}/manticore COMPONENT searchd )
  338. install ( DIRECTORY DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/log/manticore COMPONENT searchd )
  339. if (WITH_ICU AND WITH_ICU_FORCE_STATIC)
  340. install_icudata ( ${CMAKE_INSTALL_DATADIR}/manticore/icu )
  341. endif ()
  342. endif ()
  343. endif ()
  344. set ( CPACK_RPM_COMPONENT_INSTALL 1 )
  345. set ( CPACK_DEB_COMPONENT_INSTALL 1 )
  346. set ( CPACK_ARCHIVE_COMPONENT_INSTALL 1 )
  347. bannervar ( LOCALDATADIR )
  348. bannervar ( FULL_SHARE_DIR )
  349. set ( CPACK_PROJECT_CONFIG_FILE "${MANTICORE_BINARY_DIR}/config/CPackOptions.cmake" )
  350. set ( DEFAULT_CTEST_CONFIGURATION_TYPE "Debug" )
  351. include ( CTest )
  352. add_subdirectory ( src )
  353. if (BUILD_TESTING)
  354. add_subdirectory ( test )
  355. if (NOT TEST_SPECIAL_EXTERNAL)
  356. add_subdirectory ( api/libsphinxclient )
  357. endif ()
  358. endif ()
  359. # run setBuildType again, full pass. Select distribution build and install rules for most of the files
  360. if (installed)
  361. set ( only_set_paths OFF )
  362. include ( SetBuildType )
  363. endif ()
  364. cmake_print_variables ( CMAKE_INSTALL_PREFIX )
  365. foreach (var BINDIR SBINDIR LIBEXECDIR SYSCONFDIR SHAREDSTATEDIR LOCALSTATEDIR RUNSTATEDIR LIBDIR INCLUDEDIR OLDINCLUDEDIR DATAROOTDIR DATADIR INFODIR LOCALEDIR MANDIR DOCDIR LOCALLIBDIR)
  366. cmake_print_variables ( CMAKE_INSTALL_${var} CMAKE_INSTALL_FULL_${var} )
  367. endforeach ()
  368. # Configure CPack source packaging for SRPM generation
  369. set ( CPACK_SOURCE_GENERATOR "RPM" )
  370. set ( CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}" )
  371. # For source RPMs: Override the make command to use cmake --build instead
  372. # This automatically handles any generator (Unix Makefiles, Ninja, etc.)
  373. if (CPACK_SOURCE_GENERATOR STREQUAL "RPM" OR CPACK_RPM_PACKAGE_SOURCES)
  374. set ( CPACK_RPM_SPEC_MORE_DEFINE "${CPACK_RPM_SPEC_MORE_DEFINE}
  375. %global __make cmake --build . --parallel")
  376. endif()
  377. # Configure source directories for debuginfo packages
  378. # This is required when debuginfo packaging is enabled
  379. set ( CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}" )
  380. if (NOT CPack_CMake_INCLUDED)
  381. include ( CPack )
  382. endif ()
  383. cpack_add_component ( server GROUP main )
  384. cpack_add_component ( searchd GROUP main )
  385. cpack_add_component ( common GROUP main )
  386. cpack_add_component ( tools GROUP main )
  387. cpack_add_component ( meta )
  388. cpack_add_component ( devel GROUP main )
  389. cpack_add_component ( converter GROUP helpers )
  390. cpack_add_component_group ( main EXPANDED )
  391. cpack_add_component_group ( helpers EXPANDED )
  392. if (WITH_ICU)
  393. cpack_add_component ( icudata )
  394. endif ()
  395. #if (WITH_JIEBA)
  396. # cpack_add_component ( jiebadicts )
  397. #endif ()
  398. if (WIN32)
  399. cpack_add_component ( runtime GROUP main )
  400. endif ()
  401. #feature_summary (
  402. # INCLUDE_QUIET_PACKAGES
  403. # DESCRIPTION "Enabled Features1:"
  404. # VAR enabledFeaturesText
  405. # WHAT ALL)
  406. #message (STATUS "${enabledFeaturesText}")
  407. feature_summary ( WHAT ENABLED_FEATURES INCLUDE_QUIET_PACKAGES DESCRIPTION "Enabled features compiled in:" )
  408. feature_summary ( WHAT RUNTIME_PACKAGES_FOUND INCLUDE_QUIET_PACKAGES DESCRIPTION "Available runtime features:" )
  409. #feature_summary (WHAT ALL DESCRIPTION "Enabled ALL features4:")