forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
783 lines (621 loc) · 29.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Learn CMake</title>
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/black.css">
<!-- Theme used for syntax highlighted code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<style>
:root {
--r-main-font-size: 32px;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<!-- Chapter 0: Introduction -->
<section>
<!-- Title -->
<section data-markdown><textarea data-template>
![CMake logo](images/CMake-Logo-and-Text.png)
<!-- .element style="border: 0; background: None; box-shadow: None" -->
* [Slide source code](https://github.com/DavidZemon/LearnCMake)
<!-- .element target="_blank" -->
* [Syllabus](https://github.com/DavidZemon/LearnCMake/wiki/Syllabus)
<!-- .element target="_blank" -->
* [Labs](https://github.com/DavidZemon/LearnCMake_Labs)
<!-- .element target="_blank" -->
* [Lab & Demo Instructions](https://github.com/DavidZemon/LearnCMake/wiki/Lab-&-Demo-Instructions)
<!-- .element target="_blank" -->
* [CMake Documentation](https://cmake.org/documentation/) (v3+)
<!-- .element target="_blank" -->
* [CMake Documentation for v2.8.12](https://cmake.org/cmake/help/v2.8.12/cmake.html)
<!-- .element target="_blank" -->
Content by [David Zemon](https://david.zemon.name/), May 2017
</textarea></section>
<!-- What is CMake? -->
<section data-markdown><textarea data-template>
What is CMake?
--------------
* Makefile generator
* Makefile scripts compile code incrementally
* Define relational dependencies
* Low-level, granular, unstructured
* Unit test runner
* Software packaging orchestrator
</textarea></section>
<!-- Why CMake -->
<section data-markdown><textarea data-template>
Why CMake
---------
1. Cross-platform
1. High-level
1. Support for more than just compiling
* Unit testing
* Packaging
* IDE integration
</textarea></section>
<!-- Autotools -->
<section data-markdown><textarea data-template>
Shortcomings of Autotools
-------------------------
* Not build with Windows/Mac support in mind
* Configuration language is cryptic
* Flexibility overload → Minimal consistency → No IDE integration
* Few artifact packaging options
</textarea></section>
<!-- SCons -->
<section data-markdown><textarea data-template>
Shortcomings of SCons
---------------------
* Potential speed issues
* Popularity ≈ Community support and SCons is not as popular
</textarea></section>
<!-- Gradle -->
<section data-markdown><textarea data-template>
Gradle
------
* Up and coming C++ build system
* Aiming straight for Maven/NPM-like dependency resolution
* Holy grail when complete
* Worse than CMake in the meantime :(
</textarea></section>
</section>
<!-- Chapter 1: "Hello, World!" -->
<section>
<!-- Intro -->
<section data-markdown><textarea data-template>
Chapter 1
---------
![Silly hello world image](images/Hello-World.jpg)
<!-- .element style="border: 0; background: None; box-shadow: None" -->
</textarea></section>
<!-- Simple executable -->
<section data-markdown><textarea data-template>
Create an Executable
--------------------
<pre><code data-trim class="line-numbers cmake">
cmake_minimum_required(VERSION 2.8)
project(LearnCMake)
add_executable(HelloWorld main.cpp)
</code></pre>
<pre><code data-trim class="line-numbers Bash">
$ mkdir bin
$ cd bin
$ cmake ..
$ make
$ ./HelloWorld
</code></pre>
Produces an executable named either `HelloWorld` on *nix or `HelloWorld.exe` on Windows.
</textarea></section>
<!-- Add a library -->
<section data-markdown><textarea data-template>
Useless Library
---------------
<pre><code data-trim class="line-numbers cmake">
cmake_minimum_required(VERSION 2.8)
project(LearnCMake)
add_library(useless useless.cpp)
</code></pre>
* Produces a library named `libuseless.a` on *nix or `useless.lib` on Windows.
* Can select static, shared, object, or module in the `add_library()` invocation
</textarea></section>
<!-- Linking a library.-->
<section data-markdown><textarea data-template>
Say "Hello" to a Useless Library
--------------------------------
<pre><code data-trim class="line-numbers cmake">
cmake_minimum_required(VERSION 2.8)
project(LearnCMake)
add_library(useless useless/useless.cpp)
add_executable(HelloWorld hello/main.cpp)
target_link_libraries(HelloWorld useless)
</code></pre>
Use of target names rather than filenames keeps our CMake scripts platform-independent
</textarea></section>
<!-- Set some flags.-->
<section data-markdown><textarea data-template>
Set Some Compiler Options
-------------------------
<pre><code data-trim class="line-numbers cmake">
cmake_minimum_required(VERSION 2.8)
project(LearnCMake)
include_directories("${PROJECT_SOURCE_DIR}/include")
set(CMAKE_CXX_FLAGS -Wall)
add_library(useless useless/useless.cpp)
add_executable(HelloWorld hello/main.cpp)
target_link_libraries(HelloWorld useless)
</code></pre>
* Quotes are an important part of platform-independence (spaces are far more prevelant on Windows)
* The `CMAKE_CXX_FLAGS` variable sets compiler flags globally for all C++ files
* For GNU Make, use `make VERBOSE=1` to view commands and arguments as they are executed
</textarea></section>
<!-- CMake `option`s -->
<section data-markdown><textarea data-template>
User-Friendly Options
---------------------
<pre><code data-trim class="line-numbers cmake">
option(WARN_ALL "Throw warnings when you write dumb code" ON)
if (WARN_ALL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif ()
</code></pre>
* The `WARN_ALL` option is now explicitly presented to the user during an invocation of `ccmake`
(or the CMake GUI on Windows).
* CMake `option()` function does not provide functionality, only usability
</textarea></section>
<!-- CMAKE_BUILD_TYPE -->
<section data-markdown><textarea data-template>
Selecting Release/Debug Builds
------------------------------
*`CMAKE_BUILD_TYPE`* has five default options:
* Release: `-O3 -DNDEBUG`
* Debug: `-g`
* RelWithDebInfo: `-O2 -g -DNDEBUG`
* MinSizeRel: `-Os -DNDEBUG`
* Fifth option is unset (default) and will not set any flags by default
</textarea></section>
<!-- CMAKE_BUILD_TYPE continued... -->
<section data-markdown><textarea data-template>
Utilizing `CMAKE_BUILD_TYPE`
----------------------------
<pre><code data-trim class="line-numbers cmake">
# Enable super extra warnings in debug mode
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wextra")
</code></pre>
* Note that the build type is capitalized in this use case
* Set flags on a per-build-configuration basis
* Build configuration types will come up again later in other parts of CMake as well
</textarea></section>
<!-- Inheriting from dependencies -->
<section data-markdown><textarea data-template>
Set Flags on Targets, Not Folders
---------------------------------
<pre><code data-trim class="line-numbers cmake">
cmake_minimum_required(VERSION 2.8)
project(LearnCMake)
add_library(useless useless/useless.cpp)
target_include_directories(useless PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(useless PRIVATE "${PROJECT_SOURCE_DIR}/useless")
add_executable(HelloWorld hello/main.cpp)
target_link_libraries(HelloWorld useless)
</code></pre>
* `PUBLIC` means that `HelloWorld`'s source files will inherit the header search path
* `PRIVATE` means that `HelloWorld`'s source files will not inherit the header search path
* `INTERFACE` means that _only_ `HelloWorld` would inherit it, and that `useless` would _not_
</textarea></section>
<!-- More inheritance -->
<section data-markdown><textarea data-template>
Other Target-Centric Functions
------------------------------
Lots more functions aimed at setting properties on targets:
* `target_link_libraries`
* `target_include_directories`
* `target_compile_options`
* `target_compile_definitions`
</textarea></section>
<!-- Transitive dependencies -->
<section data-markdown><textarea data-template>
Transitive Dependencies
-----------------------
<pre><code data-trim class="line-numbers cmake">
add_library(useful useful/useful.cpp)
add_library(useless useless/useless.cpp)
target_link_libraries(useless useful)
add_executable(HelloWorld hello/main.cpp)
target_link_libraries(HelloWorld useless)
</code></pre>
`HelloWorld` → `useless` → `useful`
</textarea></section>
<!-- Graphviz -->
<section data-markdown><textarea data-template>
BONUS! Graphviz Output
----------------------
<pre><code data-trim class="line-numbers Bash">
$ mkdir bin
$ cd bin
$ cmake --graphviz=graphs/learn ..
$ ls graphs
$ cat graphs/learn.HelloWorld
$ dot -T png graphs/learn.HelloWorld -o HelloWorld.png
</code></pre>
* Adding the `--graphviz` option creates "dot" files for every CMake target
* The "dot" language is very simple to read _and_ write
* Converting from "dot" files to images is simple with the "dot" command line tool
</textarea></section>
<!-- Chapter 1 Demo & Lab -->
<section data-markdown><textarea data-template>
Chapter 1 Demo & Lab
--------------------
![Lab clipart](images/lab-clipart-2.jpg)
<!-- .element style="border: 0; background: None; box-shadow: None" -->
[Demo Instructions](https://github.com/DavidZemon/LearnCMake/wiki/Chapter-1-Demo)
<!-- .element target="_blank" -->
[Lab Instructions](https://github.com/DavidZemon/LearnCMake/wiki/Chapter-1-Lab)
<!-- .element target="_blank" -->
</textarea></section>
</section>
<!-- Chapter 2: In-Depth Syntax -->
<section>
<!-- Intro -->
<section data-markdown><textarea data-template>
Chapter 2
---------
![Syntax erROAR!](images/syntax-error-825x325.jpg)
<!-- .element style="border: 0; background: None; box-shadow: None" -->
### In-Depth Syntax
</textarea></section>
<!-- Variable Expansion-->
<section data-markdown><textarea data-template>
Variable Expansion
------------------
Variables are expanded similar to shell variables
<pre><code data-trim class="line-numbers CMake">
set(FOO "bar")
set(UHOH "FOO")
set(WTF "${${UHOH}}")
message("${FOO}")
message("${UHOH}")
message("${WTF}")
</code></pre>
Resulting output:
<span class="fragment fade-in">bar</span><br>
<span class="fragment fade-in">FOO</span><br>
<span class="fragment fade-in">bar</span><br>
</textarea></section>
<!-- Lists & Loops -->
<section data-markdown><textarea data-template>
Lists & Loops
-------------
All variables are "strings", but strings can be interpreted as lists
<pre><code data-trim class="line-numbers CMake">
set(MEMES "CAT;TREX")
message("All memes: ${MEMES}")
foreach(meme ${MEMES})
message("Next meme: ${meme}")
endforeach()
</code></pre>
Resulting output:
<span class="fragment fade-in">All memes: CAT;TREX</span><br>
<span class="fragment fade-in">Next meme: CAT</span><br>
<span class="fragment fade-in">Next meme: TREX</span><br>
</textarea></section>
<!-- Lists & Loops Continued... -->
<section data-markdown><textarea data-template>
Lists & Loops Continued...
--------------------------
<pre><code data-trim class="line-numbers CMake">
set(POEMS ONE FISH TWO)
message("All poems: ${POEMS}")
foreach(poem IN LISTS POEMS)
message("Next poem? ${poem}")
endforeach()
</code></pre>
Resulting output:
<span class="fragment fade-in">All poems: ONE;FISH;TWO</span><br>
<span class="fragment fade-in">Next poem? ONE</span><br>
<span class="fragment fade-in">Next poem? FISH</span><br>
<span class="fragment fade-in">Next poem? TWO</span><br>
</textarea></section>
<!-- If & boolean expressions -->
<section data-markdown><textarea data-template>
If-Statement & Boolean Expressions
----------------------------------
<pre><code data-trim class="line-numbers CMake">
set(THIS_IS_TRUTHY TRUE) # ≈ ON, YES, Y, non-zero numbers
set(THIS_IS_FALSY FALSE) # ≈ OFF, NO, N, IGNORE, NOTFOUND, *-NOTFOUND, ""
if (${THIS_IS_TRUTHY})
message("Test 1 passed")
endif ()
if (THIS_IS_TRUTHY)
message("Test 2 passed")
endif ()
if (NOT ${THIS_IS_FALSY})
message("Test 3 passed")
endif ()
if (NOT THIS_IS_FALSY)
message("Test 4 passed")
endif ()
</code></pre>
</textarea></section>
<!-- More boolean expressions -->
<section data-markdown><textarea data-template>
Boolean Operator Examples
-------------------------
<pre><code data-trim class="line-numbers CMake">
if (VAR1 OR VAR2)
if (TARGET another_exe)
if (EXISTS "${SOME_FILE}")
if ("${VAR1}" EQUAL "${VAR2}")
if ("${ACTUAL_VERSION}" VERSION_GREATER "${REQUESTED_VERSION}")
</code></pre>
See full list of boolean operators on CMake's `if` documentation
</textarea></section>
<!-- Generator Expressions -->
<section data-markdown><textarea data-template>
Generator Expressions
---------------------
<pre><code class="line-numbers CMake" data-trim>
add_executable(HelloWorld main.cpp)
add_custom_target(create_archive
COMMAND ${CMAKE_COMMAND} -E tar "cfz" "app.tar.gz" $&lt;TARGET_FILE:HelloWorld>
DEPENDS HelloWorld)
</code></pre>
* Evaluated during build system generation
* Can not be used during CMake parsing time, such as in an invocation of `message(...)`
* Provides access to information that cannot be known to the author of the CMake scripts
* Supports a declaritive approach where otherwise an if/else check would be required
</textarea></section>
<!-- Chapter 2 Lab - Part 1 -->
<section data-markdown><textarea data-template>
Chapter 2 - Lab - Part 1
------------------------
![Lab clipart](images/silly-lab.png)
<!-- .element style="border: 0; background: None; box-shadow: None; width: 50%" -->
[Instructions](https://github.com/DavidZemon/LearnCMake/wiki/Chapter-2-Lab)
<!-- .element target="_blank" -->
</textarea></section>
<!-- Macros -->
<section data-markdown><textarea data-template>
Macros
------
<pre><code data-trim class="line-numbers CMake">
macro(set_dummy name value)
set("${name}" "${value}")
endmacro()
set_dummy(FOO BAR)
message("FOO=${FOO}") # Output = "FOO=BAR"
set_dummy(BAZ;FOOBAR)
message("BAZ=${BAZ}") # Output = "BAZ=FOOBAR"
</code></pre>
* Much like the C/C++ preprocessor, macros are essentially "copied/pasted" where they are invoked
* No variable scope
* Parameters are passed in as space-separated variables or as a list
</textarea></section>
<!-- Functions -->
<section data-markdown><textarea data-template>
Functions
---------
<pre><code data-trim class="line-numbers CMake">
function(set_dummy name value)
set("${name}" "${value}")
message("${name}=${${name}}")
endfunction()
set_dummy(FOO BAR) # Output = "FOO=BAR"
message("FOO=${FOO}") # Output = "FOO="
</code></pre>
* Like a real "function", variables here have their own scope
* No concept of "return" value
<pre><code data-trim class="line-numbers CMake">
function(set_dummy name value)
set("${name}" "${value}" PARENT_SCOPE)
message("${name}=${${name}}")
endfunction()
set_dummy(FOO BAR) # Output = "FOO="
message("FOO=${FOO}") # Output = "FOO=BAR"
</code></pre>
</textarea></section>
<!-- CMakeParseArguments -->
<section data-markdown><textarea data-template>
Functions: `cmake_parse_arguments`
----------------------------------
`cmake_parse_arguments(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)`
* Adds psuedo-support for named parameters
* `${ARGN}` in a function or macro provides access to any extra arguments in an invocation
<pre><code data-trim class="line-numbers CMake">
function (do_foo)
cmake_parse_arguments(DO_FOO "FLAG1;FLAG2" "OPT1;OPT2" "M_OPT1" ${ARGN})
if (DO_FOO_FLAG1)
# Do stuff if `FLAG1` was passed into the `do_foo(...)` invocation
endif ()
# ... More code...
endfunction ()
</code></pre>
</textarea></section>
<!-- Chapter 2 Lab - Part 2 -->
<section data-markdown><textarea data-template>
Chapter 2 - Lab - Part 2
------------------------
![Lab clipart](images/dexter1.png)
<!-- .element style="border: 0; background: None; box-shadow: None; width : 50%" -->
[Instructions](https://github.com/DavidZemon/LearnCMake/wiki/Chapter-2-Lab)
<!-- .element target="_blank" -->
</textarea></section>
</section>
<!-- Chapter 3: Importing Dependencies -->
<section>
<!-- Introduction -->
<section data-markdown><textarea data-template>
Chapter 3
---------
![Dependency diagram](images/sprox_dot.png)
<!-- .element style="border: 0; background: None; box-shadow: None; width: 80%"-->
### Importing Dependencies
</textarea></section>
<!-- find_library(...) -->
<section data-markdown><textarea data-template>
`find_library(<VAR> name1 [path1 ...])`
------------------------------------------
* Search the filesystem for a library with the given name
* Once found, the search will not be performed again (set in the cache)
* Lots of different paths will be searched in a specific order
* Defaults can be disabled individually or all at once
<pre><code data-trim class="line-numbers CMake">
find_library(USELESS_LIB useless "it/might/be/installed/here/lib64")
add_executable(Hello hello.cpp)
target_link_libraries(Hello "${USELESS_LIB}")
</code></pre>
</textarea></section>
<!-- find_path(...) -->
<section data-markdown><textarea data-template>
`find_path(<VAR> name1 [path1 ...])`
------------------------------------------
* Just like `find_library(...)`, but for directories
* Frequently used to find header include paths or library installation paths
<pre><code data-trim class="line-numbers CMake">
find_path(USELESS_ROOT "include/useless/useless.h" "it/might/be/installed/here")
find_path(USELESS_INCLUDE_DIR useless/useless.h "${USELESS_ROOT}/include")
find_library(USELESS_LIB useless "${USELESS_ROOT}/lib64")
add_executable(Hello hello.cpp)
target_include_directories(Hello PUBLIC "${USELESS_INCLUDE_DIR}")
target_link_libraries(Hello "${USELESS_LIB}")
</code></pre>
</textarea></section>
<!-- Chapter 3 Lab - Part 1 -->
<section data-markdown><textarea data-template>
Chapter 3 Lab - Part 1
----------------------
![Lab clipart](images/another-lab.png)
<!-- .element style="border: 0; background: None; box-shadow: None; width: 50%" -->
[Instructions](https://github.com/DavidZemon/LearnCMake/wiki/Chapter-3-Lab)
<!-- .element target="_blank" -->
</textarea></section>
<!-- find_package(...) -->
<section data-markdown><textarea data-template>
`find_package(<package> [version] [REQUIRED])`
-------------------------------------------------
* Packages are dependencies, such as Qt or Boost
* Collection of variables or targets associated with a dependency
* Supports basic version comparisons
* Can define "components" within the package
* Segregates filesystem inspection logic from build system logic
* Reduces code duplication and minimizes end-user bugs while increasing flexibility
</textarea></section>
<!-- find_package(...) continued... -->
<section data-markdown><textarea data-template>
`find_package(...)` Examples
----------------------------
* Some implementations provide simple variables defining the header include path and library paths
<pre><code data-trim class="line-numbers CMake">
find_package(ZLIB REQUIRED)
add_executable(myProgram file1.cpp file2.cpp)
target_include_directories(myProgram PUBLIC "${ZLIB_INCLUDE_DIRS}")
target_link_libraries(myProgram "${ZLIB_LIBRARIES}")
</code></pre>
* While others rely on more sophisticated approaches, using targets and inherited properties
<pre><code data-trim class="line-numbers CMake">
find_package(Qt4 REQUIRED)
# No target_include_directories(...) needed!
add_executable(myProgram file1.cpp file2.cpp)
target_link_libraries(myProgram Qt4::QtGui)
</code></pre>
</textarea></section>
<!-- find_package(...) Search Precedence -->
<section data-markdown><textarea data-template>
`find_package(...)` Search Precedence
-------------------------------------
* Invocations of `find_package(...)` search for CMake script named `Find<package>.cmake` in
* Default installation paths (such as `/usr/share/cmake/Modules`)
* Paths provided via `CMAKE_MODULE_PATH`
* If no `Find<package>.cmake` script found, search for `<package>Config.cmake` script in
path specified by `<package>_DIR` variable.
</textarea></section>
</section>
<!-- Chapter 4: Installing Software -->
<section>
<!-- Intro -->
<section data-markdown><textarea data-template>
Chapter 4
---------
![MS DOS install!](images/MS-DOS-7.1-install-56.png)
<!-- .element style="border: 0; background: None; box-shadow: None; width: 80%" -->
### Installing Software
</textarea></section>
<!-- Install Function Overview -->
<section data-markdown><textarea data-template>
`install(...)` Function Overview
--------------------------------
* Highly versatile
* Different forms for installing:
* Executable CMake targets
* Library CMake targets
* Executables that are not CMake targets
* Miscellaneous files (such as headers)
* Whole directories
* Add an executable CMake script to run during installation
* Support for multiple installation "components" which can become one or many installation packages
</textarea></section>
<!-- Install: Common Arguments -->
<section>
<h2>Install: Common Arguments</h2>
<dl>
<dd><code>DESTINATION</code> (required)</dd>
<dt>Relative path where content should be installed</dt>
<dd><code>PERMISSIONS</code></dd>
<dt>Filesystem permissions of the installed content</dt>
<dd><code>CONFIGURATIONS</code></dd>
<dt>Support for filtering by CMake configuration type (as in, <code>CMAKE_BUILD_TYPE</code>)</dt>
<dd><code>COMPONENT</code></dd>
<dt>Specifies the component (more in Chapter 4)</dt>
<dd><code>OPTIONAL</code></dd>
<dt>Should an error be thrown if no file exists to be installed</dt>
</dl>
</section>
<!-- Install: Examples -->
<section data-markdown><textarea data-template>
Install: Examples
-----------------
<pre><code data-trim class="line-numbers CMake">
# Install the "HelloWorld" target to the `bin` directory
install(TARGETS HelloWorld DESTINATION bin)
# Install (almost) the entire contents of a directory...
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
DESTINATION include
FILES_MATCHING PATTERN "*.h")
# Install some specific files. DON'T COPY THIS EXAMPLE! See install(PROGRAMS ...)
install(FILES
"${PROJECT_SOURCE_DIR}/scripts/doFoo.sh"
"${PROJECT_SOURCE_DIR}/scripts/doBar.py"
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
</code></pre>
</textarea></section>
<!-- Exported CMake Scripts-->
<section data-markdown><textarea data-template>
Exported CMake Scripts
----------------------
</textarea></section>
</section>
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
// Learn about plugins: https://revealjs.com/plugins/
plugins: [RevealMarkdown, RevealHighlight, RevealNotes]
});
</script>
</body>
</html>