Am 2017-08-07 11:57, schrieb Björn Blissing:
3. Some of my legacy projects have all source in the same directory,
i.e. both source and header files are in the same directory. Others
have both private and public headers in the same directory. How do I
handle this with target_include_directories()? Preferably I would
to avoid reorganizing the file structure.
If things are in the same directory you don't need
target_include_directories(), as the header files will be found anyway
if you use "" (probably also <>). If they are in a different directory
it doesn't matter if the private and public things are mixed, you need
to add that directory anyway.
Lets see if I understood what you are suggesting correctly:
Alternative 1: If both source and headers are in the same directory.
Solution: Omit the target_include_directories() statement completely
and just add the private and public header files in the add_library()
statement and the public headers in the install(FILES ...) statement.
Alternative 2: If source and headers are separated but both private
and public headers are included in the same directory.
Solution: Add the private and public header files in the add_library()
statement . Then add a target_include_directories() statement such as:
Then add the public headers in the install(FILES ...) statement.
Is this correct? Follow up question: Since the directory include
contains both public and private headers should the
target_include_directories() be specified as PUBLIC or PRIVATE?
I would make it public: less code, and the private headers will simply
not exist when installed.
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
Follow this link to subscribe/unsubscribe: