Calamares - distribution indipendent installer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. # === This file is part of Calamares - <https://github.com/calamares> ===
  2. #
  3. # Calamares is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # Calamares is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Calamares. If not, see <http://www.gnu.org/licenses/>.
  15. #
  16. # SPDX-License-Identifier: GPL-3.0+
  17. # License-Filename: LICENSE
  18. #
  19. ###
  20. #
  21. # Generally, this CMakeLists.txt will find all the dependencies for Calamares
  22. # and complain appropriately. See below (later in this file) for CMake-level
  23. # options. There are some "secret" options as well:
  24. #
  25. # SKIP_MODULES : a space or semicolon-separated list of directory names
  26. # under src/modules that should not be built.
  27. # USE_<foo> : fills in SKIP_MODULES for modules called <foo>-<something>
  28. # WITH_<foo> : try to enable <foo> (these usually default to ON). For
  29. # a list of WITH_<foo> grep CMakeCache.txt after running
  30. # CMake once.
  31. # BUILD_<foo> : choose additional things to build
  32. # DEBUG_<foo> : special developer flags for debugging
  33. #
  34. # Example usage:
  35. #
  36. # cmake . -DSKIP_MODULES="partition luksbootkeycfg"
  37. #
  38. # One special target is "show-version", which can be built
  39. # to obtain the version number from here.
  40. cmake_minimum_required( VERSION 3.3 FATAL_ERROR )
  41. project( CALAMARES
  42. VERSION 3.2.15
  43. LANGUAGES C CXX )
  44. set( CALAMARES_VERSION_RC 0 ) # Set to 0 during release cycle, 1 during development
  45. ### OPTIONS
  46. #
  47. option( INSTALL_CONFIG "Install configuration files" OFF )
  48. option( INSTALL_POLKIT "Install Polkit configuration" ON )
  49. option( BUILD_TESTING "Build the testing tree." ON )
  50. option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
  51. option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
  52. option( WITH_KF5Crash "Enable crash reporting with KCrash." ON )
  53. ### USE_*
  54. #
  55. # By convention, when there are multiple modules that implement similar
  56. # functionality, and it only makes sense to have **at most one** of them
  57. # enabled at any time, those modules are named <foo>-<implementation>.
  58. # For example, services-systemd and services-openrc.
  59. #
  60. # Setting up SKIP_MODULES to ignore "the ones you don't want" can be
  61. # annoying and error-prone (e.g. if a new module shows up). The USE_*
  62. # modules provide a way to do automatic selection. To pick exactly
  63. # one of the implementations from group <foo>, set USE_<foo> to the
  64. # name of the implementation. If USE_<foo> is unset, or empty, then
  65. # all the implementations are enabled (this just means they are
  66. # **available** to `settings.conf`, not that they are used).
  67. #
  68. # Currently, only USE_services is in use (to pick only one of the two
  69. # modules, systemd or openrc).
  70. set( USE_services "" CACHE STRING "Select the services module to use" )
  71. ### Calamares application info
  72. #
  73. set( CALAMARES_ORGANIZATION_NAME "Calamares" )
  74. set( CALAMARES_ORGANIZATION_DOMAIN "github.com/calamares" )
  75. set( CALAMARES_APPLICATION_NAME "Calamares" )
  76. set( CALAMARES_DESCRIPTION_SUMMARY
  77. "The distribution-independent installer framework" )
  78. ### Transifex (languages) info
  79. #
  80. # complete = 100% translated,
  81. # good = nearly complete (use own judgement, right now >= 75%)
  82. # ok = incomplete (more than 25% untranslated, at least 5% translated),
  83. # incomplete = <5% translated, placeholder in tx; these are not included.
  84. #
  85. # Language en (source language) is added later. It isn't listed in
  86. # Transifex either. Get the list of languages and their status
  87. # from https://transifex.com/calamares/calamares/ , or (preferably)
  88. # use ci/txstats.py to automatically check.
  89. #
  90. # When adding a new language, take care that it is properly loaded
  91. # by the translation framework. Languages with alternate scripts
  92. # (sr@latin in particular) may need special handling in CalamaresUtils.cpp.
  93. #
  94. # TODO: drop the es_ES translation from Transifex
  95. #
  96. # NOTE: move eo (Esperanto) to _ok once Qt can actually create a
  97. # locale for it. (Qt 5.12.2 can, see check later on).
  98. # NOTE: update these lines by running txstats.py, or copy these four lines
  99. # and prefix each variable name with "p", so that the automatic
  100. # checks for new languages and misspelled ones are done (that is,
  101. # copy these four lines to four backup lines, add "p", and then update
  102. # the original four lines with the current translations).
  103. #
  104. # Total 61 languages
  105. set( _tx_complete ca cs_CZ da fi_FI he hr ja lt pt_BR sq )
  106. set( _tx_good ast de es es_MX et fr gl hi hu id it_IT ko nl pl
  107. pt_PT ru sk tr_TR zh_TW )
  108. set( _tx_ok ar be bg el en_GB es_PR eu is ml mr nb ro sl sr
  109. sr@latin sv th uk zh_CN )
  110. set( _tx_incomplete ca@valencia eo fa fr_CH gu kk kn lo mk ne_NP ur
  111. uz )
  112. ### Required versions
  113. #
  114. # See DEPENDENCIES section below.
  115. set( QT_VERSION 5.9.0 )
  116. set( YAMLCPP_VERSION 0.5.1 )
  117. set( ECM_VERSION 5.18 )
  118. set( PYTHONLIBS_VERSION 3.3 )
  119. set( BOOSTPYTHON_VERSION 1.55.0 )
  120. ### CMAKE SETUP
  121. #
  122. set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" )
  123. # Enable IN_LIST
  124. if( POLICY CMP0057 )
  125. cmake_policy( SET CMP0057 NEW )
  126. endif()
  127. # CMake 3.9, 3.10 compatibility
  128. if( POLICY CMP0071 )
  129. cmake_policy( SET CMP0071 NEW )
  130. endif()
  131. if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
  132. list(APPEND CMAKE_AUTOMOC_MACRO_NAMES
  133. "K_PLUGIN_FACTORY_WITH_JSON"
  134. "K_EXPORT_PLASMA_DATAENGINE_WITH_JSON"
  135. "K_EXPORT_PLASMA_RUNNER"
  136. )
  137. endif()
  138. ### C++ SETUP
  139. #
  140. set( CMAKE_CXX_STANDARD 14 )
  141. set( CMAKE_CXX_STANDARD_REQUIRED ON )
  142. set( CMAKE_C_STANDARD 99 )
  143. set( CMAKE_C_STANDARD_REQUIRED ON )
  144. # Debugging flags
  145. #
  146. # Possible debugging flags are:
  147. # - DEBUG_TIMEZONES draws latitude and longitude lines on the timezone
  148. # widget and enables chatty debug logging, for dealing with the timezone
  149. # location database.
  150. # - DEBUG_FILESYSTEMS does extra logging and checking when looking at
  151. # partition configuration. Lists known KPMCore FS types.
  152. #
  153. # The flags listed here are enabled in Debug builds. By default, none
  154. # are **actually** listed, because they're for such specific scenarios.
  155. set( _enable_debug_flags
  156. # DEBUG_TIMEZONES
  157. # DEBUG_FILESYSTEMS
  158. )
  159. # Add those flags to the CXX flags in a suitable format.
  160. foreach( _edf ${_enable_debug_flags} )
  161. string( APPEND CMAKE_CXX_FLAGS_DEBUG " -D${_edf}" )
  162. endforeach()
  163. set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
  164. if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  165. message( STATUS "Found Clang ${CMAKE_CXX_COMPILER_VERSION}, setting up Clang-specific compiler flags." )
  166. set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
  167. set( CMAKE_C_FLAGS_DEBUG "-g" )
  168. set( CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
  169. set( CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG" )
  170. set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" )
  171. # Clang warnings: doing *everything* is counter-productive, since it warns
  172. # about things which we can't fix (e.g. C++98 incompatibilities, but
  173. # Calamares is C++14).
  174. foreach( CLANG_WARNINGS
  175. -Weverything
  176. -Wno-c++98-compat
  177. -Wno-c++98-compat-pedantic
  178. -Wno-padded
  179. -Wno-undefined-reinterpret-cast
  180. -Wno-global-constructors
  181. -Wno-exit-time-destructors
  182. -Wno-missing-prototypes
  183. -Wno-documentation-unknown-command
  184. -Wno-unknown-warning-option
  185. -Werror=return-type
  186. )
  187. string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" )
  188. endforeach()
  189. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='//' -DFALLTHRU='[[clang::fallthrough]]'")
  190. # Third-party code where we don't care so much about compiler warnings
  191. # (because it's uncomfortable to patch) get different flags; use
  192. # mark_thirdparty_code( <file> [<file>...] )
  193. # to switch off warnings for those sources.
  194. set( SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything" )
  195. set( SUPPRESS_BOOST_WARNINGS " -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansion" )
  196. set( CMAKE_CXX_FLAGS_DEBUG "-g ${CMAKE_CXX_FLAGS_DEBUG}" )
  197. set( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
  198. set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" )
  199. set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" )
  200. set( CMAKE_TOOLCHAIN_PREFIX "llvm-" )
  201. set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
  202. set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" )
  203. set( CALAMARES_AUTOUIC_OPTIONS --include utils/moc-warnings.h )
  204. else()
  205. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" )
  206. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" )
  207. set( SUPPRESS_3RDPARTY_WARNINGS "" )
  208. set( SUPPRESS_BOOST_WARNINGS "" )
  209. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTREACHED='__builtin_unreachable();' -DFALLTHRU='/* */'" )
  210. endif()
  211. # Use mark_thirdparty_code() to reduce warnings from the compiler
  212. # on code that we're not going to fix. Call this with a list of files.
  213. macro(mark_thirdparty_code)
  214. set_source_files_properties( ${ARGV}
  215. PROPERTIES
  216. COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}"
  217. COMPILE_DEFINITIONS "THIRDPARTY"
  218. )
  219. endmacro()
  220. if( CMAKE_COMPILER_IS_GNUCXX )
  221. if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
  222. CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9 )
  223. message( STATUS "Found GNU g++ ${CMAKE_CXX_COMPILER_VERSION}, enabling colorized error messages." )
  224. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto" )
  225. endif()
  226. endif()
  227. include( FeatureSummary )
  228. include( CMakeColors )
  229. ### DEPENDENCIES
  230. #
  231. find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Concurrent Core Gui Widgets LinguistTools Svg Quick QuickWidgets )
  232. if( Qt5_VERSION VERSION_GREATER 5.12.1 )
  233. # At least Qt 5.12.2 seems to support Esperanto in QLocale
  234. if( "eo" IN_LIST _tx_incomplete )
  235. message(STATUS "Esperanto support since Qt 5.12.2, enabling Esperanto locale")
  236. list( REMOVE_ITEM _tx_incomplete "eo" )
  237. list( APPEND _tx_ok "eo" )
  238. endif()
  239. endif()
  240. # Optional Qt parts
  241. find_package( Qt5DBus CONFIG )
  242. find_package( YAMLCPP ${YAMLCPP_VERSION} REQUIRED )
  243. if( INSTALL_POLKIT )
  244. find_package( PolkitQt5-1 REQUIRED )
  245. else()
  246. # Find it anyway, for dependencies-reporting
  247. find_package( PolkitQt5-1 )
  248. endif()
  249. set_package_properties(
  250. PolkitQt5-1 PROPERTIES
  251. DESCRIPTION "Qt5 support for Polkit"
  252. URL "https://cgit.kde.org/polkit-qt-1.git"
  253. PURPOSE "PolkitQt5-1 helps with installing Polkit configuration"
  254. )
  255. # Find ECM once, and add it to the module search path; Calamares
  256. # modules that need ECM can do
  257. # find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE),
  258. # no need to mess with the module path after.
  259. find_package(ECM ${ECM_VERSION} NO_MODULE)
  260. if( ECM_FOUND )
  261. set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
  262. if ( BUILD_TESTING )
  263. # ECM implies that we can build the tests, too
  264. find_package( Qt5 COMPONENTS Test REQUIRED )
  265. include( ECMAddTests )
  266. endif()
  267. include(KDEInstallDirs)
  268. endif()
  269. find_package( KF5 QUIET COMPONENTS CoreAddons Crash )
  270. set_package_properties(
  271. KF5::CoreAddons PROPERTIES
  272. TYPE REQUIRED
  273. DESCRIPTION "Classes built on QtCore for About Data"
  274. URL "https://api.kde.org/frameworks/kcoreaddons/"
  275. PURPOSE "About Calamares"
  276. )
  277. if( NOT KF5Crash_FOUND )
  278. set( WITH_KF5Crash OFF )
  279. endif()
  280. if( BUILD_TESTING )
  281. enable_testing()
  282. endif ()
  283. find_package( PythonLibs ${PYTHONLIBS_VERSION} )
  284. set_package_properties(
  285. PythonLibs PROPERTIES
  286. DESCRIPTION "C interface libraries for the Python 3 interpreter."
  287. URL "http://python.org"
  288. PURPOSE "Python 3 is used for Python job modules."
  289. )
  290. if ( PYTHONLIBS_FOUND )
  291. include( BoostPython3 )
  292. find_boost_python3( ${BOOSTPYTHON_VERSION} ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND )
  293. set_package_properties(
  294. Boost PROPERTIES
  295. PURPOSE "Boost.Python is used for Python job modules."
  296. )
  297. find_package( PythonQt )
  298. set_package_properties( PythonQt PROPERTIES
  299. DESCRIPTION "A Python embedding solution for Qt applications."
  300. URL "http://pythonqt.sourceforge.net"
  301. PURPOSE "PythonQt is used for Python view modules."
  302. )
  303. endif()
  304. if( NOT PYTHONLIBS_FOUND OR NOT CALAMARES_BOOST_PYTHON3_FOUND )
  305. message(STATUS "Disabling Boost::Python modules")
  306. set( WITH_PYTHON OFF )
  307. endif()
  308. if( NOT PYTHONLIBS_FOUND OR NOT PYTHONQT_FOUND )
  309. message(STATUS "Disabling PythonQt modules")
  310. set( WITH_PYTHONQT OFF )
  311. endif()
  312. ### Transifex Translation status
  313. #
  314. # Construct language lists for use. If there are p_tx* variables,
  315. # then run an extra cmake-time check for consistency of the old
  316. # (p_tx*) and new (_tx*) lists.
  317. #
  318. set( prev_tx ${p_tx_complete} ${p_tx_good} ${p_tx_ok} ${p_tx_incomplete} )
  319. set( curr_tx ${_tx_complete} ${_tx_good} ${_tx_ok} ${_tx_incomplete} )
  320. set( tx_errors OFF )
  321. if ( prev_tx )
  322. # Gone in new list
  323. foreach( l ${prev_tx} )
  324. list( FIND curr_tx ${l} p_l )
  325. if( p_l EQUAL -1 )
  326. message(WARNING "Language ${l} was present in previous translations and is now absent.")
  327. set( tx_errors ON )
  328. endif()
  329. endforeach()
  330. # New in list
  331. foreach( l ${curr_tx} )
  332. list( FIND prev_tx ${l} p_l )
  333. if( p_l EQUAL -1 )
  334. message(WARNING "Language ${l} is new.")
  335. set( tx_errors ON )
  336. endif()
  337. set( p_l "lang/calamares_${l}.ts" )
  338. if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${p_l} )
  339. message(WARNING "Language ${l} has no .ts file yet.")
  340. set( tx_errors ON )
  341. endif()
  342. endforeach()
  343. unset( p_l )
  344. unset( l )
  345. endif()
  346. unset( prev_tx )
  347. unset( curr_tx )
  348. if( tx_errors )
  349. message( FATAL_ERROR "Translation warnings, see above." )
  350. endif()
  351. set( CALAMARES_TRANSLATION_LANGUAGES en ${_tx_complete} ${_tx_good} ${_tx_ok} )
  352. list( SORT CALAMARES_TRANSLATION_LANGUAGES )
  353. add_subdirectory( lang ) # i18n tools
  354. ### Example Distro
  355. #
  356. # For testing purposes Calamares includes a very, very, limited sample
  357. # distro called "Generic". The root filesystem of "Generic" lives in
  358. # data/example-root and can be squashed up as part of the build, so
  359. # that a pure-upstream run of ./calamares -d from the build directory
  360. # (with all the default settings and configurations) can actually
  361. # do an complete example run.
  362. #
  363. # Some binaries from the build host (e.g. /bin and /lib) are also
  364. # squashed into the example filesystem.
  365. #
  366. # To build the example distro (for use by the default, example,
  367. # unsquashfs module), build the target 'example-distro', eg.:
  368. #
  369. # make example-distro
  370. #
  371. find_program( mksquashfs_PROGRAM mksquashfs )
  372. if( mksquashfs_PROGRAM )
  373. set( mksquashfs_FOUND ON )
  374. set( src_fs ${CMAKE_SOURCE_DIR}/data/example-root/ )
  375. set( dst_fs ${CMAKE_BINARY_DIR}/example.sqfs )
  376. if( EXISTS ${src_fs} )
  377. # based on the build host. If /lib64 exists, assume it is needed.
  378. # Collect directories needed for a minimal binary distro,
  379. # Note that the last path component is added to the root, so
  380. # if you add /usr/sbin here, it will be put into /sbin_1.
  381. # Add such paths to /etc/profile under ${src_fs}.
  382. set( candidate_fs /sbin /bin /lib /lib64 )
  383. set( host_fs "" )
  384. foreach( c_fs ${candidate_fs} )
  385. if( EXISTS ${c_fs} )
  386. list( APPEND host_fs ${c_fs} )
  387. endif()
  388. endforeach()
  389. add_custom_command(
  390. OUTPUT ${dst_fs}
  391. COMMAND ${mksquashfs_PROGRAM} ${src_fs} ${dst_fs} -all-root
  392. COMMAND ${mksquashfs_PROGRAM} ${host_fs} ${dst_fs} -all-root
  393. )
  394. add_custom_target(example-distro DEPENDS ${dst_fs})
  395. endif()
  396. else()
  397. set( mksquashfs_FOUND OFF )
  398. endif()
  399. # Doesn't list mksquashfs as an optional dep, though, because it
  400. # hasn't been sent through the find_package() scheme.
  401. #
  402. # "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html"
  403. add_feature_info( ExampleDistro ${mksquashfs_FOUND} "Create example-distro target.")
  404. ### CALAMARES PROPER
  405. #
  406. set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
  407. set( CALAMARES_VERSION_SHORT "${CALAMARES_VERSION}" )
  408. if( CALAMARES_VERSION_RC )
  409. set( CALAMARES_VERSION ${CALAMARES_VERSION}rc${CALAMARES_VERSION_RC} )
  410. endif()
  411. # additional info for non-release builds
  412. if( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" )
  413. include( CMakeDateStamp )
  414. set( CALAMARES_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" )
  415. if( CALAMARES_VERSION_DATE GREATER 0 )
  416. set( CALAMARES_VERSION ${CALAMARES_VERSION}.${CALAMARES_VERSION_DATE} )
  417. endif()
  418. include( CMakeVersionSource )
  419. if( CMAKE_VERSION_SOURCE )
  420. set( CALAMARES_VERSION ${CALAMARES_VERSION}-${CMAKE_VERSION_SOURCE} )
  421. endif()
  422. endif()
  423. # Special target for not-RC (e.g. might-be-release) builds.
  424. # This is used by the release script to get the version.
  425. if ( CALAMARES_VERSION_RC EQUAL 0 )
  426. add_custom_target(show-version
  427. ${CMAKE_COMMAND} -E echo CALAMARES_VERSION=${CALAMARES_VERSION_SHORT}
  428. USES_TERMINAL
  429. )
  430. endif()
  431. # enforce using constBegin, constEnd for const-iterators
  432. add_definitions( "-DQT_STRICT_ITERATORS" )
  433. # set paths
  434. set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
  435. set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
  436. set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
  437. # Better default installation paths: GNUInstallDirs defines
  438. # CMAKE_INSTALL_FULL_SYSCONFDIR to be CMAKE_INSTALL_PREFIX/etc by default
  439. # but we really want /etc
  440. if( NOT DEFINED CMAKE_INSTALL_SYSCONFDIR )
  441. set( CMAKE_INSTALL_SYSCONFDIR "/etc" )
  442. endif()
  443. # make predefined install dirs available everywhere
  444. include( GNUInstallDirs )
  445. # make uninstall support
  446. configure_file(
  447. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  448. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  449. IMMEDIATE @ONLY
  450. )
  451. # Early configure these files as we need them later on
  452. set( CALAMARES_CMAKE_DIR "${CMAKE_SOURCE_DIR}/CMakeModules" )
  453. set( CALAMARES_LIBRARIES calamares )
  454. add_subdirectory( src )
  455. add_feature_info(Python ${WITH_PYTHON} "Python job modules")
  456. add_feature_info(PythonQt ${WITH_PYTHONQT} "Python view modules")
  457. add_feature_info(Config ${INSTALL_CONFIG} "Install Calamares configuration")
  458. add_feature_info(KCrash ${WITH_KF5Crash} "Crash dumps via KCrash")
  459. # Add all targets to the build-tree export set
  460. set( CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calamares" CACHE PATH "Installation directory for CMake files" )
  461. set( CMAKE_INSTALL_FULL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}" )
  462. export( TARGETS calamares
  463. FILE "${PROJECT_BINARY_DIR}/CalamaresLibraryDepends.cmake" )
  464. # Export the package for use from the build-tree
  465. # (this registers the build-tree with a global CMake-registry)
  466. export( PACKAGE Calamares )
  467. # Create a CalamaresBuildTreeSettings.cmake file for the use from the build tree
  468. configure_file( CalamaresBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY )
  469. # Create the CalamaresConfig.cmake and CalamaresConfigVersion files
  470. file( RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}" )
  471. configure_file( CalamaresConfig.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" @ONLY )
  472. configure_file( CalamaresConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" @ONLY )
  473. configure_file( CalamaresUse.cmake.in "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" @ONLY )
  474. # Install the cmake files
  475. install(
  476. FILES
  477. "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
  478. "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
  479. "${PROJECT_BINARY_DIR}/CalamaresUse.cmake"
  480. "CMakeModules/CalamaresAddPlugin.cmake"
  481. "CMakeModules/CalamaresAddModuleSubdirectory.cmake"
  482. "CMakeModules/CalamaresAddLibrary.cmake"
  483. "CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
  484. "CMakeModules/CalamaresAddTranslations.cmake"
  485. "CMakeModules/CalamaresAutomoc.cmake"
  486. "CMakeModules/CMakeColors.cmake"
  487. DESTINATION
  488. "${CMAKE_INSTALL_CMAKEDIR}"
  489. )
  490. # Install the export set for use with the install-tree
  491. install(
  492. EXPORT
  493. CalamaresLibraryDepends
  494. DESTINATION
  495. "${CMAKE_INSTALL_CMAKEDIR}"
  496. )
  497. if( INSTALL_CONFIG )
  498. install(
  499. FILES
  500. settings.conf
  501. DESTINATION
  502. share/calamares
  503. )
  504. endif()
  505. if( INSTALL_POLKIT )
  506. install(
  507. FILES
  508. com.github.calamares.calamares.policy
  509. DESTINATION
  510. "${POLKITQT-1_POLICY_FILES_INSTALL_DIR}"
  511. )
  512. endif()
  513. install(
  514. FILES
  515. calamares.desktop
  516. DESTINATION
  517. ${CMAKE_INSTALL_DATADIR}/applications
  518. )
  519. install(
  520. FILES
  521. man/calamares.8
  522. DESTINATION
  523. ${CMAKE_INSTALL_MANDIR}/man8/
  524. )
  525. # uninstall target
  526. configure_file(
  527. "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  528. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  529. IMMEDIATE @ONLY
  530. )
  531. add_custom_target( uninstall
  532. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
  533. )
  534. ### CMAKE SUMMARY REPORT
  535. #
  536. get_directory_property( SKIPPED_MODULES
  537. DIRECTORY src/modules
  538. DEFINITION LIST_SKIPPED_MODULES
  539. )
  540. calamares_explain_skipped_modules( ${SKIPPED_MODULES} )
  541. feature_summary(
  542. WHAT DISABLED_FEATURES
  543. DESCRIPTION "The following features have been disabled:"
  544. QUIET_ON_EMPTY
  545. )
  546. feature_summary(
  547. WHAT OPTIONAL_PACKAGES_NOT_FOUND
  548. DESCRIPTION "The following OPTIONAL packages were not found:"
  549. QUIET_ON_EMPTY
  550. )
  551. feature_summary(
  552. WHAT REQUIRED_PACKAGES_NOT_FOUND
  553. FATAL_ON_MISSING_REQUIRED_PACKAGES
  554. DESCRIPTION "The following REQUIRED packages were not found:"
  555. QUIET_ON_EMPTY
  556. )