Zitat von Eric LaFranchi <[email protected]>:
I'm confused about the following documentation.
The CMake FAQ section "How do I use a different compiler?" states:
"Set the appropriate CMAKE_FOO_COMPILER variable(s) to a valid
compiler name or full path in a list file using set(). This must be
done before any language is set (ie before any project() or
enable_language() command)."
I want to conditionally choose the compiler based on platform. My
CMakeList.txt contains code similar to the following:
cmake_minimum_required (VERSION 2.6)
if (CMAKE_SYSTEM_NAME STREQUAL "Platform1")
set (CMAKE_C_COMPILER cc1)
set (CMAKE_C_FLAGS -XYZ1)
elseif (CMAKE_SYSTEM_NAME STREQUAL "platform2")
set (CMAKE_C_COMPILER cc2)
set (CMAKE_C_FLAGS -XYZ2)
endif()
project(test)
...
However, before "project()" is called, the CMAKE_SYSTEM_NAME
appears undefined. When is CMAKE_SYSTEM_NAME defined?
Is another option available to switch on the system before
"project()" is invoked?
use
project(test NONE)
to not enable any language. Then CMAKE_SYSTEM_NAME should be defined.
OTOH, you may want to think again about your approach of doing things.
It makes it impossible to change compilers on a platform without
changing the CMakeList.txt file. What exactly is your use-case for the
above stuff?
HS
_______________________________________________
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