ENH: remove support for presetting CMAKE_SYSTEM_INFO_FILE,

CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE, CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE,
CMAKE_SYSTEM_AND_C_COMPILER_AND_PROCESSOR_INFO_FILE and CMAKE_SYSTEM_AND_CXX_COMPILER_AND_PROCESSOR_INFO_FILE

Instead of presetting these variables to arbitrary filenames, users should
set up CMAKE_SYSTEM_NAME and the compilers correctly and also create a
Platform/ directory so these files will all follow the official cmake style,
which should make it easier to understand and debug project which have their
own platform/toolchain support files.

-remove support for a suffix to MS crosscompilers, since this is not (yet)
supported by cmake and might confuse users

Alex
This commit is contained in:
Alexander Neundorf 2007-07-02 13:29:36 -04:00
parent 3c1c335800
commit 930bb0cd37
7 changed files with 31 additions and 79 deletions

View File

@ -19,30 +19,24 @@ IF(CMAKE_COMPILER_IS_GNUCC)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(CMAKE_SYSTEM_AND_C_COMPILER_AND_PROCESSOR_INFO_FILE)
INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_AND_PROCESSOR_INFO_FILE} OPTIONAL)
ELSE(CMAKE_SYSTEM_AND_C_COMPILER_AND_PROCESSOR_INFO_FILE)
IF(CMAKE_SYSTEM_PROCESSOR)
# load a hardware specific file, mostly useful for embedded compilers
IF(CMAKE_SYSTEM_PROCESSOR)
IF(CMAKE_C_COMPILER_ID)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_C_COMPILER_ID)
IF (NOT _INCLUDED_FILE)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
ENDIF (NOT _INCLUDED_FILE)
ENDIF(CMAKE_SYSTEM_PROCESSOR)
ENDIF(CMAKE_SYSTEM_AND_C_COMPILER_AND_PROCESSOR_INFO_FILE)
ENDIF(CMAKE_SYSTEM_PROCESSOR)
IF(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE)
INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE} OPTIONAL)
ELSE(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE)
IF(CMAKE_C_COMPILER_ID)
# load the system- and compiler specific files
IF(CMAKE_C_COMPILER_ID)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_C_COMPILER_ID)
IF (NOT _INCLUDED_FILE)
ENDIF(CMAKE_C_COMPILER_ID)
IF (NOT _INCLUDED_FILE)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
ENDIF (NOT _INCLUDED_FILE)
ENDIF(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE)
ENDIF (NOT _INCLUDED_FILE)
# This should be included before the _INIT variables are

View File

