How to fix CMake "target_include_directories called with invalid arguments"
Problem:
In your CMakeLists.txt, you want to add an include directory such as /usr/include/mylibrary for the executable myexe using code like:
CMakeLists.txt
target_include_directories( myexe /usr/include/mylib )But when you try to configure the build using cmake . or make, you see an error message like
cmake_error.txt
CMake Error at CMakeLists.txt:8 (target_include_directories):
target_include_directories called with invalid arguments
-- Configuring incomplete, errors occurred!Solution
You need to add PUBLIC between the target name (myexe) and the include directory/directories:
CMakeLists.txt
target_include_directories( myexe PUBLIC /usr/include/mylib )Check out similar posts by category:
CMake
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow