[CMake] Alternative for INCLUDE_EXTERMAL_MSPROJECT for Visual Studio 2012 generator

Jürgen Wohlfeil juergen.wohlfeil at dlr.de
Fri Apr 25 05:50:59 EDT 2014


Dear CMake experts,
I confugure several projects with CMake (seperately). These projects
depend on each other. For Visual Studio I used to include projects into
other projects using INCLUDE_EXTERMAL_MSPROJECT(...), which worked fine
for me as the projects were included into the solution with their source
files visible and editable, and the build system was aware of the
dependencies. At least on Visual Studio 2008.

Switching to Visual Studio 2012, it is not possible to use
INCLUDE_EXTERMAL_MSPROJECT(...) anyomre
(http://www.cmake.org/Bug/view.php?id=14897). As suggested, I tried to
solve the problem usingExternalProject_Add(...)
<http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html>, but
unfortunately I cannot make it work this way. Before I post another but
I would like to ask you for any ideas.

A simple example:

------------ Sln1/CMakeLists.txt ----------------------
cmake_minimum_required(VERSION 2.8)
project(project1)
ADD_LIBRARY (project1 STATIC main.cpp)

------------ Sln2/CMakeLists.txt ----------------------
cmake_minimum_required(VERSION 2.8)
project(project1)
ADD_LIBRARY (project1 STATIC main.cpp)

include(ExternalProject)
ExternalProject_Add(project1 SOURCE_DIR ../Sln1)


I cmake both projects and open the resulting solution Sln2/project2.sln
with Visual Studio. There are two poblems:
Problem 1: project1 is included in the solution, but the source file is
not visible
Problem 2: If I build the solution I get the following error message:

1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32
------
1>  Checking Build System
1>  CMake does not need to re-run because
[...]/Sln2/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: project1, Configuration: Debug Win32 ------
3>------ Build started: Project: project2, Configuration: Debug Win32 ------
2>  Building Custom Rule [...]/Sln2/CMakeLists.txt
2>  CMake does not need to re-run because
[...]\Sln2\CMakeFiles\generate.stamp is up-to-date.
2>  Creating directories for 'project1'
2>  No download step for 'project1'
2>  No update step for 'project1'
2>  No patch step for 'project1'
2>  Performing configure step for 'project1'
3>  Building Custom Rule [...]/Sln2/CMakeLists.txt
3>  CMake does not need to re-run because
[...]\Sln2\CMakeFiles\generate.stamp is up-to-date.
2>  -- Configuring done
2>  -- Generating done
2>  -- Build files have been written to: [...]/Sln1
3>  main.cpp
*2>  Performing build step for 'project1'**
2>CUSTOMBUILD : error : could not load cache*
3>  project2.vcxproj -> [...]\Sln2\Debug\project2.lib
4>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32
------
4>Project not selected to build for this solution configuration
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

Is this supposed to work or is it my mistake? Do you have any
suggestions what I can do to make this simple example run?
In case that you want to try it yourself I attatch the two examples to
this email:

1. cmake.include_external_msproject.bug.zip: Original attempt using
INCLUDE_EXTERMAL_MSPROJECT(...). Works with Visual Studio 2008 generator
but not with Visual Studio 2012 generator.

2. cmake.externalproject_add.bug.zip: Suggested attempt using
ExternalProject_Add(...)
<http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html>.
Fails with 2008 and 2012.

Thanks a lot for any suggestions.
Jürgen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140425/d92d10fa/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake.externalproject_add.bug.zip
Type: application/x-zip-compressed
Size: 1337 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140425/d92d10fa/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake.include_external_msproject.bug.zip
Type: application/x-zip-compressed
Size: 1305 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140425/d92d10fa/attachment-0001.bin>


More information about the CMake mailing list