<div dir="ltr">Greetings,<div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div><div><span style="white-space:pre">        </span>find_library(SECUR32 Secur32)</div><div><span style="white-space:pre"> </span>add_library(Secur32 SHARED IMPORTED)<br></div><div><span style="white-space:pre">        </span>target_link_libraries(MyTarget</div><div><span style="white-space:pre">                </span>Secur32)</div></div><div><br></div><div>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:</div><div><br></div><div>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64\Secur32.Lib<br></div><div>

<div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br class="gmail-Apple-interchange-newline">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.)</div><br></div><div>Any enlightenment would be greatly appreciated.  Thanks.<br clear="all"><div><br></div>-- </div><div><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Ted Hall<br></div><div dir="ltr"><br></div></div></div></div></div></div></div>