Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>include_directories() populates a directory property called INCLUDE_DIRECTORIES:</p> <p><a href="http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_dir:INCLUDE_DIRECTORIES">http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_dir:INCLUDE_DIRECTORIES</a></p> <p>Note that CMake 2.8.11 learned the target_include_directories command, which populates the INCLUDE_DIRECTORIES target property.</p> <p><a href="http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:target_include_directories">http://www.cmake.org/cmake/help/v2.8.12/cmake.html#command:target_include_directories</a></p> <p>Note also that you can encode the fact that 'to compile against the headers of the lib target, the include directory lib/inc is needed' into the lib target itself by using target_include_directories with the PUBLIC keyword.</p> <pre><code>add_library(lib STATIC ${lib_hdrs} ${lib_srcs}) # Why do you list the headers? target_include_directories(lib PUBLIC "${ROOT_SOURCE_DIR}/lib/inc") </code></pre> <p>Note also I am assuming you don't install the lib library for others to use. In that case you would need to specify different header directories for the build location and for the installed location.</p> <pre><code>target_include_directories(lib PUBLIC # Headers used from source/build location: "$&lt;BUILD_INTERFACE:${ROOT_SOURCE_DIR}/lib/inc&gt;" # Headers used from installed location: "$&lt;INSTALL_INTERFACE:include&gt;" ) </code></pre> <p>Anyway, that's only important if you are installing lib for others to use.</p> <p>After the target_include_directories(lib ...) above you don't need the other include_directories() call. The lib target 'tells' proj1 the include directories it needs to use.</p> <p>See also target_compile_defintions() and target_compile_options().</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload