2016-11-04 5:06 GMT+01:00 B. Scott Harper :
> 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.
>
Yes this is a kind of chicken & eggs problem.
The size of VOID_P may not be known before the arch+compiler is known and
for that you need project (+ enable_langage) etc...
Since you already use different CMake generator for your different may be
you can check
CMAKE_GENERATOR
CMAKE_GENERATOR_PLATFORM
CMAKE_GENERATOR_TOOLSET
instead. I guess that those should be (I did not checked) defined before
project command.
> 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.
>
This is a generator agnostic way to detect 32 vs 64 bits but
You may have a look at CMAKE_SYSTEM_ variables as well, but those may
not be defined before enable language/project command as well.
However CMAKE_GENERATOR_xxx matches should be enough to name your project
properly I guess.
--
Eric
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake