I have a vendor provided static library.
I have added it as a STATIC IMPORTED
library target, and set properties on the target:
add_library(
lime_api
STATIC
IMPORTED
)
set_target_properties(
lime_api
PROPERTIES
IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/trading/limeTradingApi.a"
)
# users include "api/trading/limeTradingApi.h"
set_target_properties(
lime_api
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/.."
)
elsewhere in my source tree I try to link against lime_api
, and I get an error:
/usr/bin/ld: cannot find -llime_api
My source tree looks like this:
src
|
+--- api
| |
| +--- trading
| | - limeTradingApi.a
| | - limeTradingApi.h
| |
| +--- examples
| |
| +--- trading
|
+--- order
|
+--- example
The strange thing is that there is a vendor provided example which links against this library, and that works fine:
api/examples/trading/CMakeLists.txt
:
add_executable (trading_demo exampleClient.cc)
target_link_libraries(trading_demo lime_api) <-- this works
However, when I try linking against my own library which includes the lime_api
I get the linker error.
order/CMakeLists.txt
:
add_library(
order
STATIC
${SRCS}
)
target_link_libraries(order lime_api) <-- this doesn't work
order/example/CMakeLists.txt
:
add_executable (order_example main.cpp)
target_link_libraries(order_example order)
Question:
Why doesn't CMake "convert" the linked target lime_api
into -llimeTradingApi.a
for my executable?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…