Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CMake Recipes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpcdf
training
CMake Recipes
Commits
1f1a158c
Commit
1f1a158c
authored
2 years ago
by
Sebastian Eibl
Browse files
Options
Downloads
Patches
Plain Diff
think in targets
parent
078b06d4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
00_targets/README.md
+28
-8
28 additions, 8 deletions
00_targets/README.md
with
28 additions
and
8 deletions
00_targets/README.md
+
28
−
8
View file @
1f1a158c
# Define Targets
# Think in targets!
This recipe illustrates how to build a basic application.
It consists of a backend library and an application frontend.
## Define the target type
[
add_library
](
[https://cmake.org/cmake/help/latest/command/add_library.html]
)
[
add_executable
](
[https://cmake.org/cmake/help/latest/command/add_executable.html]
)
# Set Target Properties
[
target_compile_definitions
](
[https://cmake.org/cmake/help/latest/command/target_compile_definitions.html]
)
[
target_compile_options
](
[https://cmake.org/cmake/help/latest/command/target_compile_options.html]
)
[
target_include_directories
](
[https://cmake.org/cmake/help/latest/command/target_include_directories.html]
)
[
target_link_libraries
](
[https://cmake.org/cmake/help/latest/command/target_link_libraries.html]
)
[
target_link_options
](
[https://cmake.org/cmake/help/latest/command/target_link_options.html]
)
[
target_sources
](
[https://cmake.org/cmake/help/latest/command/target_sources.html]
)
\ No newline at end of file
## Set target properties
| Aim | Command |
|----------------------------------------|-------------------------------------------------------------------------------------------------------------|
| add definitions |
[
target_compile_definitions
](
[https://cmake.org/cmake/help/latest/command/target_compile_definitions.html]
)
|
| add compile flags |
[
target_compile_options
](
[https://cmake.org/cmake/help/latest/command/target_compile_options.html]
)
|
| add include directories |
[
target_include_directories
](
[https://cmake.org/cmake/help/latest/command/target_include_directories.html]
)
|
| add a dependency, link against library |
[
target_link_libraries
](
[https://cmake.org/cmake/help/latest/command/target_link_libraries.html]
)
|
| add linker options |
[
target_link_options
](
[https://cmake.org/cmake/help/latest/command/target_link_options.html]
)
|
| add sources |
[
target_sources
](
[https://cmake.org/cmake/help/latest/command/target_sources.html]
)
|
## Usage requirements
https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#transitive-usage-requirements
| keyword | result |
|---------------|------------------------------------------------------------|
|
**PRIVATE**
| only relevant for the target |
|
**INTERFACE**
| only relevant for targets depending on this target |
|
**PUBLIC**
| relevant for both, the target itself and dependent targets |
## How to link against a "supported" third-party library?
Find the library with
[
find_package
](
[https://cmake.org/cmake/help/latest/command/find_package.html]
)
and link against
the imported target with
[
target_link_libraries
](
[https://cmake.org/cmake/help/latest/command/target_link_libraries.html]
)
.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment