diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-09-19 16:33:11 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2012-09-19 16:33:11 (GMT) |
commit | 9d8e59db71833dce7133bac48e461e388223eb51 (patch) | |
tree | ffe24aaf87035587dfb8b8f2d3c9edb0a7b1f42d /Modules | |
parent | ea12871241e1a943be75e7c987f71f54ec3f3908 (diff) | |
parent | 6674583caa20244d90aa14a67d059e7228a9f169 (diff) | |
download | CMake-9d8e59db71833dce7133bac48e461e388223eb51.zip CMake-9d8e59db71833dce7133bac48e461e388223eb51.tar.gz CMake-9d8e59db71833dce7133bac48e461e388223eb51.tar.bz2 |
Merge branch 'use-generator-target' into AutomocUseTargetProperties
Diffstat (limited to 'Modules')
59 files changed, 1564 insertions, 872 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index b4eabe5..17d63eb 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -9,6 +9,8 @@ set(CMAKE_RANLIB "@CMAKE_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) set(CMAKE_C_COMPILER_LOADED 1) +set(CMAKE_C_COMPILER_WORKS @CMAKE_C_COMPILER_WORKS@) +set(CMAKE_C_ABI_COMPILED @CMAKE_C_ABI_COMPILED@) set(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) set(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) if(CMAKE_COMPILER_IS_CYGWIN) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 06aa9bf..c5bde9a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -67,6 +67,10 @@ #elif defined(__DECC) # define COMPILER_ID "Compaq" + /* __DECC_VER = VVRRTPPPP */ +# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) +# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) +# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) #elif defined(__IBMC__) # if defined(__COMPILER_VER__) @@ -91,14 +95,25 @@ # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) # endif -#elif defined(__PATHSCALE__) +#elif defined(__PATHCC__) # define COMPILER_ID "PathScale" +# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) +# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) +# endif #elif defined(_CRAYC) # define COMPILER_ID "Cray" +# define COMPILER_VERSION_MAJOR DEC(_RELEASE) +# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) +# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) +# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) #elif defined(__TINYC__) # define COMPILER_ID "TinyCC" @@ -132,9 +147,16 @@ # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) # endif +/* Analog VisualDSP++ >= 4.5.6 */ +#elif defined(__VISUALDSPVERSION__) +# define COMPILER_ID "ADSP" + /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ +# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) +# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) + +/* Analog VisualDSP++ < 4.5.6 */ #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) -/* Analog Devices C++ compiler for Blackfin, TigerSHARC and - SHARC (21000) DSPs */ # define COMPILER_ID "ADSP" /* IAR Systems compiler for embedded systems. @@ -147,6 +169,10 @@ http://sdcc.sourceforge.net */ #elif defined(SDCC) # define COMPILER_ID "SDCC" + /* SDCC = VRP */ +# define COMPILER_VERSION_MAJOR DEC(SDCC/100) +# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) +# define COMPILER_VERSION_PATCH DEC(SDCC % 10) #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) # define COMPILER_ID "MIPSpro" diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index b6477df..7f66be5 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -9,6 +9,8 @@ set(CMAKE_RANLIB "@CMAKE_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) set(CMAKE_CXX_COMPILER_LOADED 1) +set(CMAKE_CXX_COMPILER_WORKS @CMAKE_CXX_COMPILER_WORKS@) +set(CMAKE_CXX_ABI_COMPILED @CMAKE_CXX_ABI_COMPILED@) set(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) set(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) if(CMAKE_COMPILER_IS_CYGWIN) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 95fc852..2c8dd4b 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -10,6 +10,9 @@ #if defined(__COMO__) # define COMPILER_ID "Comeau" + /* __COMO_VERSION__ = VRR */ +# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) +# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) #elif defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" @@ -69,6 +72,10 @@ #elif defined(__DECCXX) # define COMPILER_ID "Compaq" + /* __DECCXX_VER = VVRRTPPPP */ +# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) +# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) +# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) #elif defined(__IBMCPP__) # if defined(__COMPILER_VER__) @@ -93,14 +100,25 @@ # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) # endif -#elif defined(__PATHSCALE__) +#elif defined(__PATHCC__) # define COMPILER_ID "PathScale" +# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) +# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) +# endif #elif defined(_CRAYC) # define COMPILER_ID "Cray" +# define COMPILER_VERSION_MAJOR DEC(_RELEASE) +# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) +# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) +# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) #elif defined(__SCO_VERSION__) # define COMPILER_ID "SCO" @@ -131,9 +149,16 @@ # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) # endif +/* Analog VisualDSP++ >= 4.5.6 */ +#elif defined(__VISUALDSPVERSION__) +# define COMPILER_ID "ADSP" + /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ +# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) +# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) + +/* Analog VisualDSP++ < 4.5.6 */ #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) -/* Analog Devices C++ compiler for Blackfin, TigerSHARC and - SHARC (21000) DSPs */ # define COMPILER_ID "ADSP" #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) diff --git a/Modules/CMakeClDeps.cmake b/Modules/CMakeClDeps.cmake index b52641c..0214ead 100644 --- a/Modules/CMakeClDeps.cmake +++ b/Modules/CMakeClDeps.cmake @@ -26,12 +26,9 @@ if(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPIL file(WRITE ${showdir}/foo.h "\n") file(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n") execute_process(COMMAND ${CMAKE_C_COMPILER} /nologo /showIncludes ${showdir}/main.c - WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE showOut) - string(REPLACE main.c "" showOut1 ${showOut}) - string(REPLACE "/" "\\" header1 ${showdir}/foo.h) - string(TOLOWER ${header1} header2) - string(REPLACE ${header2} "" showOut2 ${showOut1}) - string(REPLACE "\n" "" showOut3 ${showOut2}) + WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE outLine) + string(REGEX MATCH "\n([^:]*:[^:]*:[ \t]*)" tmp "${outLine}") + set(localizedPrefix "${CMAKE_MATCH_1}") set(SET_CMAKE_CMCLDEPS_EXECUTABLE "set(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")") - set(SET_CMAKE_CL_SHOWINCLUDE_PREFIX "set(CMAKE_CL_SHOWINCLUDE_PREFIX \"${showOut3}\")") + set(SET_CMAKE_CL_SHOWINCLUDE_PREFIX "set(CMAKE_CL_SHOWINCLUDE_PREFIX \"${localizedPrefix}\")") endif() diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 4cf29dd..9f0b30a 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -163,7 +163,7 @@ set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY) set(_CMAKE_ASM_COMPILER) set(_CMAKE_ASM_COMPILER_ARG1) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 16e2f53..275fc47 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -39,76 +39,66 @@ if(NOT CMAKE_C_COMPILER_NAMES) set(CMAKE_C_COMPILER_NAMES cc) endif() -if(NOT CMAKE_C_COMPILER) - set(CMAKE_C_COMPILER_INIT NOTFOUND) - - # prefer the environment variable CC - if($ENV{CC} MATCHES ".+") - get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) - if(CMAKE_C_FLAGS_ENV_INIT) - set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") +elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(CMAKE_C_COMPILER_XCODE_TYPE sourcecode.c.c) +else() + if(NOT CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER_INIT NOTFOUND) + + # prefer the environment variable CC + if($ENV{CC} MATCHES ".+") + get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) + if(CMAKE_C_FLAGS_ENV_INIT) + set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") + endif() + if(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") + endif() endif() - if(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) - message(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") + + # next try prefer the compiler specified by the generator + if(CMAKE_GENERATOR_CC) + if(NOT CMAKE_C_COMPILER_INIT) + set(CMAKE_C_COMPILER_INIT ${CMAKE_GENERATOR_CC}) + endif() endif() - endif() - # next try prefer the compiler specified by the generator - if(CMAKE_GENERATOR_CC) + # finally list compilers to try if(NOT CMAKE_C_COMPILER_INIT) - set(CMAKE_C_COMPILER_INIT ${CMAKE_GENERATOR_CC}) + set(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}cc ${_CMAKE_TOOLCHAIN_PREFIX}gcc cl bcc xlc clang) endif() - endif() - - # finally list compilers to try - if(NOT CMAKE_C_COMPILER_INIT) - set(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}cc ${_CMAKE_TOOLCHAIN_PREFIX}gcc cl bcc xlc clang) - endif() - _cmake_find_compiler(C) + _cmake_find_compiler(C) -else() + else() - # we only get here if CMAKE_C_COMPILER was specified using -D or a pre-made CMakeCache.txt - # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_C_COMPILER is a list of length 2, use the first item as - # CMAKE_C_COMPILER and the 2nd one as CMAKE_C_COMPILER_ARG1 + # we only get here if CMAKE_C_COMPILER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # if CMAKE_C_COMPILER is a list of length 2, use the first item as + # CMAKE_C_COMPILER and the 2nd one as CMAKE_C_COMPILER_ARG1 - list(LENGTH CMAKE_C_COMPILER _CMAKE_C_COMPILER_LIST_LENGTH) - if("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_C_COMPILER 1 CMAKE_C_COMPILER_ARG1) - list(GET CMAKE_C_COMPILER 0 CMAKE_C_COMPILER) - endif() + list(LENGTH CMAKE_C_COMPILER _CMAKE_C_COMPILER_LIST_LENGTH) + if("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2) + list(GET CMAKE_C_COMPILER 1 CMAKE_C_COMPILER_ARG1) + list(GET CMAKE_C_COMPILER 0 CMAKE_C_COMPILER) + endif() - # if a compiler was specified by the user but without path, - # now try to find it with the full path - # if it is found, force it into the cache, - # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" - # if the C compiler already had a path, reuse it for searching the CXX compiler - 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) - if(CMAKE_C_COMPILER_WITH_PATH) - set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_WITH_PATH} CACHE STRING "C compiler" FORCE) + # if a compiler was specified by the user but without path, + # now try to find it with the full path + # if it is found, force it into the cache, + # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" + # if the C compiler already had a path, reuse it for searching the CXX compiler + 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) + if(CMAKE_C_COMPILER_WITH_PATH) + set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_WITH_PATH} CACHE STRING "C compiler" FORCE) + endif() endif() endif() -endif() -mark_as_advanced(CMAKE_C_COMPILER) - -if (NOT _CMAKE_TOOLCHAIN_LOCATION) - get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) -endif () - -# Build a small source file to identify the compiler. -if(${CMAKE_GENERATOR} MATCHES "Visual Studio") - set(CMAKE_C_COMPILER_ID_RUN 1) - set(CMAKE_C_PLATFORM_ID "Windows") - set(CMAKE_C_COMPILER_ID "MSVC") -endif() - -if(NOT CMAKE_C_COMPILER_ID_RUN) - set(CMAKE_C_COMPILER_ID_RUN 1) + mark_as_advanced(CMAKE_C_COMPILER) # Each entry in this list is a set of extra flags to try # adding to the compile line to see if it helps produce @@ -120,6 +110,11 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) # Try enabling ANSI mode on HP. "-Aa" ) +endif() + +# Build a small source file to identify the compiler. +if(NOT CMAKE_C_COMPILER_ID_RUN) + set(CMAKE_C_COMPILER_ID_RUN 1) # Try to identify the compiler. set(CMAKE_C_COMPILER_ID) @@ -139,6 +134,10 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) endif() endif() +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) +endif () + # 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, optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). @@ -170,7 +169,7 @@ if(MSVC_C_ARCHITECTURE_ID) endif() # 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" + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 ) set(CMAKE_C_COMPILER_ENV_VAR "CC") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 8e4d59f..59da3e6 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -38,87 +38,66 @@ if(NOT CMAKE_CXX_COMPILER_NAMES) set(CMAKE_CXX_COMPILER_NAMES CC) endif() -if(NOT CMAKE_CXX_COMPILER) - set(CMAKE_CXX_COMPILER_INIT NOTFOUND) - - # prefer the environment variable CXX - if($ENV{CXX} MATCHES ".+") - get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) - if(CMAKE_CXX_FLAGS_ENV_INIT) - set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") +elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(CMAKE_CXX_COMPILER_XCODE_TYPE sourcecode.cpp.cpp) +else() + if(NOT CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER_INIT NOTFOUND) + + # prefer the environment variable CXX + if($ENV{CXX} MATCHES ".+") + get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) + if(CMAKE_CXX_FLAGS_ENV_INIT) + set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + endif() + 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() endif() - 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}") + + # next prefer the generator specified compiler + if(CMAKE_GENERATOR_CXX) + if(NOT CMAKE_CXX_COMPILER_INIT) + set(CMAKE_CXX_COMPILER_INIT ${CMAKE_GENERATOR_CXX}) + endif() endif() - endif() - # next prefer the generator specified compiler - if(CMAKE_GENERATOR_CXX) + # finally list compilers to try if(NOT CMAKE_CXX_COMPILER_INIT) - set(CMAKE_CXX_COMPILER_INIT ${CMAKE_GENERATOR_CXX}) + set(CMAKE_CXX_COMPILER_LIST CC ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ aCC cl bcc xlC clang++) endif() - endif() - # finally list compilers to try - if(NOT CMAKE_CXX_COMPILER_INIT) - set(CMAKE_CXX_COMPILER_LIST CC ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ aCC cl bcc xlC clang++) - endif() - - _cmake_find_compiler(CXX) -else() + _cmake_find_compiler(CXX) + else() -# we only get here if CMAKE_CXX_COMPILER was specified using -D or a pre-made CMakeCache.txt -# (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE -# -# if CMAKE_CXX_COMPILER is a list of length 2, use the first item as -# CMAKE_CXX_COMPILER and the 2nd one as CMAKE_CXX_COMPILER_ARG1 + # we only get here if CMAKE_CXX_COMPILER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # + # if CMAKE_CXX_COMPILER is a list of length 2, use the first item as + # CMAKE_CXX_COMPILER and the 2nd one as CMAKE_CXX_COMPILER_ARG1 - list(LENGTH CMAKE_CXX_COMPILER _CMAKE_CXX_COMPILER_LIST_LENGTH) - if("${_CMAKE_CXX_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_CXX_COMPILER 1 CMAKE_CXX_COMPILER_ARG1) - list(GET CMAKE_CXX_COMPILER 0 CMAKE_CXX_COMPILER) - endif() + list(LENGTH CMAKE_CXX_COMPILER _CMAKE_CXX_COMPILER_LIST_LENGTH) + if("${_CMAKE_CXX_COMPILER_LIST_LENGTH}" EQUAL 2) + list(GET CMAKE_CXX_COMPILER 1 CMAKE_CXX_COMPILER_ARG1) + list(GET CMAKE_CXX_COMPILER 0 CMAKE_CXX_COMPILER) + endif() -# if a compiler was specified by the user but without path, -# now try to find it with the full path -# if it is found, force it into the cache, -# if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" -# if the CXX compiler already had a path, reuse it for searching the C compiler - 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) - if(CMAKE_CXX_COMPILER_WITH_PATH) - set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_WITH_PATH} CACHE STRING "CXX compiler" FORCE) + # if a compiler was specified by the user but without path, + # now try to find it with the full path + # if it is found, force it into the cache, + # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" + # if the CXX compiler already had a path, reuse it for searching the C compiler + 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) + if(CMAKE_CXX_COMPILER_WITH_PATH) + set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_WITH_PATH} CACHE STRING "CXX compiler" FORCE) + endif() endif() endif() -endif() -mark_as_advanced(CMAKE_CXX_COMPILER) - -if (NOT _CMAKE_TOOLCHAIN_LOCATION) - get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) -endif () - -# This block was used before the compiler was identified by building a -# source file. Unless g++ crashes when building a small C++ -# executable this should no longer be needed. -# -# The g++ that comes with BeOS 5 segfaults if you run "g++ -E" -# ("gcc -E" is fine), which throws up a system dialog box that hangs cmake -# until the user clicks "OK"...so for now, we just assume it's g++. -# if(BEOS) -# set(CMAKE_COMPILER_IS_GNUCXX 1) -# set(CMAKE_COMPILER_IS_GNUCXX_RUN 1) -# endif() - -# Build a small source file to identify the compiler. -if(${CMAKE_GENERATOR} MATCHES "Visual Studio") - set(CMAKE_CXX_COMPILER_ID_RUN 1) - set(CMAKE_CXX_PLATFORM_ID "Windows") - set(CMAKE_CXX_COMPILER_ID "MSVC") -endif() -if(NOT CMAKE_CXX_COMPILER_ID_RUN) - set(CMAKE_CXX_COMPILER_ID_RUN 1) + mark_as_advanced(CMAKE_CXX_COMPILER) # Each entry in this list is a set of extra flags to try # adding to the compile line to see if it helps produce @@ -127,6 +106,11 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) # Try compiling to an object file only. "-c" ) +endif() + +# Build a small source file to identify the compiler. +if(NOT CMAKE_CXX_COMPILER_ID_RUN) + set(CMAKE_CXX_COMPILER_ID_RUN 1) # Try to identify the compiler. set(CMAKE_CXX_COMPILER_ID) @@ -146,6 +130,10 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) endif() endif() +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) +endif () + # 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++ , optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). @@ -177,7 +165,7 @@ if(MSVC_CXX_ARCHITECTURE_ID) endif() # configure all variables set in this file configure_file(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 ) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index ae2eb9b..75247d9 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -19,16 +19,16 @@ include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) function(CMAKE_DETERMINE_COMPILER_ABI lang src) - if(NOT DEFINED CMAKE_DETERMINE_${lang}_ABI_COMPILED) + if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED) message(STATUS "Detecting ${lang} compiler ABI info") # Compile the ABI identification source. - set(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDetermineCompilerABI_${lang}.bin") + set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_${lang}.bin") set(CMAKE_FLAGS ) if(DEFINED CMAKE_${lang}_VERBOSE_FLAG) set(CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}") endif() - try_compile(CMAKE_DETERMINE_${lang}_ABI_COMPILED + try_compile(CMAKE_${lang}_ABI_COMPILED ${CMAKE_BINARY_DIR} ${src} CMAKE_FLAGS "${CMAKE_FLAGS}" "-DCMAKE_${lang}_STANDARD_LIBRARIES=" @@ -39,9 +39,13 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) OUTPUT_VARIABLE OUTPUT COPY_FILE "${BIN}" ) + # Move result from cache to normal variable. + set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED}) + unset(CMAKE_${lang}_ABI_COMPILED CACHE) + set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED} PARENT_SCOPE) # Load the resulting information strings. - if(CMAKE_DETERMINE_${lang}_ABI_COMPILED) + if(CMAKE_${lang}_ABI_COMPILED) message(STATUS "Detecting ${lang} compiler ABI info - done") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f574978..3df17c7 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -30,7 +30,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) string(REGEX REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") # Compute the directory in which to run the test. - set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CompilerId${lang}) + set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang}) # Try building with no extra flags and then try each set # of helper flags. Stop when the compiler is identified. @@ -66,6 +66,15 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) message(STATUS "The ${lang} compiler identification is unknown") endif() + # Check if compiler id detection gave us the compiler tool. + if(NOT CMAKE_${lang}_COMPILER) + if(CMAKE_${lang}_COMPILER_ID_TOOL) + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE) + else() + set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE) + endif() + endif() + set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" @@ -98,28 +107,126 @@ Id flags: ${testflags} ") # Compile the compiler identification source. - if(COMMAND EXECUTE_PROCESS) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)( .NET)?( 200[358])? *((Win64|IA64|ARM))?") + set(vs_version ${CMAKE_MATCH_1}) + set(vs_arch ${CMAKE_MATCH_4}) + set(id_lang "${lang}") + set(id_cl cl.exe) + if(NOT "${vs_version}" VERSION_LESS 10) + set(v 10) + set(ext vcxproj) + elseif(NOT "${vs_version}" VERSION_LESS 7) + set(id_version ${vs_version}.00) + set(v 7) + set(ext vcproj) + else() + set(v 6) + set(ext dsp) + endif() + if("${vs_arch}" STREQUAL "Win64") + set(id_machine_7 17) + set(id_machine_10 MachineX64) + set(id_arch x64) + elseif("${vs_arch}" STREQUAL "IA64") + set(id_machine_7 5) + set(id_machine_10 MachineIA64) + set(id_arch ia64) + else() + set(id_machine_6 x86) + set(id_machine_7 1) + set(id_machine_10 MachineX86) + set(id_arch Win32) + endif() + if(CMAKE_VS_PLATFORM_TOOLSET) + set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>") + else() + set(id_toolset "") + endif() + if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]") + set(build /p:Configuration=Debug /p:Platform=@id_arch@) + elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]") + set(build /make) + else() + set(build /build Debug) + endif() + set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) + get_filename_component(id_src "${src}" NAME) + configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in + ${id_dir}/CompilerId${lang}.${ext} @ONLY IMMEDIATE) execute_process( - COMMAND ${CMAKE_${lang}_COMPILER} - ${CMAKE_${lang}_COMPILER_ID_ARG1} - ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} - ${testflags} - "${src}" + COMMAND ${CMAKE_MAKE_PROGRAM} CompilerId${lang}.${ext} ${build} WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT ) - else() - exec_program( - ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_DIR} - ARGS ${CMAKE_${lang}_COMPILER_ID_ARG1} - ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} - ${testflags} - \"${src}\" + # Match the compiler location line printed out. + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CMAKE_${lang}_COMPILER=([^%\r\n]+)[\r\n]") + set(_comp "${CMAKE_MATCH_1}") + if(EXISTS "${_comp}") + file(TO_CMAKE_PATH "${_comp}" _comp) + set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) + endif() + endif() + elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(id_lang "${lang}") + set(id_type ${CMAKE_${lang}_COMPILER_XCODE_TYPE}) + set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR}) + get_filename_component(id_src "${src}" NAME) + if(NOT ${XCODE_VERSION} VERSION_LESS 3) + set(v 3) + set(ext xcodeproj) + elseif(NOT ${XCODE_VERSION} VERSION_LESS 2) + set(v 2) + set(ext xcodeproj) + else() + set(v 1) + set(ext xcode) + endif() + configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in + ${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY IMMEDIATE) + execute_process(COMMAND xcodebuild + WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT - RETURN_VALUE CMAKE_${lang}_COMPILER_ID_RESULT + ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT ) + + # Match the link line from xcodebuild output of the form + # Ld ... + # ... + # /path/to/cc ...CompilerId${lang}/... + # to extract the compiler front-end for the language. + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/\\./CompilerId${lang}[ \t\n\\\"]") + set(_comp "${CMAKE_MATCH_2}") + if(EXISTS "${_comp}") + set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) + endif() + endif() + else() + if(COMMAND EXECUTE_PROCESS) + execute_process( + COMMAND ${CMAKE_${lang}_COMPILER} + ${CMAKE_${lang}_COMPILER_ID_ARG1} + ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} + ${testflags} + "${src}" + WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT + ) + else() + exec_program( + ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_DIR} + ARGS ${CMAKE_${lang}_COMPILER_ID_ARG1} + ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} + ${testflags} + \"${src}\" + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RETURN_VALUE CMAKE_${lang}_COMPILER_ID_RESULT + ) + endif() endif() # Check the result of compilation. @@ -153,14 +260,18 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT} # Find the executable produced by the compiler, try all files in the # binary dir. - file(GLOB COMPILER_${lang}_PRODUCED_FILES + file(GLOB files RELATIVE ${CMAKE_${lang}_COMPILER_ID_DIR} ${CMAKE_${lang}_COMPILER_ID_DIR}/*) - list(REMOVE_ITEM COMPILER_${lang}_PRODUCED_FILES "${src}") - foreach(file ${COMPILER_${lang}_PRODUCED_FILES}) - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Compilation of the ${lang} compiler identification source \"" - "${src}\" produced \"${file}\"\n\n") + list(REMOVE_ITEM files "${src}") + set(COMPILER_${lang}_PRODUCED_FILES "") + foreach(file ${files}) + if(NOT IS_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}/${file}) + list(APPEND COMPILER_${lang}_PRODUCED_FILES ${file}) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Compilation of the ${lang} compiler identification source \"" + "${src}\" produced \"${file}\"\n\n") + endif() endforeach() if(NOT COMPILER_${lang}_PRODUCED_FILES) @@ -282,7 +393,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) # We get here when this function is called not from within CMAKE_DETERMINE_COMPILER_ID() # This is done e.g. for detecting the compiler ID for assemblers. # Compute the directory in which to run the test and Create a clean working directory. - set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CompilerId${lang}) + set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang}) file(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR}) file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) endif() diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index da77e21..f861e39 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -25,105 +25,102 @@ if(NOT CMAKE_Fortran_COMPILER_NAMES) set(CMAKE_Fortran_COMPILER_NAMES f95) endif() -if(NOT CMAKE_Fortran_COMPILER) - # prefer the environment variable CC - if($ENV{FC} MATCHES ".+") - get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) - if(CMAKE_Fortran_FLAGS_ENV_INIT) - set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + set(CMAKE_Fortran_COMPILER_ID_RUN 1) + set(CMAKE_Fortran_PLATFORM_ID "Windows") + set(CMAKE_Fortran_COMPILER_ID "Intel") + set(CMAKE_Fortran_COMPILER "${CMAKE_GENERATOR_FC}") +elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(CMAKE_Fortran_COMPILER_XCODE_TYPE sourcecode.fortran.f90) +else() + if(NOT CMAKE_Fortran_COMPILER) + # prefer the environment variable CC + if($ENV{FC} MATCHES ".+") + get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) + if(CMAKE_Fortran_FLAGS_ENV_INIT) + set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") + endif() + if(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) + else() + message(FATAL_ERROR "Could not find compiler set in environment variable FC:\n$ENV{FC}.") + endif() endif() - if(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) - else() - message(FATAL_ERROR "Could not find compiler set in environment variable FC:\n$ENV{FC}.") + + # next try prefer the compiler specified by the generator + if(CMAKE_GENERATOR_FC) + if(NOT CMAKE_Fortran_COMPILER_INIT) + set(CMAKE_Fortran_COMPILER_INIT ${CMAKE_GENERATOR_FC}) + endif() endif() - endif() - # next try prefer the compiler specified by the generator - if(CMAKE_GENERATOR_FC) + # finally list compilers to try if(NOT CMAKE_Fortran_COMPILER_INIT) - set(CMAKE_Fortran_COMPILER_INIT ${CMAKE_GENERATOR_FC}) + # Known compilers: + # f77/f90/f95: generic compiler names + # g77: GNU Fortran 77 compiler + # gfortran: putative GNU Fortran 95+ compiler (in progress) + # fort77: native F77 compiler under HP-UX (and some older Crays) + # frt: Fujitsu F77 compiler + # pathf90/pathf95/pathf2003: PathScale Fortran compiler + # pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers + # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers + # lf95: Lahey-Fujitsu F95 compiler + # fl32: Microsoft Fortran 77 "PowerStation" compiler + # af77: Apogee F77 compiler for Intergraph hardware running CLIX + # epcf90: "Edinburgh Portable Compiler" F90 + # fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha + # ifc: Intel Fortran 95 compiler for Linux/x86 + # efc: Intel Fortran 95 compiler for IA64 + # + # The order is 95 or newer compilers first, then 90, + # then 77 or older compilers, gnu is always last in the group, + # so if you paid for a compiler it is picked by default. + set(CMAKE_Fortran_COMPILER_LIST + ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 pgfortran lf95 xlf95 + fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77 + frt pgf77 xlf fl32 af77 g77 f77 + ) + + # Vendor-specific compiler names. + set(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77) + set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc) + set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77) + set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77) + set(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90) + set(_Fortran_COMPILER_NAMES_XL xlf) + set(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf) endif() - endif() - # finally list compilers to try - if(NOT CMAKE_Fortran_COMPILER_INIT) - # Known compilers: - # f77/f90/f95: generic compiler names - # g77: GNU Fortran 77 compiler - # gfortran: putative GNU Fortran 95+ compiler (in progress) - # fort77: native F77 compiler under HP-UX (and some older Crays) - # frt: Fujitsu F77 compiler - # pathf90/pathf95/pathf2003: PathScale Fortran compiler - # pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers - # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers - # lf95: Lahey-Fujitsu F95 compiler - # fl32: Microsoft Fortran 77 "PowerStation" compiler - # af77: Apogee F77 compiler for Intergraph hardware running CLIX - # epcf90: "Edinburgh Portable Compiler" F90 - # fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha - # ifc: Intel Fortran 95 compiler for Linux/x86 - # efc: Intel Fortran 95 compiler for IA64 - # - # The order is 95 or newer compilers first, then 90, - # then 77 or older compilers, gnu is always last in the group, - # so if you paid for a compiler it is picked by default. - set(CMAKE_Fortran_COMPILER_LIST - ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 pgfortran lf95 xlf95 - fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77 - frt pgf77 xlf fl32 af77 g77 f77 - ) - - # Vendor-specific compiler names. - set(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77) - set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc) - set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77) - set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77) - set(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90) - set(_Fortran_COMPILER_NAMES_XL xlf) - set(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf) - endif() + _cmake_find_compiler(Fortran) - _cmake_find_compiler(Fortran) + else() + # we only get here if CMAKE_Fortran_COMPILER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # if CMAKE_Fortran_COMPILER is a list of length 2, use the first item as + # CMAKE_Fortran_COMPILER and the 2nd one as CMAKE_Fortran_COMPILER_ARG1 -else() - # we only get here if CMAKE_Fortran_COMPILER was specified using -D or a pre-made CMakeCache.txt - # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_Fortran_COMPILER is a list of length 2, use the first item as - # CMAKE_Fortran_COMPILER and the 2nd one as CMAKE_Fortran_COMPILER_ARG1 - - list(LENGTH CMAKE_Fortran_COMPILER _CMAKE_Fortran_COMPILER_LIST_LENGTH) - if("${_CMAKE_Fortran_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_Fortran_COMPILER 1 CMAKE_Fortran_COMPILER_ARG1) - list(GET CMAKE_Fortran_COMPILER 0 CMAKE_Fortran_COMPILER) - endif() + list(LENGTH CMAKE_Fortran_COMPILER _CMAKE_Fortran_COMPILER_LIST_LENGTH) + if("${_CMAKE_Fortran_COMPILER_LIST_LENGTH}" EQUAL 2) + list(GET CMAKE_Fortran_COMPILER 1 CMAKE_Fortran_COMPILER_ARG1) + list(GET CMAKE_Fortran_COMPILER 0 CMAKE_Fortran_COMPILER) + endif() - # if a compiler was specified by the user but without path, - # now try to find it with the full path - # if it is found, force it into the cache, - # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" - # if the C compiler already had a path, reuse it for searching the CXX compiler - get_filename_component(_CMAKE_USER_Fortran_COMPILER_PATH "${CMAKE_Fortran_COMPILER}" PATH) - if(NOT _CMAKE_USER_Fortran_COMPILER_PATH) - find_program(CMAKE_Fortran_COMPILER_WITH_PATH NAMES ${CMAKE_Fortran_COMPILER}) - mark_as_advanced(CMAKE_Fortran_COMPILER_WITH_PATH) - if(CMAKE_Fortran_COMPILER_WITH_PATH) - set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER_WITH_PATH} - CACHE STRING "Fortran compiler" FORCE) + # if a compiler was specified by the user but without path, + # now try to find it with the full path + # if it is found, force it into the cache, + # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" + # if the C compiler already had a path, reuse it for searching the CXX compiler + get_filename_component(_CMAKE_USER_Fortran_COMPILER_PATH "${CMAKE_Fortran_COMPILER}" PATH) + if(NOT _CMAKE_USER_Fortran_COMPILER_PATH) + find_program(CMAKE_Fortran_COMPILER_WITH_PATH NAMES ${CMAKE_Fortran_COMPILER}) + mark_as_advanced(CMAKE_Fortran_COMPILER_WITH_PATH) + if(CMAKE_Fortran_COMPILER_WITH_PATH) + set(CMAKE_Fortran_COMPILER ${CMAKE_Fortran_COMPILER_WITH_PATH} + CACHE STRING "Fortran compiler" FORCE) + endif() endif() endif() -endif() - -mark_as_advanced(CMAKE_Fortran_COMPILER) - -# Build a small source file to identify the compiler. -if(${CMAKE_GENERATOR} MATCHES "Visual Studio") - set(CMAKE_Fortran_COMPILER_ID_RUN 1) - set(CMAKE_Fortran_PLATFORM_ID "Windows") - set(CMAKE_Fortran_COMPILER_ID "Intel") -endif() - -if(NOT CMAKE_Fortran_COMPILER_ID_RUN) - set(CMAKE_Fortran_COMPILER_ID_RUN 1) + mark_as_advanced(CMAKE_Fortran_COMPILER) # Each entry in this list is a set of extra flags to try # adding to the compile line to see if it helps produce @@ -135,6 +132,11 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) # Intel on windows does not preprocess by default. "-fpp" ) +endif() + +# Build a small source file to identify the compiler. +if(NOT CMAKE_Fortran_COMPILER_ID_RUN) + set(CMAKE_Fortran_COMPILER_ID_RUN 1) # Table of per-vendor compiler id flags with expected output. list(APPEND CMAKE_Fortran_COMPILER_ID_VENDORS Compaq) @@ -187,6 +189,32 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN) endif() endif() +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_Fortran_COMPILER}" PATH) +endif () + +# if we have a fortran cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-gfortran, arm-elf-gfortran or i586-mingw32msvc-gfortran , optionally +# with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names lile +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" +if (CMAKE_CROSSCOMPILING + AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + get_filename_component(COMPILER_BASENAME "${CMAKE_Fortran_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)g?fortran(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () +endif () + include(CMakeFindBinUtils) if(MSVC_Fortran_ARCHITECTURE_ID) @@ -195,7 +223,7 @@ if(MSVC_Fortran_ARCHITECTURE_ID) endif() # 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 + ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 ) set(CMAKE_Fortran_COMPILER_ENV_VAR "FC") diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index 3f430b4..c4217f5 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -98,5 +98,5 @@ mark_as_advanced(CMAKE_Java_COMPILER) # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeJavaCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeJavaCompiler.cmake IMMEDIATE @ONLY) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeJavaCompiler.cmake IMMEDIATE @ONLY) set(CMAKE_Java_COMPILER_ENV_VAR "JAVA_COMPILER") diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index 669dd16..fa78da0 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -63,5 +63,5 @@ endif() # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeRCCompiler.cmake IMMEDIATE) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeRCCompiler.cmake IMMEDIATE) set(CMAKE_RC_COMPILER_ENV_VAR "RC") diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 22c5016..cd33447 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -170,7 +170,7 @@ if(CMAKE_BINARY_DIR) # configure variables set in this file for fast reload, the template file is defined at the top of this file configure_file(${CMAKE_ROOT}/Modules/CMakeSystem.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake + ${CMAKE_PLATFORM_INFO_DIR}/CMakeSystem.cmake IMMEDIATE @ONLY) endif() diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 30d62bc..c9f58e3 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -47,6 +47,8 @@ macro(ENABLE_LANGUAGE) # But in --find-package mode, we don't want (and can't) enable any language. endmacro() +set(CMAKE_PLATFORM_INFO_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) + include(CMakeDetermineSystem) # short-cut some tests on Darwin, see Darwin-GNU.cmake: diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index 980cc17..207c8ad 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -46,7 +46,6 @@ macro(CMAKE_FORCE_C_COMPILER compiler id) set(CMAKE_C_COMPILER "${compiler}") set(CMAKE_C_COMPILER_ID_RUN TRUE) set(CMAKE_C_COMPILER_ID ${id}) - set(CMAKE_C_COMPILER_WORKS TRUE) set(CMAKE_C_COMPILER_FORCED TRUE) # Set old compiler id variables. @@ -59,7 +58,6 @@ macro(CMAKE_FORCE_CXX_COMPILER compiler id) set(CMAKE_CXX_COMPILER "${compiler}") set(CMAKE_CXX_COMPILER_ID_RUN TRUE) set(CMAKE_CXX_COMPILER_ID ${id}) - set(CMAKE_CXX_COMPILER_WORKS TRUE) set(CMAKE_CXX_COMPILER_FORCED TRUE) # Set old compiler id variables. @@ -72,7 +70,6 @@ macro(CMAKE_FORCE_Fortran_COMPILER compiler id) set(CMAKE_Fortran_COMPILER "${compiler}") set(CMAKE_Fortran_COMPILER_ID_RUN TRUE) set(CMAKE_Fortran_COMPILER_ID ${id}) - set(CMAKE_Fortran_COMPILER_WORKS TRUE) set(CMAKE_Fortran_COMPILER_FORCED TRUE) # Set old compiler id variables. diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index c7529fc..55f8277 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -7,6 +7,8 @@ set(CMAKE_AR "@CMAKE_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") set(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@) set(CMAKE_Fortran_COMPILER_LOADED 1) +set(CMAKE_Fortran_COMPILER_WORKS @CMAKE_Fortran_COMPILER_WORKS@) +set(CMAKE_Fortran_ABI_COMPILED @CMAKE_Fortran_ABI_COMPILED@) set(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) set(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) if(CMAKE_COMPILER_IS_CYGWIN) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 4b360f7..c373414 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -100,6 +100,12 @@ # elif defined(_M_ARM) # define ARCHITECTURE_ID "ARM" +# elif defined(_M_MIPS) +# define ARCHITECTURE_ID "MIPS" + +# elif defined(_M_SH) +# define ARCHITECTURE_ID "SHx" + # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 14291a7..2c75147 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2003-2009 Kitware, Inc. +# Copyright 2003-2012 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -12,8 +12,19 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +if(CMAKE_C_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + set(CMAKE_C_COMPILER_WORKS TRUE) + return() +endif() + include(CMakeTestCompilerCommon) +# Remove any cached result from an older CMake version. +# We now store this in CMakeCCompiler.cmake. +unset(CMAKE_C_COMPILER_WORKS CACHE) + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected C compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -36,6 +47,9 @@ if(NOT CMAKE_C_COMPILER_WORKS) try_compile(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT) + # Move result from cache to normal variable. + set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) + unset(CMAKE_C_COMPILER_WORKS CACHE) set(C_TEST_WAS_RUN 1) endif() @@ -44,11 +58,6 @@ if(NOT CMAKE_C_COMPILER_WORKS) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the C compiler works failed with " "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") - # if the compiler is broken make sure to remove the platform file - # since Windows-cl configures both c/cxx files both need to be removed - # when c or c++ fails - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake ) - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake ) message(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" " "is not able to compile a simple test program.\nIt fails " "with the following output:\n ${__CMAKE_C_COMPILER_OUTPUT}\n\n" @@ -60,22 +69,19 @@ else() "Determining if the C compiler works passed with " "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") endif() - set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") - if(CMAKE_C_COMPILER_FORCED) - # The compiler configuration was forced by the user. - # Assume the user has configured all compiler information. - else() - # Try to identify the ABI and configure it into CMakeCCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c) - configure_file( - ${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 - ) - include(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake) - endif() + # Try to identify the ABI and configure it into CMakeCCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c) + + # Re-configure to save learned information. + configure_file( + ${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake + @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + ) + include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake) + if(CMAKE_C_SIZEOF_DATA_PTR) foreach(f ${CMAKE_C_ABI_FILES}) include(${f}) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 5ed826b..a5cdf56 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2003-2009 Kitware, Inc. +# Copyright 2003-2012 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -12,8 +12,19 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +if(CMAKE_CXX_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + set(CMAKE_CXX_COMPILER_WORKS TRUE) + return() +endif() + include(CMakeTestCompilerCommon) +# Remove any cached result from an older CMake version. +# We now store this in CMakeCXXCompiler.cmake. +unset(CMAKE_CXX_COMPILER_WORKS CACHE) + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected C++ compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -29,16 +40,14 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) try_compile(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT) + # Move result from cache to normal variable. + set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) + unset(CMAKE_CXX_COMPILER_WORKS CACHE) set(CXX_TEST_WAS_RUN 1) endif() if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerStatus("CXX" " -- broken") - # if the compiler is broken make sure to remove the platform file - # since Windows-cl configures both c/cxx files both need to be removed - # when c or c++ fails - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake ) - file(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake ) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the CXX compiler works failed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") @@ -53,22 +62,19 @@ else() "Determining if the CXX compiler works passed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") endif() - set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") - if(CMAKE_CXX_COMPILER_FORCED) - # The compiler configuration was forced by the user. - # Assume the user has configured all compiler information. - else() - # Try to identify the ABI and configure it into CMakeCXXCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) - configure_file( - ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 - ) - include(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake) - endif() + # Try to identify the ABI and configure it into CMakeCXXCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) + + # Re-configure to save learned information. + configure_file( + ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake + @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + ) + include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake) + if(CMAKE_CXX_SIZEOF_DATA_PTR) foreach(f ${CMAKE_CXX_ABI_FILES}) include(${f}) diff --git a/Modules/CMakeTestForFreeVC.cxx b/Modules/CMakeTestForFreeVC.cxx deleted file mode 100644 index e580c1f..0000000 --- a/Modules/CMakeTestForFreeVC.cxx +++ /dev/null @@ -1,3 +0,0 @@ -#include<iostream> - -int main(){return 0;} diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index b388d1e..e263345 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2004-2009 Kitware, Inc. +# Copyright 2004-2012 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -12,8 +12,19 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +if(CMAKE_Fortran_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + set(CMAKE_Fortran_COMPILER_WORKS TRUE) + return() +endif() + include(CMakeTestCompilerCommon) +# Remove any cached result from an older CMake version. +# We now store this in CMakeFortranCompiler.cmake. +unset(CMAKE_Fortran_COMPILER_WORKS CACHE) + # This file is used by EnableLanguage in cmGlobalGenerator to # determine that that selected Fortran compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -29,6 +40,9 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) try_compile(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f OUTPUT_VARIABLE OUTPUT) + # Move result from cache to normal variable. + set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS}) + unset(CMAKE_Fortran_COMPILER_WORKS CACHE) set(FORTRAN_TEST_WAS_RUN 1) endif() @@ -48,50 +62,46 @@ else() "Determining if the Fortran compiler works passed with " "the following output:\n${OUTPUT}\n\n") endif() - set(CMAKE_Fortran_COMPILER_WORKS 1 CACHE INTERNAL "") - if(CMAKE_Fortran_COMPILER_FORCED) - # The compiler configuration was forced by the user. - # Assume the user has configured all compiler information. - else() - # Try to identify the ABI and configure it into CMakeFortranCompiler.cmake - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) - CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) + # Try to identify the ABI and configure it into CMakeFortranCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) - # Test for Fortran 90 support by using an f90-specific construct. - if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " + # Test for Fortran 90 support by using an f90-specific construct. + if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " PROGRAM TESTFortran90 stop = 1 ; do while ( stop .eq. 0 ) ; end do END PROGRAM TESTFortran90 ") - try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 - OUTPUT_VARIABLE OUTPUT) - if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the Fortran compiler supports Fortran 90 passed with " - "the following output:\n${OUTPUT}\n\n") - set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) - else() - message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- no") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the Fortran compiler supports Fortran 90 failed with " - "the following output:\n${OUTPUT}\n\n") - set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0) - endif() - unset(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE) + try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 + OUTPUT_VARIABLE OUTPUT) + if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) + message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- yes") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran compiler supports Fortran 90 passed with " + "the following output:\n${OUTPUT}\n\n") + set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) + else() + message(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90 -- no") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran compiler supports Fortran 90 failed with " + "the following output:\n${OUTPUT}\n\n") + set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0) endif() - - configure_file( - ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake - @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 - ) - include(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake) + unset(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE) endif() + + # Re-configure to save learned information. + configure_file( + ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake + @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + ) + include(${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake) + if(CMAKE_Fortran_SIZEOF_DATA_PTR) foreach(f ${CMAKE_Fortran_ABI_FILES}) include(${f}) diff --git a/Modules/CMakeTestNMakeCLVersion.c b/Modules/CMakeTestNMakeCLVersion.c deleted file mode 100644 index 3cece2a..0000000 --- a/Modules/CMakeTestNMakeCLVersion.c +++ /dev/null @@ -1,2 +0,0 @@ -VERSION=_MSC_VER - diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index b5826ef..0cec897 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -728,18 +728,24 @@ if(CPACK_RPM_USER_FILELIST_INTERNAL) set(CPACK_RPM_USER_INSTALL_FILES "") foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL) - string(REGEX REPLACE "%[A-Za-z\(\)]* " "" F_PATH ${F}) - string(REGEX MATCH "%[A-Za-z\(\)]*" F_PREFIX ${F}) + string(REGEX REPLACE "%[A-Za-z0-9\(\),-]* " "" F_PATH ${F}) + string(REGEX MATCH "%[A-Za-z0-9\(\),-]*" F_PREFIX ${F}) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>") + endif() if(F_PREFIX) - set(F_PREFIX "${F_PREFIX} ") + set(F_PREFIX "${F_PREFIX} ") endif() # Rebuild the user list file set(CPACK_RPM_USER_INSTALL_FILES "${CPACK_RPM_USER_INSTALL_FILES}${F_PREFIX}\"${F_PATH}\"\n") # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH}) - list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) + # ABSOLUTE destination files list may not exists at all + if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) + list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) + endif() endforeach() diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in new file mode 100644 index 0000000..ab4705f --- /dev/null +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|@id_arch@"> + <Configuration>Debug</Configuration> + <Platform>@id_arch@</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid> + <RootNamespace>CompilerId@id_lang@</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + @id_toolset@ + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">$(Configuration)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_arch@'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>false</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>TurnOffAllWarnings</WarningLevel> + <DebugInformationFormat> + </DebugInformationFormat> + </ClCompile> + <Link> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Console</SubSystem> + <TargetMachine>@id_machine_10@</TargetMachine> + </Link> + <PostBuildEvent> + <Command>for %%i in (@id_cl@) do %40echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="@id_src@" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> +</Project> diff --git a/Modules/CompilerId/VS-6.dsp.in b/Modules/CompilerId/VS-6.dsp.in new file mode 100644 index 0000000..4f7e676 --- /dev/null +++ b/Modules/CompilerId/VS-6.dsp.in @@ -0,0 +1,48 @@ +# Microsoft Developer Studio Project File - Name="CompilerId@id_lang@" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 + +# TARGTYPE "Win32 (@id_machine_6@) Application" 0x0101 + +CFG=CompilerId@id_lang@ - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "CompilerId@id_lang@.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "CompilerId@id_lang@.mak" CFG="CompilerId@id_lang@ - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "CompilerId@id_lang@ - Win32 Debug" (based on "Win32 (@id_machine_6@) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +CPP=cl.exe +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "." +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD CPP /nologo /MDd /c +LINK32=link.exe +# ADD LINK32 /nologo /version:0.0 /subsystem:console /machine:@id_machine_6@ /out:"CompilerId@id_lang@.exe" /IGNORE:4089 +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=for %%i in (@id_cl@) do @echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i +# End Special Build Tool +# Begin Target + +# Name "CompilerId@id_lang@ - Win32 Debug" +# Begin Group "Source Files" + +# Begin Source File + +SOURCE="@id_src@" +# End Source File +# End Group +# End Target +# End Project diff --git a/Modules/CompilerId/VS-7.vcproj.in b/Modules/CompilerId/VS-7.vcproj.in new file mode 100644 index 0000000..71bf64d --- /dev/null +++ b/Modules/CompilerId/VS-7.vcproj.in @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="@id_version@" + Name="CompilerId@id_lang@" + ProjectGUID="{CAE07175-D007-4FC3-BFE8-47B392814159}" + RootNamespace="CompilerId@id_lang@" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="@id_arch@" + /> + </Platforms> + <Configurations> + <Configuration + Name="Debug|@id_arch@" + OutputDirectory="." + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="" + MinimalRebuild="false" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="0" + DebugInformationFormat="0" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + GenerateDebugInformation="false" + SubSystem="1" + TargetMachine="@id_machine_7@" + /> + <Tool + Name="VCPostBuildEventTool" + CommandLine="for %%i in (@id_cl@) do @echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i" + /> + </Configuration> + </Configurations> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="@id_src@" + > + </File> + </Filter> + </Files> +</VisualStudioProject> diff --git a/Modules/CompilerId/Xcode-1.pbxproj.in b/Modules/CompilerId/Xcode-1.pbxproj.in new file mode 100644 index 0000000..f06960f --- /dev/null +++ b/Modules/CompilerId/Xcode-1.pbxproj.in @@ -0,0 +1,120 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + 014CEA460018CE2711CA2923 = { + buildSettings = { + }; + isa = PBXBuildStyle; + name = Development; + }; + 08FB7793FE84155DC02AAC07 = { + buildSettings = { + }; + buildStyles = ( + 014CEA460018CE2711CA2923, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 08FB7794FE84155DC02AAC07; + projectDirPath = ""; + targets = ( + 8DD76FA90486AB0100D96B5E, + ); + }; + 08FB7794FE84155DC02AAC07 = { + children = ( + 08FB7795FE84155DC02AAC07, + 1AB674ADFE9D54B511CA2CBB, + ); + isa = PBXGroup; + name = CompilerId@id_lang@; + refType = 4; + sourceTree = "<group>"; + }; + 08FB7795FE84155DC02AAC07 = { + children = ( + 2C18F0B415DC1DC700593670, + ); + isa = PBXGroup; + name = Source; + refType = 4; + sourceTree = "<group>"; + }; + 1AB674ADFE9D54B511CA2CBB = { + children = ( + 8DD76F6C0486A84900D96B5E, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = "<group>"; + }; + 2C18F0B415DC1DC700593670 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = @id_type@; + path = @id_src@; + refType = 4; + sourceTree = "<group>"; + }; + 2C18F0B615DC1E0300593670 = { + fileRef = 2C18F0B415DC1DC700593670; + isa = PBXBuildFile; + settings = { + }; + }; + 2C8FEB8E15DC1A1A00E56A5D = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"GCC_VERSION=$GCC_VERSION\""; + }; + 8DD76FA90486AB0100D96B5E = { + buildPhases = ( + 2C18F0B515DC1DCE00593670, + 2C8FEB8E15DC1A1A00E56A5D, + ); + buildRules = ( + ); + buildSettings = { + PRODUCT_NAME = CompilerId@id_lang@; + SYMROOT = .; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = CompilerId@id_lang@; + productName = CompilerId@id_lang@; + productReference = 8DD76F6C0486A84900D96B5E; + productType = "com.apple.product-type.tool"; + }; + 2C18F0B515DC1DCE00593670 = { + buildActionMask = 2147483647; + files = ( + 2C18F0B615DC1E0300593670, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 8DD76F6C0486A84900D96B5E = { + explicitFileType = "compiled.mach-o.executable"; + includeInIndex = 0; + isa = PBXFileReference; + path = CompilerId@id_lang@; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + }; + rootObject = 08FB7793FE84155DC02AAC07; +} diff --git a/Modules/CompilerId/Xcode-2.pbxproj.in b/Modules/CompilerId/Xcode-2.pbxproj.in new file mode 100644 index 0000000..e3c7aa9 --- /dev/null +++ b/Modules/CompilerId/Xcode-2.pbxproj.in @@ -0,0 +1,119 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + + 2C18F0B615DC1E0300593670 = {isa = PBXBuildFile; fileRef = 2C18F0B415DC1DC700593670; }; + 2C18F0B415DC1DC700593670 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = @id_type@; path = @id_src@; sourceTree = "<group>"; }; + 8DD76F6C0486A84900D96B5E = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CompilerId@id_lang@; sourceTree = BUILT_PRODUCTS_DIR; }; + + 08FB7794FE84155DC02AAC07 = { + isa = PBXGroup; + children = ( + 08FB7795FE84155DC02AAC07, + 1AB674ADFE9D54B511CA2CBB, + ); + name = CompilerId@id_lang@; + sourceTree = "<group>"; + }; + 08FB7795FE84155DC02AAC07 = { + isa = PBXGroup; + children = ( + 2C18F0B415DC1DC700593670, + ); + name = Source; + sourceTree = "<group>"; + }; + 1AB674ADFE9D54B511CA2CBB = { + isa = PBXGroup; + children = ( + 8DD76F6C0486A84900D96B5E, + ); + name = Products; + sourceTree = "<group>"; + }; + + 8DD76FA90486AB0100D96B5E = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB928508733DD80010E9CD; + buildPhases = ( + 2C18F0B515DC1DCE00593670, + 2C8FEB8E15DC1A1A00E56A5D, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CompilerId@id_lang@; + productName = CompilerId@id_lang@; + productReference = 8DD76F6C0486A84900D96B5E; + productType = "com.apple.product-type.tool"; + }; + 08FB7793FE84155DC02AAC07 = { + isa = PBXProject; + buildConfigurationList = 1DEB928908733DD80010E9CD; + hasScannedForEncodings = 1; + mainGroup = 08FB7794FE84155DC02AAC07; + projectDirPath = ""; + targets = ( + 8DD76FA90486AB0100D96B5E, + ); + }; + 2C8FEB8E15DC1A1A00E56A5D = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"GCC_VERSION=$GCC_VERSION\""; + }; + 2C18F0B515DC1DCE00593670 = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C18F0B615DC1E0300593670, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1DEB928608733DD80010E9CD = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = CompilerId@id_lang@; + }; + name = Debug; + }; + 1DEB928A08733DD80010E9CD = { + isa = XCBuildConfiguration; + buildSettings = { + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; + SYMROOT = .; + }; + name = Debug; + }; + 1DEB928508733DD80010E9CD = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB928608733DD80010E9CD, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 1DEB928908733DD80010E9CD = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB928A08733DD80010E9CD, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + }; + rootObject = 08FB7793FE84155DC02AAC07; +} diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in new file mode 100644 index 0000000..41ca7db --- /dev/null +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -0,0 +1,107 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + + 2C18F0B615DC1E0300593670 = {isa = PBXBuildFile; fileRef = 2C18F0B415DC1DC700593670; }; + 2C18F0B415DC1DC700593670 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = @id_type@; path = @id_src@; sourceTree = "<group>"; }; + 08FB7794FE84155DC02AAC07 = { + isa = PBXGroup; + children = ( + 2C18F0B415DC1DC700593670, + ); + name = CompilerId@id_lang@; + sourceTree = "<group>"; + }; + 8DD76FA90486AB0100D96B5E = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB928508733DD80010E9CD; + buildPhases = ( + 2C18F0B515DC1DCE00593670, + 2C8FEB8E15DC1A1A00E56A5D, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CompilerId@id_lang@; + productName = CompilerId@id_lang@; + productType = "com.apple.product-type.tool"; + }; + 08FB7793FE84155DC02AAC07 = { + isa = PBXProject; + buildConfigurationList = 1DEB928908733DD80010E9CD; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + en, + ); + mainGroup = 08FB7794FE84155DC02AAC07; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8DD76FA90486AB0100D96B5E, + ); + }; + 2C8FEB8E15DC1A1A00E56A5D = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"GCC_VERSION=$GCC_VERSION\""; + showEnvVarsInLog = 0; + }; + 2C18F0B515DC1DCE00593670 = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C18F0B615DC1E0300593670, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 1DEB928608733DD80010E9CD = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = CompilerId@id_lang@; + }; + name = Debug; + }; + 1DEB928A08733DD80010E9CD = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ONLY_ACTIVE_ARCH = YES; + CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)"; + SYMROOT = .; + }; + name = Debug; + }; + 1DEB928508733DD80010E9CD = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB928608733DD80010E9CD, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 1DEB928908733DD80010E9CD = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB928A08733DD80010E9CD, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + }; + rootObject = 08FB7793FE84155DC02AAC07; +} diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index cd77ba4..3923685 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -24,7 +24,10 @@ # [HG_REPOSITORY url] # URL of mercurial repo # [HG_TAG tag] # Mercurial branch name, commit id or tag # [URL /.../src.tgz] # Full path or URL of source -# [URL_MD5 md5] # MD5 checksum of file at URL +# [URL_HASH ALGO=value] # Hash of file at URL +# [URL_MD5 md5] # Equivalent to URL_HASH MD5=md5 +# [TLS_VERIFY bool] # Should certificate for https be checked +# [TLS_CAINFO file] # Path to a certificate authority file # [TIMEOUT seconds] # Time allowed for file download operations # #--Update/Patch step---------- # [UPDATE_COMMAND cmd...] # Source work-tree update command @@ -184,6 +187,9 @@ if(_ep_func) set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$") endif() +# Save regex matching supported hash algorithm names. +set(_ep_hash_algos "MD5|SHA1|SHA224|SHA256|SHA384|SHA512") +set(_ep_hash_regex "^(${_ep_hash_algos})=([0-9A-Fa-f]+)$") function(_ep_parse_arguments f name ns args) # Transfer the arguments to this function into target properties for the @@ -395,7 +401,7 @@ endif() endfunction() -function(_ep_write_downloadfile_script script_filename remote local timeout md5) +function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo) if(timeout) set(timeout_args TIMEOUT ${timeout}) set(timeout_msg "${timeout} seconds") @@ -404,10 +410,31 @@ function(_ep_write_downloadfile_script script_filename remote local timeout md5) set(timeout_msg "none") endif() - if(md5) - set(md5_args EXPECTED_MD5 ${md5}) + if("${hash}" MATCHES "${_ep_hash_regex}") + set(hash_args EXPECTED_HASH ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}) else() - set(md5_args "# no EXPECTED_MD5") + set(hash_args "# no EXPECTED_HASH") + endif() + # check for curl globals in the project + if(DEFINED CMAKE_TLS_VERIFY) + set(tls_verify "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})") + endif() + if(DEFINED CMAKE_TLS_CAINFO) + set(tls_cainfo "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")") + endif() + + # now check for curl locals so that the local values + # will override the globals + + # check for tls_verify argument + string(LENGTH "${tls_verify}" tls_verify_len) + if(tls_verify_len GREATER 0) + set(tls_verify "set(CMAKE_TLS_VERIFY ${tls_verify})") + endif() + # check for tls_cainfo argument + string(LENGTH "${tls_cainfo}" tls_cainfo_len) + if(tls_cainfo_len GREATER 0) + set(tls_cainfo "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")") endif() file(WRITE ${script_filename} @@ -416,11 +443,14 @@ function(_ep_write_downloadfile_script script_filename remote local timeout md5) dst='${local}' timeout='${timeout_msg}'\") +${tls_verify} +${tls_cainfo} + file(DOWNLOAD \"${remote}\" \"${local}\" SHOW_PROGRESS - ${md5_args} + ${hash_args} ${timeout_args} STATUS status LOG log) @@ -443,48 +473,30 @@ message(STATUS \"downloading... done\") endfunction() -function(_ep_write_verifyfile_script script_filename local md5) - file(WRITE ${script_filename} -"message(STATUS \"verifying file... - file='${local}'\") - -set(verified 0) - -# If an expected md5 checksum exists, compare against it: -# -if(NOT \"${md5}\" STREQUAL \"\") - execute_process(COMMAND \${CMAKE_COMMAND} -E md5sum \"${local}\" - OUTPUT_VARIABLE ov - OUTPUT_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE rv) - - if(NOT rv EQUAL 0) - message(FATAL_ERROR \"error: computing md5sum of '${local}' failed\") - endif() - - string(REGEX MATCH \"^([0-9A-Fa-f]+)\" md5_actual \"\${ov}\") - - string(TOLOWER \"\${md5_actual}\" md5_actual) - string(TOLOWER \"${md5}\" md5) - - if(NOT \"\${md5}\" STREQUAL \"\${md5_actual}\") - message(FATAL_ERROR \"error: md5sum of '${local}' does not match expected value - md5_expected: \${md5} - md5_actual: \${md5_actual} -\") - endif() - - set(verified 1) -endif() - -if(verified) +function(_ep_write_verifyfile_script script_filename local hash) + if("${hash}" MATCHES "${_ep_hash_regex}") + set(algo "${CMAKE_MATCH_1}") + string(TOLOWER "${CMAKE_MATCH_2}" expect_value) + set(script_content "set(expect_value \"${expect_value}\") +file(${algo} \"\${file}\" actual_value) +if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") message(STATUS \"verifying file... done\") else() - message(STATUS \"verifying file... warning: did not verify file - no URL_MD5 checksum argument? corrupt file?\") -endif() -" -) - + message(FATAL_ERROR \"error: ${algo} hash of + \${file} +does not match expected value + expected: \${expect_value} + actual: \${actual_value} +\") +endif()") + else() + set(script_content "message(STATUS \"verifying file... warning: did not verify file - no URL_HASH specified?\")") + endif() + file(WRITE ${script_filename} "set(file \"${local}\") +message(STATUS \"verifying file... + file='\${file}'\") +${script_content} +") endfunction() @@ -1254,10 +1266,22 @@ function(_ep_add_download_command name) list(APPEND depends ${stamp_dir}/${name}-hginfo.txt) elseif(url) get_filename_component(work_dir "${source_dir}" PATH) + get_property(hash TARGET ${name} PROPERTY _EP_URL_HASH) + if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}") + message(FATAL_ERROR "URL_HASH is set to\n ${hash}\n" + "but must be ALGO=value where ALGO is\n ${_ep_hash_algos}\n" + "and value is a hex string.") + endif() get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5) + if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}") + message(FATAL_ERROR "URL_MD5 is set to\n ${md5}\nbut must be a hex string.") + endif() + if(md5 AND NOT hash) + set(hash "MD5=${md5}") + endif() set(repository "external project URL") set(module "${url}") - set(tag "${md5}") + set(tag "${hash}") configure_file( "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${stamp_dir}/${name}-urlinfo.txt" @@ -1283,7 +1307,10 @@ function(_ep_add_download_command name) string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) - _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}" "${md5}") + get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) + get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) + _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" + "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake COMMAND) set(comment "Performing download step (download, verify and extract) for '${name}'") @@ -1291,7 +1318,7 @@ function(_ep_add_download_command name) set(file "${url}") set(comment "Performing download step (verify and extract) for '${name}'") endif() - _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${md5}") + _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}") list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake COMMAND) _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake index bc0357e..4758534 100644 --- a/Modules/FindArmadillo.cmake +++ b/Modules/FindArmadillo.cmake @@ -76,7 +76,7 @@ endif () # Checks 'REQUIRED', 'QUIET' and versions. -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(Armadillo REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR VERSION_VAR ARMADILLO_VERSION_STRING) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 6a6be47..5a834b1 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -68,6 +68,13 @@ # CUDA_HOST_COMPILATION_CPP (Default ON) # -- Set to OFF for C compilation of host code. # +# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS) +# -- Set the host compiler to be used by nvcc. Ignored if -ccbin or +# --compiler-bindir is already present in the CUDA_NVCC_FLAGS or +# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets +# $(VCInstallDir)/bin is a special value that expands out to the path when +# the command is run from withing VS. +# # CUDA_NVCC_FLAGS # CUDA_NVCC_FLAGS_<CONFIG> # -- Additional NVCC command line arguments. NOTE: multiple arguments must be @@ -390,6 +397,12 @@ option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON) # Extra user settable flags set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.") +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC") +else() + set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") +endif() + # Propagate the host flags to the host compiler via -Xcompiler option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON) @@ -900,14 +913,6 @@ endfunction() macro(CUDA_WRAP_SRCS cuda_target format generated_files) - if( ${format} MATCHES "PTX" ) - set( compile_to_ptx ON ) - elseif( ${format} MATCHES "OBJ") - set( compile_to_ptx OFF ) - else() - message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS: '${format}'. Use OBJ or PTX.") - endif() - # Set up all the command line flags here, so that they can be overridden on a per target basis. set(nvcc_flags "") @@ -940,12 +945,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) endif() # This needs to be passed in at this stage, because VS needs to fill out the - # value of VCInstallDir from within VS. + # value of VCInstallDir from within VS. Note that CCBIN is only used if + # -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches + # $(VCInstallDir)/bin. if(CMAKE_GENERATOR MATCHES "Visual Studio") - if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) - # Add nvcc flag for 64b Windows - set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" ) - endif() + set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" ) endif() # Figure out which configure we will use and pass that in as an argument to @@ -1004,12 +1008,12 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags. We # always need to set the SHARED_FLAGS, though. if(CUDA_PROPAGATE_HOST_FLAGS) - set(CUDA_HOST_FLAGS "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CMAKE_${CUDA_C_OR_CXX}_FLAGS} ${CUDA_HOST_SHARED_FLAGS})") else() - set(CUDA_HOST_FLAGS "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") + set(_cuda_host_flags "set(CMAKE_HOST_FLAGS ${CUDA_HOST_SHARED_FLAGS})") endif() - set(CUDA_NVCC_FLAGS_CONFIG "# Build specific configuration flags") + set(_cuda_nvcc_flags_config "# Build specific configuration flags") # Loop over all the configuration types to generate appropriate flags for run_nvcc.cmake foreach(config ${CUDA_configuration_types}) string(TOUPPER ${config} config_upper) @@ -1018,27 +1022,31 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) if(CUDA_PROPAGATE_HOST_FLAGS) # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g - if(CMAKE_COMPILER_IS_GNUCC AND CUDA_VERSION VERSION_LESS "3.0") + set(_cuda_fix_g3 FALSE) + + if(CMAKE_COMPILER_IS_GNUCC) + if (CUDA_VERSION VERSION_LESS "3.0" OR + CUDA_VERSION VERSION_EQUAL "4.1" OR + CUDA_VERSION VERSION_EQUAL "4.2" + ) + set(_cuda_fix_g3 TRUE) + endif() + endif() + if(_cuda_fix_g3) string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") else() set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") endif() - set(CUDA_HOST_FLAGS "${CUDA_HOST_FLAGS}\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") + set(_cuda_host_flags "${_cuda_host_flags}\nset(CMAKE_HOST_FLAGS_${config_upper} ${_cuda_C_FLAGS})") endif() # Note that if we ever want CUDA_NVCC_FLAGS_<CONFIG> to be string (instead of a list # like it is currently), we can remove the quotes around the # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_<CONFIG> variable. - set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") + set(_cuda_nvcc_flags_config "${_cuda_nvcc_flags_config}\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") endforeach() - if(compile_to_ptx) - # Don't use any of the host compilation flags for PTX targets. - set(CUDA_HOST_FLAGS) - set(CUDA_NVCC_FLAGS_CONFIG) - endif() - # Get the list of definitions from the directory property get_directory_property(CUDA_NVCC_DEFINITIONS COMPILE_DEFINITIONS) if(CUDA_NVCC_DEFINITIONS) @@ -1061,6 +1069,30 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) if(${file} MATCHES ".*\\.cu$" AND NOT _is_header) + # Allow per source file overrides of the format. + get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT) + if(NOT _cuda_source_format) + set(_cuda_source_format ${format}) + endif() + + if( ${_cuda_source_format} MATCHES "PTX" ) + set( compile_to_ptx ON ) + elseif( ${_cuda_source_format} MATCHES "OBJ") + set( compile_to_ptx OFF ) + else() + message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS for file '${file}': '${_cuda_source_format}'. Use OBJ or PTX.") + endif() + + + if(compile_to_ptx) + # Don't use any of the host compilation flags for PTX targets. + set(CUDA_HOST_FLAGS) + set(CUDA_NVCC_FLAGS_CONFIG) + else() + set(CUDA_HOST_FLAGS ${_cuda_host_flags}) + set(CUDA_NVCC_FLAGS_CONFIG ${_cuda_nvcc_flags_config}) + endif() + # Determine output directory cuda_compute_build_path("${file}" cuda_build_path) set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 8274cc7..f0aac84 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -62,6 +62,7 @@ set(cmake_dependency_file "@cmake_dependency_file@") # path set(CUDA_make2cmake "@CUDA_make2cmake@") # path set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path set(build_cubin @build_cubin@) # bool +set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@") # bool # We won't actually use these variables for now, but we need to set this, in # order to force this file to be run again if it changes. set(generated_file_path "@generated_file_path@") # path @@ -102,8 +103,15 @@ endif() # Add the build specific configuration flags list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}}) -if(DEFINED CCBIN) - set(CCBIN -ccbin "${CCBIN}") +# Any -ccbin existing in CUDA_NVCC_FLAGS gets highest priority +list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 ) +list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 ) +if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 ) + if (CUDA_HOST_COMPILER STREQUAL "$(VCInstallDir)bin" AND DEFINED CCBIN) + set(CCBIN -ccbin "${CCBIN}") + else() + set(CCBIN -ccbin "${CUDA_HOST_COMPILER}") + endif() endif() # cuda_execute_process - Executes a command with optional command echo and status message. diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index e397d28..daae94f 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -94,7 +94,7 @@ if(FLEX_EXECUTABLE) # older versions of flex printed "/full/path/to/executable version X.Y" # newer versions use "basename(executable) X.Y" get_filename_component(FLEX_EXE_NAME "${FLEX_EXECUTABLE}" NAME) - string(REGEX REPLACE "^.*${FLEX_EXE_NAME}\"? (version )?([0-9]+[^ ]*)$" "\\2" + string(REGEX REPLACE "^.*${FLEX_EXE_NAME}\"? (version )?([0-9]+[^ ]*)( .*)?$" "\\2" FLEX_VERSION "${FLEX_version_output}") unset(FLEX_EXE_NAME) endif() diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index c7cf0eb..cdb46be 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -46,9 +46,10 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h HINTS ENV FREETYPE_DIR PATHS - /usr/local/X11R6/include - /usr/local/X11/include - /usr/freeware/include + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + PATH_SUFFIXES include/freetype2 include ) find_path(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake new file mode 100644 index 0000000..37dff03 --- /dev/null +++ b/Modules/FindGLEW.cmake @@ -0,0 +1,30 @@ +# - Find the OpenGL Extension Wrangler Library (GLEW) +# This module defines the following variables: +# GLEW_INCLUDE_DIRS - include directories for GLEW +# GLEW_LIBRARIES - libraries to link against GLEW +# GLEW_FOUND - true if GLEW has been found and can be used + +#============================================================================= +# Copyright 2012 Benjamin Eikel +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(GLEW_INCLUDE_DIR GL/glew.h) +find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64) + +set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) +set(GLEW_LIBRARIES ${GLEW_LIBRARY}) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(GLEW + REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY) + +mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index c4774d9..f1c78ae 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -54,12 +54,12 @@ if(GETTEXT_MSGMERGE_EXECUTABLE) unset(gettext_version) endif() -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE VERSION_VAR GETTEXT_VERSION_STRING) -include(CMakeParseArguments) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name) set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}") @@ -210,11 +210,4 @@ function(GETTEXT_PROCESS_PO_FILES _lang) endfunction() -if (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) - set(GETTEXT_FOUND TRUE) -else () - set(GETTEXT_FOUND FALSE) - if (GetText_REQUIRED) - message(FATAL_ERROR "GetText not found") - endif () -endif () +set(GETTEXT_FOUND ${Gettext_FOUND}) diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index f8ea18b..837e633 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -47,13 +47,13 @@ endif() # it can be found in http://tukaani.org/xz/ # Avoid using old codebase if (LIBLZMA_LIBRARY) - include(CheckLibraryExists) + include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET) endif () -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZMA REQUIRED_VARS LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY LIBLZMA_HAS_AUTO_DECODER diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake index 1f30fe3..4a5aaba 100644 --- a/Modules/FindOpenSceneGraph.cmake +++ b/Modules/FindOpenSceneGraph.cmake @@ -145,23 +145,6 @@ if(OSG_INCLUDE_DIR) endif() endif() -# -# Version checking -# -if(OpenSceneGraph_FIND_VERSION AND OPENSCENEGRAPH_VERSION) - if(OpenSceneGraph_FIND_VERSION_EXACT) - if(NOT OPENSCENEGRAPH_VERSION VERSION_EQUAL ${OpenSceneGraph_FIND_VERSION}) - set(_osg_version_not_exact TRUE) - endif() - else() - # version is too low - if(NOT OPENSCENEGRAPH_VERSION VERSION_EQUAL ${OpenSceneGraph_FIND_VERSION} AND - NOT OPENSCENEGRAPH_VERSION VERSION_GREATER ${OpenSceneGraph_FIND_VERSION}) - set(_osg_version_not_high_enough TRUE) - endif() - endif() -endif() - set(_osg_quiet) if(OpenSceneGraph_FIND_QUIETLY) set(_osg_quiet "QUIET") @@ -190,63 +173,22 @@ if(OPENSCENEGRAPH_INCLUDE_DIR) endif() # -# Inform the users with an error message based on -# what version they have vs. what version was -# required. +# Check each module to see if it's found # +set(_osg_component_founds) if(OpenSceneGraph_FIND_REQUIRED) - set(_osg_version_output_type FATAL_ERROR) -else() - set(_osg_version_output_type STATUS) + foreach(_osg_module ${_osg_modules_to_process}) + string(TOUPPER ${_osg_module} _osg_module_UC) + list(APPEND _osg_component_founds ${_osg_module_UC}_FOUND) + endforeach() endif() -if(_osg_version_not_high_enough) - set(_osg_EPIC_FAIL TRUE) - if(NOT OpenSceneGraph_FIND_QUIETLY) - message(${_osg_version_output_type} - "ERROR: Version ${OpenSceneGraph_FIND_VERSION} or higher of the OSG " - "is required. Version ${OPENSCENEGRAPH_VERSION} was found.") - endif() -elseif(_osg_version_not_exact) - set(_osg_EPIC_FAIL TRUE) - if(NOT OpenSceneGraph_FIND_QUIETLY) - message(${_osg_version_output_type} - "ERROR: Version ${OpenSceneGraph_FIND_VERSION} of the OSG is required " - "(exactly), version ${OPENSCENEGRAPH_VERSION} was found.") - endif() -else() - - # - # Check each module to see if it's found - # - if(OpenSceneGraph_FIND_REQUIRED) - set(_osg_missing_message) - foreach(_osg_module ${_osg_modules_to_process}) - string(TOUPPER ${_osg_module} _osg_module_UC) - if(NOT ${_osg_module_UC}_FOUND) - set(_osg_missing_nodekit_fail true) - set(_osg_missing_message "${_osg_missing_message} ${_osg_module}") - endif() - endforeach() - - if(_osg_missing_nodekit_fail) - message(FATAL_ERROR "ERROR: Missing the following osg " - "libraries: ${_osg_missing_message}.\n" - "Consider using CMAKE_PREFIX_PATH or the OSG_DIR " - "environment variable. See the " - "${CMAKE_CURRENT_LIST_FILE} for more details.") - endif() - endif() - include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph DEFAULT_MSG OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR) -endif() +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph + REQUIRED_VARS OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR ${_osg_component_founds} + VERSION_VAR OPENSCENEGRAPH_VERSION) -if(_osg_EPIC_FAIL) - # Zero out everything, we didn't meet version requirements - set(OPENSCENEGRAPH_FOUND FALSE) - set(OPENSCENEGRAPH_LIBRARIES) - set(OPENSCENEGRAPH_INCLUDE_DIR) -endif() +unset(_osg_component_founds) set(OPENSCENEGRAPH_INCLUDE_DIRS ${OPENSCENEGRAPH_INCLUDE_DIR}) diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index b9440a8..6a1d349 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -146,7 +146,7 @@ if (PostgreSQL_INCLUDE_DIR AND EXISTS "${PostgreSQL_INCLUDE_DIR}/pg_config.h") endif() # Did we find anything? -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(PostgreSQL REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR VERSION_VAR PostgreSQL_VERSION_STRING) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index eeeaf59..13f18fe 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -1,7 +1,7 @@ -# - Searches for all installed versions of QT. +# - Searches for all installed versions of Qt. # This should only be used if your project can work with multiple -# versions of QT. If not, you should just directly use FindQt4 or FindQt3. -# If multiple versions of QT are found on the machine, then +# versions of Qt. If not, you should just directly use FindQt4 or FindQt3. +# If multiple versions of Qt are found on the machine, then # The user must set the option DESIRED_QT_VERSION to the version # they want to use. If only one version of qt is found on the machine, # then the DESIRED_QT_VERSION is set to that version and the @@ -10,7 +10,7 @@ # is included. # # QT_REQUIRED if this is set to TRUE then if CMake can -# not find QT4 or QT3 an error is raised +# not find Qt4 or Qt3 an error is raised # and a message is sent to the user. # # DESIRED_QT_VERSION OPTION is created @@ -62,7 +62,7 @@ if(QT_QMAKE_EXECUTABLE_FINDQT) exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) if(QTVERSION MATCHES "4.*") - set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "QT4 qmake program.") + set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.") set(QT4_INSTALLED TRUE) endif() if(QTVERSION MATCHES "Unknown") @@ -115,14 +115,14 @@ endif() if(QT3_INSTALLED AND QT4_INSTALLED ) # force user to pick if we have both - set(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of QT to use: 3 or 4") + set(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4") else() # if only one found then pick that one if(QT3_INSTALLED) - set(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of QT to use: 3 or 4") + set(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4") endif() if(QT4_INSTALLED) - set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of QT to use: 3 or 4") + set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4") endif() endif() @@ -139,21 +139,21 @@ endif() if(NOT QT3_INSTALLED AND NOT QT4_INSTALLED) if(QT_REQUIRED) - message(SEND_ERROR "CMake was unable to find any QT versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.") + message(SEND_ERROR "CMake was unable to find any Qt versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.") endif() else() if(NOT QT_FOUND AND NOT DESIRED_QT_VERSION) if(QT_REQUIRED) - message(SEND_ERROR "Multiple versions of QT found please set DESIRED_QT_VERSION") + message(SEND_ERROR "Multiple versions of Qt found please set DESIRED_QT_VERSION") else() - message("Multiple versions of QT found please set DESIRED_QT_VERSION") + message("Multiple versions of Qt found please set DESIRED_QT_VERSION") endif() endif() if(NOT QT_FOUND AND DESIRED_QT_VERSION) if(QT_REQUIRED) - message(FATAL_ERROR "CMake was unable to find QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.") + message(FATAL_ERROR "CMake was unable to find Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.") else() - message( "CMake was unable to find desired QT version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE.") + message( "CMake was unable to find desired Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE.") endif() endif() endif() diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 0665063..07b6fef 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -144,7 +144,7 @@ find_library(QT_QASSISTANTCLIENT_LIBRARY lib ) -# qt 3 should prefer QTDIR over the PATH +# Qt 3 should prefer QTDIR over the PATH find_program(QT_MOC_EXECUTABLE NAMES moc-qt3 moc HINTS @@ -168,7 +168,7 @@ if(QT_MOC_EXECUTABLE) set ( QT_WRAP_CPP "YES") endif() -# qt 3 should prefer QTDIR over the PATH +# Qt 3 should prefer QTDIR over the PATH find_program(QT_UIC_EXECUTABLE NAMES uic-qt3 uic HINTS diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index f133ae9..a84074b 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1,4 +1,4 @@ -# - Find QT 4 +# - Find Qt 4 # This module can be used to find Qt4. # The most important issue is that the Qt4 qmake is available via the system path. # This qmake is then used to detect basically everything else. @@ -482,7 +482,7 @@ endmacro () function(_QT4_QUERY_QMAKE VAR RESULT) execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query ${VAR} RESULT_VARIABLE return_code - OUTPUT_VARIABLE output ERROR_VARIABLE output + OUTPUT_VARIABLE output OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) if(NOT return_code) file(TO_CMAKE_PATH "${output}" output) @@ -885,6 +885,18 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}${QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) + if(QT_${_upper_qt_module}_LIBRARY_RELEASE MATCHES "/${QT_MODULE}\\.framework$") + if(NOT EXISTS "${QT_${_upper_qt_module}_LIBRARY_RELEASE}/${QT_MODULE}") + # Release framework library file does not exist... Force to NOTFOUND: + set(QT_${_upper_qt_module}_LIBRARY_RELEASE "QT_${_upper_qt_module}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library." FORCE) + endif() + endif() + if(QT_${_upper_qt_module}_LIBRARY_DEBUG MATCHES "/${QT_MODULE}\\.framework$") + if(NOT EXISTS "${QT_${_upper_qt_module}_LIBRARY_DEBUG}/${QT_MODULE}") + # Debug framework library file does not exist... Force to NOTFOUND: + set(QT_${_upper_qt_module}_LIBRARY_DEBUG "QT_${_upper_qt_module}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library." FORCE) + endif() + endif() endforeach() # QtUiTools is sometimes not in the same directory as the other found libraries diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 487c5d3..adaec95 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -133,10 +133,12 @@ endif() if(SDL_LIBRARY_TEMP) # For SDLmain - if(NOT SDL_BUILDING_LIBRARY) - if(SDLMAIN_LIBRARY) - set(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP}) + if(SDLMAIN_LIBRARY AND NOT SDL_BUILDING_LIBRARY) + list(FIND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL_MAIN_INDEX) + if(_SDL_MAIN_INDEX EQUAL -1) + list(APPEND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}") endif() + unset(_SDL_MAIN_INDEX) endif() # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa. diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 50ba80b..2bb7a20 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -57,6 +57,10 @@ if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]") set(__WINDOWS_GNU_LD_RESPONSE 0) endif() +if(NOT CMAKE_GENERATOR_RC AND CMAKE_GENERATOR MATCHES "Unix Makefiles") + set(CMAKE_GENERATOR_RC windres) +endif() + enable_language(RC) macro(__windows_compiler_gnu lang) diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake index 3370557..3a30a2e 100644 --- a/Modules/Platform/Windows-Intel.cmake +++ b/Modules/Platform/Windows-Intel.cmake @@ -61,7 +61,7 @@ set (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) set (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) -include("${CMAKE_PLATFORM_ROOT_BIN}/CMakeIntelInformation.cmake" OPTIONAL) +include("${CMAKE_PLATFORM_INFO_DIR}/CMakeIntelInformation.cmake" OPTIONAL) if(NOT _INTEL_XILINK_TEST_RUN) execute_process(COMMAND xilink /? @@ -70,8 +70,8 @@ if(NOT _INTEL_XILINK_TEST_RUN) if(_XILINK_HELP MATCHES MANIFEST) set(_INTEL_COMPILER_SUPPORTS_MANIFEST 1) endif() - if(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeIntelInformation.cmake") - file(WRITE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeIntelInformation.cmake + if(NOT EXISTS "${CMAKE_PLATFORM_INFO_DIR}/CMakeIntelInformation.cmake") + file(WRITE ${CMAKE_PLATFORM_INFO_DIR}/CMakeIntelInformation.cmake " set(_INTEL_XILINK_TEST_RUN 1) set(_INTEL_COMPILER_SUPPORTS_MANIFEST ${_INTEL_COMPILER_SUPPORTS_MANIFEST}) diff --git a/Modules/Platform/Windows-MSVC-C.cmake b/Modules/Platform/Windows-MSVC-C.cmake new file mode 100644 index 0000000..e81df9f --- /dev/null +++ b/Modules/Platform/Windows-MSVC-C.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-MSVC) +__windows_compiler_msvc(C) diff --git a/Modules/Platform/Windows-MSVC-CXX.cmake b/Modules/Platform/Windows-MSVC-CXX.cmake new file mode 100644 index 0000000..fdd1dae --- /dev/null +++ b/Modules/Platform/Windows-MSVC-CXX.cmake @@ -0,0 +1,3 @@ +include(Platform/Windows-MSVC) +set(_COMPILE_CXX " /TP") +__windows_compiler_msvc(CXX) diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake new file mode 100644 index 0000000..cc48cfe --- /dev/null +++ b/Modules/Platform/Windows-MSVC.cmake @@ -0,0 +1,240 @@ + +#============================================================================= +# Copyright 2001-2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__WINDOWS_MSVC) + return() +endif() +set(__WINDOWS_MSVC 1) + +set(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:") +set(CMAKE_LINK_LIBRARY_FLAG "") +set(MSVC 1) + +# hack: if a new cmake (which uses CMAKE__LINKER) runs on an old build tree +# (where link was hardcoded) and where CMAKE_LINKER isn't in the cache +# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun) +# hardcode CMAKE_LINKER here to link, so it behaves as it did before, Alex +if(NOT DEFINED CMAKE_LINKER) + set(CMAKE_LINKER link) +endif() + +if(CMAKE_VERBOSE_MAKEFILE) + set(CMAKE_CL_NOLOGO) +else() + set(CMAKE_CL_NOLOGO "/nologo") +endif() + +set(WIN32 1) + +if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") + set(CMAKE_CREATE_WIN32_EXE "/subsystem:windowsce /entry:WinMainCRTStartup") + set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:windowsce /entry:mainACRTStartup") +else() + set(CMAKE_CREATE_WIN32_EXE "/subsystem:windows") + set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:console") +endif() + +if(CMAKE_GENERATOR MATCHES "Visual Studio 6") + set (CMAKE_NO_BUILD_TYPE 1) +endif() +if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio") + set (CMAKE_NO_BUILD_TYPE 1) + set (CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE STRING + "Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.") + mark_as_advanced(CMAKE_CONFIGURATION_TYPES) +endif() + +# make sure to enable languages after setting configuration types +enable_language(RC) +set(CMAKE_COMPILE_RESOURCE "rc <FLAGS> /fo<OBJECT> <SOURCE>") + +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + set(MSVC_IDE 1) +else() + set(MSVC_IDE 0) +endif() + +if(NOT MSVC_VERSION) + if(CMAKE_C_COMPILER_VERSION) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + else() + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + endif() + if("${_compiler_version}" MATCHES "^([0-9]+)\\.([0-9]+)") + math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") + else() + message(FATAL_ERROR "MSVC compiler version not detected properly: ${_compiler_version}") + endif() + + set(MSVC10) + set(MSVC11) + set(MSVC60) + set(MSVC70) + set(MSVC71) + set(MSVC80) + set(MSVC90) + set(CMAKE_COMPILER_2005) + set(CMAKE_COMPILER_SUPPORTS_PDBTYPE) + if(NOT "${_compiler_version}" VERSION_LESS 17) + set(MSVC11 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 16) + set(MSVC10 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 15) + set(MSVC90 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 14) + set(MSVC80 1) + set(CMAKE_COMPILER_2005 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 13.10) + set(MSVC71 1) + elseif(NOT "${_compiler_version}" VERSION_LESS 13) + set(MSVC70 1) + else() + set(MSVC60 1) + set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) + endif() +endif() + +if(MSVC_C_ARCHITECTURE_ID MATCHES 64) + set(CMAKE_CL_64 1) +else() + set(CMAKE_CL_64 0) +endif() +if(CMAKE_FORCE_WIN64 OR CMAKE_FORCE_IA64) + set(CMAKE_CL_64 1) +endif() + +if("${MSVC_VERSION}" GREATER 1599) + set(MSVC_INCREMENTAL_DEFAULT ON) +endif() + +# default to Debug builds +set(CMAKE_BUILD_TYPE_INIT Debug) + +if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") + string(TOUPPER "${MSVC_C_ARCHITECTURE_ID}" _MSVC_C_ARCHITECTURE_ID_UPPER) + string(TOUPPER "${MSVC_CXX_ARCHITECTURE_ID}" _MSVC_CXX_ARCHITECTURE_ID_UPPER) + + if("${CMAKE_SYSTEM_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)") + math(EXPR _CE_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") + elseif("${CMAKE_SYSTEM_VERSION}" STREQUAL "") + set(_CE_VERSION "500") + else() + message(FATAL_ERROR "Invalid Windows CE version: ${CMAKE_SYSTEM_VERSION}") + endif() + + set(_PLATFORM_DEFINES "/D_WIN32_WCE=0x${_CE_VERSION} /DUNDER_CE") + set(_PLATFORM_DEFINES_C " /D${MSVC_C_ARCHITECTURE_ID} /D_${_MSVC_C_ARCHITECTURE_ID_UPPER}_") + set(_PLATFORM_DEFINES_CXX " /D${MSVC_CXX_ARCHITECTURE_ID} /D_${_MSVC_CXX_ARCHITECTURE_ID_UPPER}_") + + set(_RTC1 "") + set(_FLAGS_CXX " /GR /EHsc") + set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib") + set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib") +else() + set(_PLATFORM_DEFINES "/DWIN32") + + if(MSVC_VERSION GREATER 1310) + set(_RTC1 "/RTC1") + set(_FLAGS_CXX " /GR /EHsc") + set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib") + else() + set(_RTC1 "/GZ") + set(_FLAGS_CXX " /GR /GX") + set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib") + endif() +endif() + +set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") + +# executable linker flags +set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") +# set the stack size and the machine type +set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) +if(NOT _MACHINE_ARCH_FLAG) + set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) +endif() +if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") + if(_MACHINE_ARCH_FLAG MATCHES "ARM") + set(_MACHINE_ARCH_FLAG "THUMB") + elseif(_MACHINE_ARCH_FLAG MATCHES "SH") + set(_MACHINE_ARCH_FLAG "SH4") + endif() +endif() +set (CMAKE_EXE_LINKER_FLAGS_INIT + "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:${_MACHINE_ARCH_FLAG}") + +# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype +# on versions that support it +set( MSVC_INCREMENTAL_YES_FLAG "") +if(NOT MSVC_INCREMENTAL_DEFAULT) + set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:YES") +else() + set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL" ) +endif() + +if (CMAKE_COMPILER_SUPPORTS_PDBTYPE) + set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") + set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") +else () + set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}") + set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}") +endif () +# for release and minsize release default to no incremental linking +set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT "/INCREMENTAL:NO") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/INCREMENTAL:NO") + +# copy the EXE_LINKER flags to SHARED and MODULE linker flags +# shared linker flags +set (CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT}) +set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT}) +set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT}) +set (CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) +set (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) +# module linker flags +set (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) +set (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) +set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) +set (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) +set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) + +macro(__windows_compiler_msvc lang) + if(NOT "${CMAKE_${lang}_COMPILER_VERSION}" VERSION_LESS 14) + # for 2005 make sure the manifest is put in the dll with mt + set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll ") + set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe ") + endif() + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "${_CMAKE_VS_LINK_DLL}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + + set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") + + set(CMAKE_${lang}_COMPILE_OBJECT + "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE + "<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE + "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /FoNUL /FAs /Fa<ASSEMBLY_SOURCE> /c <SOURCE>${CMAKE_END_TEMP_FILE}") + + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1) + set(CMAKE_${lang}_LINK_EXECUTABLE + "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <FLAGS> /Fe<TARGET> /Fd<TARGET_PDB> -link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}") + + set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3 /Zm1000${_FLAGS_${lang}}") + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") +endmacro() diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake deleted file mode 100644 index 05df946..0000000 --- a/Modules/Platform/Windows-cl.cmake +++ /dev/null @@ -1,253 +0,0 @@ -# try to load any previously computed information for C on this platform -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(WIN32 1) - -include(Platform/cl) - -set(CMAKE_CREATE_WIN32_EXE /subsystem:windows) -set(CMAKE_CREATE_CONSOLE_EXE /subsystem:console) - -if(CMAKE_GENERATOR MATCHES "Visual Studio 6") - set (CMAKE_NO_BUILD_TYPE 1) -endif() -if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio") - set (CMAKE_NO_BUILD_TYPE 1) - set (CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE STRING - "Semicolon separated list of supported configuration types, only supports Debug, Release, MinSizeRel, and RelWithDebInfo, anything else will be ignored.") - mark_as_advanced(CMAKE_CONFIGURATION_TYPES) -endif() -# does the compiler support pdbtype and is it the newer compiler -if(CMAKE_GENERATOR MATCHES "Visual Studio 8") - set(CMAKE_COMPILER_2005 1) -endif() - -# make sure to enable languages after setting configuration types -enable_language(RC) -set(CMAKE_COMPILE_RESOURCE "rc <FLAGS> /fo<OBJECT> <SOURCE>") - -# for nmake we need to compute some information about the compiler -# that is being used. -# the compiler may be free command line, 6, 7, or 71, and -# each have properties that must be determined. -# to avoid running these tests with each cmake run, the -# test results are saved in CMakeCPlatform.cmake, a file -# that is automatically copied into try_compile directories -# by the global generator. -set(MSVC_IDE 1) -if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") - set(MSVC_IDE 0) - if(NOT CMAKE_VC_COMPILER_TESTS_RUN) - set(CMAKE_VC_COMPILER_TESTS 1) - set(testNmakeCLVersionFile - "${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c") - string(REGEX REPLACE "/" "\\\\" testNmakeCLVersionFile "${testNmakeCLVersionFile}") - message(STATUS "Check for CL compiler version") - set(CMAKE_TEST_COMPILER ${CMAKE_C_COMPILER}) - if (NOT CMAKE_C_COMPILER) - set(CMAKE_TEST_COMPILER ${CMAKE_CXX_COMPILER}) - endif() - exec_program(${CMAKE_TEST_COMPILER} - ARGS /nologo -EP \"${testNmakeCLVersionFile}\" - OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT - RETURN_VALUE CMAKE_COMPILER_RETURN - ) - if(NOT CMAKE_COMPILER_RETURN) - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining the version of compiler passed with the following output:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - string(REGEX REPLACE "\n" " " compilerVersion "${CMAKE_COMPILER_OUTPUT}") - string(REGEX REPLACE ".*VERSION=(.*)" "\\1" - compilerVersion "${compilerVersion}") - message(STATUS "Check for CL compiler version - ${compilerVersion}") - set(MSVC60) - set(MSVC70) - set(MSVC71) - set(MSVC80) - set(CMAKE_COMPILER_2005) - if("${compilerVersion}" LESS 1300) - set(MSVC60 1) - set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 1) - endif() - if("${compilerVersion}" EQUAL 1300) - set(MSVC70 1) - set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0) - endif() - if("${compilerVersion}" EQUAL 1310) - set(MSVC71 1) - set(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0) - endif() - if("${compilerVersion}" EQUAL 1400) - set(MSVC80 1) - set(CMAKE_COMPILER_2005 1) - endif() - if("${compilerVersion}" EQUAL 1500) - set(MSVC90 1) - endif() - if("${compilerVersion}" EQUAL 1600) - set(MSVC10 1) - endif() - set(MSVC_VERSION "${compilerVersion}") - else() - message(STATUS "Check for CL compiler version - failed") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining the version of compiler failed with the following output:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - endif() - # try to figure out if we are running the free command line - # tools from Microsoft. These tools do not provide debug libraries, - # so the link flags used have to be different. - make_directory("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp2") - set(testForFreeVCFile - "${CMAKE_ROOT}/Modules/CMakeTestForFreeVC.cxx") - string(REGEX REPLACE "/" "\\\\" testForFreeVCFile "${testForFreeVCFile}") - message(STATUS "Check if this is a free VC compiler") - exec_program(${CMAKE_TEST_COMPILER} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp2 - ARGS /nologo /MD /EHsc - \"${testForFreeVCFile}\" - OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT - RETURN_VALUE CMAKE_COMPILER_RETURN - ) - if(CMAKE_COMPILER_RETURN) - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if this is a free VC compiler failed with the following output:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - message(STATUS "Check if this is a free VC compiler - yes") - set(CMAKE_USING_VC_FREE_TOOLS 1) - else() - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if this is a free VC compiler passed with the following output:\n" - "${CMAKE_COMPILER_OUTPUT}\n\n") - message(STATUS "Check if this is a free VC compiler - no") - set(CMAKE_USING_VC_FREE_TOOLS 0) - endif() - make_directory("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp3") - endif() -endif() - -if(MSVC_C_ARCHITECTURE_ID MATCHES 64) - set(CMAKE_CL_64 1) -else() - set(CMAKE_CL_64 0) -endif() -if(CMAKE_FORCE_WIN64 OR CMAKE_FORCE_IA64) - set(CMAKE_CL_64 1) -endif() - -if("${MSVC_VERSION}" GREATER 1599) - set(MSVC_INCREMENTAL_DEFAULT ON) -endif() - -# default to Debug builds -if(MSVC_VERSION GREATER 1310) - # for 2005 make sure the manifest is put in the dll with mt - set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_COMMAND> -E vs_link_dll ${CMAKE_CXX_CREATE_SHARED_LIBRARY}") - set(CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_COMMAND> -E vs_link_dll ${CMAKE_CXX_CREATE_SHARED_MODULE}") - # create a C shared library - set(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") - # create a C shared module just copy the shared library rule - set(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}") - set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_COMMAND> -E vs_link_exe ${CMAKE_CXX_LINK_EXECUTABLE}") - set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_COMMAND> -E vs_link_exe ${CMAKE_C_LINK_EXECUTABLE}") - - set(CMAKE_BUILD_TYPE_INIT Debug) - set (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR") - set (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") - set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") - set (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") - set (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000") - set (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") - set (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") - set (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") - set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") - set (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ") - set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT}") -else() - if(CMAKE_USING_VC_FREE_TOOLS) - message(STATUS "Using FREE VC TOOLS, NO DEBUG available") - set(CMAKE_BUILD_TYPE_INIT Release) - set (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR") - set (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /GZ") - set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") - set (CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") - set (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000") - set (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /GZ") - set (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") - set (CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") - set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") - else() - set(CMAKE_BUILD_TYPE_INIT Debug) - set (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /GX /GR") - set (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /GZ") - set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") - set (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") - set (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000") - set (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /GZ") - set (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG") - set (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") - set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") - endif() - set (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib") -endif() - -set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") - -# executable linker flags -set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") -# set the stack size and the machine type -set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) -if(NOT _MACHINE_ARCH_FLAG) - set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) -endif() -set (CMAKE_EXE_LINKER_FLAGS_INIT - "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:${_MACHINE_ARCH_FLAG}") - -# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype -# on versions that support it -set( MSVC_INCREMENTAL_YES_FLAG "") -if(NOT MSVC_INCREMENTAL_DEFAULT) - set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL:YES") -else() - set( MSVC_INCREMENTAL_YES_FLAG "/INCREMENTAL" ) -endif() - -if (CMAKE_COMPILER_SUPPORTS_PDBTYPE) - set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") - set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}") -else () - set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}") - set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}") -endif () -# for release and minsize release default to no incremental linking -set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT "/INCREMENTAL:NO") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT "/INCREMENTAL:NO") - -# copy the EXE_LINKER flags to SHARED and MODULE linker flags -# shared linker flags -set (CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) -set (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) -# module linker flags -set (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) -set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) - -# save computed information for this platform -if(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake") - configure_file(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCPlatform.cmake IMMEDIATE) -endif() - -if(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake") - configure_file(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE) -endif() diff --git a/Modules/Platform/Windows-cl.cmake.in b/Modules/Platform/Windows-cl.cmake.in deleted file mode 100644 index 4f3ec3e..0000000 --- a/Modules/Platform/Windows-cl.cmake.in +++ /dev/null @@ -1,14 +0,0 @@ -set(CMAKE_VC_COMPILER_TESTS_RUN 1) -set(CMAKE_COMPILER_SUPPORTS_PDBTYPE @CMAKE_COMPILER_SUPPORTS_PDBTYPE@) -set(CMAKE_COMPILER_2005 @CMAKE_COMPILER_2005@) -set(CMAKE_USING_VC_FREE_TOOLS @CMAKE_USING_VC_FREE_TOOLS@) -set(CMAKE_CL_64 @CMAKE_CL_64@) -set(MSVC60 @MSVC60@) -set(MSVC70 @MSVC70@) -set(MSVC71 @MSVC71@) -set(MSVC80 @MSVC80@) -set(MSVC90 @MSVC90@) -set(MSVC10 @MSVC10@) -set(MSVC_IDE @MSVC_IDE@) -set(MSVC_VERSION @MSVC_VERSION@) -set(WIN32 1) diff --git a/Modules/Platform/WindowsCE-MSVC-C.cmake b/Modules/Platform/WindowsCE-MSVC-C.cmake new file mode 100644 index 0000000..ce8060b --- /dev/null +++ b/Modules/Platform/WindowsCE-MSVC-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-MSVC-C) diff --git a/Modules/Platform/WindowsCE-MSVC-CXX.cmake b/Modules/Platform/WindowsCE-MSVC-CXX.cmake new file mode 100644 index 0000000..281eadc --- /dev/null +++ b/Modules/Platform/WindowsCE-MSVC-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-MSVC-CXX) diff --git a/Modules/Platform/WindowsCE-MSVC.cmake b/Modules/Platform/WindowsCE-MSVC.cmake new file mode 100644 index 0000000..d28b4ab --- /dev/null +++ b/Modules/Platform/WindowsCE-MSVC.cmake @@ -0,0 +1 @@ +include(Platform/Windows-MSVC) diff --git a/Modules/Platform/WindowsCE.cmake b/Modules/Platform/WindowsCE.cmake new file mode 100644 index 0000000..65b2eae --- /dev/null +++ b/Modules/Platform/WindowsCE.cmake @@ -0,0 +1 @@ +include(Platform/Windows) diff --git a/Modules/Platform/cl.cmake b/Modules/Platform/cl.cmake deleted file mode 100644 index 9e4d607..0000000 --- a/Modules/Platform/cl.cmake +++ /dev/null @@ -1,62 +0,0 @@ -set(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:") -set(CMAKE_LINK_LIBRARY_FLAG "") -set(MSVC 1) - -# hack: if a new cmake (which uses CMAKE__LINKER) runs on an old build tree -# (where link was hardcoded) and where CMAKE_LINKER isn't in the cache -# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun) -# hardcode CMAKE_LINKER here to link, so it behaves as it did before, Alex -if(NOT DEFINED CMAKE_LINKER) - set(CMAKE_LINKER link) -endif() - -if(CMAKE_VERBOSE_MAKEFILE) - set(CMAKE_CL_NOLOGO) -else() - set(CMAKE_CL_NOLOGO "/nologo") -endif() -# create a shared C++ library -set(CMAKE_CXX_CREATE_SHARED_LIBRARY - "<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_FLAGS> <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> <DEFINES> /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> <DEFINES> /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}") - -set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) -set(CMAKE_C_LINK_EXECUTABLE - "<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <FLAGS> /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_USE_RESPONSE_FILE_FOR_OBJECTS 1) -set(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} <FLAGS> /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> <DEFINES> -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> <DEFINES> /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}") - diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 7c9dc9e..251d57c 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -187,15 +187,17 @@ macro (QT4_ADD_RESOURCES outfiles ) if(EXISTS "${infile}") # parse file for dependencies # all files are absolute paths or relative to the location of the qrc file - file(STRINGS "${infile}" _RC_FILES REGEX "<file[^>]*>[^<]+") - foreach(_RC_FILE IN LISTS _RC_FILES) - string(REGEX REPLACE "^<file[^>]*>([^<]*)" "\\1" _RC_FILE "${_RC_FILE}") + file(READ "${infile}" _RC_FILE_CONTENTS) + string(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}") + foreach(_RC_FILE ${_RC_FILES}) + string(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}") if(NOT IS_ABSOLUTE "${_RC_FILE}") set(_RC_FILE "${rc_path}/${_RC_FILE}") endif() set(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}") endforeach() unset(_RC_FILES) + unset(_RC_FILE_CONTENTS) # Since this cmake macro is doing the dependency scanning for these files, # let's make a configured file and add it as a dependency so cmake is run # again when dependencies need to be recomputed. diff --git a/Modules/SquishTestScript.cmake b/Modules/SquishTestScript.cmake index 5cdd212..d565305 100644 --- a/Modules/SquishTestScript.cmake +++ b/Modules/SquishTestScript.cmake @@ -44,7 +44,7 @@ foreach(i ${squish_env_vars}) endforeach() if (QT4_INSTALLED) - # record qt lib directory + # record Qt lib directory set ( ENV{${SQUISH_LIBQTDIR}} ${squish_libqtdir} ) endif () |