[CMake] Add Windows library dependency
J Decker
d3ck0r at gmail.com
Fri Jul 27 23:09:10 EDT 2018
should just be add_executable( whatever_target secur32 )
On Fri, Jul 27, 2018 at 8:05 PM Theodore Hall <twhall at umich.edu> wrote:
> Greetings,
>
> I'm building a project that depends on a Windows library -- Secur32.Lib --
> that is included in the regular library search path but is not one of the
> specific libraries that the compiler normally links to. In *NIX
> command-line terms, the "-L<path>" is OK, I only need to specify the
> "-lSecur32" part.
>
> If I put "#pragma comment (lib, "Secur32.Lib")" in the cpp file, the
> system finds and links it. If I omit that, then the build fails with an
> unresolved external symbol.
>
> I cannot find a way to accomplish this in the CMakeLists.txt file rather
> than relying on the #pragma. CMake complains that it doesn't know how to
> build it, though I've (tried to) set the IMPORTED property. I've tried
> various combinations of:
>
> find_library(SECUR32 Secur32)
> add_library(Secur32 SHARED IMPORTED)
> target_link_libraries(MyTarget
> Secur32)
>
> I have not tried to set IMPORTED_LOCATION, because libraries with that
> name exist in several locations, and the compiler actually knows better
> than I do which one to use -- e.g., one of them is in:
>
> C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64\Secur32.Lib
>
> We're building in VisualStudio 2017 as a CMake project. We have not
> generated and are not using VS ",proj" or ".sln" files. We're aiming to
> build this as a multi-platform application. (The dependence on this
> library is wrapped in the appropriate #if defined ... #endif directives.)
>
> Any enlightenment would be greatly appreciated. Thanks.
>
> --
>
> Ted Hall
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180727/7383bc5d/attachment.html>
More information about the CMake
mailing list