<div dir="ltr">should just be add_executable( whatever_target secur32 )<div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 27, 2018 at 8:05 PM Theodore Hall <<a href="mailto:twhall@umich.edu">twhall@umich.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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-wrap">      </span>find_library(SECUR32 Secur32)</div><div><span style="white-space:pre-wrap">    </span>add_library(Secur32 SHARED IMPORTED)<br></div><div><span style="white-space:pre-wrap">   </span>target_link_libraries(MyTarget</div><div><span style="white-space:pre-wrap">           </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="m_-6344733350272638231gmail-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="m_-6344733350272638231gmail_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>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>