ENH: merge CMake-CrossCompileBasic to HEAD

-add a RESULT_VARIABLE to INCLUDE()
-add CMAKE_TOOLCHAIN_FILE for specifiying your (potentially crosscompiling) toolchain
-have TRY_RUN() complain if you try to use it in crosscompiling mode (which were compiled but cannot run on this system)
-use CMAKE_EXECUTABLE_SUFFIX in TRY_RUN(), probably TRY_RUN won't be able to
run the executables if they have a different suffix because they are
probably crosscompiled, but nevertheless it should be able to find them
-make several cmake variables presettable by the user: CMAKE_C/CXX_COMPILER, CMAKE_C/CXX_OUTPUT_EXTENSION, CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_INFO_FILE
-support prefix for GNU toolchains (arm-elf-gcc, arm-elf-ar, arm-elf-strip etc.)
-move ranlib on OSX from the file command to a command in executed in cmake_install.cmake
-add support for stripping during install in cmake_install.cmake
-split out cl.cmake from Windows-cl.cmake, first (very incomplete) step to support MS crosscompiling tools
-remove stdio.h from the simple C program which checks if the compiler works, since this may not exist for some embedded platforms
-create a new CMakeFindBinUtils.cmake which collects the search fro ar, ranlib, strip, ld, link, install_name_tool and other tools like these
-add support for CMAKE_FIND_ROOT_PATH for all FIND_XXX commands, which is a
list of directories which will be prepended to all search directories, right
now as a cmake variable, turning it into a global cmake property may need
some more work
-remove cmTestTestHandler::TryExecutable(), it's unused
-split cmFileCommand::HandleInstall() into slightly smaller functions

Alex
This commit is contained in:
Alexander Neundorf 2007-05-17 13:20:44 -04:00
parent 9bfe711ef1
commit 61d3444f93
38 changed files with 1352 additions and 740 deletions

View File

@ -22,11 +22,8 @@ SET(CMAKE_C_COMPILER_ID_RUN 1)
SET(CMAKE_C_SOURCE_FILE_EXTENSIONS c)
SET(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
SET(CMAKE_C_LINKER_PREFERENCE None)
IF(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION @CMAKE_C_OUTPUT_EXTENSION@)
# save the size of void* in case where cache is removed
# and the this file is still around
SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)

View File

@ -3,18 +3,21 @@
# It also loads the available platform file for the system-compiler
# if it exists.
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_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)
ENDIF(CMAKE_C_COMPILER_ID)
SET(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
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)
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)
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)
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

@ -22,11 +22,8 @@ SET(CMAKE_CXX_COMPILER_ID_RUN 1)
SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC)
SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm)
SET(CMAKE_CXX_LINKER_PREFERENCE Prefered)
IF(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION @CMAKE_CXX_OUTPUT_EXTENSION@)
# save the size of void* in case where cache is removed
# and the this file is still around
SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)

View File

@ -3,19 +3,23 @@
# It also loads the available platform file for the system-compiler
# if it exists.
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_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)
ENDIF(CMAKE_CXX_COMPILER_ID)
SET(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
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)
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)
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)
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
# have if blocks on them, users can still define them here.

View File

@ -2,9 +2,26 @@
# determine the compiler to use for C programs
# NOTE, a generator may set CMAKE_C_COMPILER before
# loading this file to force a compiler.
# use environment variable CCC first if defined by user, next use
# use environment variable CC first if defined by user, next use
# the cmake variable CMAKE_GENERATOR_CC which can be defined by a generator
# 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-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
# CMAKE_AR
# CMAKE_RANLIB
# CMAKE_COMPILER_IS_GNUCC
#
# 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)
@ -15,10 +32,9 @@ IF(NOT CMAKE_C_COMPILER)
IF(CMAKE_C_FLAGS_ENV_INIT)
SET(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler")
ENDIF(CMAKE_C_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_C_COMPILER_INIT})
ELSE(EXISTS ${CMAKE_C_COMPILER_INIT})
IF(NOT EXISTS ${CMAKE_C_COMPILER_INIT})
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.")
ENDIF(EXISTS ${CMAKE_C_COMPILER_INIT})
ENDIF(NOT EXISTS ${CMAKE_C_COMPILER_INIT})
ENDIF($ENV{CC} MATCHES ".+")
# next try prefer the compiler specified by the generator
@ -32,26 +48,64 @@ 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 gcc cc cl bcc xlc)
SET(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl${_CMAKE_TOOLCHAIN_SUFFIX} bcc xlc)
ENDIF(CMAKE_C_COMPILER_INIT)
# Find the compiler.
IF (_CMAKE_USER_CXX_COMPILER_PATH)
FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} PATHS ${_CMAKE_USER_CXX_COMPILER_PATH} DOC "C compiler" NO_DEFAULT_PATH)
ENDIF (_CMAKE_USER_CXX_COMPILER_PATH)
FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} DOC "C compiler")
IF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER)
SET(CMAKE_C_COMPILER "${CMAKE_C_COMPILER_INIT}" CACHE FILEPATH "C compiler" FORCE)
ENDIF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER)
ELSE(NOT CMAKE_C_COMPILER)
# if a compiler was specified by the user but without path,
# now try to find it with the full path and force it into the cache
GET_FILENAME_COMPONENT(_CMAKE_USER_C_COMPILER_PATH "${CMAKE_C_COMPILER}" PATH)
IF(NOT _CMAKE_USER_C_COMPILER_PATH)
FIND_PROGRAM(CMAKE_C_COMPILER_WITH_PATH NAMES ${CMAKE_C_COMPILER})
MARK_AS_ADVANCED(CMAKE_C_COMPILER_WITH_PATH)
SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_WITH_PATH} CACHE FILEPATH "C compiler" FORCE)
ENDIF(NOT _CMAKE_USER_C_COMPILER_PATH)
ENDIF(NOT CMAKE_C_COMPILER)
MARK_AS_ADVANCED(CMAKE_C_COMPILER)
GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_C_COMPILER}"
PATH)
MARK_AS_ADVANCED(CMAKE_C_COMPILER)
FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} )
IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
# if we have a gcc cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc
# the other tools of the toolchain usually have the same prefix
IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME_WE)
IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc")
STRING(REGEX REPLACE "^(.+-)g?cc" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
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.
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)
# some exotic compilers have different extensions (e.g. sdcc uses .rel)
# so don't overwrite it if it has been already defined by the user
IF(NOT CMAKE_C_OUTPUT_EXTENSION)
IF(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)
ENDIF(NOT CMAKE_C_OUTPUT_EXTENSION)
FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib)
IF(NOT CMAKE_RANLIB)
SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
ENDIF(NOT CMAKE_RANLIB)
MARK_AS_ADVANCED(CMAKE_RANLIB)
# Build a small source file to identify the compiler.
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
@ -62,6 +116,7 @@ IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
# the user may be using an integrated Intel compiler.
# SET(CMAKE_C_COMPILER_ID "MSVC")
ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
IF(NOT CMAKE_C_COMPILER_ID_RUN)
SET(CMAKE_C_COMPILER_ID_RUN 1)
@ -81,9 +136,10 @@ IF(NOT CMAKE_C_COMPILER_ID_RUN)
ENDIF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
ENDIF(NOT CMAKE_C_COMPILER_ID_RUN)
INCLUDE(CMakeFindBinUtils)
# configure variables set in this file for fast reload later on
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in
"${CMAKE_PLATFORM_ROOT_BIN}/CMakeCCompiler.cmake" IMMEDIATE)
MARK_AS_ADVANCED(CMAKE_AR)
SET(CMAKE_C_COMPILER_ENV_VAR "CC")

