[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] How do I build conditionally required libraries?
From:       "Gagnon, Joseph - 0553 - MITLL" <Joseph.Gagnon () ll ! mit ! edu>
Date:       2015-08-20 13:14:57
Message-ID: A8E2E9CF2E60B44288814B91AA58C8D426E8F465 () LLE2K10-MBX01 ! mitll ! ad ! local
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Please refer to this structure in the description below.

 

project_root

       CMakeLists.txt

       build

              Debug

              Release

       src

              CMakeLists.txt

              COTS   <- Third party packages used by various components

                     COTS_Package_A

                     ...

              Marshalling

                     CMakeLists.txt

                     intf   <- contains pure virtual class representing
interface

                               implemented by Marshaller A, B and C

                     Utility       <- used only by Marshaller A and B

                                     requires COTS_Package_A (include
paths/libraries)

                           CMakeLists.txt

                           Utility source files, etc.

                     Marshaller A

                           CMakeLists.txt

                           Marshaller_A source files, etc.

                     Marshaller B

                           CMakeLists.txt

                           ...

                     Marshaller C

                           CMakeLists.txt

                           ...

              ... (other plug-ins)

                                

Description

                                

The project depicted above is intended to build various "plug-ins" (e.g.
marshallers) that will be used by another larger application. Using the
marshaller example, for a given installation of the application, only one of
the marshaller implementations will be used. The plan is that only the
selected implementation is built and provided as a shared library, along
with other components it depends on (e.g. COTS_Package_A) to the larger
application being installed. For the other implementations that were not
chosen, nothing related to them (code, required 3rd party packages, etc.)
should be included.

 

For a scenario, let's assume that Marshaller A is chosen. It requires the
Utility package, which in itself requires COTS_Package_A (Marshaller C
doesn't have these requirements, but Marshaller B does). So, when Marshaller
A is built, I also need to build Utility (along with its dependency on COTS
A).

 

I am assuming that each implementation should be built as EXCLUDE_FROM_ALL
so that they aren't all automatically built when make is run and instead
must be explicitly built (manually or by some other means) by running make
with the specific target.

 

Problem

 

I have not been able to figure out how to make this kind of behavior occur
using CMake. I have tried add_custom_target and add_dependencies to build
the Utility package when Marshaller A (or B) is being built, but have had no
luck. At first I thought I had it because when I ran make, the make build
messages seemed to indicate success. However, I knew it was not actually
doing the build because I deliberately left out the include_directories call
(for COTS A) in the Utility CMakeLists.txt to force compilation errors and
no errors were reported when the target build was performed. Obviously
something is not right.

 

If anyone has run into this type of scenario and has figured out a way to do
this with CMake, I would really appreciate any information you could
provide. I'm still new at using CMake and have not used, not do I understand
(yet) many of its functions and more advanced techniques.

 

Thank you,

Joe Gagnon

 

Engineer II

Group 53 - Secure Resilient Systems and Technology

MIT Lincoln Laboratory

Lexington, MA

 


[Attachment #5 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" \
CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 \
(filtered medium)"><style><!-- /* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal>Please refer to this structure in the \
description below.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>project_root<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
build<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Debug<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Release<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
src<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
COTS&nbsp;&nbsp; &lt;- Third party packages used by various \
components<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
COTS_Package_A<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
...<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Marshalling<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
intf&nbsp;&nbsp; &lt;- contains pure virtual class representing \
interface<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; implemented by Marshaller A, B and \
C<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Utility&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;- used only by Marshaller A and \
B<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp; requires COTS_Package_A (include \
paths/libraries)<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Utility source files, etc.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Marshaller A<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Marshaller_A source files, etc.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Marshaller B<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
...<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Marshaller C<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
CMakeLists.txt<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp \
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
...<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:9.0pt;font-family:Consolas'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
... (other plug-ins)<o:p></o:p></span></p><p \
class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<o:p></o:p></p><p class=MsoNormal>Description<o:p></o:p></p><p \
class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<o:p></o:p></p><p class=MsoNormal>The project depicted above is intended to build \
various &quot;plug-ins&quot; (e.g. marshallers) that will be used by another larger \
application. Using the marshaller example, for a given installation of the \
application, only one of the marshaller implementations will be used. The plan is \
that only the selected implementation is built and provided as a shared library, \
along with other components it depends on (e.g. COTS_Package_A) to the larger \
application being installed. For the other implementations that were not chosen, \
nothing related to them (code, required 3rd party packages, etc.) should be \
included.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal>For a scenario, let's assume that Marshaller A is chosen. It requires \
the Utility package, which in itself requires COTS_Package_A (Marshaller C doesn't \
have these requirements, but Marshaller B does). So, when Marshaller A is built, I \
also need to build Utility (along with its dependency on COTS A).<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I am assuming that each \
implementation should be built as EXCLUDE_FROM_ALL so that they aren't all \
automatically built when make is run and instead must be explicitly built (manually \
or by some other means) by running make with the specific target.<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Problem<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I have not been able to \
figure out how to make this kind of behavior occur using CMake. I have tried \
add_custom_target and add_dependencies to build the Utility package when Marshaller A \
(or B) is being built, but have had no luck. At first I thought I had it because when \
I ran make, the make build messages seemed to indicate success. However, I knew it \
was not actually doing the build because I deliberately left out the \
include_directories call (for COTS A) in the Utility CMakeLists.txt to force \
compilation errors and no errors were reported when the target build was performed. \
Obviously something is not right.<o:p></o:p></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>If anyone has run into this \
type of scenario and has figured out a way to do this with CMake, I would really \
appreciate any information you could provide. I'm still new at using CMake and have \
not used, not do I understand (yet) many of its functions and more advanced \
techniques.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p \
class=MsoNormal>Thank you,<o:p></o:p></p><p class=MsoNormal>Joe \
Gagnon<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><span \
style='font-size:8.0pt'>Engineer II<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:8.0pt'>Group 53 - Secure Resilient Systems and \
Technology<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:8.0pt'>MIT \
Lincoln Laboratory<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:8.0pt'>Lexington, MA<o:p></o:p></span></p><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>


["smime.p7s" (application/x-pkcs7-signature)]

-- 

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
--===============0206989819==--



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic