<div dir="ltr"><div class="gmail_extra">Hi Andrey, <br><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 17, 2015 at 5:52 PM, Andrey Pokrovskiy <span dir="ltr"><<a href="mailto:wonder.mice@gmail.com" target="_blank">wonder.mice@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="im">
<br>
I don't see how External_OpenSSL.cmake is used in Slicer (probably<br>
some weird scheme is involved).<br></span></blockquote><div><br></div><div>We used "Artichoke" that provides a set of convenience function to managed "superbuild" based project.<br>See [1] and [2] for mode details. <br><br>[1] <a href="http://public.kitware.com/pipermail/cmake/2014-June/057735.html">http://public.kitware.com/pipermail/cmake/2014-June/057735.html</a><br>[2] <a href="https://github.com/commontk/Artichoke">https://github.com/commontk/Artichoke</a><br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="im">
But from what I see, it supposed to be used like that:<br>
<br>
  include(External_OpenSSL)<br>
  add_executable(my_executable main.cpp ...)<br>
  target_include_directories(my_executable ${OPENSSL_INCLUDE_DIR})<br>
  target_link_libraries(my_executable ${OPENSSL_LIBRARIES})<br>
<br>
That means that I will need to include External_OpenSSL in every<br>
CMakeLists.txt that uses OpenSSL. That doesn't sounds right to me.<br></span></blockquote><div><br></div><div><br></div><div>One way of using external projects is to consider it automate the following steps:<br><br></div><div> (1) manual build of OpenSSL<br></div><div> (2) configuration of your project Foo passing either OPENSSL_CRYPTO_LIBRARY/OPENSSL_SSL_LIBRARY options on unix or LIB_EAY_DEBUG/LIB_EAY_RELEASE/SSL_EAY_DEBUG/SSL_EAY_RELEASE on windows, and then build of the project<br><br><br></div>And since there are no need to manually rebuild openssl for each CMakeLists.txt in your project Foo, there are no need to include "External_OpenSSL" in every CMakeLists.txt.<br><br></div><div class="gmail_quote">Reading [3] should also be helpful to understand the concepts.<br><br>[3] <a href="http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html">http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html</a><br></div><div class="gmail_quote"><div><br><br></div><div><br><br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="im">
<br>
And if not, then something adds OPENSSL_INCLUDE_DIR and<br>
OPENSSL_LIBRARIES to CACHE which is also doesn't sounds right.<br>
<br>
Also this will not setup build dependency between target and OpenSSL.<br>
I know, I could use additional add_dependencies() for that, but that's<br>
clumsy. 3 lines instead of just:<br>
<br>
  target_link_libraries(my_executable crypto ssl)<br></span></blockquote><div><br></div><div>After doing:<br><br></div><div>  find_package(OpenSSL) <br><br></div><div>in your project, you could then do:<br><br>  target_link_libraries(my_executable ${OPENSSL_LIBRARIES})<br></div><div><br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="im">
<br>
CMake already has a concept of "libraries" (added with add_library).<br>
There should be a way of saying "Hey, this static library comes from<br>
that external project. It also requires such and such include<br>
directories".</span></blockquote><div><br></div><div>In fact, all FindXXXX.cmake module are slowly been converted to create CMake imported targets.<br><br></div><div>Since the current FindOpenSSL.cmake does not create imported targets, it could be updated to do so. For an example, see [4]<br><br>[4] <a href="http://www.cmake.org/cmake/help/v3.1/manual/cmake-developer.7.html#a-sample-find-module">http://www.cmake.org/cmake/help/v3.1/manual/cmake-developer.7.html#a-sample-find-module</a><br>[5] <a href="https://github.com/Kitware/CMake/commit/bcb0e38">https://github.com/Kitware/CMake/commit/bcb0e38</a><br><br><br></div><div>Hth<br></div><div>Jc <br></div></div><br><br><br clear="all"><br>-- <br><div class="gmail_signature">+1 919 869 8849<br></div>
</div></div>