View File

@ -5,13 +5,21 @@
# use environment variable CXX first if defined by user, next use
# the cmake variable CMAKE_GENERATOR_CXX which can be defined by a generator
# 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
# CMAKE_COMPILER_IS_GNUCXX
# CMAKE_AR
# CMAKE_RANLIB
#
# 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)
@ -22,10 +30,9 @@ IF(NOT CMAKE_CXX_COMPILER)
IF(CMAKE_CXX_FLAGS_ENV_INIT)
SET(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler")
ENDIF(CMAKE_CXX_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT})
IF(NOT EXISTS ${CMAKE_CXX_COMPILER_INIT})
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}")
ENDIF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
ENDIF(NOT EXISTS ${CMAKE_CXX_COMPILER_INIT})
ENDIF($ENV{CXX} MATCHES ".+")
# next prefer the generator specified compiler
@ -39,27 +46,65 @@ 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 c++ g++ CC aCC cl bcc xlC)
SET(CMAKE_CXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl${_CMAKE_TOOLCHAIN_SUFFIX} bcc xlC)
ENDIF(CMAKE_CXX_COMPILER_INIT)
# Find the compiler.
IF (_CMAKE_USER_C_COMPILER_PATH)
FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} PATHS ${_CMAKE_USER_C_COMPILER_PATH} DOC "C++ compiler" NO_DEFAULT_PATH)
ENDIF (_CMAKE_USER_C_COMPILER_PATH)
FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} DOC "C++ compiler")
IF(CMAKE_CXX_COMPILER_INIT AND NOT CMAKE_CXX_COMPILER)
SET(CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER_INIT}" CACHE FILEPATH "C++ compiler" FORCE)
ENDIF(CMAKE_CXX_COMPILER_INIT AND NOT CMAKE_CXX_COMPILER)
ELSE(NOT CMAKE_CXX_COMPILER)
# if a compiler was specified by the user but without path,
# now try to find it with the full path and force it into the cache
GET_FILENAME_COMPONENT(_CMAKE_USER_CXX_COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH)
IF(NOT _CMAKE_USER_CXX_COMPILER_PATH)
FIND_PROGRAM(CMAKE_CXX_COMPILER_WITH_PATH NAMES ${CMAKE_CXX_COMPILER})
MARK_AS_ADVANCED(CMAKE_CXX_COMPILER_WITH_PATH)
SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_WITH_PATH} CACHE FILEPATH "CXX compiler" FORCE)
ENDIF(NOT _CMAKE_USER_CXX_COMPILER_PATH)
ENDIF(NOT CMAKE_CXX_COMPILER)
MARK_AS_ADVANCED(CMAKE_CXX_COMPILER)
GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION})
MARK_AS_ADVANCED(CMAKE_AR)
# if we have a g++ cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++
# the other tools of the toolchain usually have the same prefix
IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME_WE)
IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+")
STRING(REGEX REPLACE "^(.+-)[gc]\\+\\+" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
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)
# some exotic compilers have different extensions (e.g. sdcc uses .rel)
# so don't overwrite it if it has been already defined by the user
IF(NOT CMAKE_CXX_OUTPUT_EXTENSION)
IF(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)
ENDIF(NOT CMAKE_CXX_OUTPUT_EXTENSION)
FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib)
IF(NOT CMAKE_RANLIB)
SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
ENDIF(NOT CMAKE_RANLIB)
MARK_AS_ADVANCED(CMAKE_RANLIB)
# This block was used before the compiler was identified by building a
# source file. Unless g++ crashes when building a small C++
@ -101,6 +146,8 @@ IF(NOT CMAKE_CXX_COMPILER_ID_RUN)
ENDIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW")
ENDIF(NOT CMAKE_CXX_COMPILER_ID_RUN)
INCLUDE(CMakeFindBinUtils)
# configure all variables set in this file
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake IMMEDIATE)

View File

@ -66,14 +66,6 @@ ENDIF(NOT CMAKE_Fortran_COMPILER)
MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER)
FIND_PROGRAM(CMAKE_AR NAMES ar )
FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib)
IF(NOT CMAKE_RANLIB)
SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
ENDIF(NOT CMAKE_RANLIB)
MARK_AS_ADVANCED(CMAKE_RANLIB)
# Build a small source file to identify the compiler.
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
SET(CMAKE_Fortran_COMPILER_ID_RUN 1)
@ -130,8 +122,9 @@ IF(NOT CMAKE_Fortran_COMPILER_ID_RUN)
ENDIF("${CMAKE_Fortran_PLATFORM_ID}" MATCHES "MinGW")
ENDIF(NOT CMAKE_Fortran_COMPILER_ID_RUN)
INCLUDE(CMakeFindBinUtils)
# configure variables set in this file for fast reload later on
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake IMMEDIATE)
MARK_AS_ADVANCED(CMAKE_AR)
SET(CMAKE_Fortran_COMPILER_ENV_VAR "FC")

View File

