[CMake] How to manage dependencies between projects in Visual Studio

Luca Gherardi luca.gherardi at unibg.it
Wed Feb 5 08:36:57 EST 2014


Actually a solution for this is using add_subdirectory().

 

The problem is that I use two out-of-source build directories, one for
building A and one for B.

 

If I use some directory the files generated during the compilation of A will
be stored:

- in the out-of-source build folder of solution A when the compilation is
launched from the solution A, 

- in the out-of-source build folder of solution B when the compilation is
launched from the solution B, 

 

In this way there is a duplication of files, which I would like to avoid.

 

A solution could be use the “binary_dir” option and specify that the project
A has to be built in the out-of-source build folder of solution A also when
the compilation is launched from B.

 

 

This would be the folder organization:

 

Root

- A

  - CMakeLists.txt

 - src

- B

  - CMakeLists.txt

 - src

- BUILD_A

- BUILD_B

 

And the CMakeLists of be would contain the following line:

 

Add_subdirectory(ABSOLUT_PATH_TO_A   BUILD_A)

 

 

Does it make sense?

 

Thanks!

 

From: Petr Kmoch [mailto:petr.kmoch at gmail.com] 
Sent: mercoledì 5 febbraio 2014 14:15
To: Luca Gherardi
Cc: cmake at cmake.org
Subject: Re: [CMake] How to manage dependencies between projects in Visual
Studio

 

Sorry, I've never used either functionality myself. I just wanted to point
out what exists.

Petr

 

On Wed, Feb 5, 2014 at 2:04 PM, Luca Gherardi <luca.gherardi at unibg.it
<mailto:luca.gherardi at unibg.it> > wrote:

Hi Peter,

 

I tried to use the include_external_msproject(PROJECT_NAME PATH_TO_VCXPROJ)

 

The project is included in the solution, however when I try to build the
solution VS returns the following error:

 

“The operation could not be completed. The parameter is incorrect”

 

No other information.

Any idea?

 

Thanks,

Luca

 

 

 

From: Petr Kmoch [mailto:petr.kmoch at gmail.com <mailto:petr.kmoch at gmail.com>
] 
Sent: mercoledì 5 febbraio 2014 12:34
To: Luca Gherardi
Cc: cmake at cmake.org <mailto:cmake at cmake.org> 
Subject: Re: [CMake] How to manage dependencies between projects in Visual
Studio

 

Hi Luca.

You could look into the CMake command include_external_msproject(), or into
the ExternalProject module.

Petr

 

On Wed, Feb 5, 2014 at 12:19 PM, Luca Gherardi <luca.gherardi at unibg.it
<mailto:luca.gherardi at unibg.it> > wrote:

I’m working with Visual Studio and I need to create the CMakeLists files for
the following scenario.

 

I have a project A, which contains the sources for a library.

This project has its own CMakeLists and generates a lib (add_library).

 

I have a second project B, which contains the sources from an executable and
uses the library generated by A.

I would like to setup its CMakeLists in such a way that:

 

-        The Visual Studio solution generated from the CMakeLists of B
includes the projects for A and B

-        The project A should be just a link to the project generated with
the CMakeLists of A. In other words I would like to avoid duplications of
compilation files. I would like that the file generated for A by a
compilation started from the solution of A were stored in the same path of
the file generated for A by a compilation started from the solution of B.

 

Is that possible?

I know it is possible to do it with visual studio, but I don’t know how to
do it with CMake.

 

Thanks in advance.

 

----------------------------------------------------------------------------
--

Luca Gherardi, PhD
Postdoc at ETH Zurich
Institute for Dynamic Systems and Control
Room ML K 34
Sonneggstrasse 3 - 8092 Zurich

SWITZERLAND


Office: +41 44 632 73 55 <tel:%2B41%2044%20632%2073%2055> 
Mobile: +41 788 833 174 <tel:%2B41%20788%20833%20174> 
Home: http://www.lucagherardi.it

 


--

Powered by www.kitware.com <http://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://www.cmake.org/mailman/listinfo/cmake

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140205/afe2eb4f/attachment.html>


More information about the CMake mailing list