[CMake] Visual Studio generator, cross-compiling

Andy Yelland ay at numfum.com
Tue Oct 18 13:56:33 EDT 2016


Hi there

I am trying to coax a Cmake generation of a Visual Studio project of our 
cross-platform product, that includes the PNaCl platform.  The MSBuild 
setup for PNaCl is a little bit fussy, and does not like the relative 
pathnames in <AdditionalDependencies>, that get produced when the 
product has target_link_libraries setup between the static libraries in 
the product.  For the sake of this mail I'll call the library project 
'LibProject', which as it's based on unix toolchain, will get the static 
lib created as libLibProject.a.  To be used as a command-line on the 
PNaCl cross-compiler, then it needs to get translated to -lLibProject  
(without the lib prefix, or the .a suffix).

So going into the Visual Studio generator for the EXE project, at 
present are the relative paths (will use Debug for this example): 
../LibProject/Debug/libLibProject.a  which gets added to the 
<AdditionalDependencies> tag in the .vcxproj

To make the PNaCl MSBuild extension work, then instead it needs to be:

  * <AdditionalDependencies>LibProject</AdditionalDependencies>
  * <AdditionalLibraryDirectories>../LibProject/Debug</AdditionalLibraryDirectories>

I am well aware that these get set by the cmake functions: 
target_link_libraries() and link_directories(), so feel this ought to be 
possible by Cmake script.

What I'm struggling with, is finding *a place* where I can:

  * Query all the libraries that have become dependent on a target (the
    input to the Generator).  As target_link_libraries cascade, so my
    EXE project does not know about all of its leaf libraries, so I'm
    not really sure if there is a target property with ALL the dependent
    static library projects)
  * Adjust this list, stripping: path, 'lib' and '.a'
  * Inserting link_directories (or the equivalent, presuming it's some
    target property now), corresponding to the relative paths that were
    stripped in the step above

All of this would need to happen, after we've finished setting up the 
target, but before the generator.  Ideally this would be something I 
defined in the ToolChain folder - but I can't think of any kind of 
callback in the CMake system.

I'm open to other suggestions, about how to setup this visual studio 
cross-compile.  While PNaCl + MSDev may be rare, I feel that 
cross-compiling for other unix systems with -l and -L library and path 
command-lines ought to have been done before with Visual Studio generators.

Thanks in advance


Andy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161018/2f9e77c8/attachment.html>


More information about the CMake mailing list