I have a C library that includes the following dependency in CMake:
if (WIN32)
target_link_libraries(my_library legacy_stdio_definitions.lib)
target_link_libraries(my_library wsock32)
else()
...
endif()
This works mostly fine for my application, but I'm experimenting with a different approach that requires the libraries to have absolute paths. So switched to the following:
if (WIN32)
find_library(LEGACY_LIB legacy_stdio_definitions.lib)
find_library(WSOCK_LIB wsock32)
# Do something with ${LEGACY_LIB} and ${WSOCK_LIB}
else()
...
endif()
To my surprise, this doesn't work. Both find_library
s fail which sets the variables to NOTFOUND
.
How do I fix this? My first guess would be that find_library
is not looking in the same places as target_link_libraries
, but I did some research and I wasn't able to find where it was looking. What am I missing?