ENH: also load a processor-specific file if exists

-also try the basename file if the compiler id file doesn't exist
-don't rely so much on the CMAKE_TOOLCHAIN_FILE

Alex
This commit is contained in:
Alexander Neundorf 2007-06-05 10:28:43 -04:00
parent 6989f80026
commit eab5a4350d
5 changed files with 89 additions and 46 deletions

View File

@ -35,15 +35,15 @@
/* IAR Systems compiler for embedded systems.
http://www.iar.com
Beside this id not supported yet by CMake */
Not supported yet by CMake
#elif defined(__IAR_SYSTEMS_ICC__)
# define COMPILER_ID "IAR"
# define COMPILER_ID "IAR" */
/* sdcc, the small devices C compiler for embedded systems,
http://sdcc.sourceforge.net
Beside this id not supported yet by CMake. */
Not supported yet by CMake.
#elif defined(SDCC)
# define COMPILER_ID "SDCC"
# define COMPILER_ID "SDCC" */
#elif defined(_COMPILER_VERSION)
# define COMPILER_ID "MIPSpro"

View File

@ -2,22 +2,39 @@
# This file sets the basic flags for the C language in CMake.
# It also loads the available platform file for the system-compiler
# if it exists.
# It also loads a system - compiler - processor (or target hardware)
# specific file, which is mainly useful for crosscompiling and embedded systems.
IF(NOT CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE)
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_BASE_NAME gcc)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_BASE_NAME gcc)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
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)
IF(EXISTS ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C.cmake)
SET(CMAKE_BASE_NAME ${CMAKE_C_COMPILER_ID}-C)
ENDIF(EXISTS ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C.cmake)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_C_COMPILER_ID)
SET(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
ENDIF(NOT CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE)
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)
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)
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)
INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE} OPTIONAL)
# This should be included before the _INIT variables are
# used to initialize the cache. Since the rule variables

View File

@ -2,23 +2,40 @@
# This file sets the basic flags for the C++ language in CMake.
# It also loads the available platform file for the system-compiler
# if it exists.
# It also loads a system - compiler - processor (or target hardware)
# specific file, which is mainly useful for crosscompiling and embedded systems.
IF(NOT CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER} NAME_WE)
# since the gnu compiler has several names force g++
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_BASE_NAME g++)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER} NAME_WE)
# since the gnu compiler has several names force g++
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_BASE_NAME g++)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
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)
IF(EXISTS ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX.cmake)
SET(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER_ID}-CXX)
ENDIF(EXISTS ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX.cmake)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
ENDIF(CMAKE_CXX_COMPILER_ID)
SET(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
ENDIF(NOT CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE)
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)
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)
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)
INCLUDE(${CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE} OPTIONAL)
# This should be included before the _INIT variables are
# used to initialize the cache. Since the rule variables

View File

@ -77,19 +77,25 @@ IF(CMAKE_TOOLCHAIN_FILE)
ELSE(_INCLUDED_TOOLCHAIN_FILE)
MESSAGE(FATAL_ERROR "Could not find toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
ENDIF(_INCLUDED_TOOLCHAIN_FILE)
ENDIF(CMAKE_TOOLCHAIN_FILE)
# if CMAKE_SYSTEM_NAME is here already set, either it comes from a toolchain file
# or it was set via -DCMAKE_SYSTEM_NAME=...
# if that's the case, assume we are crosscompiling
IF(CMAKE_SYSTEM_NAME)
IF(NOT DEFINED CMAKE_CROSSCOMPILING)
SET(CMAKE_CROSSCOMPILING TRUE)
ENDIF(NOT DEFINED CMAKE_CROSSCOMPILING)
ELSE(CMAKE_TOOLCHAIN_FILE)
SET(PRESET_CMAKE_SYSTEM_NAME TRUE)
ELSE(CMAKE_SYSTEM_NAME)
SET(CMAKE_SYSTEM_NAME "${CMAKE_HOST_SYSTEM_NAME}")
SET(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
SET(CMAKE_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
SET(CMAKE_CROSSCOMPILING FALSE)
SET(PRESET_CMAKE_SYSTEM_NAME FALSE)
ENDIF(CMAKE_SYSTEM_NAME)
ENDIF(CMAKE_TOOLCHAIN_FILE)
MACRO(ADJUST_CMAKE_SYSTEM_VARIABLES _PREFIX)
IF(NOT ${_PREFIX}_NAME)
@ -118,14 +124,22 @@ ENDMACRO(ADJUST_CMAKE_SYSTEM_VARIABLES _PREFIX)
ADJUST_CMAKE_SYSTEM_VARIABLES(CMAKE_SYSTEM)
ADJUST_CMAKE_SYSTEM_VARIABLES(CMAKE_HOST_SYSTEM)
# write entry to the log file
IF(PRESET_CMAKE_SYSTEM_NAME)
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The target system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The host system is: ${CMAKE_HOST_SYSTEM_NAME} - ${CMAKE_HOST_SYSTEM_VERSION} - ${CMAKE_HOST_SYSTEM_PROCESSOR}\n")
ELSE(PRESET_CMAKE_SYSTEM_NAME)
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n")
ENDIF(PRESET_CMAKE_SYSTEM_NAME)
# if a toolchain file is used use configure_file() to copy it into the
# build tree, because this way e.g. ${CMAKE_SOURCE_DIR} will be replaced
# with its full path, and so it will also work when used in try_compile()
IF (CMAKE_TOOLCHAIN_FILE)
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The target system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The host system is: ${CMAKE_HOST_SYSTEM_NAME} - ${CMAKE_HOST_SYSTEM_VERSION} - ${CMAKE_HOST_SYSTEM_PROCESSOR}\n")
SET(_OWN_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
CONFIGURE_FILE(${CMAKE_TOOLCHAIN_FILE}
@ -134,10 +148,7 @@ IF (CMAKE_TOOLCHAIN_FILE)
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeSystemWithToolchainFile.cmake.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake
IMMEDIATE @ONLY)
ELSE (CMAKE_TOOLCHAIN_FILE)
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"The system is: ${CMAKE_SYSTEM_NAME} - ${CMAKE_SYSTEM_VERSION} - ${CMAKE_SYSTEM_PROCESSOR}\n")
# configure variables set in this file for fast reload, the template file is defined at the top of this file
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeSystem.cmake.in

View File

@ -1,12 +1,10 @@
# the following file has been configured from @CMAKE_TOOLCHAIN_FILE@
INCLUDE(@_OWN_DIR@/CMakeToolchainFile.cmake)
# set CMAKE_SYSTEM to the CMAKE_SYSTEM_NAME
SET(CMAKE_SYSTEM ${CMAKE_SYSTEM_NAME})
# if there is a CMAKE_SYSTEM_VERSION then add a -${CMAKE_SYSTEM_VERSION}
IF(CMAKE_SYSTEM_VERSION)
SET(CMAKE_SYSTEM ${CMAKE_SYSTEM}-${CMAKE_SYSTEM_VERSION})
ENDIF(CMAKE_SYSTEM_VERSION)
SET(CMAKE_SYSTEM "@CMAKE_SYSTEM@")
SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@")
SET(CMAKE_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@")
SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@")
SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@")
SET(CMAKE_HOST_SYSTEM_NAME "@CMAKE_HOST_SYSTEM_NAME@")