diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeCCompiler.cmake.in | 7 | ||||
-rw-r--r-- | Modules/CMakeCInformation.cmake | 27 | ||||
-rw-r--r-- | Modules/CMakeCXXCompiler.cmake.in | 7 | ||||
-rw-r--r-- | Modules/CMakeCXXInformation.cmake | 30 | ||||
-rw-r--r-- | Modules/CMakeDetermineCCompiler.cmake | 86 | ||||
-rw-r--r-- | Modules/CMakeDetermineCXXCompiler.cmake | 75 | ||||
-rw-r--r-- | Modules/CMakeDetermineFortranCompiler.cmake | 11 | ||||
-rw-r--r-- | Modules/CMakeDetermineSystem.cmake | 79 | ||||
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 52 | ||||
-rw-r--r-- | Modules/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Modules/CMakeSystem.cmake.in | 24 | ||||
-rw-r--r-- | Modules/CMakeSystemSpecificInformation.cmake | 13 | ||||
-rw-r--r-- | Modules/CMakeTestCCompiler.cmake | 3 | ||||
-rw-r--r-- | Modules/CTest.cmake | 1 | ||||
-rw-r--r-- | Modules/CheckTypeSize.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-cl.cmake | 51 | ||||
-rw-r--r-- | Modules/Platform/cl.cmake | 53 |
17 files changed, 361 insertions, 162 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 16c7d69..abd5067 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -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@) diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 10ec1e7..5f73e6f 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -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 diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 5fafd66..c6f4740 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -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@) diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index ef1b07e..d966f12 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -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. diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index d80452f..0ee390b 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -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) + +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) -FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} ) +# 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") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 4ba152a..41b5e47 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -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) + +# 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_AR NAMES ar PATHS ${COMPILER_LOCATION}) -MARK_AS_ADVANCED(CMAKE_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) # 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) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 15f66f9..687bb8d 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -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") diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index e7559e2..3ad4a60 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -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") diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake new file mode 100644 index 0000000..48925bc --- /dev/null +++ b/Modules/CMakeFindBinUtils.cmake @@ -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 ? diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index be80179..c3b5903 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -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$) diff --git a/Modules/CMakeSystem.cmake.in b/Modules/CMakeSystem.cmake.in index ad921f6..0fbf387 100644 --- a/Modules/CMakeSystem.cmake.in +++ b/Modules/CMakeSystem.cmake.in @@ -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) diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 53905eb..b2c5671 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -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 diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 639baee..68c1640 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -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) diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 8663f41..9838bae 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -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 diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 2eb1224..9f43249 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -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) diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index 6c6cac2..658a1e3 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -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) diff --git a/Modules/Platform/cl.cmake b/Modules/Platform/cl.cmake new file mode 100644 index 0000000..9ab3b00 --- /dev/null +++ b/Modules/Platform/cl.cmake @@ -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}") + |