[CMake] Consuming results of ExternalProject_Add

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Tue Feb 17 16:53:19 EST 2015


Hi Andrey,

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.

See
https://github.com/Slicer/Slicer/blob/ee84fba523d85be3539bf8c83c8eb73d4f59cfff/SuperBuild/External_OpenSSL.cmake#L231-L239


[1] https://github.com/Kitware/CMake/blob/master/Modules/FindOpenSSL.cmake

Hth
Jc

On Tue, Feb 17, 2015 at 3:27 PM, Andrey Pokrovskiy <wonder.mice at gmail.com>
wrote:

> Hi,
>
> I'm using ExternalProject_Add() to build OpenSLL library. After
> install step I have following artifacts available:
> * libcrypto.a
> * libssl.a
> * include/openssl/*.h
>
> I wonder, what is the "canonical" way to make those artifacts
> available for other targets in the project?
>
> FindPackage style thing with OPENSSL_LIBRARIES and OPENSSL_INCLUDE_DIR
> variables will not work, because OpenSSL target and executable that
> uses it are on the same level (I think using CACHE to propagate
> variable value up is a dirty hack):
> * src/openssl/CMakeLists.txt
> * src/my_executable/CMakeLists.txt
>
> Ideally I would like to use add_library() with
> target_include_directories() and
> target_link_libraries(). But the only way to do that is to use
> IMPORTED libraries, like that:
>
> add_library(crypto STATIC IMPORTED GLOBAL)
> add_dependencies(crypto openssl_external_project)
> set_property(TARGET crypto PROPERTY INTERFACE_LINK_LIBRARIES
> ${OPENSSL_PREFIX}/lib/libcrypto.a)
> set_property(TARGET crypto PROPERTY INTERFACE_INCLUDE_DIRECTORIES
> ${OPENSSL_PREFIX}/include)
>
> But then I get an error:
> $ cmake ..
>
> CMake Error in src/my_executable/CMakeLists.txt:
>
>   Imported target "crypto" includes non-existent path
>
>  "<...>/build.dir/src/openssl/openssl-1.0.2.install/include"
>
> Obviously, that happens because include directory was not created yet
> (it will after make).
>
> I understand that from general CMake standpoint - IMPORTED libraries
> are something that already exists and not part of the build. But then
> I don't understand how this ExternalProject_Add thing is supposed to
> be used.
>
> Any ideas what I'm doing wrong?
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150217/d5073fc7/attachment.html>


More information about the CMake mailing list