mirror of
https://github.com/ttroy50/cmake-examples.git
synced 2025-12-18 20:24:35 +03:00
Update to minimum CMake 3.5
And modernise some examples.
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user