@ -21,30 +21,23 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(CMAKE_SYSTEM_AND_CXX_COMPILER_AND_PROCESSOR_INFO_FILE)
INCLUDE(${CMAKE_SYSTEM_AND_CXX_COMPILER_AND_PROCESSOR_INFO_FILE} OPTIONAL)
ELSE(CMAKE_SYSTEM_AND_CXX_COMPILER_AND_PROCESSOR_INFO_FILE)
IF(CMAKE_SYSTEM_PROCESSOR)
# load a hardware specific file, mostly useful for embedded compilers
IF(CMAKE_SYSTEM_PROCESSOR)
IF(CMAKE_CXX_COMPILER_ID)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_CXX_COMPILER_ID)
IF (NOT _INCLUDED_FILE)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
ENDIF (NOT _INCLUDED_FILE)
ENDIF(CMAKE_SYSTEM_PROCESSOR)
ENDIF(CMAKE_SYSTEM_AND_CXX_COMPILER_AND_PROCESSOR_INFO_FILE)
ENDIF(CMAKE_SYSTEM_PROCESSOR)
IF(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
INCLUDE(${CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE} OPTIONAL)
ELSE(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
IF(CMAKE_CXX_COMPILER_ID)
# load the system- and compiler specific files
IF(CMAKE_CXX_COMPILER_ID)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_CXX_COMPILER_ID)
IF (NOT _INCLUDED_FILE)
ENDIF(CMAKE_CXX_COMPILER_ID)
IF (NOT _INCLUDED_FILE)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
ENDIF (NOT _INCLUDED_FILE)
ENDIF(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
ENDIF (NOT _INCLUDED_FILE)
# This should be included before the _INIT variables are

View File

@ -8,10 +8,6 @@
# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used
# as prefix for the tools (e.g. arm-elf-gcc, arm-elf-ar etc.). This works
# currently with the GNU crosscompilers.
# It also tries to detect a MS crosscompiler and find out its
# suffix (clarm.exe), which will be stored in _CMAKE_TOOLCHAIN_SUFFIX and
# reused for the CXX compiler.
#
#
# Sets the following variables:
# CMAKE_C_COMPILER
@ -21,7 +17,6 @@
#
# If not already set before, it also sets
# _CMAKE_TOOLCHAIN_PREFIX
# _CMAKE_TOOLCHAIN_SUFFIX
IF(NOT CMAKE_C_COMPILER)
SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
@ -48,7 +43,7 @@ IF(NOT CMAKE_C_COMPILER)
IF(CMAKE_C_COMPILER_INIT)
SET(CMAKE_C_COMPILER_LIST ${CMAKE_C_COMPILER_INIT})
ELSE(CMAKE_C_COMPILER_INIT)
SET(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl${_CMAKE_TOOLCHAIN_SUFFIX} bcc xlc)
SET(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc)
ENDIF(CMAKE_C_COMPILER_INIT)
# Find the compiler.
@ -95,15 +90,6 @@ IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc")
ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
# if we have a MS cross compiler, it usually has a suffix, like
# e.g. clarm.exe or clmips.exe. Use this suffix for the CXX compiler too.
# the same is true e.g. for the IAR cross compiler, which is "icc<suffix>"
IF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
IF (COMPILER_BASENAME MATCHES "^cl(.+)\\.exe$")
STRING(REGEX REPLACE "^cl(.+)\\.exe$" "\\1" _CMAKE_TOOLCHAIN_SUFFIX "${COMPILER_BASENAME}")
ENDIF (COMPILER_BASENAME MATCHES "^cl(.+)\\.exe$")
ENDIF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
# Build a small source file to identify the compiler.
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")

View File

@ -7,9 +7,6 @@
# as a default compiler
# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used
# as prefix for the tools (e.g. arm-elf-g++, arm-elf-ar etc.)
# It also tries to detect a MS crosscompiler and find out its
# suffix (clarm.exe), which will be stored in _CMAKE_TOOLCHAIN_SUFFIX and
# reused for the C compiler.
#
# Sets the following variables:
# CMAKE_CXX_COMPILER
@ -19,7 +16,6 @@
#
# If not already set before, it also sets
# _CMAKE_TOOLCHAIN_PREFIX
# _CMAKE_TOOLCHAIN_SUFFIX
IF(NOT CMAKE_CXX_COMPILER)
SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
@ -46,7 +42,7 @@ IF(NOT CMAKE_CXX_COMPILER)
IF(CMAKE_CXX_COMPILER_INIT)
SET(CMAKE_CXX_COMPILER_LIST ${CMAKE_CXX_COMPILER_INIT})
ELSE(CMAKE_CXX_COMPILER_INIT)
SET(CMAKE_CXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl${_CMAKE_TOOLCHAIN_SUFFIX} bcc xlC)
SET(CMAKE_CXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl bcc xlC)
ENDIF(CMAKE_CXX_COMPILER_INIT)
# Find the compiler.
@ -93,16 +89,6 @@ IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+")
ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
# if we have a MS cross compiler, it usually has a suffix, like
# e.g. clarm.exe or clmips.exe. Use this suffix for the CXX compiler too.
IF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
IF (COMPILER_BASENAME MATCHES "^cl(.+)\\.exe$")
STRING(REGEX REPLACE "^cl(.+)\\.exe$" "\\1" _CMAKE_TOOLCHAIN_SUFFIX "${COMPILER_BASENAME}")
ENDIF (COMPILER_BASENAME MATCHES "^cl(.+)\\.exe$")
ENDIF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
# This block was used before the compiler was identified by building a
# source file. Unless g++ crashes when building a small C++
# executable this should no longer be needed.

View File

@ -7,9 +7,7 @@
INCLUDE(CMakeGenericSystem)
# 2. now include SystemName.cmake file to set the system specific information
IF(NOT CMAKE_SYSTEM_INFO_FILE)
SET(CMAKE_SYSTEM_INFO_FILE Platform/${CMAKE_SYSTEM_NAME})
ENDIF(NOT CMAKE_SYSTEM_INFO_FILE)
SET(CMAKE_SYSTEM_INFO_FILE Platform/${CMAKE_SYSTEM_NAME})
INCLUDE(${CMAKE_SYSTEM_INFO_FILE} OPTIONAL RESULT_VARIABLE _INCLUDED_SYSTEM_INFO_FILE)

View File

@ -4,5 +4,5 @@ set(CMAKE_SYSTEM_VERSION "1.0")
set(CMAKE_C_COMPILER /opt/foo/bin/arm-elf-gcc)
set(CMAKE_C_OUTPUT_EXTENSION ".foo")
set(CMAKE_CXX_COMPILER /opt/bar/bin/clarm.exe)
set(CMAKE_CXX_COMPILER /opt/bar/bin/cl.exe)
set(CMAKE_CXX_OUTPUT_EXTENSION ".bar")

View File

@ -121,10 +121,6 @@ endif(NOT "${CMAKE_C_OUTPUT_EXTENSION}" STREQUAL ".foo")
# check the results from DetermineCXXCompiler
if(NOT "${_CMAKE_TOOLCHAIN_SUFFIX}" STREQUAL "arm")
message(FATAL_ERROR "wrong toolchain suffix detected: \"${_CMAKE_TOOLCHAIN_SUFFIX}\", expected: \"arm\"")
endif(NOT "${_CMAKE_TOOLCHAIN_SUFFIX}" STREQUAL "arm")
if(NOT "${_CMAKE_USER_CXX_COMPILER_PATH}" STREQUAL "/opt/bar/bin")
message(FATAL_ERROR "wrong CXX compiler location detected: \"${_CMAKE_USER_CXX_COMPILER_PATH}\", expected: \"/opt/bar/bin\"")
endif(NOT "${_CMAKE_USER_CXX_COMPILER_PATH}" STREQUAL "/opt/bar/bin")
@ -134,7 +130,6 @@ if(NOT "${CMAKE_CXX_OUTPUT_EXTENSION}" STREQUAL ".bar")
endif(NOT "${CMAKE_CXX_OUTPUT_EXTENSION}" STREQUAL ".bar")
message(STATUS "CMAKE_SYSTEM: \"${CMAKE_SYSTEM}\"")
message(STATUS "_CMAKE_TOOLCHAIN_SUFFIX: \"${_CMAKE_TOOLCHAIN_SUFFIX}\"")
message(STATUS "_CMAKE_TOOLCHAIN_PREFIX: \"${_CMAKE_TOOLCHAIN_PREFIX}\"")
message(STATUS "_CMAKE_USER_C_COMPILER_PATH: \"${_CMAKE_USER_C_COMPILER_PATH}\"")
message(STATUS "_CMAKE_USER_CXX_COMPILER_PATH: \"${_CMAKE_USER_CXX_COMPILER_PATH}\"")