[CMake] Change project name based on architecture

B. Scott Harper orcein at gmail.com
Fri Nov 4 00:06:48 EDT 2016


I have a project where I manage multiple architectures and switch back and
forth frequently for testing. Full disclosure, I'm using Visual Studio. And
since I cannot generate a single solution with multiple architectures (per
everything I've found searching Google and the mailing list), I have two
separate solution files (one each for x86 and x64). I often open a solution
using the recent solutions menu, and it would be a lot easier if I could
name the solution (cmake's "project()" command) differently for each
architecture I use.

I tried simply

if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
    set(PLATFORM_TARGET "x64")
else()
    set(PLATFORM_TARGET "x86")
endif()

project(My_Project_${PLATFORM_TARGER})

...however it seems that CMAKE_SIZEOF_VOID_P isn't filled out until AFTER
the project command, so I can't use that variable as part of my
project/solution name.

Is there another way to accomplish this? Google only returns documentation
on the project command in general and the above method seems to be the
preferred means of detecting build architecture.

Cheers,
-- Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161104/2c254543/attachment-0001.html>


More information about the CMake mailing list