How to link external libraries with cmake? i want to include header files (Liblaries/include) and link .lib files(Liblaries/lib) + opengl lib.
Asked
Active
Viewed 775 times
-3
-
I'm new to CMake, but I think you're looking for something like `target_link_libraries(Game ${CMAKE_SOURCE_DIR}/lib/glew32s.lib ${CMAKE_SOURCE_DIR}/lib/glfw3.lib)` and `target_include_directories(Game ${CMAKE_SOURCE_DIR}/include)`. It appears that your `CMakeLists.txt` file exists in `Liblaries` directory already, so you shouldn't need `Liblaries` in your paths for the target commands. – Aug 26 '18 at 18:04
-
In the future, you should be aware that it's usually more helpful to post the code that isn't working and also explain what you've tried already that hasn't worked. The image is useful for showing your project's directory structure, but that's all. – Aug 26 '18 at 18:06
1 Answers
1
ADD_LIBRARY(LibsModule
file1.cpp
file2.cpp
)
then add them to a module call LibsModule
target_link_libraries(LibsModule -lpthread)
Please refer to this post: Adding Libraries with cmake
As an advice please use the "Similar Question Asked" before posting to avoid getting downvoted or being closed as duplicate. Cheer

Hasan Patel
- 412
- 7
- 19