@ -25,37 +25,60 @@
# Ultrix ULTRIX
# cygwin CYGWIN_NT-5.1
# MacOSX Darwin
IF(UNIX)
FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
IF(CMAKE_UNAME)
EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_SYSTEM_NAME)
EXEC_PROGRAM(uname ARGS -r OUTPUT_VARIABLE CMAKE_SYSTEM_VERSION)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
IF("${val}" GREATER 0)
IF(CMAKE_TOOLCHAIN_FILE)
# at first try to load it as path relative to the directory from which cmake has been run
INCLUDE("${CMAKE_BINARY_DIR}/${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
IF(NOT _INCLUDED_TOOLCHAIN_FILE)
# if the file isn't found there, check the default locations
INCLUDE("${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
ENDIF(NOT _INCLUDED_TOOLCHAIN_FILE)
IF(_INCLUDED_TOOLCHAIN_FILE)
SET(CMAKE_TOOLCHAIN_FILE "${_INCLUDED_TOOLCHAIN_FILE}")
ELSE(_INCLUDED_TOOLCHAIN_FILE)
MESSAGE(FATAL_ERROR "Could not find toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
ENDIF(_INCLUDED_TOOLCHAIN_FILE)
IF(NOT DEFINED CMAKE_CROSSCOMPILING)
SET(CMAKE_CROSSCOMPILING TRUE)
ENDIF(NOT DEFINED CMAKE_CROSSCOMPILING)
ENDIF(CMAKE_TOOLCHAIN_FILE)
IF(NOT CMAKE_SYSTEM_NAME)
IF(UNIX)
FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
IF(CMAKE_UNAME)
EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_SYSTEM_NAME)
EXEC_PROGRAM(uname ARGS -r OUTPUT_VARIABLE CMAKE_SYSTEM_VERSION)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
IF("${val}" GREATER 0)
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
ENDIF("${val}" GREATER 0)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# check the return of the last uname -m or -p
IF("${val}" GREATER 0)
SET(CMAKE_SYSTEM_PROCESSOR "unknown")
ENDIF("${val}" GREATER 0)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# check the return of the last uname -m or -p
IF("${val}" GREATER 0)
SET(CMAKE_SYSTEM_PROCESSOR "unknown")
ENDIF("${val}" GREATER 0)
SET(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
# processor may have double quote in the name, and that needs to be removed
STRING(REGEX REPLACE "\"" "" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
STRING(REGEX REPLACE "/" "_" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
ENDIF(CMAKE_UNAME)
ELSE(UNIX)
IF(WIN32)
SET (CMAKE_SYSTEM_NAME "Windows")
SET (CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
ENDIF(WIN32)
ENDIF(UNIX)
SET(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
# processor may have double quote in the name, and that needs to be removed
STRING(REGEX REPLACE "\"" "" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
STRING(REGEX REPLACE "/" "_" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
ENDIF(CMAKE_UNAME)
ELSE(UNIX)
IF(WIN32)
SET (CMAKE_SYSTEM_NAME "Windows")
SET (CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
ENDIF(WIN32)
ENDIF(UNIX)
ENDIF(NOT CMAKE_SYSTEM_NAME)
IF(NOT CMAKE_SYSTEM_NAME)
SET(CMAKE_SYSTEM_NAME "UnknownOS")

View File

@ -0,0 +1,52 @@
# search for additional tools required for C/C++ (and other languages ?)
#
# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used
# as prefix for the tools (e.g. arm-elf-gcc etc.)
# If the cmake variable _CMAKE_TOOLCHAIN_LOCATION is set, the compiler is
# searched only there. The other tools are at first searched there, then
# also in the default locations.
#
# Sets the following variables:
# CMAKE_AR
# CMAKE_RANLIB
# CMAKE_LINKER
# CMAKE_STRIP
# CMAKE_INSTALL_NAME_TOOL
# on UNIX, cygwin and mingw
IF(UNIX OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar)
FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib)
IF(NOT CMAKE_RANLIB)
SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
ENDIF(NOT CMAKE_RANLIB)
FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip)
FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld)
MARK_AS_ADVANCED(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER)
ENDIF(UNIX OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
IF(APPLE)
FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool)
MARK_AS_ADVANCED(CMAKE_INSTALL_NAME_TOOL)
ENDIF(APPLE)
IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
FIND_PROGRAM(CMAKE_LINKER NAMES link PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH)
FIND_PROGRAM(CMAKE_LINKER NAMES link)
MARK_AS_ADVANCED(CMAKE_LINKER)
ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
# maybe check for more tools ?

View File

@ -1,4 +1,6 @@
# just install the modules
# new file added, force rerunning cmake
SUBDIRS(Platform)
INSTALL_FILES(${CMAKE_DATA_DIR}/Modules .*\\.cmake$)
INSTALL_FILES(${CMAKE_DATA_DIR}/Modules .*\\.cpp$)

View File

@ -1,5 +1,21 @@
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@")
IF("@CMAKE_TOOLCHAIN_FILE@" STREQUAL "")
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@")
ELSE("@CMAKE_TOOLCHAIN_FILE@" STREQUAL "")
INCLUDE("@CMAKE_TOOLCHAIN_FILE@")
# 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)
ENDIF("@CMAKE_TOOLCHAIN_FILE@" STREQUAL "")
SET(CMAKE_SYSTEM_LOADED 1)

View File

@ -7,10 +7,13 @@
INCLUDE(CMakeGenericSystem)
# 2. now include SystemName.cmake file to set the system specific information
SET(CMAKE_SYSTEM_INFO_FILE ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}.cmake)
IF(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
ELSE(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
IF(NOT CMAKE_SYSTEM_INFO_FILE)
SET(CMAKE_SYSTEM_INFO_FILE Platform/${CMAKE_SYSTEM_NAME})
ENDIF(NOT CMAKE_SYSTEM_INFO_FILE)
INCLUDE(${CMAKE_SYSTEM_INFO_FILE} OPTIONAL RESULT_VARIABLE _INCLUDED_SYSTEM_INFO_FILE)
IF(NOT _INCLUDED_SYSTEM_INFO_FILE)
MESSAGE("System is unknown to cmake, create:\n${CMAKE_SYSTEM_INFO_FILE}"
" to use this system, please send your config file to "
"cmake@www.cmake.org so it can be added to cmake")
@ -20,7 +23,7 @@ ELSE(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
MESSAGE("You CMakeCache.txt file was copied to CopyOfCMakeCache.txt. "
"Please send that file to cmake@www.cmake.org.")
ENDIF(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
ENDIF(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
ENDIF(NOT _INCLUDED_SYSTEM_INFO_FILE)
# for most systems a module is the same as a shared library

View File

@ -10,7 +10,6 @@ IF(NOT CMAKE_C_COMPILER_WORKS)
"#ifdef __cplusplus\n"
"# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n"
"#endif\n"
"#include <stdio.h>\n"
"#if defined(__CLASSIC_C__)\n"
"int main(argc, argv)\n"
" int argc;\n"
@ -18,7 +17,7 @@ IF(NOT CMAKE_C_COMPILER_WORKS)
"#else\n"
"int main(int argc, char* argv[])\n"
"#endif\n"
"{ printf(\"%s\\n\", argv[0]); return argc-1;}\n")
"{ return argc-1;}\n")
TRY_COMPILE(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
OUTPUT_VARIABLE OUTPUT)

View File

@ -46,6 +46,7 @@ IF(BUILD_TESTING)
SET_IF_SET_AND_NOT_SET(DROP_SITE_MODE "${CTEST_DROP_SITE_MODE}")
SET_IF_SET_AND_NOT_SET(DROP_LOCATION "${CTEST_DROP_LOCATION}")
SET_IF_SET_AND_NOT_SET(TRIGGER_SITE "${CTEST_TRIGGER_SITE}")
SET_IF_SET_AND_NOT_SET(UPDATE_TYPE "${CTEST_UPDATE_TYPE}")
ENDIF(EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
# the project can have a DartConfig.cmake file

View File

@ -13,6 +13,7 @@
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
MACRO(CHECK_TYPE_SIZE TYPE VARIABLE)
IF(NOT DEFINED ${VARIABLE})
SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1)
IF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
SET(CHECK_TYPE_SIZE_TYPE "${TYPE}")
@ -65,4 +66,5 @@ MACRO(CHECK_TYPE_SIZE TYPE VARIABLE)
ENDIF(HAVE_${VARIABLE})
ENDIF("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$")
SET(CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS )
ENDIF(NOT DEFINED ${VARIABLE})
ENDMACRO(CHECK_TYPE_SIZE)

View File

@ -3,58 +3,9 @@ INCLUDE( ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake OPTIONAL)
# try to load any previously computed information for CXX on this platform
INCLUDE( ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake OPTIONAL)
SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:")
SET(CMAKE_LINK_LIBRARY_FLAG "")
SET(WIN32 1)
SET(MSVC 1)
IF(CMAKE_VERBOSE_MAKEFILE)
SET(CMAKE_CL_NOLOGO)
ELSE(CMAKE_VERBOSE_MAKEFILE)
SET(CMAKE_CL_NOLOGO "/nologo")
ENDIF(CMAKE_VERBOSE_MAKEFILE)
# create a shared C++ library
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
"link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
# create a C shared library
SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
# create a C shared module
SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
# create a C++ static library
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "link /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
# create a C static library
SET(CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_CXX_CREATE_STATIC_LIBRARY}")
# compile a C++ file into an object file
SET(CMAKE_CXX_COMPILE_OBJECT
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
# compile a C file into an object file
SET(CMAKE_C_COMPILE_OBJECT
"<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> /Fd<TARGET_PDB> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> /Fd<TARGET_PDB> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_CREATE_PREPROCESSED_SOURCE
"<CMAKE_C_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> -E <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
"<CMAKE_CXX_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP -E <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_CREATE_ASSEMBLY_SOURCE
"<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /FAs /FoNUL /Fa<ASSEMBLY_SOURCE> /c <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP /FAs /FoNUL /Fa<ASSEMBLY_SOURCE> /c <SOURCE>${CMAKE_END_TEMP_FILE}")
INCLUDE(Platform/cl)
SET(CMAKE_CREATE_WIN32_EXE /subsystem:windows)
SET(CMAKE_CREATE_CONSOLE_EXE /subsystem:console)

53
Modules/Platform/cl.cmake Normal file
View File

@ -0,0 +1,53 @@
SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:")
SET(CMAKE_LINK_LIBRARY_FLAG "")
SET(MSVC 1)
IF(CMAKE_VERBOSE_MAKEFILE)
SET(CMAKE_CL_NOLOGO)
ELSE(CMAKE_VERBOSE_MAKEFILE)
SET(CMAKE_CL_NOLOGO "/nologo")
ENDIF(CMAKE_VERBOSE_MAKEFILE)
# create a shared C++ library
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
"${CMAKE_LINKER} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
# create a C shared library
SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
# create a C shared module
SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
# create a C++ static library
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "${CMAKE_LINKER} /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
# create a C static library
SET(CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_CXX_CREATE_STATIC_LIBRARY}")
# compile a C++ file into an object file
SET(CMAKE_CXX_COMPILE_OBJECT
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
# compile a C file into an object file
SET(CMAKE_C_COMPILE_OBJECT
"<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> /Fd<TARGET_PDB> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> /Fd<TARGET_PDB> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_CREATE_PREPROCESSED_SOURCE
"<CMAKE_C_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> -E <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
"<CMAKE_CXX_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP -E <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_C_CREATE_ASSEMBLY_SOURCE
"<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /FAs /FoNUL /Fa<ASSEMBLY_SOURCE> /c <SOURCE>${CMAKE_END_TEMP_FILE}")
SET(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /TP /FAs /FoNUL /Fa<ASSEMBLY_SOURCE> /c <SOURCE>${CMAKE_END_TEMP_FILE}")

View File

@ -213,51 +213,6 @@ bool cmCTestSetTestsPropertiesCommand::InitialPass(
return this->TestHandler->SetTestsProperties(args);
}
//----------------------------------------------------------------------
// Try to find an executable, if found fullPath will be set to the full path
// of where it was found. The directory and filename to search for are passed
// in as well an a subdir (typically used for configuraitons such as
// Release/Debug/etc)
bool cmCTestTestHandler::TryExecutable(const char *dir,
const char *file,
std::string *fullPath,
const char *subdir)
{
// try current directory
std::string tryPath;
if (dir && strcmp(dir,""))
{
tryPath = dir;
tryPath += "/";
}
if (subdir && strcmp(subdir,""))
{
tryPath += subdir;
tryPath += "/";
}
tryPath += file;
// find the file without an executable extension
if(cmSystemTools::FileExists(tryPath.c_str()))
{
*fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
return true;
}
// if not found try it with the executable extension
tryPath += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(tryPath.c_str()))
{
*fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
return true;
}
// not found at all, return false
return false;
}
//----------------------------------------------------------------------
// get the next number in a string with numbers separated by ,
// pos is the start of the search and pos2 is the end of the search

View File

@ -103,11 +103,6 @@ public:
cmCTestTestProperties* Properties;
};
// useful function for looking for a test
static bool TryExecutable(const char *dir, const char *file,
std::string *fullPath,
const char *subdir);
// add configuraitons to a search path for an executable
static void AddConfigurations(cmCTest *ctest,
std::vector<std::string> &attempted,

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@
#include "cmCommand.h"
struct cmFileInstaller;
/** \class cmFileCommand
* \brief Command for manipulation of files
*
@ -146,11 +148,45 @@ protected:
bool HandleStringsCommand(std::vector<std::string> const& args);
bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse);
bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);
bool HandleInstallCommand(std::vector<std::string> const& args);
bool HandleRelativePathCommand(std::vector<std::string> const& args);
bool HandleCMakePathCommand(std::vector<std::string> const& args,
bool nativePath);
void ComputeVersionedName(std::string& name, const char* version);
// FILE(INSTALL ...) related functions
bool HandleInstallCommand(std::vector<std::string> const& args);
bool ParseInstallArgs(std::vector<std::string> const& args,
cmFileInstaller& installer,
std::set<cmStdString>& components,
std::set<cmStdString>& configurations,
std::map<cmStdString, const char*>& properties,
int& itype,
std::string& destination,
std::string& rename,
std::vector<std::string>& files,
bool& optional
);
bool DoInstall(cmFileInstaller& installer,
const std::set<cmStdString>& components,
const std::set<cmStdString>& configurations,
std::map<cmStdString, const char*>& properties,
const int itype,
const std::string& rename,
const std::string& destination,
const std::vector<std::string>& files,
const bool optional
);
void GetTargetTypeFromString(const std::string& stype, int& itype) const;
bool HandleInstallDestination(cmFileInstaller& installer,
std::string& destination);
void HandleInstallPermissions(cmFileInstaller& installer,
mode_t& permissions_file,
mode_t& permissions_dir,
int itype,
bool use_given_permissions_file,
bool use_given_permissions_dir,
bool use_source_permissions) const;
};

View File

@ -25,6 +25,7 @@ cmFindBase::cmFindBase()
this->NoCMakeEnvironmentPath = false;
this->NoSystemEnvironmentPath = false;
this->NoCMakeSystemPath = false;
this->FindRootPathMode = RootPathModeBoth;
// default is to search frameworks first on apple
#if defined(__APPLE__)
this->SearchFrameworkFirst = true;
@ -250,6 +251,24 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
return true;
}
this->AlreadyInCache = false;
std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
findRootPathVar += this->CMakePathName;
std::string rootPathMode = this->Makefile->GetSafeDefinition(findRootPathVar.c_str());
if (rootPathMode=="NEVER")
{
this->FindRootPathMode = RootPathModeNoRootPath;
}
else if (rootPathMode=="ONLY")
{
this->FindRootPathMode = RootPathModeOnlyRootPath;
}
else if (rootPathMode=="BOTH")
{
this->FindRootPathMode = RootPathModeBoth;
}
std::vector<std::string> userPaths;
std::string doc;
bool doingNames = true; // assume it starts with a name
@ -328,6 +347,21 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
doingNames = false;
this->NoCMakeSystemPath = true;
}
else if (args[j] == "NO_CMAKE_FIND_ROOT_PATH")
{
compatibility = false;
this->FindRootPathMode = RootPathModeNoRootPath;
}
else if (args[j] == "ONLY_CMAKE_FIND_ROOT_PATH")
{
compatibility = false;
this->FindRootPathMode = RootPathModeOnlyRootPath;
}
else if (args[j] == "CMAKE_FIND_ROOT_PATH_BOTH")
{
compatibility = false;
this->FindRootPathMode = RootPathModeBoth;
}
else
{
if(doingNames)
@ -358,7 +392,7 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
if(this->VariableDocumentation.size() == 0)
{
this->VariableDocumentation = "Whare can ";
this->VariableDocumentation = "Where can ";
if(this->Names.size() == 0)
{
this->VariableDocumentation += "the (unknown) library be found";
@ -392,6 +426,8 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
}
}
this->ExpandPaths(userPaths);
this->HandleCMakeFindRootPath();
return true;
}
@ -413,7 +449,7 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
{
// Add CMAKE_*_PATH environment variables
this->AddEnvironmentVairables();
this->AddEnvironmentVariables();
}
if(!this->NoCMakePath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
@ -421,13 +457,13 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
// Add CMake varibles of the same name as the previous environment
// varibles CMAKE_*_PATH to be used most of the time with -D
// command line options
this->AddCMakeVairables();
this->AddCMakeVariables();
}
if(!this->NoSystemEnvironmentPath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
{
// add System environment PATH and (LIB or INCLUDE)
this->AddSystemEnvironmentVairables();
this->AddSystemEnvironmentVariables();
}
if(!this->NoCMakeSystemPath &&
!(this->SearchFrameworkOnly || this->SearchAppBundleOnly))
@ -453,7 +489,46 @@ void cmFindBase::ExpandPaths(std::vector<std::string> userPaths)
this->AddPaths(paths);
}
void cmFindBase::AddEnvironmentVairables()
void cmFindBase::HandleCMakeFindRootPath()
{
if (this->FindRootPathMode == RootPathModeNoRootPath)
{
return;
}
const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH");
if ((rootPath == 0) || (strlen(rootPath) == 0))
{
return;
}
std::vector<std::string> prefixes;
cmSystemTools::ExpandListArgument(rootPath, prefixes);
std::vector<std::string> unprefixedPaths=this->SearchPaths;
this->SearchPaths.clear();
for (std::vector<std::string>::const_iterator prefixIt = prefixes.begin();
prefixIt != prefixes.end();
++prefixIt )
{
for (std::vector<std::string>::const_iterator it = unprefixedPaths.begin();
it != unprefixedPaths.end();
++it )
{
std::string prefixedDir=*prefixIt;
prefixedDir+=*it;
this->SearchPaths.push_back(prefixedDir);
}
}
if (this->FindRootPathMode == RootPathModeBoth)
{
this->AddPaths(unprefixedPaths);
}
}
void cmFindBase::AddEnvironmentVariables()
{
std::string var = "CMAKE_";
var += this->CMakePathName;
@ -547,7 +622,7 @@ void cmFindBase::AddAppBundlePaths()
this->AddPaths(paths);
}
void cmFindBase::AddCMakeVairables()
void cmFindBase::AddCMakeVariables()
{
std::string var = "CMAKE_";
var += this->CMakePathName;
@ -576,7 +651,7 @@ void cmFindBase::AddCMakeVairables()
this->AddPaths(paths);
}
void cmFindBase::AddSystemEnvironmentVairables()
void cmFindBase::AddSystemEnvironmentVariables()
{
// Add LIB or INCLUDE
std::vector<std::string> paths;

View File

@ -39,16 +39,20 @@ public:
virtual const char* GetFullDocumentation()
{return this->GenericDocumentation.c_str();}
enum RootPathMode { RootPathModeBoth, RootPathModeOnlyRootPath, RootPathModeNoRootPath };
protected:
void PrintFindStuff();
void ExpandPaths(std::vector<std::string> userPaths);
void HandleCMakeFindRootPath();
// add to the SearchPaths
void AddPaths(std::vector<std::string>& paths);
void AddFrameWorkPaths();
void AddAppBundlePaths();
void AddEnvironmentVairables();
void AddCMakeVairables();
void AddSystemEnvironmentVairables();
void AddEnvironmentVariables();
void AddCMakeVariables();
void AddSystemEnvironmentVariables();
void AddCMakeSystemVariables();
void ExpandRegistryAndCleanPath(std::vector<std::string>& paths);
// see if the VariableName is already set in the cache,
@ -75,6 +79,7 @@ protected:
bool NoCMakeEnvironmentPath;
bool NoSystemEnvironmentPath;
bool NoCMakeSystemPath;
RootPathMode FindRootPathMode;
bool SearchFrameworkFirst;
bool SearchFrameworkOnly;

View File

@ -20,21 +20,55 @@
// cmIncludeCommand
bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args)
{
if (args.size()< 1 || args.size() > 2)
if (args.size()< 1 || args.size() > 4)
{
this->SetError("called with wrong number of arguments. "
"Include only takes one file.");
return false;
}
bool optional = false;
std::string fname = args[0].c_str();
if(args.size() == 2)
{
optional = args[1] == "OPTIONAL";
}
std::string fname = args[0];
std::string resultVarName;
for (unsigned int i=1; i<args.size(); i++)
{
if (args[i] == "OPTIONAL")
{
if (optional)
{
this->SetError("called with invalid arguments: OPTIONAL used twice");
return false;
}
optional = true;
}
else if(args[i] == "RESULT_VARIABLE")
{
if (resultVarName.size() > 0)
{
this->SetError("called with invalid arguments: "
"only one result variable allowed");
return false;
}
if(++i < args.size())
{
resultVarName = args[i];
}
else
{
this->SetError("called with no value for RESULT_VARIABLE.");
return false;
}
}
else if(i > 1) // compat.: in previous cmake versions the second
// parameter was ignore if it wasn't "OPTIONAL"
{
std::string errorText = "called with invalid argument: ";
errorText += args[i];
this->SetError(errorText.c_str());
return false;
}
}
if(!cmSystemTools::FileIsFullPath(fname.c_str()))
{
// Not a path. Maybe module.
@ -46,9 +80,18 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args)
fname = mfile.c_str();
}
}
std::string fullFilePath;
bool readit =
this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),
fname.c_str() );
fname.c_str(), &fullFilePath );
// add the location of the included file if a result variable was given
if (resultVarName.size())
{
this->Makefile->AddDefinition(resultVarName.c_str(),
readit?fullFilePath.c_str():"NOTFOUND");
}
if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured())
{
std::string m = "Could not find include file: ";

View File

@ -68,12 +68,14 @@ public:
virtual const char* GetFullDocumentation()
{
return
" INCLUDE(file1 [OPTIONAL])\n"
" INCLUDE(module [OPTIONAL])\n"
" INCLUDE(file1 [OPTIONAL] [RESULT_VARIABLE <VAR>])\n"
" INCLUDE(module [OPTIONAL] [RESULT_VARIABLE <VAR>])\n"
"Reads CMake listfile code from the given file. Commands in the file "
"are processed immediately as if they were written in place of the "
"INCLUDE command. If OPTIONAL is present, then no error "
"is raised if the file does not exist.\n"
"is raised if the file does not exist. If RESULT_VARIABLE is given "
"the variable will be set to the full filename which "
"has been included or NOTFOUND if it failed.\n"
"If a module is specified instead of a file, the file with name "
"<modulename>.cmake is searched in the CMAKE_MODULE_PATH.";
}

View File

@ -19,7 +19,6 @@
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmTarget.h"
#include "cmake.h"
//----------------------------------------------------------------------------
@ -171,12 +170,21 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
no_rename, literal_args.c_str());
// Fix the install_name settings in installed binaries.
if(type == cmTarget::SHARED_LIBRARY ||
if((type == cmTarget::SHARED_LIBRARY ||
type == cmTarget::MODULE_LIBRARY ||
type == cmTarget::EXECUTABLE)
type == cmTarget::EXECUTABLE) &&
this->Target->GetMakefile()->IsSet("CMAKE_INSTALL_NAME_TOOL"))
{
this->AddInstallNamePatchRule(os, destination.c_str());
}
std::string destinationFilename = destination;
destinationFilename += "/";
destinationFilename += cmSystemTools::GetFilenameName(fromFile);
this->AddRanlibRule(os, type, destinationFilename);
this->AddStripRule(os, destinationFilename);
}
//----------------------------------------------------------------------------
@ -417,7 +425,9 @@ void cmInstallTargetGenerator
component_test += this->Component;
component_test += ")$\"";
os << "IF(" << component_test << ")\n";
os << " EXECUTE_PROCESS(COMMAND install_name_tool";
os << " EXECUTE_PROCESS(COMMAND \"";
os <<this->Target->GetMakefile()->GetDefinition("CMAKE_INSTALL_NAME_TOOL");
os << "\"";
if(!new_id.empty())
{
os << "\n -id \"" << new_id << "\"";
@ -433,3 +443,54 @@ void cmInstallTargetGenerator
os << "ENDIF(" << component_test << ")\n";
}
}
void cmInstallTargetGenerator::AddStripRule(std::ostream& os,
const std::string& destinationFilename)
{
// Don't handle OSX Bundles.
if(this->Target->GetMakefile()->IsOn("APPLE") &&
this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
{
return;
}
if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
{
return;
}
os << "IF(CMAKE_INSTALL_DO_STRIP)\n";
os << " EXECUTE_PROCESS(COMMAND \"";
os << this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP");
os << "\" \"$ENV{DESTDIR}" << destinationFilename << "\" )\n";
os << "ENDIF(CMAKE_INSTALL_DO_STRIP)\n";
}
void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
cmTarget::TargetType type,
const std::string& destinationFilename)
{
// Static libraries need ranlib on this platform.
if(type != cmTarget::STATIC_LIBRARY)
{
return;
}
// Perform post-installation processing on the file depending
// on its type.
if(!this->Target->GetMakefile()->IsOn("APPLE"))
{
return;
}
std::string ranlib = this->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
if (!ranlib.size())
{
return;
}
os << "EXECUTE_PROCESS(COMMAND \"";
os << ranlib;
os << "\" \"$ENV{DESTDIR}" << destinationFilename << "\" )\n";
}

View File

@ -18,8 +18,7 @@
#define cmInstallTargetGenerator_h
#include "cmInstallGenerator.h"
class cmTarget;
#include "cmTarget.h"
/** \class cmInstallTargetGenerator
* \brief Generate target installation rules.
@ -45,6 +44,10 @@ protected:
std::string GetScriptReference(cmTarget* target, const char* place,
bool useSOName);
void AddInstallNamePatchRule(std::ostream& os, const char* destination);
void AddStripRule(std::ostream& os, const std::string& destinationFilename);
void AddRanlibRule(std::ostream& os, cmTarget::TargetType type,
const std::string& destinationFilename);
cmTarget* Target;
std::string Destination;
bool ImportLibrary;

View File

@ -370,7 +370,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff)
// Parse the given CMakeLists.txt file executing all commands
//
bool cmMakefile::ReadListFile(const char* filename_in,
const char *external_in)
const char *external_in,
std::string* fullPath)
{
std::string currentParentFile
= this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
@ -446,12 +447,19 @@ bool cmMakefile::ReadListFile(const char* filename_in,
// push the listfile onto the stack
this->ListFileStack.push_back(filenametoread);
if(fullPath!=0)
{
*fullPath=filenametoread;
}
cmListFile cacheFile;
if( !cacheFile.ParseFile(filenametoread, requireProjectCommand) )
{
// pop the listfile off the stack
this->ListFileStack.pop_back();
if(fullPath!=0)
{
fullPath->clear();
}
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
return false;

View File

@ -72,7 +72,9 @@ public:
/**
* Read and parse a CMakeLists.txt file.
*/
bool ReadListFile(const char* listfile, const char* external= 0);
bool ReadListFile(const char* listfile,
const char* external= 0,
std::string* fullPath= 0);
/**
* Add a function blocker to this makefile

View File

@ -18,13 +18,20 @@
#include "cmCacheManager.h"
#include "cmTryCompileCommand.h"
// cmExecutableCommand
// cmTryRunCommand
bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
{
if(argv.size() < 4)
{
return false;
}
if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))
{
this->SetError("doesn't work when crosscompiling.");
cmSystemTools::SetFatalErrorOccured();
return false;
}
// build an arg list for TryCompile and extract the runArgs
std::vector<std::string> tryCompile;
@ -75,10 +82,11 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
{
int retVal = -1;
std::string output;
std::string executableSuffix=this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
std::string command1 = binaryDirectory;
std::vector<std::string> attemptedPaths;
command1 += "/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
command1 += executableSuffix;
std::string fullPath;
if(cmSystemTools::FileExists(command1.c_str()))
{
@ -97,7 +105,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
command1 += "/";
command1 += config;
command1 += "/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
command1 += executableSuffix;
if(cmSystemTools::FileExists(command1.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command1.c_str());
@ -110,7 +118,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
{
command1 = binaryDirectory;
command1 += "/Debug/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
command1 += executableSuffix;
if(cmSystemTools::FileExists(command1.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command1.c_str());
@ -122,7 +130,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
{
command1 = binaryDirectory;
command1 += "/Development/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
command1 += executableSuffix;
if(cmSystemTools::FileExists(command1.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command1.c_str());

View File

@ -88,7 +88,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args)
// Construct the cache entry for the executable's location.
std::string utilityExecutable =
utilityDirectory+"/"+cmakeCFGout+"/"
+utilityName+cmSystemTools::GetExecutableExtension();
+utilityName+this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
// make sure we remove any /./ in the name
cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");

View File

@ -72,7 +72,14 @@ public:
"is assumed that the source tree of the utility will have been built "
"before it is needed.";
}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged()
{
return true;
}
cmTypeMacro(cmUtilitySourceCommand, cmCommand);
};

View File

@ -9,3 +9,6 @@ ENDMACRO(AddCMakeTest)
AddCMakeTest(List "")
AddCMakeTest(VariableWatch "")
AddCMakeTest(Include "")
AddCMakeTest(FindBase "")
AddCMakeTest(Toolchain "")

View File

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Dumdidum)
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_OUTPUT_EXTENSION ".bar")

View File

@ -0,0 +1,44 @@
set(MY_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
set(_HEADER cmake_i_do_not_exist_in_the_system.h)
set(_HEADER_FULL "${MY_SOURCE_DIR}/include/${_HEADER}")
# at first check that the header isn't found without special measures
find_file(FOO_H_1 ${_HEADER})
if(FOO_H_1)
message(FATAL_ERROR "${_HEADER} found: ${FOO_H_1}, it should not exist !")
endif(FOO_H_1)
# with this it still should not be found, since the include/ subdir is still missing
set(CMAKE_INCLUDE_PATH "${MY_SOURCE_DIR}")
find_file(FOO_H_2 ${_HEADER})
if(FOO_H_2)
message(FATAL_ERROR "${_HEADER} found: ${FOO_H_2}, it should not exist !")
endif(FOO_H_2)
# now with the PATH_SUFFIX it should be found
find_file(FOO_H_3 NAMES ${_HEADER} PATH_SUFFIXES include )
if(NOT "${FOO_H_3}" STREQUAL "${_HEADER_FULL}")
message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_3} instead !")
endif(NOT "${FOO_H_3}" STREQUAL "${_HEADER_FULL}")
# without PATH_SUFFIX, but with a CMAKE_INCLUDE_PATH it should not be found
set(CMAKE_INCLUDE_PATH /include)
find_file(FOO_H_4 ${_HEADER})
if(FOO_H_4)
message(FATAL_ERROR "${_HEADER} found: ${FOO_H_4}, it should not exist !")
endif(FOO_H_4)
# when setting CMAKE_FIND_ROOT_PATH to the current source dir,
# together with the CMAKE_INCLUDE_PATH it should be found
set(CMAKE_FIND_ROOT_PATH blub "${MY_SOURCE_DIR}")
find_file(FOO_H_5 ${_HEADER})
if(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}")
message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_5} instead !")
endif(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}")
# by explicitely disabling CMAKE_FIND_ROOT_PATH again it shouldn't be found
find_file(FOO_H_6 ${_HEADER} NO_CMAKE_FIND_ROOT_PATH)
if(FOO_H_6)
message(FATAL_ERROR "${_HEADER} found: ${FOO_H_6}, it should not exist !")
endif(FOO_H_6)

View File

@ -0,0 +1,22 @@
# this one must silently fail
include(I_am_not_here OPTIONAL)
# this one must be found and the result must be put into _includedFile
include(CMake RESULT_VARIABLE _includedFile)
if(NOT "${_includedFile}" STREQUAL "${CMAKE_ROOT}/Modules/CMake.cmake")
message(FATAL_ERROR "Wrong CMake.cmake was included: \"${_includedFile}\"")
endif(NOT "${_includedFile}" STREQUAL "${CMAKE_ROOT}/Modules/CMake.cmake")
# this one must return NOTFOUND in _includedFile
include(I_do_not_exist OPTIONAL RESULT_VARIABLE _includedFile)
if(_includedFile)
message(FATAL_ERROR "File \"I_do_not_exist\" was included, although it shouldn't exist,\nIncluded file is \"${_includedFile}\"")
endif(_includedFile)
# and this one must succeed too
include(CMake OPTIONAL RESULT_VARIABLE _includedFile)
if(NOT "${_includedFile}" STREQUAL "${CMAKE_ROOT}/Modules/CMake.cmake")
message(FATAL_ERROR "Wrong CMake.cmake was included: \"${_includedFile}\"")
endif(NOT "${_includedFile}" STREQUAL "${CMAKE_ROOT}/Modules/CMake.cmake")

View File

@ -0,0 +1,83 @@
############################################################
# some preparations so that the CMakeDetermineXXX.cmake files will work in scripted mode
# overwrite MARK_AS_ADVANCED(), since this is used in CMakeDetermineCCompiler.cmake
# which will complain that it can"t be used in script mode
macro(MARK_AS_ADVANCED)
endmacro(MARK_AS_ADVANCED)
# set this to a place where we are allowed to write
set(CMAKE_PLATFORM_ROOT_BIN "${CMAKE_CURRENT_BINARY_DIR}")
# don't run the compiler detection
set(CMAKE_C_COMPILER_ID_RUN 1)
set(CMAKE_CXX_COMPILER_ID_RUN 1)
set(MY_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
############################################################
# now define a toolchain file and check that everything is
# detected correctly and nothing predefined is overwritten
set(CMAKE_TOOLCHAIN_FILE "${MY_SOURCE_DIR}/DummyToolchain.cmake")
include(CMakeDetermineSystem)
include(CMakeDetermineCCompiler)
include(CMakeDetermineCXXCompiler)
#############################################################
# check the results from DetermineSystem
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Dumdidum")
message(FATAL_ERROR "CMAKE_SYSTEM_NAME overwritten: \"${CMAKE_SYSTEM_NAME}\", was: \"Dumdidum\"")
endif(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Dumdidum")
if(NOT "${CMAKE_SYSTEM}" STREQUAL "Dumdidum-1.0")
message(FATAL_ERROR "CMAKE_SYSTEM wrong: \"${CMAKE_SYSTEM}\", expected: \"Dumdidum-1.0\"")
endif(NOT "${CMAKE_SYSTEM}" STREQUAL "Dumdidum-1.0")
if(NOT "${_INCLUDED_TOOLCHAIN_FILE}" STREQUAL "${MY_SOURCE_DIR}/DummyToolchain.cmake")
message(FATAL_ERROR "wrong toolchain file loaded: \"${_INCLUDED_TOOLCHAIN_FILE}\", expected: \"${MY_SOURCE_DIR}/DummyToolchain.cmake\"")
endif(NOT "${_INCLUDED_TOOLCHAIN_FILE}" STREQUAL "${MY_SOURCE_DIR}/DummyToolchain.cmake")
#############################################################
# check the results from DetermineCCompiler
if(NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "arm-elf-")
message(FATAL_ERROR "wrong toolchain prefix detected: \"${_CMAKE_TOOLCHAIN_PREFIX}\", expected: \"arm-elf-\"")
endif(NOT "${_CMAKE_TOOLCHAIN_PREFIX}" STREQUAL "arm-elf-")
if(NOT "${_CMAKE_USER_C_COMPILER_PATH}" STREQUAL "/opt/foo/bin")
message(FATAL_ERROR "wrong C compiler location detected: \"${_CMAKE_USER_C_COMPILER_PATH}\", expected: \"/opt/foo/bin\"")
endif(NOT "${_CMAKE_USER_C_COMPILER_PATH}" STREQUAL "/opt/foo/bin")
if(NOT "${CMAKE_C_OUTPUT_EXTENSION}" STREQUAL ".foo")
message(FATAL_ERROR "C output extension overwritten: \"${CMAKE_C_OUTPUT_EXTENSION}\", was: \".foo\"")
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")
if(NOT "${CMAKE_CXX_OUTPUT_EXTENSION}" STREQUAL ".bar")
message(FATAL_ERROR "C output extension overwritten: \"${CMAKE_CXX_OUTPUT_EXTENSION}\", was: \".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}\"")
message(STATUS "CMAKE_C_OUTPUT_EXTENSION: \"${CMAKE_C_OUTPUT_EXTENSION}\"")
message(STATUS "CMAKE_CXX_OUTPUT_EXTENSION: \"${CMAKE_CXX_OUTPUT_EXTENSION}\"")

View File

@ -0,0 +1 @@
/* empty header file */