[CMake] Building a tool immediately so it can be used later in same CMake run

Scott Aron Bloom scott at towel42.com
Fri Apr 1 13:04:37 EDT 2016


I had asked a similar question 2 weeks or so ago.  The conclusion, which DID work well was the following.

Rather than having 1 “large” cmake project with sub libraries.

Use the “super-project” system, where you do an ExternalProject_Add for each of the projects.  Then for the projects that need the “first executable” you list that project as a dependency

Scott

From: CMake [mailto:cmake-bounces at cmake.org] On Behalf Of Craig Scott
Sent: Thursday, March 31, 2016 4:53 PM
To: cmake at cmake.org
Subject: [CMake] Building a tool immediately so it can be used later in same CMake run

All,

I originally planned to ask this question directly on this mailing list, but it got a bit more involved, so I posted it to stackoverflow instead. I'm interested if anyone can shed some more authoritative light on the proposed method for the following question:

http://stackoverflow.com/q/36084785/1938798

Short version: invoke a nested cmake-and-build immediately within the main CMake run to build a specific target via execute_process(). This makes that tool available for use still within the same (main) CMake run. An ExternalProject-based technique would normally be a better solution, but in this particular case, that wasn't possible.

I'd be interested if anyone can confirm whether the suggested approach is guaranteed to be safe for all generators and platforms, or whether there are other factors I have not considered in the proposed technique.

Cheers

--
Craig Scott
Melbourne, Australia
http://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160401/0f5f0931/attachment.html>


More information about the CMake mailing list