Update to minimum CMake 3.5

And modernise some examples.
This commit is contained in:
Thom Troy
2018-03-18 17:23:57 +00:00
parent 54e75664c1
commit b81da6f68b
52 changed files with 303 additions and 212 deletions

View File

@@ -83,6 +83,27 @@ file(GLOB SOURCES "src/*.cpp")
----
====
[NOTE]
====
An alternative to setting specific file names in the +SOURCES+ variable is
to use a GLOB command to find files using wildcard pattern matching.
[source,cmake]
----
file(GLOB SOURCES "src/*.cpp")
----
====
[TIP]
====
For modern CMake it is normally recommend to not use a variable for sources and to
directly declare the sources in the add_xxx function.
This is particularly important for glob commands which may not always show you the
correct results if you add a new source file.
====
## Including Directories
When you have different include folders, you can make your compiler aware of them using the
@@ -91,8 +112,9 @@ When you have different include folders, you can make your compiler aware of the
[source,cmake]
----
target_include_directories(target
PRIVATE ${PROJECT_SOURCE_DIR}/include
)
PRIVATE
${PROJECT_SOURCE_DIR}/include
)
----
The +PRIVATE+ identifier specifies the scope of the include. This is important for libraries and is exlpained in the next example. More details on the function is available link:https://cmake.org/cmake/help/v3.0/command/target_include_directories.html[here]