recovery
recovery

Reputation: 3

Cmake on windows, loading static library

I'm preparing windows build for my qt5 application and I have problem with loading static library .lib. My application is using 3d engine and originally was build on linux (gcc+cmake), now on windows I'm trying to use msvc+cmake. 3d engine static lib is called engined.lib. To load library I do something like that:

SET(CMAKE_FIND_LIBRARY_PREFIXES "")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
find_library(engine NAMES engined PATHS path_to_lib)
target_link_libraries(${PROJECT_NAME}
    Qt5::Widgets
    Qt5::OpenGL
    Qt5::Xml
    engine)

But during process compilation there are erros for example in my cpp file I'm loading headers:

#include "engine/Engine.h"

but, msvc do not see .h file and I have error. I'm doing something wrong?

Upvotes: 0

Views: 119

Answers (1)

piwi
piwi

Reputation: 5336

You are linking against the library, but you still need to configure CMake so that the engine's headers are found. One way to do this is to set the location of the headers through a cache variable:

# CMakeLists.txt
set(ENGINE_INCLUDE_DIR "" CACHE PATH "Include directory")
target_include_directories(engine PRIVATE ${ENGINE_INCLUDE_DIR})

And set the variable when configuring your build directory:

cmake -DENGINE_INCLUDE_DIR=/path/to/include/dir /path/to/project

Upvotes: 1

Related Questions