[CMake] Cmake and Visual Studio platforms

David Cole dlrdave at aol.com
Fri Mar 1 09:45:25 EST 2013


This is a noble and worthy idea. Unfortunately, it just won’t work, given the way that CMake has historically evolved, and the assumptions made by most folks writing CMakeLists files.

 

Here are some facts:

 

The C and C++ compilers are usually determined very early on in the configure process, and cached so that a build tree is irrevocably bound to that single compiler.

 

EVERY SUBSEQUENT TEST done at configure time that uses the compiler to compute its results is also cached, and tied to that single compiler. Changing the compiler, or having multiple compilers, makes all of those results INVALID.

 

There is code like “if(CMAKE_SIZEOF_VOID_P EQUAL 8) then (do something x64-ish...)” in many CMakeLists.txt files that depends on a single compiler (either 32-bit *or* 64-bit) being used.

 

These facts conspire against your idea, and do not allow CMake to generate a solution that contains both architectures, UNLESS you are willing to re-write existing CMakeLists files for projects that need this such that they do not rely on the compiler results at configure/generate time. (And do tons and tons of re-work of CMake code to enable the possibility...) For any project that does any sort of try_compile operation, this cannot work when multiple compilers are involved. Unless you redesign try_compile to do multiple tries, and yield multiple results.

 

Hope this helps to explain things.

 

Use separate build trees, use single configuration generators in each, and build multiple times. That’s the CMake way to do what you want.

 

Anything else is a completely major re-write, and will not work with 95%+ of the existing CMakeLists files in the world.

 

 

Unfortunate, but true,

David C.

 

 


From: Meteorhead
Sent: ‎March‎ ‎1‎, ‎2013 ‎5‎:‎28‎ ‎AM
To: cmake at cmake.org
Subject: Re: [CMake] Cmake and Visual Studio platforms


I understand why CMake cannot resolve the issue in a single call to
configure. However...

how tricky/hard/impossible would it be to alter/rape the generate stage of
CMake to handle this issue? 

Let's say I wanted to create a Win32 and an x64 platform inside a
solution/project. Then I would start a VS command prompt for the native 64
and 32 bit compilers. I'd start a CMake GUI from both (or use the command
line, whatever) and configure once a 32-bit and once a 64-bit solution. The
tricky part comes here: both CMake instances have their output directory set
to the same directory.

I could image the generate stage (or even later internally just when writing
the output files), that when I generate let's say the 32-bit first, it sees
an empty directory, creates all neccessary files, and it's done. When I hit
generate the second time on the 64-bit configuration, it finds solution
files with Win32 set as platform. Instead of overwriting all the project and
solution files, it could insert into the xml code it's own x64 platform and
leave the others as it is. This way both platforms would compile and link
the proper libraries and dependencies.

Having met CMake as not an end-user only 3 weeks ago, I have little
knowledge of the intimacies of the configuration cache for example, so I
could imagine that having two different configuration set onto the same
output directory could cause mishaps, but that is why I ask the black-belt
people here.

I have not used other IDEs throroughly, but I can image CodeBlocks or XCode
has got their own equivalent (or maybe not) of platforms beside regular
build targets. Could this setup of configurate/generate serve as a solution
to our problem? Is there hope of it being implemented? Or are there
conceptual errors along the way that I have not come to realise?

(I could image changing the behavior of "shoot first, ask later", namely do
not check anything, just overwrite whatever we find in the target dir, could
be misleading in the sense that one would expect such behavior from all
generators, but instead the VS generator parses the found solution/project
files, and inserts code into it if the platforms differ, rather than
overwriting the entire thing. I believe these behavioral differences could
be overlooked, if one could make multi-platform solution files.)

Ideas? Suggestions? Flame?



--
View this message in context: http://cmake.3232098.n2.nabble.com/Cmake-and-Visual-Studio-platforms-tp7583415p7583436.html
Sent from the CMake mailing list archive at Nabble.com.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

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/20130301/1f9d6aa3/attachment-0001.htm>


More information about the CMake mailing list