<HTML><HEAD>
<STYLE type=text/css> body { margin:0.7em; } body.OECFntDef, body.OECFntDef div { font-family:"Segoe UI",Tahoma,Verdana,Arial,Helvetica,sans-serif;font-size:10pt; }</STYLE>
<META name=GENERATOR content="MSHTML 11.00.10570.1001"></HEAD>
<BODY spellcheck=true class=OECFntDef>
<DIV>I have a project with a chain of external libraries and some of the dependencies depend on each other as options </DIV>
<DIV> </DIV>
<DIV>meaning </DIV>
<DIV> </DIV>
<DIV>project uses </DIV>
<DIV> </DIV>
<DIV>LIB A, </DIV>
<DIV>LIB B</DIV>
<DIV> </DIV>
<DIV>LIB B can use as option LIB C</DIV>
<DIV> </DIV>
<DIV>my project then needs to inquire LIB B to see if LIB C was included (to link with LIB C)</DIV>
<DIV> </DIV>
<DIV>I do this like this</DIV>
<DIV> </DIV>
<DIV>message("-- Detecting if HDF5 library ${HDF5_LIBRARY} needs the ZLIB library...")<BR>check_library_exists(${HDF5_LIBRARY} H5Z_DEFLATE "" NEED_ZLIB)</DIV>
<DIV> </DIV>
<DIV>here LIB B = HDF5_LIBRARY</DIV>
<DIV>LIB C = the zlib library</DIV>
<DIV> </DIV>
<DIV>this works with no problems in Linux.</DIV>
<DIV> </DIV>
<DIV>However in Visual Studio , this detection only works if I manually set in the generated project</DIV>
<DIV>the option</DIV>
<DIV>"Link Library Dependencies"</DIV>
<DIV>to include LIB C (the zlib library)</DIV>
<DIV> </DIV>
<DIV>these lines get added to the generated Visual Studio project</DIV>
<DIV> </DIV>
<DIV><PRE><CODE><Lib>
<AdditionalOptions>%(AdditionalOptions) /machine:x64</AdditionalOptions>
<AdditionalDependencies>I:\nco\cmake\zlib\build\Debug\zlibstaticd.lib;I:\nco\cmake\szip\build\bin\Debug\libszip_D.lib</AdditionalDependencies>
</Lib</CODE></PRE></DIV>
<DIV> </DIV>
<DIV>Is there a way that I can set this in the CMake script?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>these comments show the problem</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>#HDF5 can be optionally linked with the SZIP library (Science Data Lossless Compression Program) and ZLIB<BR>#Symbol to detect in ZLIB can be only H5Z_DEFLATE, a structure only defined in H5Zdeflate.c if the filter is enabled<BR>#For SZIP the structure can be only H5Z_SZIP, defined in H5Zszip.c if the filter is enabled<BR>#check_library_exists() tries to link a temporary program with these symbols<BR>#On MSVC for this detection to work, the HDF5 library MUST HAVE as additional dependencies the ZLIB and SZIP libraries,<BR>#which is not a requirement for the library to build successfully</DIV>
<DIV> </DIV>
<DIV>to reproduce the problem, this is the project</DIV>
<DIV> </DIV>
<DIV><A href="https://github.com/nco/nco/tree/master/cmake">https://github.com/nco/nco/tree/master/cmake</A></DIV>
<DIV> </DIV>
<DIV>on a windows Win64 developer shell</DIV>
<DIV> </DIV>
<DIV>git clone <A href="https://github.com/nco/nco">https://github.com/nco/nco</A></DIV>
<DIV>cd cmake</DIV>
<DIV>clone.bat</DIV>
<DIV>bld.bat</DIV>
<DIV> </DIV>
<DIV>this will git clone and build dependencies, but there will be linking errors because the ZLIB (and SZIP) libraries</DIV>
<DIV>were not correctly identified as needed</DIV>
<DIV> </DIV>
<DIV>thanks</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><SPAN style='FONT-SIZE: 10pt; FONT-FAMILY: "Arial",sans-serif'>----------------------<BR>Pedro Vicente<BR><A href="http://www.space-research.org/" rel=nofollow target=_top link="external">http://www.space-research.org/</A></SPAN></DIV>
<DIV><SPAN style='FONT-SIZE: 10pt; FONT-FAMILY: "Arial",sans-serif'><A href="http://pedro-vicente.net/">http://pedro-vicente.net/</A></SPAN></DIV>
<DIV><SPAN style='FONT-SIZE: 10pt; FONT-FAMILY: "Arial",sans-serif'></SPAN> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></BODY></HTML>