[CMake] how to map to cmake configurations when using include_external_msproject?

Bill Hoffman bill.hoffman at kitware.com
Mon Apr 12 17:46:03 EDT 2010


David Genest wrote:
> Reposting... trying to get your attention. Using cmake 2.8.0. Thank you for your time.
> 
> I am including a thirdparty msproject with the
> include_external_msproject() command. But this project has different
> configurations than the standard cmake configs.
> 
> The mapping is like this:
> 
> CMake				External Ms proj
> -----				----------------
> Debug		    -> 	Debug
> RelWithDebInfo 	->	Release
> Release		    ->	Retail
> 
> I have tried using the MAP_IMPORTED_CONFIG_<CONFIG> target property,
> but it has no effect (although the documentation says exactly what I
> want to accomplish, it mentions references to IMPORTED targets).
> 
> Here is my code:
> 
> include_external_msproject(externalms <pathToproject>)
> set_target_properties(externalms PROPERTIES
> 	MAP_IMPORTED_CONFIG_RELEASE "Retail"
> 	MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release")
> 
> Is there a way to have the configuration mapping done correctly with
> the include_external_msproject() command?
> 

I don't think that has ever been implemented...   The imported targets 
are a very different thing than the included external projects.    You 
might also be able to use imported targets and the external include 
together to get this to work...   You would have to create an "imported" 
target for the libraries that are built in your external project.  Say, 
you had an external pojrect foo.vcproj that built bar.lib.  You would do 
something like this:
include_external_msproject(externalms bar.vcproj)
  add_library(bar SHARED IMPORTED)
  set_property(TARGET bar PROPERTY IMPORTED_LOCATION c:/path/to/bar.dll)
  set_property(TARGET bar PROPERTY IMPORTED_IMPLIB c:/path/to/bar.lib)

Then link to bar in the CMake code. Then the MAP_IMPORTED should work. 
You will want to make sure that externalms depends on all the targets 
that use bar.

See here for more info:

http://www.cmake.org/Wiki/CMake_2.6_Notes

-Bill


More information about the CMake mailing list