Reputation: 351
I need to make library test
and use it in other projects by #include <libraryname>
In project test
:
CmakeLists.txt
... add_library(libtest STATIC lib.h lib.cpp) set_target_properties(libtest PROPERTIES PUBLIC_HEADER lib.h) install(TARGETS libtest PUBLIC_HEADER DESTINATION include RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) ...
In project testUseLibrary
:
CmakeLists.txt
... add_executable(project main.cpp) target_link_libraries(project PUBLIC libtest) ...
main.cpp
#include <libtest> // error
int main() {
return 0;
}
In project testUseLibrary
#include<libtest>
doesn't see library.
Upvotes: 1
Views: 2304
Reputation: 350
You need to use target_include_directories
to specify the include directories for your target. In this case, the directory where libtest resides.
Upvotes: 0