<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">Thanks for your help with this issue.</div><div class=""><br class=""></div><div class="">Here is the resulting CMake “module” created:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/SimpleITK/SimpleITK/blob/master/CMake/sitkTargetLinkLibrariesWithDynamicLookup.cmake" class="">https://github.com/SimpleITK/SimpleITK/blob/master/CMake/sitkTargetLinkLibrariesWithDynamicLookup.cmake</a></div><div class=""><br class=""></div><div class="">It implements a function called <span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre; background-color: rgb(255, 255, 255);" class="">sitk_target_link_libraries_with_dynamic_lookup. </span>SimpleITK uses it for linking for all loadable modules to the wrapped languages libraries.</div><div class=""><br class=""></div><div class="">In CMake, Matt pointed to me that there is some undocumented functionality with not linking to LibPython in a undocumented PYTHON_ADD_MODULE method[1].</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Please consider adding a bonified intrinsic CMake way of doing “weak” or “with dynamic lookup” linking, perhaps as a option to the target_link_libraries function.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class="">Brad</div><div class=""><br class=""></div><div class="">[1] <a href="https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake#L293" class="">https://github.com/Kitware/CMake/blob/master/Modules/FindPythonLibs.cmake#L293</a></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Mar 24, 2016, at 10:16 AM, Bradly Lowekamp <<a href="mailto:blowekamp@mail.nih.gov" class="">blowekamp@mail.nih.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><blockquote type="cite" class="">On Mar 23, 2016, at 4:27 PM, Brad King <<a href="mailto:brad.king@kitware.com" class="">brad.king@kitware.com</a>> wrote:<br class=""><br class="">On 03/23/2016 04:16 PM, Bradley Lowekamp wrote:<br class=""><blockquote type="cite" class="">1) Is there a more CMAKE-ic way for doing this?<br class="">  With all they library and linking properties?<br class=""></blockquote><br class="">I'm not certain what you're asking because if you don't want to link<br class="">to a library then don't pass it to target_link_libraries and then<br class="">propagation doesn't matter.  What role do you think CMake might play<br class="">in doing this?<br class=""></blockquote><br class="">I thought that there may have been something I was missing with options to target_link_librares options or the MODULE options in add_libraries.<br class=""><br class="">What role could it?<br class="">1) There could be a target property corresponding to if undefined symbols are allowed. It would be true for this case of linux, where it defaults to allowing undefined symbols. Conversely OSX does not allow undefined symbols by default but has a flag to enable them.<br class="">2) There could be an additional target_link_library keyword to specify the type of linking, say “WEAK”. This could cause a SHARED or MODULE target to to be linked against this library if undefined symbols are NOT allowed.<br class="">3) This is the first case I have seen where a MODULE library target, as in one intended to be dynamically loaded, should be handled differently.<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">2) Is there a way to know if the linker allows undefined symbols<br class="">  for shared libraries?<br class=""></blockquote><br class="">CMake does not provide this information directly.  You could use a<br class="">try_compile to test it.<br class=""></blockquote><br class="">Do you know of a try_compile example which creates a shared library? <br class=""><br class="">Just need to compile and link this as a shared library:  ”extern int bar(void); int foo(void) {return bar()+1;}”<br class=""><br class="">Lastly I am working on a couple experiments here: <a href="https://github.com/blowekamp/CMakeSecondaryDependencies" class="">https://github.com/blowekamp/CMakeSecondaryDependencies</a><br class=""><br class="">Thanks!<br class="">Brad<br class=""><br class=""><blockquote type="cite" class=""><br class="">-Brad K<br class=""><br class=""></blockquote><br class="">_______________________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at<br class=""><a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Kitware offers ITK Training Courses, for more information visit:<br class="">http://kitware.com/products/protraining.php<br class=""><br class="">Please keep messages on-topic and check the ITK FAQ at:<br class="">http://www.itk.org/Wiki/ITK_FAQ<br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class="">http://public.kitware.com/mailman/listinfo/insight-developers<br class=""></div></div></blockquote></div><br class=""></div></body></html>