Table of Contents for
CMake Cookbook

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition CMake Cookbook by Roberto Di Remigio Published by Packt Publishing, 2018
  1. CMake Cookbook
  2. Title Page
  3. Copyright and Credits
  4. CMake Cookbook
  5. Packt Upsell
  6. Why subscribe?
  7. PacktPub.com
  8. Contributors
  9. About the authors
  10. About the reviewers
  11. Packt is searching for authors like you
  12. Table of Contents
  13. Preface
  14. Who this book is for
  15. What this book covers
  16. To get the most out of this book
  17. Download the example code files
  18. Download the color images
  19. Conventions used
  20. Additional reading resources
  21. Get in touch
  22. Reviews
  23. Setting up Your System
  24. Obtaining the code
  25. Docker image
  26. Installing prerequisite software
  27. Getting CMake
  28. Compilers
  29. Build-automation tools
  30. Python
  31. Additional software
  32. BLAS and LAPACK
  33. Message passing interface (MPI)
  34. The Eigen linear algebra template library
  35. The Boost libraries
  36. Cross-compilers
  37. ZeroMQ, pkg-config, UUID, and Doxygen
  38. Conda build and deployment tools
  39. Testing the recipes
  40. Reporting problems and suggesting improvements
  41. From a Simple Executable to Libraries
  42. Introduction
  43. Compiling a single source file into an executable
  44. Getting ready
  45. How to do it
  46. How it works
  47. There is more
  48. Switching generators
  49. Getting ready
  50. How to do it
  51. How it works
  52. See also
  53. Building and linking static and shared libraries
  54. Getting ready
  55. How to do it
  56. How it works
  57. There is more
  58. Controlling compilation with conditionals
  59. How to do it
  60. How it works
  61. Presenting options to the user
  62. How to do it
  63. How it works
  64. There is more
  65. Specifying the compiler
  66. How to do it
  67. How it works
  68. There is more
  69. Switching the build type
  70. How to do it
  71. How it works
  72. There is more
  73. Controlling compiler flags
  74. Getting ready
  75. How to do it
  76. How it works
  77. There is more
  78. Setting the standard for the language
  79. Getting ready
  80. How to do it
  81. How it works
  82. There is more
  83. Using control flow constructs
  84. Getting ready
  85. How to do it
  86. How it works
  87. There is more
  88. Detecting the Environment
  89. Introduction
  90. Discovering the operating system
  91. How to do it
  92. How it works
  93. Dealing with platform-dependent source code
  94. Getting ready
  95. How to do it
  96. How it works
  97. Dealing with compiler-dependent source code
  98. Getting ready
  99. How to do it
  100. How it works
  101. Discovering the host processor architecture
  102. Getting ready
  103. How to do it
  104. How it works
  105. There is more
  106. Discovering the host processor instruction set
  107. Getting ready
  108. How to do it
  109. How it works
  110. There is more
  111. Enabling vectorization for the Eigen library
  112. Getting ready
  113. How to do it
  114. How it works
  115. There is more
  116. Detecting External Libraries and Programs
  117. Introduction
  118. Detecting the Python interpreter
  119. How to do it
  120. How it works
  121. There is more
  122. Detecting the Python library
  123. Getting ready
  124. How to do it
  125. How it works
  126. There is more
  127. See also
  128. Detecting Python modules and packages
  129. Getting ready
  130. How to do it
  131. How it works
  132. Detecting the BLAS and LAPACK math libraries
  133. Getting ready
  134. How to do it
  135. How it works
  136. There is more
  137. Detecting the OpenMP parallel environment
  138. Getting ready
  139. How to do it
  140. How it works
  141. Detecting the MPI parallel environment
  142. Getting ready
  143. How to do it
  144. How it works
  145. Detecting the Eigen library
  146. Getting ready
  147. How to do it
  148. How it works
  149. There is more
  150. Detecting the Boost libraries
  151. Getting ready
  152. How to do it
  153. How it works
  154. Detecting external libraries: I. Using pkg-config
  155. Getting ready
  156. How to do it
  157. How it works
  158. Detecting external libraries: II. Writing a find-module
  159. How to do it
  160. How it works
  161. There is more
  162. Creating and Running Tests
  163. Introduction
  164. Creating a simple unit test
  165. Getting ready
  166. How to do it
  167. How it works
  168. There is more
  169. Defining a unit test using the Catch2 library
  170. Getting ready
  171. How to do it
  172. How it works
  173. There is more
  174. See also
  175. Defining a unit test and linking against Google Test
  176. Getting ready
  177. How to do it
  178. How it works
  179. There is more
  180. See also
  181. Defining a unit test and linking against Boost test
  182. Getting ready
  183. How to do it
  184. How it works
  185. There is more
  186. Using dynamic analysis to detect memory defects
  187. Getting ready
  188. How to do it
  189. How it works
  190. There is more
  191. See also
  192. Testing expected failures
  193. Getting ready
  194. How to do it
  195. How it works
  196. There is more
  197. Using timeouts for long tests
  198. Getting ready
  199. How to do it
  200. How it works
  201. Running tests in parallel
  202. Getting ready
  203. How to do it
  204. How it works
  205. There is more
  206. Running a subset of tests
  207. Getting ready
  208. How to do it
  209. How it works
  210. There is more
  211. Using test fixtures
  212. Getting ready
  213. How to do it
  214. How it works
  215. There is more
  216. Configure-time and Build-time Operations
  217. Introduction
  218. Using platform-independent file operations
  219. Getting ready
  220. How to do it
  221. How it works
  222. There is more
  223. Running a custom command at configure time
  224. How to do it
  225. How it works
  226. There is more
  227. Running a custom command at build time: I. Using add_custom_command
  228. Getting ready
  229. How to do it
  230. How it works
  231. Running a custom command at build time: II. Using add_custom_target
  232. Getting ready
  233. How to do it
  234. How it works
  235. Running custom commands for specific targets at build time
  236. Getting ready
  237. How to do it
  238. How it works
  239. Probing compilation and linking
  240. Getting ready
  241. How to do it
  242. How it works
  243. There is more
  244. Probing compiler flags
  245. Getting ready
  246. How to do it
  247. How it works
  248. See also
  249. Probing execution
  250. Getting ready
  251. How to do it
  252. How it works
  253. Fine-tuning configuration and compilation with generator expressions
  254. Getting ready
  255. How to do it
  256. How it works
  257. There is more
  258. See also
  259. Generating Source Code
  260. Introduction
  261. Generating sources at configure time
  262. Getting ready
  263. How to do it
  264. How it works
  265. There is more
  266. Generating source code at configure time using Python
  267. Getting ready
  268. How to do it
  269. How it works
  270. There is more
  271. Generating source code at build time using Python
  272. Getting ready
  273. How to do it
  274. How it works
  275. There is more
  276. Recording the project version information for reproducibility
  277. Getting ready
  278. How to do it
  279. How it works
  280. There is more
  281. Recording the project version from a file
  282. Getting ready
  283. How to do it
  284. How it works
  285. Recording the Git hash at configure time
  286. Getting ready
  287. How to do it
  288. How it works
  289. Recording the Git hash at build time
  290. Getting ready
  291. How to do it
  292. How it works
  293. There is more
  294. Structuring Projects
  295. Introduction
  296. Code reuse with functions and macros
  297. Getting ready
  298. How to do it
  299. How it works
  300. There is more
  301. Splitting CMake sources into modules
  302. Getting ready
  303. How to do it
  304. How it works
  305. There is more
  306. Writing a function to test and set compiler flags
  307. Getting ready
  308. How to do it
  309. How it works
  310. There is more
  311. Defining a function or macro with named arguments
  312. Getting ready
  313. How to do it
  314. How it works
  315. There is more
  316. Redefining functions and macros
  317. Getting ready
  318. How to do it
  319. How it works
  320. Deprecating functions, macros, and variables
  321. Getting ready
  322. How to do it
  323. How it works
  324. Limiting scope with add_subdirectory
  325. Getting ready
  326. How to do it
  327. How it works
  328. There is more
  329. See also
  330. Avoiding global variables using target_sources
  331. Getting ready
  332. How to do it
  333. How it works
  334. There is more
  335. Organizing Fortran projects
  336. Getting ready
  337. How to do it
  338. How it works
  339. There is more
  340. The Superbuild Pattern
  341. Introduction
  342. Using the superbuild pattern
  343. Getting ready
  344. How to do it
  345. How it works
  346. There is more
  347. Managing dependencies with a superbuild: I. The Boost libraries
  348. How to do it
  349. How it works
  350. Managing dependencies with a superbuild: II. The FFTW library
  351. Getting ready
  352. How to do it
  353. How it works
  354. Managing dependencies with a superbuild: III. The Google Test framework
  355. Getting ready
  356. How to do it
  357. How it works
  358. See also
  359. Managing your project as a superbuild
  360. Getting ready
  361. How to do it
  362. How it works
  363. Mixed-language Projects
  364. Introduction
  365. Building Fortran projects that use C/C++ libraries
  366. Getting ready
  367. How to do it
  368. How it works
  369. There is more
  370. Building C/C++ projects that use Fortran libraries
  371. Getting ready
  372. How to do it
  373. How it works
  374. Building C++ and Python projects using Cython
  375. Getting ready
  376. How to do it
  377. How it works
  378. There is more
  379. Building C++ and Python projects using Boost.Python
  380. Getting ready
  381. How to do it
  382. How it works
  383. There is more
  384. Building C++ and Python projects using pybind11
  385. Getting ready
  386. How to do it
  387. How it works
  388. There is more
  389. See also
  390. Mixing C, C++, Fortran, and Python using Python CFFI
  391. Getting ready
  392. How to do it
  393. How it works
  394. There is more
  395. See also
  396. Writing an Installer
  397. Introduction
  398. Installing your project
  399. Getting ready
  400. How to do it
  401. How it works
  402. Installing to standard locations
  403. Target properties and RPATH handling
  404. Installation directives
  405. There is more
  406. Generating export headers
  407. Getting ready
  408. How to do it
  409. How it works
  410. There is more
  411. Exporting your targets
  412. Getting ready
  413. How to do it
  414. How it works
  415. There is more
  416. Installing a superbuild
  417. Getting ready
  418. How to do it
  419. How it works
  420. Packaging Projects
  421. Introduction
  422. Generating source and binary packages
  423. Getting ready
  424. How to do it
  425. How it works
  426. Source archives
  427. Binary archives
  428. Platform-native binary installers
  429. There is more
  430. Distributing a C++/Python project built with CMake/pybind11 via PyPI
  431. Getting ready
  432. How to do it
  433. How it works
  434. There is more
  435. Distributing a C/Fortran/Python project build with CMake/CFFI via PyPI
  436. Getting ready
  437. How to do it
  438. How it works
  439. There is more
  440. Distributing a simple project as Conda package
  441. Getting ready
  442. How to do it
  443. How it works
  444. There is more
  445. Distributing a project with dependencies as Conda package
  446. Getting ready
  447. How to do it
  448. How it works
  449. There is more
  450. Building Documentation
  451. Introduction
  452. Building documentation using Doxygen
  453. Getting ready
  454. How to do it
  455. How it works
  456. Building documentation using Sphinx
  457. Getting ready
  458. How to do it
  459. How it works
  460. Combining Doxygen and Sphinx
  461. Getting ready
  462. How to do it
  463. How it works
  464. Alternative Generators and Cross-compilation
  465. Introduction
  466. Building a CMake project using Visual Studio 2017
  467. Getting ready
  468. How to do it
  469. How it works
  470. See also
  471. Cross-compiling a hello world example
  472. Getting ready
  473. How to do it
  474. How it works
  475. See also
  476. Cross-compiling a Windows binary with OpenMP parallelization
  477. Getting ready
  478. How to do it
  479. How it works
  480. There is more
  481. Testing Dashboards
  482. Introduction
  483. Setting up a CDash dashboard
  484. Deploying tests to the CDash dashboard
  485. Getting ready
  486. How to do it
  487. How it works
  488. There is more
  489. See also
  490. Reporting test coverage to the CDash dashboard
  491. Getting ready
  492. How to do it
  493. How it works
  494. See also
  495. Using the AddressSanitizer and reporting memory defects to CDash
  496. Getting ready
  497. How to do it
  498. How it works
  499. There is more
  500. See also
  501. Using the ThreadSanitizer and reporting data races to CDash
  502. Getting ready
  503. How to do it
  504. How it works
  505. There is more
  506. See also
  507. Porting a Project to CMake
  508. Where to start
  509. Reproducing the porting example
  510. Creating a top-level CMakeLists.txt
  511. How to allow both conventional configuration and configuration with CMake at the same time
  512. Capturing a record of what the traditional build does
  513. Debugging the migration
  514. Implementing options
  515. Start with the executable and very few targets, later localize scope
  516. Generating files and writing platform checks
  517. How to structure files
  518. Configuring preprocessor definitions based on the system environment
  519. Configuring files with paths and compiler flags
  520. Executing shell scripts at configure time
  521. Detecting required dependencies and linking
  522. Reproducing compiler flags
  523. Defining compiler flags
  524. Scope of compiler flags
  525. Porting tests
  526. Getting started
  527. Implementing a multi-step test
  528. Recommendation for tests
  529. Porting install targets
  530. Further steps
  531. Summary and common pitfalls when converting projects to CMake
  532. Summary of code changes
  533. Common pitfalls
  534. Other Books You May Enjoy
  535. Leave a review - let other readers know what you think
CMake Cookbook