In the CMakeLists.txt, if I define the .lib (static library) file path as absolute path, it's working correctly. But if I define the same as relative path, an error is thrown. How do I solve it without hard coded ?
File structure:
|--D
| |--Rohit
| | |--Sandbox
| | | |--demo
| | | | |--src
| | | | | |--abc
| | | | | | |--build
| | | | | | |--CMakeLists.txt
| | | | | | |--lib
| | | | | | | |--foo.lib
.
.
| | | | |--workspace
| | | | | |--xyz
| | | | | | |--foo2.lib
This way is working fine:
add_library(foo STATIC IMPORTED)
set_property(TARGET foo PROPERTY IMPORTED_LOCATION D:/Rohit/Sandbox/demo/src/abc/lib/foo.lib)
This way is throwing error:
add_library(foo STATIC IMPORTED)
set_property(TARGET foo PROPERTY IMPORTED_LOCATION "/lib/foo.lib")
My CMakeLists.txt path: D:\Rohit\Sandbox\demo\src\abc\CmakeLists.txt
This is error I'm getting: LINK : fatal error LNK1104: cannot open file '\lib\foo.lib'
Also if I want to include .lib file from some other folder (let's say foo2.lib file is present in xyz folder of workspace), How to define it ?