<div dir="ltr"><div><div>Hi Andrey, <br><br></div>Since there is already a FindOpenSSL.cmake module [1], configuring the consumer project with the variable expected by the FindOpenSSL.cmake module is the easiest.<br><br>See <a href="https://github.com/Slicer/Slicer/blob/ee84fba523d85be3539bf8c83c8eb73d4f59cfff/SuperBuild/External_OpenSSL.cmake#L231-L239">https://github.com/Slicer/Slicer/blob/ee84fba523d85be3539bf8c83c8eb73d4f59cfff/SuperBuild/External_OpenSSL.cmake#L231-L239</a><br><br><br>[1] <a href="https://github.com/Kitware/CMake/blob/master/Modules/FindOpenSSL.cmake">https://github.com/Kitware/CMake/blob/master/Modules/FindOpenSSL.cmake</a><br><br>Hth<br></div>Jc<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 17, 2015 at 3:27 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm using ExternalProject_Add() to build OpenSLL library. After<br>
install step I have following artifacts available:<br>
* libcrypto.a<br>
* libssl.a<br>
* include/openssl/*.h<br>
<br>
I wonder, what is the "canonical" way to make those artifacts<br>
available for other targets in the project?<br>
<br>
FindPackage style thing with OPENSSL_LIBRARIES and OPENSSL_INCLUDE_DIR<br>
variables will not work, because OpenSSL target and executable that<br>
uses it are on the same level (I think using CACHE to propagate<br>
variable value up is a dirty hack):<br>
* src/openssl/CMakeLists.txt<br>
* src/my_executable/CMakeLists.txt<br>
<br>
Ideally I would like to use add_library() with target_include_directories() and<br>
target_link_libraries(). But the only way to do that is to use<br>
IMPORTED libraries, like that:<br>
<br>
add_library(crypto STATIC IMPORTED GLOBAL)<br>
add_dependencies(crypto openssl_external_project)<br>
set_property(TARGET crypto PROPERTY INTERFACE_LINK_LIBRARIES<br>
${OPENSSL_PREFIX}/lib/libcrypto.a)<br>
set_property(TARGET crypto PROPERTY INTERFACE_INCLUDE_DIRECTORIES<br>
${OPENSSL_PREFIX}/include)<br>
<br>
But then I get an error:<br>
$ cmake ..<br>
<br>
CMake Error in src/my_executable/CMakeLists.txt:<br>
<br>
  Imported target "crypto" includes non-existent path<br>
<br>
 "<...>/build.dir/src/openssl/openssl-1.0.2.install/include"<br>
<br>
Obviously, that happens because include directory was not created yet<br>
(it will after make).<br>
<br>
I understand that from general CMake standpoint - IMPORTED libraries<br>
are something that already exists and not part of the build. But then<br>
I don't understand how this ExternalProject_Add thing is supposed to<br>
be used.<br>
<br>
Any ideas what I'm doing wrong?<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" 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" 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" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" 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" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">+1 919 869 8849<br></div>
</div>