diff options
175 files changed, 1629 insertions, 570 deletions
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake index 692befa..c3c25f5 100644 --- a/CMakeCPack.cmake +++ b/CMakeCPack.cmake @@ -13,16 +13,18 @@ # If the cmake version includes cpack, use it IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") IF(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake") - OPTION(CMAKE_INSTALL_DEBUG_LIBRARIES + OPTION(CMAKE_INSTALL_DEBUG_LIBRARIES "Install Microsoft runtime debug libraries with CMake." FALSE) MARK_AS_ADVANCED(CMAKE_INSTALL_DEBUG_LIBRARIES) + + # By default, do not warn when built on machines using only VS Express: + IF(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) + SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) + ENDIF() + INCLUDE(${CMake_SOURCE_DIR}/Modules/InstallRequiredSystemLibraries.cmake) ENDIF(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake") - # Set the options file that needs to be included inside CMakeCPackOptions.cmake - SET(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake) - CONFIGURE_FILE("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in" - "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY) - SET(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake") + SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool") SET(CPACK_PACKAGE_VENDOR "Kitware") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") @@ -30,6 +32,25 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") SET(CPACK_PACKAGE_VERSION "${CMake_VERSION}") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") SET(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-${CMake_VERSION}") + + # Make this explicit here, rather than accepting the CPack default value, + # so we can refer to it: + SET(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") + + # Installers for 32- vs. 64-bit CMake: + # - Root install directory (displayed to end user at installer-run time) + # - "NSIS package/display name" (text used in the installer GUI) + # - Registry key used to store info about the installation + IF(CMAKE_CL_64) + SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") + SET(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} (Win64)") + SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)") + ELSE() + SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") + SET(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") + SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") + ENDIF() + IF(NOT DEFINED CPACK_SYSTEM_NAME) # make sure package is not Cygwin-unknown, for Cygwin just # cygwin is good for the system name @@ -41,11 +62,12 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") ENDIF(NOT DEFINED CPACK_SYSTEM_NAME) IF(${CPACK_SYSTEM_NAME} MATCHES Windows) IF(CMAKE_CL_64) - SET(CPACK_SYSTEM_NAME win64-${CMAKE_SYSTEM_PROCESSOR}) + SET(CPACK_SYSTEM_NAME win64-x64) ELSE(CMAKE_CL_64) - SET(CPACK_SYSTEM_NAME win32-${CMAKE_SYSTEM_PROCESSOR}) + SET(CPACK_SYSTEM_NAME win32-x86) ENDIF(CMAKE_CL_64) ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows) + IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME) # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache # default to source package - system, on cygwin system is not @@ -57,15 +79,17 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}") ENDIF(CYGWIN) ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME) + SET(CPACK_PACKAGE_CONTACT "cmake@cmake.org") + IF(UNIX) SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest") SET(CPACK_SOURCE_STRIP_FILES "") SET(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") ENDIF(UNIX) -# cygwin specific packaging stuff + + # cygwin specific packaging stuff IF(CYGWIN) - # setup the cygwin package name SET(CPACK_PACKAGE_NAME cmake) # setup the name of the package for cygwin cmake-2.4.3 @@ -87,6 +111,13 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") # this file uses some of the package file name variables INCLUDE(Utilities/Release/Cygwin/CMakeLists.txt) ENDIF(CYGWIN) + + # Set the options file that needs to be included inside CMakeCPackOptions.cmake + SET(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in" + "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY) + SET(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake") + # include CPack model once all variables are set INCLUDE(CPack) ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index a94fa72..69a1508 100644 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -3,8 +3,10 @@ # in this file. if(CPACK_GENERATOR MATCHES "NSIS") + SET(CPACK_NSIS_INSTALL_ROOT "@CPACK_NSIS_INSTALL_ROOT@") + # set the install/unistall icon used for the installer itself - # There is a bug in NSI that does not handle full unix paths properly. + # There is a bug in NSI that does not handle full unix paths properly. SET(CPACK_NSIS_MUI_ICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeLogo.ico") SET(CPACK_NSIS_MUI_UNIICON "@CMake_SOURCE_DIR@/Utilities/Release\\CMakeLogo.ico") # set the package header icon for MUI @@ -21,11 +23,11 @@ if(CPACK_GENERATOR MATCHES "NSIS") "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cpack.html" "CPack Help" "http://www.cmake.org" "CMake Web Site" ) - # Use the icond from cmake-gui for add-remove programs + # Use the icon from cmake-gui for add-remove programs SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\cmake-gui.exe") - SET(CPACK_NSIS_DISPLAY_NAME "CMake @CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@ a cross-platform, open-source build system") - SET(CPACK_NSIS_PACKAGE_NAME "CMake @CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@") + SET(CPACK_NSIS_PACKAGE_NAME "@CPACK_NSIS_PACKAGE_NAME@") + SET(CPACK_NSIS_DISPLAY_NAME "@CPACK_NSIS_PACKAGE_NAME@, a cross-platform, open-source build system") SET(CPACK_NSIS_HELP_LINK "http://www.cmake.org") SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.kitware.com") SET(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea35e21..dd3be79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,12 @@ IF(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) ENDIF(COMMAND CMAKE_POLICY) +IF(CMAKE_BOOTSTRAP) + # Running from bootstrap script. Set local variable and remove from cache. + SET(CMAKE_BOOTSTRAP 1) + UNSET(CMAKE_BOOTSTRAP CACHE) +ENDIF() + MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY) # Allow empty endif() and such with CMake 2.4. @@ -53,42 +59,47 @@ MACRO(CMAKE_HANDLE_SYSTEM_LIBRARIES) OPTION(CTEST_USE_XMLRPC "Enable xmlrpc submission method in CTest." OFF) MARK_AS_ADVANCED(CTEST_USE_XMLRPC) - # Allow the user to enable/disable all system utility library options - # by setting CMAKE_USE_SYSTEM_LIBRARIES on the command line. - IF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES) - SET(CMAKE_USE_SYSTEM_LIBRARIES_USER 1) - ENDIF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES) - IF(CMAKE_USE_SYSTEM_LIBRARIES) - SET(CMAKE_USE_SYSTEM_LIBRARIES ON) - ELSE(CMAKE_USE_SYSTEM_LIBRARIES) - SET(CMAKE_USE_SYSTEM_LIBRARIES OFF) - ENDIF(CMAKE_USE_SYSTEM_LIBRARIES) - IF(CMAKE_USE_SYSTEM_LIBRARIES_USER) - SET(CMAKE_USE_SYSTEM_CURL "${CMAKE_USE_SYSTEM_LIBRARIES}" - CACHE BOOL "Use system-installed curl" FORCE) - SET(CMAKE_USE_SYSTEM_EXPAT "${CMAKE_USE_SYSTEM_LIBRARIES}" - CACHE BOOL "Use system-installed expat" FORCE) - SET(CMAKE_USE_SYSTEM_ZLIB "${CMAKE_USE_SYSTEM_LIBRARIES}" - CACHE BOOL "Use system-installed zlib" FORCE) - SET(CMAKE_USE_SYSTEM_BZIP2 "${CMAKE_USE_SYSTEM_LIBRARIES}" - CACHE BOOL "Use system-installed bzip2" FORCE) - SET(CMAKE_USE_SYSTEM_LIBARCHIVE "${CMAKE_USE_SYSTEM_LIBRARIES}" - CACHE BOOL "Use system-installed libarchive" FORCE) - ENDIF(CMAKE_USE_SYSTEM_LIBRARIES_USER) + # Allow the user to enable/disable all system utility library options by + # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}. + SET(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE ZLIB) + FOREACH(util ${UTILITIES}) + IF(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util} + AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES) + SET(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}") + ENDIF() + IF(DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}) + IF(CMAKE_USE_SYSTEM_LIBRARY_${util}) + SET(CMAKE_USE_SYSTEM_LIBRARY_${util} ON) + ELSE() + SET(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF) + ENDIF() + IF(CMAKE_BOOTSTRAP) + UNSET(CMAKE_USE_SYSTEM_LIBRARY_${util} CACHE) + ENDIF() + STRING(TOLOWER "${util}" lutil) + SET(CMAKE_USE_SYSTEM_${util} "${CMAKE_USE_SYSTEM_LIBRARY_${util}}" + CACHE BOOL "Use system-installed ${lutil}" FORCE) + ELSE() + SET(CMAKE_USE_SYSTEM_LIBRARY_${util} OFF) + ENDIF() + ENDFOREACH(util) + IF(CMAKE_BOOTSTRAP) + UNSET(CMAKE_USE_SYSTEM_LIBRARIES CACHE) + ENDIF() # Optionally use system utility libraries. - OPTION(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" ${CMAKE_USE_SYSTEM_LIBRARIES}) + OPTION(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" "${CMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE}") CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl" - ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CTEST_USE_XMLRPC" ON) + "${CMAKE_USE_SYSTEM_LIBRARY_CURL}" "NOT CTEST_USE_XMLRPC" ON) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat" - ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CTEST_USE_XMLRPC" ON) + "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}" "NOT CTEST_USE_XMLRPC" ON) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib" - ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON) + "${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2" - ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) + "${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) # Mention to the user what system libraries are being used. - FOREACH(util BZIP2 CURL EXPAT LIBARCHIVE ZLIB) + FOREACH(util ${UTILITIES}) IF(CMAKE_USE_SYSTEM_${util}) MESSAGE(STATUS "Using system-installed ${util}") ENDIF(CMAKE_USE_SYSTEM_${util}) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index c7778fb..c91553a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -48,6 +48,9 @@ #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" +#elif defined(__SCO_VERSION__) +# define COMPILER_ID "SCO" + #elif defined(__GNUC__) # define COMPILER_ID "GNU" diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 668119f..9285fef 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2004-2009 Kitware, Inc. +# Copyright 2004-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -76,12 +76,16 @@ ENDIF (NOT _INCLUDED_FILE) # be made to those values. IF(CMAKE_USER_MAKE_RULES_OVERRIDE) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") +ENDIF() IF(CMAKE_USER_MAKE_RULES_OVERRIDE_C) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_C}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_C) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_C} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE_C "${_override}") +ENDIF() # for most systems a module is the same as a shared library diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 2ff227a..4c8f497 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -50,6 +50,9 @@ #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" +#elif defined(__SCO_VERSION__) +# define COMPILER_ID "SCO" + #elif defined(__GNUC__) # define COMPILER_ID "GNU" diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 163a7ef..620de63 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2004-2009 Kitware, Inc. +# Copyright 2004-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -75,12 +75,16 @@ ENDIF (NOT _INCLUDED_FILE) # be made to those values. IF(CMAKE_USER_MAKE_RULES_OVERRIDE) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") +ENDIF() IF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX "${_override}") +ENDIF() # for most systems a module is the same as a shared library diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 7a443e0..d6350bf 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -81,16 +81,17 @@ ENDIF() # If we have a gas/as cross compiler, they have usually some prefix, like -# e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas . +# e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally +# with a 3-component version number at the end # 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-gas.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" IF (NOT _CMAKE_TOOLCHAIN_PREFIX) GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME) - IF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$") + IF (COMPILER_BASENAME MATCHES "^(.+-)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") STRING(REGEX REPLACE "^(.+-)g?as(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}") - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$") + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) INCLUDE(CMakeFindBinUtils) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 639b426..06664c1 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -15,14 +15,14 @@ # determine the compiler to use for C programs # NOTE, a generator may set CMAKE_C_COMPILER before # loading this file to force a compiler. -# use environment variable CC first if defined by user, next use +# use environment variable CC first if defined by user, next use # the cmake variable CMAKE_GENERATOR_CC which can be defined by a generator # as a default compiler -# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used +# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used # as prefix for the tools (e.g. arm-elf-gcc, arm-elf-ar etc.). This works # currently with the GNU crosscompilers. # -# Sets the following variables: +# Sets the following variables: # CMAKE_C_COMPILER # CMAKE_AR # CMAKE_RANLIB @@ -41,12 +41,12 @@ IF(NOT CMAKE_C_COMPILER) SET(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") ENDIF(CMAKE_C_FLAGS_ENV_INIT) IF(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) - MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") + MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") ENDIF(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) ENDIF($ENV{CC} MATCHES ".+") # next try prefer the compiler specified by the generator - IF(CMAKE_GENERATOR_CC) + IF(CMAKE_GENERATOR_CC) IF(NOT CMAKE_C_COMPILER_INIT) SET(CMAKE_C_COMPILER_INIT ${CMAKE_GENERATOR_CC}) ENDIF(NOT CMAKE_C_COMPILER_INIT) @@ -64,7 +64,7 @@ IF(NOT CMAKE_C_COMPILER) FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} PATHS ${_CMAKE_USER_CXX_COMPILER_PATH} DOC "C compiler" NO_DEFAULT_PATH) ENDIF (_CMAKE_USER_CXX_COMPILER_PATH) FIND_PROGRAM(CMAKE_C_COMPILER NAMES ${CMAKE_C_COMPILER_LIST} DOC "C compiler") - + IF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER) SET(CMAKE_C_COMPILER "${CMAKE_C_COMPILER_INIT}" CACHE FILEPATH "C compiler" FORCE) ENDIF(CMAKE_C_COMPILER_INIT AND NOT CMAKE_C_COMPILER) @@ -72,7 +72,7 @@ ELSE(NOT CMAKE_C_COMPILER) # 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 + # 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) @@ -81,9 +81,9 @@ ELSE(NOT CMAKE_C_COMPILER) LIST(GET CMAKE_C_COMPILER 0 CMAKE_C_COMPILER) ENDIF("${_CMAKE_C_COMPILER_LIST_LENGTH}" EQUAL 2) - # if a compiler was specified by the user but without path, + # 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 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) @@ -143,19 +143,20 @@ IF(NOT CMAKE_C_COMPILER_ID_RUN) ENDIF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") ENDIF(NOT CMAKE_C_COMPILER_ID_RUN) -# 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 . +# 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). # 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.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 +IF (CMAKE_CROSSCOMPILING AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _CMAKE_TOOLCHAIN_PREFIX) GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) - IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") + IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") # 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.) @@ -163,7 +164,7 @@ IF (CMAKE_CROSSCOMPILING SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") -ENDIF (CMAKE_CROSSCOMPILING +ENDIF (CMAKE_CROSSCOMPILING AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _CMAKE_TOOLCHAIN_PREFIX) @@ -179,5 +180,5 @@ ENDIF(MSVC_C_ARCHITECTURE_ID) CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in "${CMAKE_PLATFORM_ROOT_BIN}/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 555d20e..e77672d 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -15,10 +15,10 @@ # determine the compiler to use for C++ programs # NOTE, a generator may set CMAKE_CXX_COMPILER before # loading this file to force a compiler. -# use environment variable CXX first if defined by user, next use +# use environment variable CXX first if defined by user, next use # the cmake variable CMAKE_GENERATOR_CXX which can be defined by a generator # as a default compiler -# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used +# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used # as prefix for the tools (e.g. arm-elf-g++, arm-elf-ar etc.) # # Sets the following variables: @@ -63,7 +63,7 @@ IF(NOT CMAKE_CXX_COMPILER) FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} PATHS ${_CMAKE_USER_C_COMPILER_PATH} DOC "C++ compiler" NO_DEFAULT_PATH) ENDIF (_CMAKE_USER_C_COMPILER_PATH) FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} DOC "C++ compiler") - + IF(CMAKE_CXX_COMPILER_INIT AND NOT CMAKE_CXX_COMPILER) SET(CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER_INIT}" CACHE FILEPATH "C++ compiler" FORCE) ENDIF(CMAKE_CXX_COMPILER_INIT AND NOT CMAKE_CXX_COMPILER) @@ -72,7 +72,7 @@ ELSE(NOT CMAKE_CXX_COMPILER) # 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 +# 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) @@ -81,9 +81,9 @@ ELSE(NOT CMAKE_CXX_COMPILER) LIST(GET CMAKE_CXX_COMPILER 0 CMAKE_CXX_COMPILER) ENDIF("${_CMAKE_CXX_COMPILER_LIST_LENGTH}" EQUAL 2) -# if a compiler was specified by the user but without path, +# 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 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) @@ -151,19 +151,20 @@ IF(NOT CMAKE_CXX_COMPILER_ID_RUN) ENDIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") ENDIF(NOT CMAKE_CXX_COMPILER_ID_RUN) -# if we have a g++ cross compiler, they have usually some prefix, like -# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ -# the other tools of the toolchain usually have the same prefix +# if 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). +# 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.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 +IF (CMAKE_CROSSCOMPILING AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _CMAKE_TOOLCHAIN_PREFIX) GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) - IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$") + IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$") + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") # 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.) @@ -171,7 +172,7 @@ IF (CMAKE_CROSSCOMPILING SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") -ENDIF (CMAKE_CROSSCOMPILING +ENDIF (CMAKE_CROSSCOMPILING AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index ed0b6fb..7f918e6 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -24,10 +24,18 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) # Compile the ABI identification source. SET(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/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 ${CMAKE_BINARY_DIR} ${src} - CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}" + CMAKE_FLAGS "${CMAKE_FLAGS}" "-DCMAKE_${lang}_STANDARD_LIBRARIES=" + # We need ignore these warnings because some platforms need + # CMAKE_${lang}_STANDARD_LIBRARIES to link properly and we + # don't care when we are just determining the ABI. + "--no-warn-unused-cli" OUTPUT_VARIABLE OUTPUT COPY_FILE "${BIN}" ) @@ -58,10 +66,16 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) # Parse implicit linker information for this language, if available. SET(implicit_dirs "") SET(implicit_libs "") + SET(MULTI_ARCH FALSE) + IF(DEFINED CMAKE_OSX_ARCHITECTURES) + IF( "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";" ) + SET(MULTI_ARCH TRUE) + ENDIF() + ENDIF() IF(CMAKE_${lang}_VERBOSE_FLAG # Implicit link information cannot be used explicitly for # multiple OS X architectures, so we skip it. - AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";" + AND NOT MULTI_ARCH # Skip this with Xcode for now. AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode) CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index bf78a5b..9a3884a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -243,7 +243,9 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) # ENDIF("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface") ENDIF(NOT CMAKE_EXECUTABLE_FORMAT) - + IF(NOT DEFINED CMAKE_EXECUTABLE_FORMAT) + SET(CMAKE_EXECUTABLE_FORMAT) + ENDIF() # Return the information extracted. SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index d18353a..4f033e3 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2004-2009 Kitware, Inc. +# Copyright 2004-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -52,12 +52,16 @@ ENDIF (NOT _INCLUDED_FILE) # be made to those values. IF(CMAKE_USER_MAKE_RULES_OVERRIDE) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") +ENDIF() IF(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran "${_override}") +ENDIF() # Fortran needs cmake to do a requires step during its build process to diff --git a/Modules/CMakeJavaInformation.cmake b/Modules/CMakeJavaInformation.cmake index e9bc9be..e192db1 100644 --- a/Modules/CMakeJavaInformation.cmake +++ b/Modules/CMakeJavaInformation.cmake @@ -1,6 +1,6 @@ #============================================================================= -# Copyright 2004-2009 Kitware, Inc. +# Copyright 2004-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -19,12 +19,16 @@ # be made to those values. IF(CMAKE_USER_MAKE_RULES_OVERRIDE) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) - -IF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) - INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_CXX}) -ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") +ENDIF() + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_Java) + # Save the full path of the file so try_compile can use it. + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_Java} RESULT_VARIABLE _override) + SET(CMAKE_USER_MAKE_RULES_OVERRIDE_Java "${_override}") +ENDIF() # this is a place holder if java needed flags for javac they would go here. IF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY) diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake index e8bfc0c..d59fe55 100644 --- a/Modules/CheckCSourceCompiles.cmake +++ b/Modules/CheckCSourceCompiles.cmake @@ -1,6 +1,6 @@ -# - Check if the given C source code compiles. +# - Check if given C source compiles and links into an executable # CHECK_C_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>]) -# <code> - source code to try to compile +# <code> - source code to try to compile, must define 'main' # <var> - variable to store whether the source code compiled # <fail-regex> - fail if test output matches this regex # The following variables may be set before calling this macro to diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index 4502c6b..0491b37 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -1,6 +1,6 @@ -# - Check if the given C++ source code compiles. +# - Check if given C++ source compiles and links into an executable # CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>]) -# <code> - source code to try to compile +# <code> - source code to try to compile, must define 'main' # <var> - variable to store whether the source code compiled # <fail-regex> - fail if test output matches this regex # The following variables may be set before calling this macro to diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index e1a1777..0ba36d9 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -1,8 +1,10 @@ -# - Check if the function exists. -# CHECK_FUNCTION_EXISTS(FUNCTION VARIABLE) -# - macro which checks if the function exists -# FUNCTION - the name of the function -# VARIABLE - variable to store the result +# - Check if a C function can be linked +# CHECK_FUNCTION_EXISTS(<function> <variable>) +# +# Check that the <function> is provided by libraries on the system and +# store the result in a <variable>. This does not verify that any +# system header file declares the function, only that it can be found +# at link time (considure using CheckSymbolExists). # # The following variables may be set before calling this macro to # modify the way the check is run: @@ -13,7 +15,7 @@ # CMAKE_REQUIRED_LIBRARIES = list of libraries to link #============================================================================= -# Copyright 2002-2009 Kitware, Inc. +# Copyright 2002-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index 40910f2..e86604b 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -1,9 +1,16 @@ -# - Check if the symbol exists in include files -# CHECK_SYMBOL_EXISTS(SYMBOL FILES VARIABLE) +# - Check if a symbol exists as a function, variable, or macro +# CHECK_SYMBOL_EXISTS(<symbol> <files> <variable>) # -# SYMBOL - symbol -# FILES - include files to check -# VARIABLE - variable to return result +# Check that the <symbol> is available after including given header +# <files> and store the result in a <variable>. Specify the list +# of files in one argument as a semicolon-separated list. +# +# If the header files define the symbol as a macro it is considered +# available and assumed to work. If the header files declare the +# symbol as a function or variable then the symbol must also be +# available for linking. If the symbol is a type or enum value +# it will not be recognized (consider using CheckTypeSize or +# CheckCSourceCompiles). # # The following variables may be set before calling this macro to # modify the way the check is run: @@ -14,7 +21,7 @@ # CMAKE_REQUIRED_LIBRARIES = list of libraries to link #============================================================================= -# Copyright 2003-2009 Kitware, Inc. +# Copyright 2003-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/Compiler/SCO-C.cmake b/Modules/Compiler/SCO-C.cmake new file mode 100644 index 0000000..6e762cc --- /dev/null +++ b/Modules/Compiler/SCO-C.cmake @@ -0,0 +1,2 @@ +include(Compiler/SCO) +__compiler_sco(C) diff --git a/Modules/Compiler/SCO-CXX.cmake b/Modules/Compiler/SCO-CXX.cmake new file mode 100644 index 0000000..5b713a0 --- /dev/null +++ b/Modules/Compiler/SCO-CXX.cmake @@ -0,0 +1,2 @@ +include(Compiler/SCO) +__compiler_sco(CXX) diff --git a/Modules/Compiler/SCO.cmake b/Modules/Compiler/SCO.cmake new file mode 100644 index 0000000..d3deeb1 --- /dev/null +++ b/Modules/Compiler/SCO.cmake @@ -0,0 +1,25 @@ + +#============================================================================= +# Copyright 2002-2011 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(__COMPILER_SCO) + return() +endif() +set(__COMPILER_SCO 1) + +macro(__compiler_sco lang) + # Feature flags. + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-Kpic -belf") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-belf -Wl,-Bexport") +endmacro() diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake index 40bd6f3..af84f8c 100644 --- a/Modules/FindALSA.cmake +++ b/Modules/FindALSA.cmake @@ -35,7 +35,7 @@ find_library(ALSA_LIBRARY NAMES asound # handle the QUIETLY and REQUIRED arguments and set ALSA_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA DEFAULT_MSG ALSA_LIBRARY ALSA_INCLUDE_DIR) if(ALSA_FOUND) diff --git a/Modules/FindASPELL.cmake b/Modules/FindASPELL.cmake index 63ffdf9..d19fab4 100644 --- a/Modules/FindASPELL.cmake +++ b/Modules/FindASPELL.cmake @@ -26,7 +26,7 @@ FIND_LIBRARY(ASPELL_LIBRARIES NAMES aspell aspell-15 libaspell-15 libaspell) # handle the QUIETLY and REQUIRED arguments and set ASPELL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASPELL DEFAULT_MSG ASPELL_LIBRARIES ASPELL_INCLUDE_DIR) MARK_AS_ADVANCED(ASPELL_INCLUDE_DIR ASPELL_LIBRARIES) diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index 90885ac..8b5b05a 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake @@ -37,7 +37,7 @@ ENDIF (UNIX) # handle the QUIETLY and REQUIRED arguments and set AVIFILE_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVIFile DEFAULT_MSG AVIFILE_INCLUDE_DIR AVIFILE_AVIPLAY_LIBRARY) IF (AVIFILE_FOUND) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index fc5daa6..e855a27 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -158,7 +158,7 @@ IF(BISON_EXECUTABLE) ENDIF(BISON_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE VERSION_VAR BISON_VERSION) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index e671f93..679c129 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -26,7 +26,7 @@ FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2 ) # handle the QUIETLY and REQUIRED arguments and set BZip2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 DEFAULT_MSG BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) IF (BZIP2_FOUND) diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index a7c6de2..cebb828 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -70,7 +70,7 @@ _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_d) # handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 1547b19..d5ef430 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -684,7 +684,7 @@ set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(CUDA REQUIRED_VARS CUDA_TOOLKIT_ROOT_DIR diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 07835fa..36f3841 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -34,7 +34,7 @@ MARK_AS_ADVANCED(CURL_LIBRARY) # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL DEFAULT_MSG CURL_LIBRARY CURL_INCLUDE_DIR) IF(CURL_FOUND) diff --git a/Modules/FindCVS.cmake b/Modules/FindCVS.cmake index 2769111..57680bd 100644 --- a/Modules/FindCVS.cmake +++ b/Modules/FindCVS.cmake @@ -65,5 +65,5 @@ mark_as_advanced(CVS_EXECUTABLE) # Handle the QUIETLY and REQUIRED arguments and set CVS_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(CVS DEFAULT_MSG CVS_EXECUTABLE) diff --git a/Modules/FindCoin3D.cmake b/Modules/FindCoin3D.cmake index 47d0c55..8bfe97a 100644 --- a/Modules/FindCoin3D.cmake +++ b/Modules/FindCoin3D.cmake @@ -76,7 +76,7 @@ ENDIF (WIN32) # handle the QUIETLY and REQUIRED arguments and set COIN3D_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Coin3D DEFAULT_MSG COIN3D_LIBRARIES COIN3D_INCLUDE_DIRS) MARK_AS_ADVANCED(COIN3D_INCLUDE_DIRS COIN3D_LIBRARIES ) diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 4485f43..d1e1311 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -155,7 +155,7 @@ SET(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG CURSES_LIBRARY CURSES_INCLUDE_PATH) diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake index 69104c5..4ff310c 100644 --- a/Modules/FindCxxTest.cmake +++ b/Modules/FindCxxTest.cmake @@ -165,7 +165,7 @@ find_program(CXXTEST_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl PATHS ${CXXTEST_INCLUDE_DIR}) if(PYTHONINTERP_FOUND OR PERL_FOUND) - include(FindPackageHandleStandardArgs) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(PYTHONINTERP_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND)) set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE}) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 3bed97f..0ac22f8 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -132,7 +132,7 @@ if(DCMTK_ofstd_INCLUDE_DIR) mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR) endif() -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(DCMTK DEFAULT_MSG DCMTK_config_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR diff --git a/Modules/FindDart.cmake b/Modules/FindDart.cmake index 90f71bd..f7c54df 100644 --- a/Modules/FindDart.cmake +++ b/Modules/FindDart.cmake @@ -30,7 +30,7 @@ FIND_PATH(DART_ROOT README.INSTALL # handle the QUIETLY and REQUIRED arguments and set DART_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Dart DEFAULT_MSG DART_ROOT) MARK_AS_ADVANCED(DART_ROOT) diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake index c87e736..0e21284 100644 --- a/Modules/FindDevIL.cmake +++ b/Modules/FindDevIL.cmake @@ -25,7 +25,7 @@ # TODO: Add version support. # Tested under Linux and Windows (MSVC) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PATH(IL_INCLUDE_DIR il.h PATH_SUFFIXES include IL diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index aa4973d..e5428ae 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -76,7 +76,7 @@ FIND_PROGRAM(DOXYGEN_EXECUTABLE DOC "Doxygen documentation generation tool (http://www.doxygen.org)" ) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Doxygen DEFAULT_MSG DOXYGEN_EXECUTABLE) # diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 3c04b4c..8551fd6 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -26,7 +26,7 @@ FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat) # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR) # Copy the results to the output variables. diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 481e1e2..3cc3da5 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -143,7 +143,7 @@ IF(FLEX_EXECUTABLE) ENDIF(FLEX_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLEX REQUIRED_VARS FLEX_EXECUTABLE VERSION_VAR FLEX_VERSION) diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index 03d4b8e..bb18a2e 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -292,7 +292,7 @@ ENDIF(NOT FLTK_DIR) ENDIF() LIST(APPEND FLTK_LIBRARIES ${FLTK_BASE_LIBRARY}) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) IF(FLTK_SKIP_FLUID) FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLTK DEFAULT_MSG FLTK_LIBRARIES FLTK_INCLUDE_DIR) ELSE() diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 7762684..8957b64 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -88,7 +88,7 @@ SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS) diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index 2050c72..c31bef5 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -100,7 +100,7 @@ FIND_LIBRARY(GDAL_LIBRARY /usr/freeware ) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR) set(GDAL_LIBRARIES ${GDAL_LIBRARY}) diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index e0d25e1..1fad07d 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -60,7 +60,7 @@ SET(GIF_LIBRARIES ${GIF_LIBRARY}) # handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF DEFAULT_MSG GIF_LIBRARY GIF_INCLUDE_DIR) MARK_AS_ADVANCED(GIF_INCLUDE_DIR GIF_LIBRARY) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 45df79e..af88997 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -23,7 +23,7 @@ IF (WIN32) FIND_PATH( GLUT_INCLUDE_DIR NAMES GL/glut.h PATHS ${GLUT_ROOT_PATH}/include ) - FIND_LIBRARY( GLUT_glut_LIBRARY NAMES glut glut32 + FIND_LIBRARY( GLUT_glut_LIBRARY NAMES glut glut32 freeglut PATHS ${OPENGL_LIBRARY_DIR} ${GLUT_ROOT_PATH}/Release diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index caecca2..a03c023 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -521,7 +521,7 @@ endif() set(_GTK2_did_we_find_everything true) # This gets set to GTK2_FOUND -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index ef2852a..6cffb5c 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -146,7 +146,7 @@ else() _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind) endif() -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTest DEFAULT_MSG GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) if(GTEST_FOUND) diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index af316d8..503b640 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -43,5 +43,5 @@ mark_as_advanced(GIT_EXECUTABLE) # Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE) diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake index 5c41253..a437a1f 100644 --- a/Modules/FindGnuTLS.cmake +++ b/Modules/FindGnuTLS.cmake @@ -56,7 +56,7 @@ MARK_AS_ADVANCED(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY) # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR) IF(GNUTLS_FOUND) diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake index 364d725..7c59f03 100644 --- a/Modules/FindGnuplot.cmake +++ b/Modules/FindGnuplot.cmake @@ -34,7 +34,7 @@ SET(GNUPLOT ${GNUPLOT_EXECUTABLE}) # handle the QUIETLY and REQUIRED arguments and set GNUPLOT_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gnuplot DEFAULT_MSG GNUPLOT_EXECUTABLE) MARK_AS_ADVANCED( GNUPLOT_EXECUTABLE ) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 30203f2..90849a1 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -57,7 +57,7 @@ # This module is maintained by Will Dicharry <wdicharry@stellarscience.com>. include(SelectLibraryConfigurations) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # List of the valid HDF5 components set( HDF5_VALID_COMPONENTS diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake index 3a8943f..054f565 100644 --- a/Modules/FindHSPELL.cmake +++ b/Modules/FindHSPELL.cmake @@ -36,7 +36,7 @@ ENDIF() # handle the QUIETLY and REQUIRED arguments and set HSPELL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(HSPELL DEFAULT_MSG HSPELL_LIBRARIES HSPELL_INCLUDE_DIR) MARK_AS_ADVANCED(HSPELL_INCLUDE_DIR HSPELL_LIBRARIES) diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 3afcb1c..5e6fa20 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -171,7 +171,7 @@ SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES}) #--------------------------------------------------------------------- # Standard Package Output #--------------------------------------------------------------------- -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS( ImageMagick DEFAULT_MSG ImageMagick_FOUND ) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 5d70f0b..6ba1826 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -232,7 +232,7 @@ FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h ${JAVA_INCLUDE_PATH} ) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 1f37483..349e7e1 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -27,7 +27,7 @@ FIND_LIBRARY(JPEG_LIBRARY NAMES ${JPEG_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR) IF(JPEG_FOUND) diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index 8aaa373..bae4c05 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -27,7 +27,7 @@ FIND_LIBRARY(JASPER_LIBRARY NAMES jasper libjasper) # handle the QUIETLY and REQUIRED arguments and set JASPER_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper DEFAULT_MSG JASPER_LIBRARY JASPER_INCLUDE_DIR JPEG_LIBRARIES) IF (JASPER_FOUND) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 1599433..8c2128e 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -150,7 +150,7 @@ FIND_PROGRAM(Java_JAVAC_EXECUTABLE PATHS ${_JAVA_PATHS} ) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(Java_FIND_COMPONENTS) foreach(component ${Java_FIND_COMPONENTS}) # User just want to execute some Java byte-compiled diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index e7c2706..cedcd24 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -50,7 +50,10 @@ endif() # Handle the QUIETLY and REQUIRED arguments and set LIBARCHIVE_FOUND # to TRUE if all listed variables are TRUE. -include(FindPackageHandleStandardArgs) +# (Use ${CMAKE_ROOT}/Modules instead of ${CMAKE_CURRENT_LIST_DIR} because CMake +# itself includes this FindLibArchive when built with an older CMake that does +# not provide it. The older CMake also does not have CMAKE_CURRENT_LIST_DIR.) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(LibArchive DEFAULT_MSG LibArchive_LIBRARY LibArchive_INCLUDE_DIR ) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 250c20a..95ae180 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -46,7 +46,7 @@ SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index 0fcfbf5..462835a 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -40,7 +40,7 @@ FIND_LIBRARY(LIBXSLT_LIBRARIES NAMES xslt libxslt # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt DEFAULT_MSG LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR) MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR LIBXSLT_LIBRARIES) diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake index 091e596..ee8b84e 100644 --- a/Modules/FindLua50.cmake +++ b/Modules/FindLua50.cmake @@ -87,7 +87,7 @@ ELSE(${LUA_LIBRARY_lua} MATCHES "framework") ENDIF(${LUA_LIBRARY_lua} MATCHES "framework") -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index e67d545..123fd5d 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -66,7 +66,7 @@ IF(LUA_LIBRARY) ENDIF(UNIX AND NOT APPLE) ENDIF(LUA_LIBRARY) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) diff --git a/Modules/FindMPEG.cmake b/Modules/FindMPEG.cmake index 9d44ac4..cf4ef58 100644 --- a/Modules/FindMPEG.cmake +++ b/Modules/FindMPEG.cmake @@ -34,7 +34,7 @@ FIND_LIBRARY( MPEG_vo_LIBRARY vo # handle the QUIETLY and REQUIRED arguments and set MPEG2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG DEFAULT_MSG MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY) IF(MPEG_FOUND) diff --git a/Modules/FindMPEG2.cmake b/Modules/FindMPEG2.cmake index bc1cf2b..fab37cf 100644 --- a/Modules/FindMPEG2.cmake +++ b/Modules/FindMPEG2.cmake @@ -36,7 +36,7 @@ FIND_LIBRARY( MPEG2_vo_LIBRARY vo # handle the QUIETLY and REQUIRED arguments and set MPEG2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG2 DEFAULT_MSG MPEG2_mpeg2_LIBRARY MPEG2_INCLUDE_DIR) IF(MPEG2_FOUND) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 4d1da5b..a81a53b 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -346,7 +346,7 @@ else (MPI_INCLUDE_PATH AND MPI_LIBRARY) set(MPI_FOUND FALSE) endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # handle the QUIETLY and REQUIRED arguments find_package_handle_standard_args(MPI DEFAULT_MSG MPI_LIBRARY MPI_INCLUDE_PATH) diff --git a/Modules/FindMotif.cmake b/Modules/FindMotif.cmake index f101545..e354112 100644 --- a/Modules/FindMotif.cmake +++ b/Modules/FindMotif.cmake @@ -34,7 +34,7 @@ ENDIF(UNIX) # handle the QUIETLY and REQUIRED arguments and set MOTIF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Motif DEFAULT_MSG MOTIF_LIBRARIES MOTIF_INCLUDE_DIR) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 8f79436..bcba6e2 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -97,7 +97,7 @@ FIND_LIBRARY(OPENAL_LIBRARY # handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) MARK_AS_ADVANCED(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 3618963..98d8808 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -149,7 +149,7 @@ SET(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) # handle the QUIETLY and REQUIRED arguments and set OPENGL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL DEFAULT_MSG OPENGL_gl_LIBRARY) MARK_AS_ADVANCED( diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index f149d9f..652803c 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -26,7 +26,7 @@ include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) set(OpenMP_C_FLAG_CANDIDATES #Gnu diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index d3d7fc2..f41a66b 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -113,7 +113,7 @@ ELSE(WIN32 AND NOT CYGWIN) ENDIF(WIN32 AND NOT CYGWIN) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(OpenSSL DEFAULT_MSG OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake index 8e6abdb..460f0fd 100644 --- a/Modules/FindOpenSceneGraph.cmake +++ b/Modules/FindOpenSceneGraph.cmake @@ -231,7 +231,7 @@ else() endif() endif() - include(FindPackageHandleStandardArgs) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph DEFAULT_MSG OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR) endif() diff --git a/Modules/FindOpenThreads.cmake b/Modules/FindOpenThreads.cmake index e1fe937..6b81fbe 100644 --- a/Modules/FindOpenThreads.cmake +++ b/Modules/FindOpenThreads.cmake @@ -118,6 +118,6 @@ else() set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY}) endif() -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR) diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake index 3b21f89..6c2965a 100644 --- a/Modules/FindPHP4.cmake +++ b/Modules/FindPHP4.cmake @@ -81,5 +81,5 @@ IF(APPLE) ENDFOREACH(symbol) ENDIF(APPLE) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHP4 DEFAULT_MSG PHP4_EXECUTABLE PHP4_INCLUDE_PATH) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index 4fb218b..f607dc6 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -33,7 +33,7 @@ if(ZLIB_FOUND) /usr/local/include/libpng # OpenBSD ) - set(PNG_NAMES ${PNG_NAMES} png libpng png14 libpng14 png14d libpng14d png12 libpng12 png12d libpng12d) + set(PNG_NAMES ${PNG_NAMES} png libpng png15 libpng15 png15d libpng15d png14 libpng14 png14d libpng14d png12 libpng12 png12d libpng12d) find_library(PNG_LIBRARY NAMES ${PNG_NAMES} ) if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) @@ -55,7 +55,7 @@ endif(ZLIB_FOUND) # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(PNG DEFAULT_MSG PNG_LIBRARY PNG_PNG_INCLUDE_DIR) mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY ) diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index 87d1ff9..db393e7 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -44,7 +44,7 @@ SET(PERL ${PERL_EXECUTABLE}) # handle the QUIETLY and REQUIRED arguments and set PERL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl DEFAULT_MSG PERL_EXECUTABLE) MARK_AS_ADVANCED(PERL_EXECUTABLE) diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index 91eb91d..270d894 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -258,7 +258,7 @@ endif (PERL_EXECUTABLE) # handle the QUIETLY and REQUIRED arguments and set PERLLIBS_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(PerlLibs REQUIRED_VARS PERL_LIBRARY PERL_INCLUDE_PATH VERSION_VAR PERL_VERSION) diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake index c38f4bc..80dfd51 100644 --- a/Modules/FindPhysFS.cmake +++ b/Modules/FindPhysFS.cmake @@ -56,6 +56,6 @@ FIND_LIBRARY(PHYSFS_LIBRARY # handle the QUIETLY and REQUIRED arguments and set PHYSFS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR) diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake index d5aefb9..39a9436 100644 --- a/Modules/FindProducer.cmake +++ b/Modules/FindProducer.cmake @@ -77,6 +77,6 @@ FIND_LIBRARY(PRODUCER_LIBRARY /opt ) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Producer DEFAULT_MSG PRODUCER_LIBRARY PRODUCER_INCLUDE_DIR) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index c9823c2..a6e6653 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -111,7 +111,7 @@ if(WIN32) set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}") endif() -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 3592e4c..46cde43 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -45,7 +45,7 @@ endif() # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE) mark_as_advanced(PYTHON_EXECUTABLE) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 780ffc2..adcec46 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -104,7 +104,7 @@ SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) @@ -151,6 +151,7 @@ FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename) GET_FILENAME_COMPONENT(_name "${_filename}" NAME) STRING(REPLACE "." "_" _name "${_name}") STRING(TOUPPER ${_name} _nameUpper) + SET(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename}) SET(_filenameTmp "${_filename}.in") FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n") diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 1319de2..bacbb07 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -242,7 +242,7 @@ IF (QT_MIN_VERSION) ENDIF (QT_MIN_VERSION) # if the include a library are found then we have it -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3 DEFAULT_MSG QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE) SET(QT_FOUND ${QT3_FOUND} ) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index d9d6ea7..79a3d51 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -447,7 +447,10 @@ MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) ENDMACRO (_QT4_ADJUST_LIB_VARS) function(_QT4_QUERY_QMAKE VAR RESULT) - exec_program(${QT_QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output ) + execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query ${VAR} + RESULT_VARIABLE return_code + OUTPUT_VARIABLE output ERROR_VARIABLE output + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) if(NOT return_code) file(TO_CMAKE_PATH "${output}" output) set(${RESULT} ${output} PARENT_SCOPE) diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake index b86a59f..038c2dd 100644 --- a/Modules/FindQuickTime.cmake +++ b/Modules/FindQuickTime.cmake @@ -43,5 +43,5 @@ ENDIF(APPLE) # handle the QUIETLY and REQUIRED arguments and set QUICKTIME_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(QuickTime DEFAULT_MSG QUICKTIME_LIBRARY QUICKTIME_INCLUDE_DIR) diff --git a/Modules/FindRTI.cmake b/Modules/FindRTI.cmake index b27eaa7..031c138 100644 --- a/Modules/FindRTI.cmake +++ b/Modules/FindRTI.cmake @@ -95,7 +95,7 @@ ENDIF (RTI_INCLUDE_DIR) # Set the modified system variables back to the original value. SET(CMAKE_FIND_LIBRARY_PREFIXES "${RTI_OLD_FIND_LIBRARY_PREFIXES}") -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(RTI DEFAULT_MSG RTI_LIBRARY RTI_INCLUDE_DIR) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 2e78d85..80fb216 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -209,7 +209,7 @@ ENDIF(WIN32) FIND_LIBRARY(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} ) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) SET(_RUBY_REQUIRED_VARS RUBY_EXECUTABLE RUBY_INCLUDE_DIR RUBY_LIBRARY) IF(_RUBY_VERSION_SHORT_NODOT GREATER 18) LIST(APPEND _RUBY_REQUIRED_VARS RUBY_CONFIG_INCLUDE_DIR) diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index 68a913d..2e719ff 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -62,6 +62,6 @@ IF(SWIG_EXECUTABLE) ENDIF(SWIG_swiglib_result) ENDIF(SWIG_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR VERSION_VAR SWIG_VERSION ) diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 3561a19..d8cdacb 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -122,7 +122,7 @@ IF(Subversion_SVN_EXECUTABLE) ENDIF(Subversion_SVN_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion REQUIRED_VARS Subversion_SVN_EXECUTABLE VERSION_VAR Subversion_VERSION_SVN ) diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index b206c9a..13f32f8 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -197,7 +197,7 @@ FIND_PATH(TK_INCLUDE_PATH # handle the QUIETLY and REQUIRED arguments and set TCL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) SET(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED}) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 6f06ff1..714f65f 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -27,7 +27,7 @@ FIND_LIBRARY(TIFF_LIBRARY NAMES ${TIFF_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF DEFAULT_MSG TIFF_LIBRARY TIFF_INCLUDE_DIR) IF(TIFF_FOUND) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 322c3a9..8fde59e 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -84,7 +84,7 @@ FIND_PROGRAM(TCL_TCLSH # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh DEFAULT_MSG TCL_TCLSH) MARK_AS_ADVANCED(TCL_TCLSH) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 4cb7451..a6c2df8 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -153,5 +153,5 @@ IF(CMAKE_USE_PTHREADS_INIT) ENDIF() ENDIF(CMAKE_USE_PTHREADS_INIT) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND) diff --git a/Modules/FindWget.cmake b/Modules/FindWget.cmake index 97c4302..c94132c 100644 --- a/Modules/FindWget.cmake +++ b/Modules/FindWget.cmake @@ -26,7 +26,7 @@ FIND_PROGRAM(WGET_EXECUTABLE # handle the QUIETLY and REQUIRED arguments and set WGET_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Wget DEFAULT_MSG WGET_EXECUTABLE) MARK_AS_ADVANCED( WGET_EXECUTABLE ) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 1ac6c2c..2062a7e 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -35,7 +35,7 @@ FIND_PATH(ZLIB_INCLUDE_DIR zlib.h "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include" ) -SET(ZLIB_NAMES z zlib zdll) +SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1) FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} @@ -66,7 +66,7 @@ ENDIF() # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY VERSION_VAR ZLIB_VERSION_STRING) diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake index 76f202f..0106372 100644 --- a/Modules/Findosg.cmake +++ b/Modules/Findosg.cmake @@ -50,5 +50,5 @@ include(Findosg_functions) OSG_FIND_PATH (OSG osg/PositionAttitudeTransform) OSG_FIND_LIBRARY(OSG osg) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osg DEFAULT_MSG OSG_LIBRARY OSG_INCLUDE_DIR) diff --git a/Modules/FindosgAnimation.cmake b/Modules/FindosgAnimation.cmake index 83e669a..b9b44a0 100644 --- a/Modules/FindosgAnimation.cmake +++ b/Modules/FindosgAnimation.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGANIMATION osgAnimation/Animation) OSG_FIND_LIBRARY(OSGANIMATION osgAnimation) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgAnimation DEFAULT_MSG OSGANIMATION_LIBRARY OSGANIMATION_INCLUDE_DIR) diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake index f1cdfa5..eabdde7 100644 --- a/Modules/FindosgDB.cmake +++ b/Modules/FindosgDB.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGDB osgDB/DatabasePager) OSG_FIND_LIBRARY(OSGDB osgDB) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgDB DEFAULT_MSG OSGDB_LIBRARY OSGDB_INCLUDE_DIR) diff --git a/Modules/FindosgFX.cmake b/Modules/FindosgFX.cmake index 64cbda8..81d5af5 100644 --- a/Modules/FindosgFX.cmake +++ b/Modules/FindosgFX.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGFX osgFX/BumpMapping) OSG_FIND_LIBRARY(OSGFX osgFX) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgFX DEFAULT_MSG OSGFX_LIBRARY OSGFX_INCLUDE_DIR) diff --git a/Modules/FindosgGA.cmake b/Modules/FindosgGA.cmake index 00fc313..a4fe79b 100644 --- a/Modules/FindosgGA.cmake +++ b/Modules/FindosgGA.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGGA osgGA/FlightManipulator) OSG_FIND_LIBRARY(OSGGA osgGA) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgGA DEFAULT_MSG OSGGA_LIBRARY OSGGA_INCLUDE_DIR) diff --git a/Modules/FindosgIntrospection.cmake b/Modules/FindosgIntrospection.cmake index 919523b..24e6ed5 100644 --- a/Modules/FindosgIntrospection.cmake +++ b/Modules/FindosgIntrospection.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGINTROSPECTION osgIntrospection/Reflection) OSG_FIND_LIBRARY(OSGINTROSPECTION osgIntrospection) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgIntrospection DEFAULT_MSG OSGINTROSPECTION_LIBRARY OSGINTROSPECTION_INCLUDE_DIR) diff --git a/Modules/FindosgManipulator.cmake b/Modules/FindosgManipulator.cmake index 93d4bac..f71b5fd 100644 --- a/Modules/FindosgManipulator.cmake +++ b/Modules/FindosgManipulator.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGMANIPULATOR osgManipulator/TrackballDragger) OSG_FIND_LIBRARY(OSGMANIPULATOR osgManipulator) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgManipulator DEFAULT_MSG OSGMANIPULATOR_LIBRARY OSGMANIPULATOR_INCLUDE_DIR) diff --git a/Modules/FindosgParticle.cmake b/Modules/FindosgParticle.cmake index a0d7516..f23a83f 100644 --- a/Modules/FindosgParticle.cmake +++ b/Modules/FindosgParticle.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGPARTICLE osgParticle/FireEffect) OSG_FIND_LIBRARY(OSGPARTICLE osgParticle) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgParticle DEFAULT_MSG OSGPARTICLE_LIBRARY OSGPARTICLE_INCLUDE_DIR) diff --git a/Modules/FindosgProducer.cmake b/Modules/FindosgProducer.cmake index e4e57f3..51f6090 100644 --- a/Modules/FindosgProducer.cmake +++ b/Modules/FindosgProducer.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGPRODUCER osgProducer/OsgSceneHandler) OSG_FIND_LIBRARY(OSGPRODUCER osgProducer) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgProducer DEFAULT_MSG OSGPRODUCER_LIBRARY OSGPRODUCER_INCLUDE_DIR) diff --git a/Modules/FindosgShadow.cmake b/Modules/FindosgShadow.cmake index 86a339c..278f8ae 100644 --- a/Modules/FindosgShadow.cmake +++ b/Modules/FindosgShadow.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGSHADOW osgShadow/ShadowTexture) OSG_FIND_LIBRARY(OSGSHADOW osgShadow) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgShadow DEFAULT_MSG OSGSHADOW_LIBRARY OSGSHADOW_INCLUDE_DIR) diff --git a/Modules/FindosgSim.cmake b/Modules/FindosgSim.cmake index b66a991..15daf64 100644 --- a/Modules/FindosgSim.cmake +++ b/Modules/FindosgSim.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGSIM osgSim/ImpostorSprite) OSG_FIND_LIBRARY(OSGSIM osgSim) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgSim DEFAULT_MSG OSGSIM_LIBRARY OSGSIM_INCLUDE_DIR) diff --git a/Modules/FindosgTerrain.cmake b/Modules/FindosgTerrain.cmake index 04559cf..fbf373e 100644 --- a/Modules/FindosgTerrain.cmake +++ b/Modules/FindosgTerrain.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGTERRAIN osgTerrain/Terrain) OSG_FIND_LIBRARY(OSGTERRAIN osgTerrain) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgTerrain DEFAULT_MSG OSGTERRAIN_LIBRARY OSGTERRAIN_INCLUDE_DIR) diff --git a/Modules/FindosgText.cmake b/Modules/FindosgText.cmake index 6d20336..22f825f 100644 --- a/Modules/FindosgText.cmake +++ b/Modules/FindosgText.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGTEXT osgText/Text) OSG_FIND_LIBRARY(OSGTEXT osgText) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgText DEFAULT_MSG OSGTEXT_LIBRARY OSGTEXT_INCLUDE_DIR) diff --git a/Modules/FindosgUtil.cmake b/Modules/FindosgUtil.cmake index 2faa7d4..05a74df 100644 --- a/Modules/FindosgUtil.cmake +++ b/Modules/FindosgUtil.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGUTIL osgUtil/SceneView) OSG_FIND_LIBRARY(OSGUTIL osgUtil) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgUtil DEFAULT_MSG OSGUTIL_LIBRARY OSGUTIL_INCLUDE_DIR) diff --git a/Modules/FindosgViewer.cmake b/Modules/FindosgViewer.cmake index 30b9926..650dbd7 100644 --- a/Modules/FindosgViewer.cmake +++ b/Modules/FindosgViewer.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGVIEWER osgViewer/Viewer) OSG_FIND_LIBRARY(OSGVIEWER osgViewer) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgViewer DEFAULT_MSG OSGVIEWER_LIBRARY OSGVIEWER_INCLUDE_DIR) diff --git a/Modules/FindosgVolume.cmake b/Modules/FindosgVolume.cmake index f916667..3ad7edc 100644 --- a/Modules/FindosgVolume.cmake +++ b/Modules/FindosgVolume.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGVOLUME osgVolume/Volume) OSG_FIND_LIBRARY(OSGVOLUME osgVolume) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgVolume DEFAULT_MSG OSGVOLUME_LIBRARY OSGVOLUME_INCLUDE_DIR) diff --git a/Modules/FindosgWidget.cmake b/Modules/FindosgWidget.cmake index 5f84873..206a8b7 100644 --- a/Modules/FindosgWidget.cmake +++ b/Modules/FindosgWidget.cmake @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGWIDGET osgWidget/Widget) OSG_FIND_LIBRARY(OSGWIDGET osgWidget) -include(FindPackageHandleStandardArgs) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgWidget DEFAULT_MSG OSGWIDGET_LIBRARY OSGWIDGET_INCLUDE_DIR) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index d991cd4..090259b 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -827,7 +827,7 @@ DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}") #===================================================================== #===================================================================== -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND) # Maintain consistency with all other variables. SET(wxWidgets_FOUND ${WXWIDGETS_FOUND}) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 4564e74..2dfe8b1 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -16,6 +16,12 @@ # libraries are installed as well as the CRT run time libraries. # If CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION is set then the libraries are # installed to that directory rather than the default. +# If CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS is NOT set, then this file +# warns about required files that do not exist. You can set this variable to +# ON before including this file to avoid the warning. For example, the Visual +# Studio Express editions do not include the redistributable files, so if you +# include this file on a machine with only VS Express installed, you'll get +# the warning. #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -33,6 +39,21 @@ IF(MSVC) FILE(TO_CMAKE_PATH "$ENV{SYSTEMROOT}" SYSTEMROOT) + IF(CMAKE_CL_64) + IF(MSVC_VERSION GREATER 1599) + # VS 10 and later: + SET(CMAKE_MSVC_ARCH x64) + ELSE() + # VS 9 and earlier: + SET(CMAKE_MSVC_ARCH amd64) + ENDIF() + ELSE(CMAKE_CL_64) + SET(CMAKE_MSVC_ARCH x86) + ENDIF(CMAKE_CL_64) + + GET_FILENAME_COMPONENT(devenv_dir "${CMAKE_MAKE_PROGRAM}" PATH) + GET_FILENAME_COMPONENT(base_dir "${devenv_dir}/../.." ABSOLUTE) + IF(MSVC70) SET(__install__libs "${SYSTEMROOT}/system32/msvcp70.dll" @@ -47,15 +68,6 @@ IF(MSVC) ) ENDIF(MSVC71) - IF(CMAKE_CL_64) - SET(CMAKE_MSVC_ARCH amd64) - ELSE(CMAKE_CL_64) - SET(CMAKE_MSVC_ARCH x86) - ENDIF(CMAKE_CL_64) - - GET_FILENAME_COMPONENT(devenv_dir "${CMAKE_MAKE_PROGRAM}" PATH) - GET_FILENAME_COMPONENT(base_dir "${devenv_dir}/../.." ABSOLUTE) - IF(MSVC80) # Find the runtime library redistribution directory. FIND_PATH(MSVC80_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT/Microsoft.VC80.CRT.manifest @@ -87,7 +99,6 @@ IF(MSVC) "${MSVC80_CRT_DIR}/msvcr80d.dll" ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - ENDIF(MSVC80) IF(MSVC90) @@ -130,15 +141,14 @@ IF(MSVC) PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/../../VC/redist" "${base_dir}/VC/redist" + "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/VC/redist" + "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio 10.0/VC/redist" ) MARK_AS_ADVANCED(MSVC10_REDIST_DIR) SET(MSVC10_CRT_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT") - # Install the manifest that allows DLLs to be loaded from the - # directory containing the executable. IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) SET(__install__libs - "${MSVC10_CRT_DIR}/Microsoft.VC100.CRT.manifest" "${MSVC10_CRT_DIR}/msvcp100.dll" "${MSVC10_CRT_DIR}/msvcr100.dll" ) @@ -146,9 +156,8 @@ IF(MSVC) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC10_CRT_DIR - "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugCRT") + "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugCRT") SET(__install__libs ${__install__libs} - "${MSVC10_CRT_DIR}/Microsoft.VC100.DebugCRT.manifest" "${MSVC10_CRT_DIR}/msvcp100d.dll" "${MSVC10_CRT_DIR}/msvcr100d.dll" ) @@ -161,11 +170,13 @@ IF(MSVC) "${SYSTEMROOT}/system32/mfc70.dll" ) ENDIF(MSVC70) + IF(MSVC71) SET(__install__libs ${__install__libs} "${SYSTEMROOT}/system32/mfc71.dll" ) ENDIF(MSVC71) + IF(MSVC80) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC80_MFC_DIR @@ -259,7 +270,6 @@ IF(MSVC) SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugMFC") SET(__install__libs ${__install__libs} - "${MSVC10_MFC_DIR}/Microsoft.VC100.DebugMFC.manifest" "${MSVC10_MFC_DIR}/mfc100d.dll" "${MSVC10_MFC_DIR}/mfc100ud.dll" "${MSVC10_MFC_DIR}/mfcm100d.dll" @@ -268,11 +278,8 @@ IF(MSVC) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFC") - # Install the manifest that allows DLLs to be loaded from the - # directory containing the executable. IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) SET(__install__libs ${__install__libs} - "${MSVC10_MFC_DIR}/Microsoft.VC100.MFC.manifest" "${MSVC10_MFC_DIR}/mfc100.dll" "${MSVC10_MFC_DIR}/mfc100u.dll" "${MSVC10_MFC_DIR}/mfcm100.dll" @@ -282,10 +289,7 @@ IF(MSVC) # include the language dll's for vs10 as well as the actuall dll's SET(MSVC10_MFCLOC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFCLOC") - # Install the manifest that allows DLLs to be loaded from the - # directory containing the executable. SET(__install__libs ${__install__libs} - "${MSVC10_MFCLOC_DIR}/Microsoft.VC100.MFCLOC.manifest" "${MSVC10_MFCLOC_DIR}/mfc100chs.dll" "${MSVC10_MFCLOC_DIR}/mfc100cht.dll" "${MSVC10_MFCLOC_DIR}/mfc100enu.dll" @@ -297,7 +301,6 @@ IF(MSVC) "${MSVC10_MFCLOC_DIR}/mfc100kor.dll" ) ENDIF(MSVC10) - ENDIF(CMAKE_INSTALL_MFC_LIBRARIES) FOREACH(lib @@ -306,6 +309,15 @@ IF(MSVC) IF(EXISTS ${lib}) SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib}) + ELSE(EXISTS ${lib}) + IF(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) + MESSAGE(WARNING "system runtime library file does not exist: '${lib}'") + # This warning indicates an incomplete Visual Studio installation + # or a bug somewhere above here in this file. + # If you would like to avoid this warning, fix the real problem, or + # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including + # this file. + ENDIF() ENDIF(EXISTS ${lib}) ENDFOREACH(lib) ENDIF(MSVC) diff --git a/Modules/Platform/SCO_SV.cmake b/Modules/Platform/SCO_SV.cmake index efb7aa0..cbdcb7d 100644 --- a/Modules/Platform/SCO_SV.cmake +++ b/Modules/Platform/SCO_SV.cmake @@ -1,5 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-Kpic -belf") -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Kpic -belf") SET(CMAKE_DL_LIBS "") -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-belf -Wl,-Bexport") INCLUDE(Platform/UnixPaths) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index f183eb4..7722c19 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -158,6 +158,7 @@ SET(SRCS cmDocumentationFormatterText.cxx cmDocumentationFormatterUsage.cxx cmDocumentationSection.cxx + cmDocumentCompileDefinitions.h cmDocumentGeneratorExpressions.h cmDocumentVariables.cxx cmDynamicLoader.cxx diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 7f3e360..e1876b9 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -334,32 +334,35 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) } // Re-adjust the fields according to their place - bool isNewPage; - int i=0; this->NumberOfPages = 1; - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) + if (height > 0) { - cmCacheManager::CacheIterator mit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); - if (mit.IsAtEnd() || - (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) + bool isNewPage; + int i=0; + std::vector<cmCursesCacheEntryComposite*>::iterator it; + for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - continue; - } - int row = (i % height) + 1; - int page = (i / height) + 1; - isNewPage = ( page > 1 ) && ( row == 1 ); + cmCacheManager::CacheIterator mit = + this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); + if (mit.IsAtEnd() || + (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) + { + continue; + } + int row = (i % height) + 1; + int page = (i / height) + 1; + isNewPage = ( page > 1 ) && ( row == 1 ); - if (isNewPage) - { - this->NumberOfPages++; + if (isNewPage) + { + this->NumberOfPages++; + } + (*it)->Label->Move(left, top+row-1, isNewPage); + (*it)->IsNewLabel->Move(left+32, top+row-1, false); + (*it)->Entry->Move(left+33, top+row-1, false); + (*it)->Entry->SetPage(this->NumberOfPages); + i++; } - (*it)->Label->Move(left, top+row-1, isNewPage); - (*it)->IsNewLabel->Move(left+32, top+row-1, false); - (*it)->Entry->Move(left+33, top+row-1, false); - (*it)->Entry->SetPage(this->NumberOfPages); - i++; } // Post the form @@ -786,6 +789,7 @@ void cmCursesMainForm::RemoveEntry(const char* value) const char* val = (*it)->GetValue(); if ( val && !strcmp(value, val) ) { + this->CMakeInstance->UnwatchUnusedCli(value); this->Entries->erase(it); break; } diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 408dbac..c8c4bfa 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -118,8 +118,15 @@ CMakeSetupDialog::CMakeSetupDialog() this, SLOT(doInstallForCommandLine())); #endif QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options")); - this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); + this->SuppressDevWarningsAction = + OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); this->SuppressDevWarningsAction->setCheckable(true); + this->WarnUninitializedAction = + OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)")); + this->WarnUninitializedAction->setCheckable(true); + this->WarnUnusedAction = + OptionsMenu->addAction(tr("&Warn Unused (--warn-unused-vars)")); + this->WarnUnusedAction->setCheckable(true); QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output")); debugAction->setCheckable(true); @@ -247,6 +254,13 @@ void CMakeSetupDialog::initialize() QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool))); + QObject::connect(this->WarnUninitializedAction, SIGNAL(triggered(bool)), + this->CMakeThread->cmakeInstance(), + SLOT(setWarnUninitializedMode(bool))); + QObject::connect(this->WarnUnusedAction, SIGNAL(triggered(bool)), + this->CMakeThread->cmakeInstance(), + SLOT(setWarnUnusedMode(bool))); + if(!this->SourceDirectory->text().isEmpty() || !this->BinaryDirectory->lineEdit()->text().isEmpty()) { diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 1934795..5121759 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -97,6 +97,8 @@ protected: QAction* ConfigureAction; QAction* GenerateAction; QAction* SuppressDevWarningsAction; + QAction* WarnUninitializedAction; + QAction* WarnUnusedAction; QAction* InstallForCommandLineAction; State CurrentState; diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index dc31fad..a40a175 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -28,6 +28,8 @@ QCMake::QCMake(QObject* p) : QObject(p) { this->SuppressDevWarnings = false; + this->WarnUninitializedMode = false; + this->WarnUnusedMode = false; qRegisterMetaType<QCMakeProperty>(); qRegisterMetaType<QCMakePropertyList>(); @@ -164,6 +166,8 @@ void QCMake::configure() this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data())); this->CMakeInstance->LoadCache(); this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings); + this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); + this->CMakeInstance->SetWarnUnused(this->WarnUnusedMode); this->CMakeInstance->PreLoadCMakeFiles(); cmSystemTools::ResetErrorOccuredFlag(); @@ -238,12 +242,16 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) // remove some properites foreach(QString s, toremove) { + this->CMakeInstance->UnwatchUnusedCli(s.toAscii().data()); + cachem->RemoveCacheEntry(s.toAscii().data()); } // add some new properites foreach(QCMakeProperty s, props) { + this->CMakeInstance->WatchUnusedCli(s.Key.toAscii().data()); + if(s.Type == QCMakeProperty::BOOL) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), @@ -417,3 +425,13 @@ void QCMake::setSuppressDevWarnings(bool value) { this->SuppressDevWarnings = value; } + +void QCMake::setWarnUninitializedMode(bool value) +{ + this->WarnUninitializedMode = value; +} + +void QCMake::setWarnUnusedMode(bool value) +{ + this->WarnUnusedMode = value; +} diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index bbfb3d7..0d10823 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -88,6 +88,10 @@ public slots: void setDebugOutput(bool); /// set whether to do suppress dev warnings void setSuppressDevWarnings(bool value); + /// set whether to run cmake with warnings about uninitialized variables + void setWarnUninitializedMode(bool value); + /// set whether to run cmake with warnings about unused variables + void setWarnUnusedMode(bool value); public: /// get the list of cache properties @@ -133,6 +137,9 @@ protected: static void errorCallback(const char* msg, const char* title, bool&, void* cd); bool SuppressDevWarnings; + bool WarnUninitializedMode; + bool WarnUnusedMode; + bool WarnUnusedAllMode; QString SourceDirectory; QString BinaryDirectory; QString Generator; diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 11ca9e7..a9165f5 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -170,7 +170,10 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args) cmTest* test = this->Makefile->CreateTest(name.c_str()); test->SetOldStyle(false); test->SetCommand(command); - test->SetProperty("WORKING_DIRECTORY", working_directory.c_str()); + if(!working_directory.empty()) + { + test->SetProperty("WORKING_DIRECTORY", working_directory.c_str()); + } this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations)); return true; diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 234c37e..a781767 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -20,6 +20,8 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner ); // cmCommandArgumentParserHelper::cmCommandArgumentParserHelper() { + this->WarnUninitialized = false; + this->CheckSystemVars = false; this->FileLine = -1; this->FileName = 0; this->RemoveEmpty = true; @@ -119,10 +121,32 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) cmOStringStream ostr; ostr << this->FileLine; return this->AddString(ostr.str().c_str()); - } + } const char* value = this->Makefile->GetDefinition(var); if(!value && !this->RemoveEmpty) { + // check to see if we need to print a warning + // if strict mode is on and the variable has + // not been "cleared"/initialized with a set(foo ) call + if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) + { + if (this->CheckSystemVars || + cmSystemTools::IsSubDirectory(this->FileName, + this->Makefile->GetHomeDirectory()) || + cmSystemTools::IsSubDirectory(this->FileName, + this->Makefile->GetHomeOutputDirectory())) + { + cmOStringStream msg; + cmListFileBacktrace bt; + cmListFileContext lfc; + lfc.FilePath = this->FileName; + lfc.Line = this->FileLine; + bt.push_back(lfc); + msg << "uninitialized variable \'" << var << "\'"; + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, + msg.str().c_str(), bt); + } + } return 0; } if (this->EscapeQuotes && value) @@ -319,6 +343,8 @@ void cmCommandArgumentParserHelper::Error(const char* str) void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf) { this->Makefile = mf; + this->WarnUninitialized = mf->GetCMakeInstance()->GetWarnUninitialized(); + this->CheckSystemVars = mf->GetCMakeInstance()->GetCheckSystemVars(); } void cmCommandArgumentParserHelper::SetResult(const char* value) diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index 62cbc80..a211e95 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -96,6 +96,8 @@ private: const cmMakefile* Makefile; std::string Result; const char* FileName; + bool WarnUninitialized; + bool CheckSystemVars; long FileLine; bool EscapeQuotes; std::string ErrorString; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 0fe64ad..96a214e 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -1,6 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium Distributed under the OSI-approved BSD License (the "License"); see accompanying file Copyright.txt for details. @@ -56,7 +56,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { if ( argv.size() <= (i+1) ) { - cmSystemTools::Error( + this->Makefile->IssueMessage(cmake::FATAL_ERROR, "OUTPUT_VARIABLE specified but there is no variable"); return -1; } @@ -92,7 +92,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { if ( argv.size() <= (i+1) ) { - cmSystemTools::Error( + this->Makefile->IssueMessage(cmake::FATAL_ERROR, "COPY_FILE specified but there is no variable"); return -1; } @@ -120,13 +120,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) // only valid for srcfile signatures if (compileFlags.size()) { - cmSystemTools::Error( + this->Makefile->IssueMessage(cmake::FATAL_ERROR, "COMPILE_FLAGS specified on a srcdir type TRY_COMPILE"); return -1; } if (copyFile.size()) { - cmSystemTools::Error("COPY_FILE specified on a srcdir type TRY_COMPILE"); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE specified on a srcdir type TRY_COMPILE"); return -1; } } @@ -136,9 +137,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) // do not allow recursive try Compiles if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) { - cmSystemTools::Error( - "Attempt at a recursive or nested TRY_COMPILE in directory ", - this->BinaryDirectory.c_str()); + cmOStringStream e; + e << "Attempt at a recursive or nested TRY_COMPILE in directory\n" + << " " << this->BinaryDirectory << "\n"; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return -1; } @@ -158,14 +160,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) FILE *fout = fopen(outFileName.c_str(),"w"); if (!fout) { - cmSystemTools::Error("Failed to create CMakeList file for ", - outFileName.c_str()); - cmSystemTools::ReportLastSystemError(""); + cmOStringStream e; + e << "Failed to open\n" + << " " << outFileName.c_str() << "\n" + << cmSystemTools::GetLastSystemError(); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return -1; } std::string source = argv[2]; - std::string ext = cmSystemTools::GetFilenameExtension(source); + std::string ext = cmSystemTools::GetFilenameLastExtension(source); const char* lang =(this->Makefile->GetCMakeInstance()->GetGlobalGenerator() ->GetLanguageFromExtension(ext.c_str())); const char* def = this->Makefile->GetDefinition("CMAKE_MODULE_PATH"); @@ -199,10 +203,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } else { + fclose(fout); cmOStringStream err; - err << "Unknown extension \"" << ext << "\" for file \"" - << source << "\". TRY_COMPILE only works for enabled languages.\n" - << "Currently enabled languages are:"; + err << "Unknown extension \"" << ext << "\" for file\n" + << " " << source << "\n" + << "try_compile() works only for enabled languages. " + << "Currently these are:\n "; std::vector<std::string> langs; this->Makefile->GetCMakeInstance()->GetGlobalGenerator()-> GetEnabledLanguages(langs); @@ -211,9 +217,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { err << " " << *l; } - err << "\nSee PROJECT command for help enabling other languages."; - cmSystemTools::Error(err.str().c_str()); - fclose(fout); + err << "\nSee project() command to enable other languages."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str()); return -1; } std::string langFlags = "CMAKE_"; @@ -246,10 +251,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) CMAKE_TRY_COMPILE_OSX_ARCHITECTURE first to i386 and then to ppc to have the tests run for each specific architecture. Since cmLocalGenerator doesn't allow building for "the other" - architecture only via CMAKE_OSX_ARCHITECTURES,use to CMAKE_DO_TRY_COMPILE - to enforce it for this case here. + architecture only via CMAKE_OSX_ARCHITECTURES. */ - cmakeFlags.push_back("-DCMAKE_DO_TRY_COMPILE=TRUE"); if(this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_OSX_ARCHITECTURES")!=0) { std::string flag="-DCMAKE_OSX_ARCHITECTURES="; @@ -278,6 +281,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) cmakeFlags.push_back(flag); } + /* Put the executable at a known location (for COPY_FILE). */ + fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", + this->BinaryDirectory.c_str()); + /* Create the actual executable. */ fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str()); fprintf(fout, "TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n"); @@ -340,17 +347,15 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) copyFile.c_str())) { cmOStringStream emsg; - emsg << "Could not COPY_FILE.\n" - << " OutputFile: '" << this->OutputFile.c_str() << "'\n" - << " copyFile: '" << copyFile.c_str() << "'\n"; - - if (this->FindErrorMessage.size()) + emsg << "Cannot copy output executable\n" + << " '" << this->OutputFile.c_str() << "'\n" + << "to destination specified by COPY_FILE:\n" + << " '" << copyFile.c_str() << "'\n"; + if(!this->FindErrorMessage.empty()) { - emsg << "\n"; - emsg << this->FindErrorMessage.c_str() << "\n"; + emsg << this->FindErrorMessage.c_str(); } - - cmSystemTools::Error(emsg.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); return -1; } } @@ -457,18 +462,11 @@ void cmCoreTryCompile::FindOutputFile(const char* targetName) } cmOStringStream emsg; - emsg << "Unable to find executable for " << this->GetName() << ": tried \""; + emsg << "Unable to find the executable at any of:\n"; for (unsigned int i = 0; i < searchDirs.size(); ++i) { - emsg << this->BinaryDirectory << searchDirs[i] << tmpOutputFile; - if (i < searchDirs.size() - 1) - { - emsg << "\" and \""; - } - else - { - emsg << "\"."; - } + emsg << " " << this->BinaryDirectory << searchDirs[i] + << tmpOutputFile << "\n"; } this->FindErrorMessage = emsg.str(); return; diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 2d40718..9d28700 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -85,6 +85,22 @@ const char* cmDefinitions::Set(const char* key, const char* value) } //---------------------------------------------------------------------------- +std::set<cmStdString> cmDefinitions::LocalKeys() const +{ + std::set<cmStdString> keys; + // Consider local definitions. + for(MapType::const_iterator mi = this->Map.begin(); + mi != this->Map.end(); ++mi) + { + if (mi->second.Exists) + { + keys.insert(mi->first); + } + } + return keys; +} + +//---------------------------------------------------------------------------- cmDefinitions cmDefinitions::Closure() const { return cmDefinitions(ClosureTag(), this); diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index e385e88..4834d84 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -40,6 +40,9 @@ public: /** Set (or unset if null) a value associated with a key. */ const char* Set(const char* key, const char* value); + /** Get the set of all local keys. */ + std::set<cmStdString> LocalKeys() const; + /** Compute the closure of all defined keys with values. This flattens the scope. The result has no parent. */ cmDefinitions Closure() const; diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 942cb3f..a76b3af 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -448,6 +448,7 @@ void cmDependsC::Scan(std::istream& is, const char* directory, // Get the file being included. UnscannedEntry entry; entry.FileName = this->IncludeRegexLine.match(2); + cmSystemTools::ConvertToUnixSlashes(entry.FileName); if(this->IncludeRegexLine.match(3) == "\"" && !cmSystemTools::FileIsFullPath(entry.FileName.c_str())) { diff --git a/Source/cmDocumentCompileDefinitions.h b/Source/cmDocumentCompileDefinitions.h new file mode 100644 index 0000000..ef3b3e7 --- /dev/null +++ b/Source/cmDocumentCompileDefinitions.h @@ -0,0 +1,34 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmDocumentCompileDefinitions_h +#define cmDocumentCompileDefinitions_h + +#define CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER \ + "Disclaimer: Most native build tools have poor support for escaping " \ + "certain values. CMake has work-arounds for many cases but some " \ + "values may just not be possible to pass correctly. If a value " \ + "does not seem to be escaped correctly, do not attempt to " \ + "work-around the problem by adding escape sequences to the value. " \ + "Your work-around may break in a future version of CMake that " \ + "has improved escape support. Instead consider defining the macro " \ + "in a (configured) header file. Then report the limitation. " \ + "Known limitations include:\n" \ + " # - broken almost everywhere\n" \ + " ; - broken in VS IDE and Borland Makefiles\n" \ + " , - broken in VS IDE\n" \ + " % - broken in some cases in NMake\n" \ + " & | - broken in some cases on MinGW\n" \ + " ^ < > \\\" - broken in most Make tools on Windows\n" \ + "CMake does not reject these values outright because they do work " \ + "in some cases. Use with caution. " + +#endif diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 5dfa64e..6fffecb 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -696,13 +696,29 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cm->DefineProperty ("CMAKE_USER_MAKE_RULES_OVERRIDE", cmProperty::VARIABLE, - "Specify a file that can change the build rule variables.", - "If this variable is set, it should to point to a " - "CMakeLists.txt file that will be read in by CMake " - "after all the system settings have been set, but " - "before they have been used. This would allow you " - "to override any variables that need to be changed " - "for some special project. ",false, + "Specify a CMake file that overrides platform information.", + "CMake loads the specified file while enabling support for each " + "language from either the project() or enable_language() commands. " + "It is loaded after CMake's builtin compiler and platform information " + "modules have been loaded but before the information is used. " + "The file may set platform information variables to override CMake's " + "defaults." + "\n" + "This feature is intended for use only in overriding information " + "variables that must be set before CMake builds its first test " + "project to check that the compiler for a language works. " + "It should not be used to load a file in cases that a normal include() " + "will work. " + "Use it only as a last resort for behavior that cannot be achieved " + "any other way. " + "For example, one may set CMAKE_C_FLAGS_INIT to change the default " + "value used to initialize CMAKE_C_FLAGS before it is cached. " + "The override file should NOT be used to set anything that could " + "be set after languages are enabled, such as variables like " + "CMAKE_RUNTIME_OUTPUT_DIRECTORY that affect the placement of binaries. " + "Information set in the file will be used for try_compile and try_run " + "builds too." + ,false, "Variables That Change Behavior"); cm->DefineProperty @@ -1121,6 +1137,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "this variable for a target if they are set. " "Library targets are otherwise placed in this directory.",false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_TRY_COMPILE_CONFIGURATION", cmProperty::VARIABLE, + "Build configuration used for try_compile and try_run projects.", + "Projects built by try_compile and try_run are built " + "synchronously during the CMake configuration step. " + "Therefore a specific build configuration must be chosen even " + "if the generated build system supports multiple configurations.",false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will @@ -1130,13 +1154,10 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cm->DefineProperty ("CMAKE_USER_MAKE_RULES_OVERRIDE_<LANG>", cmProperty::VARIABLE, - "Specify a file that can change the build rule variables.", - "If this variable is set, it should to point to a " - "CMakeLists.txt file that will be read in by CMake " - "after all the system settings have been set, but " - "before they have been used. This would allow you " - "to override any variables that need to be changed " - "for some language. ",false, + "Specify a CMake file that overrides platform information for <LANG>.", + "This is a language-specific version of " + "CMAKE_USER_MAKE_RULES_OVERRIDE loaded only when enabling " + "language <LANG>.",false, "Variables for Languages"); cm->DefineProperty diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index b05642e..ec4fd16 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -113,6 +113,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass cmOStringStream strStream; strStream << expandedArgs.size(); this->Makefile->AddDefinition("ARGC",strStream.str().c_str()); + this->Makefile->MarkVariableAsUsed("ARGC"); // set the values for ARGV0 ARGV1 ... for (unsigned int t = 0; t < expandedArgs.size(); ++t) @@ -121,6 +122,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass tmpStream << "ARGV" << t; this->Makefile->AddDefinition(tmpStream.str().c_str(), expandedArgs[t].c_str()); + this->Makefile->MarkVariableAsUsed(tmpStream.str().c_str()); } // define the formal arguments @@ -153,7 +155,9 @@ bool cmFunctionHelperCommand::InvokeInitialPass cnt ++; } this->Makefile->AddDefinition("ARGV", argvDef.c_str()); + this->Makefile->MarkVariableAsUsed("ARGV"); this->Makefile->AddDefinition("ARGN", argnDef.c_str()); + this->Makefile->MarkVariableAsUsed("ARGN"); // Invoke all the functions that were collected in the block. // for each function diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index c78671e..d82be70 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -54,11 +54,14 @@ public: { return " get_cmake_property(VAR property)\n" - "Get a property from the CMake instance. The value of the " - "property is stored in the variable VAR. If the property is " - "not found, CMake will report an error. Some supported properties " + "Get a property from the CMake instance. " + "The value of the property is stored in the variable VAR. " + "If the property is not found, VAR will be set to \"NOTFOUND\". " + "Some supported properties " "include: VARIABLES, CACHE_VARIABLES, COMMANDS, MACROS, and " - "COMPONENTS."; + "COMPONENTS." + "\n" + "See also the more general get_property() command."; } cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h index c3a23a3..b7a5f71 100644 --- a/Source/cmGetDirectoryPropertyCommand.h +++ b/Source/cmGetDirectoryPropertyCommand.h @@ -66,7 +66,8 @@ public: "Get a variable definition from a directory. " "This form is useful to get a variable definition from another " "directory." - ; + "\n" + "See also the more general get_property() command."; } cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand); diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index c1d5e11..56469f8 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -53,7 +53,9 @@ public: "stored in the variable VAR. If the property is not found, VAR " "will be set to \"NOTFOUND\". Use set_source_files_properties to set " "property values. Source file properties usually control how the " - "file is built. One property that is always there is LOCATION"; + "file is built. One property that is always there is LOCATION" + "\n" + "See also the more general get_property() command."; } cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand); diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index e1984c3..71c75ef 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -55,7 +55,9 @@ public: "property values. Properties are usually used to control how " "a target is built, but some query the target instead. " "This command can get properties for any target so far created. " - "The targets do not need to be in the current CMakeLists.txt file."; + "The targets do not need to be in the current CMakeLists.txt file." + "\n" + "See also the more general get_property() command."; } cmTypeMacro(cmGetTargetPropertyCommand, cmCommand); diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index 956cf55..d9f5d9b 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -48,11 +48,13 @@ public: virtual const char* GetFullDocumentation() { return - " get_test_property(test VAR property)\n" - "Get a property from the Test. The value of the property is " - "stored in the variable VAR. If the property is not found, " - "CMake will report an error. For a list of standard properties " - "you can type cmake --help-property-list"; + " get_test_property(test property VAR)\n" + "Get a property from the Test. The value of the property is " + "stored in the variable VAR. If the property is not found, VAR " + "will be set to \"NOTFOUND\". For a list of standard properties " + "you can type cmake --help-property-list" + "\n" + "See also the more general get_property() command."; } cmTypeMacro(cmGetTestPropertyCommand, cmCommand); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 123ab5e..d47fb6f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -56,6 +56,7 @@ cmGlobalGenerator::cmGlobalGenerator() this->ExtraGenerator = 0; this->CurrentLocalGenerator = 0; + this->TryCompileOuterMakefile = 0; } cmGlobalGenerator::~cmGlobalGenerator() @@ -199,6 +200,34 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, cmSystemTools::SetFatalErrorOccured(); return; } + + if(this->TryCompileOuterMakefile) + { + // In a try-compile we can only enable languages provided by caller. + for(std::vector<std::string>::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + if(*li == "NONE") + { + this->SetLanguageEnabled("NONE", mf); + } + else + { + const char* lang = li->c_str(); + if(this->LanguagesReady.find(lang) == this->LanguagesReady.end()) + { + cmOStringStream e; + e << "The test project needs language " + << lang << " which is not enabled."; + this->TryCompileOuterMakefile + ->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return; + } + } + } + } + mf->AddDefinition("RUN_CONFIGURE", true); std::string rootBin = mf->GetHomeOutputDirectory(); rootBin += cmake::GetCMakeFilesDirectory(); @@ -208,15 +237,6 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, // files from the parent cmake bin dir, into the try compile bin dir if(this->ConfiguredFilesPath.size()) { - for(std::vector<std::string>::const_iterator l = languages.begin(); - l != languages.end(); ++l) - { - if(*l == "NONE") - { - this->SetLanguageEnabled("NONE", mf); - break; - } - } rootBin = this->ConfiguredFilesPath; } @@ -421,6 +441,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { this->SetLanguageEnabledMaps(lang, mf); } + this->LanguagesReady.insert(lang); std::string compilerName = "CMAKE_"; compilerName += lang; @@ -882,6 +903,8 @@ void cmGlobalGenerator::Generate() } this->CMakeInstance->UpdateProgress("Generating done", -1); + + this->CMakeInstance->RunCheckForUnusedVariables("generation"); } //---------------------------------------------------------------------------- @@ -1333,9 +1356,11 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator() return lg; } -void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen ) +void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, + cmMakefile* mf) { this->SetConfiguredFilesPath(gen); + this->TryCompileOuterMakefile = mf; const char* make = gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make, @@ -1343,6 +1368,7 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen ) cmCacheManager::FILEPATH); // copy the enabled languages this->LanguageEnabled = gen->LanguageEnabled; + this->LanguagesReady = gen->LanguagesReady; this->ExtensionToLanguage = gen->ExtensionToLanguage; this->IgnoreExtensions = gen->IgnoreExtensions; this->LanguageToOutputExtension = gen->LanguageToOutputExtension; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 6a1aa53..5268731 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -79,7 +79,8 @@ public: /** * Try to determine system infomation, get it from another generator */ - virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen); + virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen, + cmMakefile* mf); /** * Try running cmake and building a file. This is used for dynalically @@ -325,11 +326,13 @@ protected: virtual bool UseFolderProperty(); private: + cmMakefile* TryCompileOuterMakefile; float FirstTimeProgress; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator std::map<cmStdString, bool> IgnoreExtensions; std::map<cmStdString, bool> LanguageEnabled; + std::set<cmStdString> LanguagesReady; // Ready for try_compile std::map<cmStdString, cmStdString> OutputExtensions; std::map<cmStdString, cmStdString> LanguageToOutputExtension; std::map<cmStdString, cmStdString> ExtensionToLanguage; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0b939af..6c3c1ed 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -114,18 +114,23 @@ std::string cmGlobalVisualStudio10Generator ::GenerateBuildCommand(const char* makeProgram, const char *projectName, const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool) + const char* config, bool ignoreErrors, bool fast) { - // Ingoring errors is not implemented in visual studio 6 - (void) ignoreErrors; - - // now build the test std::string makeCommand = cmSystemTools::ConvertToOutputPath(makeProgram); std::string lowerCaseCommand = makeCommand; cmSystemTools::LowerCase(lowerCaseCommand); + // If makeProgram is devenv, parent class knows how to generate command: + if (lowerCaseCommand.find("devenv") != std::string::npos) + { + return cmGlobalVisualStudio7Generator::GenerateBuildCommand(makeProgram, + projectName, additionalOptions, targetName, config, ignoreErrors, fast); + } + + // Otherwise, assume MSBuild command line, and construct accordingly. + // if there are spaces in the makeCommand, assume a full path // and convert it to a path with no spaces in it as the // RunSingleCommand does not like spaces diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 59ca38f..358721f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -355,7 +355,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmCustomCommandLines commandLines; commandLines.push_back(makecommand); // Add Re-Run CMake rules - this->CreateReRunCMakeFile(root); + this->CreateReRunCMakeFile(root, gens); // now make the allbuild depend on all the non-utility targets // in the project @@ -403,10 +403,18 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root) +void cmGlobalXCodeGenerator::CreateReRunCMakeFile( + cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens) { cmMakefile* mf = root->GetMakefile(); - std::vector<std::string> lfiles = mf->GetListFiles(); + std::vector<std::string> lfiles; + for(std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin(); + gi != gens.end(); ++gi) + { + std::vector<std::string> const& lf = (*gi)->GetMakefile()->GetListFiles(); + lfiles.insert(lfiles.end(), lf.begin(), lf.end()); + } + // sort the array std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>()); std::vector<std::string>::iterator new_end = @@ -1279,6 +1287,9 @@ void cmGlobalXCodeGenerator makefileStream << "# Generated by CMake, DO NOT EDIT\n"; makefileStream << "# Custom rules for " << target.GetName() << "\n"; + // disable the implicit rules + makefileStream << ".SUFFIXES: " << "\n"; + // have all depend on all outputs makefileStream << "all: "; std::map<const cmCustomCommand*, cmStdString> tname; @@ -2682,7 +2693,7 @@ void cmGlobalXCodeGenerator this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); const char* osxArch = this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); - if(strlen(osxArch) == 0) + if(!osxArch || strlen(osxArch) == 0) { if(this->XcodeVersion >= 32) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index b4de805..290532a 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -171,7 +171,8 @@ private: const char* name2, cmTarget& cmtarget, const std::vector<cmCustomCommand>&); - void CreateReRunCMakeFile(cmLocalGenerator* root); + void CreateReRunCMakeFile(cmLocalGenerator* root, + std::vector<cmLocalGenerator*> const& gens); std::string LookupFlags(const char* varNamePrefix, const char* varNameLang, diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 107a892..4996bc4 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -125,10 +125,13 @@ public: "True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. " "False if the constant is 0, OFF, NO, FALSE, N, IGNORE, \"\", " "or ends in the suffix '-NOTFOUND'. " - "Named boolean constants are case-insensitive." + "Named boolean constants are case-insensitive. " + "If the argument is not one of these constants, " + "it is treated as a variable:" "\n" " if(<variable>)\n" - "True if the variable's value is not a false constant." + "True if the variable is defined to a value that is not a false " + "constant. False otherwise. " "\n" " if(NOT <expression>)\n" "True if the expression is not true." @@ -163,32 +166,25 @@ public: "Behavior is well-defined only for full paths.\n" " if(IS_ABSOLUTE path)\n" "True if the given path is an absolute path.\n" - " if(variable MATCHES regex)\n" - " if(string MATCHES regex)\n" + " if(<variable|string> MATCHES regex)\n" "True if the given string or variable's value matches the given " "regular expression.\n" - " if(variable LESS number)\n" - " if(string LESS number)\n" - " if(variable GREATER number)\n" - " if(string GREATER number)\n" - " if(variable EQUAL number)\n" - " if(string EQUAL number)\n" + " if(<variable|string> LESS <variable|string>)\n" + " if(<variable|string> GREATER <variable|string>)\n" + " if(<variable|string> EQUAL <variable|string>)\n" "True if the given string or variable's value is a valid number and " "the inequality or equality is true.\n" - " if(variable STRLESS string)\n" - " if(string STRLESS string)\n" - " if(variable STRGREATER string)\n" - " if(string STRGREATER string)\n" - " if(variable STREQUAL string)\n" - " if(string STREQUAL string)\n" + " if(<variable|string> STRLESS <variable|string>)\n" + " if(<variable|string> STRGREATER <variable|string>)\n" + " if(<variable|string> STREQUAL <variable|string>)\n" "True if the given string or variable's value is lexicographically " "less (or greater, or equal) than the string or variable on the right.\n" - " if(version1 VERSION_LESS version2)\n" - " if(version1 VERSION_EQUAL version2)\n" - " if(version1 VERSION_GREATER version2)\n" + " if(<variable|string> VERSION_LESS <variable|string>)\n" + " if(<variable|string> VERSION_EQUAL <variable|string>)\n" + " if(<variable|string> VERSION_GREATER <variable|string>)\n" "Component-wise integer version number comparison (version format is " "major[.minor[.patch[.tweak]]]).\n" - " if(DEFINED variable)\n" + " if(DEFINED <variable>)\n" "True if the given variable is defined. It does not matter if the " "variable is true or false just if it has been set.\n" " if((expression) AND (expression OR (expression)))\n" @@ -199,38 +195,27 @@ public: "that contains them." "\n" - "The if statement was written fairly early in CMake's history " - "and it has some convenience features that are worth covering. " - "The if statement reduces operations until there is " - "a single remaining value, at that point if the case " - "insensitive value is: ON, 1, YES, TRUE, Y it returns true, if " - "it is OFF, 0, NO, FALSE, N, NOTFOUND, *-NOTFOUND, IGNORE it " - "will return false. \n" - - "This is fairly reasonable. The convenience feature that sometimes " - "throws new authors is how CMake handles values that do not " - "match the true or false list. Those values are treated as " - "variables and are dereferenced even though they do not have " - "the required ${} syntax. This means that if you write\n" - - " if (boobah)\n" - - "CMake will treat it as if you wrote \n" - - " if (${boobah})\n" - - "likewise if you write \n" - - " if (fubar AND sol)\n" - - "CMake will conveniently treat it as \n" - - " if (\"${fubar}\" AND \"${sol}\")\n" - - "The later is really the correct way to write it, but the " - "former will work as well. Only some operations in the if " - "statement have this special handling of arguments. The " - "specific details follow: \n" + "The if command was written very early in CMake's history, predating " + "the ${} variable evaluation syntax, and for convenience evaluates " + "variables named by its arguments as shown in the above signatures. " + "Note that normal variable evaluation with ${} applies before the " + "if command even receives the arguments. " + "Therefore code like\n" + " set(var1 OFF)\n" + " set(var2 \"var1\")\n" + " if(${var2})\n" + "appears to the if command as\n" + " if(var1)\n" + "and is evaluated according to the if(<variable>) case " + "documented above. " + "The result is OFF which is false. " + "However, if we remove the ${} from the example then the command sees\n" + " if(var2)\n" + "which is true because var2 is defined to \"var1\" which is not " + "a false constant." + "\n" + "Automatic evaluation applies in the other cases whenever the " + "above-documented signature accepts <variable|string>:\n" "1) The left hand argument to MATCHES is first checked to see " "if it is a defined variable, if so the variable's value is " diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 21f6460..e839ed3 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -755,7 +755,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } fout << "\"\n"; targetOptions.OutputFlagMap(fout, "\t\t\t\t"); - targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n"); + targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n"; fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; if(targetBuilds) @@ -789,7 +789,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } // add the -D flags to the RC tool fout << "\""; - targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", ""); + targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC"); fout << "/>\n"; tool = "VCMIDLTool"; if(this->FortranProject) @@ -1462,6 +1462,7 @@ void cmLocalVisualStudio7Generator else if(!fcinfo.FileConfigMap.empty()) { const char* aCompilerTool = "VCCLCompilerTool"; + const char* lang = "CXX"; if(this->FortranProject) { aCompilerTool = "VFFortranCompilerTool"; @@ -1479,6 +1480,7 @@ void cmLocalVisualStudio7Generator if(ext == "rc") { aCompilerTool = "VCResourceCompilerTool"; + lang = "RC"; if(this->FortranProject) { aCompilerTool = "VFResourceCompilerTool"; @@ -1520,7 +1522,8 @@ void cmLocalVisualStudio7Generator fileOptions.OutputAdditionalOptions(fout, "\t\t\t\t\t", "\n"); fileOptions.OutputFlagMap(fout, "\t\t\t\t\t"); fileOptions.OutputPreprocessorDefinitions(fout, - "\t\t\t\t\t", "\n"); + "\t\t\t\t\t", "\n", + lang); } if(!fc.AdditionalDeps.empty()) { @@ -1706,6 +1709,22 @@ void cmLocalVisualStudio7Generator event.Finish(); } +void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout, + cmTarget& target) +{ + // if we have all the required Source code control tags + // then add that to the project + const char* vsProjectname = target.GetProperty("VS_SCC_PROJECTNAME"); + const char* vsLocalpath = target.GetProperty("VS_SCC_LOCALPATH"); + const char* vsProvider = target.GetProperty("VS_SCC_PROVIDER"); + if(vsProvider && vsLocalpath && vsProjectname) + { + fout << "\tSccProjectName=\"" << vsProjectname << "\"\n" + << "\tSccLocalPath=\"" << vsLocalpath << "\"\n" + << "\tSccProvider=\"" << vsProvider << "\"\n"; + } +} + void cmLocalVisualStudio7Generator ::WriteProjectStartFortran(std::ostream& fout, @@ -1773,6 +1792,7 @@ cmLocalVisualStudio7Generator { fout << "\tProjectType=\"" << projectType << "\"\n"; } + this->WriteProjectSCC(fout, target); fout<< "\tKeyword=\"" << keyword << "\">\n" << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n" << "\t<Platforms>\n" @@ -1813,9 +1833,6 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, { keyword = "Win32Proj"; } - const char* vsProjectname = target.GetProperty("VS_SCC_PROJECTNAME"); - const char* vsLocalpath = target.GetProperty("VS_SCC_LOCALPATH"); - const char* vsProvider = target.GetProperty("VS_SCC_PROVIDER"); cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; @@ -1823,14 +1840,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, { fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; } - // if we have all the required Source code control tags - // then add that to the project - if(vsProvider && vsLocalpath && vsProjectname) - { - fout << "\tSccProjectName=\"" << vsProjectname << "\"\n" - << "\tSccLocalPath=\"" << vsLocalpath << "\"\n" - << "\tSccProvider=\"" << vsProvider << "\"\n"; - } + this->WriteProjectSCC(fout, target); fout << "\tKeyword=\"" << keyword << "\">\n" << "\t<Platforms>\n" << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n" diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 19f7b97..160e2d4 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -102,6 +102,7 @@ private: cmTarget& t, bool debug); void OutputLibraryDirectories(std::ostream& fout, std::vector<std::string> const& dirs); + void WriteProjectSCC(std::ostream& fout, cmTarget& target); void WriteProjectStart(std::ostream& fout, const char *libName, cmTarget &tgt, std::vector<cmSourceGroup> &sgs); void WriteProjectStartFortran(std::ostream& fout, const char *libName, diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 497949a..774f32b 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -31,6 +31,7 @@ public: // we must copy when we clone newC->Args = this->Args; newC->Functions = this->Functions; + newC->FilePath = this->FilePath; newC->Policies = this->Policies; return newC; } @@ -78,6 +79,7 @@ public: std::vector<std::string> Args; std::vector<cmListFileFunction> Functions; cmPolicies::PolicyMap Policies; + std::string FilePath; }; @@ -121,7 +123,10 @@ bool cmMacroHelperCommand::InvokeInitialPass std::string argnDef; bool argnDefInitialized = false; bool argvDefInitialized = false; - + if( this->Functions.size()) + { + this->FilePath = this->Functions[0].FilePath; + } // Invoke all the functions that were collected in the block. cmListFileFunction newLFF; // for each function @@ -135,10 +140,13 @@ bool cmMacroHelperCommand::InvokeInitialPass newLFF.Line = this->Functions[c].Line; // for each argument of the current function - for (std::vector<cmListFileArgument>::const_iterator k = + for (std::vector<cmListFileArgument>::iterator k = this->Functions[c].Arguments.begin(); k != this->Functions[c].Arguments.end(); ++k) { + // Set the FilePath on the arguments to match the function since it is + // not stored and the original values may be freed + k->FilePath = this->FilePath.c_str(); tmps = k->Value; // replace formal arguments for (unsigned int j = 1; j < this->Args.size(); ++j) diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index 3457da2..93e10b2 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -112,7 +112,6 @@ public: "policies inside macros." ; } - cmTypeMacro(cmMacroCommand, cmCommand); }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 53f4c3c..e14e44d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -22,6 +22,7 @@ #include "cmFunctionBlocker.h" #include "cmListFileCache.h" #include "cmCommandArgumentParserHelper.h" +#include "cmDocumentCompileDefinitions.h" #include "cmTest.h" #ifdef CMAKE_BUILD_WITH_CMAKE # include "cmVariableWatch.h" @@ -43,12 +44,22 @@ class cmMakefile::Internals { public: std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack; + std::stack<std::set<cmStdString> > VarInitStack; + std::stack<std::set<cmStdString> > VarUsageStack; }; // default is not to be building executables cmMakefile::cmMakefile(): Internal(new Internals) { - this->Internal->VarStack.push(cmDefinitions()); + const cmDefinitions& defs = cmDefinitions(); + const std::set<cmStdString> globalKeys = defs.LocalKeys(); + this->Internal->VarStack.push(defs); + this->Internal->VarInitStack.push(globalKeys); + this->Internal->VarUsageStack.push(globalKeys); + + // Initialize these first since AddDefaultDefinitions calls AddDefinition + this->WarnUnused = false; + this->CheckSystemVars = false; // Setup the default include file regular expression (match everything). this->IncludeFileRegularExpression = "^.*$"; @@ -91,6 +102,8 @@ cmMakefile::cmMakefile(): Internal(new Internals) cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) { this->Internal->VarStack.push(mf.Internal->VarStack.top().Closure()); + this->Internal->VarInitStack.push(mf.Internal->VarInitStack.top()); + this->Internal->VarUsageStack.push(mf.Internal->VarUsageStack.top()); this->Prefix = mf.Prefix; this->AuxSourceDirectories = mf.AuxSourceDirectories; @@ -128,8 +141,10 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->SubDirectoryOrder = mf.SubDirectoryOrder; this->Properties = mf.Properties; this->PreOrder = mf.PreOrder; - this->ListFileStack = mf.ListFileStack; + this->WarnUnused = mf.WarnUnused; this->Initialize(); + this->CheckSystemVars = mf.CheckSystemVars; + this->ListFileStack = mf.ListFileStack; } //---------------------------------------------------------------------------- @@ -570,6 +585,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, std::string currentFile = this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE"); this->AddDefinition("CMAKE_PARENT_LIST_FILE", filename_in); + this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE"); const char* external = 0; std::string external_abs; @@ -610,8 +626,10 @@ bool cmMakefile::ReadListFile(const char* filename_in, } this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE"); this->AddDefinition("CMAKE_CURRENT_LIST_DIR", cmSystemTools::GetFilenamePath(filenametoread).c_str()); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR"); // try to see if the list file is the top most // list file for a project, and if it is, then it @@ -644,9 +662,12 @@ bool cmMakefile::ReadListFile(const char* filename_in, *fullPath = ""; } this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); + this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE"); this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE"); this->AddDefinition("CMAKE_CURRENT_LIST_DIR", cmSystemTools::GetFilenamePath(currentFile).c_str()); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR"); return false; } // add this list file to the list of dependencies @@ -686,13 +707,19 @@ bool cmMakefile::ReadListFile(const char* filename_in, } this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); + this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE"); this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE"); this->AddDefinition("CMAKE_CURRENT_LIST_DIR", cmSystemTools::GetFilenamePath(currentFile).c_str()); + this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR"); // pop the listfile off the stack this->ListFileStack.pop_back(); + // Check for unused variables + this->CheckForUnusedVariables(); + return true; } @@ -758,6 +785,8 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) this->AddSourceGroup("Resources", "\\.plist$"); #endif + this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); + this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); } bool cmMakefile::NeedBackwardsCompatibility(unsigned int major, @@ -1626,6 +1655,13 @@ void cmMakefile::AddDefinition(const char* name, const char* value) #endif this->Internal->VarStack.top().Set(name, value); + if (this->Internal->VarUsageStack.size() && + this->VariableInitialized(name)) + { + this->CheckForUnused("changing definition", name); + this->Internal->VarUsageStack.top().erase(name); + } + this->Internal->VarInitStack.top().insert(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); @@ -1690,6 +1726,13 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value, void cmMakefile::AddDefinition(const char* name, bool value) { this->Internal->VarStack.top().Set(name, value? "ON" : "OFF"); + if (this->Internal->VarUsageStack.size() && + this->VariableInitialized(name)) + { + this->CheckForUnused("changing definition", name); + this->Internal->VarUsageStack.top().erase(name); + } + this->Internal->VarInitStack.top().insert(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -1700,9 +1743,90 @@ void cmMakefile::AddDefinition(const char* name, bool value) #endif } +void cmMakefile::CheckForUnusedVariables() const +{ + const cmDefinitions& defs = this->Internal->VarStack.top(); + const std::set<cmStdString>& locals = defs.LocalKeys(); + std::set<cmStdString>::const_iterator it = locals.begin(); + for (; it != locals.end(); ++it) + { + this->CheckForUnused("out of scope", it->c_str()); + } +} + +void cmMakefile::MarkVariableAsUsed(const char* var) +{ + this->Internal->VarUsageStack.top().insert(var); +} + +bool cmMakefile::VariableInitialized(const char* var) const +{ + if(this->Internal->VarInitStack.top().find(var) != + this->Internal->VarInitStack.top().end()) + { + return true; + } + return false; +} + +bool cmMakefile::VariableUsed(const char* var) const +{ + if(this->Internal->VarUsageStack.top().find(var) != + this->Internal->VarUsageStack.top().end()) + { + return true; + } + return false; +} + +void cmMakefile::CheckForUnused(const char* reason, const char* name) const +{ + if (this->WarnUnused && !this->VariableUsed(name)) + { + cmStdString path; + cmListFileBacktrace bt; + if (this->CallStack.size()) + { + const cmListFileContext* file = this->CallStack.back().Context; + bt.push_back(*file); + path = file->FilePath.c_str(); + } + else + { + path = this->GetStartDirectory(); + path += "/CMakeLists.txt"; + cmListFileContext lfc; + lfc.FilePath = path; + lfc.Line = 0; + bt.push_back(lfc); + } + if (this->CheckSystemVars || + cmSystemTools::IsSubDirectory(path.c_str(), + this->GetHomeDirectory()) || + (cmSystemTools::IsSubDirectory(path.c_str(), + this->GetHomeOutputDirectory()) && + !cmSystemTools::IsSubDirectory(path.c_str(), + cmake::GetCMakeFilesDirectory()))) + { + cmOStringStream msg; + msg << "unused variable (" << reason << ") \'" << name << "\'"; + this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, + msg.str().c_str(), + bt); + } + } +} + void cmMakefile::RemoveDefinition(const char* name) { this->Internal->VarStack.top().Set(name, 0); + if (this->Internal->VarUsageStack.size() && + this->VariableInitialized(name)) + { + this->CheckForUnused("unsetting", name); + this->Internal->VarUsageStack.top().erase(name); + } + this->Internal->VarInitStack.top().insert(name); #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); if ( vv ) @@ -2054,6 +2178,7 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const bool cmMakefile::IsDefinitionSet(const char* name) const { const char* def = this->Internal->VarStack.top().Get(name); + this->Internal->VarUsageStack.top().insert(name); if(!def) { def = this->GetCacheManager()->GetCacheValue(name); @@ -2081,6 +2206,10 @@ const char* cmMakefile::GetDefinition(const char* name) const RecordPropertyAccess(name,cmProperty::VARIABLE); } #endif + if (this->WarnUnused) + { + this->Internal->VarUsageStack.top().insert(name); + } const char* def = this->Internal->VarStack.top().Get(name); if(!def) { @@ -2717,14 +2846,51 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, cm.SetStartOutputDirectory(bindir); cm.SetCMakeCommand(cmakeCommand.c_str()); cm.LoadCache(); + if(!gg->IsMultiConfig()) + { + if(const char* config = + this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) + { + // Tell the single-configuration generator which one to use. + // Add this before the user-provided CMake arguments in case + // one of the arguments is -DCMAKE_BUILD_TYPE=... + cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, + "Build configuration", cmCacheManager::STRING); + } + } // if cmake args were provided then pass them in if (cmakeArgs) { + // FIXME: Workaround to ignore unused CLI variables in try-compile. + // + // Ideally we should use SetArgs to honor options like --warn-unused-vars. + // However, there is a subtle problem when certain arguments are passed to + // a macro wrapping around try_compile or try_run that does not escape + // semicolons in its parameters but just passes ${ARGV} or ${ARGN}. In + // this case a list argument like "-DVAR=a;b" gets split into multiple + // cmake arguments "-DVAR=a" and "b". Currently SetCacheArgs ignores + // argument "b" and uses just "-DVAR=a", leading to a subtle bug in that + // the try_compile or try_run does not get the proper value of VAR. If we + // call SetArgs here then it would treat "b" as the source directory and + // cause an error such as "The source directory .../CMakeFiles/CMakeTmp/b + // does not exist", thus breaking the try_compile or try_run completely. + // + // Strictly speaking the bug is in the wrapper macro because the CMake + // language has always flattened nested lists and the macro should escape + // the semicolons in its arguments before forwarding them. However, this + // bug is so subtle that projects typically work anyway, usually because + // the value VAR=a is sufficient for the try_compile or try_run to get the + // correct result. Calling SetArgs here would break such projects that + // previously built. Instead we work around the issue by never reporting + // unused arguments and ignoring options such as --warn-unused-vars. + cm.SetWarnUnusedCli(false); + //cm.SetArgs(*cmakeArgs, true); + cm.SetCacheArgs(*cmakeArgs); } // to save time we pass the EnableLanguage info directly gg->EnableLanguagesFromGenerator - (this->LocalGenerator->GetGlobalGenerator()); + (this->LocalGenerator->GetGlobalGenerator(), this); if(this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) { cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", @@ -3403,12 +3569,48 @@ std::string cmMakefile::GetListFileStack() void cmMakefile::PushScope() { cmDefinitions* parent = &this->Internal->VarStack.top(); + const std::set<cmStdString>& init = this->Internal->VarInitStack.top(); + const std::set<cmStdString>& usage = this->Internal->VarUsageStack.top(); this->Internal->VarStack.push(cmDefinitions(parent)); + this->Internal->VarInitStack.push(init); + this->Internal->VarUsageStack.push(usage); } void cmMakefile::PopScope() { + cmDefinitions* current = &this->Internal->VarStack.top(); + std::set<cmStdString> init = this->Internal->VarInitStack.top(); + std::set<cmStdString> usage = this->Internal->VarUsageStack.top(); + const std::set<cmStdString>& locals = current->LocalKeys(); + // Remove initialization and usage information for variables in the local + // scope. + std::set<cmStdString>::const_iterator it = locals.begin(); + for (; it != locals.end(); ++it) + { + init.erase(*it); + if (!this->VariableUsed(it->c_str())) + { + this->CheckForUnused("out of scope", it->c_str()); + } + else + { + usage.erase(*it); + } + } this->Internal->VarStack.pop(); + this->Internal->VarInitStack.pop(); + this->Internal->VarUsageStack.pop(); + // Push initialization and usage up to the parent scope. + it = init.begin(); + for (; it != init.end(); ++it) + { + this->Internal->VarInitStack.top().insert(*it); + } + it = usage.begin(); + for (; it != usage.end(); ++it) + { + this->Internal->VarUsageStack.top().insert(*it); + } } void cmMakefile::RaiseScope(const char *var, const char *varDef) @@ -3433,7 +3635,14 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef) // directory's scope was initialized by the closure of the parent // scope, so we do not need to localize the definition first. cmMakefile* parent = plg->GetMakefile(); - parent->Internal->VarStack.top().Set(var, varDef); + if (varDef) + { + parent->AddDefinition(var, varDef); + } + else + { + parent->RemoveDefinition(var); + } } else { @@ -3492,14 +3701,7 @@ void cmMakefile::DefineProperties(cmake *cm) "are not supported by the native build tool. " "The VS6 IDE does not support definition values with spaces " "(but NMake does).\n" - "Dislaimer: Most native build tools have poor support for escaping " - "certain values. CMake has work-arounds for many cases but some " - "values may just not be possible to pass correctly. If a value " - "does not seem to be escaped correctly, do not attempt to " - "work-around the problem by adding escape sequences to the value. " - "Your work-around may break in a future version of CMake that " - "has improved escape support. Instead consider defining the macro " - "in a (configured) header file. Then report the limitation."); + CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER); cm->DefineProperty ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::DIRECTORY, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 8b8a3f8..837a352 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -61,6 +61,14 @@ public: unsigned int GetCacheMajorVersion(); unsigned int GetCacheMinorVersion(); + /* Check for unused variables in this scope */ + void CheckForUnusedVariables() const; + /* Mark a variable as used */ + void MarkVariableAsUsed(const char* var); + /* return true if a variable has been initialized */ + bool VariableInitialized(const char* ) const; + /* return true if a variable has been used */ + bool VariableUsed(const char* ) const; /** Return whether compatibility features needed for a version of the cache or lower should be enabled. */ bool NeedCacheCompatibility(int major, int minor); @@ -836,7 +844,10 @@ public: protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const char* name, cmTarget& target); - + + // Check for a an unused variable + void CheckForUnused(const char* reason, const char* name) const; + std::string Prefix; std::vector<std::string> AuxSourceDirectories; // @@ -929,6 +940,10 @@ private: // should this makefile be processed before or after processing the parent bool PreOrder; + // Unused variable flags + bool WarnUnused; + bool CheckSystemVars; + // stack of list files being read std::deque<cmStdString> ListFileStack; diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 26328cf..ed1da7b 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -16,6 +16,7 @@ #include "cmMakefile.h" #include "cmSystemTools.h" #include "cmake.h" +#include "cmDocumentCompileDefinitions.h" //---------------------------------------------------------------------------- cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name): @@ -187,8 +188,13 @@ bool cmSourceFile::FindFullPath(std::string* error) } cmOStringStream e; - e << "Cannot find source file \"" << this->Location.GetName() << "\""; - e << ". Tried extensions"; + std::string missing = this->Location.GetDirectory(); + if(!missing.empty()) + { + missing += "/"; + } + missing += this->Location.GetName(); + e << "Cannot find source file:\n " << missing << "\nTried extensions"; for(std::vector<std::string>::const_iterator ext = srcExts.begin(); ext != srcExts.end(); ++ext) { @@ -411,15 +417,7 @@ void cmSourceFile::DefineProperties(cmake *cm) "The VS6 IDE does not support definition values with spaces " "(but NMake does). Xcode does not support per-configuration " "definitions on source files.\n" - "Disclaimer: Most native build tools have poor support for escaping " - "certain values. CMake has work-arounds for many cases but some " - "values may just not be possible to pass correctly. If a value " - "does not seem to be escaped correctly, do not attempt to " - "work-around the problem by adding escape sequences to the value. " - "Your work-around may break in a future version of CMake that " - "has improved escape support. Instead consider defining the macro " - "in a (configured) header file. Then report the limitation."); - + CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER); cm->DefineProperty ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::SOURCE_FILE, diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 2b4414d..949fcf5 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -482,6 +482,7 @@ void cmStringCommand::ClearMatches(cmMakefile* mf) char name[128]; sprintf(name, "CMAKE_MATCH_%d", i); mf->AddDefinition(name, ""); + mf->MarkVariableAsUsed(name); } } @@ -493,6 +494,7 @@ void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) char name[128]; sprintf(name, "CMAKE_MATCH_%d", i); mf->AddDefinition(name, re.match(i).c_str()); + mf->MarkVariableAsUsed(name); } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 52574e2..72efce3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -16,6 +16,7 @@ #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" +#include "cmDocumentCompileDefinitions.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" #include <cmsys/RegularExpression.hxx> @@ -146,14 +147,7 @@ void cmTarget::DefineProperties(cmake *cm) "are not supported by the native build tool. " "The VS6 IDE does not support definition values with spaces " "(but NMake does).\n" - "Dislaimer: Most native build tools have poor support for escaping " - "certain values. CMake has work-arounds for many cases but some " - "values may just not be possible to pass correctly. If a value " - "does not seem to be escaped correctly, do not attempt to " - "work-around the problem by adding escape sequences to the value. " - "Your work-around may break in a future version of CMake that " - "has improved escape support. Instead consider defining the macro " - "in a (configured) header file. Then report the limitation."); + CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER); cm->DefineProperty ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::TARGET, diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 3a30e4c..0c67a8b 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -47,7 +47,7 @@ public: */ virtual const char* GetTerseDocumentation() { - return "Try compiling some code."; + return "Try building some code."; } /** @@ -55,23 +55,28 @@ public: virtual const char* GetFullDocumentation() { return - " try_compile(RESULT_VAR bindir srcdir\n" - " projectName <targetname> [CMAKE_FLAGS <Flags>]\n" - " [OUTPUT_VARIABLE var])\n" - "Try compiling a program. In this form, srcdir should contain a " - "complete CMake project with a CMakeLists.txt file and all sources. The " - "bindir and srcdir will not be deleted after this command is run. " - "If <target name> is specified then build just that target " - "otherwise the all or ALL_BUILD target is built.\n" - " try_compile(RESULT_VAR bindir srcfile\n" - " [CMAKE_FLAGS <Flags>]\n" - " [COMPILE_DEFINITIONS <flags> ...]\n" - " [OUTPUT_VARIABLE var]\n" - " [COPY_FILE <filename> )\n" - "Try compiling a srcfile. In this case, the user need only supply a " - "source file. CMake will create the appropriate CMakeLists.txt file " - "to build the source. If COPY_FILE is used, the compiled file will be " - "copied to the given file.\n" + " try_compile(RESULT_VAR <bindir> <srcdir>\n" + " <projectName> [targetName] [CMAKE_FLAGS flags...]\n" + " [OUTPUT_VARIABLE <var>])\n" + "Try building a project. In this form, srcdir should contain a " + "complete CMake project with a CMakeLists.txt file and all sources. " + "The bindir and srcdir will not be deleted after this command is run. " + "Specify targetName to build a specific target instead of the 'all' or " + "'ALL_BUILD' target." + "\n" + " try_compile(RESULT_VAR <bindir> <srcfile>\n" + " [CMAKE_FLAGS flags...]\n" + " [COMPILE_DEFINITIONS flags...]\n" + " [OUTPUT_VARIABLE <var>]\n" + " [COPY_FILE <fileName>])\n" + "Try building a source file into an executable. " + "In this form the user need only supply a source file that defines " + "a 'main'. " + "CMake will create a CMakeLists.txt file to build the source " + "as an executable. " + "Specify COPY_FILE to get a copy of the linked executable at the " + "given fileName." + "\n" "In this version all files in bindir/CMakeFiles/CMakeTmp, " "will be cleaned automatically, for debugging a --debug-trycompile can " "be passed to cmake to avoid the clean. Some extra flags that " @@ -94,7 +99,9 @@ public: "Return the success or failure in " "RESULT_VAR. CMAKE_FLAGS can be used to pass -DVAR:TYPE=VALUE flags " "to the cmake that is run during the build. " - ""; + "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " + "configuration." + ; } cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile); diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index ca48e90..f86d863 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -93,7 +93,10 @@ public: "that when crosscompiling, the cache variables will have to be set " "manually to the output of the executable. You can also \"guard\" the " "calls to try_run with if(CMAKE_CROSSCOMPILING) and provide an " - "easy-to-preset alternative for this case.\n"; + "easy-to-preset alternative for this case.\n" + "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " + "configuration." + ; } cmTypeMacro(cmTryRunCommand, cmCoreTryCompile); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ab282b0..4cb745e 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -597,7 +597,11 @@ WriteGroupSources(const char* name, for(std::vector<cmSourceFile*>::const_iterator s = sources.begin(); s != sources.end(); ++s) { - cmSourceFile* sf = *s; + cmSourceFile* sf = *s; + if(sf->GetExtension() == "obj") + { + continue; + } std::string const& source = sf->GetFullPath(); cmSourceGroup& sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); @@ -666,55 +670,60 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) { - // if it is not a custom command then add it as a c/c++ file, - // TODO: need to check for idl or rc - if(!(*source)->GetCustomCommand()) + std::string ext = (*source)->GetExtension(); + if((*source)->GetCustomCommand() || ext == "obj") { - bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY") - || this->GlobalGenerator->IgnoreFile - ((*source)->GetExtension().c_str()); - const char* lang = (*source)->GetLanguage(); - bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0); - bool rc = lang && (strcmp(lang, "RC") == 0); - bool idl = (*source)->GetExtension() == "idl"; - std::string sourceFile = (*source)->GetFullPath(); - sourceFile = cmSystemTools::RelativePath( - this->Makefile->GetCurrentOutputDirectory(), - sourceFile.c_str()); - this->ConvertToWindowsSlash(sourceFile); - // output the source file - if(header) - { - this->WriteString("<ClInclude Include=\"", 2); - } - else if(cl) - { - this->WriteString("<ClCompile Include=\"", 2); - } - else if(rc) - { - this->WriteString("<ResourceCompile Include=\"", 2); - } - else if(idl) - { - this->WriteString("<Midl Include=\"", 2); - } - else - { - this->WriteString("<None Include=\"", 2); - } - (*this->BuildFileStream ) << sourceFile << "\""; - // ouput any flags specific to this source file - if(!header && cl && this->OutputSourceSpecificFlags(*source)) - { - // if the source file has specific flags the tag - // is ended on a new line - this->WriteString("</ClCompile>\n", 2); - } - else - { - (*this->BuildFileStream ) << " />\n"; - } + continue; + } + // If it is not a custom command and it is not a pre-built obj file, + // then add it as a source (c/c++/header/rc/idl) file + bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY") + || this->GlobalGenerator->IgnoreFile(ext.c_str()); + const char* lang = (*source)->GetLanguage(); + bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0); + bool rc = lang && (strcmp(lang, "RC") == 0); + bool idl = ext == "idl"; + std::string sourceFile = (*source)->GetFullPath(); + sourceFile = cmSystemTools::RelativePath( + this->Makefile->GetCurrentOutputDirectory(), + sourceFile.c_str()); + this->ConvertToWindowsSlash(sourceFile); + // output the source file + if(header) + { + this->WriteString("<ClInclude Include=\"", 2); + } + else if(cl) + { + this->WriteString("<ClCompile Include=\"", 2); + } + else if(rc) + { + this->WriteString("<ResourceCompile Include=\"", 2); + } + else if(idl) + { + this->WriteString("<Midl Include=\"", 2); + } + else + { + this->WriteString("<None Include=\"", 2); + } + (*this->BuildFileStream ) << sourceFile << "\""; + // ouput any flags specific to this source file + if(!header && cl && this->OutputSourceSpecificFlags(*source)) + { + // if the source file has specific flags the tag + // is ended on a new line + this->WriteString("</ClCompile>\n", 2); + } + else if(!header && rc && this->OutputSourceSpecificFlags(*source)) + { + this->WriteString("</ResourceCompile>\n", 2); + } + else + { + (*this->BuildFileStream ) << " />\n"; } } this->WriteString("</ItemGroup>\n", 1); @@ -848,8 +857,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); clOptions.OutputFlagMap(*this->BuildFileStream, " "); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, - " ", "\n"); - + " ", "\n", lang); } } return hasFlags; @@ -1115,7 +1123,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", - "\n"); + "\n", "CXX"); this->WriteString("<AssemblerListingLocation>", 3); *this->BuildFileStream << configName << "</AssemblerListingLocation>\n"; @@ -1150,7 +1158,7 @@ WriteRCOptions(std::string const& configName, this->WriteString("<ResourceCompile>\n", 2); Options& clOptions = *(this->ClOptions[configName]); clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", - "\n"); + "\n", "RC"); this->OutputIncludes(includes); this->WriteString("</ResourceCompile>\n", 2); } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 9acae0d..ed0d60c 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -204,7 +204,8 @@ void cmVisualStudioGeneratorOptions ::OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, - const char* suffix) + const char* suffix, + const char* lang) { if(this->Defines.empty()) { @@ -251,6 +252,11 @@ cmVisualStudioGeneratorOptions if(this->Version == 10) { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str()); + + if(0 == strcmp(lang, "RC")) + { + cmSystemTools::ReplaceString(define, "\"", "\\\""); + } } else { diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 8619ba0..fadc4b5 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -54,7 +54,8 @@ public: // Write options to output. void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, - const char* suffix); + const char* suffix, + const char* lang); void OutputFlagMap(std::ostream& fout, const char* indent); void OutputAdditionalOptions(std::ostream& fout, const char* prefix, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1b49837..bab0aaf 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -138,9 +138,20 @@ void cmNeedBackwardsCompatibility(const std::string& variable, #endif } +void cmWarnUnusedCliWarning(const std::string& variable, + int, void* ctx, const char*, const cmMakefile*) +{ + cmake* cm = reinterpret_cast<cmake*>(ctx); + cm->MarkCliAsUsed(variable); +} + cmake::cmake() { this->Trace = false; + this->WarnUninitialized = false; + this->WarnUnused = false; + this->WarnUnusedCli = true; + this->CheckSystemVars = false; this->SuppressDevWarnings = false; this->DoSuppressDevWarnings = false; this->DebugOutput = false; @@ -367,6 +378,10 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) { this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), "No help, variable specified on the command line.", type); + if(this->WarnUnusedCli) + { + this->WatchUnusedCli(var.c_str()); + } } else { @@ -509,9 +524,10 @@ void cmake::ReadListFile(const char *path) } // Parse the args -void cmake::SetArgs(const std::vector<std::string>& args) +void cmake::SetArgs(const std::vector<std::string>& args, + bool directoriesSetBefore) { - bool directoriesSet = false; + bool directoriesSet = directoriesSetBefore; for(unsigned int i=1; i < args.size(); ++i) { std::string arg = args[i]; @@ -613,6 +629,28 @@ void cmake::SetArgs(const std::vector<std::string>& args) std::cout << "Running with trace output on.\n"; this->SetTrace(true); } + else if(arg.find("--warn-uninitialized",0) == 0) + { + std::cout << "Warn about uninitialized values.\n"; + this->SetWarnUninitialized(true); + } + else if(arg.find("--warn-unused-vars",0) == 0) + { + std::cout << "Finding unused variables.\n"; + this->SetWarnUnused(true); + } + else if(arg.find("--no-warn-unused-cli",0) == 0) + { + std::cout << "Not searching for unused variables given on the " << + "command line.\n"; + this->SetWarnUnusedCli(false); + } + else if(arg.find("--check-system-vars",0) == 0) + { + std::cout << "Also check system files when warning about unused and " << + "uninitialized variables.\n"; + this->SetCheckSystemVars(true); + } else if(arg.find("-G",0) == 0) { std::string value = arg.substr(2); @@ -2272,6 +2310,11 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) std::string oldstartoutputdir = this->GetStartOutputDirectory(); this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); + const bool warncli = this->WarnUnusedCli; + if (!this->ScriptMode) + { + this->WarnUnusedCli = false; + } int ret = this->Configure(); if (ret || this->ScriptMode) { @@ -2293,6 +2336,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) #endif return ret; } + this->WarnUnusedCli = warncli; ret = this->Generate(); std::string message = "Build files have been written to: "; message += this->GetHomeOutputDirectory(); @@ -2835,6 +2879,10 @@ const char* cmake::GetCPackCommand() return this->CPackCommand.c_str(); } +void cmake::MarkCliAsUsed(const std::string& variable) +{ + this->UsedCliVariables[variable] = true; +} void cmake::GenerateGraphViz(const char* fileName) const { @@ -4255,3 +4303,40 @@ int cmake::Build(const std::string& dir, config.c_str(), clean, false, 0, true, 0, nativeOptions); } + +void cmake::WatchUnusedCli(const char* var) +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this); + this->UsedCliVariables[var] = false; +#endif +} + +void cmake::UnwatchUnusedCli(const char* var) +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning); + this->UsedCliVariables[var] = true; +#endif +} + +void cmake::RunCheckForUnusedVariables(const std::string& reason) const +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + if(this->WarnUnusedCli) + { + std::map<std::string, bool>::const_iterator it; + for(it = this->UsedCliVariables.begin(); + it != this->UsedCliVariables.end(); ++it) + { + if(!it->second) + { + std::string message = "CMake Warning: The variable, '" + it->first + + "', specified manually, was not used during the " + reason + + "."; + cmSystemTools::Message(message.c_str()); + } + } + } +#endif +} diff --git a/Source/cmake.h b/Source/cmake.h index 435d38b..1bb42d3 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -214,7 +214,8 @@ class cmake bool CommandExists(const char* name) const; ///! Parse command line arguments - void SetArgs(const std::vector<std::string>&); + void SetArgs(const std::vector<std::string>&, + bool directoriesSetBefore = false); ///! Is this cmake running as a result of a TRY_COMPILE command bool GetIsInTryCompile() { return this->InTryCompile; } @@ -308,6 +309,17 @@ class cmake // Do we want trace output during the cmake run. bool GetTrace() { return this->Trace;} void SetTrace(bool b) { this->Trace = b;} + bool GetWarnUninitialized() { return this->WarnUninitialized;} + void SetWarnUninitialized(bool b) { this->WarnUninitialized = b;} + bool GetWarnUnused() { return this->WarnUnused;} + void SetWarnUnused(bool b) { this->WarnUnused = b;} + bool GetWarnUnusedCli() { return this->WarnUnusedCli;} + void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b;} + bool GetCheckSystemVars() { return this->CheckSystemVars;} + void SetCheckSystemVars(bool b) { this->CheckSystemVars = b;} + + void MarkCliAsUsed(const std::string& variable); + // Define a property void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, @@ -353,6 +365,10 @@ class cmake const std::string& config, const std::vector<std::string>& nativeOptions, bool clean); + + void UnwatchUnusedCli(const char* var); + void WatchUnusedCli(const char* var); + void RunCheckForUnusedVariables(const std::string& reason) const; protected: void InitializeProperties(); int HandleDeleteCacheVariables(const char* var); @@ -445,6 +461,11 @@ private: bool ScriptMode; bool DebugOutput; bool Trace; + bool WarnUninitialized; + bool WarnUnused; + bool WarnUnusedCli; + bool CheckSystemVars; + std::map<std::string, bool> UsedCliVariables; std::string CMakeEditCommand; std::string CMakeCommand; std::string CXXEnvironment; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ddff71d..a51673c 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -120,6 +120,17 @@ static const char * cmDocumentationOptions[][3] = {"--trace", "Put cmake in trace mode.", "Print a trace of all calls made and from where with " "message(send_error ) calls."}, + {"--warn-uninitialized", "Warn about uninitialized values.", + "Print a warning when an uninitialized variable is used."}, + {"--warn-unused-vars", "Warn about unused variables.", + "Find variables that are declared or set, but not used."}, + {"--no-warn-unused-cli", "Don't warn about command line options.", + "Don't find variables that are declared on the command line, but not " + "used."}, + {"--check-system-vars", "Find problems with variable usage in system " + "files.", "Normally, unused and uninitialized variables are searched for " + "only in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to " + "warn about other files as well."}, {"--help-command cmd [file]", "Print help for a single command and exit.", "Full documentation specific to the given command is displayed. " "If a file is specified, the documentation is written into and the output " diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4bc8769..60d03d6 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 01) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 11) +SET(KWSYS_DATE_STAMP_DAY 31) diff --git a/Tests/ArgumentExpansion/CMakeLists.txt b/Tests/ArgumentExpansion/CMakeLists.txt new file mode 100644 index 0000000..a24636f --- /dev/null +++ b/Tests/ArgumentExpansion/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 2.8) + +project(ArgumentExpansion) + +function (argument_tester expected expected_len) + list(LENGTH ARGN argn_len) + list(LENGTH ${expected} expected_received_len) + + if (NOT ${expected_received_len} EQUAL ${expected_len}) + message(STATUS "Unexpected: Expanding expected values isn't working") + endif (NOT ${expected_received_len} EQUAL ${expected_len}) + + if (${argn_len} EQUAL ${expected_len}) + set(i 0) + while (i LESS ${argn_len}) + list(GET ARGN ${i} argn_value) + list(GET ${expected} ${i} expected_value) + + if (NOT "${argn_value}" STREQUAL "${expected_value}") + message(STATUS "Unexpected: Argument ${i} doesn't match") + message(STATUS " Expected: ${expected_value}") + message(STATUS " Received: ${argn_value}") + endif () + + math(EXPR i "${i} + 1") + endwhile (i LESS ${argn_len}) + else (${argn_len} EQUAL ${expected_len}) + message(STATUS "Unexpected: Lengths of arguments don't match") + message(STATUS " Expected: ${expected_len}") + message(STATUS " Received: ${argn_len}") + endif (${argn_len} EQUAL ${expected_len}) +endfunction (argument_tester expected) + +set(empty_test) +message(STATUS "Test: Empty arguments") +argument_tester(empty_test 0 ${empty_test}) + +set(single_arg_test + "single arg") +message(STATUS "Test: Single argument") +argument_tester(single_arg_test 1 ${single_arg_test}) + +set(multiple_arg_test + "first arg" + "second arg") +message(STATUS "Test: Multiple arguments") +argument_tester(multiple_arg_test 2 ${multiple_arg_test}) + +set(nested_list_arg_test + "${multiple_arg_test}" + "first arg" + "second arg") +message(STATUS "Test: Nested list argument flattens") +argument_tester(nested_list_arg_test 4 ${nested_list_arg_test}) + +set(semicolon_arg_test + "pre\;post") +set(semicolon_arg_test_flat "pre;post") +message(STATUS "Test: Semicolon argument flattens") +argument_tester(semicolon_arg_test_flat 2 ${semicolon_arg_test}) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c5331be..cbca02d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -138,8 +138,8 @@ IF(BUILD_TESTING) SET(TEST_RESOURCES TRUE) ENDIF() # for borland and watcom there is no resource support - IF(("${CMAKE_TEST_GENERATOR}" MATCHES "WMake") OR - ("${CMAKE_TEST_GENERATOR}" MATCHES "Borland")) + IF("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR + "${CMAKE_TEST_GENERATOR}" MATCHES "Borland") SET(TEST_RESOURCES FALSE) ENDIF() IF(TEST_RESOURCES) @@ -149,7 +149,7 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(PreOrder PreOrder) ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) SET_TESTS_PROPERTIES(MissingSourceFile PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file \"MissingSourceFile.c\"") + PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(IPO COnly/COnly) @@ -391,6 +391,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend") + ADD_TEST(ArgumentExpansion ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion" + "${CMake_BINARY_DIR}/Tests/ArgumentExpansion" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project ArgumentExpansion + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin" + ) + SET_TESTS_PROPERTIES(ArgumentExpansion PROPERTIES + FAIL_REGULAR_EXPRESSION "Unexpected: ") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion") + ADD_TEST(CustomCommand ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/CustomCommand" @@ -1139,6 +1152,77 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest") ENDIF(APPLE AND CTEST_TEST_CPACK) + ADD_TEST(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet" + "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedUnusedViaSet + --build-options "--warn-unused-vars") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaSet PROPERTIES + PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaSet PROPERTIES + FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet") + + ADD_TEST(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset" + "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedUnusedViaUnset + --build-options "--warn-unused-vars") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning .*:7 \\(set\\):") + SET_TESTS_PROPERTIES(WarnUnusedUnusedViaUnset PROPERTIES + FAIL_REGULAR_EXPRESSION "CMake Warning .*:5 \\(set\\):") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") + + ADD_TEST(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUsage" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedCliUnused + --build-options "-DUNUSED_CLI_VARIABLE=Unused") + SET_TESTS_PROPERTIES(WarnUnusedCliUnused PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Warning: The variable, 'UNUSED_CLI_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") + + ADD_TEST(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUsage" + "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUnusedCliUsed + --build-options "-DUSED_VARIABLE=Usage proven") + SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES + PASS_REGULAR_EXPRESSION "Usage proven") + SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES + FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed") + + ADD_TEST(WarnUninitialized ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VariableUsage" + "${CMake_BINARY_DIR}/Tests/WarnUninitialized" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-noclean + --build-project WarnUninitialized + --build-options "--warn-uninitialized") + SET_TESTS_PROPERTIES(WarnUninitialized PROPERTIES + PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'") + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized") + ADD_TEST(TestsWorkingDirectory ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory" @@ -1785,11 +1869,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc") ENDIF(SDCC_EXECUTABLE) - + # If a Linux -> MinGW cross compiler is found then try it FIND_PROGRAM(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc) FIND_PROGRAM(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++) - MARK_AS_ADVANCED(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE) - IF(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE) + FIND_PROGRAM(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres) + MARK_AS_ADVANCED(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE) + IF(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE) ADD_TEST(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/Simple" @@ -1800,11 +1885,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-options "-DCMAKE_SYSTEM_NAME=Windows" "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}" - "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}") + "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}" + "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}" + ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win") - ENDIF(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE) - - + ENDIF() ENDIF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") IF(UNIX) diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in index f6ec198..b58b639 100644 --- a/Tests/CTestTest2/test.cmake.in +++ b/Tests/CTestTest2/test.cmake.in @@ -15,13 +15,12 @@ SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") -# for unix purify has to be used as a linker, and -# will not work with ctest. So disable it so -# that it is not attempted. -IF(UNIX) - IF("${CTEST_MEMORYCHECK_COMMAND}" MATCHES purify) - SET(CTEST_MEMORYCHECK_COMMAND) - ENDIF() + +# By default, CTESTTEST2_USE_PURIFY is not defined. If you want to run purify +# on CTestTest2, set CTESTTEST2_USE_PURIFY to ON in CMake's cache. +SET(CTESTTEST2_USE_PURIFY @CTESTTEST2_USE_PURIFY@) +IF("${CTEST_MEMORYCHECK_COMMAND}" MATCHES purify AND NOT CTESTTEST2_USE_PURIFY) + SET(CTEST_MEMORYCHECK_COMMAND) ENDIF() #CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) diff --git a/Tests/MissingSourceFile/CMakeLists.txt b/Tests/MissingSourceFile/CMakeLists.txt index 42b7c51..a7206c8 100644 --- a/Tests/MissingSourceFile/CMakeLists.txt +++ b/Tests/MissingSourceFile/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 2.8) project(MissingSourceFile C) -add_executable(MissingSourceFile MissingSourceFile.c) +add_executable(MissingSourceFile DoesNotExist/MissingSourceFile.c) diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt index a647fef..879530b 100644 --- a/Tests/SubDirSpaces/CMakeLists.txt +++ b/Tests/SubDirSpaces/CMakeLists.txt @@ -13,7 +13,15 @@ set(CMAKE_PAREN TRUE) IF("${CMAKE_MAKE_PROGRAM}" MATCHES "wmake") message("wmake does not support () in path") set(CMAKE_PAREN FALSE) -ENDIF("${CMAKE_MAKE_PROGRAM}" MATCHES "wmake") +elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "make") + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version + RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("${out}" MATCHES "GNU Make 3.82") + # GNU Make 3.82 fails on parens: http://savannah.gnu.org/bugs/?30612 + message(STATUS "GNU Make 3.82 sometimes fails on () in path") + set(CMAKE_PAREN FALSE) + endif() +endif() IF(CMAKE_PAREN) ADD_DEFINITIONS(-DCMAKE_PAREN=1) diff --git a/Tests/TestsWorkingDirectory/CMakeLists.txt b/Tests/TestsWorkingDirectory/CMakeLists.txt index 0fef19d..a0fd18a 100644 --- a/Tests/TestsWorkingDirectory/CMakeLists.txt +++ b/Tests/TestsWorkingDirectory/CMakeLists.txt @@ -7,6 +7,8 @@ enable_testing() set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") +add_test(NAME WorkingDirectory0 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}") + add_test(NAME WorkingDirectory1 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}") set_tests_properties(WorkingDirectory1 PROPERTIES WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" @@ -19,7 +21,7 @@ set_tests_properties(WorkingDirectory2 PROPERTIES WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.." ) -get_filename_component(_default_cwd "${EXECUTABLE_OUTPUT_PATH}" PATH) +set(_default_cwd "${CMAKE_BINARY_DIR}") # FIXME: How to deal with /debug, /release, etc. with VS or XCode? if(${CMAKE_GENERATOR} MATCHES "Makefiles") @@ -36,3 +38,5 @@ add_test(NAME WorkingDirectory5 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/.. COMMAND if(${CMAKE_GENERATOR} MATCHES "Makefiles") add_test(WorkingDirectory6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..) endif() + +add_subdirectory(subdir) diff --git a/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt b/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt new file mode 100644 index 0000000..523f02e --- /dev/null +++ b/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt @@ -0,0 +1,31 @@ +add_test(NAME WorkingDirectory-Subdir0 COMMAND WorkingDirectory "${CMAKE_CURRENT_BINARY_DIR}") + +add_test(NAME WorkingDirectory-Subdir1 COMMAND WorkingDirectory "${CMAKE_CURRENT_BINARY_DIR}") +set_tests_properties(WorkingDirectory-Subdir1 PROPERTIES + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" +) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}") + +add_test(NAME WorkingDirectory-Subdir2 COMMAND WorkingDirectory "${_parent_dir}") +set_tests_properties(WorkingDirectory-Subdir2 PROPERTIES + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." +) + +set(_default_cwd "${CMAKE_CURRENT_BINARY_DIR}") + +# FIXME: How to deal with /debug, /release, etc. with VS or XCode? +if(${CMAKE_GENERATOR} MATCHES "Makefiles") +add_test(WorkingDirectory-Subdir3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd}) +endif() + +add_test(NAME WorkingDirectory-Subdir4 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND WorkingDirectory ${CMAKE_CURRENT_BINARY_DIR}) + +string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}") + +add_test(NAME WorkingDirectory-Subdir5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir}) + +# FIXME: How to deal with /debug, /release, etc. with VS or XCode? +if(${CMAKE_GENERATOR} MATCHES "Makefiles") +add_test(WorkingDirectory-Subdir6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..) +endif() diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt index e842955..5d7d14e 100644 --- a/Tests/VSResource/CMakeLists.txt +++ b/Tests/VSResource/CMakeLists.txt @@ -1,7 +1,37 @@ -cmake_minimum_required (VERSION 2.6) -project (VSResource) -add_definitions(/DCMAKE_RCDEFINE="test.txt") +cmake_minimum_required(VERSION 2.8.3.20110118) +project(VSResource) + string(REPLACE "/INCREMENTAL:YES" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}") + +message(STATUS "CMAKE_RC_COMPILER='${CMAKE_RC_COMPILER}'") + +# Because of the following avoidance techniques required for windres and VS6, +# we recommend using a configured header file, and defining preprocessor +# symbols via #define code and including that header in the rc file. Using +# add_definitions is fine for simple definitions (with no spaces and no +# quoting), but requires avoidance or work-arounds beyond that... + +if(CMAKE_RC_COMPILER MATCHES windres) + # windres rc compiler does not properly define quoted /D values as strings + message(STATUS "CMAKE_RC_COMPILER MATCHES windres") + add_definitions(/DCMAKE_RCDEFINE=test.txt) + add_definitions(/DCMAKE_RCDEFINE_NO_QUOTED_STRINGS) +elseif(MSVC60) + # VS6 rc compiler does not deal well with spaces in a "/D" value, but it can + # handle the quoting + message(STATUS "MSVC60") + add_definitions(/DCMAKE_RCDEFINE="test.txt") +else() + # expected case -- rc compiler is "capable enough" + message(STATUS + "rc compiler handles quoted strings with spaces in values via /D") + set(TEXTFILE_FROM_SOURCE_DIR "textfile, spaces in name, from binary dir") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.txt + "${CMAKE_CURRENT_BINARY_DIR}/test with spaces.txt" @ONLY) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_definitions(/DCMAKE_RCDEFINE="test with spaces.txt") +endif() + add_executable(VSResource main.cpp test.rc) diff --git a/Tests/VSResource/main.cpp b/Tests/VSResource/main.cpp index 6f68df3..7ee0c74 100644 --- a/Tests/VSResource/main.cpp +++ b/Tests/VSResource/main.cpp @@ -1,10 +1,80 @@ #include <windows.h> +#include <stdio.h> -int main(int argc, char** argv) { - HRSRC hello = ::FindResource(0, "hello", "TEXT"); - if(hello) { - return 0; - } else { - return 1; - } +struct x +{ + const char *txt; +}; + +int main(int argc, char** argv) +{ + int ret = 1; + + fprintf(stdout, "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)\n"); + +#ifdef CMAKE_RCDEFINE + fprintf(stdout, "CMAKE_RCDEFINE defined\n"); +#endif + +#ifdef CMAKE_RCDEFINE_NO_QUOTED_STRINGS + // Expect CMAKE_RCDEFINE to preprocess to exactly test.txt + x test; + test.txt = "*exactly* test.txt"; + fprintf(stdout, "CMAKE_RCDEFINE_NO_QUOTED_STRINGS defined\n"); + fprintf(stdout, "CMAKE_RCDEFINE is %s, and is *not* a string constant\n", + CMAKE_RCDEFINE); +#else + // Expect CMAKE_RCDEFINE to be a string: + fprintf(stdout, "CMAKE_RCDEFINE='%s', and is a string constant\n", + CMAKE_RCDEFINE); +#endif + + HRSRC hello = ::FindResource(NULL, MAKEINTRESOURCE(1025), "TEXTFILE"); + if(hello) + { + fprintf(stdout, "FindResource worked\n"); + HGLOBAL hgbl = ::LoadResource(NULL, hello); + int datasize = (int) ::SizeofResource(NULL, hello); + if(hgbl && datasize>0) + { + fprintf(stdout, "LoadResource worked\n"); + fprintf(stdout, "SizeofResource returned datasize='%d'\n", datasize); + void *data = ::LockResource(hgbl); + if (data) + { + fprintf(stdout, "LockResource worked\n"); + char *str = (char *) malloc(datasize+4); + if (str) + { + memcpy(str, data, datasize); + str[datasize] = 'E'; + str[datasize+1] = 'O'; + str[datasize+2] = 'R'; + str[datasize+3] = 0; + fprintf(stdout, "str='%s'\n", str); + free(str); + + ret = 0; + +#ifdef CMAKE_RCDEFINE_NO_QUOTED_STRINGS + fprintf(stdout, "LoadString skipped\n"); +#else + char buf[256]; + if (::LoadString(NULL, 1026, buf, sizeof(buf)) > 0) + { + fprintf(stdout, "LoadString worked\n"); + fprintf(stdout, "buf='%s'\n", buf); + } + else + { + fprintf(stdout, "LoadString failed\n"); + ret = 1; + } +#endif + } + } + } + } + + return ret; } diff --git a/Tests/VSResource/test.rc b/Tests/VSResource/test.rc index 8aab8b7..4ce4b53 100644 --- a/Tests/VSResource/test.rc +++ b/Tests/VSResource/test.rc @@ -1,5 +1,17 @@ #ifdef CMAKE_RCDEFINE -hello TEXT DISCARDABLE CMAKE_RCDEFINE + +// This line can compile with either an unquoted or a quoted string +1025 TEXTFILE CMAKE_RCDEFINE + +#ifndef CMAKE_RCDEFINE_NO_QUOTED_STRINGS +// This block can only be compiled if CMAKE_RCDEFINE preprocesses +// to a double quoted string +STRINGTABLE +BEGIN + 1026 CMAKE_RCDEFINE +END +#endif + #else #error "resource compiler did not get defines from command line!" -#endif
\ No newline at end of file +#endif diff --git a/Tests/VSResource/test.txt b/Tests/VSResource/test.txt index 980a0d5..c27c68d 100644 --- a/Tests/VSResource/test.txt +++ b/Tests/VSResource/test.txt @@ -1 +1 @@ -Hello World! +Hello World! (@TEXTFILE_FROM_SOURCE_DIR@) diff --git a/Tests/VariableUnusedViaSet/CMakeLists.txt b/Tests/VariableUnusedViaSet/CMakeLists.txt new file mode 100644 index 0000000..0123ab2 --- /dev/null +++ b/Tests/VariableUnusedViaSet/CMakeLists.txt @@ -0,0 +1,4 @@ +set(UNUSED_VARIABLE) +# Warning should occur here +set(UNUSED_VARIABLE "Usage") +message(STATUS "${UNUSED_VARIABLE}") diff --git a/Tests/VariableUnusedViaUnset/CMakeLists.txt b/Tests/VariableUnusedViaUnset/CMakeLists.txt new file mode 100644 index 0000000..4b4031d --- /dev/null +++ b/Tests/VariableUnusedViaUnset/CMakeLists.txt @@ -0,0 +1,8 @@ +# NOTE: Changing lines in here changes the test results since the first +# instance shouldn't warn, but the second should and they have the same message + +# A warning should NOT be issued for this line: +set(UNUSED_VARIABLE) +# Warning should occur here: +set(UNUSED_VARIABLE) +message(STATUS "${UNUSED_VARIABLE}") diff --git a/Tests/VariableUsage/CMakeLists.txt b/Tests/VariableUsage/CMakeLists.txt new file mode 100644 index 0000000..4da1f56 --- /dev/null +++ b/Tests/VariableUsage/CMakeLists.txt @@ -0,0 +1 @@ +message(STATUS "${USED_VARIABLE}") diff --git a/Utilities/Release/v20n250_aix_release.cmake b/Utilities/Release/v20n250_aix_release.cmake index 88eb8d0..7a5c8b9 100644 --- a/Utilities/Release/v20n250_aix_release.cmake +++ b/Utilities/Release/v20n250_aix_release.cmake @@ -1,9 +1,9 @@ -set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory" ) +set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory") set(FINAL_PATH /u/noibm34/cmake-release) set(PROCESSORS 2) set(CVS_COMMAND /vol/local/bin/cvs) -set(HOST "sshserv.centers.ihost.com" ) -set(EXTRA_HOP "rsh v20n250" ) +set(HOST "sshserv.centers.ihost.com") +set(EXTRA_HOP "rsh p90n03") set(MAKE_PROGRAM "make") set(CC "xlc_r") set(CXX "xlC_r") diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 8c10b21..6472ec5 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -415,8 +415,12 @@ CHECK_SYMBOL_EXISTS(strerror_r "string.h" HAVE_STRERROR_R) CHECK_SYMBOL_EXISTS(strftime "time.h" HAVE_STRFTIME) CHECK_SYMBOL_EXISTS(vprintf "stdio.h" HAVE_VPRINTF) -CHECK_SYMBOL_EXISTS(major "sys/mkdev.h" MAJOR_IN_MKDEV) -CHECK_SYMBOL_EXISTS(major "sys/sysmacros.h" MAJOR_IN_SYSMACROS) +CHECK_C_SOURCE_COMPILES( + "#include <sys/mkdev.h>\nint main() { return major(256); }" + MAJOR_IN_MKDEV) +CHECK_C_SOURCE_COMPILES( + "#include <sys/sysmacros.h>\nint main() { return major(256); }" + MAJOR_IN_SYSMACROS) IF(HAVE_STRERROR_R) SET(HAVE_DECL_STRERROR_R 1) @@ -26,6 +26,11 @@ cmake_date_stamp_component() " } +cmake_toupper() +{ + echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' +} + # Detect system and directory information. cmake_system=`uname` cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd` @@ -294,11 +299,23 @@ Configuration: --verbose display more information --parallel=n bootstrap cmake in parallel, where n is number of nodes [1] - --init=FILE use FILE for cmake initialization - --system-libs use system-installed third-party libraries + --enable-ccache Enable ccache when building cmake + --init=FILE load FILE as script to populate cache + --system-libs use all system-installed third-party libraries (for use only by package maintainers) - --no-system-libs use cmake-provided third-party libraries + --no-system-libs use all cmake-provided third-party libraries (default) + --system-curl use system-installed curl library + --no-system-curl use cmake-provided curl library (default) + --system-expat use system-installed expat library + --no-system-expat use cmake-provided expat library (default) + --system-zlib use system-installed zlib library + --no-system-zlib use cmake-provided zlib library (default) + --system-bzip2 use system-installed bzip2 library + --no-system-bzip2 use cmake-provided bzip2 library (default) + --system-libarchive use system-installed libarchive library + --no-system-libarchive use cmake-provided libarchive library (default) + --qt-gui build the Qt-based GUI (requires Qt >= 4.2) --no-qt-gui do not build the Qt-based GUI (default) --qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt @@ -507,6 +524,7 @@ cmake_try_make () # Parse arguments cmake_verbose= cmake_parallel_make= +cmake_ccache_enabled= cmake_prefix_dir="${cmake_default_prefix}" for a in "$@"; do if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then @@ -528,11 +546,20 @@ for a in "$@"; do if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then cmake_init_file=`echo $a | sed "s/^--init=//"` fi + for lib in bzip2 curl expat libarchive zlib; do + if echo $a | grep "^--system-${lib}" > /dev/null 2> /dev/null; then + cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper ${lib}`=1" + break + elif echo $a | grep "^--no-system-${lib}" > /dev/null 2> /dev/null; then + cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper ${lib}`=0" + break + fi + done if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then - cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=1" + cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" fi if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then - cmake_bootstrap_system_libs="-DCMAKE_USE_SYSTEM_LIBRARIES=0" + cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" fi if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then cmake_bootstrap_qt_gui="1" @@ -553,6 +580,9 @@ for a in "$@"; do if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then cmake_verbose=TRUE fi + if echo $a | grep "^--enable-ccache" > /dev/null 2> /dev/null; then + cmake_ccache_enabled=TRUE + fi done # If verbose, display some information about bootstrap @@ -1488,13 +1518,21 @@ cd "${cmake_binary_dir}" # build with same compiler and make CC="${cmake_c_compiler}" CXX="${cmake_cxx_compiler}" +if [ -n "${cmake_ccache_enabled}" ]; then + CC="ccache ${CC}" + CXX="ccache ${CXX}" +fi MAKE="${cmake_make_processor}" export CC export CXX export MAKE # Run bootstrap CMake to configure real CMake -"${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_bootstrap_system_libs} +cmake_options="-DCMAKE_BOOTSTRAP=1" +if [ -n "${cmake_verbose}" ]; then + cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1" +fi +"${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} RES=$? if [ "${RES}" -ne "0" ]; then cmake_error 11 "Problem while running initial CMake" |