mstranne
mstranne

Reputation: 78

how include external library in c++ with cmake

I got my directory like:

-lib
-- mylibrary.dll
-- mylibrary.lib
-- mylibrary.exp
-main.cpp
-cmakelist

and i want my cmake to include the library into the main project like following:

link_directories(${CMAKE_BINARY_DIR}/lib)
add_executable(test_app main.cpp)
target_link_libraries(testapp mylibrary)

but the the include do not find the header. I tried find_package but that did not work...

anyone can help me?

Upvotes: 0

Views: 1861

Answers (1)

Vittorio Romeo
Vittorio Romeo

Reputation: 93364

You need to use include_directories to point CMake to your header search folders.

Add the given directories to those the compiler uses to search for include files. Relative paths are interpreted as relative to the current source directory.

Upvotes: 2

Related Questions