[CMake] Using ExternalProject with find_library and find_path

Alexander Dahl post at lespocky.de
Fri Aug 24 06:01:24 EDT 2018


Hei hei,

for a standalone build without system libraries I was experimenting
with the ExternalProject module today. My goal is to have some top
level build project which includes several CMake projects and some
external projects without relying on dev libraries installed on the
system (reason are basically incompatible library versions). However
those CMake projects should not be altered and should also be capable
of building against dev libs from the system or in a cross compile
environment like ptxdist. I created a simple example project to build
OpenSSL with the ExternalProject module, and link either that or the
OpenSSL lib from the system:

https://github.com/LeSpocky/effective-succotash

(Note: using MD5 inside this example program is really just a very
simple example, the real application will use more of OpenSSL, so that
one is really needed, please no suggestions for alternatives. ;-) )

(Also note: some things were inspired by the FindOpenSSL.cmake coming
with CMake 3.9).

This works in general with one minor flaw. When building OpenSSL as
external project, I have to run the build twice, because find_library
and find_path obviously fail to find OpenSSL in the build tree before
it is built. I could set those paths by hand with a priori knowledge
were the OpenSSL build will put its output, but that seems like an
unelegant solution to me.

Any hints on that topic? What I found on the web was basically things
from several years ago, I would appreciate a more modern CMake
approach with imported targets. ;-)

Greets
Alex

-- 
/"\ ASCII RIBBON | »With the first link, the chain is forged. The first
\ / CAMPAIGN     | speech censured, the first thought forbidden, the
 X  AGAINST      | first freedom denied, chains us all irrevocably.«
/ \ HTML MAIL    | (Jean-Luc Picard, quoting Judge Aaron Satie)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://cmake.org/pipermail/cmake/attachments/20180824/014f56b9/attachment.sig>


More information about the CMake mailing list