You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1017 B
27 lines
1017 B
5 years ago
|
# Adding Usage Requirements for Library #
|
||
|
|
||
|
Usage requirements allow for far better control over a library / executable's
|
||
|
link and include line. While also giving more control over the transitive
|
||
|
property of targets inside CMake. The primary commands that leverage usage
|
||
|
requirements are:
|
||
|
|
||
|
- target_compile_definitions
|
||
|
- target_compile_options
|
||
|
- target_include_directories
|
||
|
- target_link_libraries
|
||
|
|
||
|
First up is MathFunctions. We first state that anybody linking to MathFunctions
|
||
|
needs to include the current source directory, while MathFunctions itself
|
||
|
doesn't. So this can become an INTERFACE usage requirement.
|
||
|
|
||
|
Remember INTERFACE means things that consumers require but the producer doesn't.
|
||
|
|
||
|
target_include_directories(MathFunctions
|
||
|
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||
|
|
||
|
Now that we've specified usage requirements for MathFunctions we can safely remove
|
||
|
our uses of the EXTRA_INCLUDES variable.
|
||
|
|
||
|
Run cmake or cmake-gui to configure the project and then build it with your
|
||
|
chosen build tool.
|