diff options
418 files changed, 9148 insertions, 4982 deletions
diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index 3a72eaa..47dad49 100644 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -51,3 +51,27 @@ if("${CPACK_GENERATOR}" STREQUAL "PackageMaker") set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr") endif() endif() + +if("${CPACK_GENERATOR}" STREQUAL "WIX") + # Reset CPACK_PACKAGE_VERSION to deal with WiX restriction. + # But the file names still use the full CMake_VERSION value: + set(CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-@CMake_VERSION@-${CPACK_SYSTEM_NAME}") + set(CPACK_SOURCE_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-@CMake_VERSION@-Source") + + if(NOT CPACK_WIX_SIZEOF_VOID_P) + set(CPACK_WIX_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@") + endif() + + set(CPACK_PACKAGE_VERSION + "@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@.@CMake_VERSION_PATCH@") + # WIX installers require at most a 4 component version number, where + # each component is an integer between 0 and 65534 inclusive + set(tweak "@CMake_VERSION_TWEAK@") + if(tweak MATCHES "^[0-9]+$") + if(tweak GREATER 0 AND tweak LESS 65535) + set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.${tweak}") + endif() + endif() +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index ea1c033..9ad9587 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,8 +234,6 @@ macro (CMAKE_BUILD_UTILITIES) set(kwsys_folder "Utilities/KWSys") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}EncodeExecutable "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}ProcessFwd9x "${kwsys_folder}") if(BUILD_TESTING) CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") @@ -585,6 +583,29 @@ option(CMAKE_STRICT "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF) mark_as_advanced(CMAKE_STRICT) +if(NOT CMake_VERSION_IS_RELEASE) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND + NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) + set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts + -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security + -Wmissing-format-attribute -fno-common + ) + set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W + -Wshadow -Wpointer-arith -Wformat-security + ) + + foreach(FLAG_LANG C CXX) + foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") + set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + endif() + endforeach() + endforeach() + + unset(C_FLAGS_LIST) + unset(CXX_FLAGS_LIST) + endif() +endif() # build the remaining subdirectories add_subdirectory(Source) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 1e6224b..495d156 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -31,6 +31,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "remark: .*LOOP WAS VECTORIZED" "warning .980: wrong number of actual arguments to intrinsic function .std::basic_" "LINK : warning LNK4089: all references to.*ADVAPI32.dll.*discarded by /OPT:REF" + "LINK : warning LNK4089: all references to.*PSAPI.DLL.*discarded by /OPT:REF" "LINK : warning LNK4089: all references to.*USER32.dll.*discarded by /OPT:REF" "Warning: library was too large for page size.*" "Warning: public.*_archive_.*in module.*archive_*clashes with prior module.*archive_.*" diff --git a/CompileFlags.cmake b/CompileFlags.cmake index b2044e4..20f5dec 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -62,3 +62,9 @@ endif () if (CMAKE_ANSI_CFLAGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") endif () + +# avoid binutils problem with large binaries, e.g. when building CMake in debug mode +# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230 +if (CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL parisc) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text.*") +endif () diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 4557be6..0f6cd05 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -369,7 +369,7 @@ function(set_bundle_key_values keys_var context item exepath dirs copyflag) # For frameworks, construct the name under the embedded path from the # opening "${item_name}.framework/" to the closing "/${item_name}": # - string(REGEX REPLACE "^.*(${item_name}.framework/.*/${item_name}).*$" "${default_embedded_path}/\\1" embedded_item "${item}") + string(REGEX REPLACE "^.*(${item_name}.framework/.*/?${item_name}).*$" "${default_embedded_path}/\\1" embedded_item "${item}") else() # For other items, just use the same name as the original, but in the # embedded path: diff --git a/Modules/CMakeAddNewLanguage.txt b/Modules/CMakeAddNewLanguage.txt index 6a30dd8..612e1a3 100644 --- a/Modules/CMakeAddNewLanguage.txt +++ b/Modules/CMakeAddNewLanguage.txt @@ -1,3 +1,19 @@ +This file provides a few notes to CMake developers about how to add +support for a new language to CMake. It is also possible to place +these files in CMAKE_MODULE_PATH within an outside project to add +languages not supported by upstream CMake. However, this is not +a fully supported use case. + +The implementation behind the scenes of project/enable_language, +including the compiler/platform modules, is an *internal* API that +does not make any compatibility guarantees. It is not covered in the +official reference documentation that is versioned with the source code. +Maintainers of external language support are responsible for porting +it to each version of CMake as upstream changes are made. Since +the API is internal we will not necessarily include notice of any +changes in release notes. + + CMakeDetermine(LANG)Compiler.cmake -> this should find the compiler for LANG and configure CMake(LANG)Compiler.cmake.in CMake(LANG)Compiler.cmake.in -> used by CMakeDetermine(LANG)Compiler.cmake diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 906a5e7..609f35b 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -107,11 +107,14 @@ Id flags: ${testflags} ") # Compile the compiler identification source. - if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)( .NET)?( 200[358])? *((Win64|IA64|ARM))?") + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)") set(vs_version ${CMAKE_MATCH_1}) - set(vs_arch ${CMAKE_MATCH_4}) + set(id_arch ${CMAKE_VS_PLATFORM_NAME}) set(id_lang "${lang}") set(id_cl cl.exe) + if(NOT id_arch) + set(id_arch Win32) + endif() if(NOT "${vs_version}" VERSION_LESS 10) set(v 10) set(ext vcxproj) @@ -123,25 +126,26 @@ Id flags: ${testflags} set(v 6) set(ext dsp) endif() - if("${vs_arch}" STREQUAL "Win64") - set(id_machine_7 17) + if("${id_arch}" STREQUAL "x64") set(id_machine_10 MachineX64) - set(id_arch x64) - elseif("${vs_arch}" STREQUAL "IA64") - set(id_machine_7 5) + elseif("${id_arch}" STREQUAL "Itanium") set(id_machine_10 MachineIA64) set(id_arch ia64) else() set(id_machine_6 x86) - set(id_machine_7 1) set(id_machine_10 MachineX86) - set(id_arch Win32) endif() if(CMAKE_VS_PLATFORM_TOOLSET) set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>") else() set(id_toolset "") endif() + if(CMAKE_VS_WINCE_VERSION) + set(id_entrypoint "mainACRTStartup") + set(id_subsystem 9) + else() + set(id_subsystem 1) + endif() if("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Bb][Uu][Ii][Ll][Dd]") set(build /p:Configuration=Debug /p:Platform=@id_arch@ /p:VisualStudioVersion=${vs_version}.0) elseif("${CMAKE_MAKE_PROGRAM}" MATCHES "[Mm][Ss][Dd][Ee][Vv]") diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index c4217f5..ae9f5fc 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -63,6 +63,8 @@ if(NOT CMAKE_Java_COMPILER) /usr/java/j2sdk1.4.2_09/bin /usr/lib/j2sdk1.5-sun/bin /opt/sun-jdk-1.5.0.04/bin + /usr/local/jdk-1.7.0/bin + /usr/local/jdk-1.6.0/bin ) # if no compiler has been specified yet, then look for one if(CMAKE_Java_COMPILER_INIT) diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index cd33447..c7f9c32 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -106,6 +106,12 @@ if(CMAKE_SYSTEM_NAME) set(CMAKE_CROSSCOMPILING TRUE) endif() set(PRESET_CMAKE_SYSTEM_NAME TRUE) +elseif(CMAKE_VS_WINCE_VERSION) + set(CMAKE_SYSTEM_NAME "WindowsCE") + set(CMAKE_SYSTEM_VERSION "${CMAKE_VS_WINCE_VERSION}") + set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}") + set(CMAKE_CROSSCOMPILING TRUE) + set(PRESET_CMAKE_SYSTEM_NAME TRUE) else() set(CMAKE_SYSTEM_NAME "${CMAKE_HOST_SYSTEM_NAME}") set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}") diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake index 14551d1..f5c009c 100644 --- a/Modules/CMakeExpandImportedTargets.cmake +++ b/Modules/CMakeExpandImportedTargets.cmake @@ -30,7 +30,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(CMakeParseArguments) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index 37b72fa..ae17454 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -77,6 +77,8 @@ endif() # This variable is used by the Eclipse generator and appended to the make invocation commands. set(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds") +set(CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES TRUE CACHE BOOL "If disabled, CMake will not generate linked resource to the subprojects and to the source files within targets") + # This variable is used by the Eclipse generator in out-of-source builds only. set(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") mark_as_advanced(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 96ecb42..a92ce7c 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -188,8 +188,13 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) endif() endforeach() + get_filename_component(inputFileName "${_inputFile}" NAME) + set(PACKAGE_INIT " ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ####### +####### Any changes to this file will be overwritten by the next CMake run #### +####### The input file was ${inputFileName} ######## + get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${PACKAGE_RELATIVE_PATH}\" ABSOLUTE) ") diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 6886ed9..42d3c0c 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -438,6 +438,7 @@ if(NOT CPACK_GENERATOR) endif() else() option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON) + option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF) option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF) endif() @@ -453,6 +454,7 @@ if(NOT CPACK_GENERATOR) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ) + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_WIX WIX) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP) endif() @@ -483,7 +485,7 @@ endif() mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11 CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2 CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ - CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE + CPACK_BINARY_NSIS CPACK_BINARY_WIX CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ CPACK_SOURCE_TZ CPACK_SOURCE_ZIP CPACK_BINARY_DRAGNDROP) @@ -522,6 +524,9 @@ cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "") cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") +# WiX specific variables +cpack_set_if_not_set(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}") + if(DEFINED CPACK_COMPONENTS_ALL) if(CPACK_MONOLITHIC_INSTALL) message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.") diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 106b44c..75ff3be 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -385,15 +385,13 @@ endif() # Are we packaging components ? if(CPACK_DEB_PACKAGE_COMPONENT) set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "-${CPACK_DEB_PACKAGE_COMPONENT}") - set(CPACK_DEB_PACKAGE_COMPONENT_PART_PATH "/${CPACK_DEB_PACKAGE_COMPONENT}") - set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_DEB_PACKAGE_COMPONENT}") string(TOLOWER "${CPACK_PACKAGE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_NAME}" CPACK_DEBIAN_PACKAGE_NAME) else() set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "") - set(CPACK_DEB_PACKAGE_COMPONENT_PART_PATH "") - set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") endif() +set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}") + # Print out some debug information if we were asked for that if(CPACK_DEBIAN_PACKAGE_DEBUG) message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 0cec897..34d0045 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -311,14 +311,12 @@ endif() # Are we packaging components ? if(CPACK_RPM_PACKAGE_COMPONENT) set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") - set(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") - set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") else() set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") - set(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") - set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") endif() +set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") + # # Use user-defined RPM specific variables value # or generate reasonable default value from diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake new file mode 100644 index 0000000..0c0a8f1 --- /dev/null +++ b/Modules/CPackWIX.cmake @@ -0,0 +1,109 @@ +##section Variables specific to CPack WiX generator +##end +##module +# - CPack WiX generator specific options +# +# The following variables are specific to the installers built +# on Windows using WiX. +##end +##variable +# CPACK_WIX_UPGRADE_GUID - Upgrade GUID (Product/@UpgradeCode) +# +# Will be automatically generated unless explicitly provided. +# +# It should be explicitly set to a constant generated +# gloabally unique identifier (GUID) to allow your installers +# to replace existing installations that use the same GUID. +# +# You may for example explicitly set this variable in +# your CMakeLists.txt to the value that has been generated per default. +# You should not use GUIDs that you did not generate yourself or which may +# belong to other projects. +# +# A GUID shall have the following fixed length syntax: +# XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX +# (each X represents an uppercase hexadecimal digit) +##end +##variable +# CPACK_WIX_PRODUCT_GUID - Product GUID (Product/@Id) +# +# Will be automatically generated unless explicitly provided. +# +# If explicitly provided this will set the Product Id of your installer. +# +# The installer will abort if it detects a pre-existing installation that uses +# the same GUID. +# +# The GUID shall use the syntax described for CPACK_WIX_UPGRADE_GUID. +##end +##variable +# CPACK_WIX_LICENSE_RTF - RTF License File +# +# If CPACK_RESOURCE_FILE_LICENSE has an .rtf extension +# it is used as-is. +# +# If CPACK_RESOURCE_FILE_LICENSE has an .txt extension +# it is implicitly converted to RTF by the WiX Generator. +# +# With CPACK_WIX_LICENSE_RTF you can override the license file used +# by the WiX Generator in case CPACK_RESOURCE_FILE_LICENSE +# is in an unsupported format or the .txt -> .rtf +# conversion does not work as expected. +# +##end +# +##variable +# CPACK_WIX_PRODUCT_ICON - The Icon shown next to the program name in Add/Remove programs. +# +# If set, this icon is used in place of the default icon. +# +##end +# +##variable +# CPACK_WIX_UI_BANNER - The bitmap will appear at the top of all installer pages other than the welcome and completion dialogs. +# +# If set, this image will replace the default banner image. +# +# This image must be 493 by 58 pixels. +# +##end +# +##variable +# CPACK_WIX_UI_DIALOG - Background bitmap used on the welcome and completion dialogs. +# +# If this variable is set, the installer will replace the default dialog image. +# +# This image must be 493 by 312 pixels. +# +##end + +#============================================================================= +# Copyright 2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(NOT CPACK_WIX_ROOT) + file(TO_CMAKE_PATH "$ENV{WIX}" CPACK_WIX_ROOT) +endif() + +find_program(CPACK_WIX_CANDLE_EXECUTABLE candle + PATHS "${CPACK_WIX_ROOT}/bin") + +if(NOT CPACK_WIX_CANDLE_EXECUTABLE) + message(FATAL_ERROR "Could not find the WiX candle executable.") +endif() + +find_program(CPACK_WIX_LIGHT_EXECUTABLE light + PATHS "${CPACK_WIX_ROOT}/bin") + +if(NOT CPACK_WIX_LIGHT_EXECUTABLE) + message(FATAL_ERROR "Could not find the WiX light executable.") +endif() diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake index 6731d37..24f5f2e 100644 --- a/Modules/CTestUseLaunchers.cmake +++ b/Modules/CTestUseLaunchers.cmake @@ -35,7 +35,7 @@ if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT}) CACHE INTERNAL "CTEST_USE_LAUNCHERS initial value from ENV") endif() -if(NOT "${CMAKE_GENERATOR}" MATCHES "Make") +if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja") set(CTEST_USE_LAUNCHERS 0) endif() diff --git a/Modules/Compiler/TI_DSP-ASM.cmake b/Modules/Compiler/TI_DSP-ASM.cmake new file mode 100644 index 0000000..e097626 --- /dev/null +++ b/Modules/Compiler/TI_DSP-ASM.cmake @@ -0,0 +1,8 @@ +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") +set(CMAKE_INCLUDE_FLAG_ASM "--include_path=") + +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --compile_only --asm_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<OBJECT>") +set(CMAKE_ASM_LINK_EXECUTABLE "<CMAKE_ASM_COMPILER> <OBJECTS> --run_linker --output_file=<TARGET> <CMAKE_ASM_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>") + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm;s;abs) diff --git a/Modules/Compiler/TI_DSP-C.cmake b/Modules/Compiler/TI_DSP-C.cmake new file mode 100644 index 0000000..b580994 --- /dev/null +++ b/Modules/Compiler/TI_DSP-C.cmake @@ -0,0 +1,10 @@ +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") +set(CMAKE_INCLUDE_FLAG_C "--include_path=") + +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> --compile_only --skip_assembler --c_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> --preproc_only --c_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") + +set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> --compile_only --c_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<OBJECT>") +set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -r <TARGET> <OBJECTS>") +set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_LIBRARIES> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Compiler/TI_DSP-CXX.cmake b/Modules/Compiler/TI_DSP-CXX.cmake new file mode 100644 index 0000000..8cf5ac3 --- /dev/null +++ b/Modules/Compiler/TI_DSP-CXX.cmake @@ -0,0 +1,10 @@ +set(CMAKE_LIBRARY_PATH_FLAG "--search_path=") +set(CMAKE_LINK_LIBRARY_FLAG "--library=") +set(CMAKE_INCLUDE_FLAG_CXX "--include_path=") + +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> --compile_only --skip_assembler --cpp_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>") +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> --preproc_only --cpp_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") + +set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> --compile_only --cpp_file=<SOURCE> <DEFINES> <FLAGS> --output_file=<OBJECT>") +set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -r <TARGET> <OBJECTS>") +set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_CXX_LINK_FLAGS> <LINK_LIBRARIES> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/CompilerId/VS-7.vcproj.in b/Modules/CompilerId/VS-7.vcproj.in index 71bf64d..fa48cad 100644 --- a/Modules/CompilerId/VS-7.vcproj.in +++ b/Modules/CompilerId/VS-7.vcproj.in @@ -24,7 +24,6 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - PreprocessorDefinitions="" MinimalRebuild="false" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -35,9 +34,10 @@ <Tool Name="VCLinkerTool" LinkIncremental="1" + IgnoreDefaultLibraryNames="libc" GenerateDebugInformation="false" - SubSystem="1" - TargetMachine="@id_machine_7@" + SubSystem="@id_subsystem@" + EntryPointSymbol="@id_entrypoint@" /> <Tool Name="VCPostBuildEventTool" diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index 309fce3..5f8a9fb 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -80,7 +80,7 @@ # The functions defined in this file depend on the fixup_bundle function # (and others) found in BundleUtilities.cmake -include(BundleUtilities) +include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake") set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") set(DeployQt4_apple_plugins_dir "PlugIns") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 8d57860..2355dac 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -402,6 +402,79 @@ endif() endfunction() +function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_repository work_dir) + file(WRITE ${script_filename} +"if(\"${git_tag}\" STREQUAL \"\") + message(FATAL_ERROR \"Tag for git checkout should not be empty.\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 HEAD + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + OUTPUT_VARIABLE head_sha + ) +if(error_code) + message(FATAL_ERROR \"Failed to get the hash for HEAD\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" show-ref ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + OUTPUT_VARIABLE show_ref_output + ) +# If a remote ref is asked for, which can possibly move around, +# we must always do a fetch and checkout. +if(\"\${show_ref_output}\" MATCHES \"remotes\") + set(is_remote_ref 1) +else() + set(is_remote_ref 0) +endif() + +# This will fail if the tag does not exist (it probably has not been fetched +# yet). +execute_process( + COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + OUTPUT_VARIABLE tag_sha + ) + +# Is the hash checkout out that we want? +if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\")) + execute_process( + COMMAND \"${git_EXECUTABLE}\" fetch + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\") + endif() + + execute_process( + COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") + endif() + + execute_process( + COMMAND \"${git_EXECUTABLE}\" submodule update --recursive + WORKING_DIRECTORY \"${work_dir}/${src_name}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\") + endif() +endif() + +" +) + +endfunction(_ep_write_gitupdate_script) + function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo) if(timeout) set(timeout_args TIMEOUT ${timeout}) @@ -1354,7 +1427,7 @@ endfunction() function(_ep_add_update_command name) - ExternalProject_Get_Property(${name} source_dir) + ExternalProject_Get_Property(${name} source_dir tmp_dir) get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET) get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND) @@ -1406,15 +1479,15 @@ function(_ep_add_update_command name) message(FATAL_ERROR "error: could not find git for fetch of ${name}") endif() set(work_dir ${source_dir}) - set(comment "Performing update step (git fetch) for '${name}'") + set(comment "Performing update step for '${name}'") get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) if(NOT git_tag) set(git_tag "master") endif() - set(cmd ${GIT_EXECUTABLE} fetch - COMMAND ${GIT_EXECUTABLE} checkout ${git_tag} - COMMAND ${GIT_EXECUTABLE} submodule update --recursive + _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake + ${GIT_EXECUTABLE} ${git_tag} ${git_repository} ${work_dir} ) + set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake) set(always 1) elseif(hg_repository) if(NOT HG_EXECUTABLE) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 41bce1e..5d98ac3 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -177,7 +177,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(CMakeParseArguments) +include("${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake") function(ADD_FEATURE_INFO _name _enabled _desc) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index a0afd34..4a3e68c 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -47,7 +47,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -find_program(BISON_EXECUTABLE bison DOC "path to the bison executable") +find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable") mark_as_advanced(BISON_EXECUTABLE) if(BISON_EXECUTABLE) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d9b3c61..f8a284d 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -40,8 +40,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(CheckFunctionExists) -include(CheckFortranFunctionExists) +include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 8b9d235..9fb29d0 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -49,7 +49,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 VERSION_VAR BZIP2_VERSION_STRING) if (BZIP2_FOUND) - include(CheckLibraryExists) + include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX) endif () diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 17aba1b..8d8b10c 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1,248 +1,141 @@ -# - Try to find Boost include dirs and libraries -# Usage of this module as follows: -# -# NOTE: Take note of the Boost_ADDITIONAL_VERSIONS variable below. -# Due to Boost naming conventions and limitations in CMake this find -# module is NOT future safe with respect to Boost version numbers, -# and may break. -# -# == Using Header-Only libraries from within Boost: == -# -# find_package( Boost 1.36.0 ) -# if(Boost_FOUND) -# include_directories(${Boost_INCLUDE_DIRS}) -# add_executable(foo foo.cc) -# endif() -# -# -# == Using actual libraries from within Boost: == -# -# set(Boost_USE_STATIC_LIBS ON) -# set(Boost_USE_MULTITHREADED ON) -# set(Boost_USE_STATIC_RUNTIME OFF) -# find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... ) -# -# if(Boost_FOUND) -# include_directories(${Boost_INCLUDE_DIRS}) -# add_executable(foo foo.cc) -# target_link_libraries(foo ${Boost_LIBRARIES}) -# endif() -# -# -# The components list needs to contain actual names of boost libraries only, -# such as "date_time" for "libboost_date_time". If you're using parts of -# Boost that contain header files only (e.g. foreach) you do not need to -# specify COMPONENTS. -# -# You should provide a minimum version number that should be used. If you provide this -# version number and specify the REQUIRED attribute, this module will fail if it -# can't find the specified or a later version. If you specify a version number this is -# automatically put into the considered list of version numbers and thus doesn't need -# to be specified in the Boost_ADDITIONAL_VERSIONS variable (see below). -# -# NOTE for Visual Studio Users: -# Automatic linking is used on MSVC & Borland compilers by default when -# #including things in Boost. It's important to note that setting -# Boost_USE_STATIC_LIBS to OFF is NOT enough to get you dynamic linking, -# should you need this feature. Automatic linking typically uses static -# libraries with a few exceptions (Boost.Python is one). -# -# Please see the section below near Boost_LIB_DIAGNOSTIC_DEFINITIONS for -# more details. Adding a target_link_libraries() as shown in the example -# above appears to cause VS to link dynamically if Boost_USE_STATIC_LIBS -# gets set to OFF. It is suggested you avoid automatic linking since it -# will make your application less portable. -# -# =========== The mess that is Boost_ADDITIONAL_VERSIONS (sorry?) ============ -# -# OK, so the Boost_ADDITIONAL_VERSIONS variable can be used to specify a list of -# boost version numbers that should be taken into account when searching -# for Boost. Unfortunately boost puts the version number into the -# actual filename for the libraries, so this variable will certainly be needed -# in the future when new Boost versions are released. -# -# Currently this module searches for the following version numbers: -# 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, -# 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, -# 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, -# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0, -# 1.49, 1.49.0, 1.50, 1.50.0, 1.51, 1.51.0, 1.52, 1.52.0, -# 1.53, 1.53.0, 1.54, 1.54.0, 1.55, 1.55.0, 1.56, 1.56.0 -# -# NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should -# add both 1.x and 1.x.0 as shown above. Official Boost include directories -# omit the 3rd version number from include paths if it is 0 although not all -# binary Boost releases do so. -# -# set(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0") -# -# ===================================== ============= ======================== -# -# Variables used by this module, they can change the default behaviour and -# need to be set before calling find_package: -# -# Boost_USE_MULTITHREADED Can be set to OFF to use the non-multithreaded -# boost libraries. If not specified, defaults -# to ON. -# -# Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static -# boost libraries. Defaults to OFF. -# -# Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system -# paths (or other locations outside of BOOST_ROOT -# or BOOST_INCLUDEDIR). Useful when specifying -# BOOST_ROOT. Defaults to OFF. -# [Since CMake 2.8.3] -# -# Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode -# before searching for a regular boost install. -# This will avoid finding boost-cmake installs. -# Defaults to OFF. -# [Since CMake 2.8.6] -# -# Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries -# linked against a static C++ standard library -# ('s' ABI tag). This option should be set to -# ON or OFF because the default behavior -# if not specified is platform dependent -# for backwards compatibility. -# [Since CMake 2.8.3] -# -# Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries -# compiled against a special debug build of -# Python ('y' ABI tag). Defaults to OFF. -# [Since CMake 2.8.3] -# -# Boost_USE_STLPORT If enabled, searches for boost libraries -# compiled against the STLPort standard -# library ('p' ABI tag). Defaults to OFF. -# [Since CMake 2.8.3] -# -# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS -# If enabled, searches for boost libraries -# compiled against the deprecated STLPort -# "native iostreams" feature ('n' ABI tag). -# Defaults to OFF. -# [Since CMake 2.8.3] -# -# Other Variables used by this module which you may want to set. -# -# Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching -# the boost include directory. Please see -# the documentation above regarding this -# annoying, but necessary variable :( -# -# Boost_DEBUG Set this to TRUE to enable debugging output -# of FindBoost.cmake if you are having problems. -# Please enable this before filing any bug -# reports. -# -# Boost_DETAILED_FAILURE_MSG FindBoost doesn't output detailed information -# about why it failed or how to fix the problem -# unless this is set to TRUE or the REQUIRED -# keyword is specified in find_package(). -# [Since CMake 2.8.0] -# -# Boost_COMPILER Set this to the compiler suffix used by Boost -# (e.g. "-gcc43") if FindBoost has problems finding -# the proper Boost installation -# -# Boost_THREADAPI When building boost.thread, sometimes the name of the -# library contains an additional "pthread" or "win32" -# string known as the threadapi. This can happen when -# compiling against pthreads on Windows or win32 threads -# on Cygwin. You may specify this variable and if set -# when FindBoost searches for the Boost threading library -# it will first try to match the threadapi you specify. -# For Example: libboost_thread_win32-mgw45-mt-1_43.a -# might be found if you specified "win32" here before -# falling back on libboost_thread-mgw45-mt-1_43.a. -# [Since CMake 2.8.3] -# -# Boost_REALPATH Resolves symbolic links for discovered boost libraries -# to assist with packaging. For example, instead of -# Boost_SYSTEM_LIBRARY_RELEASE being resolved to -# "/usr/lib/libboost_system.so" it would be -# "/usr/lib/libboost_system.so.1.42.0" instead. -# This does not affect linking and should not be -# enabled unless the user needs this information. -# [Since CMake 2.8.3] -# - - -# -# These last three variables are available also as environment variables: -# Also, note they are completely UPPERCASE, except Boost_DIR. -# -# Boost_DIR or The preferred installation prefix for searching for -# BOOST_ROOT or BOOSTROOT Boost. Set this if the module has problems finding -# the proper Boost installation. -# -# Note that Boost_DIR behaves exactly as <package>_DIR -# variables are documented to behave in find_package's -# Config mode. That is, if it is set as a -D argument -# to CMake, it must point to the location of the -# BoostConfig.cmake or Boost-config.cmake file. If it -# is set as an environment variable, it must point to -# the root of the boost installation. BOOST_ROOT and -# BOOSTROOT, on the other hand, will point to the root -# in either case. -# -# To prevent falling back on the system paths, set -# Boost_NO_SYSTEM_PATHS to true. -# -# To avoid finding boost-cmake installations, set -# Boost_NO_BOOST_CMAKE to true. -# -# BOOST_INCLUDEDIR Set this to the include directory of Boost, if the -# module has problems finding the proper Boost installation -# -# BOOST_LIBRARYDIR Set this to the lib directory of Boost, if the -# module has problems finding the proper Boost installation -# -# Variables defined by this module: -# -# Boost_FOUND System has Boost, this means the include dir was -# found, as well as all the libraries specified in -# the COMPONENTS list. -# -# Boost_INCLUDE_DIRS Boost include directories: not cached -# -# Boost_INCLUDE_DIR This is almost the same as above, but this one is -# cached and may be modified by advanced users -# -# Boost_LIBRARIES Link to these to use the Boost libraries that you -# specified: not cached -# -# Boost_LIBRARY_DIRS The path to where the Boost library files are. -# -# Boost_VERSION The version number of the boost libraries that -# have been found, same as in version.hpp from Boost -# -# Boost_LIB_VERSION The version number in filename form as -# it's appended to the library filenames -# -# Boost_MAJOR_VERSION major version number of boost -# Boost_MINOR_VERSION minor version number of boost -# Boost_SUBMINOR_VERSION subminor version number of boost -# -# Boost_LIB_DIAGNOSTIC_DEFINITIONS [WIN32 Only] You can call -# add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) -# to have diagnostic information about Boost's -# automatic linking outputted during compilation time. -# -# For each component you specify in find_package(), the following (UPPER-CASE) -# variables are set. You can use these variables if you would like to pick and -# choose components for your targets instead of just using Boost_LIBRARIES. -# -# Boost_${COMPONENT}_FOUND True IF the Boost library "component" was found. -# -# Boost_${COMPONENT}_LIBRARY Contains the libraries for the specified Boost -# "component" (includes debug and optimized keywords -# when needed). +# - Find Boost include dirs and libraries +# Use this module by invoking find_package with the form: +# find_package(Boost +# [version] [EXACT] # Minimum or EXACT version e.g. 1.36.0 +# [REQUIRED] # Fail with error if Boost is not found +# [COMPONENTS <libs>...] # Boost libraries by their canonical name +# ) # e.g. "date_time" for "libboost_date_time" +# This module finds headers and requested component libraries OR a CMake +# package configuration file provided by a "Boost CMake" build. For the +# latter case skip to the "Boost CMake" section below. For the former +# case results are reported in variables: +# Boost_FOUND - True if headers and requested libraries were found +# Boost_INCLUDE_DIRS - Boost include directories +# Boost_LIBRARY_DIRS - Link directories for Boost libraries +# Boost_LIBRARIES - Boost component libraries to be linked +# Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case) +# Boost_<C>_LIBRARY - Libraries to link for component <C> (may include +# target_link_libraries debug/optimized keywords) +# Boost_VERSION - BOOST_VERSION value from boost/version.hpp +# Boost_LIB_VERSION - Version string appended to library filenames +# Boost_MAJOR_VERSION - Boost major version number (X in X.y.z) +# Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z) +# Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z) +# Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows) +# - Pass to add_definitions() to have diagnostic +# information about Boost's automatic linking +# displayed during compilation +# +# This module reads hints about search locations from variables: +# BOOST_ROOT - Preferred installation prefix +# (or BOOSTROOT) +# BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include +# BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib +# Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not +# specified by these hint variables. Default is OFF. +# Boost_ADDITIONAL_VERSIONS +# - List of Boost versions not known to this module +# (Boost install locations may contain the version) +# and saves search results persistently in CMake cache entries: +# Boost_INCLUDE_DIR - Directory containing Boost headers +# Boost_LIBRARY_DIR - Directory containing Boost libraries +# Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant +# Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant +# Users may set the these hints or results as cache entries. Projects should +# not read these entries directly but instead use the above result variables. +# Note that some hint names start in upper-case "BOOST". One may specify +# these as environment variables if they are not specified as CMake variables +# or cache entries. +# +# This module first searches for the Boost header files using the above hint +# variables (excluding BOOST_LIBRARYDIR) and saves the result in +# Boost_INCLUDE_DIR. Then it searches for requested component libraries using +# the above hints (excluding BOOST_INCLUDEDIR and Boost_ADDITIONAL_VERSIONS), +# "lib" directories near Boost_INCLUDE_DIR, and the library name configuration +# settings below. It saves the library directory in Boost_LIBRARY_DIR and +# individual library locations in Boost_<C>_LIBRARY_DEBUG and +# Boost_<C>_LIBRARY_RELEASE. When one changes settings used by previous +# searches in the same build tree (excluding environment variables) this +# module discards previous search results affected by the changes and searches +# again. +# +# Boost libraries come in many variants encoded in their file name. Users or +# projects may tell this module which variant to find by setting variables: +# Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded +# libraries ('mt' tag). Default is ON. +# Boost_USE_STATIC_LIBS - Set to ON to force the use of the static +# libraries. Default is OFF. +# Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use +# libraries linked statically to the C++ runtime +# ('s' tag). Default is platform dependent. +# Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a +# debug Python build ('y' tag). Default is OFF. +# Boost_USE_STLPORT - Set to ON to use libraries compiled with +# STLPort ('p' tag). Default is OFF. +# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS +# - Set to ON to use libraries compiled with +# STLPort deprecated "native iostreams" +# ('n' tag). Default is OFF. +# Boost_COMPILER - Set to the compiler-specific library suffix +# (e.g. "-gcc43"). Default is auto-computed +# for the C++ compiler in use. +# Boost_THREADAPI - Suffix for "thread" component library name, +# such as "pthread" or "win32". Names with +# and without this suffix will both be tried. +# Other variables one may set to control this module are: +# Boost_DEBUG - Set to ON to enable debug output from FindBoost. +# Please enable this before filing any bug report. +# Boost_DETAILED_FAILURE_MSG +# - Set to ON to add detailed information to the +# failure message even when the REQUIRED option +# is not given to the find_package call. +# Boost_REALPATH - Set to ON to resolve symlinks for discovered +# libraries to assist with packaging. For example, +# the "system" component library may be resolved to +# "/usr/lib/libboost_system.so.1.42.0" instead of +# "/usr/lib/libboost_system.so". This does not +# affect linking and should not be enabled unless +# the user needs this information. +# On Visual Studio and Borland compilers Boost headers request automatic +# linking to corresponding libraries. This requires matching libraries to be +# linked explicitly or available in the link library search path. In this +# case setting Boost_USE_STATIC_LIBS to OFF may not achieve dynamic linking. +# Boost automatic linking typically requests static libraries with a few +# exceptions (such as Boost.Python). Use +# add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) +# to ask Boost to report information about automatic linking requests. +# +# Example to find Boost headers only: +# find_package(Boost 1.36.0) +# if(Boost_FOUND) +# include_directories(${Boost_INCLUDE_DIRS}) +# add_executable(foo foo.cc) +# endif() +# Example to find Boost headers and some libraries: +# set(Boost_USE_STATIC_LIBS ON) +# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_RUNTIME OFF) +# find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...) +# if(Boost_FOUND) +# include_directories(${Boost_INCLUDE_DIRS}) +# add_executable(foo foo.cc) +# target_link_libraries(foo ${Boost_LIBRARIES}) +# endif() +# +# Boost CMake ---------------------------------------------------------- +# +# If Boost was built using the boost-cmake project it provides a package +# configuration file for use with find_package's Config mode. This module +# looks for the package configuration file called BoostConfig.cmake or +# boost-config.cmake and stores the result in cache entry "Boost_DIR". If +# found, the package configuration file is loaded and this module returns with +# no further action. See documentation of the Boost CMake package +# configuration for details on what it provides. +# +# Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake. #============================================================================= -# Copyright 2006-2009 Kitware, Inc. +# Copyright 2006-2012 Kitware, Inc. # Copyright 2006-2008 Andreas Schneider <mail@cynapses.org> # Copyright 2007 Wengo # Copyright 2007 Mike Jackson @@ -282,6 +175,7 @@ if (NOT Boost_NO_BOOST_CMAKE) # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no # need to delegate them to this find_package call. find_package(Boost QUIET NO_MODULE) + mark_as_advanced(Boost_DIR) # If we found boost-cmake, then we're done. Print out what we found. # Otherwise let the rest of the module try to find it. @@ -349,29 +243,54 @@ macro(_Boost_ADJUST_LIB_VARS basename) endif() if(Boost_${basename}_LIBRARY) - set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") - - # Remove superfluous "debug" / "optimized" keywords from - # Boost_LIBRARY_DIRS - foreach(_boost_my_lib ${Boost_${basename}_LIBRARY}) - get_filename_component(_boost_my_lib_path "${_boost_my_lib}" PATH) - list(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path}) - endforeach() - list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) - - set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory") - set(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") + set(Boost_${basename}_FOUND ON) endif() endif() # Make variables changeble to the advanced user mark_as_advanced( - Boost_${basename}_LIBRARY Boost_${basename}_LIBRARY_RELEASE Boost_${basename}_LIBRARY_DEBUG ) endmacro() +macro(_Boost_CHANGE_DETECT changed_var) + set(${changed_var} 0) + foreach(v ${ARGN}) + if(DEFINED _Boost_COMPONENTS_SEARCHED) + if(${v}) + if(_${v}_LAST) + string(COMPARE NOTEQUAL "${${v}}" "${_${v}_LAST}" _${v}_CHANGED) + else() + set(_${v}_CHANGED 1) + endif() + elseif(_${v}_LAST) + set(_${v}_CHANGED 1) + endif() + if(_${v}_CHANGED) + set(${changed_var} 1) + endif() + else() + set(_${v}_CHANGED 0) + endif() + endforeach() +endmacro() + +macro(_Boost_FIND_LIBRARY var) + find_library(${var} ${ARGN}) + + # If we found the first library save Boost_LIBRARY_DIR. + if(${var} AND NOT Boost_LIBRARY_DIR) + get_filename_component(_dir "${${var}}" PATH) + set(Boost_LIBRARY_DIR "${_dir}" CACHE PATH "Boost library directory" FORCE) + endif() + + # If Boost_LIBRARY_DIR is known then search only there. + if(Boost_LIBRARY_DIR) + set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH) + endif() +endmacro() + #------------------------------------------------------------------------------- # @@ -391,17 +310,6 @@ function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) endfunction() # -# A convenience function for marking desired components -# as found or not -# -function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no) - foreach(COMPONENT ${Boost_FIND_COMPONENTS}) - string(TOUPPER ${COMPONENT} UPPERCOMPONENT) - set(Boost_${UPPERCOMPONENT}_FOUND ${_yes_or_no} CACHE INTERNAL "Whether the Boost ${COMPONENT} library found" FORCE) - endforeach() -endfunction() - -# # Take a list of libraries with "thread" in it # and prepend duplicates with "thread_${Boost_THREADAPI}" # at the front of the list @@ -561,652 +469,679 @@ endif() # Boost. set(Boost_ERROR_REASON) - if(Boost_DEBUG) - # Output some of their choices - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}") - endif() - - if(WIN32) - # In windows, automatic linking is performed, so you do not have - # to specify the libraries. If you are linking to a dynamic - # runtime, then you can choose to link to either a static or a - # dynamic Boost library, the default is to do a static link. You - # can alter this for a specific library "whatever" by defining - # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be - # linked dynamically. Alternatively you can force all Boost - # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. - - # This feature can be disabled for Boost library "whatever" by - # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining - # BOOST_ALL_NO_LIB. - - # If you want to observe which libraries are being linked against - # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking - # code to emit a #pragma message each time a library is selected - # for linking. - set(Boost_LIB_DIAGNOSTIC_DEFINITIONS - "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") - endif() +if(Boost_DEBUG) + # Output some of their choices + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}") +endif() - set(_boost_INCLUDE_SEARCH_DIRS_SYSTEM - C:/boost/include - C:/boost - "$ENV{ProgramFiles}/boost/include" - "$ENV{ProgramFiles}/boost" - /sw/local/include - ) +if(WIN32) + # In windows, automatic linking is performed, so you do not have + # to specify the libraries. If you are linking to a dynamic + # runtime, then you can choose to link to either a static or a + # dynamic Boost library, the default is to do a static link. You + # can alter this for a specific library "whatever" by defining + # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be + # linked dynamically. Alternatively you can force all Boost + # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. + + # This feature can be disabled for Boost library "whatever" by + # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining + # BOOST_ALL_NO_LIB. + + # If you want to observe which libraries are being linked against + # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking + # code to emit a #pragma message each time a library is selected + # for linking. + set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") +endif() - _Boost_CHECK_SPELLING(Boost_ROOT) - _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) - _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) +_Boost_CHECK_SPELLING(Boost_ROOT) +_Boost_CHECK_SPELLING(Boost_LIBRARYDIR) +_Boost_CHECK_SPELLING(Boost_INCLUDEDIR) - # If BOOST_ROOT was defined in the environment, use it. - if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "") - set(BOOST_ROOT $ENV{Boost_DIR}) +# Collect environment variable inputs as hints. Do not consider changes. +foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR) + set(_env $ENV{${v}}) + if(_env) + file(TO_CMAKE_PATH "${_env}" _ENV_${v}) + else() + set(_ENV_${v} "") endif() +endforeach() +if(NOT _ENV_BOOST_ROOT AND _ENV_BOOSTROOT) + set(_ENV_BOOST_ROOT "${_ENV_BOOSTROOT}") +endif() - # If BOOST_ROOT was defined in the environment, use it. - if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") - set(BOOST_ROOT $ENV{BOOST_ROOT}) - endif() +# Collect inputs and cached results. Detect changes since the last run. +if(NOT BOOST_ROOT AND BOOSTROOT) + set(BOOST_ROOT "${BOOSTROOT}") +endif() +set(_Boost_VARS_DIR + BOOST_ROOT + Boost_NO_SYSTEM_PATHS + ) - # If BOOSTROOT was defined in the environment, use it. - if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") - set(BOOST_ROOT $ENV{BOOSTROOT}) - endif() +if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Declared as CMake or Environmental Variables:") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " BOOST_ROOT = ${BOOST_ROOT}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") +endif() - # If BOOST_INCLUDEDIR was defined in the environment, use it. - if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) - set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR}) - endif() +# ------------------------------------------------------------------------ +# Search for Boost include DIR +# ------------------------------------------------------------------------ - # If BOOST_LIBRARYDIR was defined in the environment, use it. - if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) - set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR}) - endif() +set(_Boost_VARS_INC BOOST_INCLUDEDIR Boost_INCLUDE_DIR Boost_ADDITIONAL_VERSIONS) +_Boost_CHANGE_DETECT(_Boost_CHANGE_INCDIR ${_Boost_VARS_DIR} ${_Boost_VARS_INC}) +# Clear Boost_INCLUDE_DIR if it did not change but other input affecting the +# location did. We will find a new one based on the new inputs. +if(_Boost_CHANGE_INCDIR AND NOT _Boost_INCLUDE_DIR_CHANGED) + unset(Boost_INCLUDE_DIR CACHE) +endif() - if( BOOST_ROOT ) - file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT) +if(NOT Boost_INCLUDE_DIR) + set(_boost_INCLUDE_SEARCH_DIRS "") + if(BOOST_INCLUDEDIR) + list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR}) + elseif(_ENV_BOOST_INCLUDEDIR) + list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_INCLUDEDIR}) endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Declared as CMake or Environmental Variables:") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " BOOST_ROOT = ${BOOST_ROOT}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") + if( BOOST_ROOT ) + list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT}) + elseif( _ENV_BOOST_ROOT ) + list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_ROOT}/include ${_ENV_BOOST_ROOT}) endif() if( Boost_NO_SYSTEM_PATHS) - set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH) else() - set(_boost_INCLUDE_SEARCH_DIRS ${_boost_INCLUDE_SEARCH_DIRS_SYSTEM}) - endif() - - if( BOOST_ROOT ) - set(_boost_INCLUDE_SEARCH_DIRS - ${BOOST_ROOT}/include - ${BOOST_ROOT} - ${_boost_INCLUDE_SEARCH_DIRS}) - endif() - - # prepend BOOST_INCLUDEDIR to search path if specified - if( BOOST_INCLUDEDIR ) - file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR) - set(_boost_INCLUDE_SEARCH_DIRS - ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) + list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS + C:/boost/include + C:/boost + /sw/local/include + ) endif() - # ------------------------------------------------------------------------ - # Search for Boost include DIR - # ------------------------------------------------------------------------ # Try to find Boost by stepping backwards through the Boost versions # we know about. - if( NOT Boost_INCLUDE_DIR ) - # Build a list of path suffixes for each version. - set(_boost_PATH_SUFFIXES) - foreach(_boost_VER ${_boost_TEST_VERSIONS}) - # Add in a path suffix, based on the required version, ideally - # we could read this from version.hpp, but for that to work we'd - # need to know the include dir already - set(_boost_BOOSTIFIED_VERSION) - - # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 - if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" - _boost_BOOSTIFIED_VERSION ${_boost_VER}) - elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+") - string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" - _boost_BOOSTIFIED_VERSION ${_boost_VER}) - endif() - - list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") - list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") - - endforeach() - - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Include debugging info:") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}") + # Build a list of path suffixes for each version. + set(_boost_PATH_SUFFIXES) + foreach(_boost_VER ${_boost_TEST_VERSIONS}) + # Add in a path suffix, based on the required version, ideally + # we could read this from version.hpp, but for that to work we'd + # need to know the include dir already + set(_boost_BOOSTIFIED_VERSION) + + # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 + if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" + _boost_BOOSTIFIED_VERSION ${_boost_VER}) + elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" + _boost_BOOSTIFIED_VERSION ${_boost_VER}) endif() - # Look for a standard boost header file. - find_path(Boost_INCLUDE_DIR - NAMES boost/config.hpp - HINTS ${_boost_INCLUDE_SEARCH_DIRS} - PATH_SUFFIXES ${_boost_PATH_SUFFIXES} - ${_boost_FIND_OPTIONS} + list(APPEND _boost_PATH_SUFFIXES + "boost-${_boost_BOOSTIFIED_VERSION}" + "boost_${_boost_BOOSTIFIED_VERSION}" + "boost/boost-${_boost_BOOSTIFIED_VERSION}" + "boost/boost_${_boost_BOOSTIFIED_VERSION}" ) - endif() - # ------------------------------------------------------------------------ - # Extract version information from version.hpp - # ------------------------------------------------------------------------ - - if(Boost_INCLUDE_DIR) - # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp - # Read the whole file: - # - set(BOOST_VERSION 0) - set(BOOST_LIB_VERSION "") - file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ") - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") - endif() + endforeach() - string(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}") - string(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}") - unset(_boost_VERSION_HPP_CONTENTS) + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Include debugging info:") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}") + endif() - set(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries") - set(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries") + # Look for a standard boost header file. + find_path(Boost_INCLUDE_DIR + NAMES boost/config.hpp + HINTS ${_boost_INCLUDE_SEARCH_DIRS} + PATH_SUFFIXES ${_boost_PATH_SUFFIXES} + ) +endif() - if(NOT "${Boost_VERSION}" STREQUAL "0") - math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") - math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") - math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") +# ------------------------------------------------------------------------ +# Extract version information from version.hpp +# ------------------------------------------------------------------------ - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") - endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "version.hpp reveals boost " - "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - endif() - else() - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") +# Set Boost_FOUND based only on header location and version. +# It will be updated below for component libraries. +if(Boost_INCLUDE_DIR) + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") endif() - # ------------------------------------------------------------------------ - # Suffix initialization and compiler suffix detection. - # ------------------------------------------------------------------------ + # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp + set(Boost_VERSION 0) + set(Boost_LIB_VERSION "") + file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ") + set(_Boost_VERSION_REGEX "([0-9]+)") + set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"") + foreach(v VERSION LIB_VERSION) + if("${_boost_VERSION_HPP_CONTENTS}" MATCHES ".*#define BOOST_${v} ${_Boost_${v}_REGEX}.*") + set(Boost_${v} "${CMAKE_MATCH_1}") + endif() + endforeach() + unset(_boost_VERSION_HPP_CONTENTS) + + math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") + math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") + math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") - # Setting some more suffixes for the library - set(Boost_LIB_PREFIX "") - if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) - set(Boost_LIB_PREFIX "lib") + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "version.hpp reveals boost " + "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") endif() - if (Boost_COMPILER) - set(_boost_COMPILER ${Boost_COMPILER}) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "using user-specified Boost_COMPILER = ${_boost_COMPILER}") + if(Boost_FIND_VERSION) + # Set Boost_FOUND based on requested version. + set(_Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") + if("${_Boost_VERSION}" VERSION_LESS "${Boost_FIND_VERSION}") + set(Boost_FOUND 0) + set(_Boost_VERSION_AGE "old") + elseif(Boost_FIND_VERSION_EXACT AND + NOT "${_Boost_VERSION}" VERSION_EQUAL "${Boost_FIND_VERSION}") + set(Boost_FOUND 0) + set(_Boost_VERSION_AGE "new") + else() + set(Boost_FOUND 1) endif() + if(NOT Boost_FOUND) + # State that we found a version of Boost that is too new or too old. + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") + if (Boost_FIND_VERSION_PATCH) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") + endif () + if (NOT Boost_FIND_VERSION_EXACT) + set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)") + endif () + set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.") + endif () else() - # Attempt to guess the compiler suffix - # NOTE: this is not perfect yet, if you experience any issues - # please report them and use the Boost_COMPILER variable - # to work around the problems. - _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "guessed _boost_COMPILER = ${_boost_COMPILER}") - endif() + # Caller will accept any Boost version. + set(Boost_FOUND 1) endif() +else() + set(Boost_FOUND 0) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") +endif() - set (_boost_MULTITHREADED "-mt") - if( NOT Boost_USE_MULTITHREADED ) - set (_boost_MULTITHREADED "") +# ------------------------------------------------------------------------ +# Suffix initialization and compiler suffix detection. +# ------------------------------------------------------------------------ + +set(_Boost_VARS_NAME + Boost_COMPILER + Boost_THREADAPI + Boost_USE_DEBUG_PYTHON + Boost_USE_MULTITHREADED + Boost_USE_STATIC_LIBS + Boost_USE_STATIC_RUNTIME + Boost_USE_STLPORT + Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS + ) +_Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME}) + +# Setting some more suffixes for the library +set(Boost_LIB_PREFIX "") +if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) + set(Boost_LIB_PREFIX "lib") +endif() + +if (Boost_COMPILER) + set(_boost_COMPILER ${Boost_COMPILER}) + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "using user-specified Boost_COMPILER = ${_boost_COMPILER}") endif() +else() + # Attempt to guess the compiler suffix + # NOTE: this is not perfect yet, if you experience any issues + # please report them and use the Boost_COMPILER variable + # to work around the problems. + _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") + "guessed _boost_COMPILER = ${_boost_COMPILER}") endif() +endif() - #====================== - # Systematically build up the Boost ABI tag - # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming - set( _boost_RELEASE_ABI_TAG "-") - set( _boost_DEBUG_ABI_TAG "-") - # Key Use this library when: - # s linking statically to the C++ standard library and - # compiler runtime support libraries. - if(Boost_USE_STATIC_RUNTIME) - set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s") - set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s") - endif() - # g using debug versions of the standard and runtime - # support libraries - if(WIN32) - if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" - OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") - set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") - endif() - endif() - # y using special debug build of python - if(Boost_USE_DEBUG_PYTHON) - set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y") - endif() - # d using a debug version of your code - set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d") - # p using the STLport standard library rather than the - # default one supplied with your compiler - if(Boost_USE_STLPORT) - set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p") - set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p") - endif() - # n using the STLport deprecated "native iostreams" feature - if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS) - set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n") - set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n") - endif() +set (_boost_MULTITHREADED "-mt") +if( NOT Boost_USE_MULTITHREADED ) + set (_boost_MULTITHREADED "") +endif() +if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") +endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}") +#====================== +# Systematically build up the Boost ABI tag +# http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming +set( _boost_RELEASE_ABI_TAG "-") +set( _boost_DEBUG_ABI_TAG "-") +# Key Use this library when: +# s linking statically to the C++ standard library and +# compiler runtime support libraries. +if(Boost_USE_STATIC_RUNTIME) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s") +endif() +# g using debug versions of the standard and runtime +# support libraries +if(WIN32) + if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") endif() +endif() +# y using special debug build of python +if(Boost_USE_DEBUG_PYTHON) + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y") +endif() +# d using a debug version of your code +set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d") +# p using the STLport standard library rather than the +# default one supplied with your compiler +if(Boost_USE_STLPORT) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p") +endif() +# n using the STLport deprecated "native iostreams" feature +if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n") +endif() + +if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}") +endif() + +# ------------------------------------------------------------------------ +# Begin finding boost libraries +# ------------------------------------------------------------------------ +set(_Boost_VARS_LIB BOOST_LIBRARYDIR Boost_LIBRARY_DIR) +_Boost_CHANGE_DETECT(_Boost_CHANGE_LIBDIR ${_Boost_VARS_DIR} ${_Boost_VARS_LIB} Boost_INCLUDE_DIR) +# Clear Boost_LIBRARY_DIR if it did not change but other input affecting the +# location did. We will find a new one based on the new inputs. +if(_Boost_CHANGE_LIBDIR AND NOT _Boost_LIBRARY_DIR_CHANGED) + unset(Boost_LIBRARY_DIR CACHE) +endif() - # ------------------------------------------------------------------------ - # Begin finding boost libraries - # ------------------------------------------------------------------------ +if(Boost_LIBRARY_DIR) + set(_boost_LIBRARY_SEARCH_DIRS ${Boost_LIBRARY_DIR} NO_DEFAULT_PATH) +else() + set(_boost_LIBRARY_SEARCH_DIRS "") + if(BOOST_LIBRARYDIR) + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${BOOST_LIBRARYDIR}) + elseif(_ENV_BOOST_LIBRARYDIR) + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_ENV_BOOST_LIBRARYDIR}) + endif() if(BOOST_ROOT) - set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS - ${BOOST_ROOT}/lib - ${BOOST_ROOT}/stage/lib) + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib) + elseif(_ENV_BOOST_ROOT) + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib) endif() - set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS - ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS} + + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${Boost_INCLUDE_DIR}/lib ${Boost_INCLUDE_DIR}/../lib ${Boost_INCLUDE_DIR}/stage/lib - ) - set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM - C:/boost/lib - C:/boost - "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib" - "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}/lib" - "$ENV{ProgramFiles}/boost/lib" - "$ENV{ProgramFiles}/boost" - /sw/local/lib - ) - set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS}) + ) if( Boost_NO_SYSTEM_PATHS ) - set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + list(APPEND _boost_LIBRARY_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH) else() - list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM}) - endif() - - # prepend BOOST_LIBRARYDIR to search path if specified - if( BOOST_LIBRARYDIR ) - file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR) - set(_boost_LIBRARY_SEARCH_DIRS - ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS}) + list(APPEND _boost_LIBRARY_SEARCH_DIRS PATHS + C:/boost/lib + C:/boost + /sw/local/lib + ) endif() +endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}") - endif() +if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}") +endif() - # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES - if( Boost_USE_STATIC_LIBS ) - set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) - endif() +# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES +if( Boost_USE_STATIC_LIBS ) + set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) endif() +endif() - # We want to use the tag inline below without risking double dashes - if(_boost_RELEASE_ABI_TAG) - if(${_boost_RELEASE_ABI_TAG} STREQUAL "-") - set(_boost_RELEASE_ABI_TAG "") - endif() +# We want to use the tag inline below without risking double dashes +if(_boost_RELEASE_ABI_TAG) + if(${_boost_RELEASE_ABI_TAG} STREQUAL "-") + set(_boost_RELEASE_ABI_TAG "") endif() - if(_boost_DEBUG_ABI_TAG) - if(${_boost_DEBUG_ABI_TAG} STREQUAL "-") - set(_boost_DEBUG_ABI_TAG "") - endif() +endif() +if(_boost_DEBUG_ABI_TAG) + if(${_boost_DEBUG_ABI_TAG} STREQUAL "-") + set(_boost_DEBUG_ABI_TAG "") endif() +endif() - # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled - # on WIN32 was to: - # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found) - # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found) - # We maintain this behavior since changing it could break people's builds. - # To disable the ambiguous behavior, the user need only - # set Boost_USE_STATIC_RUNTIME either ON or OFF. - set(_boost_STATIC_RUNTIME_WORKAROUND false) - if(WIN32 AND Boost_USE_STATIC_LIBS) - if(NOT DEFINED Boost_USE_STATIC_RUNTIME) - set(_boost_STATIC_RUNTIME_WORKAROUND true) - endif() +# The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled +# on WIN32 was to: +# 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found) +# 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found) +# We maintain this behavior since changing it could break people's builds. +# To disable the ambiguous behavior, the user need only +# set Boost_USE_STATIC_RUNTIME either ON or OFF. +set(_boost_STATIC_RUNTIME_WORKAROUND false) +if(WIN32 AND Boost_USE_STATIC_LIBS) + if(NOT DEFINED Boost_USE_STATIC_RUNTIME) + set(_boost_STATIC_RUNTIME_WORKAROUND true) endif() +endif() - # On versions < 1.35, remove the System library from the considered list - # since it wasn't added until 1.35. - if(Boost_VERSION AND Boost_FIND_COMPONENTS) - if(Boost_VERSION LESS 103500) - list(REMOVE_ITEM Boost_FIND_COMPONENTS system) - endif() - endif() +# On versions < 1.35, remove the System library from the considered list +# since it wasn't added until 1.35. +if(Boost_VERSION AND Boost_FIND_COMPONENTS) + if(Boost_VERSION LESS 103500) + list(REMOVE_ITEM Boost_FIND_COMPONENTS system) + endif() +endif() - foreach(COMPONENT ${Boost_FIND_COMPONENTS}) +# If the user changed any of our control inputs flush previous results. +if(_Boost_CHANGE_LIBDIR OR _Boost_CHANGE_LIBNAME) + foreach(COMPONENT ${_Boost_COMPONENTS_SEARCHED}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) - set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) - set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) - set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") - - set( _boost_docstring_release "Boost ${COMPONENT} library (release)") - set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") - - # - # Find RELEASE libraries - # - set(_boost_RELEASE_NAMES - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT} ) - if(_boost_STATIC_RUNTIME_WORKAROUND) - set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") - list(APPEND _boost_RELEASE_NAMES - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) - endif() - if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") - _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) - endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") - endif() - find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE - NAMES ${_boost_RELEASE_NAMES} - HINTS ${_boost_LIBRARY_SEARCH_DIRS} - ${_boost_FIND_OPTIONS} - DOC "${_boost_docstring_release}" - ) + foreach(c DEBUG RELEASE) + set(_var Boost_${UPPERCOMPONENT}_LIBRARY_${c}) + unset(${_var} CACHE) + set(${_var} "${_var}-NOTFOUND") + endforeach() + endforeach() + set(_Boost_COMPONENTS_SEARCHED "") +endif() - # - # Find DEBUG libraries - # - set(_boost_DEBUG_NAMES - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} - ${Boost_LIB_PREFIX}boost_${COMPONENT} ) - if(_boost_STATIC_RUNTIME_WORKAROUND) - set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") - list(APPEND _boost_DEBUG_NAMES - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) - endif() - if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") - _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) - endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") - endif() - find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - NAMES ${_boost_DEBUG_NAMES} - HINTS ${_boost_LIBRARY_SEARCH_DIRS} - ${_boost_FIND_OPTIONS} - DOC "${_boost_docstring_debug}" +foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + + set( _boost_docstring_release "Boost ${COMPONENT} library (release)") + set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") + + # + # Find RELEASE libraries + # + set(_boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") + endif() + _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE + NAMES ${_boost_RELEASE_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + NAMES_PER_DIR + DOC "${_boost_docstring_release}" ) - if(Boost_REALPATH) - _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") - _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" ) - endif() - - _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) - - endforeach() + # + # Find DEBUG libraries + # + set(_boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") + endif() + _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG + NAMES ${_boost_DEBUG_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + NAMES_PER_DIR + DOC "${_boost_docstring_debug}" + ) - # Restore the original find library ordering - if( Boost_USE_STATIC_LIBS ) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + if(Boost_REALPATH) + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" ) endif() - # ------------------------------------------------------------------------ - # End finding boost libraries - # ------------------------------------------------------------------------ + _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) - # ------------------------------------------------------------------------ - # Begin long process of determining Boost_FOUND, starting with version - # number checks, followed by - # TODO: Ideally the version check logic should happen prior to searching - # for libraries... - # ------------------------------------------------------------------------ +endforeach() - set(Boost_INCLUDE_DIRS - ${Boost_INCLUDE_DIR} - ) +# Restore the original find library ordering +if( Boost_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +endif() - set(Boost_FOUND FALSE) - if(Boost_INCLUDE_DIR) - set( Boost_FOUND TRUE ) +# ------------------------------------------------------------------------ +# End finding boost libraries +# ------------------------------------------------------------------------ - if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" ) - set( Boost_FOUND FALSE ) - set(_Boost_VERSION_AGE "old") - elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) - if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" ) - set( Boost_FOUND FALSE ) - set(_Boost_VERSION_AGE "old") - elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) - if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" ) - set( Boost_FOUND FALSE ) - set(_Boost_VERSION_AGE "old") - endif() - endif() - endif() +set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) +set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR}) - if (NOT Boost_FOUND) - _Boost_MARK_COMPONENTS_FOUND(OFF) +# The above setting of Boost_FOUND was based only on the header files. +# Update it for the requested component libraries. +if(Boost_FOUND) + # The headers were found. Check for requested component libs. + set(_boost_CHECKED_COMPONENT FALSE) + set(_Boost_MISSING_COMPONENTS "") + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) + set(_boost_CHECKED_COMPONENT TRUE) + if(NOT Boost_${COMPONENT}_FOUND) + string(TOLOWER ${COMPONENT} COMPONENT) + list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) endif() + endforeach() - if (Boost_FOUND AND Boost_FIND_VERSION_EXACT) - # If the user requested an exact version of Boost, check - # that. We already know that the Boost version we have is >= the - # requested version. - set(_Boost_VERSION_AGE "new") - - # If the user didn't specify a patchlevel, it's 0. - if (NOT Boost_FIND_VERSION_PATCH) - set(Boost_FIND_VERSION_PATCH 0) - endif () - - # We'll set Boost_FOUND true again if we have an exact version match. - set(Boost_FOUND FALSE) - _Boost_MARK_COMPONENTS_FOUND(OFF) - if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) - if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) - if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) - set( Boost_FOUND TRUE ) - _Boost_MARK_COMPONENTS_FOUND(ON) - endif() - endif() - endif() - endif () + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}") + endif() - if(NOT Boost_FOUND) - # State that we found a version of Boost that is too new or too old. + if (_Boost_MISSING_COMPONENTS) + set(Boost_FOUND 0) + # We were unable to find some libraries, so generate a sensible + # error message that lists the libraries we were unable to find. + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n") + foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") - if (Boost_FIND_VERSION_PATCH) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") - endif () - if (NOT Boost_FIND_VERSION_EXACT) - set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)") - endif () - set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.") - endif () - - # Always check for missing components - set(_boost_CHECKED_COMPONENT FALSE) - set(_Boost_MISSING_COMPONENTS "") - foreach(COMPONENT ${Boost_FIND_COMPONENTS}) - string(TOUPPER ${COMPONENT} COMPONENT) - set(_boost_CHECKED_COMPONENT TRUE) - if(NOT Boost_${COMPONENT}_FOUND) - string(TOLOWER ${COMPONENT} COMPONENT) - list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) - set( Boost_FOUND FALSE) - endif() + "${Boost_ERROR_REASON} boost_${COMPONENT}\n") endforeach() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}") - endif() - - if (_Boost_MISSING_COMPONENTS) - # We were unable to find some libraries, so generate a sensible - # error message that lists the libraries we were unable to find. + list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED) + list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) + if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n") - foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON} boost_${COMPONENT}\n") - endforeach() - - list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED) - list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) - if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") - else () - set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") - endif () + "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + else () + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") endif () + endif () - if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) - # Compatibility Code for backwards compatibility with CMake - # 2.4's FindBoost module. + if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) + # Compatibility Code for backwards compatibility with CMake + # 2.4's FindBoost module. - # Look for the boost library path. - # Note that the user may not have installed any libraries - # so it is quite possible the Boost_LIBRARY_DIRS may not exist. - set(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) + # Look for the boost library path. + # Note that the user may not have installed any libraries + # so it is quite possible the Boost_LIBRARY_DIRS may not exist. + set(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) - if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") - get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) - endif() + if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") + get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) + endif() - if("${_boost_LIB_DIR}" MATCHES "/include$") - # Strip off the trailing "/include" in the path. - get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) - endif() + if("${_boost_LIB_DIR}" MATCHES "/include$") + # Strip off the trailing "/include" in the path. + get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) + endif() - if(EXISTS "${_boost_LIB_DIR}/lib") - set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib) + if(EXISTS "${_boost_LIB_DIR}/lib") + set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib) + else() + if(EXISTS "${_boost_LIB_DIR}/stage/lib") + set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) else() - if(EXISTS "${_boost_LIB_DIR}/stage/lib") - set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) - else() - set(_boost_LIB_DIR "") - endif() - endif() - - if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") - set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory") + set(_boost_LIB_DIR "") endif() + endif() + if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") + set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR}) endif() - else() - set( Boost_FOUND FALSE) endif() +else() + # Boost headers were not found so no components were found. + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + set(Boost_${UPPERCOMPONENT}_FOUND 0) + endforeach() +endif() - # ------------------------------------------------------------------------ - # Notification to end user about what was found - # ------------------------------------------------------------------------ +# ------------------------------------------------------------------------ +# Notification to end user about what was found +# ------------------------------------------------------------------------ - if(Boost_FOUND) +set(Boost_LIBRARIES "") +if(Boost_FOUND) + if(NOT Boost_FIND_QUIETLY) + message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") + if(Boost_FIND_COMPONENTS) + message(STATUS "Found the following Boost libraries:") + endif() + endif() + foreach( COMPONENT ${Boost_FIND_COMPONENTS} ) + string( TOUPPER ${COMPONENT} UPPERCOMPONENT ) + if( Boost_${UPPERCOMPONENT}_FOUND ) if(NOT Boost_FIND_QUIETLY) - message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - if(Boost_FIND_COMPONENTS) - message(STATUS "Found the following Boost libraries:") - endif() + message (STATUS " ${COMPONENT}") endif() - foreach( COMPONENT ${Boost_FIND_COMPONENTS} ) - string( TOUPPER ${COMPONENT} UPPERCOMPONENT ) - if( Boost_${UPPERCOMPONENT}_FOUND ) - if(NOT Boost_FIND_QUIETLY) - message (STATUS " ${COMPONENT}") - endif() - set(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY}) - endif() - endforeach() + list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY}) + endif() + endforeach() +else() + if(Boost_FIND_REQUIRED) + message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") else() - if(Boost_FIND_REQUIRED) - message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") - else() - if(NOT Boost_FIND_QUIETLY) - # we opt not to automatically output Boost_ERROR_REASON here as - # it could be quite lengthy and somewhat imposing in its requests - # Since Boost is not always a required dependency we'll leave this - # up to the end-user. - if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG) - message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}") - else() - message(STATUS "Could NOT find Boost") - endif() + if(NOT Boost_FIND_QUIETLY) + # we opt not to automatically output Boost_ERROR_REASON here as + # it could be quite lengthy and somewhat imposing in its requests + # Since Boost is not always a required dependency we'll leave this + # up to the end-user. + if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG) + message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}") + else() + message(STATUS "Could NOT find Boost") endif() endif() endif() +endif() - # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view - mark_as_advanced(Boost_INCLUDE_DIR - Boost_INCLUDE_DIRS - Boost_LIBRARY_DIRS - ) +# Configure display of cache entries in GUI. +foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB}) + get_property(_type CACHE ${v} PROPERTY TYPE) + if(_type) + set_property(CACHE ${v} PROPERTY ADVANCED 1) + if("x${_type}" STREQUAL "xUNINITIALIZED") + if("x${v}" STREQUAL "xBoost_ADDITIONAL_VERSIONS") + set_property(CACHE ${v} PROPERTY TYPE STRING) + else() + set_property(CACHE ${v} PROPERTY TYPE PATH) + endif() + endif() + endif() +endforeach() + +# Record last used values of input variables so we can +# detect on the next run if the user changed them. +foreach(v + ${_Boost_VARS_INC} ${_Boost_VARS_LIB} + ${_Boost_VARS_DIR} ${_Boost_VARS_NAME} + ) + if(DEFINED ${v}) + set(_${v}_LAST "${${v}}" CACHE INTERNAL "Last used ${v} value.") + else() + unset(_${v}_LAST CACHE) + endif() +endforeach() + +# Maintain a persistent list of components requested anywhere since +# the last flush. +set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}") +list(APPEND _Boost_COMPONENTS_SEARCHED ${Boost_FIND_COMPONENTS}) +list(REMOVE_DUPLICATES _Boost_COMPONENTS_SEARCHED) +list(SORT _Boost_COMPONENTS_SEARCHED) +set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}" + CACHE INTERNAL "Components requested for this build tree.") diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index 1c4a9de..1a27fc3 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -33,6 +33,8 @@ macro(_FIND_BULLET_LIBRARY _var) ${ARGN} HINTS ${BULLET_ROOT} + ${BULLET_ROOT}/lib/Release + ${BULLET_ROOT}/lib/Debug ${BULLET_ROOT}/out/release8/libs ${BULLET_ROOT}/out/debug8/libs PATH_SUFFIXES lib diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index f74366b..53ab031 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -28,7 +28,7 @@ find_path(CUPS_INCLUDE_DIR cups/cups.h ) find_library(CUPS_LIBRARIES NAMES cups ) if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) - include(CheckLibraryExists) + include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint) CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE) diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 6acf421..09d1ba4 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -56,7 +56,7 @@ endif() # prefix as the library was found, if still not found, try curses.h with the # default search paths. if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) - include(CheckLibraryExists) + include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" wsyncup "" CURSES_CURSES_HAS_WSYNCUP) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index daae94f..79a3a1e 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -63,7 +63,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -find_program(FLEX_EXECUTABLE flex DOC "path to the flex executable") +find_program(FLEX_EXECUTABLE NAMES flex win_flex DOC "path to the flex executable") mark_as_advanced(FLEX_EXECUTABLE) find_library(FL_LIBRARY NAMES fl @@ -93,10 +93,12 @@ if(FLEX_EXECUTABLE) else() # older versions of flex printed "/full/path/to/executable version X.Y" # newer versions use "basename(executable) X.Y" - get_filename_component(FLEX_EXE_NAME "${FLEX_EXECUTABLE}" NAME) - string(REGEX REPLACE "^.*${FLEX_EXE_NAME}\"? (version )?([0-9]+[^ ]*)( .*)?$" "\\2" + get_filename_component(FLEX_EXE_NAME_WE "${FLEX_EXECUTABLE}" NAME_WE) + get_filename_component(FLEX_EXE_EXT "${FLEX_EXECUTABLE}" EXT) + string(REGEX REPLACE "^.*${FLEX_EXE_NAME_WE}(${FLEX_EXE_EXT})?\"? (version )?([0-9]+[^ ]*)( .*)?$" "\\3" FLEX_VERSION "${FLEX_version_output}") - unset(FLEX_EXE_NAME) + unset(FLEX_EXE_EXT) + unset(FLEX_EXE_NAME_WE) endif() #============================================================ diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index 24cfb87..92c14da 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -58,7 +58,7 @@ if(WIN32) endif() if(UNIX) - include(FindX11) + include(${CMAKE_CURRENT_LIST_DIR}/FindX11.cmake) find_library(FLTK_MATH_LIBRARY m) set( FLTK_PLATFORM_DEPENDENT_LIBS ${X11_LIBRARIES} ${FLTK_MATH_LIBRARY}) endif() diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index cdb46be..1df2399 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -46,6 +46,7 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h HINTS ENV FREETYPE_DIR PATHS + /usr/X11R6 /usr/local/X11R6 /usr/local/X11 /usr/freeware @@ -56,6 +57,7 @@ find_path(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h HINTS ENV FREETYPE_DIR PATHS + /usr/X11R6 /usr/local/X11R6 /usr/local/X11 /usr/freeware @@ -68,6 +70,7 @@ find_library(FREETYPE_LIBRARY ENV FREETYPE_DIR PATH_SUFFIXES lib PATHS + /usr/X11R6 /usr/local/X11R6 /usr/local/X11 /usr/freeware diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 6a665ad..90ff737 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -58,8 +58,8 @@ set(GIF_LIBRARIES ${GIF_LIBRARY}) # one. # http://giflib.sourcearchive.com/documentation/4.1.4/files.html if(GIF_INCLUDE_DIR) - include(CMakePushCheckState) - include(CheckStructHasMember) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake) CMAKE_PUSH_CHECK_STATE() set(GIF_VERSION 3) set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}") diff --git a/Modules/FindGLU.cmake b/Modules/FindGLU.cmake index d87945a..0d36fad 100644 --- a/Modules/FindGLU.cmake +++ b/Modules/FindGLU.cmake @@ -19,7 +19,7 @@ message(STATUS "WARNING: you are using the obsolete 'GLU' package, please use 'OpenGL' instead") -include(FindOpenGL) +include(${CMAKE_CURRENT_LIST_DIR}/FindOpenGL.cmake) if (OPENGL_GLU_FOUND) set (GLU_LIBRARY ${OPENGL_LIBRARIES}) diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake index 07af0bf..f2f9dd0 100644 --- a/Modules/FindGnuplot.cmake +++ b/Modules/FindGnuplot.cmake @@ -21,7 +21,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindCygwin) +include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) find_program(GNUPLOT_EXECUTABLE NAMES diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 33599be..8514164 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -60,7 +60,7 @@ # This module is maintained by Will Dicharry <wdicharry@stellarscience.com>. -include(SelectLibraryConfigurations) +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # List of the valid HDF5 components diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake new file mode 100644 index 0000000..8c10177 --- /dev/null +++ b/Modules/FindIcotool.cmake @@ -0,0 +1,56 @@ +# - Find icotool +# This module looks for icotool. This module defines the +# following values: +# ICOTOOL_EXECUTABLE: the full path to the icotool tool. +# ICOTOOL_FOUND: True if icotool has been found. +# ICOTOOL_VERSION_STRING: the version of icotool found. +# + +#============================================================================= +# Copyright 2012 Aleksey Avdeev <solo@altlinux.ru> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_program(ICOTOOL_EXECUTABLE + icotool +) + +if(ICOTOOL_EXECUTABLE) + execute_process( + COMMAND ${ICOTOOL_EXECUTABLE} --version + OUTPUT_VARIABLE _icotool_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*") + set( ICOTOOL_VERSION_STRING + "${CMAKE_MATCH_1}" + ) + else() + set( ICOTOOL_VERSION_STRING + "" + ) + endif() + unset(_icotool_version) +endif() + +# handle the QUIETLY and REQUIRED arguments and set ICOTOOL_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + Icotool + REQUIRED_VARS ICOTOOL_EXECUTABLE + VERSION_VAR ICOTOOL_VERSION_STRING +) + +mark_as_advanced( + ICOTOOL_EXECUTABLE +) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 0de3f79..9d708ca 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -120,6 +120,11 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES /usr/lib/jvm/default-java/jre/lib/{libarch} /usr/lib/jvm/default-java/jre/lib /usr/lib/jvm/default-java/lib + # OpenBSD specific paths for default JVM + /usr/local/jdk-1.7.0/jre/lib/{libarch} + /usr/local/jre-1.7.0/lib/{libarch} + /usr/local/jdk-1.6.0/jre/lib/{libarch} + /usr/local/jre-1.6.0/lib/{libarch} ) set(JAVA_JVM_LIBRARY_DIRECTORIES) @@ -153,6 +158,9 @@ set(JAVA_AWT_INCLUDE_DIRECTORIES /opt/sun-jdk-1.5.0.04/include # Debian specific path for default JVM /usr/lib/jvm/default-java/include + # OpenBSD specific path for default JVM + /usr/local/jdk-1.7.0/include + /usr/local/jdk-1.6.0/include ) foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") @@ -227,6 +235,7 @@ find_path(JAVA_INCLUDE_PATH2 jni_md.h ${JAVA_INCLUDE_PATH}/win32 ${JAVA_INCLUDE_PATH}/linux ${JAVA_INCLUDE_PATH}/freebsd + ${JAVA_INCLUDE_PATH}/openbsd ${JAVA_INCLUDE_PATH}/solaris ${JAVA_INCLUDE_PATH}/hp-ux ${JAVA_INCLUDE_PATH}/alpha diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 1b4593d..2f02b7a 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -80,6 +80,8 @@ set(_JAVA_PATHS /usr/java/j2sdk1.4.2_09/bin /usr/lib/j2sdk1.5-sun/bin /opt/sun-jdk-1.5.0.04/bin + /usr/local/jdk-1.7.0/bin + /usr/local/jdk-1.6.0/bin ) find_program(Java_JAVA_EXECUTABLE NAMES java @@ -107,6 +109,7 @@ if(Java_JAVA_EXECUTABLE) # 2. OpenJDK 1.6 # 3. GCJ 1.5 # 4. Kaffe 1.4.2 + # 5. OpenJDK 1.7.x on OpenBSD if(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_.]+.*\".*") # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer string( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\".*" @@ -115,6 +118,10 @@ if(Java_JAVA_EXECUTABLE) # Kaffe style string( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*" "\\1" Java_VERSION_STRING "${var}" ) + elseif(var MATCHES "openjdk version \"[0-9]+\\.[0-9]+\\.[0-9_]+\".*") + # OpenJDK ver 1.7.x on OpenBSD + string( REGEX REPLACE "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+).*" + "\\1" Java_VERSION_STRING "${var}" ) else() if(NOT Java_FIND_QUIETLY) message(WARNING "regex not supported: ${var}. Please report") diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index a092116..70eccef 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -245,7 +245,7 @@ endif() # KDE3Macros.cmake contains all the KDE specific macros -include(KDE3Macros) +include(${CMAKE_CURRENT_LIST_DIR}/KDE3Macros.cmake) macro (KDE3_PRINT_RESULTS) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 430e45f..3167850 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -40,9 +40,9 @@ set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) if (NOT _LANGUAGES_ MATCHES Fortran) -include(CheckFunctionExists) +include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) else () -include(CheckFortranFunctionExists) +include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) endif () set(LAPACK_FOUND FALSE) diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index eac25f5..2d7ed3d 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -28,7 +28,7 @@ find_path(LUA_INCLUDE_DIR lua.h HINTS ENV LUA_DIR - PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include + PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include PATHS ~/Library/Frameworks /Library/Frameworks diff --git a/Modules/FindMPEG2.cmake b/Modules/FindMPEG2.cmake index 0290eca..fc01c4c 100644 --- a/Modules/FindMPEG2.cmake +++ b/Modules/FindMPEG2.cmake @@ -45,7 +45,7 @@ if(MPEG2_FOUND) #some native mpeg2 installations will depend #on libSDL, if found, add it in. - include( FindSDL ) + include(${CMAKE_CURRENT_LIST_DIR}/FindSDL.cmake) if(SDL_FOUND) set( MPEG2_LIBRARIES ${MPEG2_LIBRARIES} ${SDL_LIBRARY}) endif() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 4ce4de9..143d10a 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -78,7 +78,7 @@ # include this to handle the QUIETLY and REQUIRED arguments include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -include(GetPrerequisites) +include(${CMAKE_CURRENT_LIST_DIR}/GetPrerequisites.cmake) # # This part detects MPI compilers, attempting to wade through the mess of compiler names in diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index a6f4503..4a393f2 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -103,7 +103,7 @@ else () if (OPENGL_gl_LIBRARY) if(NOT X11_FOUND) - include(FindX11) + include(${CMAKE_CURRENT_LIST_DIR}/FindX11.cmake) endif() if (X11_FOUND) if (NOT APPLE) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index ad15d8c..8c8ad55 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -95,7 +95,7 @@ if(CMAKE_C_COMPILER_LOADED) unset(OpenMP_C_FLAG_CANDIDATES) else() _OPENMP_FLAG_CANDIDATES("C") - include(CheckCSourceCompiles) + include(${CMAKE_CURRENT_LIST_DIR}/CheckCSourceCompiles.cmake) endif() foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES}) @@ -126,7 +126,7 @@ if(CMAKE_CXX_COMPILER_LOADED) unset(OpenMP_CXX_FLAG_CANDIDATES) else() _OPENMP_FLAG_CANDIDATES("CXX") - include(CheckCXXSourceCompiles) + include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSourceCompiles.cmake) # use the same source for CXX as C for now set(OpenMP_CXX_TEST_SOURCE ${OpenMP_C_TEST_SOURCE}) diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake index 4a5aaba..7affca8 100644 --- a/Modules/FindOpenSceneGraph.cmake +++ b/Modules/FindOpenSceneGraph.cmake @@ -72,7 +72,7 @@ # Output variables of the form OPENSCENEGRAPH_FOO # -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) set(_osg_modules_to_process) foreach(_osg_component ${OpenSceneGraph_FIND_COMPONENTS}) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 25d8df3..e89e9a9 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -88,8 +88,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindPackageMessage) -include(CMakeParseArguments) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) @@ -187,8 +187,8 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # user knows better what went wrong (#6375) set(MISSING_VARS "") set(DETAILS "") - set(${_NAME_UPPER}_FOUND TRUE) # check if all passed variables are valid + unset(${_NAME_UPPER}_FOUND) foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) if(NOT ${_CURRENT_VAR}) set(${_NAME_UPPER}_FOUND FALSE) @@ -197,6 +197,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") endif() endforeach() + if(NOT "${${_NAME_UPPER}_FOUND}" STREQUAL "FALSE") + set(${_NAME_UPPER}_FOUND TRUE) + endif() # component handling unset(FOUND_COMPONENTS_MSG) diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index e908a65..5eaf207 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -18,7 +18,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindCygwin) +include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) set(PERL_POSSIBLE_BIN_PATHS ${CYGWIN_INSTALL_PATH}/bin diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index e9313ad..492f047 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -38,7 +38,7 @@ # License text for the above reference.) # find the perl executable -include(FindPerl) +include(${CMAKE_CURRENT_LIST_DIR}/FindPerl.cmake) if (PERL_EXECUTABLE) ### PERL_PREFIX diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 0a9a990..bffa9fb 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -32,7 +32,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(CMakeFindFrameworks) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake) # Search for the python framework on Apple. CMAKE_FIND_FRAMEWORKS(Python) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 13f18fe..54b7c6f 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -31,7 +31,7 @@ # License text for the above reference.) # look for signs of qt3 installations -file(GLOB GLOB_TEMP_VAR /usr/lib/qt-3*/bin/qmake) +file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake) if(GLOB_TEMP_VAR) set(QT3_INSTALLED TRUE) endif() @@ -43,6 +43,12 @@ if(GLOB_TEMP_VAR) endif() set(GLOB_TEMP_VAR) +file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt3/bin/qmake) +if(GLOB_TEMP_VAR) + set(QT3_INSTALLED TRUE) +endif() +set(GLOB_TEMP_VAR) + # look for qt4 installations file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake) if(GLOB_TEMP_VAR) @@ -56,6 +62,16 @@ if(GLOB_TEMP_VAR) endif() set(GLOB_TEMP_VAR) +file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt4/bin/qmake) +if(GLOB_TEMP_VAR) + set(QT4_INSTALLED TRUE) +endif() +set(GLOB_TEMP_VAR) + +if (Qt_FIND_VERSION) + set(DESIRED_QT_VERSION "${Qt_FIND_VERSION}") +endif () + # now find qmake find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin") if(QT_QMAKE_EXECUTABLE_FINDQT) @@ -87,6 +103,7 @@ find_file( QT4_QGLOBAL_H_FILE qglobal.h /usr/lib/qt/include/Qt /usr/include/Qt /usr/share/qt4/include/Qt + /usr/local/include/X11/qt4/Qt C:/Progra~1/qt/include/Qt ) if(QT4_QGLOBAL_H_FILE) @@ -106,6 +123,7 @@ find_file( QT3_QGLOBAL_H_FILE qglobal.h /usr/lib/qt/include /usr/include /usr/share/qt3/include + /usr/local/include/X11/qt3 C:/Progra~1/qt/include /usr/include/qt3 ) @@ -113,15 +131,15 @@ if(QT3_QGLOBAL_H_FILE) set(QT3_INSTALLED TRUE) endif() -if(QT3_INSTALLED AND QT4_INSTALLED ) +if(QT3_INSTALLED AND QT4_INSTALLED AND NOT DESIRED_QT_VERSION) # force user to pick if we have both set(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4") else() # if only one found then pick that one - if(QT3_INSTALLED) + if(QT3_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 4) set(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4") endif() - if(QT4_INSTALLED) + if(QT4_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 3) set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4") endif() endif() @@ -129,12 +147,12 @@ endif() if(DESIRED_QT_VERSION MATCHES 3) set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED}) set(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY}) - include(FindQt3) + include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake) endif() if(DESIRED_QT_VERSION MATCHES 4) set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED}) set(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY}) - include(FindQt4) + include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake) endif() if(NOT QT3_INSTALLED AND NOT QT4_INSTALLED) diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 07b6fef..4fc8e40 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -64,6 +64,7 @@ find_path(QT_INCLUDE_DIR qt.h /usr/share/qt3/include C:/Progra~1/qt/include /usr/include/qt3 + /usr/local/include/X11/qt3 ) # if qglobal.h is not in the qt_include_dir then set @@ -146,7 +147,7 @@ find_library(QT_QASSISTANTCLIENT_LIBRARY # Qt 3 should prefer QTDIR over the PATH find_program(QT_MOC_EXECUTABLE - NAMES moc-qt3 moc + NAMES moc-qt3 moc moc3 moc3-mt HINTS ENV QTDIR PATHS @@ -154,6 +155,7 @@ find_program(QT_MOC_EXECUTABLE "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" ${GLOB_PATHS_BIN} + /usr/local/lib/qt3 /usr/local/qt /usr/lib/qt /usr/lib/qt3 @@ -170,7 +172,7 @@ endif() # Qt 3 should prefer QTDIR over the PATH find_program(QT_UIC_EXECUTABLE - NAMES uic-qt3 uic + NAMES uic-qt3 uic uic3 uic3-mt HINTS ENV QTDIR PATHS diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index a84074b..ea4d8f4 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -65,6 +65,10 @@ # is much more flexible, but requires that FindQt4.cmake is executed before # such an exported dependency file is processed. # +# QT_INCLUDE_DIRS_NO_SYSTEM +# If this variable is set to TRUE, the Qt include directories +# in the QT_USE_FILE will NOT have the SYSTEM keyword set. +# # There are also some files that need processing by some Qt tools such as moc # and uic. Listed below are macros that may be used to process those files. # @@ -376,8 +380,8 @@ if(QT_QT_LIBRARY) endif() -include(CheckCXXSymbolExists) -include(MacroAddFileDependencies) +include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) @@ -982,13 +986,13 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) endif() find_program(QT_MOC_EXECUTABLE - NAMES moc-qt4 moc + NAMES moc-qt4 moc moc4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) find_program(QT_UIC_EXECUTABLE - NAMES uic-qt4 uic + NAMES uic-qt4 uic uic4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) @@ -1018,13 +1022,13 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) ) find_program(QT_LUPDATE_EXECUTABLE - NAMES lupdate-qt4 lupdate + NAMES lupdate-qt4 lupdate lupdate4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) find_program(QT_LRELEASE_EXECUTABLE - NAMES lrelease-qt4 lrelease + NAMES lrelease-qt4 lrelease lrelease4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) @@ -1036,13 +1040,13 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) ) find_program(QT_DESIGNER_EXECUTABLE - NAMES designer-qt4 designer + NAMES designer-qt4 designer designer4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) find_program(QT_LINGUIST_EXECUTABLE - NAMES linguist-qt4 linguist + NAMES linguist-qt4 linguist linguist4 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index f2e9f25..fec142e 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -122,7 +122,7 @@ if(SDL_LIBRARY_TEMP) if(SDLMAIN_LIBRARY AND NOT SDL_BUILDING_LIBRARY) list(FIND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" _SDL_MAIN_INDEX) if(_SDL_MAIN_INDEX EQUAL -1) - list(APPEND SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}") + set(SDL_LIBRARY_TEMP "${SDLMAIN_LIBRARY}" ${SDL_LIBRARY_TEMP}) endif() unset(_SDL_MAIN_INDEX) endif() diff --git a/Modules/FindSelfPackers.cmake b/Modules/FindSelfPackers.cmake index 7726dce..fd28642 100644 --- a/Modules/FindSelfPackers.cmake +++ b/Modules/FindSelfPackers.cmake @@ -18,7 +18,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindCygwin) +include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) find_program(SELF_PACKER_FOR_EXECUTABLE upx diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index a032496..b797805 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -1,9 +1,13 @@ # # ---- Find Squish -# This module can be used to find Squish (currently support is aimed at version 3). +# This module can be used to find Squish. Currently Squish versions 3 and 4 are supported. # # ---- Variables and Macros # SQUISH_FOUND If false, don't try to use Squish +# SQUISH_VERSION The full version of Squish found +# SQUISH_VERSION_MAJOR The major version of Squish found +# SQUISH_VERSION_MINOR The minor version of Squish found +# SQUISH_VERSION_PATCH The patch version of Squish found # # SQUISH_INSTALL_DIR The Squish installation directory (containing bin, lib, etc) # SQUISH_SERVER_EXECUTABLE The squishserver executable @@ -13,18 +17,52 @@ # SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found? # SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found? # -# macro SQUISH_ADD_TEST(testName applicationUnderTest testSuite testCase) +# It provides the function squish_v4_add_test() for adding a squish test to cmake using Squish 4.x: +# +# squish_v4_add_test(cmakeTestName AUT targetName SUITE suiteName TEST squishTestName +# [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] ) +# +# The arguments have the following meaning: +# cmakeTestName: this will be used as the first argument for add_test() +# AUT targetName: the name of the cmake target which will be used as AUT, i.e. the +# executable which will be tested. +# SUITE suiteName: this is either the full path to the squish suite, or just the +# last directory of the suite, i.e. the suite name. In this case +# the CMakeLists.txt which calls squish_add_test() must be located +# in the parent directory of the suite directory. +# TEST squishTestName: the name of the squish test, i.e. the name of the subdirectory +# of the test inside the suite directory. +# SETTINGSGROUP group: if specified, the given settings group will be used for executing the test. +# If not specified, the groupname will be "CTest_<username>" +# PRE_COMMAND command: if specified, the given command will be executed before starting the squish test. +# POST_COMMAND command: same as PRE_COMMAND, but after the squish test has been executed. +# +# ---- Typical Use +# enable_testing() +# find_package(Squish 4.0) +# if (SQUISH_FOUND) +# squish_v4_add_test(myTestName AUT myApp SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite TEST someSquishTest SETTINGSGROUP myGroup ) +# endif () +# +# +# For users of Squish version 3.x the macro squish_v3_add_test() is provided: +# squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper) +# Use this macro to add a test using Squish 3.x. # # ---- Typical Use # enable_testing() # find_package(Squish) # if (SQUISH_FOUND) -# SQUISH_ADD_TEST(myTestName myApplication testSuiteName testCaseName) +# squish_v3_add_test(myTestName myApplication testCase envVars testWrapper) # endif () # +# macro SQUISH_ADD_TEST(testName applicationUnderTest testCase envVars testWrapper) +# This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead. + #============================================================================= # Copyright 2008-2009 Kitware, Inc. +# Copyright 2012 Alexander Neundorf # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -36,6 +74,9 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) + +include(CMakeParseArguments) + set(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.") set(SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program.") set(SQUISH_CLIENT_EXECUTABLE_STRING "The squishclient executable program.") @@ -74,21 +115,36 @@ if(SQUISH_INSTALL_DIR) # find the client program if(NOT SQUISH_CLIENT_EXECUTABLE) - find_program(SQUISH_CLIENT_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishrunner DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}") + find_program(SQUISH_CLIENT_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishrunner${CMAKE_EXECUTABLE_SUFFIX} DOC "The ${SQUISH_CLIENT_EXECUTABLE_STRING}") endif() # find the server program if(NOT SQUISH_SERVER_EXECUTABLE) - find_program(SQUISH_SERVER_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishserver DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}") + find_program(SQUISH_SERVER_EXECUTABLE ${SQUISH_INSTALL_DIR}/bin/squishserver${CMAKE_EXECUTABLE_SUFFIX} DOC "The ${SQUISH_SERVER_EXECUTABLE_STRING}") endif() else() set(SQUISH_INSTALL_DIR_FOUND 0) endif() + +set(SQUISH_VERSION) +set(SQUISH_VERSION_MAJOR ) +set(SQUISH_VERSION_MINOR ) +set(SQUISH_VERSION_PATCH ) + # record if executables are set if(SQUISH_CLIENT_EXECUTABLE) set(SQUISH_CLIENT_EXECUTABLE_FOUND 1) + execute_process(COMMAND "${SQUISH_CLIENT_EXECUTABLE}" --version + OUTPUT_VARIABLE _squishVersionOutput + ERROR_QUIET ) + if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+).*$") + set(SQUISH_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(SQUISH_VERSION_MINOR "${CMAKE_MATCH_2}") + set(SQUISH_VERSION_PATCH "${CMAKE_MATCH_3}") + set(SQUISH_VERSION "${SQUISH_VERSION_MAJOR}.${SQUISH_VERSION_MINOR}.${SQUISH_VERSION_PATCH}" ) + endif() else() set(SQUISH_CLIENT_EXECUTABLE_FOUND 0) endif() @@ -100,16 +156,21 @@ else() endif() # record if Squish was found -set(SQUISH_FOUND 1) -foreach(var SQUISH_INSTALL_DIR_FOUND SQUISH_CLIENT_EXECUTABLE_FOUND SQUISH_SERVER_EXECUTABLE_FOUND) - if(NOT ${var}) - set(SQUISH_FOUND 0) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Squish REQUIRED_VARS SQUISH_INSTALL_DIR SQUISH_CLIENT_EXECUTABLE SQUISH_SERVER_EXECUTABLE + VERSION_VAR SQUISH_VERSION ) + + +set(_SQUISH_MODULE_DIR "${CMAKE_CURRENT_LIST_DIR}") + +macro(SQUISH_V3_ADD_TEST testName testAUT testCase envVars testWraper) + if("${SQUISH_VERSION_MAJOR}" STREQUAL "4") + message(STATUS "Using squish_v3_add_test(), but SQUISH_VERSION_MAJOR is ${SQUISH_VERSION_MAJOR}.\nThis may not work.") endif() -endforeach() -macro(SQUISH_ADD_TEST testName testAUT testCase envVars testWraper) add_test(${testName} ${CMAKE_COMMAND} -V -VV + "-Dsquish_version:STRING=3" "-Dsquish_aut:STRING=${testAUT}" "-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}" "-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}" @@ -117,10 +178,84 @@ macro(SQUISH_ADD_TEST testName testAUT testCase envVars testWraper) "-Dsquish_test_case:STRING=${testCase}" "-Dsquish_env_vars:STRING=${envVars}" "-Dsquish_wrapper:STRING=${testWraper}" - -P "${CMAKE_ROOT}/Modules/SquishTestScript.cmake" + "-Dsquish_module_dir:STRING=${_SQUISH_MODULE_DIR}" + -P "${_SQUISH_MODULE_DIR}/SquishTestScript.cmake" ) set_tests_properties(${testName} PROPERTIES FAIL_REGULAR_EXPRESSION "FAILED;ERROR;FATAL" ) endmacro() + +macro(SQUISH_ADD_TEST) + message(STATUS "Using squish_add_test() is deprecated, use squish_v3_add_test() instead.") + squish_v3_add_test(${ARGV}) +endmacro() + + +function(SQUISH_V4_ADD_TEST testName) + + if(NOT "${SQUISH_VERSION_MAJOR}" STREQUAL "4") + message(STATUS "Using squish_v4_add_test(), but SQUISH_VERSION_MAJOR is ${SQUISH_VERSION_MAJOR}.\nThis may not work.") + endif() + + set(oneValueArgs AUT SUITE TEST SETTINGSGROUP PRE_COMMAND POST_COMMAND) + + cmake_parse_arguments(_SQUISH "" "${oneValueArgs}" "" ${ARGN} ) + + if(_SQUISH_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to SQUISH_ADD_TEST(): \"${_SQUISH_UNPARSED_ARGUMENTS}\"") + endif() + + if(NOT _SQUISH_AUT) + message(FATAL_ERROR "Required argument AUT not given for SQUISH_ADD_TEST()") + endif() + + if(NOT _SQUISH_SUITE) + message(FATAL_ERROR "Required argument SUITE not given for SQUISH_ADD_TEST()") + endif() + + if(NOT _SQUISH_TEST) + message(FATAL_ERROR "Required argument TEST not given for SQUISH_ADD_TEST()") + endif() + + get_target_property(testAUTLocation ${_SQUISH_AUT} LOCATION) + get_filename_component(testAUTDir ${testAUTLocation} PATH) + get_filename_component(testAUTName ${testAUTLocation} NAME) + + get_filename_component(absTestSuite "${_SQUISH_SUITE}" ABSOLUTE) + if(NOT EXISTS "${absTestSuite}") + message(FATAL_ERROR "Could not find squish test suite ${_SQUISH_SUITE} (checked ${absTestSuite})") + endif() + + set(absTestCase "${absTestSuite}/${_SQUISH_TEST}") + if(NOT EXISTS "${absTestCase}") + message(FATAL_ERROR "Could not find squish testcase ${_SQUISH_TEST} (checked ${absTestCase})") + endif() + + if(NOT _SQUISH_SETTINGSGROUP) + set(_SQUISH_SETTINGSGROUP "CTest_$ENV{LOGNAME}") + endif() + + add_test(${testName} + ${CMAKE_COMMAND} -V -VV + "-Dsquish_version:STRING=4" + "-Dsquish_aut:STRING=${testAUTName}" + "-Dsquish_aut_dir:STRING=${testAUTDir}" + "-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}" + "-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}" + "-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}" + "-Dsquish_test_suite:STRING=${absTestSuite}" + "-Dsquish_test_case:STRING=${_SQUISH_TEST}" + "-Dsquish_env_vars:STRING=${envVars}" + "-Dsquish_wrapper:STRING=${testWraper}" + "-Dsquish_module_dir:STRING=${_SQUISH_MODULE_DIR}" + "-Dsquish_settingsgroup:STRING=${_SQUISH_SETTINGSGROUP}" + "-Dsquish_pre_command:STRING=${_SQUISH_PRE_COMMAND}" + "-Dsquish_post_command:STRING=${_SQUISH_POST_COMMAND}" + -P "${_SQUISH_MODULE_DIR}/SquishTestScript.cmake" + ) + set_tests_properties(${testName} + PROPERTIES FAIL_REGULAR_EXPRESSION "FAIL;FAILED;ERROR;FATAL" + ) +endfunction() diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index 0d20da5..f649ddc 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -44,9 +44,9 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(CMakeFindFrameworks) -include(FindTclsh) -include(FindWish) +include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindTclsh.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/FindWish.cmake) if(TCLSH_VERSION_STRING) set(TCL_TCLSH_VERSION "${TCLSH_VERSION_STRING}") @@ -82,6 +82,10 @@ set(TCLTK_POSSIBLE_LIB_PATHS "${TK_LIBRARY_PATH}" "${TCL_TCLSH_PATH_PARENT}/lib" "${TK_WISH_PATH_PARENT}/lib" + /usr/local/lib/tcl/tcl8.5 + /usr/local/lib/tcl/tk8.5 + /usr/local/lib/tcl/tcl8.4 + /usr/local/lib/tcl/tk8.4 ) if(WIN32) @@ -168,6 +172,10 @@ set(TCLTK_POSSIBLE_INCLUDE_PATHS /usr/include/tcl8.3 /usr/include/tcl8.2 /usr/include/tcl8.0 + /usr/local/include/tcl8.5 + /usr/local/include/tk8.5 + /usr/local/include/tcl8.4 + /usr/local/include/tk8.4 ) if(WIN32) diff --git a/Modules/FindTclStub.cmake b/Modules/FindTclStub.cmake index e66f7bc..8dda94a 100644 --- a/Modules/FindTclStub.cmake +++ b/Modules/FindTclStub.cmake @@ -34,7 +34,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindTCL) +include(${CMAKE_CURRENT_LIST_DIR}/FindTCL.cmake) get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH) get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH) diff --git a/Modules/FindUnixCommands.cmake b/Modules/FindUnixCommands.cmake index a69e3f1..87caadc 100644 --- a/Modules/FindUnixCommands.cmake +++ b/Modules/FindUnixCommands.cmake @@ -15,7 +15,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindCygwin) +include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) find_program(BASH bash diff --git a/Modules/FindVTK.cmake b/Modules/FindVTK.cmake index fa090ff..0dede2d 100644 --- a/Modules/FindVTK.cmake +++ b/Modules/FindVTK.cmake @@ -62,7 +62,7 @@ set(VTK_DIR_MESSAGE "VTK not found. Set the VTK_DIR cmake cache entry to the ${ if(_VTK_40_ALLOW AND VTK_DIR) if(EXISTS ${VTK_DIR}/UseVTK.cmake AND NOT EXISTS ${VTK_DIR}/VTKConfig.cmake) set(VTK_FOUND 1) - include(UseVTKConfig40) # No VTKConfig; load VTK 4.0 settings. + include(${CMAKE_CURRENT_LIST_DIR}/UseVTKConfig40.cmake) # No VTKConfig; load VTK 4.0 settings. endif() endif() @@ -117,7 +117,7 @@ if(_VTK_40_ALLOW AND NOT VTK_DIR) if(VTK_DIR) if(EXISTS ${VTK_DIR}/UseVTK.cmake AND NOT EXISTS ${VTK_DIR}/VTKConfig.cmake) set(VTK_FOUND 1) - include(UseVTKConfig40) # No VTKConfig; load VTK 4.0 settings. + include(${CMAKE_CURRENT_LIST_DIR}/UseVTKConfig40.cmake) # No VTKConfig; load VTK 4.0 settings. else() # We found the wrong version. Pretend we did not find it. set(VTK_DIR "VTK_DIR-NOTFOUND" CACHE PATH "The ${VTK_DIR_DESCRIPTION}" FORCE) diff --git a/Modules/FindWget.cmake b/Modules/FindWget.cmake index a1dd47f..4da98b1 100644 --- a/Modules/FindWget.cmake +++ b/Modules/FindWget.cmake @@ -17,7 +17,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(FindCygwin) +include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) find_program(WGET_EXECUTABLE wget diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index e12dc0a..3cd3cef 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -336,8 +336,8 @@ if (UNIX) endif () if(X11_FOUND) - include(CheckFunctionExists) - include(CheckLibraryExists) + include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) # Translated from an autoconf-generated configure script. # See libs.m4 in autoconf's m4 directory. @@ -417,7 +417,7 @@ if (UNIX) # Build the final list of libraries. set(X11_LIBRARIES ${X11_X_PRE_LIBS} ${X11_LIBRARIES} ${X11_X_EXTRA_LIBS}) - include(FindPackageMessage) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") else () diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake index fb7421e..bc1e48a 100644 --- a/Modules/Findosg.cmake +++ b/Modules/Findosg.cmake @@ -46,7 +46,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgUtil/SceneView> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSG osg/PositionAttitudeTransform) OSG_FIND_LIBRARY(OSG osg) diff --git a/Modules/FindosgAnimation.cmake b/Modules/FindosgAnimation.cmake index 1c8eb50..121aefc 100644 --- a/Modules/FindosgAnimation.cmake +++ b/Modules/FindosgAnimation.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgAnimation/Animation> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGANIMATION osgAnimation/Animation) OSG_FIND_LIBRARY(OSGANIMATION osgAnimation) diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake index 76272aa..1ed94a1 100644 --- a/Modules/FindosgDB.cmake +++ b/Modules/FindosgDB.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgDB/DatabasePager> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGDB osgDB/DatabasePager) OSG_FIND_LIBRARY(OSGDB osgDB) diff --git a/Modules/FindosgFX.cmake b/Modules/FindosgFX.cmake index 3314750..1f1d59f 100644 --- a/Modules/FindosgFX.cmake +++ b/Modules/FindosgFX.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgFX/BumpMapping> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGFX osgFX/BumpMapping) OSG_FIND_LIBRARY(OSGFX osgFX) diff --git a/Modules/FindosgGA.cmake b/Modules/FindosgGA.cmake index fd9317d..e60f7f5 100644 --- a/Modules/FindosgGA.cmake +++ b/Modules/FindosgGA.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgGA/FlightManipulator> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGGA osgGA/FlightManipulator) OSG_FIND_LIBRARY(OSGGA osgGA) diff --git a/Modules/FindosgIntrospection.cmake b/Modules/FindosgIntrospection.cmake index 2394c05..a430ad6 100644 --- a/Modules/FindosgIntrospection.cmake +++ b/Modules/FindosgIntrospection.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgIntrospection/Reflection> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGINTROSPECTION osgIntrospection/Reflection) OSG_FIND_LIBRARY(OSGINTROSPECTION osgIntrospection) diff --git a/Modules/FindosgManipulator.cmake b/Modules/FindosgManipulator.cmake index 9e58570..32d6def 100644 --- a/Modules/FindosgManipulator.cmake +++ b/Modules/FindosgManipulator.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgManipulator/TrackballDragger> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGMANIPULATOR osgManipulator/TrackballDragger) OSG_FIND_LIBRARY(OSGMANIPULATOR osgManipulator) diff --git a/Modules/FindosgParticle.cmake b/Modules/FindosgParticle.cmake index 2f93389..1a6ae0b 100644 --- a/Modules/FindosgParticle.cmake +++ b/Modules/FindosgParticle.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgParticle/FireEffect> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGPARTICLE osgParticle/FireEffect) OSG_FIND_LIBRARY(OSGPARTICLE osgParticle) diff --git a/Modules/FindosgPresentation.cmake b/Modules/FindosgPresentation.cmake index f89e25f..412502a 100644 --- a/Modules/FindosgPresentation.cmake +++ b/Modules/FindosgPresentation.cmake @@ -43,7 +43,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgPresentation/SlideEventHandler> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGPRESENTATION osgPresentation/SlideEventHandler) OSG_FIND_LIBRARY(OSGPRESENTATION osgPresentation) diff --git a/Modules/FindosgProducer.cmake b/Modules/FindosgProducer.cmake index 2c3800b..ea561a0 100644 --- a/Modules/FindosgProducer.cmake +++ b/Modules/FindosgProducer.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgProducer/OsgSceneHandler> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGPRODUCER osgProducer/OsgSceneHandler) OSG_FIND_LIBRARY(OSGPRODUCER osgProducer) diff --git a/Modules/FindosgQt.cmake b/Modules/FindosgQt.cmake index ddc9128..c7e8fee 100644 --- a/Modules/FindosgQt.cmake +++ b/Modules/FindosgQt.cmake @@ -43,7 +43,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgQt/GraphicsWindowQt> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGQT osgQt/GraphicsWindowQt) OSG_FIND_LIBRARY(OSGQT osgQt) diff --git a/Modules/FindosgShadow.cmake b/Modules/FindosgShadow.cmake index ca87b56..f3be0bf 100644 --- a/Modules/FindosgShadow.cmake +++ b/Modules/FindosgShadow.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgShadow/ShadowTexture> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGSHADOW osgShadow/ShadowTexture) OSG_FIND_LIBRARY(OSGSHADOW osgShadow) diff --git a/Modules/FindosgSim.cmake b/Modules/FindosgSim.cmake index 2fc5105..19cd175 100644 --- a/Modules/FindosgSim.cmake +++ b/Modules/FindosgSim.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgSim/ImpostorSprite> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGSIM osgSim/ImpostorSprite) OSG_FIND_LIBRARY(OSGSIM osgSim) diff --git a/Modules/FindosgTerrain.cmake b/Modules/FindosgTerrain.cmake index eafd8fb..4b7249e 100644 --- a/Modules/FindosgTerrain.cmake +++ b/Modules/FindosgTerrain.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgTerrain/Terrain> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGTERRAIN osgTerrain/Terrain) OSG_FIND_LIBRARY(OSGTERRAIN osgTerrain) diff --git a/Modules/FindosgText.cmake b/Modules/FindosgText.cmake index 57655b1..41683c7 100644 --- a/Modules/FindosgText.cmake +++ b/Modules/FindosgText.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgText/Text> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGTEXT osgText/Text) OSG_FIND_LIBRARY(OSGTEXT osgText) diff --git a/Modules/FindosgUtil.cmake b/Modules/FindosgUtil.cmake index eeabc34..85c1177 100644 --- a/Modules/FindosgUtil.cmake +++ b/Modules/FindosgUtil.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgUtil/SceneView> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGUTIL osgUtil/SceneView) OSG_FIND_LIBRARY(OSGUTIL osgUtil) diff --git a/Modules/FindosgViewer.cmake b/Modules/FindosgViewer.cmake index 2afd761..d2252f4 100644 --- a/Modules/FindosgViewer.cmake +++ b/Modules/FindosgViewer.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgViewer/Viewer> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGVIEWER osgViewer/Viewer) OSG_FIND_LIBRARY(OSGVIEWER osgViewer) diff --git a/Modules/FindosgVolume.cmake b/Modules/FindosgVolume.cmake index 1fa6764..ae2d95c 100644 --- a/Modules/FindosgVolume.cmake +++ b/Modules/FindosgVolume.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgVolume/Volume> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGVOLUME osgVolume/Volume) OSG_FIND_LIBRARY(OSGVOLUME osgVolume) diff --git a/Modules/FindosgWidget.cmake b/Modules/FindosgWidget.cmake index 1a51e60..cb2e12f 100644 --- a/Modules/FindosgWidget.cmake +++ b/Modules/FindosgWidget.cmake @@ -42,7 +42,7 @@ # #include <osg/PositionAttitudeTransform> # #include <osgWidget/Widget> -include(Findosg_functions) +include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake) OSG_FIND_PATH (OSGWIDGET osgWidget/Widget) OSG_FIND_LIBRARY(OSGWIDGET osgWidget) diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake index 5030bcc..4179f7b 100644 --- a/Modules/FindwxWindows.cmake +++ b/Modules/FindwxWindows.cmake @@ -26,7 +26,7 @@ # HAVE_ISYSTEM - true required to replace -I by -isystem on g++ # # For convenience include Use_wxWindows.cmake in your project's -# CMakeLists.txt using include(Use_wxWindows). +# CMakeLists.txt using include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake). # # USAGE # set(WXWINDOWS_USE_GL 1) diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index ffc425e..59a444b 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -37,6 +37,9 @@ ;Set compression SetCompressor @CPACK_NSIS_COMPRESSOR@ + ;Require administrator access + RequestExecutionLevel admin + @CPACK_NSIS_DEFINES@ !include Sections.nsh @@ -119,7 +122,7 @@ Var AR_RegFlags "exit_${SecName}:" !macroend -!macro RemoveSection SecName +!macro RemoveSection_CPack SecName ; This macro is used to call section's Remove_... macro ;from the uninstaller. ;Input: section index constant name specified in Section command. @@ -841,7 +844,7 @@ Section "Uninstall" DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" ; Removes all optional components - !insertmacro SectionList "RemoveSection" + !insertmacro SectionList "RemoveSection_CPack" !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 4e7e99c..ed0b8af 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -263,6 +263,23 @@ set(CMAKE_SYSTEM_FRAMEWORK_PATH /Network/Library/Frameworks /System/Library/Frameworks) +# Warn about known system mis-configuration case. +if(CMAKE_OSX_SYSROOT) + get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) + if(NOT _IN_TC AND + NOT IS_SYMLINK "${CMAKE_OSX_SYSROOT}/Library/Frameworks" + AND IS_SYMLINK "${CMAKE_OSX_SYSROOT}/Library/Frameworks/Frameworks") + message(WARNING "The SDK Library/Frameworks path\n" + " ${CMAKE_OSX_SYSROOT}/Library/Frameworks\n" + "is not set up correctly on this system. " + "This is known to occur when installing Xcode 3.2.6:\n" + " http://bugs.python.org/issue14018\n" + "The problem may cause build errors that report missing system frameworks. " + "Fix your SDK symlinks to resolve this issue and avoid this warning." + ) + endif() +endif() + # default to searching for application bundles first if(NOT DEFINED CMAKE_FIND_APPBUNDLE) set(CMAKE_FIND_APPBUNDLE FIRST) diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index cf18501..ce4d3ce 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -1,16 +1,14 @@ -if(EXISTS /usr/include/dlfcn.h) - set(CMAKE_DL_LIBS "") - set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") - set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") - set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared - set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib - set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath - set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty - set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") - set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") - set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -endif() +set(CMAKE_DL_LIBS "") +set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") +set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 7318275..1004eb3 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -1,15 +1,13 @@ -if(EXISTS /usr/include/dlfcn.h) - set(CMAKE_DL_LIBS "") - set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") - set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") - set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared - set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib - set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath - set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty - set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") - set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") - set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -endif() +set(CMAKE_DL_LIBS "") +set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") +set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") include(Platform/UnixPaths) diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index df240e0..53cabed 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -16,3 +16,7 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH) endif() set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) + +# OpenBSD policy requires that shared libraries be installed without +# executable permission. +set(CMAKE_INSTALL_SO_NO_EXE 1) diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake index 58da8c5..8a9d630 100644 --- a/Modules/Platform/Windows-Intel.cmake +++ b/Modules/Platform/Windows-Intel.cmake @@ -50,7 +50,7 @@ elseif(MSVC_CXX_ARCHITECTURE_ID) elseif(MSVC_Fortran_ARCHITECTURE_ID) set(_MACHINE_ARCH_FLAG "/machine:${MSVC_Fortran_ARCHITECTURE_ID}") endif() -set (CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /INCREMENTAL:YES ${_MACHINE_ARCH_FLAG}") +set (CMAKE_EXE_LINKER_FLAGS_INIT "/INCREMENTAL:YES ${_MACHINE_ARCH_FLAG}") set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug") set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 1f28c50..5cbf9ee 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -154,13 +154,18 @@ else() set(_FLAGS_CXX " /GR /GX") set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib") endif() + + if(MSVC_VERSION LESS 1310) + set(_FLAGS_C " /Zm1000${_FLAGS_C}") + set(_FLAGS_CXX " /Zm1000${_FLAGS_CXX}") + endif() endif() set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") # executable linker flags set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") -# set the stack size and the machine type +# set the machine type set(_MACHINE_ARCH_FLAG ${MSVC_C_ARCHITECTURE_ID}) if(NOT _MACHINE_ARCH_FLAG) set(_MACHINE_ARCH_FLAG ${MSVC_CXX_ARCHITECTURE_ID}) @@ -173,7 +178,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "WindowsCE") endif() endif() set (CMAKE_EXE_LINKER_FLAGS_INIT - "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:${_MACHINE_ARCH_FLAG}") + "${CMAKE_EXE_LINKER_FLAGS_INIT} /machine:${_MACHINE_ARCH_FLAG}") # add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype # on versions that support it @@ -233,7 +238,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> /Fe<TARGET> /Fd<TARGET_PDB> <OBJECTS> /link /implib:<TARGET_IMPLIB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}") - set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3 /Zm1000${_FLAGS_${lang}}") + set(CMAKE_${lang}_FLAGS_INIT "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") set(CMAKE_${lang}_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od ${_RTC1}") set(CMAKE_${lang}_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") diff --git a/Modules/Squish4RunTestCase.bat b/Modules/Squish4RunTestCase.bat new file mode 100755 index 0000000..ad1cc8c --- /dev/null +++ b/Modules/Squish4RunTestCase.bat @@ -0,0 +1,24 @@ +set SQUISHSERVER=%1 +set SQUISHRUNNER=%2 +set TESTSUITE=%3 +set TESTCASE=%4 +set AUT=%5 +set AUTDIR=%6 +set SETTINGSGROUP=%7 + +%SQUISHSERVER% --stop + +echo "Adding AUT... %SQUISHSERVER% --config addAUT %AUT% %AUTDIR%" +%SQUISHSERVER% --config addAUT "%AUT%" "%AUTDIR%" + +echo "Starting the squish server... %SQUISHSERVER%" +start /B %SQUISHSERVER% + +echo "Running the test case...%SQUISHRUNNER% --testsuite %TESTSUITE% --testcase %TESTCASE%" +%SQUISHRUNNER% --testsuite "%TESTSUITE%" --testcase "%TESTCASE%" +set returnValue=%ERRORLEVEL% + +echo "Stopping the squish server... %SQUISHSERVER% --stop" +%SQUISHSERVER% --stop + +exit /B %returnValue% diff --git a/Modules/Squish4RunTestCase.sh b/Modules/Squish4RunTestCase.sh new file mode 100755 index 0000000..abd5deb --- /dev/null +++ b/Modules/Squish4RunTestCase.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +SQUISHSERVER=$1 +SQUISHRUNNER=$2 +TESTSUITE=$3 +TESTCASE=$4 +AUT=$5 +AUTDIR=$6 +SETTINGSGROUP=$7 + +$SQUISHSERVER --stop > /dev/null 2>&1 + +echo "Adding AUT... $SQUISHSERVER --settingsGroup $SETTINGSGROUP --config addAUT $AUT $AUTDIR" +$SQUISHSERVER --settingsGroup "$SETTINGSGROUP" --config addAUT "$AUT" "$AUTDIR" || exit -1 +# sleep 1 + +echo "Starting the squish server... $SQUISHSERVER --daemon" +$SQUISHSERVER --daemon || exit -1 +# sleep 2 + +echo "Running the test case...$SQUISHRUNNER --settingsGroup $SETTINGSGROUP --testsuite $TESTSUITE --testcase $TESTCASE" +$SQUISHRUNNER --settingsGroup "$SETTINGSGROUP" --testsuite "$TESTSUITE" --testcase "$TESTCASE" +returnValue=$? + +echo "Stopping the squish server... $SQUISHSERVER --stop" +$SQUISHSERVER --stop + +exit $returnValue diff --git a/Modules/SquishTestScript.cmake b/Modules/SquishTestScript.cmake index d565305..f794b3e 100644 --- a/Modules/SquishTestScript.cmake +++ b/Modules/SquishTestScript.cmake @@ -22,17 +22,22 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -cmake_minimum_required(VERSION 2.6 FATAL_ERROR) - # print out the variable that we are using message(STATUS "squish_aut='${squish_aut}'") +message(STATUS "squish_aut_dir='${squish_aut_dir}'") +message(STATUS "squish_version='${squish_version}'") message(STATUS "squish_server_executable='${squish_server_executable}'") message(STATUS "squish_client_executable='${squish_client_executable}'") message(STATUS "squish_libqtdir ='${squish_libqtdir}'") +message(STATUS "squish_test_suite='${squish_test_suite}'") message(STATUS "squish_test_case='${squish_test_case}'") message(STATUS "squish_wrapper='${squish_wrapper}'") message(STATUS "squish_env_vars='${squish_env_vars}'") +message(STATUS "squish_module_dir='${squish_module_dir}'") +message(STATUS "squish_settingsgroup='${squish_settingsgroup}'") +message(STATUS "squish_pre_command='${squish_pre_command}'") +message(STATUS "squish_post_command='${squish_post_command}'") # parse enviornment variables foreach(i ${squish_env_vars}) @@ -48,25 +53,38 @@ if (QT4_INSTALLED) set ( ENV{${SQUISH_LIBQTDIR}} ${squish_libqtdir} ) endif () +if(squish_pre_command) + message(STATUS "Executing pre command: ${squish_pre_command}") + execute_process(COMMAND "${squish_pre_command}") +endif() + # run the test -if (WIN32) - execute_process( - COMMAND ${CMAKE_ROOT}/Modules/SquishRunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut} - RESULT_VARIABLE test_rv - ) -endif () +if("${squish_version}" STREQUAL "4") + if (WIN32) + execute_process(COMMAND ${squish_module_dir}/Squish4RunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_suite} ${squish_test_case} ${squish_aut} ${squish_aut_dir} ${squish_settingsgroup} + RESULT_VARIABLE test_rv ) + elseif(UNIX) + execute_process(COMMAND ${squish_module_dir}/Squish4RunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_suite} ${squish_test_case} ${squish_aut} ${squish_aut_dir} ${squish_settingsgroup} + RESULT_VARIABLE test_rv ) + endif () -if (UNIX) - execute_process( - COMMAND ${CMAKE_ROOT}/Modules/SquishRunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut} - RESULT_VARIABLE test_rv - ) -endif () +else() + + if (WIN32) + execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut} + RESULT_VARIABLE test_rv ) + elseif(UNIX) + execute_process(COMMAND ${squish_module_dir}/SquishRunTestCase.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_case} ${squish_wrapper} ${squish_aut} + RESULT_VARIABLE test_rv ) + endif () +endif() + +if(squish_post_command) + message(STATUS "Executing post command: ${squish_post_command}") + execute_process(COMMAND "${squish_post_command}") +endif() # check for an error with running the test if(NOT "${test_rv}" STREQUAL "0") message(FATAL_ERROR "Error running Squish test") endif() - - - diff --git a/Modules/TestForANSIStreamHeaders.cmake b/Modules/TestForANSIStreamHeaders.cmake index 4aa4023..060b3a4 100644 --- a/Modules/TestForANSIStreamHeaders.cmake +++ b/Modules/TestForANSIStreamHeaders.cmake @@ -16,7 +16,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -include(CheckIncludeFileCXX) +include(${CMAKE_CURRENT_LIST_DIR}/CheckIncludeFileCXX.cmake) if(NOT CMAKE_NO_ANSI_STREAM_HEADERS) CHECK_INCLUDE_FILE_CXX(iostream CMAKE_ANSI_STREAM_HEADERS) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index e8166f4..f05a3d5 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -25,7 +25,11 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG) endif() -include_directories(${QT_INCLUDE_DIR}) +if(QT_INCLUDE_DIRS_NO_SYSTEM) + include_directories(${QT_INCLUDE_DIR}) +else(QT_INCLUDE_DIRS_NO_SYSTEM) + include_directories(SYSTEM ${QT_INCLUDE_DIR}) +endif(QT_INCLUDE_DIRS_NO_SYSTEM) set(QT_LIBRARIES "") set(QT_LIBRARIES_PLUGINS "") @@ -89,7 +93,11 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN if(QT_USE_${module}) string(REPLACE "QT" "" qt_module_def "${module}") add_definitions(-DQT_${qt_module_def}_LIB) - include_directories(${QT_${module}_INCLUDE_DIR}) + if(QT_INCLUDE_DIRS_NO_SYSTEM) + include_directories(${QT_${module}_INCLUDE_DIR}) + else(QT_INCLUDE_DIRS_NO_SYSTEM) + include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR}) + endif(QT_INCLUDE_DIRS_NO_SYSTEM) endif() set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in new file mode 100644 index 0000000..0bc7e10 --- /dev/null +++ b/Modules/WIX.template.in @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?include "cpack_variables.wxi"?> + +<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" + RequiredVersion="3.6.3303.0"> + + <Product Id="$(var.CPACK_WIX_PRODUCT_GUID)" + Name="$(var.CPACK_PACKAGE_NAME)" + Language="1033" + Version="$(var.CPACK_PACKAGE_VERSION)" + Manufacturer="$(var.CPACK_PACKAGE_VENDOR)" + UpgradeCode="$(var.CPACK_WIX_UPGRADE_GUID)"> + + <Package InstallerVersion="301" Compressed="yes"/> + + <Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/> + + <MajorUpgrade + Schedule="afterInstallInitialize" + AllowSameVersionUpgrades="yes" + DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."/> + + <WixVariable Id="WixUILicenseRtf" Value="$(var.CPACK_WIX_LICENSE_RTF)"/> + <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_ROOT"/> + + <?ifdef CPACK_WIX_PRODUCT_ICON?> + <Property Id="ARPPRODUCTICON">ProductIcon.ico</Property> + <Icon Id="ProductIcon.ico" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)"/> + <?endif?> + + <?ifdef CPACK_WIX_UI_BANNER?> + <WixVariable Id="WixUIBannerBmp" Value="$(var.CPACK_WIX_UI_BANNER)"/> + <?endif?> + + <?ifdef CPACK_WIX_UI_DIALOG?> + <WixVariable Id="WixUIDialogBmp" Value="$(var.CPACK_WIX_UI_DIALOG)"/> + <?endif?> + + <FeatureRef Id="ProductFeature"/> + + <UIRef Id="WixUI_InstallDir" /> + </Product> +</Wix> diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8bf6c40..675f576 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -201,6 +201,7 @@ set(SRCS cmGeneratorTarget.h cmGlobalGenerator.cxx cmGlobalGenerator.h + cmGlobalGeneratorFactory.h cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h cmGraphAdjacencyList.h @@ -330,12 +331,6 @@ if (WIN32) cmGlobalVisualStudio8Generator.h cmGlobalVisualStudio9Generator.cxx cmGlobalVisualStudio9Generator.h - cmGlobalVisualStudio8Win64Generator.cxx - cmGlobalVisualStudio8Win64Generator.h - cmGlobalVisualStudio9Win64Generator.cxx - cmGlobalVisualStudio9Win64Generator.h - cmGlobalVisualStudio9IA64Generator.cxx - cmGlobalVisualStudio9IA64Generator.h cmVisualStudioGeneratorOptions.h cmVisualStudioGeneratorOptions.cxx cmVisualStudio10TargetGenerator.h @@ -344,16 +339,8 @@ if (WIN32) cmLocalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.h cmGlobalVisualStudio10Generator.cxx - cmGlobalVisualStudio10Win64Generator.h - cmGlobalVisualStudio10Win64Generator.cxx - cmGlobalVisualStudio10IA64Generator.h - cmGlobalVisualStudio10IA64Generator.cxx cmGlobalVisualStudio11Generator.h cmGlobalVisualStudio11Generator.cxx - cmGlobalVisualStudio11Win64Generator.h - cmGlobalVisualStudio11Win64Generator.cxx - cmGlobalVisualStudio11ARMGenerator.h - cmGlobalVisualStudio11ARMGenerator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h cmGlobalWatcomWMakeGenerator.cxx @@ -366,6 +353,8 @@ if (WIN32) cmLocalVisualStudio7Generator.h cmLocalVisualStudioGenerator.cxx cmLocalVisualStudioGenerator.h + cmVisualStudioWCEPlatformParser.h + cmVisualStudioWCEPlatformParser.cxx cmWin32ProcessExecution.cxx cmWin32ProcessExecution.h ) @@ -510,6 +499,14 @@ if(UNIX) ) endif() +if(WIN32) + set(CPACK_SRCS ${CPACK_SRCS} + CPack/WiX/cmCPackWIXGenerator.cxx + CPack/WiX/cmWIXSourceWriter.cxx + CPack/WiX/cmWIXRichTextFormatWriter.cxx + ) +endif() + if(APPLE) set(CPACK_SRCS ${CPACK_SRCS} CPack/cmCPackBundleGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c59c618..3badbd7 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 2) -#set(CMake_VERSION_RC 3) +set(CMake_VERSION_TWEAK 20130103) +#set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx new file mode 100644 index 0000000..e8b0ea9 --- /dev/null +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -0,0 +1,571 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 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. +============================================================================*/ + +#include "cmCPackWIXGenerator.h" + +#include <cmSystemTools.h> +#include <cmGeneratedFileStream.h> +#include <CPack/cmCPackLog.h> +#include <CPack/cmCPackComponentGroup.h> + +#include "cmWIXSourceWriter.h" +#include "cmWIXRichTextFormatWriter.h" + +#include <cmsys/SystemTools.hxx> +#include <cmsys/Directory.hxx> + +#include <rpc.h> // for GUID generation + +int cmCPackWIXGenerator::InitializeInternal() +{ + componentPackageMethod = ONE_PACKAGE; + + return this->Superclass::InitializeInternal(); +} + +bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command) +{ + std::string cpackTopLevel; + if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) + { + return false; + } + + std::string logFileName = cpackTopLevel + "/wix.log"; + + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Running WiX command: " << command << std::endl); + + std::string output; + + int returnValue = 0; + bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output, + &returnValue, 0, cmSystemTools::OUTPUT_NONE); + + std::ofstream logFile(logFileName.c_str(), std::ios::app); + logFile << command << std::endl; + logFile << output; + logFile.close(); + + if(!status || returnValue) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running WiX candle. " + "Please check '" << logFileName << "' for errors." << std::endl); + + return false; + } + + return true; +} + +bool cmCPackWIXGenerator::RunCandleCommand( + const std::string& sourceFile, const std::string& objectFile) +{ + std::string executable; + if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable)) + { + return false; + } + + std::stringstream command; + command << QuotePath(executable); + command << " -nologo"; + command << " -arch " << GetArchitecture(); + command << " -out " << QuotePath(objectFile); + command << " " << QuotePath(sourceFile); + + return RunWiXCommand(command.str()); +} + +bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) +{ + std::string executable; + if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable)) + { + return false; + } + + std::stringstream command; + command << QuotePath(executable); + command << " -nologo"; + command << " -out " << QuotePath(packageFileNames.at(0)); + command << " -ext WixUIExtension"; + command << " " << objectFiles; + + return RunWiXCommand(command.str()); +} + +int cmCPackWIXGenerator::PackageFiles() +{ + if(!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Fatal WiX Generator Error" << std::endl); + return false; + } + + return true; +} + +bool cmCPackWIXGenerator::InitializeWiXConfiguration() +{ + if(!ReadListFile("CPackWIX.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while executing CPackWIX.cmake" << std::endl); + return false; + } + + if(GetOption("CPACK_WIX_PRODUCT_GUID") == 0) + { + std::string guid = GenerateGUID(); + SetOption("CPACK_WIX_PRODUCT_GUID", guid.c_str()); + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "CPACK_WIX_PRODUCT_GUID implicitly set to " << guid << " . " + << std::endl); + } + + if(GetOption("CPACK_WIX_UPGRADE_GUID") == 0) + { + std::string guid = GenerateGUID(); + SetOption("CPACK_WIX_UPGRADE_GUID", guid.c_str()); + + cmCPackLogger(cmCPackLog::LOG_WARNING, + "CPACK_WIX_UPGRADE_GUID implicitly set to " << guid << " . " + "Please refer to the documentation on how and why " + "you might want to set this explicitly." << std::endl); + } + + std::string cpackTopLevel; + if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) + { + return false; + } + + if(GetOption("CPACK_WIX_LICENSE_RTF") == 0) + { + std::string licenseFilename = cpackTopLevel + "/License.rtf"; + SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str()); + + if(!CreateLicenseFile()) + { + return false; + } + } + + return true; +} + +bool cmCPackWIXGenerator::PackageFilesImpl() +{ + if(!InitializeWiXConfiguration()) + { + return false; + } + + if(!CreateWiXVariablesIncludeFile()) + { + return false; + } + + if(!CreateWiXSourceFiles()) + { + return false; + } + + std::stringstream objectFiles; + for(size_t i = 0; i < wixSources.size(); ++i) + { + const std::string& sourceFilename = wixSources[i]; + + std::string objectFilename = + cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; + + if(!RunCandleCommand(sourceFilename, objectFilename)) + { + return false; + } + + objectFiles << " " << QuotePath(objectFilename); + } + + return RunLightCommand(objectFiles.str()); +} + +bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() +{ + std::string cpackTopLevel; + if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) + { + return false; + } + + std::string includeFilename = + cpackTopLevel + "/cpack_variables.wxi"; + + cmWIXSourceWriter includeFile(Logger, includeFilename, true); + CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID"); + CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID"); + CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR"); + CopyDefinition(includeFile, "CPACK_PACKAGE_NAME"); + CopyDefinition(includeFile, "CPACK_PACKAGE_VERSION"); + CopyDefinition(includeFile, "CPACK_WIX_LICENSE_RTF"); + CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_ICON"); + CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER"); + CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG"); + + return true; +} + +void cmCPackWIXGenerator::CopyDefinition( + cmWIXSourceWriter &source, const std::string &name) +{ + const char* value = GetOption(name.c_str()); + if(value) + { + AddDefinition(source, name, value); + } +} + +void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, + const std::string& name, const std::string& value) +{ + std::stringstream tmp; + tmp << name << "=\"" << value << '"'; + + source.AddProcessingInstruction("define", + cmWIXSourceWriter::WindowsCodepageToUtf8(tmp.str())); +} + +bool cmCPackWIXGenerator::CreateWiXSourceFiles() +{ + std::string cpackTopLevel; + if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) + { + return false; + } + + std::string directoryDefinitionsFilename = + cpackTopLevel + "/directories.wxs"; + + wixSources.push_back(directoryDefinitionsFilename); + + cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename); + directoryDefinitions.BeginElement("Fragment"); + + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "TARGETDIR"); + directoryDefinitions.AddAttribute("Name", "SourceDir"); + + directoryDefinitions.BeginElement("Directory"); + if(GetArchitecture() == "x86") + { + directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder"); + } + else + { + directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder"); + } + + std::vector<std::string> install_root; + + std::string tmp; + if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp)) + { + return false; + } + + cmSystemTools::SplitPath(tmp.c_str(), install_root); + + if(!install_root.empty() && install_root.back().empty()) + { + install_root.pop_back(); + } + + for(size_t i = 1; i < install_root.size(); ++i) + { + directoryDefinitions.BeginElement("Directory"); + + if(i == install_root.size() - 1) + { + directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT"); + } + else + { + std::stringstream ss; + ss << "INSTALL_PREFIX_" << i; + directoryDefinitions.AddAttribute("Id", ss.str()); + } + + directoryDefinitions.AddAttribute("Name", install_root[i]); + } + + size_t directoryCounter = 0; + size_t fileCounter = 0; + + std::string fileDefinitionsFilename = + cpackTopLevel + "/files.wxs"; + + wixSources.push_back(fileDefinitionsFilename); + + cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename); + fileDefinitions.BeginElement("Fragment"); + + std::string featureDefinitionsFilename = + cpackTopLevel +"/features.wxs"; + + wixSources.push_back(featureDefinitionsFilename); + + cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename); + featureDefinitions.BeginElement("Fragment"); + + featureDefinitions.BeginElement("Feature"); + featureDefinitions.AddAttribute("Id", "ProductFeature"); + featureDefinitions.AddAttribute("Title", Name); + featureDefinitions.AddAttribute("Level", "1"); + featureDefinitions.EndElement(); + + featureDefinitions.BeginElement("FeatureRef"); + featureDefinitions.AddAttribute("Id", "ProductFeature"); + + AddDirectoryAndFileDefinitons( + toplevel, "INSTALL_ROOT", + directoryDefinitions, fileDefinitions, featureDefinitions, + directoryCounter, fileCounter); + + featureDefinitions.EndElement(); + featureDefinitions.EndElement(); + fileDefinitions.EndElement(); + + for(size_t i = 1; i < install_root.size(); ++i) + { + directoryDefinitions.EndElement(); + } + + directoryDefinitions.EndElement(); + directoryDefinitions.EndElement(); + directoryDefinitions.EndElement(); + + std::string wixTemplate = FindTemplate("WIX.template.in"); + if(wixTemplate.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Could not find CPack WiX template file WIX.template.in" << std::endl); + return false; + } + + std::string mainSourceFilePath = cpackTopLevel + "/main.wxs"; + + if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Failed creating '" << mainSourceFilePath << + "'' from template." << std::endl); + + return false; + } + + wixSources.push_back(mainSourceFilePath); + + return true; +} + +bool cmCPackWIXGenerator::CreateLicenseFile() +{ + std::string licenseSourceFilename; + if(!RequireOption("CPACK_RESOURCE_FILE_LICENSE", licenseSourceFilename)) + { + return false; + } + + std::string licenseDestinationFilename; + if(!RequireOption("CPACK_WIX_LICENSE_RTF", licenseDestinationFilename)) + { + return false; + } + + std::string extension = GetRightmostExtension(licenseSourceFilename); + + if(extension == ".rtf") + { + cmSystemTools::CopyAFile( + licenseSourceFilename.c_str(), + licenseDestinationFilename.c_str()); + } + else if(extension == ".txt") + { + cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename); + + std::ifstream licenseSource(licenseSourceFilename.c_str()); + + std::string line; + while(std::getline(licenseSource, line)) + { + rtfWriter.AddText(line); + rtfWriter.AddText("\n"); + } + } + else + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "unsupported WiX License file extension '" << + extension << "'" << std::endl); + + return false; + } + + return true; +} + +void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( + const std::string& topdir, + const std::string& directoryId, + cmWIXSourceWriter& directoryDefinitions, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions, + size_t& directoryCounter, + size_t& fileCounter) +{ + cmsys::Directory dir; + dir.Load(topdir.c_str()); + + for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i) + { + std::string fileName = dir.GetFile(static_cast<unsigned long>(i)); + + if(fileName == "." || fileName == "..") + { + continue; + } + + std::string fullPath = topdir + "/" + fileName; + + if(cmSystemTools::FileIsDirectory(fullPath.c_str())) + { + std::stringstream tmp; + tmp << "DIR_ID_" << ++directoryCounter; + std::string subDirectoryId = tmp.str(); + + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", subDirectoryId); + directoryDefinitions.AddAttribute("Name", fileName); + + AddDirectoryAndFileDefinitons( + fullPath, subDirectoryId, + directoryDefinitions, + fileDefinitions, + featureDefinitions, + directoryCounter, + fileCounter); + + directoryDefinitions.EndElement(); + } + else + { + std::stringstream tmp; + tmp << "_ID_" << ++fileCounter; + std::string idSuffix = tmp.str(); + + std::string componentId = std::string("CMP") + idSuffix; + std::string fileId = std::string("FILE") + idSuffix; + + fileDefinitions.BeginElement("DirectoryRef"); + fileDefinitions.AddAttribute("Id", directoryId); + + fileDefinitions.BeginElement("Component"); + fileDefinitions.AddAttribute("Id", componentId); + fileDefinitions.AddAttribute("Guid", "*"); + + fileDefinitions.BeginElement("File"); + fileDefinitions.AddAttribute("Id", fileId); + fileDefinitions.AddAttribute("Source", fullPath); + fileDefinitions.AddAttribute("KeyPath", "yes"); + + fileDefinitions.EndElement(); + fileDefinitions.EndElement(); + fileDefinitions.EndElement(); + + featureDefinitions.BeginElement("ComponentRef"); + featureDefinitions.AddAttribute("Id", componentId); + featureDefinitions.EndElement(); + } + } +} + +bool cmCPackWIXGenerator::RequireOption( + const std::string& name, std::string &value) const +{ + const char* tmp = GetOption(name.c_str()); + if(tmp) + { + value = tmp; + + return true; + } + else + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Required variable " << name << " not set" << std::endl); + + return false; + } +} + +std::string cmCPackWIXGenerator::GetArchitecture() const +{ + std::string void_p_size; + RequireOption("CPACK_WIX_SIZEOF_VOID_P", void_p_size); + + if(void_p_size == "8") + { + return "x64"; + } + else + { + return "x86"; + } +} + +std::string cmCPackWIXGenerator::GenerateGUID() +{ + UUID guid; + UuidCreate(&guid); + + unsigned char *tmp = 0; + UuidToString(&guid, &tmp); + + std::string result(reinterpret_cast<char*>(tmp)); + RpcStringFree(&tmp); + + return cmSystemTools::UpperCase(result); +} + +std::string cmCPackWIXGenerator::QuotePath(const std::string& path) +{ + return std::string("\"") + path + '"'; +} + +std::string cmCPackWIXGenerator::GetRightmostExtension( + const std::string& filename) +{ + std::string extension; + + std::string::size_type i = filename.rfind("."); + if(i != std::string::npos) + { + extension = filename.substr(i); + } + + return cmSystemTools::LowerCase(extension); +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h new file mode 100644 index 0000000..0e95d70 --- /dev/null +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -0,0 +1,101 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackWIXGenerator_h +#define cmCPackWIXGenerator_h + +#include <CPack/cmCPackGenerator.h> + +#include <string> +#include <map> + +class cmWIXSourceWriter; + +/** \class cmCPackWIXGenerator + * \brief A generator for WIX files + */ +class cmCPackWIXGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator); + +protected: + virtual int InitializeInternal(); + + virtual int PackageFiles(); + + virtual const char* GetOutputExtension() + { + return ".msi"; + } + + virtual enum CPackSetDestdirSupport SupportsSetDestdir() const + { + return SETDESTDIR_UNSUPPORTED; + } + + virtual bool SupportsAbsoluteDestination() const + { + return false; + } + + virtual bool SupportsComponentInstallation() const + { + return false; + } + +private: + bool InitializeWiXConfiguration(); + + bool PackageFilesImpl(); + + bool CreateWiXVariablesIncludeFile(); + + void CopyDefinition( + cmWIXSourceWriter &source, const std::string &name); + + void AddDefinition(cmWIXSourceWriter& source, + const std::string& name, const std::string& value); + + bool CreateWiXSourceFiles(); + + bool CreateLicenseFile(); + + bool RunWiXCommand(const std::string& command); + + bool RunCandleCommand( + const std::string& sourceFile, const std::string& objectFile); + + bool RunLightCommand(const std::string& objectFiles); + + void AddDirectoryAndFileDefinitons(const std::string& topdir, + const std::string& directoryId, + cmWIXSourceWriter& directoryDefinitions, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions, + size_t& directoryCounter, + size_t& fileCounter); + + bool RequireOption(const std::string& name, std::string& value) const; + + std::string GetArchitecture() const; + + static std::string GenerateGUID(); + + static std::string QuotePath(const std::string& path); + + static std::string GetRightmostExtension(const std::string& filename); + + std::vector<std::string> wixSources; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx new file mode 100644 index 0000000..774c22c --- /dev/null +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -0,0 +1,137 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXRichTextFormatWriter.h" + +#include <cmVersion.h> + +cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( + const std::string& filename): + file(filename.c_str(), std::ios::binary) +{ + StartGroup(); + WriteHeader(); + WriteDocumentPrefix(); +} + +cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter() +{ + EndGroup(); + + /* I haven't seen this in the RTF spec but + * wordpad terminates its RTF like this */ + file << "\r\n"; + file.put(0); +} + +void cmWIXRichTextFormatWriter::AddText(const std::string& text) +{ + typedef unsigned char rtf_byte_t; + + for(size_t i = 0; i < text.size(); ++i) + { + rtf_byte_t c = rtf_byte_t(text[i]); + + switch(c) + { + case '\\': + file << "\\\\"; + break; + case '{': + file << "\\{"; + break; + case '}': + file << "\\}"; + break; + case '\n': + file << "\\par\r\n"; + break; + case '\r': + continue; + default: + { + if(c <= 0x7F) + { + file << c; + } + else + { + file << "[NON-ASCII-" << int(c) << "]"; + } + } + break; + } + } +} + +void cmWIXRichTextFormatWriter::WriteHeader() +{ + ControlWord("rtf1"); + ControlWord("ansi"); + ControlWord("ansicpg1252"); + ControlWord("deff0"); + ControlWord("deflang1031"); + + WriteFontTable(); + WriteGenerator(); +} + +void cmWIXRichTextFormatWriter::WriteFontTable() +{ + StartGroup(); + ControlWord("fonttbl"); + + StartGroup(); + ControlWord("f0"); + ControlWord("fswiss"); + ControlWord("fcharset0 Arial;"); + EndGroup(); + + EndGroup(); +} + +void cmWIXRichTextFormatWriter::WriteGenerator() +{ + StartGroup(); + NewControlWord("generator"); + file << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");"; + EndGroup(); +} + +void cmWIXRichTextFormatWriter::WriteDocumentPrefix() +{ + ControlWord("viewkind4"); + ControlWord("uc1"); + ControlWord("pard"); + ControlWord("f0"); + ControlWord("fs20"); +} + +void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword) +{ + file << "\\" << keyword; +} + +void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword) +{ + file << "\\*\\" << keyword; +} + +void cmWIXRichTextFormatWriter::StartGroup() +{ + file.put('{'); +} + +void cmWIXRichTextFormatWriter::EndGroup() +{ + file.put('}'); +} diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h new file mode 100644 index 0000000..10b67c3 --- /dev/null +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -0,0 +1,46 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXRichTextFormatWriter_h +#define cmWIXRichTextFormatWriter_h + +#include <fstream> + +/** \class cmWIXRichtTextFormatWriter + * \brief Helper class to generate Rich Text Format (RTF) documents + * from plain text (e.g. for license and welcome text) + */ +class cmWIXRichTextFormatWriter +{ +public: + cmWIXRichTextFormatWriter(const std::string& filename); + ~cmWIXRichTextFormatWriter(); + + void AddText(const std::string& text); + +private: + void WriteHeader(); + void WriteFontTable(); + void WriteGenerator(); + + void WriteDocumentPrefix(); + + void ControlWord(const std::string& keyword); + void NewControlWord(const std::string& keyword); + + void StartGroup(); + void EndGroup(); + + std::ofstream file; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx new file mode 100644 index 0000000..af7ba80 --- /dev/null +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -0,0 +1,189 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2012 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXSourceWriter.h" + +#include <CPack/cmCPackGenerator.h> + +#include <windows.h> + +cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, + const std::string& filename, + bool isIncludeFile): + Logger(logger), + file(filename.c_str()), + state(DEFAULT) +{ + WriteXMLDeclaration(); + + if(isIncludeFile) + { + BeginElement("Include"); + } + else + { + BeginElement("Wix"); + } + + AddAttribute("xmlns", "http://schemas.microsoft.com/wix/2006/wi"); +} + +cmWIXSourceWriter::~cmWIXSourceWriter() +{ + while(elements.size()) + { + EndElement(); + } +} + +void cmWIXSourceWriter::BeginElement(const std::string& name) +{ + if(state == BEGIN) + { + file << ">"; + } + + file << "\n"; + Indent(elements.size()); + file << "<" << name; + + elements.push_back(name); + state = BEGIN; +} + +void cmWIXSourceWriter::EndElement() +{ + if(elements.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "can not end WiX element with no open elements" << std::endl); + return; + } + + if(state == DEFAULT) + { + file << "\n"; + Indent(elements.size()-1); + file << "</" << elements.back() << ">"; + } + else + { + file << "/>"; + } + + elements.pop_back(); + state = DEFAULT; +} + +void cmWIXSourceWriter::AddProcessingInstruction( + const std::string& target, const std::string& content) +{ + if(state == BEGIN) + { + file << ">"; + } + + file << "\n"; + Indent(elements.size()); + file << "<?" << target << " " << content << "?>"; + + state = DEFAULT; +} + +void cmWIXSourceWriter::AddAttribute( + const std::string& key, const std::string& value) +{ + std::string utf8 = WindowsCodepageToUtf8(value); + + file << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; +} + +std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) +{ + if(value.empty()) + { + return std::string(); + } + + int characterCount = MultiByteToWideChar( + CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0); + + if(characterCount == 0) + { + return std::string(); + } + + std::vector<wchar_t> utf16(characterCount); + + MultiByteToWideChar( + CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), + &utf16[0], static_cast<int>(utf16.size())); + + int utf8ByteCount = WideCharToMultiByte( + CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0); + + if(utf8ByteCount == 0) + { + return std::string(); + } + + std::vector<char> utf8(utf8ByteCount); + + WideCharToMultiByte(CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), + &utf8[0], static_cast<int>(utf8.size()), 0, 0); + + return std::string(&utf8[0], utf8.size()); +} + + +void cmWIXSourceWriter::WriteXMLDeclaration() +{ + file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; +} + +void cmWIXSourceWriter::Indent(size_t count) +{ + for(size_t i = 0; i < count; ++i) + { + file << " "; + } +} + +std::string cmWIXSourceWriter::EscapeAttributeValue( + const std::string& value) +{ + std::string result; + result.reserve(value.size()); + + char c = 0; + for(size_t i = 0 ; i < value.size(); ++i) + { + c = value[i]; + switch(c) + { + case '<': + result += "<"; + break; + case '&': + result +="&"; + break; + case '"': + result += """; + break; + default: + result += c; + break; + } + } + + return result; +} diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h new file mode 100644 index 0000000..1dafc1f --- /dev/null +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -0,0 +1,67 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2012 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmWIXSourceWriter_h +#define cmWIXSourceWriter_h + +#include <vector> +#include <string> +#include <fstream> + +#include <CPack/cmCPackLog.h> + +/** \class cmWIXSourceWriter + * \brief Helper class to generate XML WiX source files + */ +class cmWIXSourceWriter +{ +public: + cmWIXSourceWriter(cmCPackLog* logger, + const std::string& filename, bool isIncludeFile = false); + + ~cmWIXSourceWriter(); + + void BeginElement(const std::string& name); + + void EndElement(); + + void AddProcessingInstruction( + const std::string& target, const std::string& content); + + void AddAttribute( + const std::string& key, const std::string& value); + + static std::string WindowsCodepageToUtf8(const std::string& value); + +private: + enum State + { + DEFAULT, + BEGIN + }; + + void WriteXMLDeclaration(); + + void Indent(size_t count); + + static std::string EscapeAttributeValue(const std::string& value); + + cmCPackLog* Logger; + + std::ofstream file; + + State state; + + std::vector<std::string> elements; +}; + +#endif diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index 48d935c..abae372 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -42,7 +42,9 @@ public: class cmCPackComponent { public: - cmCPackComponent() : Group(0), TotalSize(0) { } + cmCPackComponent() : Group(0), IsRequired(true), IsHidden(false), + IsDisabledByDefault(false), IsDownloaded(false), + TotalSize(0) { } /// The name of the component (used to reference the component). std::string Name; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 4bd5d5c..f99db58 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -76,6 +76,11 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, packageFileName.c_str()); // Tell CPackDeb.cmake the name of the component GROUP. this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",packageName.c_str()); + // Tell CPackDeb.cmake the path where the component is. + std::string component_path = "/"; + component_path += packageName; + this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", + component_path.c_str()); if (!this->ReadListFile("CPackDeb.cmake")) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -198,8 +203,11 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() /* replace the TEMPORARY package file name */ this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", packageFileName.c_str()); - // Tell CPackDeb.cmake the name of the component GROUP. - this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",compInstDirName.c_str()); + // Tell CPackDeb.cmake the path where the component is. + std::string component_path = "/"; + component_path += compInstDirName; + this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", + component_path.c_str()); if (!this->ReadListFile("CPackDeb.cmake")) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 78cb1b6..d973c01 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -442,7 +442,22 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, line.replace(pos, 1, "\\\""); pos = line.find('\"', pos+2); } - osf << " \"" << line << "\\n\"\n"; + // break up long lines to avoid Rez errors + std::vector<std::string> lines; + const size_t max_line_length = 512; + for(size_t i=0; i<line.size(); i+= max_line_length) + { + int line_length = max_line_length; + if(i+max_line_length > line.size()) + line_length = line.size()-i; + lines.push_back(line.substr(i, line_length)); + } + + for(size_t i=0; i<lines.size(); i++) + { + osf << " \"" << lines[i] << "\"\n"; + } + osf << " \"\\n\"\n"; } osf << "};\n"; osf << "\n"; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index e964696..7cc1522 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -23,7 +23,6 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Glob.hxx> -#include <memory> // auto_ptr #include <algorithm> #if defined(__HAIKU__) @@ -97,7 +96,6 @@ int cmCPackGenerator::PrepareNames() } tempDirectory += this->GetOption("CPACK_GENERATOR"); std::string topDirectory = tempDirectory; - this->GetOption("CPACK_PACKAGE_FILE_NAME"); const char* pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME"); if(!pfname) { @@ -208,7 +206,7 @@ int cmCPackGenerator::InstallProject() { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating temporary directory: " - << (tempInstallDirectory ? tempInstallDirectory : "(NULL}") + << (tempInstallDirectory ? tempInstallDirectory : "(NULL)") << std::endl); return 0; } @@ -697,7 +695,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 37ff460..55776739 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -19,6 +19,7 @@ #include "cmCPackZIPGenerator.h" #include "cmCPackSTGZGenerator.h" #include "cmCPackNSISGenerator.h" + #ifdef __APPLE__ # include "cmCPackDragNDropGenerator.h" # include "cmCPackBundleGenerator.h" @@ -37,6 +38,9 @@ # include "cmCPackRPMGenerator.h" #endif +#ifdef _WIN32 +# include "WiX/cmCPackWIXGenerator.h" +#endif #include "cmCPackLog.h" @@ -61,6 +65,8 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() { this->RegisterGenerator("NSIS", "Null Soft Installer", cmCPackNSISGenerator::CreateGenerator); + this->RegisterGenerator("NSIS64", "Null Soft Installer (64-bit)", + cmCPackNSISGenerator::CreateGenerator64); } #ifdef __CYGWIN__ if (cmCPackCygwinBinaryGenerator::CanGenerate()) @@ -80,6 +86,13 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("ZIP", "ZIP file format", cmCPackZIPGenerator::CreateGenerator); } +#ifdef _WIN32 + if (cmCPackWIXGenerator::CanGenerate()) + { + this->RegisterGenerator("WIX", "MSI file format via WiX tools", + cmCPackWIXGenerator::CreateGenerator); + } +#endif if (cmCPackTarBZip2Generator::CanGenerate()) { this->RegisterGenerator("TBZ2", "Tar BZip2 compression", diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index b2e57a2..9f86ea2 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -33,8 +33,9 @@ #endif //---------------------------------------------------------------------- -cmCPackNSISGenerator::cmCPackNSISGenerator() +cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64) { + Nsis64 = nsis64; } //---------------------------------------------------------------------- @@ -356,19 +357,46 @@ int cmCPackNSISGenerator::InitializeInternal() << std::endl); std::vector<std::string> path; std::string nsisPath; - bool gotRegValue = true; + bool gotRegValue = false; #ifdef _WIN32 - if ( !cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, - cmsys::SystemTools::KeyWOW64_32) ) + if (Nsis64) { - if ( !cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath) ) + if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath, + cmsys::SystemTools::KeyWOW64_64) ) + { + gotRegValue = true; + } + if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, + cmsys::SystemTools::KeyWOW64_64) ) { - gotRegValue = false; + gotRegValue = true; } } + if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath, + cmsys::SystemTools::KeyWOW64_32) ) + { + gotRegValue = true; + } + if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath) ) + { + gotRegValue = true; + } + if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, + cmsys::SystemTools::KeyWOW64_32) ) + { + gotRegValue = true; + } + if ( !gotRegValue && cmsys::SystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath) ) + { + gotRegValue = true; + } if (gotRegValue) { diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 8224854..e46fbda 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -27,10 +27,13 @@ class cmCPackNSISGenerator : public cmCPackGenerator public: cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenerator); + static cmCPackGenerator* CreateGenerator64() + { return new cmCPackNSISGenerator(true); } + /** * Construct generator */ - cmCPackNSISGenerator(); + cmCPackNSISGenerator(bool nsis64 = false); virtual ~cmCPackNSISGenerator(); protected: @@ -77,6 +80,8 @@ protected: /// Translations any newlines found in the string into \\r\\n, so that the /// resulting string can be used within NSIS. static std::string TranslateNewlines(std::string str); + + bool Nsis64; }; #endif diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index edbe838..c617a3e 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -106,56 +106,101 @@ int cmCPackPackageMakerGenerator::PackageFiles() resDir += "/en.lproj"; } - - // Create directory structure - std::string preflightDirName = resDir + "/PreFlight"; - std::string postflightDirName = resDir + "/PostFlight"; const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT"); const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT"); const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT"); - // if preflight or postflight scripts not there create directories - // of the same name, I think this makes it work - if(!preflight) + + if(this->Components.empty()) { - if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) + // Create directory structure + std::string preflightDirName = resDir + "/PreFlight"; + std::string postflightDirName = resDir + "/PostFlight"; + // if preflight or postflight scripts not there create directories + // of the same name, I think this makes it work + if(!preflight) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem creating installer directory: " - << preflightDirName.c_str() << std::endl); - return 0; + if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating installer directory: " + << preflightDirName.c_str() << std::endl); + return 0; + } + } + if(!postflight) + { + if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating installer directory: " + << postflightDirName.c_str() << std::endl); + return 0; + } + } + // if preflight, postflight, or postupgrade are set + // then copy them into the resource directory and make + // them executable + if(preflight) + { + this->CopyInstallScript(resDir.c_str(), + preflight, + "preflight"); + } + if(postflight) + { + this->CopyInstallScript(resDir.c_str(), + postflight, + "postflight"); + } + if(postupgrade) + { + this->CopyInstallScript(resDir.c_str(), + postupgrade, + "postupgrade"); } } - if(!postflight) + else if(postflight) { - if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) + // create a postflight component to house the script + this->PostFlightComponent.Name = "PostFlight"; + this->PostFlightComponent.DisplayName = "PostFlight"; + this->PostFlightComponent.Description = "PostFlight"; + this->PostFlightComponent.IsHidden = true; + + // empty directory for pkg contents + std::string packageDir = toplevel + "/" + PostFlightComponent.Name; + if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem creating installer directory: " - << postflightDirName.c_str() << std::endl); + "Problem creating component packages directory: " + << packageDir.c_str() << std::endl); return 0; } - } - // if preflight, postflight, or postupgrade are set - // then copy them into the resource directory and make - // them executable - if(preflight) - { - this->CopyInstallScript(resDir.c_str(), - preflight, - "preflight"); - } - if(postflight) - { - this->CopyInstallScript(resDir.c_str(), + + // create package + std::string packageFileDir = packageDirFileName + "/Contents/Packages/"; + if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating component PostFlight Packages directory: " + << packageFileDir.c_str() << std::endl); + return 0; + } + std::string packageFile = packageFileDir + + this->GetPackageName(PostFlightComponent); + if (!this->GenerateComponentPackage(packageFile.c_str(), + packageDir.c_str(), + PostFlightComponent)) + { + return 0; + } + + // copy postflight script into resource directory of .pkg + std::string resourceDir = packageFile + "/Contents/Resources"; + this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight"); } - if(postupgrade) - { - this->CopyInstallScript(resDir.c_str(), - postupgrade, - "postupgrade"); - } if (!this->Components.empty()) { @@ -778,6 +823,11 @@ WriteDistributionFile(const char* metapackageFile) << std::endl; } } + if(!this->PostFlightComponent.Name.empty()) + { + choiceOut << "<line choice=\"" << PostFlightComponent.Name + << "Choice\"></line>" << std::endl; + } choiceOut << "</choices-outline>" << std::endl; // Create the actual choices @@ -792,6 +842,12 @@ WriteDistributionFile(const char* metapackageFile) { CreateChoice(compIt->second, choiceOut); } + + if(!this->PostFlightComponent.Name.empty()) + { + CreateChoice(PostFlightComponent, choiceOut); + } + this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str()); // Create the distribution.dist file in the metapackage to turn it diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 101813f..ba3d968 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -112,6 +112,9 @@ protected: // value. std::string EscapeForXML(std::string str); + // The PostFlight component when creating a metapackage + cmCPackComponent PostFlightComponent; + double PackageMakerVersion; double PackageCompatibilityVersion; }; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 13aa6d8..66a4194 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -77,6 +77,11 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel, packageFileName.c_str()); // Tell CPackRPM.cmake the name of the component NAME. this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",packageName.c_str()); + // Tell CPackRPM.cmake the path where the component is. + std::string component_path = "/"; + component_path += packageName; + this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", + component_path.c_str()); if (!this->ReadListFile("CPackRPM.cmake")) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -178,8 +183,11 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne() /* replace the TEMPORARY package file name */ this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", packageFileName.c_str()); - // Tell CPackRPM.cmake the name of the component GROUP. - this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compInstDirName.c_str()); + // Tell CPackRPM.cmake the path where the component is. + std::string component_path = "/"; + component_path += compInstDirName; + this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", + component_path.c_str()); if (!this->ReadListFile("CPackRPM.cmake")) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index b603585..0ba7322 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -27,7 +27,6 @@ #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> -#include <memory> // auto_ptr //---------------------------------------------------------------------------- static const char * cmDocumentationName[][3] = @@ -276,7 +275,7 @@ int main (int argc, char *argv[]) cminst.RemoveUnscriptableCommands(); cmGlobalGenerator cmgg; cmgg.SetCMakeInstance(&cminst); - std::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator()); cmMakefile* globalMF = cmlg->GetMakefile(); bool cpackConfigFileSpecified = true; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 4d1e249..20aded2 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1097,10 +1097,17 @@ int cmCTestCoverageHandler::HandleGCovCoverage( } else { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Unknown gcov output line: [" << line->c_str() << "]" << std::endl); - cont->Error ++; - //abort(); + // gcov 4.7 can have output lines saying "No executable lines" and + // "Removing 'filename.gcov'"... Don't log those as "errors." + if(*line != "No executable lines" && + !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Unknown gcov output line: [" << line->c_str() << "]" + << std::endl); + cont->Error ++; + //abort(); + } } diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 0da8aae..453e32c 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -121,7 +121,7 @@ bool cmCTestHandlerCommand } if ( this->Values[ct_SUBMIT_INDEX] ) { - if ( this->CTest->GetDartVersion() <= 1 ) + if(!this->CTest->GetDropSiteCDash() && this->CTest->GetDartVersion() <= 1) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Dart before version 2.0 does not support collecting submissions." diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index ebef1ed..76ddeea 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -248,7 +248,12 @@ bool cmCTestMultiProcessHandler::StartTest(int test) //--------------------------------------------------------- void cmCTestMultiProcessHandler::StartNextTests() { - size_t numToStart = this->ParallelLevel - this->RunningCount; + size_t numToStart = 0; + if(this->RunningCount < this->ParallelLevel) + { + numToStart = this->ParallelLevel - this->RunningCount; + } + if(numToStart == 0) { return; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b796b83..e7491bb 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -32,7 +32,6 @@ #include <math.h> #include <float.h> -#include <memory> // auto_ptr #include <set> //---------------------------------------------------------------------- @@ -1547,7 +1546,7 @@ void cmCTestTestHandler::GetListOfTests() cmake cm; cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index 5c7414f..bd1ff71 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -175,7 +175,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, } else if ( key == ctrl('d') ||key == KEY_DC ) { - if ( form->curcol > 0 ) + if ( form->curcol >= 0 ) { form_driver(form, REQ_DEL_CHAR); } diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index c5252b7..1cc1e3a 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -68,7 +68,8 @@ public: " [COMMAND command2 [ARGS] [args2...] ...]\n" " [MAIN_DEPENDENCY depend]\n" " [DEPENDS [depends...]]\n" - " [IMPLICIT_DEPENDS <lang1> depend1 ...]\n" + " [IMPLICIT_DEPENDS <lang1> depend1\n" + " [<lang2> depend2] ...]\n" " [WORKING_DIRECTORY dir]\n" " [COMMENT comment] [VERBATIM] [APPEND])\n" "This defines a command to generate specified OUTPUT file(s). " @@ -142,6 +143,8 @@ public: "dependencies of an input file. The language given specifies the " "programming language whose corresponding dependency scanner should " "be used. Currently only C and CXX language scanners are supported. " + "The language has to be specified for every file in the " + "IMPLICIT_DEPENDS list. " "Dependencies discovered from the scanning are added to those of " "the custom command at build time. Note that the IMPLICIT_DEPENDS " "option is currently supported only for Makefile generators and " diff --git a/Source/cmBootstrapCommands.cxx b/Source/cmBootstrapCommands.cxx index 9097a74..e3a2ad4 100644 --- a/Source/cmBootstrapCommands.cxx +++ b/Source/cmBootstrapCommands.cxx @@ -89,6 +89,7 @@ #include "cmStringCommand.cxx" #include "cmSubdirCommand.cxx" #include "cmTargetLinkLibrariesCommand.cxx" +#include "cmTimestamp.cxx" #include "cmTryCompileCommand.cxx" #include "cmTryRunCommand.cxx" #include "cmUnsetCommand.cxx" diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index a6d04b7..bb6f3f2 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -327,6 +327,7 @@ cmCTest::cmCTest() this->OutputLogFileLastTag = -1; this->SuppressUpdatingCTestConfiguration = false; this->DartVersion = 1; + this->DropSiteCDash = false; this->OutputTestOutputOnTestFailure = false; this->ComputedCompressTestOutput = false; this->ComputedCompressMemCheckOutput = false; @@ -653,6 +654,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) = this->GetCTestConfiguration("SourceDirectory").c_str(); std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str(); this->DartVersion = 1; + this->DropSiteCDash = false; for(Part p = PartStart; p != PartCount; p = Part(p+1)) { this->Parts[p].SubmitFiles.clear(); @@ -719,6 +721,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) return false; } } + this->DropSiteCDash = mf->IsOn("CTEST_DROP_SITE_CDASH"); if ( !this->Initialize(bld_dir.c_str(), command) ) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index f2638fe..587a6db 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -384,6 +384,7 @@ public: //! Get the version of dart server int GetDartVersion() { return this->DartVersion; } + int GetDropSiteCDash() { return this->DropSiteCDash; } //! Add file to be submitted void AddSubmitFile(Part part, const char* name); @@ -561,6 +562,7 @@ private: bool Quiet; int DartVersion; + bool DropSiteCDash; std::vector<cmStdString> InitialCommandLineArguments; diff --git a/Source/cmCommandArgumentParser.cxx b/Source/cmCommandArgumentParser.cxx index 696a6a8..c5146c5 100644 --- a/Source/cmCommandArgumentParser.cxx +++ b/Source/cmCommandArgumentParser.cxx @@ -279,7 +279,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if YYENABLE_NLS +# if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -701,7 +701,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if YYLTYPE_IS_TRIVIAL +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index cd3ef59..d8ffb5e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -277,6 +277,10 @@ cmComputeLinkInformation this->UseImportLibrary = this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false; + // Check whether we should skip dependencies on shared library files. + this->LinkDependsNoShared = + this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. @@ -650,7 +654,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) // Pass the full path to the target file. std::string lib = tgt->GetFullPath(config, implib, true); - this->Depends.push_back(lib); + if(!this->LinkDependsNoShared || + tgt->GetType() != cmTarget::SHARED_LIBRARY) + { + this->Depends.push_back(lib); + } this->AddTargetItem(lib, tgt); this->AddLibraryRuntimeInfo(lib, tgt); diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index f60f8d3..e0078af 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -82,6 +82,7 @@ private: // Configuration information. const char* Config; const char* LinkLanguage; + bool LinkDependsNoShared; // Modes for dealing with dependent shared libraries. enum SharedDepMode diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ab77c6b..3b15ec1 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -214,6 +214,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) if(emitted.insert(lib->first).second) { this->AddTargetDepend(depender_index, lib->first.c_str(), true); + this->AddInterfaceDepends(depender_index, lib->first.c_str(), + true, emitted); } } } @@ -237,6 +239,63 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) } //---------------------------------------------------------------------------- +void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, + cmTarget* dependee, + const char *config, + std::set<cmStdString> &emitted) +{ + if(cmTarget::LinkInterface const* iface = + dependee->GetLinkInterface(config)) + { + for(std::vector<std::string>::const_iterator + lib = iface->Libraries.begin(); + lib != iface->Libraries.end(); ++lib) + { + // Don't emit the same library twice for this target. + if(emitted.insert(*lib).second) + { + this->AddTargetDepend(depender_index, lib->c_str(), true); + } + } + } +} + +//---------------------------------------------------------------------------- +void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, + const char* dependee_name, + bool linking, + std::set<cmStdString> &emitted) +{ + cmTarget* depender = this->Targets[depender_index]; + cmTarget* dependee = + depender->GetMakefile()->FindTargetToUse(dependee_name); + // Skip targets that will not really be linked. This is probably a + // name conflict between an external library and an executable + // within the project. + if(linking && dependee && + dependee->GetType() == cmTarget::EXECUTABLE && + !dependee->IsExecutableWithExports()) + { + dependee = 0; + } + + if(dependee) + { + this->AddInterfaceDepends(depender_index, dependee, 0, emitted); + std::vector<std::string> configs; + depender->GetMakefile()->GetConfigurations(configs); + for (std::vector<std::string>::const_iterator it = configs.begin(); + it != configs.end(); ++it) + { + // A target should not depend on itself. + emitted.insert(depender->GetName()); + this->AddInterfaceDepends(depender_index, dependee, + it->c_str(), emitted); + } + } +} + +//---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, const char* dependee_name, bool linking) diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 67bce72..d6131cf 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -48,7 +48,11 @@ private: bool linking); void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); - + void AddInterfaceDepends(int depender_index, const char* dependee_name, + bool linking, std::set<cmStdString> &emitted); + void AddInterfaceDepends(int depender_index, cmTarget* dependee, + const char *config, + std::set<cmStdString> &emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; bool NoCycles; diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 347174a..0393ecf 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -68,6 +68,9 @@ public: "If <output> names an existing directory the input file is placed " "in that directory with its original name. " "\n" + "If the <input> file is modified the build system will re-run CMake " + "to re-configure the file and generate the build system again." + "\n" "This command replaces any variables in the input file referenced as " "${VAR} or @VAR@ with their values as determined by CMake. If a " "variable is not defined, it will be replaced with nothing. " @@ -76,13 +79,18 @@ public: "will be C-style escaped. " "The file will be configured with the current values of CMake " "variables. If @ONLY is specified, only variables " - "of the form @VAR@ will be replaces and ${VAR} will be ignored. " - "This is useful for configuring scripts that use ${VAR}. " - "Any occurrences of #cmakedefine VAR will be replaced with " - "either #define VAR or /* #undef VAR */ depending on " - "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR " - "will be replaced with either #define VAR 1 or #define VAR 0 " - "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n" + "of the form @VAR@ will be replaced and ${VAR} will be ignored. " + "This is useful for configuring scripts that use ${VAR}." + "\n" + "Input file lines of the form \"#cmakedefine VAR ...\" " + "will be replaced with either \"#define VAR ...\" or " + "\"/* #undef VAR */\" depending on whether VAR is set in CMake to " + "any value not considered a false constant by the if() command. " + "(Content of \"...\", if any, is processed as above.) " + "Input file lines of the form \"#cmakedefine01 VAR\" " + "will be replaced with either \"#define VAR 1\" or " + "\"#define VAR 0\" similarly." + "\n" "With NEWLINE_STYLE the line ending could be adjusted: \n" " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" "COPYONLY must not be used with NEWLINE_STYLE.\n"; diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 07df7d5..f2f77ee 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -47,7 +47,7 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { return target->GetLocation(this->Config); } - return this->GE->Parse(argv0).Evaluate(this->Makefile, this->Config); + return this->GE->Parse(argv0)->Evaluate(this->Makefile, this->Config); } //---------------------------------------------------------------------------- @@ -58,7 +58,7 @@ cmCustomCommandGenerator cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c]; for(unsigned int j=1;j < commandLine.size(); ++j) { - std::string arg = this->GE->Parse(commandLine[j]).Evaluate(this->Makefile, + std::string arg = this->GE->Parse(commandLine[j])->Evaluate(this->Makefile, this->Config); cmd += " "; if(this->OldStyle) diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 166a584..74a0ccb 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -50,6 +50,7 @@ bool cmDepends::Write(std::ostream &makeDepends, std::vector<std::string> pairs; cmSystemTools::ExpandListArgument(srcStr, pairs); + std::map<std::string, std::set<std::string> > dependencies; for(std::vector<std::string>::iterator si = pairs.begin(); si != pairs.end();) { @@ -62,9 +63,14 @@ bool cmDepends::Write(std::ostream &makeDepends, obj = this->LocalGenerator->Convert(obj.c_str(), cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); + dependencies[obj].insert(src); + } + for(std::map<std::string, std::set<std::string> >::const_iterator + it = dependencies.begin(); it != dependencies.end(); ++it) + { // Write the dependencies for this pair. - if(!this->WriteDependencies(src.c_str(), obj.c_str(), + if(!this->WriteDependencies(it->second, it->first, makeDepends, internalDepends)) { return false; @@ -134,8 +140,9 @@ void cmDepends::Clear(const char *file) } //---------------------------------------------------------------------------- -bool cmDepends::WriteDependencies(const char*, const char*, - std::ostream&, std::ostream&) +bool cmDepends::WriteDependencies( + const std::set<std::string>&, const std::string&, + std::ostream&, std::ostream&) { // This should be implemented by the subclass. return false; @@ -174,8 +181,10 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends, // kdelibs/khtml this reduces the number of calls from 184k down to 92k, // or the time for cmake -E cmake_depends from 0.3 s down to 0.21 s. dependerExists = cmSystemTools::FileExists(this->Depender); - DependencyVector tmp; - validDeps[this->Depender] = tmp; + // If we erase validDeps[this->Depender] by overwriting it with an empty + // vector, we lose dependencies for dependers that have multiple + // entries. No need to initialize the entry, std::map will do so on first + // access. currentDependencies = &validDeps[this->Depender]; continue; } diff --git a/Source/cmDepends.h b/Source/cmDepends.h index f7dc881..d787edd 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -76,8 +76,10 @@ protected: // Write dependencies for the target file to the given stream. // Return true for success and false for failure. - virtual bool WriteDependencies(const char *src, const char* obj, - std::ostream& makeDepends, std::ostream& internalDepends); + virtual bool WriteDependencies(const std::set<std::string>& sources, + const std::string& obj, + std::ostream& makeDepends, + std::ostream& internalDepends); // Check dependencies for the target file in the given stream. // Return false if dependencies must be regenerated and true diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 44841a9..43b7b8a 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -98,176 +98,179 @@ cmDependsC::~cmDependsC() } //---------------------------------------------------------------------------- -bool cmDependsC::WriteDependencies(const char *src, const char *obj, - std::ostream& makeDepends, std::ostream& internalDepends) +bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, + const std::string& obj, + std::ostream& makeDepends, + std::ostream& internalDepends) { // Make sure this is a scanning instance. - if(!src || src[0] == '\0') + if(sources.empty() || sources.begin()->empty()) { cmSystemTools::Error("Cannot scan dependencies without a source file."); return false; } - if(!obj || obj[0] == '\0') + if(obj.empty()) { cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } + std::set<cmStdString> dependencies; + bool haveDeps = false; + if (this->ValidDeps != 0) { std::map<std::string, DependencyVector>::const_iterator tmpIt = this->ValidDeps->find(obj); if (tmpIt!= this->ValidDeps->end()) { - // Write the dependencies to the output stream. Makefile rules - // written by the original local generator for this directory - // convert the dependencies to paths relative to the home output - // directory. We must do the same here. - internalDepends << obj << std::endl; for(DependencyVector::const_iterator i=tmpIt->second.begin(); i != tmpIt->second.end(); ++i) { - makeDepends << obj << ": " << - this->LocalGenerator->Convert(i->c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE) - << std::endl; - internalDepends << " " << i->c_str() << std::endl; + dependencies.insert(*i); } - makeDepends << std::endl; - return true; + haveDeps = true; } } - // Walk the dependency graph starting with the source file. - bool first = true; - UnscannedEntry root; - root.FileName = src; - this->Unscanned.push(root); - this->Encountered.clear(); - this->Encountered.insert(src); - std::set<cmStdString> dependencies; - std::set<cmStdString> scanned; + if (!haveDeps) + { + // Walk the dependency graph starting with the source file. + int srcFiles = (int)sources.size(); + this->Encountered.clear(); + + for(std::set<std::string>::const_iterator srcIt = sources.begin(); + srcIt != sources.end(); ++srcIt) + { + UnscannedEntry root; + root.FileName = *srcIt; + this->Unscanned.push(root); + this->Encountered.insert(*srcIt); + } - // Use reserve to allocate enough memory for tempPathStr - // so that during the loops no memory is allocated or freed - std::string tempPathStr; - tempPathStr.reserve(4*1024); + std::set<cmStdString> scanned; - while(!this->Unscanned.empty()) - { - // Get the next file to scan. - UnscannedEntry current = this->Unscanned.front(); - this->Unscanned.pop(); + // Use reserve to allocate enough memory for tempPathStr + // so that during the loops no memory is allocated or freed + std::string tempPathStr; + tempPathStr.reserve(4*1024); - // If not a full path, find the file in the include path. - std::string fullName; - if(first || cmSystemTools::FileIsFullPath(current.FileName.c_str())) + while(!this->Unscanned.empty()) { - if(cmSystemTools::FileExists(current.FileName.c_str(), true)) + // Get the next file to scan. + UnscannedEntry current = this->Unscanned.front(); + this->Unscanned.pop(); + + // If not a full path, find the file in the include path. + std::string fullName; + if((srcFiles>0) + || cmSystemTools::FileIsFullPath(current.FileName.c_str())) { - fullName = current.FileName; + if(cmSystemTools::FileExists(current.FileName.c_str(), true)) + { + fullName = current.FileName; + } } - } - else if(!current.QuotedLocation.empty() && - cmSystemTools::FileExists(current.QuotedLocation.c_str(), true)) - { - // The include statement producing this entry was a double-quote - // include and the included file is present in the directory of - // the source containing the include statement. - fullName = current.QuotedLocation; - } - else - { - std::map<cmStdString, cmStdString>::iterator - headerLocationIt=this->HeaderLocationCache.find(current.FileName); - if (headerLocationIt!=this->HeaderLocationCache.end()) + else if(!current.QuotedLocation.empty() && + cmSystemTools::FileExists(current.QuotedLocation.c_str(), true)) { - fullName=headerLocationIt->second; + // The include statement producing this entry was a double-quote + // include and the included file is present in the directory of + // the source containing the include statement. + fullName = current.QuotedLocation; } - else for(std::vector<std::string>::const_iterator i = - this->IncludePath.begin(); i != this->IncludePath.end(); ++i) + else { - // Construct the name of the file as if it were in the current - // include directory. Avoid using a leading "./". - - tempPathStr = ""; - if((*i) == ".") + std::map<cmStdString, cmStdString>::iterator + headerLocationIt=this->HeaderLocationCache.find(current.FileName); + if (headerLocationIt!=this->HeaderLocationCache.end()) { - tempPathStr += current.FileName; + fullName=headerLocationIt->second; } - else + else for(std::vector<std::string>::const_iterator i = + this->IncludePath.begin(); i != this->IncludePath.end(); ++i) { - tempPathStr += *i; - tempPathStr+="/"; - tempPathStr+=current.FileName; - } + // Construct the name of the file as if it were in the current + // include directory. Avoid using a leading "./". - // Look for the file in this location. - if(cmSystemTools::FileExists(tempPathStr.c_str(), true)) - { - fullName = tempPathStr; - HeaderLocationCache[current.FileName]=fullName; - break; + tempPathStr = ""; + if((*i) == ".") + { + tempPathStr += current.FileName; + } + else + { + tempPathStr += *i; + tempPathStr+="/"; + tempPathStr+=current.FileName; + } + + // Look for the file in this location. + if(cmSystemTools::FileExists(tempPathStr.c_str(), true)) + { + fullName = tempPathStr; + HeaderLocationCache[current.FileName]=fullName; + break; + } } } - } - - // Complain if the file cannot be found and matches the complain - // regex. - if(fullName.empty() && - this->IncludeRegexComplain.find(current.FileName.c_str())) - { - cmSystemTools::Error("Cannot find file \"", - current.FileName.c_str(), "\"."); - return false; - } - // Scan the file if it was found and has not been scanned already. - if(!fullName.empty() && (scanned.find(fullName) == scanned.end())) - { - // Record scanned files. - scanned.insert(fullName); + // Complain if the file cannot be found and matches the complain + // regex. + if(fullName.empty() && + this->IncludeRegexComplain.find(current.FileName.c_str())) + { + cmSystemTools::Error("Cannot find file \"", + current.FileName.c_str(), "\"."); + return false; + } - // Check whether this file is already in the cache - std::map<cmStdString, cmIncludeLines*>::iterator fileIt= - this->FileCache.find(fullName); - if (fileIt!=this->FileCache.end()) + // Scan the file if it was found and has not been scanned already. + if(!fullName.empty() && (scanned.find(fullName) == scanned.end())) { - fileIt->second->Used=true; - dependencies.insert(fullName); - for (std::vector<UnscannedEntry>::const_iterator incIt= - fileIt->second->UnscannedEntries.begin(); - incIt!=fileIt->second->UnscannedEntries.end(); ++incIt) + // Record scanned files. + scanned.insert(fullName); + + // Check whether this file is already in the cache + std::map<cmStdString, cmIncludeLines*>::iterator fileIt= + this->FileCache.find(fullName); + if (fileIt!=this->FileCache.end()) { - if (this->Encountered.find(incIt->FileName) == - this->Encountered.end()) + fileIt->second->Used=true; + dependencies.insert(fullName); + for (std::vector<UnscannedEntry>::const_iterator incIt= + fileIt->second->UnscannedEntries.begin(); + incIt!=fileIt->second->UnscannedEntries.end(); ++incIt) { - this->Encountered.insert(incIt->FileName); - this->Unscanned.push(*incIt); + if (this->Encountered.find(incIt->FileName) == + this->Encountered.end()) + { + this->Encountered.insert(incIt->FileName); + this->Unscanned.push(*incIt); + } } } - } - else - { - - // Try to scan the file. Just leave it out if we cannot find - // it. - std::ifstream fin(fullName.c_str()); - if(fin) + else { - // Add this file as a dependency. - dependencies.insert(fullName); - // Scan this file for new dependencies. Pass the directory - // containing the file to handle double-quote includes. - std::string dir = cmSystemTools::GetFilenamePath(fullName); - this->Scan(fin, dir.c_str(), fullName); + // Try to scan the file. Just leave it out if we cannot find + // it. + std::ifstream fin(fullName.c_str()); + if(fin) + { + // Add this file as a dependency. + dependencies.insert(fullName); + + // Scan this file for new dependencies. Pass the directory + // containing the file to handle double-quote includes. + std::string dir = cmSystemTools::GetFilenamePath(fullName); + this->Scan(fin, dir.c_str(), fullName); + } } } - } - first = false; + srcFiles--; + } } // Write the dependencies to the output stream. Makefile rules @@ -275,7 +278,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, // convert the dependencies to paths relative to the home output // directory. We must do the same here. internalDepends << obj << std::endl; - for(std::set<cmStdString>::iterator i=dependencies.begin(); + for(std::set<cmStdString>::const_iterator i=dependencies.begin(); i != dependencies.end(); ++i) { makeDepends << obj << ": " << diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index bd9a4b7..16dfad7 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -32,11 +32,9 @@ public: virtual ~cmDependsC(); protected: - typedef std::vector<char> t_CharBuffer; - // Implement writing/checking methods required by superclass. - virtual bool WriteDependencies(const char *src, - const char *file, + virtual bool WriteDependencies(const std::set<std::string>& sources, + const std::string& obj, std::ostream& makeDepends, std::ostream& internalDepends); @@ -82,7 +80,6 @@ protected: const std::map<std::string, DependencyVector>* ValidDeps; std::set<cmStdString> Encountered; std::queue<UnscannedEntry> Unscanned; - t_CharBuffer Buffer; std::map<cmStdString, cmIncludeLines *> FileCache; std::map<cmStdString, cmStdString> HeaderLocationCache; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 3e66058..e41e5ea 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -170,44 +170,50 @@ cmDependsFortran::~cmDependsFortran() } //---------------------------------------------------------------------------- -bool cmDependsFortran::WriteDependencies(const char *src, const char *obj, - std::ostream&, std::ostream&) +bool cmDependsFortran::WriteDependencies( + const std::set<std::string>& sources, const std::string& obj, + std::ostream&, std::ostream&) { // Make sure this is a scanning instance. - if(!src || src[0] == '\0') + if(sources.empty() || sources.begin()->empty()) { - cmSystemTools::Error("Cannot scan dependencies without an source file."); + cmSystemTools::Error("Cannot scan dependencies without a source file."); return false; } - if(!obj || obj[0] == '\0') + if(obj.empty()) { cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } - // Get the information object for this source. - cmDependsFortranSourceInfo& info = - this->Internal->CreateObjectInfo(obj, src); + bool okay = true; + for(std::set<std::string>::const_iterator it = sources.begin(); + it != sources.end(); ++it) + { + const std::string& src = *it; + // Get the information object for this source. + cmDependsFortranSourceInfo& info = + this->Internal->CreateObjectInfo(obj.c_str(), src.c_str()); - // Make a copy of the macros defined via ADD_DEFINITIONS - std::set<std::string> ppDefines(this->PPDefinitions.begin(), - this->PPDefinitions.end()); + // Make a copy of the macros defined via ADD_DEFINITIONS + std::set<std::string> ppDefines(this->PPDefinitions.begin(), + this->PPDefinitions.end()); - // Create the parser object. The constructor takes ppMacro and info per - // reference, so we may look into the resulting objects later. - cmDependsFortranParser parser(this, ppDefines, info); + // Create the parser object. The constructor takes ppMacro and info per + // reference, so we may look into the resulting objects later. + cmDependsFortranParser parser(this, ppDefines, info); - // Push on the starting file. - cmDependsFortranParser_FilePush(&parser, src); + // Push on the starting file. + cmDependsFortranParser_FilePush(&parser, src.c_str()); - // Parse the translation unit. - if(cmDependsFortran_yyparse(parser.Scanner) != 0) - { - // Failed to parse the file. Report failure to write dependencies. - return false; + // Parse the translation unit. + if(cmDependsFortran_yyparse(parser.Scanner) != 0) + { + // Failed to parse the file. Report failure to write dependencies. + okay = false; + } } - - return true; + return okay; } //---------------------------------------------------------------------------- diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index cdfde6e..cb40796 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -66,7 +66,7 @@ protected: // Implement writing/checking methods required by superclass. virtual bool WriteDependencies( - const char *src, const char *file, + const std::set<std::string>& sources, const std::string& file, std::ostream& makeDepends, std::ostream& internalDepends); // Actually write the depenencies to the streams. diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx index ba0e8fb..949d465 100644 --- a/Source/cmDependsJava.cxx +++ b/Source/cmDependsJava.cxx @@ -25,11 +25,11 @@ cmDependsJava::~cmDependsJava() } //---------------------------------------------------------------------------- -bool cmDependsJava::WriteDependencies(const char *src, const char *, - std::ostream&, std::ostream&) +bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources, + const std::string&, std::ostream&, std::ostream&) { // Make sure this is a scanning instance. - if(!src || src[0] == '\0') + if(sources.empty() || sources.begin()->empty()) { cmSystemTools::Error("Cannot scan dependencies without an source file."); return false; diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index bf7e234..22af53f 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -29,7 +29,8 @@ public: protected: // Implement writing/checking methods required by superclass. - virtual bool WriteDependencies(const char *src, const char *file, + virtual bool WriteDependencies( + const std::set<std::string>& sources, const std::string& file, std::ostream& makeDepends, std::ostream& internalDepends); virtual bool CheckDependencies(std::istream& internalDepends, const char* internalDependsFileName, diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 8db0e8f..d4a876d 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -896,6 +896,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) " script, it may get fatal error messages from the script.",false, "Variables That Change Behavior"); + cm->DefineProperty + ("CMAKE_DEBUG_TARGET_PROPERTIES", cmProperty::VARIABLE, + "Enables tracing output for target properties.", + "This variable can be populated with a list of properties to generate " + "debug output for when evaluating target properties. Currently it can " + "only be used when evaluating the INCLUDE_DIRECTORIES target property. " + "In that case, it outputs a backtrace for each include directory in " + "the build. Default is unset.",false,"Variables That Change Behavior"); + // Variables defined by CMake that describe the system cm->DefineProperty @@ -1222,6 +1231,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty + ("CMAKE_LINK_DEPENDS_NO_SHARED", cmProperty::VARIABLE, + "Whether to skip link dependencies on shared library files.", + "This variable initializes the LINK_DEPENDS_NO_SHARED " + "property on targets when they are created. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + + cm->DefineProperty ("CMAKE_AUTOMOC", cmProperty::VARIABLE, "Whether to handle moc automatically for Qt targets.", "This variable is used to initialize the " @@ -1612,7 +1630,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "These paths are implicit linker search directories for the compiler's " "language. " "CMake automatically detects these directories for each language and " - "reports the results in this variable.", false, + "reports the results in this variable." + "\n" + "When a library in one of these directories is given by full path to " + "target_link_libraries() CMake will generate the -l<name> form on " + "link lines to ensure the linker searches its implicit directories " + "for the library. " + "Note that some toolchains read implicit directories from an " + "environment variable such as LIBRARY_PATH so keep its value " + "consistent when operating in a given build tree.",false, "Variables for Languages"); cm->DefineProperty diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index fb3f39f..cd6a7ab 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -22,6 +22,20 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + { + std::string expectedTargets; + std::string sep; + for(std::vector<cmTarget*>::const_iterator + tei = this->Exports->begin(); + tei != this->Exports->end(); ++tei) + { + expectedTargets += sep + this->Namespace + (*tei)->GetName(); + sep = " "; + } + + this->GenerateExpectedTargetsCode(os, expectedTargets); + } + // Create all the imported targets. for(std::vector<cmTarget*>::const_iterator tei = this->Exports->begin(); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8dffae4..3f738cc 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -287,6 +287,37 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os) } //---------------------------------------------------------------------------- +void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, + const std::string &expectedTargets) +{ + os << "SET(_targetsDefined)\n" + "SET(_targetsNotDefined)\n" + "SET(_expectedTargets)\n" + "FOREACH(_expectedTarget " << expectedTargets << ")\n" + " LIST(APPEND _expectedTargets ${_expectedTarget})\n" + " IF(NOT TARGET ${_expectedTarget})\n" + " LIST(APPEND _targetsNotDefined ${_expectedTarget})\n" + " ENDIF(NOT TARGET ${_expectedTarget})\n" + " IF(TARGET ${_expectedTarget})\n" + " LIST(APPEND _targetsDefined ${_expectedTarget})\n" + " ENDIF(TARGET ${_expectedTarget})\n" + "ENDFOREACH(_expectedTarget)\n" + "IF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" + " SET(CMAKE_IMPORT_FILE_VERSION)\n" + " CMAKE_POLICY(POP)\n" + " RETURN()\n" + "ENDIF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" + "IF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" + " MESSAGE(FATAL_ERROR \"Some (but not all) targets in this export " + "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n" + "Targets not yet defined: ${_targetsNotDefined}\\n\")\n" + "ENDIF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" + "UNSET(_targetsDefined)\n" + "UNSET(_targetsNotDefined)\n" + "UNSET(_expectedTargets)\n" + "\n\n"; +} +//---------------------------------------------------------------------------- void cmExportFileGenerator ::GenerateImportTargetCode(std::ostream& os, cmTarget* target) diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 70bc65d..4a75c52 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -63,6 +63,8 @@ protected: void GenerateMissingTargetsCheckCode(std::ostream& os, const std::vector<std::string>& missingTargets); + void GenerateExpectedTargetsCode(std::ostream& os, + const std::string &expectedTargets); // Collect properties with detailed information about targets beyond // their location on disk. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 7841731..6ba7d9f 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -39,6 +39,20 @@ std::string cmExportInstallFileGenerator::GetConfigImportFileGlob() //---------------------------------------------------------------------------- bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) { + { + std::string expectedTargets; + std::string sep; + for(std::vector<cmTargetExport*>::const_iterator + tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); + tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) + { + expectedTargets += sep + this->Namespace + (*tei)->Target->GetName(); + sep = " "; + } + + this->GenerateExpectedTargetsCode(os, expectedTargets); + } + // Create all the imported targets. for(std::vector<cmTargetExport*>::const_iterator tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 96b8a09..97ab086 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -38,6 +38,7 @@ cmExtraEclipseCDT4Generator this->SupportedGlobalGenerators.push_back("Unix Makefiles"); this->SupportsVirtualFolders = true; + this->GenerateLinkedResources = true; } //---------------------------------------------------------------------------- @@ -83,6 +84,9 @@ void cmExtraEclipseCDT4Generator::Generate() this->HomeDirectory = mf->GetHomeDirectory(); this->HomeOutputDirectory = mf->GetHomeOutputDirectory(); + this->GenerateLinkedResources = mf->IsOn( + "CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES"); + this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory); this->GenerateSourceProject = (this->IsOutOfSourceBuild && @@ -501,6 +505,10 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( linkName2 += ti->first; this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", VirtualFolder); + if (!this->GenerateLinkedResources) + { + break; // skip generating the linked resources to the source files + } std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups(); // get the files from the source lists then add them to the groups cmTarget* tgt = const_cast<cmTarget*>(&ti->second); @@ -555,6 +563,11 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( cmGeneratedFileStream& fout, const std::string& baseDir) { + if (!this->GenerateLinkedResources) + { + return; + } + // for each sub project create a linked resource to the source dir // - only if it is an out-of-source build this->AppendLinkedResource(fout, "[Subprojects]", @@ -579,7 +592,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( this->GetEclipsePath(linkSourceDirectory), LinkToFolder ); - this->SrcLinkedResources.push_back(it->first); + // Don't add it to the srcLinkedResources, because listing multiple + // directories confuses the Eclipse indexer (#13596). } } } @@ -730,15 +744,16 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const /* I don't know what the pathentry kind="src" are good for, e.g. autocompletion * works also without them. Done wrong, the indexer complains, see #12417 * and #12213. + * According to #13596, this entry at least limits the directories the + * indexer is searching for files. So now the "src" entry contains only + * the linked resource to CMAKE_SOURCE_DIR. * The CDT documentation is very terse on that: * "CDT_SOURCE: Entry kind constant describing a path entry identifying a * folder containing source code to be compiled." * Also on the cdt-dev list didn't bring any information: * http://web.archiveorange.com/archive/v/B4NlJDNIpYoOS1SbxFNy - * So I'm disabling them for now, hoping that somebody will report if something - * is not workging anymore. * Alex */ -#ifdef DO_CREATE_SRC_PATH_ENTRIES + for (std::vector<std::string>::const_iterator it = this->SrcLinkedResources.begin(); it != this->SrcLinkedResources.end(); @@ -755,7 +770,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const excludeFromOut += this->EscapeForXML(*it) + "/|"; } } -#endif + excludeFromOut += "**/CMakeFiles/"; fout << "<pathentry excluding=\"" << excludeFromOut << "\" kind=\"out\" path=\"\"/>\n"; diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 37ce65e..31ad68d 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -109,6 +109,7 @@ private: std::string HomeOutputDirectory; bool IsOutOfSourceBuild; bool GenerateSourceProject; + bool GenerateLinkedResources; bool SupportsVirtualFolders; }; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 8de24b3..0cdbb82 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -17,11 +17,14 @@ #include "cmFileTimeComparison.h" #include "cmCryptoHash.h" +#include "cmTimestamp.h" + #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cm_curl.h" #endif #undef GetCurrentDirectory +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> @@ -160,6 +163,10 @@ bool cmFileCommand { return this->HandleCMakePathCommand(args, true); } + else if ( subCommand == "TIMESTAMP" ) + { + return this->HandleTimestampCommand(args); + } std::string e = "does not recognize sub-command "+subCommand; this->SetError(e.c_str()); @@ -705,11 +712,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, bool recurse) { - if ( args.size() < 2 ) - { - this->SetError("GLOB requires at least a variable name"); - return false; - } + // File commands has at least one argument + assert(args.size() > 1); std::vector<std::string>::const_iterator i = args.begin(); @@ -843,11 +847,8 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, bool cmFileCommand::HandleMakeDirectoryCommand( std::vector<std::string> const& args) { - if(args.size() < 2 ) - { - this->SetError("called with incorrect number of arguments"); - return false; - } + // File command has at least one argument + assert(args.size() > 1); std::vector<std::string>::const_iterator i = args.begin(); @@ -3246,3 +3247,54 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) return false; #endif } + +//---------------------------------------------------------------------------- +bool cmFileCommand::HandleTimestampCommand( + std::vector<std::string> const& args) +{ + if(args.size() < 3) + { + this->SetError("sub-command TIMESTAMP requires at least two arguments."); + return false; + } + else if(args.size() > 5) + { + this->SetError("sub-command TIMESTAMP takes at most four arguments."); + return false; + } + + unsigned int argsIndex = 1; + + const std::string& filename = args[argsIndex++]; + + const std::string& outputVariable = args[argsIndex++]; + + std::string formatString; + if(args.size() > argsIndex && args[argsIndex] != "UTC") + { + formatString = args[argsIndex++]; + } + + bool utcFlag = false; + if(args.size() > argsIndex) + { + if(args[argsIndex] == "UTC") + { + utcFlag = true; + } + else + { + std::string e = " TIMESTAMP sub-command does not recognize option " + + args[argsIndex] + "."; + this->SetError(e.c_str()); + return false; + } + } + + cmTimestamp timestamp; + std::string result = timestamp.FileModificationTime( + filename.c_str(), formatString, utcFlag); + this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str()); + + return true; +} diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index b4aa903..5973fa7 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -87,9 +87,11 @@ public: " [TLS_VERIFY on|off] [TLS_CAINFO file])\n" " file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n" " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n" + " file(TIMESTAMP filename variable [<format string>] [UTC])\n" "WRITE will write a message into a file called 'filename'. It " "overwrites the file if it already exists, and creates the file " - "if it does not exist.\n" + "if it does not exist. (If the file is a build input, use " + "configure_file to update the file only when its content changes.)\n" "APPEND will write a message into a file same as WRITE, except " "it will append it to the end of the file\n" "READ will read the content of a file and store it into the " @@ -199,6 +201,12 @@ public: "If SHOW_PROGRESS is specified, progress information will be printed " "as status messages until the operation is complete." "\n" + "TIMESTAMP will write a string representation of " + "the modification time of filename to variable.\n" + "Should the command be unable to obtain a timestamp " + "variable will be set to the empty string \"\".\n" + "See documentation of the string TIMESTAMP sub-command for more details." + "\n" "The file() command also provides COPY and INSTALL signatures:\n" " file(<COPY|INSTALL> files... DESTINATION <dir>\n" " [FILE_PERMISSIONS permissions...]\n" @@ -259,6 +267,8 @@ protected: bool HandleInstallCommand(std::vector<std::string> const& args); bool HandleDownloadCommand(std::vector<std::string> const& args); bool HandleUploadCommand(std::vector<std::string> const& args); + + bool HandleTimestampCommand(std::vector<std::string> const& args); }; diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index a54bf7c..7ce0032 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -15,6 +15,8 @@ cmFindBase::cmFindBase() { this->AlreadyInCache = false; this->AlreadyInCacheWithoutMetaInfo = false; + this->NamesPerDir = false; + this->NamesPerDirAllowed = false; } //---------------------------------------------------------------------------- @@ -213,6 +215,19 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) compatibility = false; newStyle = true; } + else if (args[j] == "NAMES_PER_DIR") + { + doing = DoingNone; + if(this->NamesPerDirAllowed) + { + this->NamesPerDir = true; + } + else + { + this->SetError("does not support NAMES_PER_DIR"); + return false; + } + } else if (args[j] == "NO_SYSTEM_PATH") { doing = DoingNone; @@ -345,13 +360,13 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths, { dir += "/"; } - if(subdir == "lib") + if(subdir == "include" || subdir == "lib") { const char* arch = this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); if(arch && *arch) { - this->AddPathInternal(dir+"lib/"+arch, pathType); + this->AddPathInternal(dir+subdir+"/"+arch, pathType); } } std::string add = dir + subdir; diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index eac1885..84b0330 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -49,6 +49,8 @@ protected: cmStdString VariableDocumentation; cmStdString VariableName; std::vector<std::string> Names; + bool NamesPerDir; + bool NamesPerDirAllowed; // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM cmStdString EnvironmentPath; // LIB,INCLUDE diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 0080e55..4af7e11 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -17,6 +17,7 @@ cmFindLibraryCommand::cmFindLibraryCommand() { this->EnvironmentPath = "LIB"; + this->NamesPerDirAllowed = true; } //---------------------------------------------------------------------------- @@ -44,6 +45,9 @@ void cmFindLibraryCommand::GenerateDocumentation() "SEARCH_XXX", "library"); cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "lib"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "NAMES name1 [name2 ...]", + "NAMES name1 [name2 ...] [NAMES_PER_DIR]"); cmSystemTools::ReplaceString( this->GenericDocumentation, "XXX_EXTRA_PREFIX_ENTRY", @@ -53,6 +57,12 @@ void cmFindLibraryCommand::GenerateDocumentation() "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY"); this->GenericDocumentation += "\n" + "When more than one value is given to the NAMES option this command " + "by default will consider one name at a time and search every directory " + "for it. " + "The NAMES_PER_DIR option tells this command to consider one directory " + "at a time and search for all names in it." + "\n" "If the library found is a framework, then VAR will be set to " "the full path to the framework <fullPath>/A.framework. " "When a full path to a framework is used as a library, " @@ -220,18 +230,19 @@ struct cmFindLibraryHelper // Keep track of the best library file found so far. typedef std::vector<std::string>::size_type size_type; std::string BestPath; - size_type BestPrefix; - size_type BestSuffix; // Support for OpenBSD shared library naming: lib<name>.so.<major>.<minor> bool OpenBSD; - unsigned int BestMajor; - unsigned int BestMinor; - // Current name under consideration. - cmsys::RegularExpression NameRegex; - bool TryRawName; - std::string RawName; + // Current names under consideration. + struct Name + { + bool TryRaw; + std::string Raw; + cmsys::RegularExpression Regex; + Name(): TryRaw(false) {} + }; + std::vector<Name> Names; // Current full path under consideration. std::string TestPath; @@ -249,8 +260,9 @@ struct cmFindLibraryHelper suffix) - this->Suffixes.begin(); } bool HasValidSuffix(std::string const& name); - void SetName(std::string const& name); + void AddName(std::string const& name); bool CheckDirectory(std::string const& path); + bool CheckDirectoryForName(std::string const& path, Name& name); }; //---------------------------------------------------------------------------- @@ -273,14 +285,6 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf): this->OpenBSD = this->Makefile->GetCMakeInstance() ->GetPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING"); - - this->TryRawName = false; - - // No library file has yet been found. - this->BestPrefix = this->Prefixes.size(); - this->BestSuffix = this->Suffixes.size(); - this->BestMajor = 0; - this->BestMinor = 0; } //---------------------------------------------------------------------------- @@ -353,11 +357,13 @@ bool cmFindLibraryHelper::HasValidSuffix(std::string const& name) } //---------------------------------------------------------------------------- -void cmFindLibraryHelper::SetName(std::string const& name) +void cmFindLibraryHelper::AddName(std::string const& name) { + Name entry; + // Consider checking the raw name too. - this->TryRawName = this->HasValidSuffix(name); - this->RawName = name; + entry.TryRaw = this->HasValidSuffix(name); + entry.Raw = name; // Build a regular expression to match library names. std::string regex = "^"; @@ -369,21 +375,37 @@ void cmFindLibraryHelper::SetName(std::string const& name) regex += "(\\.[0-9]+\\.[0-9]+)?"; } regex += "$"; - this->NameRegex.compile(regex.c_str()); + entry.Regex.compile(regex.c_str()); + this->Names.push_back(entry); } //---------------------------------------------------------------------------- bool cmFindLibraryHelper::CheckDirectory(std::string const& path) { + for(std::vector<Name>::iterator i = this->Names.begin(); + i != this->Names.end(); ++i) + { + if(this->CheckDirectoryForName(path, *i)) + { + return true; + } + } + return false; +} + +//---------------------------------------------------------------------------- +bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path, + Name& name) +{ // If the original library name provided by the user matches one of // the suffixes, try it first. This allows users to search // specifically for a static library on some platforms (on MS tools // one cannot tell just from the library name whether it is a static // library or an import library). - if(this->TryRawName) + if(name.TryRaw) { this->TestPath = path; - this->TestPath += this->RawName; + this->TestPath += name.Raw; if(cmSystemTools::FileExists(this->TestPath.c_str(), true)) { this->BestPath = @@ -393,6 +415,12 @@ bool cmFindLibraryHelper::CheckDirectory(std::string const& path) } } + // No library file has yet been found. + size_type bestPrefix = this->Prefixes.size(); + size_type bestSuffix = this->Suffixes.size(); + unsigned int bestMajor = 0; + unsigned int bestMinor = 0; + // Search for a file matching the library name regex. std::string dir = path; cmSystemTools::ConvertToUnixSlashes(dir); @@ -406,7 +434,7 @@ bool cmFindLibraryHelper::CheckDirectory(std::string const& path) #else std::string const& testName = origName; #endif - if(this->NameRegex.find(testName)) + if(name.Regex.find(testName)) { this->TestPath = path; this->TestPath += origName; @@ -416,25 +444,25 @@ bool cmFindLibraryHelper::CheckDirectory(std::string const& path) // best name found so far. Earlier prefixes are preferred, // followed by earlier suffixes. For OpenBSD, shared library // version extensions are compared. - size_type prefix = this->GetPrefixIndex(this->NameRegex.match(1)); - size_type suffix = this->GetSuffixIndex(this->NameRegex.match(2)); + size_type prefix = this->GetPrefixIndex(name.Regex.match(1)); + size_type suffix = this->GetSuffixIndex(name.Regex.match(2)); unsigned int major = 0; unsigned int minor = 0; if(this->OpenBSD) { - sscanf(this->NameRegex.match(3).c_str(), ".%u.%u", &major, &minor); + sscanf(name.Regex.match(3).c_str(), ".%u.%u", &major, &minor); } - if(this->BestPath.empty() || prefix < this->BestPrefix || - (prefix == this->BestPrefix && suffix < this->BestSuffix) || - (prefix == this->BestPrefix && suffix == this->BestSuffix && - (major > this->BestMajor || - (major == this->BestMajor && minor > this->BestMinor)))) + if(this->BestPath.empty() || prefix < bestPrefix || + (prefix == bestPrefix && suffix < bestSuffix) || + (prefix == bestPrefix && suffix == bestSuffix && + (major > bestMajor || + (major == bestMajor && minor > bestMinor)))) { this->BestPath = this->TestPath; - this->BestPrefix = prefix; - this->BestSuffix = suffix; - this->BestMajor = major; - this->BestMinor = minor; + bestPrefix = prefix; + bestSuffix = suffix; + bestMajor = major; + bestMinor = minor; } } } @@ -447,6 +475,42 @@ bool cmFindLibraryHelper::CheckDirectory(std::string const& path) //---------------------------------------------------------------------------- std::string cmFindLibraryCommand::FindNormalLibrary() { + if(this->NamesPerDir) + { + return this->FindNormalLibraryNamesPerDir(); + } + else + { + return this->FindNormalLibraryDirsPerName(); + } +} + +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindNormalLibraryNamesPerDir() +{ + // Search for all names in each directory. + cmFindLibraryHelper helper(this->Makefile); + for(std::vector<std::string>::const_iterator ni = this->Names.begin(); + ni != this->Names.end() ; ++ni) + { + helper.AddName(*ni); + } + // Search every directory. + for(std::vector<std::string>::const_iterator + p = this->SearchPaths.begin(); p != this->SearchPaths.end(); ++p) + { + if(helper.CheckDirectory(*p)) + { + return helper.BestPath; + } + } + // Couldn't find the library. + return ""; +} + +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindNormalLibraryDirsPerName() +{ // Search the entire path for each name. cmFindLibraryHelper helper(this->Makefile); for(std::vector<std::string>::const_iterator ni = this->Names.begin(); @@ -454,7 +518,7 @@ std::string cmFindLibraryCommand::FindNormalLibrary() { // Switch to searching for this name. std::string const& name = *ni; - helper.SetName(name); + helper.AddName(name); // Search every directory. for(std::vector<std::string>::const_iterator @@ -474,19 +538,60 @@ std::string cmFindLibraryCommand::FindNormalLibrary() //---------------------------------------------------------------------------- std::string cmFindLibraryCommand::FindFrameworkLibrary() { - // Search for a framework of each name in the entire search path. + if(this->NamesPerDir) + { + return this->FindFrameworkLibraryNamesPerDir(); + } + else + { + return this->FindFrameworkLibraryDirsPerName(); + } +} + +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir() +{ + std::string fwPath; + // Search for all names in each search path. + for(std::vector<std::string>::const_iterator di = this->SearchPaths.begin(); + di != this->SearchPaths.end(); ++di) + { + for(std::vector<std::string>::const_iterator ni = this->Names.begin(); + ni != this->Names.end() ; ++ni) + { + fwPath = *di; + fwPath += *ni; + fwPath += ".framework"; + if(cmSystemTools::FileIsDirectory(fwPath.c_str())) + { + return cmSystemTools::CollapseFullPath(fwPath.c_str()); + } + } + } + + // No framework found. + return ""; +} + +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName() +{ + std::string fwPath; + // Search for each name in all search paths. for(std::vector<std::string>::const_iterator ni = this->Names.begin(); ni != this->Names.end() ; ++ni) { - // Search the paths for a framework with this name. - std::string fwName = *ni; - fwName += ".framework"; - std::string fwPath = cmSystemTools::FindDirectory(fwName.c_str(), - this->SearchPaths, - true); - if(!fwPath.empty()) + for(std::vector<std::string>::const_iterator + di = this->SearchPaths.begin(); + di != this->SearchPaths.end(); ++di) { - return fwPath; + fwPath = *di; + fwPath += *ni; + fwPath += ".framework"; + if(cmSystemTools::FileIsDirectory(fwPath.c_str())) + { + return cmSystemTools::CollapseFullPath(fwPath.c_str()); + } } } diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index 455348a..cd0fce8 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -70,7 +70,11 @@ protected: virtual void GenerateDocumentation(); private: std::string FindNormalLibrary(); + std::string FindNormalLibraryNamesPerDir(); + std::string FindNormalLibraryDirsPerName(); std::string FindFrameworkLibrary(); + std::string FindFrameworkLibraryNamesPerDir(); + std::string FindFrameworkLibraryDirsPerName(); }; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 9524924..6a43298 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -45,8 +45,10 @@ void cmFindPathCommand::GenerateDocumentation() "SEARCH_XXX", "file in a directory"); cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "include"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_EXTRA_PREFIX_ENTRY", ""); + cmSystemTools::ReplaceString( + this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", + " <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and\n"); cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"); diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index 730a7a7..0a029dc 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -90,7 +90,9 @@ public: "will have the actual values of the arguments passed in. This " "facilitates creating functions with optional arguments. Additionally " "ARGV holds the list of all arguments given to the function and ARGN " - "holds the list of argument past the last expected argument." + "holds the list of arguments past the last expected argument." + "\n" + "A function opens a new scope: see set(var PARENT_SCOPE) for details." "\n" "See the cmake_policy() command documentation for the behavior of " "policies inside functions." diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 7d8df37..3fd4a5f 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -25,55 +25,40 @@ //---------------------------------------------------------------------------- cmGeneratorExpression::cmGeneratorExpression( cmListFileBacktrace const& backtrace): - Backtrace(backtrace), CompiledExpression(0) + Backtrace(backtrace) { } //---------------------------------------------------------------------------- -const cmCompiledGeneratorExpression & +cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(std::string const& input) { return this->Parse(input.c_str()); } //---------------------------------------------------------------------------- -const cmCompiledGeneratorExpression & +cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(const char* input) { - cmGeneratorExpressionLexer l; - std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(input); - bool needsParsing = l.GetSawGeneratorExpression(); - std::vector<cmGeneratorExpressionEvaluator*> evaluators; - - if (needsParsing) - { - cmGeneratorExpressionParser p(tokens); - p.Parse(evaluators); - } - - delete this->CompiledExpression; - this->CompiledExpression = new cmCompiledGeneratorExpression( - this->Backtrace, - evaluators, - input, - needsParsing); - return *this->CompiledExpression; + return cmsys::auto_ptr<cmCompiledGeneratorExpression>( + new cmCompiledGeneratorExpression( + this->Backtrace, + input)); } cmGeneratorExpression::~cmGeneratorExpression() { - delete this->CompiledExpression; } //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( cmMakefile* mf, const char* config, bool quiet, - cmGeneratorTarget *target, + cmTarget *target, cmGeneratorExpressionDAGChecker *dagChecker) const { if (!this->NeedsParsing) { - return this->Input; + return this->Input.c_str(); } this->Output = ""; @@ -108,12 +93,19 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, - const std::vector<cmGeneratorExpressionEvaluator*> &evaluators, - const char *input, bool needsParsing) - : Backtrace(backtrace), Evaluators(evaluators), Input(input), - NeedsParsing(needsParsing) + const char *input) + : Backtrace(backtrace), Input(input ? input : "") { + cmGeneratorExpressionLexer l; + std::vector<cmGeneratorExpressionToken> tokens = + l.Tokenize(this->Input.c_str()); + this->NeedsParsing = l.GetSawGeneratorExpression(); + if (this->NeedsParsing) + { + cmGeneratorExpressionParser p(tokens); + p.Parse(this->Evaluators); + } } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 29d3f44..15e637c 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -14,13 +14,14 @@ #define cmGeneratorExpression_h #include "cmStandardIncludes.h" +#include "cmListFileCache.h" #include <stack> #include <cmsys/RegularExpression.hxx> +#include <cmsys/auto_ptr.hxx> class cmTarget; -class cmGeneratorTarget; class cmMakefile; class cmListFileBacktrace; @@ -45,8 +46,9 @@ public: cmGeneratorExpression(cmListFileBacktrace const& backtrace); ~cmGeneratorExpression(); - const cmCompiledGeneratorExpression& Parse(std::string const& input); - const cmCompiledGeneratorExpression& Parse(const char* input); + cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse( + std::string const& input); + cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(const char* input); enum PreprocessContext { StripAllGeneratorExpressions @@ -60,7 +62,6 @@ private: void operator=(const cmGeneratorExpression &); cmListFileBacktrace const& Backtrace; - cmCompiledGeneratorExpression *CompiledExpression; }; class cmCompiledGeneratorExpression @@ -68,7 +69,7 @@ class cmCompiledGeneratorExpression public: const char* Evaluate(cmMakefile* mf, const char* config, bool quiet = false, - cmGeneratorTarget *target = 0, + cmTarget *target = 0, cmGeneratorExpressionDAGChecker *dagChecker = 0) const; /** Get set of targets found during evaluations. */ @@ -77,20 +78,29 @@ public: ~cmCompiledGeneratorExpression(); + std::string GetInput() const + { + return this->Input; + } + + cmListFileBacktrace GetBacktrace() const + { + return this->Backtrace; + } + private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, - const std::vector<cmGeneratorExpressionEvaluator*> &evaluators, - const char *input, bool needsParsing); + const char *input); friend class cmGeneratorExpression; cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &); void operator=(const cmCompiledGeneratorExpression &); - cmListFileBacktrace const& Backtrace; - const std::vector<cmGeneratorExpressionEvaluator*> Evaluators; - const char* const Input; - const bool NeedsParsing; + cmListFileBacktrace Backtrace; + std::vector<cmGeneratorExpressionEvaluator*> Evaluators; + const std::string Input; + bool NeedsParsing; mutable std::set<cmTarget*> Targets; mutable std::string Output; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 2e123a4..3b7cfc0 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -66,6 +66,8 @@ static const struct ZeroNode : public cmGeneratorExpressionNode virtual bool GeneratesContent() const { return false; } + virtual bool AcceptsSingleArbitraryContentParameter() const { return true; } + std::string Evaluate(const std::vector<std::string> &, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, @@ -287,7 +289,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmsys::RegularExpression propertyNameValidator; propertyNameValidator.compile("^[A-Za-z0-9_]+$"); - cmGeneratorTarget* target = context->Target; + cmTarget* target = context->Target; std::string propertyName = *parameters.begin(); if (parameters.size() == 2) { @@ -320,7 +322,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "Target name not supported."); return std::string(); } - target = context->Makefile->FindGeneratorTargetToUse( + target = context->Makefile->FindTargetToUse( targetName.c_str()); if (!target) @@ -551,13 +553,13 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) { if (identifier == "0") return &zeroNode; - if (identifier == "1") + else if (identifier == "1") return &oneNode; - if (identifier == "AND") + else if (identifier == "AND") return &andNode; - if (identifier == "OR") + else if (identifier == "OR") return &orNode; - if (identifier == "NOT") + else if (identifier == "NOT") return ¬Node; else if (identifier == "CONFIGURATION") return &configurationNode; @@ -642,6 +644,20 @@ std::string GeneratorExpressionContent::Evaluate( if (!node->GeneratesContent()) { + if (node->AcceptsSingleArbitraryContentParameter()) + { + if (this->ParamChildren.empty()) + { + reportError(context, this->GetOriginalExpression(), + "$<" + identifier + "> expression requires a parameter."); + } + } + else + { + std::vector<std::string> parameters; + this->EvaluateParameters(node, identifier, context, dagChecker, + parameters); + } return std::string(); } @@ -677,6 +693,23 @@ std::string GeneratorExpressionContent::Evaluate( } std::vector<std::string> parameters; + this->EvaluateParameters(node, identifier, context, dagChecker, parameters); + if (context->HadError) + { + return std::string(); + } + + return node->Evaluate(parameters, context, this, dagChecker); +} + +//---------------------------------------------------------------------------- +std::string GeneratorExpressionContent::EvaluateParameters( + const cmGeneratorExpressionNode *node, + const std::string &identifier, + cmGeneratorExpressionContext *context, + cmGeneratorExpressionDAGChecker *dagChecker, + std::vector<std::string> ¶meters) const +{ { std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator pit = this->ParamChildren.begin(); @@ -732,10 +765,8 @@ std::string GeneratorExpressionContent::Evaluate( { reportError(context, this->GetOriginalExpression(), "$<" + identifier + "> expression requires at least one parameter."); - return std::string(); } - - return node->Evaluate(parameters, context, this, dagChecker); + return std::string(); } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 04a2acd..d904b02 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -18,7 +18,6 @@ #include "cmListFileCache.h" class cmTarget; -class cmGeneratorTarget; //---------------------------------------------------------------------------- struct cmGeneratorExpressionContext @@ -27,12 +26,13 @@ struct cmGeneratorExpressionContext std::set<cmTarget*> Targets; cmMakefile *Makefile; const char *Config; - cmGeneratorTarget *Target; + cmTarget *Target; bool Quiet; bool HadError; }; struct cmGeneratorExpressionDAGChecker; +struct cmGeneratorExpressionNode; //---------------------------------------------------------------------------- struct cmGeneratorExpressionEvaluator @@ -118,6 +118,13 @@ struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator ~GeneratorExpressionContent(); private: + std::string EvaluateParameters(const cmGeneratorExpressionNode *node, + const std::string &identifier, + cmGeneratorExpressionContext *context, + cmGeneratorExpressionDAGChecker *dagChecker, + std::vector<std::string> ¶meters) const; + +private: std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren; std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren; const char *StartContent; diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 7a8fc51..a619cec 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -88,7 +88,15 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression && this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator) { - this->ParseContent(identifier); + if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) + { + extendText(identifier, this->it); + ++this->it; + } + else + { + this->ParseContent(identifier); + } if (this->it == this->Tokens.end()) { break; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 19b55c6..62ee26a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -14,14 +14,11 @@ #include "cmTarget.h" #include "cmMakefile.h" #include "cmLocalGenerator.h" -#include "cmComputeLinkInformation.h" #include "cmGlobalGenerator.h" #include "cmSourceFile.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" -#include <assert.h> - //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) { @@ -32,15 +29,6 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) this->LookupObjectLibraries(); } -cmGeneratorTarget::~cmGeneratorTarget() -{ - for(std::map<cmStdString, cmComputeLinkInformation*>::iterator i - = LinkInformation.begin(); i != LinkInformation.end(); ++i) - { - delete i->second; - } -} - //---------------------------------------------------------------------------- int cmGeneratorTarget::GetType() const { @@ -221,32 +209,6 @@ void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmGeneratorTarget::GetLinkInformation(const char* config) -{ - // Lookup any existing information for this configuration. - std::map<cmStdString, cmComputeLinkInformation*>::iterator - i = this->LinkInformation.find(config?config:""); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - std::map<cmStdString, cmComputeLinkInformation*>::value_type - entry(config?config:"", info); - i = this->LinkInformation.insert(entry).first; - } - return i->second; -} - -//---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const char* config, std::vector<std::string>& archVec) { @@ -290,45 +252,7 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( const char *config) { - std::vector<std::string> includes; - const char *prop = this->Target->GetProperty("INCLUDE_DIRECTORIES"); - if(!prop) - { - return includes; - } - - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "INCLUDE_DIRECTORIES", 0, 0); - - cmSystemTools::ExpandListArgument(ge.Parse(prop) - .Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - includes); - - std::set<std::string> uniqueIncludes; - std::vector<std::string> orderedAndUniqueIncludes; - for(std::vector<std::string>::const_iterator - li = includes.begin(); li != includes.end(); ++li) - { - std::string inc = *li; - if (!cmSystemTools::IsOff(inc.c_str())) - { - cmSystemTools::ConvertToUnixSlashes(inc); - } - if(uniqueIncludes.insert(inc).second) - { - orderedAndUniqueIncludes.push_back(inc); - } - } - - return orderedAndUniqueIncludes; + return this->Target->GetIncludeDirectories(config); } //---------------------------------------------------------------------------- @@ -353,9 +277,9 @@ std::string cmGeneratorTarget::GetCompileDefinitions(const char *config) cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), defPropName, 0, 0); - return ge.Parse(prop).Evaluate(this->Makefile, + return ge.Parse(prop)->Evaluate(this->Makefile, config, false, - this, + this->Target, &dagChecker); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a29a9f9..6f5ecb7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -14,7 +14,6 @@ #include "cmStandardIncludes.h" -class cmComputeLinkInformation; class cmCustomCommand; class cmGlobalGenerator; class cmLocalGenerator; @@ -26,7 +25,6 @@ class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*); - ~cmGeneratorTarget(); int GetType() const; const char *GetName() const; @@ -60,10 +58,6 @@ public: void UseObjectLibraries(std::vector<std::string>& objs); - std::map<cmStdString, cmComputeLinkInformation*> LinkInformation; - - cmComputeLinkInformation* GetLinkInformation(const char* config); - void GetAppleArchs(const char* config, std::vector<std::string>& archVec); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 8c6787a..2a7d61d 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -55,9 +55,9 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalBorlandMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalBorlandMakefileGenerator::GetActualName(); entry.Brief = "Generates Borland makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index c0cb8a6..bd3db3e 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalBorlandMakefileGenerator : public cmGlobalNMakeMakefileGenerator { public: cmGlobalBorlandMakefileGenerator(); - static cmGlobalGenerator* New() - { return new cmGlobalBorlandMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalBorlandMakefileGenerator>(); } ///! Get the name for the generator. virtual const char* GetName() const { @@ -32,7 +33,7 @@ public: static const char* GetActualName() {return "Borland Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6c95ea8..0f439e9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1556,14 +1556,6 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } } -//---------------------------------------------------------------------------- -void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = ""; - entry.Full = ""; -} - bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) { @@ -2055,7 +2047,7 @@ bool cmGlobalGenerator::UseFolderProperty() } // By default, this feature is OFF, since it is not supported in the - // Visual Studio Express editions: + // Visual Studio Express editions until VS11: // return false; } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 0aab2d6..bb805d9 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -49,9 +49,6 @@ public: ///! Get the name for this generator virtual const char *GetName() const { return "Generic"; }; - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - /** * Create LocalGenerators and process the CMakeLists files. This does not * actually produce any makefiles, DSPs, etc. diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h new file mode 100644 index 0000000..fd1d65f --- /dev/null +++ b/Source/cmGlobalGeneratorFactory.h @@ -0,0 +1,59 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 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 cmGlobalGeneratorFactory_h +#define cmGlobalGeneratorFactory_h + +#include "cmStandardIncludes.h" + +class cmGlobalGenerator; +struct cmDocumentationEntry; + +/** \class cmGlobalGeneratorFactory + * \brief Responable for creating cmGlobalGenerator instances + * + * Subclasses of this class generate instances of cmGlobalGenerator. + */ +class cmGlobalGeneratorFactory +{ +public: + virtual ~cmGlobalGeneratorFactory() {} + + /** Create a GlobalGenerator */ + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0; + + /** Get the documentation entry for this factory */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0; + + /** Get the names of the current registered generators */ + virtual void GetGenerators(std::vector<std::string>& names) const = 0; +}; + +template<class T> +class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory +{ +public: + /** Create a GlobalGenerator */ + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if (strcmp(name, T::GetActualName())) return 0; + return new T; } + + /** Get the documentation entry for this factory */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + T::GetDocumentation(entry); } + + /** Get the names of the current registered generators */ + virtual void GetGenerators(std::vector<std::string>& names) const { + names.push_back(T::GetActualName()); } +}; + +#endif diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index ef42bd4..4af0607 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -61,9 +61,9 @@ cmLocalGenerator *cmGlobalJOMMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalJOMMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Brief = "Generates JOM makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 691ebdb..28893bf 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalJOMMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalJOMMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalJOMMakefileGenerator>(); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalJOMMakefileGenerator::GetActualName();} @@ -33,7 +34,7 @@ public: static const char* GetActualName() {return "NMake Makefiles JOM";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 80526aa..d49639b 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -106,9 +106,9 @@ cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalMSYSMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalMSYSMakefileGenerator::GetActualName(); entry.Brief = "Generates MSYS makefiles."; entry.Full = "The makefiles use /bin/sh as the shell. " "They require msys to be installed on the machine."; diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index b76a5bf..659de11 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -23,8 +23,9 @@ class cmGlobalMSYSMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalMSYSMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalMSYSMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalMSYSMakefileGenerator>(); } ///! Get the name for the generator. virtual const char* GetName() const { @@ -32,7 +33,7 @@ public: static const char* GetActualName() {return "MSYS Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index d6045c8..e202b02 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -71,9 +71,9 @@ cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalMinGWMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalMinGWMakefileGenerator::GetActualName(); entry.Brief = "Generates a make file for use with mingw32-make."; entry.Full = "The makefiles generated use cmd.exe as the shell. " "They do not require msys or a unix shell."; diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 9a6a513..7951e98 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -23,15 +23,16 @@ class cmGlobalMinGWMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalMinGWMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalMinGWMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalMinGWMakefileGenerator>(); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalMinGWMakefileGenerator::GetActualName();} static const char* GetActualName() {return "MinGW Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 57a26c8..7af4ee3 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -61,9 +61,9 @@ cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalNMakeMakefileGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Brief = "Generates NMake makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index de33b8f..5756fbd 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -23,15 +23,16 @@ class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalNMakeMakefileGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalNMakeMakefileGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalNMakeMakefileGenerator>(); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalNMakeMakefileGenerator::GetActualName();} static const char* GetActualName() {return "NMake Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 05f5b4c..60f5a47 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -452,9 +452,9 @@ cmLocalGenerator* cmGlobalNinjaGenerator::CreateLocalGenerator() } void cmGlobalNinjaGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalNinjaGenerator::GetActualName(); entry.Brief = "Generates build.ninja files (experimental)."; entry.Full = "A build.ninja file is generated into the build tree. Recent " diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 24c3916..c3df7d9 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -14,6 +14,7 @@ # define cmGlobalNinjaGenerator_h # include "cmGlobalGenerator.h" +# include "cmGlobalGeneratorFactory.h" # include "cmNinjaTypes.h" //#define NINJA_GEN_VERBOSE_FILES @@ -160,8 +161,8 @@ public: cmGlobalNinjaGenerator(); /// Convenience method for creating an instance of this class. - static cmGlobalGenerator* New() { - return new cmGlobalNinjaGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>(); } /// Destructor. virtual ~cmGlobalNinjaGenerator() { } @@ -177,7 +178,7 @@ public: static const char* GetActualName() { return "Ninja"; } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); /// Overloaded methods. @see cmGlobalGenerator::Generate() virtual void Generate(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ebd8219..e26cca9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -61,9 +61,9 @@ cmLocalGenerator *cmGlobalUnixMakefileGenerator3::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalUnixMakefileGenerator3::GetActualName(); entry.Brief = "Generates standard UNIX makefiles."; entry.Full = "A hierarchy of UNIX makefiles is generated into the build tree. Any " diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index e6dd09d..385cdc4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -13,6 +13,7 @@ #define cmGlobalUnixMakefileGenerator3_h #include "cmGlobalGenerator.h" +#include "cmGlobalGeneratorFactory.h" class cmGeneratedFileStream; class cmMakefileTargetGenerator; @@ -54,8 +55,9 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator { public: cmGlobalUnixMakefileGenerator3(); - static cmGlobalGenerator* New() { - return new cmGlobalUnixMakefileGenerator3; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalUnixMakefileGenerator3>(); } ///! Get the name for the generator. virtual const char* GetName() const { @@ -63,7 +65,7 @@ public: static const char* GetActualName() {return "Unix Makefiles";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator3 virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 480c577..d992036 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -16,8 +16,61 @@ #include "cmSourceFile.h" #include "cmake.h" +static const char vs10Win32generatorName[] = "Visual Studio 10"; +static const char vs10Win64generatorName[] = "Visual Studio 10 Win64"; +static const char vs10IA64generatorName[] = "Visual Studio 10 IA64"; -cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator() +class cmGlobalVisualStudio10Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(!strcmp(name, vs10Win32generatorName)) + { + return new cmGlobalVisualStudio10Generator( + vs10Win32generatorName, NULL, NULL); + } + if(!strcmp(name, vs10Win64generatorName)) + { + return new cmGlobalVisualStudio10Generator( + vs10Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + } + if(!strcmp(name, vs10IA64generatorName)) + { + return new cmGlobalVisualStudio10Generator( + vs10IA64generatorName, "Itanium", "CMAKE_FORCE_IA64"); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = "Visual Studio 10"; + entry.Brief = "Generates Visual Studio 10 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 10 Win64\" will create project files for " + "the x64 processor; \"Visual Studio 10 IA64\" for Itanium."; + } + + virtual void GetGenerators(std::vector<std::string>& names) const { + names.push_back(vs10Win32generatorName); + names.push_back(vs10Win64generatorName); + names.push_back(vs10IA64generatorName); } +}; + +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) + : cmGlobalVisualStudio8Generator(name, architectureId, + additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; std::string vc10Express; @@ -88,18 +141,16 @@ void cmGlobalVisualStudio10Generator::Generate() //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 10 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) { + if(this->ArchitectureId == "Itanium" || this->ArchitectureId == "x64") + { + if(this->IsExpressEdition() && !this->Find64BitTools(mf)) + { + return; + } + } cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 47ce790..b377a20 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -24,9 +24,9 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio10Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10Generator; } + cmGlobalVisualStudio10Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); virtual std::string GenerateBuildCommand(const char* makeProgram, @@ -34,15 +34,8 @@ public: const char* additionalOptions, const char *targetName, const char* config, bool ignoreErrors, bool); - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio10Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 10";} virtual void AddPlatformDefinitions(cmMakefile* mf); - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -92,6 +85,7 @@ protected: bool UseFolderProperty(); private: + class Factory; struct LongestSourcePath { LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} diff --git a/Source/cmGlobalVisualStudio10IA64Generator.cxx b/Source/cmGlobalVisualStudio10IA64Generator.cxx deleted file mode 100644 index 25dd88f..0000000 --- a/Source/cmGlobalVisualStudio10IA64Generator.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio10IA64Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10IA64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 10 Itanium project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10IA64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10IA64Generator -::EnableLanguage(std::vector<std::string> const& languages, - cmMakefile* mf, bool optional) -{ - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - this->cmGlobalVisualStudio10Generator - ::EnableLanguage(languages, mf, optional); -} diff --git a/Source/cmGlobalVisualStudio10IA64Generator.h b/Source/cmGlobalVisualStudio10IA64Generator.h deleted file mode 100644 index a088272..0000000 --- a/Source/cmGlobalVisualStudio10IA64Generator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio10IA64Generator_h -#define cmGlobalVisualStudio10IA64Generator_h - -#include "cmGlobalVisualStudio10Generator.h" - -class cmGlobalVisualStudio10IA64Generator : - public cmGlobalVisualStudio10Generator -{ -public: - cmGlobalVisualStudio10IA64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10IA64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio10IA64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 10 IA64";} - - virtual const char* GetPlatformName() const {return "Itanium";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); - - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); -}; -#endif diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx deleted file mode 100644 index d0a0c49..0000000 --- a/Source/cmGlobalVisualStudio10Win64Generator.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio10Win64Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 10 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio10Win64Generator -::EnableLanguage(std::vector<std::string> const& languages, - cmMakefile* mf, bool optional) -{ - if(this->IsExpressEdition() && !this->Find64BitTools(mf)) - { - return; - } - this->cmGlobalVisualStudio10Generator - ::EnableLanguage(languages, mf, optional); -} diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h deleted file mode 100644 index 8a2de4c..0000000 --- a/Source/cmGlobalVisualStudio10Win64Generator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio10Win64Generator_h -#define cmGlobalVisualStudio10Win64Generator_h - -#include "cmGlobalVisualStudio10Generator.h" - -class cmGlobalVisualStudio10Win64Generator : - public cmGlobalVisualStudio10Generator -{ -public: - cmGlobalVisualStudio10Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio10Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio10Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 10 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); - - virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *, bool optional); -}; -#endif diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.cxx b/Source/cmGlobalVisualStudio11ARMGenerator.cxx deleted file mode 100644 index efd71c6..0000000 --- a/Source/cmGlobalVisualStudio11ARMGenerator.cxx +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================ - 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. -============================================================================*/ -#include "cmGlobalVisualStudio11ARMGenerator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio11ARMGenerator::cmGlobalVisualStudio11ARMGenerator() -{ - this->ArchitectureId = "ARM"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11ARMGenerator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 ARM project files."; - entry.Full = ""; -} diff --git a/Source/cmGlobalVisualStudio11ARMGenerator.h b/Source/cmGlobalVisualStudio11ARMGenerator.h deleted file mode 100644 index 71dbf2e..0000000 --- a/Source/cmGlobalVisualStudio11ARMGenerator.h +++ /dev/null @@ -1,35 +0,0 @@ -/*============================================================================ - 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 cmGlobalVisualStudio11ARMGenerator_h -#define cmGlobalVisualStudio11ARMGenerator_h - -#include "cmGlobalVisualStudio11Generator.h" - -class cmGlobalVisualStudio11ARMGenerator : - public cmGlobalVisualStudio11Generator -{ -public: - cmGlobalVisualStudio11ARMGenerator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11ARMGenerator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio11ARMGenerator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 11 ARM";} - - virtual const char* GetPlatformName() const {return "ARM";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; -}; -#endif diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 23a1204..b6d7d04 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -13,8 +13,61 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" +static const char vs11Win32generatorName[] = "Visual Studio 11"; +static const char vs11Win64generatorName[] = "Visual Studio 11 Win64"; +static const char vs11ARMgeneratorName[] = "Visual Studio 11 ARM"; + +class cmGlobalVisualStudio11Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(!strcmp(name, vs11Win32generatorName)) + { + return new cmGlobalVisualStudio11Generator( + vs11Win32generatorName, NULL, NULL); + } + if(!strcmp(name, vs11Win64generatorName)) + { + return new cmGlobalVisualStudio11Generator( + vs11Win64generatorName, "x64", "CMAKE_FORCE_WIN64"); + } + if(!strcmp(name, vs11ARMgeneratorName)) + { + return new cmGlobalVisualStudio11Generator( + vs11ARMgeneratorName, "ARM", NULL); + } + return 0; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = "Visual Studio 11"; + entry.Brief = "Generates Visual Studio 11 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 11 Win64\" will create project files for " + "the x64 processor; \"Visual Studio 11 ARM\" for ARM."; + } + + virtual void GetGenerators(std::vector<std::string>& names) const { + names.push_back(vs11Win32generatorName); + names.push_back(vs11Win64generatorName); + names.push_back(vs11ARMgeneratorName); } +}; + +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() +{ + return new Factory; +} + //---------------------------------------------------------------------------- -cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() +cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) + : cmGlobalVisualStudio10Generator(name, architectureId, + additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; std::string vc11Express; @@ -42,10 +95,10 @@ cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio11Generator -::GetDocumentation(cmDocumentationEntry& entry) const +bool cmGlobalVisualStudio11Generator::UseFolderProperty() { - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 project files."; - entry.Full = ""; + // Intentionally skip over the parent class implementation and call the + // grand-parent class's implementation. Folders are not supported by the + // Express editions in VS10 and earlier, but they are in VS11 Express. + return cmGlobalVisualStudio8Generator::UseFolderProperty(); } diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 56337a4..174f1cc 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -20,20 +20,12 @@ class cmGlobalVisualStudio11Generator: public cmGlobalVisualStudio10Generator { public: - cmGlobalVisualStudio11Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio11Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 11";} + cmGlobalVisualStudio11Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); virtual void WriteSLNHeader(std::ostream& fout); - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -41,5 +33,8 @@ public: virtual std::string GetUserMacrosDirectory() { return ""; } protected: virtual const char* GetIDEVersion() { return "11.0"; } + bool UseFolderProperty(); +private: + class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio11Win64Generator.cxx b/Source/cmGlobalVisualStudio11Win64Generator.cxx deleted file mode 100644 index 94e07bf..0000000 --- a/Source/cmGlobalVisualStudio11Win64Generator.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - 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. -============================================================================*/ -#include "cmGlobalVisualStudio11Win64Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - -//---------------------------------------------------------------------------- -cmGlobalVisualStudio11Win64Generator::cmGlobalVisualStudio11Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 11 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio11Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio11Win64Generator.h b/Source/cmGlobalVisualStudio11Win64Generator.h deleted file mode 100644 index 9445d15..0000000 --- a/Source/cmGlobalVisualStudio11Win64Generator.h +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - 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 cmGlobalVisualStudio11Win64Generator_h -#define cmGlobalVisualStudio11Win64Generator_h - -#include "cmGlobalVisualStudio11Generator.h" - -class cmGlobalVisualStudio11Win64Generator : - public cmGlobalVisualStudio11Generator -{ -public: - cmGlobalVisualStudio11Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio11Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio11Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 11 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - virtual void AddPlatformDefinitions(cmMakefile* mf); -}; -#endif diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index e8ca788..cb15c30 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -200,7 +200,6 @@ void cmGlobalVisualStudio6Generator tt != orderedProjectTargets.end(); ++tt) { cmTarget* target = *tt; - cmMakefile* mf = target->GetMakefile(); // Write the project into the DSW file const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) @@ -398,9 +397,9 @@ cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudio6Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio6Generator::GetActualName(); entry.Brief = "Generates Visual Studio 6 project files."; entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 259aa8d..40149e9 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -13,6 +13,7 @@ #define cmGlobalVisualStudio6Generator_h #include "cmGlobalVisualStudioGenerator.h" +#include "cmGlobalGeneratorFactory.h" class cmTarget; @@ -25,8 +26,9 @@ class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio6Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio6Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalVisualStudio6Generator>(); } ///! Get the name for the generator. virtual const char* GetName() const { @@ -34,7 +36,7 @@ public: static const char* GetActualName() {return "Visual Studio 6";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index ab2308f..2494f55 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -128,6 +128,9 @@ void cmGlobalVisualStudio71Generator fout << "\tEndGlobalSection\n"; } + // Write out global sections + this->WriteSLNGlobalSections(fout, root); + // Write the footer for the SLN file this->WriteSLNFooter(fout); } @@ -273,9 +276,10 @@ void cmGlobalVisualStudio71Generator // Write a dsp file into the SLN file, Note, that dependencies from // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator -::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild, - const char* platformMapping) +::WriteProjectConfigurations( + std::ostream& fout, const char* name, cmTarget::TargetType, + const std::set<std::string>& configsPartOfDefaultBuild, + const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); @@ -284,7 +288,9 @@ void cmGlobalVisualStudio71Generator fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|" << (platformMapping ? platformMapping : "Win32") << std::endl; - if(partOfDefaultBuild) + std::set<std::string>::const_iterator + ci = configsPartOfDefaultBuild.find(*i); + if(!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|" @@ -294,17 +300,6 @@ void cmGlobalVisualStudio71Generator } //---------------------------------------------------------------------------- -// Standard end of dsw file -void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout) -{ - fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" - << "\tEndGlobalSection\n" - << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" - << "\tEndGlobalSection\n" - << "EndGlobal\n"; -} - -//---------------------------------------------------------------------------- // ouput standard header for dsw file void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) { @@ -313,9 +308,9 @@ void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- void cmGlobalVisualStudio71Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio71Generator::GetActualName(); entry.Brief = "Generates Visual Studio .NET 2003 project files."; entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index a8daad6..6d91f97 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -24,8 +24,9 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator { public: cmGlobalVisualStudio71Generator(); - static cmGlobalGenerator* New() - { return new cmGlobalVisualStudio71Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalVisualStudio71Generator>(); } ///! Get the name for the generator. virtual const char* GetName() const { @@ -33,7 +34,7 @@ public: static const char* GetActualName() {return "Visual Studio 7 .NET 2003";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -61,16 +62,15 @@ protected: const char* name, const char* path, cmTarget &t); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); - virtual void WriteProjectConfigurations(std::ostream& fout, - const char* name, - bool partOfDefaultBuild, - const char* platformMapping = NULL); + virtual void WriteProjectConfigurations( + std::ostream& fout, const char* name, cmTarget::TargetType type, + const std::set<std::string>& configsPartOfDefaultBuild, + const char* platformMapping = NULL); virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, const char* typeGuid, const std::set<cmStdString>& depends); - virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); std::string ProjectConfigurationSectionName; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b6eea5d..71d79a1 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "windows.h" // this must be first to define GetCurrentDirectory +#include <assert.h> #include "cmGlobalVisualStudio7Generator.h" #include "cmGeneratedFileStream.h" #include "cmLocalVisualStudio7Generator.h" @@ -243,20 +244,23 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) { + std::set<std::string> allConfigurations(this->Configurations.begin(), + this->Configurations.end()); this->WriteProjectConfigurations( - fout, target->GetName(), - true, target->GetProperty("VS_PLATFORM_MAPPING")); + fout, target->GetName(), target->GetType(), + allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING")); } else { - bool partOfDefaultBuild = this->IsPartOfDefaultBuild( - root->GetMakefile()->GetProjectName(), target); + const std::set<std::string>& configsPartOfDefaultBuild = + this->IsPartOfDefaultBuild(root->GetMakefile()->GetProjectName(), + target); const char *vcprojName = target->GetProperty("GENERATOR_FILE_NAME"); if (vcprojName) { - this->WriteProjectConfigurations(fout, vcprojName, - partOfDefaultBuild); + this->WriteProjectConfigurations(fout, vcprojName, target->GetType(), + configsPartOfDefaultBuild); } } } @@ -268,6 +272,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( cmLocalGenerator* root, OrderedTargetDependSet const& projectTargets) { + VisualStudioFolders.clear(); + for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { @@ -429,6 +435,9 @@ void cmGlobalVisualStudio7Generator this->WriteTargetConfigurations(fout, root, orderedProjectTargets); fout << "\tEndGlobalSection\n"; + // Write out global sections + this->WriteSLNGlobalSections(fout, root); + // Write the footer for the SLN file this->WriteSLNFooter(fout); } @@ -577,9 +586,10 @@ cmGlobalVisualStudio7Generator // Write a dsp file into the SLN file, Note, that dependencies from // executables to the libraries it uses are also done here void cmGlobalVisualStudio7Generator -::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild, - const char* platformMapping) +::WriteProjectConfigurations( + std::ostream& fout, const char* name, cmTarget::TargetType, + const std::set<std::string>& configsPartOfDefaultBuild, + const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); @@ -588,7 +598,9 @@ void cmGlobalVisualStudio7Generator fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|" << (platformMapping ? platformMapping : "Win32") << "\n"; - if(partOfDefaultBuild) + std::set<std::string>::const_iterator + ci = configsPartOfDefaultBuild.find(*i); + if(!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|" @@ -622,14 +634,73 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, +void cmGlobalVisualStudio7Generator +::WriteSLNGlobalSections(std::ostream& fout, + cmLocalGenerator* root) +{ + bool extensibilityGlobalsOverridden = false; + bool extensibilityAddInsOverridden = false; + const cmPropertyMap& props = root->GetMakefile()->GetProperties(); + for(cmPropertyMap::const_iterator itProp = props.begin(); + itProp != props.end(); ++itProp) + { + if(itProp->first.find("VS_GLOBAL_SECTION_") == 0) + { + std::string sectionType; + std::string name = itProp->first.substr(18); + if(name.find("PRE_") == 0) + { + name = name.substr(4); + sectionType = "preSolution"; + } + else if(name.find("POST_") == 0) + { + name = name.substr(5); + sectionType = "postSolution"; + } + else + continue; + if(!name.empty()) + { + if(name == "ExtensibilityGlobals" && sectionType == "postSolution") + extensibilityGlobalsOverridden = true; + else if(name == "ExtensibilityAddIns" && sectionType == "postSolution") + extensibilityAddInsOverridden = true; + fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n"; + std::vector<std::string> keyValuePairs; + cmSystemTools::ExpandListArgument(itProp->second.GetValue(), + keyValuePairs); + for(std::vector<std::string>::const_iterator itPair = + keyValuePairs.begin(); itPair != keyValuePairs.end(); ++itPair) + { + const std::string::size_type posEqual = itPair->find('='); + if(posEqual != std::string::npos) + { + const std::string key = + cmSystemTools::TrimWhitespace(itPair->substr(0, posEqual)); + const std::string value = + cmSystemTools::TrimWhitespace(itPair->substr(posEqual + 1)); + fout << "\t\t" << key << " = " << value << "\n"; + } + } + fout << "\tEndGlobalSection\n"; + } + } + } + if(!extensibilityGlobalsOverridden) + fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" + << "\tEndGlobalSection\n"; + if(!extensibilityAddInsOverridden) + fout << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" + << "\tEndGlobalSection\n"; +} + + + // Standard end of dsw file void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) { - fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" - << "\tEndGlobalSection\n" - << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" - << "\tEndGlobalSection\n" - << "EndGlobal\n"; + fout << "EndGlobal\n"; } @@ -738,9 +809,9 @@ std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations() //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio7Generator::GetActualName(); entry.Brief = "Generates Visual Studio .NET 2002 project files."; entry.Full = ""; } @@ -761,26 +832,34 @@ cmGlobalVisualStudio7Generator } } -bool cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget* target) +std::set<std::string> +cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, + cmTarget* target) { - if(target->GetPropertyAsBool("EXCLUDE_FROM_DEFAULT_BUILD")) - { - return false; - } + std::set<std::string> activeConfigs; // if it is a utilitiy target then only make it part of the // default build if another target depends on it int type = target->GetType(); if (type == cmTarget::GLOBAL_TARGET) { - return false; + return activeConfigs; } - if(type == cmTarget::UTILITY) + if(type == cmTarget::UTILITY && !this->IsDependedOn(project, target)) { - return this->IsDependedOn(project, target); + return activeConfigs; + } + // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties + for(std::vector<std::string>::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) + { + const char* propertyValue = + target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str()); + if(cmSystemTools::IsOff(propertyValue)) + { + activeConfigs.insert(*i); + } } - // default is to be part of the build - return true; + return activeConfigs; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 1df58f9..6e78620 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -13,6 +13,7 @@ #define cmGlobalVisualStudio7Generator_h #include "cmGlobalVisualStudioGenerator.h" +#include "cmGlobalGeneratorFactory.h" class cmTarget; struct cmIDEFlagTable; @@ -26,8 +27,9 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio7Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio7Generator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalVisualStudio7Generator>(); } ///! Get the name for the generator. virtual const char* GetName() const { @@ -38,7 +40,7 @@ public: virtual cmLocalGenerator *CreateLocalGenerator(); /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); /** * Try to determine system infomation such as shared library @@ -105,10 +107,12 @@ protected: const char* name, const char* path, cmTarget &t); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); - virtual void WriteProjectConfigurations(std::ostream& fout, - const char* name, - bool partOfDefaultBuild, - const char* platformMapping = NULL); + virtual void WriteProjectConfigurations( + std::ostream& fout, const char* name, cmTarget::TargetType type, + const std::set<std::string>& configsPartOfDefaultBuild, + const char* platformMapping = NULL); + virtual void WriteSLNGlobalSections(std::ostream& fout, + cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); @@ -136,8 +140,8 @@ protected: std::string ConvertToSolutionPath(const char* path); - bool IsPartOfDefaultBuild(const char* project, - cmTarget* target); + std::set<std::string> IsPartOfDefaultBuild(const char* project, + cmTarget* target); std::vector<std::string> Configurations; std::map<cmStdString, cmStdString> GUIDMap; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index bca1754..864e8db 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -13,14 +13,117 @@ #include "cmGlobalVisualStudio8Generator.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" +#include "cmVisualStudioWCEPlatformParser.h" #include "cmake.h" #include "cmGeneratedFileStream.h" +static const char vs8generatorName[] = "Visual Studio 8 2005"; + +class cmGlobalVisualStudio8Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(strstr(name, vs8generatorName) != name) + { + return 0; + } + + const char* p = name + sizeof(vs8generatorName) - 1; + if(p[0] == '\0') + { + return new cmGlobalVisualStudio8Generator( + name, NULL, NULL); + } + + if(p[0] != ' ') + { + return 0; + } + + ++p; + + if(!strcmp(p, "Win64")) + { + return new cmGlobalVisualStudio8Generator( + name, "x64", "CMAKE_FORCE_WIN64"); + } + + cmVisualStudioWCEPlatformParser parser(p); + parser.ParseVersion("8.0"); + if (!parser.Found()) + { + return 0; + } + + cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( + name, parser.GetArchitectureFamily(), NULL); + ret->PlatformName = p; + ret->WindowsCEVersion = parser.GetOSVersion(); + return ret; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = vs8generatorName; + entry.Brief = "Generates Visual Studio 8 2005 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 8 2005 Win64\" will create project files for " + "the x64 processor."; + } + + virtual void GetGenerators(std::vector<std::string>& names) const { + names.push_back(vs8generatorName); + names.push_back(vs8generatorName + std::string(" Win64")); + cmVisualStudioWCEPlatformParser parser; + parser.ParseVersion("8.0"); + const std::vector<std::string>& availablePlatforms = + parser.GetAvailablePlatforms(); + for(std::vector<std::string>::const_iterator i = + availablePlatforms.begin(); i != availablePlatforms.end(); ++i) + { + names.push_back("Visual Studio 8 2005 " + *i); + } + } +}; + +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() +{ + return new Factory; +} + //---------------------------------------------------------------------------- -cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() +cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; + this->Name = name; + if (architectureId) + { + this->ArchitectureId = architectureId; + } + if (additionalPlatformDefinition) + { + this->AdditionalPlatformDefinition = additionalPlatformDefinition; + } +} + +//---------------------------------------------------------------------------- +const char* cmGlobalVisualStudio8Generator::GetPlatformName() const +{ + if (!this->PlatformName.empty()) + { + return this->PlatformName.c_str(); + } + if (this->ArchitectureId == "X86") + { + return "Win32"; + } + return this->ArchitectureId.c_str(); } //---------------------------------------------------------------------------- @@ -36,6 +139,19 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() } //---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + cmGlobalVisualStudio71Generator::AddPlatformDefinitions(mf); + mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); + + if(this->TargetsWindowsCE()) + { + mf->AddDefinition("CMAKE_VS_WINCE_VERSION", + this->WindowsCEVersion.c_str()); + } +} + +//---------------------------------------------------------------------------- // ouput standard header for dsw file void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) { @@ -45,9 +161,9 @@ void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalVisualStudio8Generator::GetActualName(); entry.Brief = "Generates Visual Studio 8 2005 project files."; entry.Full = ""; } @@ -204,7 +320,6 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget() // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) const char* no_main_dependency = 0; - const char* no_working_directory = 0; if(cmSourceFile* file = mf->AddCustomCommandToOutput( stamps, listFiles, @@ -258,9 +373,10 @@ cmGlobalVisualStudio8Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator -::WriteProjectConfigurations(std::ostream& fout, const char* name, - bool partOfDefaultBuild, - const char* platformMapping) +::WriteProjectConfigurations( + std::ostream& fout, const char* name, cmTarget::TargetType type, + const std::set<std::string>& configsPartOfDefaultBuild, + const char* platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); @@ -270,13 +386,24 @@ cmGlobalVisualStudio8Generator << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n"; - if(partOfDefaultBuild) + std::set<std::string>::const_iterator + ci = configsPartOfDefaultBuild.find(*i); + if(!(ci == configsPartOfDefaultBuild.end())) { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n"; } + bool needsDeploy = (type == cmTarget::EXECUTABLE || + type == cmTarget::SHARED_LIBRARY); + if(this->TargetsWindowsCE() && needsDeploy) + { + fout << "\t\t{" << guid << "}." << *i + << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|" + << (platformMapping ? platformMapping : this->GetPlatformName()) + << "\n"; + } } } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 5009f29..bcbd7a0 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -23,23 +23,23 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: - cmGlobalVisualStudio8Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio8Generator; } + cmGlobalVisualStudio8Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio8Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 8 2005";} + virtual const char* GetName() const {return this->Name.c_str();} - virtual const char* GetPlatformName() const {return "Win32";} + const char* GetPlatformName() const; /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + virtual void AddPlatformDefinitions(cmMakefile* mf); + /** * Override Configure and Generate to add the build-system check * target. @@ -64,6 +64,10 @@ public: LinkLibraryDependencies and link to .sln dependencies. */ virtual bool NeedLinkLibraryDependencies(cmTarget& target); + /** Return true if building for Windows CE */ + virtual bool TargetsWindowsCE() const { + return !this->WindowsCEVersion.empty(); } + protected: virtual const char* GetIDEVersion() { return "8.0"; } @@ -74,12 +78,20 @@ protected: static cmIDEFlagTable const* GetExtraFlagTableVS8(); virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout); - virtual void WriteProjectConfigurations(std::ostream& fout, - const char* name, - bool partOfDefaultBuild, - const char* platformMapping = NULL); + virtual void WriteProjectConfigurations( + std::ostream& fout, const char* name, cmTarget::TargetType type, + const std::set<std::string>& configsPartOfDefaultBuild, + const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); + + std::string Name; + std::string PlatformName; + std::string WindowsCEVersion; + +private: + class Factory; + friend class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx deleted file mode 100644 index 4cbc275..0000000 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "windows.h" // this must be first to define GetCurrentDirectory -#include "cmGlobalVisualStudio8Win64Generator.h" -#include "cmLocalVisualStudio7Generator.h" -#include "cmMakefile.h" -#include "cmake.h" - - - -cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 8 2005 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - this->cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio8Win64Generator.h b/Source/cmGlobalVisualStudio8Win64Generator.h deleted file mode 100644 index 12f8012..0000000 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio8Win64Generator_h -#define cmGlobalVisualStudio8Win64Generator_h - -#include "cmGlobalVisualStudio8Generator.h" - - -/** \class cmGlobalVisualStudio8Win64Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio8Win64Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio8Win64Generator : - public cmGlobalVisualStudio8Generator -{ -public: - cmGlobalVisualStudio8Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio8Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio8Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 8 2005 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - /** - * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. - */ - virtual void AddPlatformDefinitions(cmMakefile *); -}; -#endif diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 70af50d..2082384 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -13,11 +13,99 @@ #include "cmGlobalVisualStudio9Generator.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" +#include "cmVisualStudioWCEPlatformParser.h" #include "cmake.h" +static const char vs9generatorName[] = "Visual Studio 9 2008"; +class cmGlobalVisualStudio9Generator::Factory + : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { + if(strstr(name, vs9generatorName) != name) + { + return 0; + } + + const char* p = name + sizeof(vs9generatorName) - 1; + if(p[0] == '\0') + { + return new cmGlobalVisualStudio9Generator( + name, NULL, NULL); + } + + if(p[0] != ' ') + { + return 0; + } + + ++p; + + if(!strcmp(p, "IA64")) + { + return new cmGlobalVisualStudio9Generator( + name, "Itanium", "CMAKE_FORCE_IA64"); + } + + if(!strcmp(p, "Win64")) + { + return new cmGlobalVisualStudio9Generator( + name, "x64", "CMAKE_FORCE_WIN64"); + } + + cmVisualStudioWCEPlatformParser parser(p); + parser.ParseVersion("9.0"); + if (!parser.Found()) + { + return 0; + } + + cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator( + name, parser.GetArchitectureFamily(), NULL); + ret->PlatformName = p; + ret->WindowsCEVersion = parser.GetOSVersion(); + return ret; + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + entry.Name = vs9generatorName; + entry.Brief = "Generates Visual Studio 9 2008 project files."; + entry.Full = + "It is possible to append a space followed by the platform name " + "to create project files for a specific target platform. E.g. " + "\"Visual Studio 9 2008 Win64\" will create project files for " + "the x64 processor; \"Visual Studio 9 2008 IA64\" for Itanium."; + } + + virtual void GetGenerators(std::vector<std::string>& names) const { + names.push_back(vs9generatorName); + names.push_back(vs9generatorName + std::string(" Win64")); + names.push_back(vs9generatorName + std::string(" IA64")); + cmVisualStudioWCEPlatformParser parser; + parser.ParseVersion("9.0"); + const std::vector<std::string>& availablePlatforms = + parser.GetAvailablePlatforms(); + for(std::vector<std::string>::const_iterator i = + availablePlatforms.begin(); i != availablePlatforms.end(); ++i) + { + names.push_back("Visual Studio 9 2008 " + *i); + } + } +}; -cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() +//---------------------------------------------------------------------------- +cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() +{ + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( + const char* name, const char* architectureId, + const char* additionalPlatformDefinition) + : cmGlobalVisualStudio8Generator(name, architectureId, + additionalPlatformDefinition) { this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; } @@ -42,15 +130,6 @@ cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalVisualStudio9Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 9 2008 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 0b0d143..1310a93 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -24,17 +24,9 @@ class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio9Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio9Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 9 2008";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + cmGlobalVisualStudio9Generator(const char* name, + const char* architectureId, const char* additionalPlatformDefinition); + static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -61,5 +53,8 @@ public: virtual std::string GetUserMacrosRegKeyBase(); protected: virtual const char* GetIDEVersion() { return "9.0"; } +private: + class Factory; + friend class Factory; }; #endif diff --git a/Source/cmGlobalVisualStudio9IA64Generator.cxx b/Source/cmGlobalVisualStudio9IA64Generator.cxx deleted file mode 100644 index 38dbfac..0000000 --- a/Source/cmGlobalVisualStudio9IA64Generator.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio9IA64Generator.h" -#include "cmLocalVisualStudio7Generator.h" -#include "cmMakefile.h" - - -cmGlobalVisualStudio9IA64Generator::cmGlobalVisualStudio9IA64Generator() -{ - this->ArchitectureId = "Itanium"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9IA64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 9 2008 Itanium project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9IA64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - cmGlobalVisualStudio9Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio9IA64Generator.h b/Source/cmGlobalVisualStudio9IA64Generator.h deleted file mode 100644 index 989b0d1..0000000 --- a/Source/cmGlobalVisualStudio9IA64Generator.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio9IA64Generator_h -#define cmGlobalVisualStudio9IA64Generator_h - -#include "cmGlobalVisualStudio9Generator.h" - - -/** \class cmGlobalVisualStudio8IA64Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio8IA64Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio9IA64Generator : - public cmGlobalVisualStudio9Generator -{ -public: - cmGlobalVisualStudio9IA64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9IA64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio9IA64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 9 2008 IA64";} - - virtual const char* GetPlatformName() const {return "Itanium";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - /** - * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. - */ - virtual void AddPlatformDefinitions(cmMakefile *); -}; -#endif diff --git a/Source/cmGlobalVisualStudio9Win64Generator.cxx b/Source/cmGlobalVisualStudio9Win64Generator.cxx deleted file mode 100644 index 4d8a646..0000000 --- a/Source/cmGlobalVisualStudio9Win64Generator.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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. -============================================================================*/ -#include "cmGlobalVisualStudio9Win64Generator.h" -#include "cmLocalVisualStudio7Generator.h" -#include "cmMakefile.h" - - -cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator() -{ - this->ArchitectureId = "x64"; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Win64Generator -::GetDocumentation(cmDocumentationEntry& entry) const -{ - entry.Name = this->GetName(); - entry.Brief = "Generates Visual Studio 9 2008 Win64 project files."; - entry.Full = ""; -} - -//---------------------------------------------------------------------------- -void cmGlobalVisualStudio9Win64Generator -::AddPlatformDefinitions(cmMakefile* mf) -{ - cmGlobalVisualStudio9Generator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); -} diff --git a/Source/cmGlobalVisualStudio9Win64Generator.h b/Source/cmGlobalVisualStudio9Win64Generator.h deleted file mode 100644 index 7c20cf4..0000000 --- a/Source/cmGlobalVisualStudio9Win64Generator.h +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 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 cmGlobalVisualStudio9Win64Generator_h -#define cmGlobalVisualStudio9Win64Generator_h - -#include "cmGlobalVisualStudio9Generator.h" - - -/** \class cmGlobalVisualStudio8Win64Generator - * \brief Write a Unix makefiles. - * - * cmGlobalVisualStudio8Win64Generator manages UNIX build process for a tree - */ -class cmGlobalVisualStudio9Win64Generator : - public cmGlobalVisualStudio9Generator -{ -public: - cmGlobalVisualStudio9Win64Generator(); - static cmGlobalGenerator* New() { - return new cmGlobalVisualStudio9Win64Generator; } - - ///! Get the name for the generator. - virtual const char* GetName() const { - return cmGlobalVisualStudio9Win64Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 9 2008 Win64";} - - virtual const char* GetPlatformName() const {return "x64";} - - /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; - - /** - * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. - */ - virtual void AddPlatformDefinitions(cmMakefile *); -}; -#endif diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 0968b77..808664d 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -22,6 +22,7 @@ cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { this->ArchitectureId = "X86"; + this->AdditionalPlatformDefinition = NULL; } //---------------------------------------------------------------------------- @@ -32,9 +33,16 @@ cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator() //---------------------------------------------------------------------------- std::string cmGlobalVisualStudioGenerator::GetRegistryBase() { + return cmGlobalVisualStudioGenerator::GetRegistryBase( + this->GetIDEVersion()); +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudioGenerator::GetRegistryBase( + const char* version) +{ std::string key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\"; - key += this->GetIDEVersion(); - return key; + return key + version; } //---------------------------------------------------------------------------- @@ -75,7 +83,6 @@ void cmGlobalVisualStudioGenerator::Generate() #endif // Now make all targets depend on the ALL_BUILD target - cmTargets targets; for(std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { @@ -492,8 +499,13 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId.c_str()); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId.c_str()); + + if(this->AdditionalPlatformDefinition) + { + mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index cebf7d7..9d81170 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -65,10 +65,16 @@ public: /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); + /** Get the top-level registry key for the given VS version. */ + static std::string GetRegistryBase(const char* version); + /** Return true if the generated build tree may contain multiple builds. i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return true; } + /** Return true if building for Windows CE */ + virtual bool TargetsWindowsCE() const { return false; } + class TargetSet: public std::set<cmTarget*> {}; struct TargetCompare { @@ -98,7 +104,8 @@ protected: std::string GetUtilityDepend(cmTarget* target); typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; - const char* ArchitectureId; + std::string ArchitectureId; + const char* AdditionalPlatformDefinition; private: void ComputeTargetObjects(cmGeneratorTarget* gt) const; diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 45b171f..e3cebc4 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -58,9 +58,9 @@ cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalWatcomWMakeGenerator -::GetDocumentation(cmDocumentationEntry& entry) const +::GetDocumentation(cmDocumentationEntry& entry) { - entry.Name = this->GetName(); + entry.Name = cmGlobalWatcomWMakeGenerator::GetActualName(); entry.Brief = "Generates Watcom WMake makefiles."; entry.Full = ""; } diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index ee16eae..23e60a1 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -23,14 +23,16 @@ class cmGlobalWatcomWMakeGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalWatcomWMakeGenerator(); - static cmGlobalGenerator* New() { return new cmGlobalWatcomWMakeGenerator; } + static cmGlobalGeneratorFactory* NewFactory() { + return new cmGlobalGeneratorSimpleFactory + <cmGlobalWatcomWMakeGenerator>(); } ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalWatcomWMakeGenerator::GetActualName();} static const char* GetActualName() {return "Watcom WMake";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 30d8f18..b2d325c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -20,6 +20,7 @@ #include "cmSourceFile.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratorTarget.h" +#include "cmGlobalGeneratorFactory.h" #include <cmsys/auto_ptr.hxx> @@ -112,6 +113,18 @@ public: } }; +class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory +{ +public: + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const; + + virtual void GetDocumentation(cmDocumentationEntry& entry) const { + cmGlobalXCodeGenerator::GetDocumentation(entry); } + + virtual void GetGenerators(std::vector<std::string>& names) const { + names.push_back(cmGlobalXCodeGenerator::GetActualName()); } +}; + //---------------------------------------------------------------------------- cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) { @@ -132,8 +145,17 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) } //---------------------------------------------------------------------------- -cmGlobalGenerator* cmGlobalXCodeGenerator::New() +cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() { + return new Factory; +} + +//---------------------------------------------------------------------------- +cmGlobalGenerator* cmGlobalXCodeGenerator::Factory +::CreateGlobalGenerator(const char* name) const +{ + if (strcmp(name, GetActualName())) + return 0; #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; std::string versionFile; @@ -495,8 +517,12 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( (this->CurrentReRunCMakeMakefile.c_str()); makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; - makefileStream << cmake::GetCMakeFilesDirectoryPostSlash(); - makefileStream << "cmake.check_cache: "; + std::string checkCache = mf->GetHomeOutputDirectory(); + checkCache += "/"; + checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); + checkCache += "cmake.check_cache"; + makefileStream << this->ConvertToRelativeForMake(checkCache.c_str()) + << ": "; for(std::vector<std::string>::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { @@ -1971,15 +1997,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, dirs.Add(incpath.c_str()); } } - std::vector<std::string>& frameworks = target.GetFrameworks(); - if(frameworks.size()) + if(target.GetType() != cmTarget::OBJECT_LIBRARY && + target.GetType() != cmTarget::STATIC_LIBRARY) { - for(std::vector<std::string>::iterator fmIt = frameworks.begin(); - fmIt != frameworks.end(); ++fmIt) + // Add framework search paths needed for linking. + if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) { - if(emitted.insert(*fmIt).second) + std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths(); + for(std::vector<std::string>::const_iterator fdi = fwDirs.begin(); + fdi != fwDirs.end(); ++fdi) { - fdirs.Add(this->XCodeEscapePath(fmIt->c_str()).c_str()); + if(emitted.insert(*fdi).second) + { + fdirs.Add(this->XCodeEscapePath(fdi->c_str()).c_str()); + } } } } @@ -2623,8 +2654,7 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); - cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); + cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); if(!pcli) { continue; @@ -2666,25 +2696,6 @@ void cmGlobalXCodeGenerator linkDirs.c_str(), configName); } - // add the framework search paths - { - const char* sep = ""; - std::string fdirs; - std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths(); - for(std::vector<std::string>::const_iterator fdi = fwDirs.begin(); - fdi != fwDirs.end(); ++fdi) - { - fdirs += sep; - sep = " "; - fdirs += this->XCodeEscapePath(fdi->c_str()); - } - if(!fdirs.empty()) - { - this->AppendBuildSettingAttribute(target, "FRAMEWORK_SEARCH_PATHS", - fdirs.c_str(), configName); - } - } - // now add the link libraries { std::string linkLibs; @@ -3470,9 +3481,8 @@ const char* cmGlobalXCodeGenerator::GetCMakeCFGIntDir() const //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry) - const { - entry.Name = this->GetName(); + entry.Name = cmGlobalXCodeGenerator::GetActualName(); entry.Brief = "Generate Xcode project files."; entry.Full = ""; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index afa1ca2..c98652f 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -15,6 +15,7 @@ #include "cmGlobalGenerator.h" #include "cmXCodeObject.h" #include "cmCustomCommand.h" +class cmGlobalGeneratorFactory; class cmTarget; class cmSourceFile; class cmSourceGroup; @@ -29,7 +30,7 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator { public: cmGlobalXCodeGenerator(std::string const& version); - static cmGlobalGenerator* New(); + static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. virtual const char* GetName() const { @@ -37,7 +38,7 @@ public: static const char* GetActualName() {return "Xcode";} /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry) const; + static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -186,6 +187,7 @@ private: const char* varNameSuffix, const char* default_flags); + class Factory; class BuildObjectListOrString; friend class BuildObjectListOrString; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 15bad52..4816da9 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -15,8 +15,6 @@ #include "cmGlobalGenerator.h" #include "cmGeneratedFileStream.h" -#include <memory> - static const char* getShapeForTarget(const cmTarget* target) @@ -67,7 +65,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cmake cm; cmGlobalGenerator ggi; ggi.SetCMakeInstance(&cm); - std::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator()); cmMakefile *mf = lg->GetMakefile(); const char* inFileName = settingsFileName; diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index d9c0e87..76a60cf 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -177,3 +177,14 @@ void cmIDEOptions::RemoveFlag(const char* flag) { this->FlagMap.erase(flag); } + +//---------------------------------------------------------------------------- +const char* cmIDEOptions::GetFlag(const char* flag) +{ + std::map<cmStdString, cmStdString>::iterator i = this->FlagMap.find(flag); + if(i != this->FlagMap.end()) + { + return i->second.c_str(); + } + return 0; +} diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index a5be8fb..e556bde 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -29,6 +29,7 @@ public: void AddDefines(const char* defines); void AddFlag(const char* flag, const char* value); void RemoveFlag(const char* flag); + const char* GetFlag(const char* flag); protected: // create a map of xml tags to the values they should have in the output diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 6751fc0..dd37b82 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -72,9 +72,12 @@ public: "CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. " "By using AFTER or BEFORE explicitly, you can select between " "appending and prepending, independent of the default. " + "\n" "If the SYSTEM option is given, the compiler will be told the " "directories are meant as system include directories on some " - "platforms."; + "platforms (signalling this setting might achieve effects such as " + "the compiler skipping warnings, or these fixed-install system files " + "not being considered in dependency calculations - see compiler docs)."; } cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 347ad3e..5f9b658 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -16,7 +16,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmake.h" -#include "cmGeneratorTarget.h" #include <assert.h> @@ -27,8 +26,7 @@ cmInstallTargetGenerator std::vector<std::string> const& configurations, const char* component, bool optional): cmInstallGenerator(dest, configurations, component), Target(&t), - ImportLibrary(implib), FilePermissions(file_permissions), - Optional(optional), GeneratorTarget(0) + ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional) { this->ActionsPerConfig = true; this->NamelinkMode = NamelinkModeNone; @@ -486,17 +484,6 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, this->AddStripRule(os, indent, file); } -void cmInstallTargetGenerator::CreateGeneratorTarget() -{ - if (!this->GeneratorTarget) - { - this->GeneratorTarget = this->Target->GetMakefile() - ->GetLocalGenerator() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - } -} - //---------------------------------------------------------------------------- void cmInstallTargetGenerator @@ -520,13 +507,10 @@ cmInstallTargetGenerator return; } - this->CreateGeneratorTarget(); - // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map<cmStdString, cmStdString> install_name_remap; - if(cmComputeLinkInformation* cli = - this->GeneratorTarget->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); @@ -624,12 +608,9 @@ cmInstallTargetGenerator return; } - this->CreateGeneratorTarget(); - // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->GeneratorTarget->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -658,12 +639,9 @@ cmInstallTargetGenerator return; } - this->CreateGeneratorTarget(); - // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->GeneratorTarget->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index cab3e90..8cf72f9 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -14,8 +14,7 @@ #include "cmInstallGenerator.h" #include "cmTarget.h" - -class cmGeneratorTarget; +#include "cmGeneratorTarget.h" /** \class cmInstallTargetGenerator * \brief Generate target installation rules. @@ -94,8 +93,6 @@ protected: void AddRanlibRule(std::ostream& os, Indent const& indent, const std::string& toDestDirPath); - void CreateGeneratorTarget(); - cmTarget* Target; bool ImportLibrary; std::string FilePermissions; diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 7848424..df64695 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -15,13 +15,14 @@ #include <stdlib.h> // required for atoi #include <ctype.h> +#include <assert.h> //---------------------------------------------------------------------------- bool cmListCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { - if(args.size() < 1) + if(args.size() < 2) { - this->SetError("must be called with at least one argument."); + this->SetError("must be called with at least two arguments."); return false; } @@ -243,11 +244,7 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) //---------------------------------------------------------------------------- bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command APPEND requires at least one argument."); - return false; - } + assert(args.size() >= 2); // Skip if nothing to append. if(args.size() < 3) @@ -424,12 +421,8 @@ bool cmListCommand bool cmListCommand ::HandleReverseCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command REVERSE requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command REVERSE only takes one argument."); @@ -463,13 +456,8 @@ bool cmListCommand bool cmListCommand ::HandleRemoveDuplicatesCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError( - "sub-command REMOVE_DUPLICATES requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command REMOVE_DUPLICATES only takes one argument."); @@ -513,12 +501,8 @@ bool cmListCommand bool cmListCommand ::HandleSortCommand(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("sub-command SORT requires a list as an argument."); - return false; - } - else if(args.size() > 2) + assert(args.size() >= 2); + if(args.size() > 2) { this->SetError( "sub-command SORT only takes one argument."); diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index b2acf06..181b922 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -224,6 +224,10 @@ cmLoadedCommand::~cmLoadedCommand() bool cmLoadCommandCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + this->Makefile->IssueMessage( + cmake::AUTHOR_WARNING, + "The \"load_command\" command will be removed in CMake 3.0. " + "See command documentation for details."); if(args.size() < 1 ) { return true; diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index f0b34ee..bcd1831 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -47,7 +47,7 @@ public: */ virtual const char* GetTerseDocumentation() const { - return "Load a command into a running CMake."; + return "Deprecated. Use macro() or function() instead."; } /** @@ -56,6 +56,13 @@ public: virtual const char* GetFullDocumentation() const { return + "This command will be removed in CMake 3.0. " + "It works only when the target architecture matches the " + "running CMake binary. " + "Use macro() or function() to add commands. " + "Use execute_process() to run advanced computations " + "in external processes." + "\n" " load_command(COMMAND_NAME <loc1> [loc2 ...])\n" "The given locations are searched for a library whose name is " "cmCOMMAND_NAME. If found, it is loaded as a module and the command " @@ -67,6 +74,12 @@ public: "Otherwise the variable will not be set."; } + /** This command is kept for compatibility with older CMake versions. */ + virtual bool IsDiscouraged() const + { + return true; + } + cmTypeMacro(cmLoadCommandCommand, cmCommand); }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4952a8c..b41f060 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1329,7 +1329,9 @@ std::string cmLocalGenerator::GetIncludeFlags( void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, const char* lang, - const char *config) + const char *config, + bool stripImplicitInclDirs + ) { // Need to decide whether to automatically include the source and // binary directories at the beginning of the include path. @@ -1404,18 +1406,21 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } - // Load implicit include directories for this language. - std::string impDirVar = "CMAKE_"; - impDirVar += lang; - impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; - if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) + if (stripImplicitInclDirs) { - std::vector<std::string> impDirVec; - cmSystemTools::ExpandListArgument(value, impDirVec); - for(std::vector<std::string>::const_iterator i = impDirVec.begin(); - i != impDirVec.end(); ++i) + // Load implicit include directories for this language. + std::string impDirVar = "CMAKE_"; + impDirVar += lang; + impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; + if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) { - emitted.insert(*i); + std::vector<std::string> impDirVec; + cmSystemTools::ExpandListArgument(value, impDirVec); + for(std::vector<std::string>::const_iterator i = impDirVec.begin(); + i != impDirVec.end(); ++i) + { + emitted.insert(*i); + } } } @@ -1671,7 +1676,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, { cmOStringStream fout; const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); if(!pcli) { return; @@ -1875,6 +1880,14 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, // modify the name so stripping down to just the file name should // produce the target name in this case. std::string name = cmSystemTools::GetFilenameName(inName); + + // If the input name is the empty string, there is no real + // dependency. Short-circuit the other checks: + if(name == "") + { + return false; + } + if(cmSystemTools::GetFilenameLastExtension(name) == ".exe") { name = cmSystemTools::GetFilenameWithoutLastExtension(name); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index bd58218..63559d7 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -212,7 +212,8 @@ public: /** Get the include flags for the current makefile and language. */ void GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, - const char* lang = "C", const char *config = 0); + const char* lang = "C", const char *config = 0, + bool stripImplicitInclDirs = true); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index db93529..d629e71 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -32,7 +32,6 @@ #include <cmsys/auto_ptr.hxx> -#include <memory> // auto_ptr #include <queue> //---------------------------------------------------------------------------- @@ -1939,8 +1938,12 @@ void cmLocalUnixMakefileGenerator3 for(ImplicitDependFileMap::const_iterator pi = implicitPairs.begin(); pi != implicitPairs.end(); ++pi) { - cmakefileStream << " \"" << pi->second << "\" "; - cmakefileStream << "\"" << pi->first << "\"\n"; + for(cmDepends::DependencyVector::const_iterator di = pi->second.begin(); + di != pi->second.end(); ++ di) + { + cmakefileStream << " \"" << *di << "\" "; + cmakefileStream << "\"" << pi->first << "\"\n"; + } } cmakefileStream << " )\n"; @@ -2204,7 +2207,7 @@ cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt, const char* obj, const char* src) { - this->ImplicitDepends[tgt.GetName()][lang][obj] = src; + this->ImplicitDepends[tgt.GetName()][lang][obj].push_back(src); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index e374959..703369e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -209,7 +209,8 @@ public: // File pairs for implicit dependency scanning. The key of the map // is the depender and the value is the explicit dependee. - struct ImplicitDependFileMap: public std::map<cmStdString, cmStdString> {}; + struct ImplicitDependFileMap: + public std::map<cmStdString, cmDepends::DependencyVector> {}; struct ImplicitDependLanguageMap: public std::map<cmStdString, ImplicitDependFileMap> {}; struct ImplicitDependTargetMap: diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index f15322b..6c78ac4 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -326,18 +326,18 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, { cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); #if defined(_WIN32) || defined(__CYGWIN__) - std::ofstream fout(source.c_str(), + std::ofstream sourceFout(source.c_str(), std::ios::binary | std::ios::out | std::ios::trunc); #else - std::ofstream fout(source.c_str(), + std::ofstream sourceFout(source.c_str(), std::ios::out | std::ios::trunc); #endif - if(fout) + if(sourceFout) { - fout.write("# generated from CMake",22); - fout.flush(); - fout.close(); + sourceFout.write("# generated from CMake",22); + sourceFout.flush(); + sourceFout.close(); } } } @@ -710,6 +710,8 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, switch(b) { + case WIN32_EXECUTABLE: + break; case STATIC_LIBRARY: this->DSPHeaderTemplate = root; this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate"; @@ -1783,10 +1785,8 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); + cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f9a2d32..918b21e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -229,6 +229,9 @@ void cmLocalVisualStudio7Generator this->FortranProject = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) ->TargetIsFortranOnly(target); + this->WindowsCEProject = + static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) + ->TargetsWindowsCE(); // Intel Fortran for VS10 uses VS9 format ".vfproj" files. VSVersion realVersion = this->Version; @@ -914,12 +917,12 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // for FAT32 file systems, which can cause an empty manifest // to be embedded into the resulting executable. See CMake // bug #2617. - const char* tool = "VCManifestTool"; + const char* manifestTool = "VCManifestTool"; if(this->FortranProject) { - tool = "VFManifestTool"; + manifestTool = "VFManifestTool"; } - fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n" + fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << manifestTool << "\"\n" << "\t\t\t\tUseFAT32Workaround=\"true\"\n" << "\t\t\t/>\n"; } @@ -1003,6 +1006,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } switch(target.GetType()) { + case cmTarget::UNKNOWN_LIBRARY: + break; case cmTarget::OBJECT_LIBRARY: { std::string libpath = this->GetTargetDirectory(target); @@ -1074,9 +1079,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); - cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); + cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); if(!pcli) { return; @@ -1161,9 +1164,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); - cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); + cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); if(!pcli) { return; @@ -1171,6 +1172,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, cmComputeLinkInformation& cli = *pcli; const char* linkLanguage = cli.GetLinkLanguage(); + bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE"); + // Compute the variable name to lookup standard libraries for this // language. std::string standardLibsVar = "CMAKE_"; @@ -1218,15 +1221,24 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, { fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n"; } - if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") ) + if ( this->WindowsCEProject ) + { + fout << "\t\t\t\tSubSystem=\"9\"\n" + << "\t\t\t\tEntryPointSymbol=\"" + << (isWin32Executable ? "WinMainCRTStartup" : "mainACRTStartup") + << "\"\n"; + } + else if ( this->FortranProject ) { fout << "\t\t\t\tSubSystem=\"" - << (this->FortranProject? "subSystemWindows" : "2") << "\"\n"; + << (isWin32Executable ? "subSystemWindows" : "subSystemConsole") + << "\"\n"; } else { fout << "\t\t\t\tSubSystem=\"" - << (this->FortranProject? "subSystemConsole" : "1") << "\"\n"; + << (isWin32Executable ? "2" : "1") + << "\"\n"; } std::string stackVar = "CMAKE_"; stackVar += linkLanguage; diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 95db2cc..5a1d208 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -122,6 +122,7 @@ private: cmVS7FlagTable const* ExtraFlagTable; std::string ModuleDefinitionFile; bool FortranProject; + bool WindowsCEProject; std::string PlatformName; // Win32 or x64 cmLocalVisualStudio7GeneratorInternals* Internal; }; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4bcf4de..ef2bb1d 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -84,7 +84,6 @@ cmLocalVisualStudioGenerator const char* newline_text) { bool useLocal = this->CustomCommandUseLocal(); - const cmCustomCommandLines& commandLines = cc.GetCommandLines(); const char* workingDirectory = cc.GetWorkingDirectory(); cmCustomCommandGenerator ccg(cc, configName, this->Makefile); RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT; diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index f8c40c0..aedbb4d 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -92,12 +92,12 @@ public: "facilitates creating macros with optional arguments. Additionally " "${ARGV} holds the list of all arguments given to the macro and " "${ARGN} " - "holds the list of argument past the last expected argument. " + "holds the list of arguments past the last expected argument. " "Note that the parameters to a macro and values such as ARGN " "are not variables in the usual CMake sense. They are string " - "replacements much like the c preprocessor would do with a " - "macro. If you want true CMake variables you should look at " - "the function command." + "replacements much like the C preprocessor would do with a macro. " + "If you want true CMake variables and/or better CMake scope control " + "you should look at the function command." "\n" "See the cmake_policy() command documentation for the behavior of " "policies inside macros." diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f067da4..b432986 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -814,7 +814,7 @@ bool cmMakefile::NeedBackwardsCompatibility(unsigned int major, void cmMakefile::FinalPass() { // do all the variable expansions here - this->ExpandVariables(); + this->ExpandVariablesCMP0019(); // give all the commands a chance to do something // after the file has been parsed before generation @@ -1485,9 +1485,12 @@ void cmMakefile::InitializeFromParent() // Initialize definitions with the closure of the parent scope. this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure(); - // copy include paths - this->SetProperty("INCLUDE_DIRECTORIES", - parent->GetProperty("INCLUDE_DIRECTORIES")); + const std::vector<IncludeDirectoriesEntry> parentIncludes = + parent->GetIncludeDirectoriesEntries(); + this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), + parentIncludes.begin(), + parentIncludes.end()); + this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -1613,41 +1616,6 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, } //---------------------------------------------------------------------------- -void AddStringToProperty(cmProperty *prop, const char* name, const char* s, - bool before) -{ - if (!prop) - { - return; - } - - // Don't worry about duplicates at this point. We eliminate them when - // we convert the property to a vector in GetIncludeDirectories. - - if (before) - { - const char *val = prop->GetValue(); - cmOStringStream oss; - - if(val && *val) - { - oss << s << ";" << val; - } - else - { - oss << s; - } - - std::string newVal = oss.str(); - prop->Set(name, newVal.c_str()); - } - else - { - prop->Append(name, s); - } -} - -//---------------------------------------------------------------------------- void cmMakefile::AddIncludeDirectory(const char* inc, bool before) { if (!inc) @@ -1655,18 +1623,21 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before) return; } - // Directory property: - cmProperty *prop = - this->GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES"); - AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before); + std::vector<IncludeDirectoriesEntry>::iterator position = + before ? this->IncludeDirectoriesEntries.begin() + : this->IncludeDirectoriesEntries.end(); + + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + IncludeDirectoriesEntry entry(inc, lfbt); + this->IncludeDirectoriesEntries.insert(position, entry); // Property on each target: for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); ++l) { cmTarget &t = l->second; - prop = t.GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES"); - AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before); + t.InsertInclude(entry, before); } } @@ -2122,21 +2093,33 @@ void cmMakefile::AddExtraDirectory(const char* dir) this->AuxSourceDirectories.push_back(dir); } +static bool mightExpandVariablesCMP0019(const char* s) +{ + return s && *s && strstr(s,"${") && strchr(s,'}'); +} -// expand CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the -// include and library directories. - -void cmMakefile::ExpandVariables() +void cmMakefile::ExpandVariablesCMP0019() { - // Now expand variables in the include and link strings + // Drop this ancient compatibility behavior with a policy. + cmPolicies::PolicyStatus pol = this->GetPolicyStatus(cmPolicies::CMP0019); + if(pol != cmPolicies::OLD && pol != cmPolicies::WARN) + { + return; + } + cmOStringStream w; - // May not be necessary anymore... But may need a policy for strict - // backwards compatibility const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES"); - if (includeDirs) + if(mightExpandVariablesCMP0019(includeDirs)) { std::string dirs = includeDirs; this->ExpandVariablesInString(dirs, true, true); + if(pol == cmPolicies::WARN && dirs != includeDirs) + { + w << "Evaluated directory INCLUDE_DIRECTORIES\n" + << " " << includeDirs << "\n" + << "as\n" + << " " << dirs << "\n"; + } this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str()); } @@ -2146,10 +2129,17 @@ void cmMakefile::ExpandVariables() { cmTarget &t = l->second; includeDirs = t.GetProperty("INCLUDE_DIRECTORIES"); - if (includeDirs) + if(mightExpandVariablesCMP0019(includeDirs)) { std::string dirs = includeDirs; this->ExpandVariablesInString(dirs, true, true); + if(pol == cmPolicies::WARN && dirs != includeDirs) + { + w << "Evaluated target " << t.GetName() << " INCLUDE_DIRECTORIES\n" + << " " << includeDirs << "\n" + << "as\n" + << " " << dirs << "\n"; + } t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str()); } } @@ -2157,13 +2147,45 @@ void cmMakefile::ExpandVariables() for(std::vector<std::string>::iterator d = this->LinkDirectories.begin(); d != this->LinkDirectories.end(); ++d) { - this->ExpandVariablesInString(*d, true, true); + if(mightExpandVariablesCMP0019(d->c_str())) + { + std::string orig = *d; + this->ExpandVariablesInString(*d, true, true); + if(pol == cmPolicies::WARN && *d != orig) + { + w << "Evaluated link directory\n" + << " " << orig << "\n" + << "as\n" + << " " << *d << "\n"; + } + } } for(cmTarget::LinkLibraryVectorType::iterator l = this->LinkLibraries.begin(); l != this->LinkLibraries.end(); ++l) { - this->ExpandVariablesInString(l->first, true, true); + if(mightExpandVariablesCMP0019(l->first.c_str())) + { + std::string orig = l->first; + this->ExpandVariablesInString(l->first, true, true); + if(pol == cmPolicies::WARN && l->first != orig) + { + w << "Evaluated link library\n" + << " " << orig << "\n" + << "as\n" + << " " << l->first << "\n"; + } + } + } + + if(!w.str().empty()) + { + cmOStringStream m; + m << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0019) + << "\n" + << "The following variable evaluations were encountered:\n" + << w.str(); + this->IssueMessage(cmake::AUTHOR_WARNING, m.str()); } } @@ -3400,6 +3422,15 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->SetLinkDirectories(varArgsExpanded); return; } + if (propname == "INCLUDE_DIRECTORIES") + { + this->IncludeDirectoriesEntries.clear(); + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + this->IncludeDirectoriesEntries.push_back( + IncludeDirectoriesEntry(value, lfbt)); + return; + } if ( propname == "INCLUDE_REGULAR_EXPRESSION" ) { @@ -3431,6 +3462,14 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, // handle special props std::string propname = prop; + if (propname == "INCLUDE_DIRECTORIES") + { + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + this->IncludeDirectoriesEntries.push_back( + IncludeDirectoriesEntry(value, lfbt)); + return; + } if ( propname == "LINK_DIRECTORIES" ) { std::vector<std::string> varArgsExpanded; @@ -3542,6 +3581,20 @@ const char *cmMakefile::GetProperty(const char* prop, output = str.str(); return output.c_str(); } + else if (!strcmp("INCLUDE_DIRECTORIES",prop)) + { + std::string sep; + for (std::vector<IncludeDirectoriesEntry>::const_iterator + it = this->IncludeDirectoriesEntries.begin(), + end = this->IncludeDirectoriesEntries.end(); + it != end; ++it) + { + output += sep; + output += it->Value; + sep = ";"; + } + return output.c_str(); + } bool chain = false; const char *retVal = @@ -3937,6 +3990,46 @@ void cmMakefile::DefineProperties(cmake *cm) "See the global property of the same name for details. " "This overrides the global property for a directory.", true); + + cm->DefineProperty + ("VS_GLOBAL_SECTION_PRE_<section>", cmProperty::DIRECTORY, + "Specify a preSolution global section in Visual Studio.", + "Setting a property like this generates an entry of the following form " + "in the solution file:\n" + " GlobalSection(<section>) = preSolution\n" + " <contents based on property value>\n" + " EndGlobalSection\n" + "The property must be set to a semicolon-separated list of key=value " + "pairs. Each such pair will be transformed into an entry in the solution " + "global section. Whitespace around key and value is ignored. List " + "elements which do not contain an equal sign are skipped." + "\n" + "This property only works for Visual Studio 7 and above; it is ignored " + "on other generators. The property only applies when set on a directory " + "whose CMakeLists.txt conatins a project() command."); + cm->DefineProperty + ("VS_GLOBAL_SECTION_POST_<section>", cmProperty::DIRECTORY, + "Specify a postSolution global section in Visual Studio.", + "Setting a property like this generates an entry of the following form " + "in the solution file:\n" + " GlobalSection(<section>) = postSolution\n" + " <contents based on property value>\n" + " EndGlobalSection\n" + "The property must be set to a semicolon-separated list of key=value " + "pairs. Each such pair will be transformed into an entry in the solution " + "global section. Whitespace around key and value is ignored. List " + "elements which do not contain an equal sign are skipped." + "\n" + "This property only works for Visual Studio 7 and above; it is ignored " + "on other generators. The property only applies when set on a directory " + "whose CMakeLists.txt conatins a project() command." + "\n" + "Note that CMake generates postSolution sections ExtensibilityGlobals " + "and ExtensibilityAddIns by default. If you set the corresponding " + "property, it will override the default section. For example, setting " + "VS_GLOBAL_SECTION_POST_ExtensibilityGlobals will override the default " + "contents of the ExtensibilityGlobals section, while keeping " + "ExtensibilityAddIns on its default."); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 70cfe54..a85015f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -22,6 +22,7 @@ #include "cmNewLineStyle.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmMakefileIncludeDirectoriesEntry.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmSourceGroup.h" @@ -693,7 +694,7 @@ public: /** * Expand variables in the makefiles ivars such as link directories etc */ - void ExpandVariables(); + void ExpandVariablesCMP0019(); /** * Replace variables and #cmakedefine lines in the given string. @@ -861,6 +862,13 @@ public: /** Set whether or not to report a CMP0000 violation. */ void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } + typedef cmMakefileIncludeDirectoriesEntry IncludeDirectoriesEntry; + + std::vector<IncludeDirectoriesEntry> GetIncludeDirectoriesEntries() const + { + return this->IncludeDirectoriesEntries; + } + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const char* name, cmTarget& target); @@ -909,6 +917,8 @@ protected: std::vector<std::string> HeaderFileExtensions; std::string DefineFlags; + std::vector<IncludeDirectoriesEntry> IncludeDirectoriesEntries; + // Track the value of the computed DEFINITIONS property. void AddDefineFlag(const char*, std::string&); void RemoveDefineFlag(const char*, std::string::size_type, std::string&); diff --git a/Source/cmMakefileIncludeDirectoriesEntry.h b/Source/cmMakefileIncludeDirectoriesEntry.h new file mode 100644 index 0000000..f35642d --- /dev/null +++ b/Source/cmMakefileIncludeDirectoriesEntry.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2012 Stephen Kelly <steveire@gmail.com> + + 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 cmMakefileIncludeDirectoriesEntry_h +#define cmMakefileIncludeDirectoriesEntry_h + +#include <string> +#include "cmListFileCache.h" + +struct cmMakefileIncludeDirectoriesEntry { + cmMakefileIncludeDirectoriesEntry(const std::string &value, + const cmListFileBacktrace &bt) + : Value(value), Backtrace(bt) + {} + std::string Value; + cmListFileBacktrace Backtrace; +}; + +#endif diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index e7004d6..5b4e4d7 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -19,8 +19,6 @@ #include "cmTarget.h" #include "cmake.h" -#include <memory> // auto_ptr - //---------------------------------------------------------------------------- cmMakefileLibraryTargetGenerator ::cmMakefileLibraryTargetGenerator(cmTarget* target): diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3d02d6a..9bf6b7d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1017,8 +1017,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "SET(CMAKE_TARGET_LINKED_INFO_FILES\n"; std::set<cmTarget const*> emitted; const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); - if(cmComputeLinkInformation* cli = - this->GeneratorTarget->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator @@ -1551,10 +1550,10 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags() this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); - std::vector<std::string>::iterator i; // check all include directories for frameworks as this // will already have added a -F for the framework - for(i = includes.begin(); i != includes.end(); ++i) + for(std::vector<std::string>::iterator i = includes.begin(); + i != includes.end(); ++i) { if(this->Target->NameResolvesToFramework(i->c_str())) { @@ -1566,17 +1565,21 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags() } std::string flags; - std::vector<std::string>& frameworks = this->Target->GetFrameworks(); - for(i = frameworks.begin(); - i != frameworks.end(); ++i) + const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { - if(emitted.insert(*i).second) + std::vector<std::string> const& frameworks = cli->GetFrameworkPaths(); + for(std::vector<std::string>::const_iterator i = frameworks.begin(); + i != frameworks.end(); ++i) { - flags += "-F"; - flags += this->Convert(i->c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL, true); - flags += " "; + if(emitted.insert(*i).second) + { + flags += "-F"; + flags += this->Convert(i->c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL, true); + flags += " "; + } } } return flags; @@ -1594,8 +1597,7 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); - if(cmComputeLinkInformation* cli = - this->GeneratorTarget->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { std::vector<std::string> const& libDeps = cli->GetDepends(); for(std::vector<std::string>::const_iterator j = libDeps.begin(); diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index 27c5b6a..dc0ceb3 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -58,11 +58,11 @@ public: { return " math(EXPR <output variable> <math expression>)\n" - "EXPR evaluates mathematical expression and return result in the " + "EXPR evaluates mathematical expression and returns result in the " "output variable. Example mathematical expression is " "'5 * ( 10 + 13 )'. Supported operators are " "+ - * / % | & ^ ~ << >> * / %. They have the same meaning " - " as they do in c code."; + " as they do in C code."; } cmTypeMacro(cmMathCommand, cmCommand); diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index 9f01eaf..fc61810 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -67,8 +67,9 @@ public: " STATUS = Incidental information\n" " WARNING = CMake Warning, continue processing\n" " AUTHOR_WARNING = CMake Warning (dev), continue processing\n" - " SEND_ERROR = CMake Error, continue but skip generation\n" - " FATAL_ERROR = CMake Error, stop all processing\n" + " SEND_ERROR = CMake Error, continue processing,\n" + " but skip generation\n" + " FATAL_ERROR = CMake Error, stop processing and generation\n" "The CMake command-line tool displays STATUS messages on stdout " "and all other message types on stderr. " "The CMake GUI displays all messages in its log area. " diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 6c54ced..65967a5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -439,6 +439,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetGeneratorTarget()); this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); + vars["LINK_FLAGS"] = cmGlobalNinjaGenerator + ::EncodeLiteral(vars["LINK_FLAGS"]); + vars["LINK_PATH"] = frameworkPath + linkPath; // Compute architecture specific link flags. Yes, these go into a different @@ -564,6 +567,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000; #else + (void)linkRuleLength; commandLineLengthLimit = -1; #endif } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0f10152..15842e4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -257,7 +257,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); + this->Target->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); @@ -423,17 +423,19 @@ cmNinjaTargetGenerator std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + if(useClDeps) + { + std::string cmdPrefix = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " + + clShowPrefix + clBinary; + compileCmds.front().insert(0, cmdPrefix); + } + for (std::vector<std::string>::iterator i = compileCmds.begin(); i != compileCmds.end(); ++i) this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); - std::string cmdLine; - if(useClDeps) - { - cmdLine = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " + - clShowPrefix + clBinary; - } - cmdLine += this->GetLocalGenerator()->BuildCommandLine(compileCmds); + std::string cmdLine = + this->GetLocalGenerator()->BuildCommandLine(compileCmds); // Write the rule for compiling file of the given language. diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 79af4d7..eb7d666 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -457,7 +457,7 @@ cmPolicies::cmPolicies() "This makes sure that the modules belonging to " "CMake always get those files included which they expect, and against " "which they were developed and tested. " - "In call other cases, the files found in " + "In all other cases, the files found in " "CMAKE_MODULE_PATH still take precedence over the ones in " "the CMake module directory. " "The OLD behaviour is to always prefer files from CMAKE_MODULE_PATH over " @@ -491,6 +491,23 @@ cmPolicies::cmPolicies() "CMAKE_SHARED_LIBRARY_<Lang>_FLAGS whether it is modified or not and " "honor the POSITION_INDEPENDENT_CODE target property.", 2,8,9,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0019, "CMP0019", + "Do not re-expand variables in include and link information.", + "CMake 2.8.10 and lower re-evaluated values given to the " + "include_directories, link_directories, and link_libraries " + "commands to expand any leftover variable references at the " + "end of the configuration step. " + "This was for strict compatibility with VERY early CMake versions " + "because all variable references are now normally evaluated during " + "CMake language processing. " + "CMake 2.8.11 and higher prefer to skip the extra evaluation." + "\n" + "The OLD behavior for this policy is to re-evaluate the values " + "for strict compatibility. " + "The NEW behavior for this policy is to leave the values untouched.", + 2,8,11,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 6932565..d7d945c 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -68,6 +68,7 @@ public: CMP0018, ///< Ignore language flags for shared libs, and adhere to /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C} /// instead. + CMP0019, ///< No variable re-expansion in include and link info /** \brief Always the last entry. * diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 25614b8..bf034cf 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -85,6 +85,18 @@ static std::string extractSubDir(const std::string& absPath, } +static void copyTargetProperty(cmTarget* destinationTarget, + cmTarget* sourceTarget, + const char* propertyName) +{ + const char* propertyValue = sourceTarget->GetProperty(propertyName); + if (propertyValue) + { + destinationTarget->SetProperty(propertyName, propertyValue); + } +} + + cmQtAutomoc::cmQtAutomoc() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,ColorOutput(true) @@ -152,9 +164,13 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string automocComment = "Automoc for target "; automocComment += targetName; - makefile->AddUtilityCommand(automocTargetName.c_str(), true, + cmTarget* automocTarget = makefile->AddUtilityCommand( + automocTargetName.c_str(), true, workingDirectory.c_str(), depends, commandLines, false, automocComment.c_str()); + // inherit FOLDER property from target (#13688) + copyTargetProperty(automocTarget, target, "FOLDER"); + target->AddUtility(automocTargetName.c_str()); // configure a file to get all information to automoc at buildtime: @@ -196,36 +212,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } - const char* qtIncDir = 0; - const char* qtCoreIncDir = 0; - - // check whether ${QT_INCLUDE_DIR} is part of the implicit include dirs, - // see http://public.kitware.com/Bug/view.php?id=13667 - bool qtIncludeDirMayHaveBeenRemoved = false; - if (makefile->IsSet("QT_INCLUDE_DIR")) - { - qtIncDir = makefile->GetDefinition("QT_INCLUDE_DIR"); - std::string s = - makefile->GetSafeDefinition("CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES"); - std::vector<std::string> implIncDirs; - cmSystemTools::ExpandListArgument(s, implIncDirs); - if (std::find(implIncDirs.begin(), implIncDirs.end(),std::string(qtIncDir)) - != implIncDirs.end()) - { - qtIncludeDirMayHaveBeenRemoved = true; - if (makefile->IsSet("QT_QTCORE_INCLUDE_DIR")) - { - qtCoreIncDir = makefile->GetDefinition("QT_QTCORE_INCLUDE_DIR"); - } - } - } - - bool haveQtCoreIncDir = false; - bool haveQtIncDir = false; - std::vector<std::string> includeDirs; cmGeneratorTarget gtgt(target); - localGen->GetIncludeDirectories(includeDirs, >gt, "CXX"); + // Get the include dirs for this target, without stripping the implicit + // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 + localGen->GetIncludeDirectories(includeDirs, >gt, "CXX", 0, false); std::string _moc_incs = ""; const char* sep = ""; for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin(); @@ -235,37 +226,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) _moc_incs += sep; sep = ";"; _moc_incs += *incDirIt; - - if (qtIncludeDirMayHaveBeenRemoved && qtCoreIncDir && qtIncDir) // #13667 - { - if (*incDirIt == qtIncDir) - { - haveQtIncDir = true; - qtIncludeDirMayHaveBeenRemoved = false; // it's here, i.e. not removed - } - if (*incDirIt == qtCoreIncDir) - { - haveQtCoreIncDir = true; - } - } - } - - // Some projects (kdelibs, phonon) query the compiler for its default - // include search dirs, and add those to - // CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES. - // These may include e.g./usr/lib/qt/include . This is typically also part - // of ${QT_INCLUDES}. If this directory is then contained in the implicit - // include dirs, it is removed from the include dirs returned from the - // target above. So we add ${QT_INCLUDE_DIR} manually for moc if we detected - // that ${QT_QTCORE_INCLUDE_DIR} is among the include dirs (there shouldn't - // be a way to use Qt4 without using ${QT_QTCORE_INCLUDE_DIR} I think. - // See #13646 and #13667. - if (qtIncludeDirMayHaveBeenRemoved && qtCoreIncDir && qtIncDir - && (haveQtCoreIncDir == true) && (haveQtIncDir == false)) - { - _moc_incs += sep; - sep = ";"; - _moc_incs += qtIncDir; } const char* tmp = target->GetProperty("COMPILE_DEFINITIONS"); diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 65c89fa..9dd7848 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -156,7 +156,9 @@ public: "\n" "The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual " "studio generators. If it is set to 1 the target will not be " - "part of the default build when you select \"Build Solution\"." + "part of the default build when you select \"Build Solution\". " + "This can also be set on a per-configuration basis using " + "EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>." ; } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index cc3b6d6..1d4b0c8 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -458,7 +458,7 @@ void cmSourceFile::DefineProperties(cmake *cm) "A property on a source file that indicates if the source file " "is a header file with no associated implementation. This is " "set automatically based on the file extension and is used by " - "CMake to determine is certain dependency information should be " + "CMake to determine if certain dependency information should be " "computed."); cm->DefineProperty diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 4fd9851..f09976f 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -182,10 +182,6 @@ cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name) std::vector<cmSourceGroup>::iterator end = this->Internal->GroupChildren.end(); - if(this->MatchesRegex(name)) - { - return this; - } for(;iter!=end; ++iter) { cmSourceGroup *result = iter->MatchChildrenRegex(name); @@ -194,6 +190,11 @@ cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name) return result; } } + if(this->MatchesRegex(name)) + { + return this; + } + return 0; } diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 6c87b71..9f6b7e4 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -68,7 +68,7 @@ public: "expression matches the file will be favored.\n" "The name of the group may contain backslashes to specify subgroups:\n" " source_group(outer\\\\inner ...)\n" - "For backwards compatibility, this command is also supports the " + "For backwards compatibility, this command also supports the " "format:\n" " source_group(name regex)"; } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 0193dc9..e49edd8 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -19,6 +19,8 @@ #include <ctype.h> #include <time.h> +#include <cmTimestamp.h> + //---------------------------------------------------------------------------- bool cmStringCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -87,6 +89,10 @@ bool cmStringCommand { return this->HandleFindCommand(args); } + else if(subCommand == "TIMESTAMP") + { + return this->HandleTimestampCommand(args); + } std::string e = "does not recognize sub-command "+subCommand; this->SetError(e.c_str()); @@ -879,3 +885,51 @@ bool cmStringCommand this->Makefile->AddDefinition(variableName.c_str(), &*result.begin()); return true; } + +//---------------------------------------------------------------------------- +bool cmStringCommand +::HandleTimestampCommand(std::vector<std::string> const& args) +{ + if(args.size() < 2) + { + this->SetError("sub-command TIMESTAMP requires at least one argument."); + return false; + } + else if(args.size() > 4) + { + this->SetError("sub-command TIMESTAMP takes at most three arguments."); + return false; + } + + unsigned int argsIndex = 1; + + const std::string &outputVariable = args[argsIndex++]; + + std::string formatString; + if(args.size() > argsIndex && args[argsIndex] != "UTC") + { + formatString = args[argsIndex++]; + } + + bool utcFlag = false; + if(args.size() > argsIndex) + { + if(args[argsIndex] == "UTC") + { + utcFlag = true; + } + else + { + std::string e = " TIMESTAMP sub-command does not recognize option " + + args[argsIndex] + "."; + this->SetError(e.c_str()); + return false; + } + } + + cmTimestamp timestamp; + std::string result = timestamp.CurrentTime(formatString, utcFlag); + this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str()); + + return true; +} diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 728b1bc..4423a90 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -93,6 +93,7 @@ public: " string(RANDOM [LENGTH <length>] [ALPHABET <alphabet>]\n" " [RANDOM_SEED <seed>] <output variable>)\n" " string(FIND <string> <substring> <output variable> [REVERSE])\n" + " string(TIMESTAMP <output variable> [<format string>] [UTC])\n" "REGEX MATCH will match the regular expression once and store the " "match in the output variable.\n" "REGEX MATCHALL will match the regular expression as many times as " @@ -142,7 +143,33 @@ public: " () Saves a matched subexpression, which can be referenced \n" " in the REGEX REPLACE operation. Additionally it is saved\n" " by all regular expression-related commands, including \n" - " e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9)."; + " e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).\n" + "TIMESTAMP will write a string representation of " + "the current date and/or time to the output variable.\n" + "Should the command be unable to obtain a timestamp " + "the output variable will be set to the empty string \"\".\n" + "The optional UTC flag requests the current date/time " + "representation to be in Coordinated Universal Time (UTC) " + "rather than local time.\n" + "The optional <format string> may contain the following " + "format specifiers: \n" + " %d The day of the current month (01-31).\n" + " %H The hour on a 24-hour clock (00-23).\n" + " %I The hour on a 12-hour clock (01-12).\n" + " %j The day of the current year (001-366).\n" + " %m The month of the current year (01-12).\n" + " %M The minute of the current hour (00-59).\n" + " %S The second of the current minute.\n" + " 60 represents a leap second. (00-60)\n" + " %U The week number of the current year (00-53).\n" + " %w The day of the current week. 0 is Sunday. (0-6)\n" + " %y The last two digits of the current year (00-99)\n" + " %Y The current year. \n" + "Unknown format specifiers will be ignored " + "and copied to the output as-is.\n" + "If no explicit <format string> is given it will default to:\n" + " %Y-%m-%dT%H:%M:%S for local time.\n" + " %Y-%m-%dT%H:%M:%SZ for UTC."; } cmTypeMacro(cmStringCommand, cmCommand); @@ -165,6 +192,7 @@ protected: bool HandleStripCommand(std::vector<std::string> const& args); bool HandleRandomCommand(std::vector<std::string> const& args); bool HandleFindCommand(std::vector<std::string> const& args); + bool HandleTimestampCommand(std::vector<std::string> const& args); class RegexReplacement { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 544f7e4..c2521d9 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -52,7 +52,6 @@ #endif #if defined(CMAKE_BUILD_WITH_CMAKE) -# include <memory> // auto_ptr # include <fcntl.h> # include "cmCryptoHash.h" #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f3eb52b..58fab80 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -15,11 +15,13 @@ #include "cmSourceFile.h" #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" +#include "cmComputeLinkInformation.h" #include "cmDocumentCompileDefinitions.h" #include "cmDocumentGeneratorExpressions.h" #include "cmDocumentLocationUndefined.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" +#include "cmGeneratorExpressionDAGChecker.h" #include <cmsys/RegularExpression.hxx> #include <map> #include <set> @@ -117,6 +119,14 @@ public: struct SourceEntry { std::vector<cmSourceFile*> Depends; }; typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; SourceEntriesType SourceEntries; + + struct IncludeDirectoriesEntry { + IncludeDirectoriesEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge) + : ge(cge) + {} + const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; + }; + std::vector<IncludeDirectoriesEntry*> IncludeDirectoriesEntries; }; //---------------------------------------------------------------------------- @@ -266,6 +276,21 @@ void cmTarget::DefineProperties(cmake *cm) "bundle."); cm->DefineProperty + ("EXCLUDE_FROM_DEFAULT_BUILD", cmProperty::TARGET, + "Exclude target from \"Build Solution\".", + "This property is only used by Visual Studio generators 7 and above. " + "When set to TRUE, the target will not be built when you press " + "\"Build Solution\"."); + + cm->DefineProperty + ("EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>", cmProperty::TARGET, + "Per-configuration version of target exclusion from \"Build Solution\". ", + "This is the configuration-specific version of " + "EXCLUDE_FROM_DEFAULT_BUILD. If the generic EXCLUDE_FROM_DEFAULT_BUILD " + "is also set on a target, EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG> takes " + "precedence in configurations for which it has a value."); + + cm->DefineProperty ("FRAMEWORK", cmProperty::TARGET, "This target is a framework on the Mac.", "If a shared library target has this property set to true it will " @@ -651,6 +676,22 @@ void cmTarget::DefineProperties(cmake *cm) "custom Makefile link rules."); cm->DefineProperty + ("LINK_DEPENDS_NO_SHARED", cmProperty::TARGET, + "Do not depend on linked shared library files.", + "Set this property to true to tell CMake generators not to add " + "file-level dependencies on the shared library files linked by " + "this target. " + "Modification to the shared libraries will not be sufficient to " + "re-link this target. " + "Logical target-level dependencies will not be affected so the " + "linked shared libraries will still be brought up to date before " + "this target is built." + "\n" + "This property is initialized by the value of the variable " + "CMAKE_LINK_DEPENDS_NO_SHARED if it is set when a target is " + "created."); + + cm->DefineProperty ("LINK_INTERFACE_LIBRARIES", cmProperty::TARGET, "List public interface libraries for a shared library or executable.", "By default linking to a shared library target transitively " @@ -1314,6 +1355,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); + this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); this->SetPropertyDefault("WIN32_EXECUTABLE", 0); this->SetPropertyDefault("MACOSX_BUNDLE", 0); @@ -1359,8 +1401,14 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - this->SetProperty("INCLUDE_DIRECTORIES", - this->Makefile->GetProperty("INCLUDE_DIRECTORIES")); + const std::vector<cmMakefileIncludeDirectoriesEntry> parentIncludes = + this->Makefile->GetIncludeDirectoriesEntries(); + + for (std::vector<cmMakefileIncludeDirectoriesEntry>::const_iterator it + = parentIncludes.begin(); it != parentIncludes.end(); ++it) + { + this->InsertInclude(*it); + } if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) @@ -1695,9 +1743,10 @@ cmTargetTraceDependencies for(cmCustomCommandLine::const_iterator cli = cit->begin(); cli != cit->end(); ++cli) { - const cmCompiledGeneratorExpression &cge = ge.Parse(*cli); - cge.Evaluate(this->Makefile, 0, true); - std::set<cmTarget*> geTargets = cge.GetTargets(); + const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge + = ge.Parse(*cli); + cge->Evaluate(this->Makefile, 0, true); + std::set<cmTarget*> geTargets = cge->GetTargets(); for(std::set<cmTarget*>::const_iterator it = geTargets.begin(); it != geTargets.end(); ++it) { @@ -2060,26 +2109,6 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) } //---------------------------------------------------------------------------- -bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType) -{ - if(this->NameResolvesToFramework(libname.c_str())) - { - std::string frameworkDir = libname; - frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); - std::vector<std::string>::iterator i = - std::find(this->Frameworks.begin(), - this->Frameworks.end(), frameworkDir); - if(i == this->Frameworks.end()) - { - this->Frameworks.push_back(frameworkDir); - } - return true; - } - return false; -} - -//---------------------------------------------------------------------------- void cmTarget::AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt) @@ -2089,7 +2118,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, { return; } - this->AddFramework(lib, llt); cmTarget::LibraryID tmp; tmp.first = lib; tmp.second = llt; @@ -2433,6 +2461,20 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, } //---------------------------------------------------------------------------- +void deleteAndClear( + std::vector<cmTargetInternals::IncludeDirectoriesEntry*> &entries) +{ + for (std::vector<cmTargetInternals::IncludeDirectoriesEntry*>::const_iterator + it = entries.begin(), + end = entries.end(); + it != end; ++it) + { + delete *it; + } + entries.clear(); +} + +//---------------------------------------------------------------------------- void cmTarget::SetProperty(const char* prop, const char* value) { if (!prop) @@ -2440,6 +2482,17 @@ void cmTarget::SetProperty(const char* prop, const char* value) return; } + if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + deleteAndClear(this->Internal->IncludeDirectoriesEntries); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); + this->Internal->IncludeDirectoriesEntries.push_back( + new cmTargetInternals::IncludeDirectoriesEntry(cge)); + return; + } this->Properties.SetProperty(prop, value, cmProperty::TARGET); this->MaybeInvalidatePropertyCache(prop); } @@ -2452,11 +2505,100 @@ void cmTarget::AppendProperty(const char* prop, const char* value, { return; } + if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->IncludeDirectoriesEntries.push_back( + new cmTargetInternals::IncludeDirectoriesEntry(ge.Parse(value))); + return; + } this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); this->MaybeInvalidatePropertyCache(prop); } //---------------------------------------------------------------------------- +void cmTarget::InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, + bool before) +{ + cmGeneratorExpression ge(entry.Backtrace); + + std::vector<cmTargetInternals::IncludeDirectoriesEntry*>::iterator position + = before ? this->Internal->IncludeDirectoriesEntries.begin() + : this->Internal->IncludeDirectoriesEntries.end(); + + this->Internal->IncludeDirectoriesEntries.insert(position, + new cmTargetInternals::IncludeDirectoriesEntry(ge.Parse(entry.Value))); +} + +//---------------------------------------------------------------------------- +std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) +{ + std::vector<std::string> includes; + std::set<std::string> uniqueIncludes; + cmListFileBacktrace lfbt; + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "INCLUDE_DIRECTORIES", 0, 0); + + + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugIncludes = std::find(debugProperties.begin(), + debugProperties.end(), + "INCLUDE_DIRECTORIES") + != debugProperties.end(); + + for (std::vector<cmTargetInternals::IncludeDirectoriesEntry*>::const_iterator + it = this->Internal->IncludeDirectoriesEntries.begin(), + end = this->Internal->IncludeDirectoriesEntries.end(); + it != end; ++it) + { + std::vector<std::string> entryIncludes; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker), + entryIncludes); + std::string usedIncludes; + for(std::vector<std::string>::const_iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + std::string inc = *li; + if (!cmSystemTools::IsOff(inc.c_str())) + { + cmSystemTools::ConvertToUnixSlashes(inc); + } + + if(uniqueIncludes.insert(inc).second) + { + includes.push_back(*li); + if (debugIncludes) + { + usedIncludes += " * " + *li + "\n"; + } + } + } + if (!usedIncludes.empty()) + { + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, + "Used includes:\n" + usedIncludes, + (*it)->ge->GetBacktrace()); + } + } + return includes; +} + +//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const char* prop) { // Wipe out maps caching information affected by this property. @@ -2783,6 +2925,24 @@ const char *cmTarget::GetProperty(const char* prop, } } } + if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + { + static std::string output; + output = ""; + std::string sep; + typedef cmTargetInternals::IncludeDirectoriesEntry + IncludeDirectoriesEntry; + for (std::vector<IncludeDirectoriesEntry*>::const_iterator + it = this->Internal->IncludeDirectoriesEntries.begin(), + end = this->Internal->IncludeDirectoriesEntries.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } + return output.c_str(); + } if (strcmp(prop,"IMPORTED") == 0) { @@ -4675,14 +4835,24 @@ void cmTarget::ComputeLinkImplementation(const char* config, { continue; } - if(li->second == cmTarget::GENERAL || li->second == linkType) { // The entry is meant for this configuration. impl.Libraries.push_back(item); } - else + } + + LinkLibraryVectorType const& oldllibs = this->GetOriginalLinkLibraries(); + for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); + li != oldllibs.end(); ++li) + { + if(li->second != cmTarget::GENERAL && li->second != linkType) { + std::string item = this->CheckCMP0004(li->first); + if(item == this->GetName() || item.empty()) + { + continue; + } // Support OLD behavior for CMP0003. impl.WrongConfigLibraries.push_back(item); } @@ -4772,6 +4942,32 @@ std::string cmTarget::CheckCMP0004(std::string const& item) } //---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmTarget::GetLinkInformation(const char* config) +{ + // Lookup any existing information for this configuration. + std::map<cmStdString, cmComputeLinkInformation*>::iterator + i = this->LinkInformation.find(config?config:""); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + std::map<cmStdString, cmComputeLinkInformation*>::value_type + entry(config?config:"", info); + i = this->LinkInformation.insert(entry).first; + } + return i->second; +} + +//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const char* config) { std::string fpath; @@ -4829,6 +5025,29 @@ std::string cmTarget::GetMacContentDirectory(const char* config, } //---------------------------------------------------------------------------- +cmTargetLinkInformationMap +::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() +{ + // Ideally cmTarget instances should never be copied. However until + // we can make a sweep to remove that, this copy constructor avoids + // allowing the resources (LinkInformation) from getting copied. In + // the worst case this will lead to extra cmComputeLinkInformation + // instances. We also enforce in debug mode that the map be emptied + // when copied. + static_cast<void>(r); + assert(r.empty()); +} + +//---------------------------------------------------------------------------- +cmTargetLinkInformationMap::~cmTargetLinkInformationMap() +{ + for(derived::iterator i = this->begin(); i != this->end(); ++i) + { + delete i->second; + } +} + +//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; @@ -4847,6 +5066,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { + deleteAndClear(this->Pointer->IncludeDirectoriesEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e442d25..3f36050 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -15,6 +15,7 @@ #include "cmCustomCommand.h" #include "cmPropertyMap.h" #include "cmPolicies.h" +#include "cmMakefileIncludeDirectoriesEntry.h" #include <cmsys/auto_ptr.hxx> @@ -22,8 +23,18 @@ class cmake; class cmMakefile; class cmSourceFile; class cmGlobalGenerator; +class cmComputeLinkInformation; class cmListFileBacktrace; +struct cmTargetLinkInformationMap: + public std::map<cmStdString, cmComputeLinkInformation*> +{ + typedef std::map<cmStdString, cmComputeLinkInformation*> derived; + cmTargetLinkInformationMap() {} + cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); + ~cmTargetLinkInformationMap(); +}; + class cmTargetInternals; class cmTargetInternalPointer { @@ -99,9 +110,6 @@ public: std::vector<cmCustomCommand> &GetPostBuildCommands() {return this->PostBuildCommands;} - ///! Return the list of frameworks being linked to this target - std::vector<std::string> &GetFrameworks() {return this->Frameworks;} - /** * Get the list of the source files used by this target */ @@ -169,7 +177,6 @@ public: // Check to see if a library is a framework and treat it different on Mac bool NameResolvesToFramework(const std::string& libname); - bool AddFramework(const std::string& lib, LinkLibraryType llt); void AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt); @@ -392,6 +399,8 @@ public: std::string GetInstallNameDirForInstallTree(const char* config, bool for_xcode = false); + cmComputeLinkInformation* GetLinkInformation(const char* config); + // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; @@ -462,6 +471,9 @@ public: /** @return the Mac framework directory without the base. */ std::string GetFrameworkDirectory(const char* config = 0); + std::vector<std::string> GetIncludeDirectories(const char *config); + void InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, + bool before = false); private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. @@ -557,7 +569,6 @@ private: LinkLibraryVectorType LinkLibraries; LinkLibraryVectorType PrevLinkedLibraries; bool LinkLibrariesAnalyzed; - std::vector<std::string> Frameworks; std::vector<std::string> LinkDirectories; std::set<cmStdString> LinkDirectoriesEmmitted; bool HaveInstallRule; @@ -584,6 +595,8 @@ private: ImportInfo const* GetImportInfo(const char* config); void ComputeImportInfo(std::string const& desired_config, ImportInfo& info); + cmTargetLinkInformationMap LinkInformation; + bool ComputeLinkInterface(const char* config, LinkInterface& iface); void ComputeLinkImplementation(const char* config, diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 63114d2..8e5823c 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -100,11 +100,11 @@ public: "to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent " "target properties instead of using them for linking. " "Libraries specified as \"debug\" are appended to the " - "the LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " + "LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " "corresponding to configurations listed in the DEBUG_CONFIGURATIONS " "global property if it is set). " "Libraries specified as \"optimized\" are appended to the " - "the LINK_INTERFACE_LIBRARIES property. " + "LINK_INTERFACE_LIBRARIES property. " "Libraries specified as \"general\" (or without any keyword) are " "treated as if specified for both \"debug\" and \"optimized\"." "\n" diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 2f650e7..42f511e 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -112,7 +112,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, else { // Use the command name given. - exe = ge.Parse(exe.c_str()).Evaluate(mf, config); + exe = ge.Parse(exe.c_str())->Evaluate(mf, config); cmSystemTools::ConvertToUnixSlashes(exe); } @@ -122,7 +122,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, for(std::vector<std::string>::const_iterator ci = command.begin()+1; ci != command.end(); ++ci) { - os << " " << lg->EscapeForCMake(ge.Parse(*ci).Evaluate(mf, config)); + os << " " << lg->EscapeForCMake(ge.Parse(*ci)->Evaluate(mf, config)); } // Finish the test command. diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx new file mode 100644 index 0000000..ac26503 --- /dev/null +++ b/Source/cmTimestamp.cxx @@ -0,0 +1,134 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2012 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. +============================================================================*/ +#include "cmTimestamp.h" + +#include <cstring> + +#include <sys/types.h> +#include <sys/stat.h> + +//---------------------------------------------------------------------------- +std::string cmTimestamp::CurrentTime( + const std::string& formatString, bool utcFlag) +{ + time_t currentTimeT = time(0); + if(currentTimeT == time_t(-1)) + { + return std::string(); + } + + return CreateTimestampFromTimeT(currentTimeT, formatString, utcFlag); +} + +//---------------------------------------------------------------------------- +std::string cmTimestamp::FileModificationTime(const char* path, + const std::string& formatString, bool utcFlag) +{ + struct stat info; + memset(&info, 0, sizeof(info)); + + if(stat(path, &info) != 0) + { + return std::string(); + } + + return CreateTimestampFromTimeT(info.st_mtime, formatString, utcFlag); +} + +//---------------------------------------------------------------------------- +std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, + std::string formatString, bool utcFlag) +{ + if(formatString.empty()) + { + formatString = "%Y-%m-%dT%H:%M:%S"; + if(utcFlag) + { + formatString += "Z"; + } + } + + struct tm timeStruct; + memset(&timeStruct, 0, sizeof(timeStruct)); + + struct tm* ptr = (struct tm*) 0; + if(utcFlag) + { + ptr = gmtime(&timeT); + } + else + { + ptr = localtime(&timeT); + } + + if(ptr == 0) + { + return std::string(); + } + + timeStruct = *ptr; + + std::string result; + for(std::string::size_type i = 0; i < formatString.size(); ++i) + { + char c1 = formatString[i]; + char c2 = (i+1 < formatString.size()) ? + formatString[i+1] : static_cast<char>(0); + + if(c1 == '%' && c2 != 0) + { + result += AddTimestampComponent(c2, timeStruct); + ++i; + } + else + { + result += c1; + } + } + + return result; +} + +//---------------------------------------------------------------------------- +std::string cmTimestamp::AddTimestampComponent( + char flag, struct tm& timeStruct) +{ + std::string formatString = "%"; + formatString += flag; + + switch(flag) + { + case 'd': + case 'H': + case 'I': + case 'j': + case 'm': + case 'M': + case 'S': + case 'U': + case 'w': + case 'y': + case 'Y': + break; + default: + { + return formatString; + } + } + + char buffer[16]; + + size_t size = strftime(buffer, sizeof(buffer), + formatString.c_str(), &timeStruct); + + return std::string(buffer, size); +} diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h new file mode 100644 index 0000000..24c1869 --- /dev/null +++ b/Source/cmTimestamp.h @@ -0,0 +1,40 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2012 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 cmTimestamp_h +#define cmTimestamp_h + +#include <string> +#include <time.h> + +/** \class cmTimestamp + * \brief Utility class to generate sting representation of a timestamp + * + */ +class cmTimestamp +{ +public: + cmTimestamp() {} + + std::string CurrentTime(const std::string& formatString, bool utcFlag); + + std::string FileModificationTime(const char* path, + const std::string& formatString, bool utcFlag); + +private: + std::string CreateTimestampFromTimeT(time_t timeT, + std::string formatString, bool utcFlag); + + std::string AddTimestampComponent(char flag, struct tm& timeStruct); +}; + + +#endif diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index 7878729..13b9973 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -81,7 +81,7 @@ public: "the executable, but it will not try to run the executable. Instead it " "will create cache variables which must be filled by the user or by " "presetting them in some CMake script file to the values the " - "executable would have produced if it would have been run on its actual " + "executable would have produced if it had been run on its actual " "target platform. These variables are RUN_RESULT_VAR (explanation see " "above) and if RUN_OUTPUT_VARIABLE (or OUTPUT_VARIABLE) was used, an " "additional cache variable " diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h index c60e8eb..64febbb 100644 --- a/Source/cmVS10LinkFlagTable.h +++ b/Source/cmVS10LinkFlagTable.h @@ -182,8 +182,8 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0}, {"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0}, {"Profile", "PROFILE", "", "true", 0}, - {"DelaySign", "DELAYSIGN:NO", "", "false", 0}, - {"DelaySign", "DELAYSIGN", "", "true", 0}, + {"LinkDelaySign", "DELAYSIGN:NO", "", "false", 0}, + {"LinkDelaySign", "DELAYSIGN", "", "true", 0}, {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0}, {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0}, {"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0}, @@ -294,7 +294,7 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = {"MergeSections", "MERGE:", "Merge Sections", "", cmVS7FlagTable::UserValue}, - {"KeyFile", "KEYFILE:", + {"LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue}, {"KeyContainer", "KEYCONTAINER:", diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1e37ca5..ec9c125 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -109,6 +109,11 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() { delete i->second; } + for(OptionsMap::iterator i = this->LinkOptions.begin(); + i != this->LinkOptions.end(); ++i) + { + delete i->second; + } if(!this->BuildFileStream) { return; @@ -181,6 +186,10 @@ void cmVisualStudio10TargetGenerator::Generate() { return; } + if(!this->ComputeLinkOptions()) + { + return; + } } cmMakefile* mf = this->Target->GetMakefile(); std::string path = mf->GetStartOutputDirectory(); @@ -395,6 +404,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() case cmTarget::UTILITY: configType += "Utility"; break; + case cmTarget::GLOBAL_TARGET: + case cmTarget::UNKNOWN_LIBRARY: + break; } configType += "</ConfigurationType>\n"; this->WriteString(configType.c_str(), 2); @@ -416,8 +428,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() mfcLine += useOfMfcValue + "</UseOfMfc>\n"; this->WriteString(mfcLine.c_str(), 2); - if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && - this->ClOptions[*i]->UsingUnicode() || + if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && + this->ClOptions[*i]->UsingUnicode()) || this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); @@ -898,7 +910,6 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( cmSourceFile* source) { cmSourceFile& sf = *source; - cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string objectName; if(this->GeneratorTarget->ExplicitObjectName.find(&sf) @@ -1077,7 +1088,6 @@ void cmVisualStudio10TargetGenerator:: OutputLinkIncremental(std::string const& configName) { - std::string CONFIG = cmSystemTools::UpperCase(configName); // static libraries and things greater than modules do not need // to set this option if(this->Target->GetType() == cmTarget::STATIC_LIBRARY @@ -1085,72 +1095,36 @@ OutputLinkIncremental(std::string const& configName) { return; } - const char* linkType = "SHARED"; - if(this->Target->GetType() == cmTarget::EXECUTABLE) - { - linkType = "EXE"; - } + Options& linkOptions = *(this->LinkOptions[configName]); - // assume incremental linking - const char* incremental = "true"; - const char* linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); - if(!linkLanguage) - { - cmSystemTools::Error - ("CMake can not determine linker language for target:", - this->Name.c_str()); - return; - } - std::string linkFlagVarBase = "CMAKE_"; - linkFlagVarBase += linkType; - linkFlagVarBase += "_LINKER_FLAGS"; - std::string flags = this-> - Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str()); - std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG; - flags += this-> - Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str()); - if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0 - || strcmp(linkLanguage, "Fortran") == 0) - { - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += linkLanguage; - baseFlagVar += "_FLAGS"; - flags += this-> - Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str()); - std::string flagVar = baseFlagVar + std::string("_") + CONFIG; - flags += - Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); - } - const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS"); - if(targetLinkFlags) - { - flags += " "; - flags += targetLinkFlags; - } - std::string flagsProp = "LINK_FLAGS_"; - flagsProp += CONFIG; - if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str())) - { - flags += " "; - flags += flagsConfig; - } - if(flags.find("INCREMENTAL:NO") != flags.npos) - { - incremental = "false"; - } + const char* incremental = linkOptions.GetFlag("LinkIncremental"); this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3); - *this->BuildFileStream << incremental + *this->BuildFileStream << (incremental?incremental:"true") << "</LinkIncremental>\n"; + linkOptions.RemoveFlag("LinkIncremental"); - const char* manifest = "true"; - if(flags.find("MANIFEST:NO") != flags.npos) - { - manifest = "false"; - } + const char* manifest = linkOptions.GetFlag("GenerateManifest"); this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3); - *this->BuildFileStream << manifest + *this->BuildFileStream << (manifest?manifest:"true") << "</GenerateManifest>\n"; + linkOptions.RemoveFlag("GenerateManifest"); + + // Some link options belong here. Use them now and remove them so that + // WriteLinkOptions does not use them. + const char* flags[] = { + "LinkDelaySign", + "LinkKeyFile", + 0}; + for(const char** f = flags; *f; ++f) + { + const char* flag = *f; + if(const char* value = linkOptions.GetFlag(flag)) + { + this->WritePlatformConfigTag(flag, configName.c_str(), 3); + *this->BuildFileStream << value << "</" << flag << ">\n"; + linkOptions.RemoveFlag(flag); + } + } } //---------------------------------------------------------------------------- @@ -1343,18 +1317,36 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) } } +//---------------------------------------------------------------------------- +bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() +{ + if(this->Target->GetType() == cmTarget::EXECUTABLE || + this->Target->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->GetType() == cmTarget::MODULE_LIBRARY) + { + std::vector<std::string> const* configs = + this->GlobalGenerator->GetConfigurations(); + for(std::vector<std::string>::const_iterator i = configs->begin(); + i != configs->end(); ++i) + { + if(!this->ComputeLinkOptions(*i)) + { + return false; + } + } + } + return true; +} -void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& - config) +//---------------------------------------------------------------------------- +bool +cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) { + cmsys::auto_ptr<Options> pOptions( + new Options(this->LocalGenerator, Options::Linker, + cmVSGetLinkFlagTable(this->LocalGenerator), 0, this)); + Options& linkOptions = *pOptions; - // static libraries and things greater than modules do not need - // to set this option - if(this->Target->GetType() == cmTarget::STATIC_LIBRARY - || this->Target->GetType() > cmTarget::MODULE_LIBRARY) - { - return; - } const char* linkLanguage = this->Target->GetLinkerLanguage(config.c_str()); if(!linkLanguage) @@ -1362,10 +1354,9 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& cmSystemTools::Error ("CMake can not determine linker language for target:", this->Name.c_str()); - return; + return false; } - this->WriteString("<Link>\n", 2); std::string CONFIG = cmSystemTools::UpperCase(config); const char* linkType = "SHARED"; @@ -1387,7 +1378,6 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& flags += " "; flags += stackVal; } - // assume incremental linking std::string linkFlagVarBase = "CMAKE_"; linkFlagVarBase += linkType; linkFlagVarBase += "_LINKER_FLAGS"; @@ -1411,10 +1401,6 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& flags += " "; flags += flagsConfig; } - cmVisualStudioGeneratorOptions - linkOptions(this->LocalGenerator, - cmVisualStudioGeneratorOptions::Linker, - cmVSGetLinkFlagTable(this->LocalGenerator), 0, this); if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) { flags += " /SUBSYSTEM:WINDOWS"; @@ -1423,8 +1409,6 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& { flags += " /SUBSYSTEM:CONSOLE"; } - cmSystemTools::ReplaceString(flags, "/INCREMENTAL:YES", ""); - cmSystemTools::ReplaceString(flags, "/INCREMENTAL:NO", ""); std::string standardLibsVar = "CMAKE_"; standardLibsVar += linkLanguage; standardLibsVar += "_STANDARD_LIBRARIES"; @@ -1446,13 +1430,13 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& // Replace spaces in libs with ; cmSystemTools::ReplaceString(libs, " ", ";"); cmComputeLinkInformation* pcli = - this->GeneratorTarget->GetLinkInformation(config.c_str()); + this->Target->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error ("CMake can not compute cmComputeLinkInformation for target:", this->Name.c_str()); - return; + return false; } // add the libraries for the target to libs string cmComputeLinkInformation& cli = *pcli; @@ -1521,7 +1505,22 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& this->GeneratorTarget->ModuleDefinitionFile.c_str()); } - linkOptions.RemoveFlag("GenerateManifest"); + this->LinkOptions[config] = pOptions.release(); + return true; +} + +//---------------------------------------------------------------------------- +void +cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config) +{ + if(this->Target->GetType() == cmTarget::STATIC_LIBRARY + || this->Target->GetType() > cmTarget::MODULE_LIBRARY) + { + return; + } + Options& linkOptions = *(this->LinkOptions[config]); + this->WriteString("<Link>\n", 2); + linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); linkOptions.OutputFlagMap(*this->BuildFileStream, " "); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 308b9bd..55a850a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -68,6 +68,8 @@ private: std::vector<std::string> const & includes); void WriteRCOptions(std::string const& config, std::vector<std::string> const & includes); + bool ComputeLinkOptions(); + bool ComputeLinkOptions(std::string const& config); void WriteLinkOptions(std::string const& config); void WriteMidlOptions(std::string const& config, std::vector<std::string> const & includes); @@ -95,6 +97,7 @@ private: typedef cmVisualStudioGeneratorOptions Options; typedef std::map<cmStdString, Options*> OptionsMap; OptionsMap ClOptions; + OptionsMap LinkOptions; std::string PathToVcxproj; cmTarget* Target; cmGeneratorTarget* GeneratorTarget; diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx new file mode 100644 index 0000000..b302246 --- /dev/null +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -0,0 +1,175 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 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. +============================================================================*/ +#include "cmVisualStudioWCEPlatformParser.h" +#include "cmGlobalVisualStudioGenerator.h" +#include "cmXMLParser.h" + +int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version) +{ + const std::string registryBase = + cmGlobalVisualStudioGenerator::GetRegistryBase(version); + const std::string vckey = registryBase + "\\Setup\\VC;ProductDir"; + const std::string vskey = registryBase + "\\Setup\\VS;ProductDir"; + + if(!cmSystemTools::ReadRegistryValue(vckey.c_str(), this->VcInstallDir) || + !cmSystemTools::ReadRegistryValue(vskey.c_str(), this->VsInstallDir)) + { + return 0; + } + cmSystemTools::ConvertToUnixSlashes(this->VcInstallDir); + cmSystemTools::ConvertToUnixSlashes(this->VsInstallDir); + this->VcInstallDir.append("/"); + this->VsInstallDir.append("/"); + + const std::string configFilename = + this->VcInstallDir + "vcpackages/WCE.VCPlatform.config"; + + return this->ParseFile(configFilename.c_str()); +} + +std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const +{ + if (this->OSMinorVersion.empty()) + { + return OSMajorVersion; + } + + return OSMajorVersion + "." + OSMinorVersion; +} + +const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const +{ + std::map<std::string, std::string>::const_iterator it = + this->Macros.find("ARCHFAM"); + if (it != this->Macros.end()) + { + return it->second.c_str(); + } + + return 0; +} + +void cmVisualStudioWCEPlatformParser::StartElement(const char* name, + const char** attributes) +{ + if(this->FoundRequiredName) + { + return; + } + + this->CharacterData = ""; + + if(strcmp(name, "PlatformData") == 0) + { + this->PlatformName = ""; + this->OSMajorVersion = ""; + this->OSMinorVersion = ""; + this->Macros.clear(); + } + + if(strcmp(name, "Macro") == 0) + { + std::string macroName; + std::string macroValue; + + for(const char** attr = attributes; *attr; attr += 2) + { + if(strcmp(attr[0], "Name") == 0) + { + macroName = attr[1]; + } + else if(strcmp(attr[0], "Value") == 0) + { + macroValue = attr[1]; + } + } + + if(!macroName.empty()) + { + this->Macros[macroName] = macroValue; + } + } + else if(strcmp(name, "Directories") == 0) + { + for(const char** attr = attributes; *attr; attr += 2) + { + if(strcmp(attr[0], "Include") == 0) + { + this->Include = attr[1]; + } + else if(strcmp(attr[0], "Library") == 0) + { + this->Library = attr[1]; + } + else if(strcmp(attr[0], "Path") == 0) + { + this->Path = attr[1]; + } + } + } +} + +void cmVisualStudioWCEPlatformParser::EndElement(const char* name) +{ + if(!this->RequiredName) + { + if(strcmp(name, "PlatformName") == 0) + { + this->AvailablePlatforms.push_back(this->CharacterData); + } + return; + } + + if(this->FoundRequiredName) + { + return; + } + + if(strcmp(name, "PlatformName") == 0) + { + this->PlatformName = this->CharacterData; + } + else if(strcmp(name, "OSMajorVersion") == 0) + { + this->OSMajorVersion = this->CharacterData; + } + else if(strcmp(name, "OSMinorVersion") == 0) + { + this->OSMinorVersion = this->CharacterData; + } + else if(strcmp(name, "Platform") == 0) + { + if(this->PlatformName == this->RequiredName) + { + this->FoundRequiredName = true; + } + } +} + +void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data, + int length) +{ + this->CharacterData.append(data, length); +} + +std::string cmVisualStudioWCEPlatformParser::FixPaths( + const std::string& paths) const +{ + std::string ret = paths; + cmSystemTools::ReplaceString(ret, "$(PATH)", "%PATH%"); + cmSystemTools::ReplaceString(ret, "$(VCInstallDir)", VcInstallDir.c_str()); + cmSystemTools::ReplaceString(ret, "$(VSInstallDir)", VsInstallDir.c_str()); + cmSystemTools::ReplaceString(ret, "\\", "/"); + cmSystemTools::ReplaceString(ret, "//", "/"); + cmSystemTools::ReplaceString(ret, "/", "\\"); + return ret; +} diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h new file mode 100644 index 0000000..466e1dd --- /dev/null +++ b/Source/cmVisualStudioWCEPlatformParser.h @@ -0,0 +1,68 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 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 cmVisualStudioWCEPlatformParser_h +#define cmVisualStudioWCEPlatformParser_h +#include "cmStandardIncludes.h" + +#include "cmXMLParser.h" + +// This class is used to parse XML with configuration +// of installed SDKs in system +class cmVisualStudioWCEPlatformParser : public cmXMLParser +{ +public: + cmVisualStudioWCEPlatformParser(const char* name = NULL) + : RequiredName(name) + , FoundRequiredName(false) + { + } + + int ParseVersion(const char* version); + + bool Found() const {return this->FoundRequiredName;} + const char* GetArchitectureFamily() const; + std::string GetOSVersion() const; + std::string GetIncludeDirectories() const { + return this->FixPaths(this->Include); } + std::string GetLibraryDirectories() const { + return this->FixPaths(this->Library); } + std::string GetPathDirectories() const { + return this->FixPaths(this->Path); } + const std::vector<std::string>& GetAvailablePlatforms() const { + return this->AvailablePlatforms; } + +protected: + virtual void StartElement(const char* name, const char** attributes); + void EndElement(const char* name); + void CharacterDataHandler(const char* data, int length); + +private: + std::string FixPaths(const std::string& paths) const; + + std::string CharacterData; + + std::string Include; + std::string Library; + std::string Path; + std::string PlatformName; + std::string OSMajorVersion; + std::string OSMinorVersion; + std::map<std::string, std::string> Macros; + std::vector<std::string> AvailablePlatforms; + + const char* RequiredName; + bool FoundRequiredName; + std::string VcInstallDir; + std::string VsInstallDir; +}; + +#endif diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx index 9a536c1..5752ab6 100644 --- a/Source/cmWin32ProcessExecution.cxx +++ b/Source/cmWin32ProcessExecution.cxx @@ -271,13 +271,6 @@ bool cmWin32ProcessExecution::Wait(int timeout) return this->PrivateClose(timeout); } -/* - * Internal dictionary mapping popen* file pointers to process handles, - * for use when retrieving the process exit code. See _PyPclose() below - * for more information on this dictionary's use. - */ -static void *_PyPopenProcs = NULL; - static BOOL RealPopenCreateProcess(const char *cmdstring, const char *path, const char *szConsoleSpawn, @@ -679,18 +672,6 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring, } } - /* - * Insert the files we've created into the process dictionary - * all referencing the list with the process handle and the - * initial number of files (see description below in _PyPclose). - * Since if _PyPclose later tried to wait on a process when all - * handles weren't closed, it could create a deadlock with the - * child, we spend some energy here to try to ensure that we - * either insert all file handles into the dictionary or none - * at all. It's a little clumsy with the various popen modes - * and variable number of files involved. - */ - /* Child is launched. Close the parents copy of those pipe * handles that only the child should have open. You need to * make sure that no handles to the write end of the output pipe @@ -761,43 +742,6 @@ cmWin32ProcessExecution::~cmWin32ProcessExecution() this->CloseHandles(); } -/* - * Wrapper for fclose() to use for popen* files, so we can retrieve the - * exit code for the child process and return as a result of the close. - * - * This function uses the _PyPopenProcs dictionary in order to map the - * input file pointer to information about the process that was - * originally created by the popen* call that created the file pointer. - * The dictionary uses the file pointer as a key (with one entry - * inserted for each file returned by the original popen* call) and a - * single list object as the value for all files from a single call. - * The list object contains the Win32 process handle at [0], and a file - * count at [1], which is initialized to the total number of file - * handles using that list. - * - * This function closes whichever handle it is passed, and decrements - * the file count in the dictionary for the process handle pointed to - * by this file. On the last close (when the file count reaches zero), - * this function will wait for the child process and then return its - * exit code as the result of the close() operation. This permits the - * files to be closed in any order - it is always the close() of the - * final handle that will return the exit code. - */ - - /* RED_FLAG 31-Aug-2000 Tim - * This is always called (today!) between a pair of - * Py_BEGIN_ALLOW_THREADS/ Py_END_ALLOW_THREADS - * macros. So the thread running this has no valid thread state, as - * far as Python is concerned. However, this calls some Python API - * functions that cannot be called safely without a valid thread - * state, in particular PyDict_GetItem. - * As a temporary hack (although it may last for years ...), we - * *rely* on not having a valid thread state in this function, in - * order to create our own "from scratch". - * This will deadlock if _PyPclose is ever called by a thread - * holding the global lock. - */ - bool cmWin32ProcessExecution::PrivateClose(int /* timeout */) { HANDLE hProcess = this->ProcessHandle; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 0123427..a44c825 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -63,15 +63,8 @@ # include "cmGlobalVisualStudio71Generator.h" # include "cmGlobalVisualStudio8Generator.h" # include "cmGlobalVisualStudio9Generator.h" -# include "cmGlobalVisualStudio9IA64Generator.h" -# include "cmGlobalVisualStudio9Win64Generator.h" # include "cmGlobalVisualStudio10Generator.h" -# include "cmGlobalVisualStudio10IA64Generator.h" -# include "cmGlobalVisualStudio10Win64Generator.h" # include "cmGlobalVisualStudio11Generator.h" -# include "cmGlobalVisualStudio11Win64Generator.h" -# include "cmGlobalVisualStudio11ARMGenerator.h" -# include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalJOMMakefileGenerator.h" @@ -89,6 +82,7 @@ #if defined(CMAKE_HAVE_VS_GENERATORS) #include "cmCallVisualStudioMacro.h" +#include "cmVisualStudioWCEPlatformParser.h" #endif #if !defined(CMAKE_BOOT_MINGW) @@ -117,8 +111,6 @@ #include <sys/stat.h> // struct stat -#include <memory> // auto_ptr - static bool cmakeCheckStampFile(const char* stampName); static bool cmakeCheckStampList(const char* stampName); @@ -222,6 +214,11 @@ cmake::~cmake() { delete (*j).second; } + for(RegisteredGeneratorsVector::iterator j = this->Generators.begin(); + j != this->Generators.end(); ++j) + { + delete *j; + } #ifdef CMAKE_BUILD_WITH_CMAKE delete this->VariableWatch; #endif @@ -521,7 +518,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args, // read in the list file to fill the cache if(path) { - std::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); lg->GetMakefile()->SetHomeOutputDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); lg->GetMakefile()->SetStartOutputDirectory @@ -560,7 +557,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) this->SetGlobalGenerator(gg); // read in the list file to fill the cache - std::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); mf->SetHomeOutputDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); @@ -956,7 +953,7 @@ int cmake::AddCMakePaths() cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); cMakeSelf += "/cmake"; cMakeSelf += cmSystemTools::GetExecutableExtension(); -#if __APPLE__ +#ifdef __APPLE__ // on the apple this might be the gui bundle if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { @@ -1147,6 +1144,10 @@ void CMakeCommandUsage(const char* program) << "Available on Windows only:\n" << " comspec - on windows 9x use this for RunCommand\n" << " delete_regv key - delete registry value\n" + << " env_vs8_wince sdkname - displays a batch file which sets the " + "environment for the provided Windows CE SDK installed in VS2005\n" + << " env_vs9_wince sdkname - displays a batch file which sets the " + "environment for the provided Windows CE SDK installed in VS2008\n" << " write_regv key value - write registry value\n" #else << "Available on UNIX only:\n" @@ -1656,7 +1657,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str())) { cm.SetGlobalGenerator(ggd); - std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); lgd->GetMakefile()->SetStartDirectory(startDir.c_str()); lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str()); lgd->GetMakefile()->MakeStartDirectoriesCurrent(); @@ -1812,6 +1813,14 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) } return cmWin32ProcessExecution::Windows9xHack(command.c_str()); } + else if (args[1] == "env_vs8_wince" && args.size() == 3) + { + return cmake::WindowsCEEnvironment("8.0", args[2]); + } + else if (args[1] == "env_vs9_wince" && args.size() == 3) + { + return cmake::WindowsCEEnvironment("9.0", args[2]); + } #endif } @@ -1869,10 +1878,10 @@ void cmake::AddDefaultExtraGenerators() //---------------------------------------------------------------------------- void cmake::GetRegisteredGenerators(std::vector<std::string>& names) { - for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin(); + for(RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(); i != this->Generators.end(); ++i) { - names.push_back(i->first); + (*i)->GetGenerators(names); } for(RegisteredExtraGeneratorsMap::const_iterator i = this->ExtraGenerators.begin(); @@ -1884,29 +1893,36 @@ void cmake::GetRegisteredGenerators(std::vector<std::string>& names) cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) { - cmGlobalGenerator* generator = 0; cmExternalMakefileProjectGenerator* extraGenerator = 0; - RegisteredGeneratorsMap::const_iterator genIt = this->Generators.find(name); - if(genIt == this->Generators.end()) + RegisteredExtraGeneratorsMap::const_iterator extraGenIt = + this->ExtraGenerators.find(name); + if (extraGenIt != this->ExtraGenerators.end()) { - RegisteredExtraGeneratorsMap::const_iterator extraGenIt = - this->ExtraGenerators.find(name); - if (extraGenIt == this->ExtraGenerators.end()) - { - return 0; - } extraGenerator = (extraGenIt->second)(); - genIt=this->Generators.find(extraGenerator->GetGlobalGeneratorName(name)); - if(genIt == this->Generators.end()) + name = extraGenerator->GetGlobalGeneratorName(name); + } + + cmGlobalGenerator* generator = 0; + for (RegisteredGeneratorsVector::const_iterator i = + this->Generators.begin(); i != this->Generators.end(); ++i) + { + generator = (*i)->CreateGlobalGenerator(name); + if (generator) { - delete extraGenerator; - return 0; + break; } - } + } + + if (generator) + { + generator->SetCMakeInstance(this); + generator->SetExternalMakefileProjectGenerator(extraGenerator); + } + else + { + delete extraGenerator; + } - generator = (genIt->second)(); - generator->SetCMakeInstance(this); - generator->SetExternalMakefileProjectGenerator(extraGenerator); return generator; } @@ -2570,55 +2586,41 @@ void cmake::AddDefaultGenerators() { #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) - this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] = - &cmGlobalVisualStudio6Generator::New; - this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] = - &cmGlobalVisualStudio7Generator::New; - this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] = - &cmGlobalVisualStudio10Generator::New; - this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] = - &cmGlobalVisualStudio10IA64Generator::New; - this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] = - &cmGlobalVisualStudio10Win64Generator::New; - this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] = - &cmGlobalVisualStudio11Generator::New; - this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] = - &cmGlobalVisualStudio11Win64Generator::New; - this->Generators[cmGlobalVisualStudio11ARMGenerator::GetActualName()] = - &cmGlobalVisualStudio11ARMGenerator::New; - this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = - &cmGlobalVisualStudio71Generator::New; - this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = - &cmGlobalVisualStudio8Generator::New; - this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] = - &cmGlobalVisualStudio9Generator::New; - this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] = - &cmGlobalVisualStudio9IA64Generator::New; - this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] = - &cmGlobalVisualStudio9Win64Generator::New; - this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] = - &cmGlobalVisualStudio8Win64Generator::New; - this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] = - &cmGlobalBorlandMakefileGenerator::New; - this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] = - &cmGlobalNMakeMakefileGenerator::New; - this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] = - &cmGlobalJOMMakefileGenerator::New; - this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] = - &cmGlobalWatcomWMakeGenerator::New; + this->Generators.push_back( + cmGlobalVisualStudio6Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio7Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio10Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio11Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio71Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio8Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio9Generator::NewFactory()); + this->Generators.push_back( + cmGlobalBorlandMakefileGenerator::NewFactory()); + this->Generators.push_back( + cmGlobalNMakeMakefileGenerator::NewFactory()); + this->Generators.push_back( + cmGlobalJOMMakefileGenerator::NewFactory()); + this->Generators.push_back( + cmGlobalWatcomWMakeGenerator::NewFactory()); # endif - this->Generators[cmGlobalMSYSMakefileGenerator::GetActualName()] = - &cmGlobalMSYSMakefileGenerator::New; - this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] = - &cmGlobalMinGWMakefileGenerator::New; + this->Generators.push_back( + cmGlobalMSYSMakefileGenerator::NewFactory()); + this->Generators.push_back( + cmGlobalMinGWMakefileGenerator::NewFactory()); #endif - this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = - &cmGlobalUnixMakefileGenerator3::New; - this->Generators[cmGlobalNinjaGenerator::GetActualName()] = - &cmGlobalNinjaGenerator::New; + this->Generators.push_back( + cmGlobalUnixMakefileGenerator3::NewFactory()); + this->Generators.push_back( + cmGlobalNinjaGenerator::NewFactory()); #ifdef CMAKE_USE_XCODE - this->Generators[cmGlobalXCodeGenerator::GetActualName()] = - &cmGlobalXCodeGenerator::New; + this->Generators.push_back( + cmGlobalXCodeGenerator::NewFactory()); #endif } @@ -2712,17 +2714,15 @@ void cmake::GetPropertiesDocumentation(std::map<std::string, void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) { - for(RegisteredGeneratorsMap::const_iterator i = this->Generators.begin(); - i != this->Generators.end(); ++i) + for(RegisteredGeneratorsVector::const_iterator i = + this->Generators.begin(); i != this->Generators.end(); ++i) { cmDocumentationEntry e; - cmGlobalGenerator* generator = (i->second)(); - generator->GetDocumentation(e); - delete generator; + (*i)->GetDocumentation(e); v.push_back(e); } - for(RegisteredExtraGeneratorsMap::const_iterator - i = this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i) + for(RegisteredExtraGeneratorsMap::const_iterator i = + this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i) { cmDocumentationEntry e; cmExternalMakefileProjectGenerator* generator = (i->second)(); @@ -2805,7 +2805,7 @@ int cmake::CheckBuildSystem() cmake cm; cmGlobalGenerator gg; gg.SetCMakeInstance(&cm); - std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); if(!mf->ReadListFile(0, this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) @@ -2831,11 +2831,11 @@ int cmake::CheckBuildSystem() } // Create the generator and use it to clear the dependencies. - std::auto_ptr<cmGlobalGenerator> + cmsys::auto_ptr<cmGlobalGenerator> ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { - std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); lgd->ClearDependencies(mf, verbose); } } @@ -3078,7 +3078,7 @@ void cmake::MarkCliAsUsed(const std::string& variable) void cmake::GenerateGraphViz(const char* fileName) const { #ifdef CMAKE_BUILD_WITH_CMAKE - std::auto_ptr<cmGraphVizWriter> gvWriter( + cmsys::auto_ptr<cmGraphVizWriter> gvWriter( new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators())); std::string settingsFile = this->GetHomeOutputDirectory(); @@ -4014,6 +4014,29 @@ static bool cmakeCheckStampList(const char* stampList) return true; } +//---------------------------------------------------------------------------- +int cmake::WindowsCEEnvironment(const char* version, const std::string& name) +{ +#if defined(CMAKE_HAVE_VS_GENERATORS) + cmVisualStudioWCEPlatformParser parser(name.c_str()); + parser.ParseVersion(version); + if (parser.Found()) + { + std::cout << "@echo off" << std::endl; + std::cout << "echo Environment Selection: " << name << std::endl; + std::cout << "set PATH=" << parser.GetPathDirectories() << std::endl; + std::cout << "set INCLUDE=" << parser.GetIncludeDirectories() <<std::endl; + std::cout << "set LIB=" << parser.GetLibraryDirectories() <<std::endl; + return 0; + } +#else + (void)version; +#endif + + std::cerr << "Could not find " << name; + return -1; +} + // For visual studio 2005 and newer manifest files need to be embeded into // exe and dll's. This code does that in such a way that incremental linking // still works. @@ -4477,7 +4500,7 @@ int cmake::Build(const std::string& dir, std::cerr << "Error: could find generator in Cache\n"; return 1; } - std::auto_ptr<cmGlobalGenerator> gen( + cmsys::auto_ptr<cmGlobalGenerator> gen( this->CreateGlobalGenerator(it.GetValue())); std::string output; std::string projName; diff --git a/Source/cmake.h b/Source/cmake.h index 94c6f12..e5aa076 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -17,6 +17,7 @@ #include "cmPropertyDefinitionMap.h" #include "cmPropertyMap.h" +class cmGlobalGeneratorFactory; class cmGlobalGenerator; class cmLocalGenerator; class cmCacheManager; @@ -396,12 +397,9 @@ protected: cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); typedef std::map<cmStdString, CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap; - - typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)(); - typedef std::map<cmStdString, - CreateGeneratorFunctionType> RegisteredGeneratorsMap; + typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector; RegisteredCommandsMap Commands; - RegisteredGeneratorsMap Generators; + RegisteredGeneratorsVector Generators; RegisteredExtraGeneratorsMap ExtraGenerators; void AddDefaultCommands(); void AddDefaultGenerators(); @@ -447,6 +445,8 @@ protected: std::string const& link); static int ExecuteEchoColor(std::vector<std::string>& args); static int ExecuteLinkScript(std::vector<std::string>& args); + static int WindowsCEEnvironment(const char* version, + const std::string& name); static int VisualStudioLink(std::vector<std::string>& args, int type); static int VisualStudioLinkIncremental(std::vector<std::string>& args, int type, diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 34350bf..04dab59 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -237,12 +237,14 @@ int main() { // needed to suppress filename output of msvc tools std::string srcfilename; + { std::string::size_type pos = srcfile.rfind("\\"); if (pos == std::string::npos) { srcfilename = srcfile; } else { srcfilename = srcfile.substr(pos + 1); } + } std::string nol = " /nologo "; std::string show = " /showIncludes "; @@ -266,10 +268,12 @@ int main() { // call cl in object dir so the .i is generated there std::string objdir; + { std::string::size_type pos = objfile.rfind("\\"); if (pos != std::string::npos) { objdir = objfile.substr(0, pos); } + } // extract dependencies with cl.exe int exit_code = process(srcfilename, dfile, objfile, diff --git a/Source/cmw9xcom.cxx b/Source/cmw9xcom.cxx index e6014b3..ab238d5 100644 --- a/Source/cmw9xcom.cxx +++ b/Source/cmw9xcom.cxx @@ -31,14 +31,14 @@ int main (int argc, char *argv[]) int cc; for ( cc = 2; cc < argc; cc ++ ) { - std::string arg = argv[cc]; - if ( (arg.find_first_of(" ") != arg.npos) && - (arg.find_first_of("\"") == arg.npos) ) + std::string nextArg = argv[cc]; + if ( (nextArg.find_first_of(" ") != nextArg.npos) && + (nextArg.find_first_of("\"") == nextArg.npos) ) { - arg = "\"" + arg + "\""; + nextArg = "\"" + nextArg + "\""; } command += " "; - command += arg; + command += nextArg; } return cmWin32ProcessExecution::Windows9xHack(command.c_str()); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index a132357..ccdff12 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -116,7 +116,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_MD5 1) SET(KWSYS_USE_Process 1) SET(KWSYS_USE_RegularExpression 1) - SET(KWSYS_USE_Registry 1) SET(KWSYS_USE_System 1) SET(KWSYS_USE_SystemTools 1) SET(KWSYS_USE_CommandLineArguments 1) @@ -509,19 +508,28 @@ ENDIF(KWSYS_USE_FundamentalType) IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. + SET(KWSYS_PLATFORM_CXX_TEST_DEFINES + -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} + -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) IF(KWSYS_CXX_HAS_LONG_LONG) - SET(KWSYS_PLATFORM_CXX_TEST_DEFINES - -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} - -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM_LONG_LONG "Checking if istream supports long long" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG "Checking if ostream supports long long" DIRECT) - SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) ELSE() SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0) SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0) ENDIF() + IF(KWSYS_CXX_HAS___INT64) + KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM___INT64 + "Checking if istream supports __int64" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM___INT64 + "Checking if ostream supports __int64" DIRECT) + ELSE() + SET(KWSYS_IOS_HAS_ISTREAM___INT64 0) + SET(KWSYS_IOS_HAS_OSTREAM___INT64 0) + ENDIF() + SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) ENDIF(KWSYS_USE_IOStream) IF(KWSYS_NAMESPACE MATCHES "^kwsys$") @@ -566,9 +574,76 @@ IF(KWSYS_USE_SystemTools) ENDIF() IF(KWSYS_USE_SystemInformation) - SET_PROPERTY(SOURCE SystemInformation.cxx PROPERTY - COMPILE_DEFINITIONS KWSYS_USE_LONG_LONG=${KWSYS_USE_LONG_LONG} - KWSYS_USE___INT64=${KWSYS_USE___INT64}) + IF(NOT CYGWIN) + INCLUDE(CheckIncludeFiles) + CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H) + IF(KWSYS_SYS_HAS_IFADDRS_H) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYS_HAS_IFADDRS_H=1) + ENDIF() + ENDIF() + IF(WIN32) + INCLUDE(CheckSymbolExists) + SET(CMAKE_REQUIRED_LIBRARIES Psapi) + CHECK_SYMBOL_EXISTS(GetProcessMemoryInfo "windows.h;psapi.h" KWSYS_SYS_HAS_PSAPI) + UNSET(CMAKE_REQUIRED_LIBRARIES) + IF(KWSYS_SYS_HAS_PSAPI) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYS_HAS_PSAPI=1) + IF(MSVC70 OR MSVC71) + # Suppress LNK4089: all references to 'PSAPI.DLL' discarded by /OPT:REF + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /IGNORE:4089") + ENDIF() + ENDIF() + ENDIF() + IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE) + SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1) + ENDIF() + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_RLIMIT64 + "Checking whether CXX compiler has rlimit64" DIRECT) + SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) + IF(KWSYS_CXX_HAS_RLIMIT64) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_CXX_HAS_RLIMIT64=1) + ENDIF() + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ATOL + "Checking whether CXX compiler has atol" DIRECT) + IF(KWSYS_CXX_HAS_ATOL) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_CXX_HAS_ATOL=1) + ENDIF() + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ATOLL + "Checking whether CXX compiler has atoll" DIRECT) + IF(KWSYS_CXX_HAS_ATOLL) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_CXX_HAS_ATOLL=1) + ENDIF() + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS__ATOI64 + "Checking whether CXX compiler has _atoi64" DIRECT) + IF(KWSYS_CXX_HAS__ATOI64) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1) + ENDIF() + IF(KWSYS_USE___INT64) + SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_USE___INT64=1) + ENDIF() + IF(KWSYS_USE_LONG_LONG) + SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_USE_LONG_LONG=1) + ENDIF() + IF(KWSYS_IOS_HAS_OSTREAM_LONG_LONG) + SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_IOS_HAS_OSTREAM_LONG_LONG=1) + ENDIF() + IF(KWSYS_IOS_HAS_OSTREAM___INT64) + SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_IOS_HAS_OSTREAM___INT64=1) + ENDIF() + IF(KWSYS_BUILD_SHARED) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_BUILD_SHARED=1) + ENDIF() ENDIF() #----------------------------------------------------------------------------- @@ -686,7 +761,7 @@ SET(KWSYS_HXX_FILES Configure String # Add selected C++ classes. SET(cppclasses Directory DynamicLoader Glob RegularExpression SystemTools - CommandLineArguments Registry IOStream SystemInformation + CommandLineArguments IOStream SystemInformation ) FOREACH(cpp ${cppclasses}) IF(KWSYS_USE_${cpp}) @@ -724,12 +799,8 @@ SET(KWSYS_CXX_SRCS) # Add the proper sources for this platform's Process implementation. IF(KWSYS_USE_Process) IF(NOT UNIX) - # Use the Windows implementation. We need the encoded forwarding executable. - SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c - ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c) - SET_SOURCE_FILES_PROPERTIES( - ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - PROPERTIES GENERATED 1) + # Use the Windows implementation. + SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c) ELSE(NOT UNIX) # Use the UNIX implementation. SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c) @@ -802,9 +873,12 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) ENDIF(UNIX) ENDIF(KWSYS_USE_DynamicLoader) - + IF(KWSYS_USE_SystemInformation AND WIN32) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32) + IF(KWSYS_SYS_HAS_PSAPI) + TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} Psapi) + ENDIF() ENDIF(KWSYS_USE_SystemInformation AND WIN32) # Apply user-defined target properties to the library. @@ -842,6 +916,16 @@ ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) # line to configure the namespace in the C and C++ source files. ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}") +# Disable deprecation warnings for standard C functions. +IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")) + ADD_DEFINITIONS( + -D_CRT_NONSTDC_NO_DEPRECATE + -D_CRT_SECURE_NO_DEPRECATE + -D_CRT_SECURE_NO_WARNINGS + -D_SCL_SECURE_NO_DEPRECATE + ) +ENDIF() + IF(KWSYS_USE_String) # Activate code in "String.c". See the comment in the source. SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES @@ -849,43 +933,6 @@ IF(KWSYS_USE_String) ENDIF(KWSYS_USE_String) #----------------------------------------------------------------------------- -# Process execution on windows needs to build a forwarding executable -# that works around a Win9x bug. We encode the executable into a C -# file and build it into the library. Win9x platforms reproduce the -# executable into a temporary directory when it is needed. -IF(KWSYS_USE_Process) - IF(NOT UNIX) - # Build the forwarding executable itself and a program that will - # encode it into a C file. - ADD_EXECUTABLE(${KWSYS_NAMESPACE}ProcessFwd9x ProcessFwd9x.c) - ADD_EXECUTABLE(${KWSYS_NAMESPACE}EncodeExecutable EncodeExecutable.c) - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}ProcessFwd9x PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}EncodeExecutable PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}ProcessFwd9x PROPERTY LABELS ${KWSYS_LABELS_EXE}) - SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}EncodeExecutable PROPERTY LABELS ${KWSYS_LABELS_EXE}) - - SET(CFG_INTDIR "/${CMAKE_CFG_INTDIR}") - IF(CMAKE_BUILD_TOOL MATCHES "make") - SET(CFG_INTDIR "") - ENDIF(CMAKE_BUILD_TOOL MATCHES "make") - - # Take advantage of a better custom command syntax if possible. - SET(CMD ${CMAKE_CURRENT_BINARY_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}EncodeExecutable.exe) - SET(FWD ${CMAKE_CURRENT_BINARY_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}ProcessFwd9x.exe) - ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - COMMAND ${CMD} - ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - ${KWSYS_NAMESPACE} ProcessFwd9x - DEPENDS ${CMD} ${FWD}) - - # Make sure build occurs in proper order. - ADD_DEPENDENCIES(${KWSYS_NAMESPACE} ${KWSYS_NAMESPACE}ProcessFwd9x - ${KWSYS_NAMESPACE}EncodeExecutable) - ENDIF(NOT UNIX) -ENDIF(KWSYS_USE_Process) - -#----------------------------------------------------------------------------- # Setup testing if not being built as part of another project. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) IF(BUILD_TESTING) @@ -923,7 +970,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ) ENDIF(NOT WATCOM) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} - testRegistry testIOS testSystemTools testCommandLineArguments @@ -1027,8 +1073,6 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # We expect test to fail SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON) GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv) - SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR_NOT_VALGRIND;FAIL;Test failed") - SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES PASS_REGULAR_EXPRESSION "Test passed") SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value") MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}") ENDIF() diff --git a/Source/kwsys/CPU.h.in b/Source/kwsys/CPU.h.in index ecd29d1..2e1a584 100644 --- a/Source/kwsys/CPU.h.in +++ b/Source/kwsys/CPU.h.in @@ -98,6 +98,14 @@ #elif defined(__SYSC_ZARCH__) # define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG +/* Aarch64 */ +#elif defined(__aarch64__) +# if !defined(__AARCH64EB__) +# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE +# else +# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG +# endif + /* Unknown CPU */ #else # define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID 0 diff --git a/Source/kwsys/CTestConfig.cmake b/Source/kwsys/CTestConfig.cmake index 9ab6ed8..d977b47 100644 --- a/Source/kwsys/CTestConfig.cmake +++ b/Source/kwsys/CTestConfig.cmake @@ -1,6 +1,6 @@ #============================================================================= # KWSys - Kitware System Library -# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# Copyright 2000-2012 Kitware, Inc., Insight Software Consortium # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -9,10 +9,9 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -set (CTEST_PROJECT_NAME "kwsys") -set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") -set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_PROJECT_NAME "KWSys") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "www.cdash.org") -set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard") set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in index 15986cf..70cf844 100644 --- a/Source/kwsys/Configure.h.in +++ b/Source/kwsys/Configure.h.in @@ -37,20 +37,6 @@ /* Whether kwsys namespace is "kwsys". */ #define @KWSYS_NAMESPACE@_NAME_IS_KWSYS @KWSYS_NAME_IS_KWSYS@ -/* If we are building a kwsys .c or .cxx file, suppress the Microsoft - deprecation warnings. */ -#if defined(KWSYS_NAMESPACE) -# ifndef _CRT_NONSTDC_NO_DEPRECATE -# define _CRT_NONSTDC_NO_DEPRECATE -# endif -# ifndef _CRT_SECURE_NO_DEPRECATE -# define _CRT_SECURE_NO_DEPRECATE -# endif -# ifndef _SCL_SECURE_NO_DEPRECATE -# define _SCL_SECURE_NO_DEPRECATE -# endif -#endif - /* Whether Large File Support is requested. */ #define @KWSYS_NAMESPACE@_LFS_REQUESTED @KWSYS_LFS_REQUESTED@ diff --git a/Source/kwsys/EncodeExecutable.c b/Source/kwsys/EncodeExecutable.c deleted file mode 100644 index bc30568..0000000 --- a/Source/kwsys/EncodeExecutable.c +++ /dev/null @@ -1,114 +0,0 @@ -/*============================================================================ - KWSys - Kitware System Library - Copyright 2000-2009 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. -============================================================================*/ -#include <stdio.h> -#ifdef __WATCOMC__ -#define _unlink unlink -#endif -int main(int argc, char* argv[]) -{ - FILE* ifp; - FILE* ofp; - int i; - int n; - int count = 0; - unsigned char buffer[1024]; - - /* Check arguments. */ - if(argc != 5) - { - fprintf(stderr, "Usage: %s <input> <output> <kwsys-name> <array>\n", - argv[0]); - return 1; - } - - /* Open the input file. */ - ifp = fopen(argv[1], "rb"); - if(!ifp) - { - fprintf(stderr, "Cannot open input file: \"%s\"\n", argv[1]); - return 2; - } - ofp = fopen(argv[2], "w"); - if(!ofp) - { - fprintf(stderr, "Cannot open output file: \"%s\"\n", argv[2]); - fclose(ifp); - return 2; - } - - /* Prepend header comment. */ - fprintf(ofp, "/*\n * DO NOT EDIT\n * This file is generated by:\n"); - fprintf(ofp, " * %s\n */\n\n", argv[0]); - fprintf(ofp, "#include \"kwsysPrivate.h\"\n"); - fprintf(ofp, "#include KWSYS_HEADER(Configure.h)\n\n"); - fprintf(ofp, "#include <stdio.h>\n\n"); - fprintf(ofp, "#if defined(_WIN32)\n"); - fprintf(ofp, "# include <io.h>\n"); - fprintf(ofp, "#else\n"); - fprintf(ofp, "# include <unistd.h>\n"); - fprintf(ofp, "#endif\n"); - fprintf(ofp, "\n"); - fprintf(ofp, "static void kwsys_unlink(const char* fname)\n"); - fprintf(ofp, "{\n"); - fprintf(ofp, "#if defined(__WATCOMC__)\n"); - fprintf(ofp, " unlink(fname);\n"); - fprintf(ofp, "#else\n"); - fprintf(ofp, " _unlink(fname);\n"); - fprintf(ofp, "#endif\n"); - fprintf(ofp, "}\n"); - fprintf(ofp, "\n"); - - /* Split file up in 1024-byte chunks. */ - while((n = (int)fread(buffer, 1, 1024, ifp)) > 0) - { - fprintf(ofp, "static unsigned char kwsysEncodedArray%s_%d[%d] = {\n", - argv[4], count++, n); - for(i=0; i < n-1; ++i) - { - fprintf(ofp, "0x%02X", buffer[i]); - if(i%10 == 9) - { - fprintf(ofp, ",\n"); - } - else - { - fprintf(ofp, ", "); - } - } - fprintf(ofp, "0x%02X};\n\n", buffer[n-1]); - } - fclose(ifp); - - /* Provide a function to write the data to a file. */ - fprintf(ofp, "extern %s_EXPORT int %sEncodedWriteArray%s(const char* fname)\n", - argv[3], argv[3], argv[4]); - fprintf(ofp, "{\n"); - fprintf(ofp, " FILE* ofp = fopen(fname, \"wb\");\n"); - fprintf(ofp, " if(!ofp) { return 0; }\n"); - for(i=0; i < count; ++i) - { - fprintf(ofp, " if(fwrite(kwsysEncodedArray%s_%d, 1,\n" - " sizeof(kwsysEncodedArray%s_%d), ofp) !=\n" - " sizeof(kwsysEncodedArray%s_%d))\n", - argv[4], i, argv[4], i, argv[4], i); - fprintf(ofp, " {\n"); - fprintf(ofp, " fclose(ofp);\n"); - fprintf(ofp, " kwsys_unlink(fname);\n"); - fprintf(ofp, " return 0;\n"); - fprintf(ofp, " }\n"); - } - fprintf(ofp, " fclose(ofp);\n"); - fprintf(ofp, " return 1;\n"); - fprintf(ofp, "}\n"); - fclose(ofp); - return 0; -} diff --git a/Source/kwsys/ProcessFwd9x.c b/Source/kwsys/ProcessFwd9x.c deleted file mode 100644 index 536c54b..0000000 --- a/Source/kwsys/ProcessFwd9x.c +++ /dev/null @@ -1,211 +0,0 @@ -/*============================================================================ - KWSys - Kitware System Library - Copyright 2000-2009 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. -============================================================================*/ - -/* - On Windows9x platforms, this executable is spawned between a parent - process and the child it is invoking to work around a bug. See the - Win32 implementation file for details. - - Future Work: This executable must be linked statically against the C - runtime library before being encoded into the library. Building it - in this way may be hard because CMake has limited abilities to build - different targets with different configurations in the same - directory. We may just have to create and encode the executable - once instead of generating it during the build. This would be an - acceptable solution because the forwarding executable should not - change very often and is pretty simple. -*/ - -#ifdef _MSC_VER -#pragma warning (push, 1) -#endif -#include <windows.h> -#include <stdio.h> - -void ReportLastError(HANDLE errorPipe); - -int main() -{ - /* Process startup information for the real child. */ - STARTUPINFO si; - PROCESS_INFORMATION pi; - - /* The result of waiting for the child to exit. */ - DWORD waitResult; - - /* The child's process return code. */ - DWORD retVal; - - /* The command line used to invoke this process. */ - LPSTR commandLine = GetCommandLine(); - - /* Pointer that will be advanced to the beginning of the command - line of the real child process. */ - LPSTR cmdLine = commandLine; - - /* Handle to the error reporting pipe provided by the parent. This - is parsed off the command line. */ - HANDLE errorPipe = 0; - HANDLE errorPipeOrig = 0; - - /* Handle to the event the parent uses to tell us to resume the child. - This is parsed off the command line. */ - HANDLE resumeEvent = 0; - - /* Handle to the event the parent uses to tell us to kill the child. - This is parsed off the command line. */ - HANDLE killEvent = 0; - - /* Flag for whether to hide window of child process. */ - int hideWindow = 0; - - /* An array of the handles on which we wait when the child is - running. */ - HANDLE waitHandles[2] = {0, 0}; - - /* Move the pointer past the name of this executable. */ - if(*cmdLine == '"') - { - ++cmdLine; - while(*cmdLine && *cmdLine != '"') { ++cmdLine; } - if(*cmdLine) { ++cmdLine; } - } - else - { - while(*cmdLine && *cmdLine != ' ') { ++cmdLine; } - } - - /* Parse the error pipe handle. */ - while(*cmdLine && *cmdLine == ' ') { ++cmdLine; } - sscanf(cmdLine, "%p", &errorPipeOrig); - - /* Parse the resume event handle. */ - while(*cmdLine && *cmdLine != ' ') { ++cmdLine; } - while(*cmdLine && *cmdLine == ' ') { ++cmdLine; } - sscanf(cmdLine, "%p", &resumeEvent); - - /* Parse the kill event handle. */ - while(*cmdLine && *cmdLine != ' ') { ++cmdLine; } - while(*cmdLine && *cmdLine == ' ') { ++cmdLine; } - sscanf(cmdLine, "%p", &killEvent); - - /* Parse the hide window flag. */ - while(*cmdLine && *cmdLine != ' ') { ++cmdLine; } - while(*cmdLine && *cmdLine == ' ') { ++cmdLine; } - sscanf(cmdLine, "%d", &hideWindow); - - /* Skip to the beginning of the command line of the real child. */ - while(*cmdLine && *cmdLine != ' ') { ++cmdLine; } - while(*cmdLine && *cmdLine == ' ') { ++cmdLine; } - - /* Create a non-inherited copy of the error pipe. We do not want - the child to get it. */ - if(DuplicateHandle(GetCurrentProcess(), errorPipeOrig, - GetCurrentProcess(), &errorPipe, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - /* Have a non-inherited duplicate. Close the inherited one. */ - CloseHandle(errorPipeOrig); - } - else - { - /* Could not duplicate handle. Report the error. */ - ReportLastError(errorPipeOrig); - return 1; - } - - /* Create the subprocess. */ - ZeroMemory(&si, sizeof(si)); - ZeroMemory(&pi, sizeof(pi)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; - si.wShowWindow = hideWindow?SW_HIDE:SW_SHOWDEFAULT; - si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - if(CreateProcess(0, cmdLine, 0, 0, TRUE, CREATE_SUSPENDED, 0, 0, &si, &pi)) - { - /* Process created successfully. Close the error reporting pipe - to notify the parent of success. */ - CloseHandle(errorPipe); - } - else - { - /* Error creating the process. Report the error to the parent - process through the special error reporting pipe. */ - ReportLastError(errorPipe); - return 1; - } - - /* Wait for resume or kill event from parent. */ - waitHandles[0] = killEvent; - waitHandles[1] = resumeEvent; - waitResult = WaitForMultipleObjects(2, waitHandles, 0, INFINITE); - - /* Check what happened. */ - if(waitResult == WAIT_OBJECT_0) - { - /* We were asked to kill the child. */ - TerminateProcess(pi.hProcess, 255); - WaitForSingleObject(pi.hProcess, INFINITE); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - return 1; - } - else - { - /* We were asked to resume the child. */ - ResumeThread(pi.hThread); - CloseHandle(pi.hThread); - } - - /* Wait for subprocess to exit or for kill event from parent. */ - waitHandles[0] = killEvent; - waitHandles[1] = pi.hProcess; - waitResult = WaitForMultipleObjects(2, waitHandles, 0, INFINITE); - - /* Check what happened. */ - if(waitResult == WAIT_OBJECT_0) - { - /* We were asked to kill the child. */ - TerminateProcess(pi.hProcess, 255); - WaitForSingleObject(pi.hProcess, INFINITE); - CloseHandle(pi.hProcess); - return 1; - } - else - { - /* The child exited. Get the return code. */ - GetExitCodeProcess(pi.hProcess, &retVal); - CloseHandle(pi.hProcess); - return retVal; - } -} - -void ReportLastError(HANDLE errorPipe) -{ - LPVOID lpMsgBuf; - DWORD n; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - WriteFile(errorPipe, lpMsgBuf, strlen(lpMsgBuf)+1, &n, 0); - LocalFree( lpMsgBuf ); -} diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 9c66a44..1992211 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -2732,6 +2732,7 @@ static void kwsysProcessesSignalHandler(int signum kwsysProcess* cp = kwsysProcesses.Processes[i]; kwsysProcess_ssize_t status= read(cp->PipeReadEnds[KWSYSPE_PIPE_SIGNAL], &buf, 1); + (void)status; status=write(cp->SignalPipe, &buf, 1); (void)status; } diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 5aa4d8b..c836f9b 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -28,14 +28,6 @@ On windows, a thread is created to wait for data on each pipe. The threads are synchronized with the main thread to simulate the use of a UNIX-style select system call. -On Windows9x platforms, a small WIN32 console application is spawned -in-between the calling process and the actual child to be executed. -This is to work-around a problem with connecting pipes from WIN16 -console applications to WIN32 applications. - -For more information, please check Microsoft Knowledge Base Articles -Q190351 and Q150956. - */ #ifdef _MSC_VER @@ -91,18 +83,12 @@ Q190351 and Q150956. # define KWSYSPE_DEBUG(x) (void)1 #endif -#define kwsysEncodedWriteArrayProcessFwd9x kwsys_ns(EncodedWriteArrayProcessFwd9x) - typedef LARGE_INTEGER kwsysProcessTime; typedef struct kwsysProcessCreateInformation_s { /* Windows child startup control data. */ STARTUPINFO StartupInfo; - - /* Special error reporting pipe for Win9x forwarding executable. */ - HANDLE ErrorPipeRead; - HANDLE ErrorPipeWrite; } kwsysProcessCreateInformation; /*--------------------------------------------------------------------------*/ @@ -146,7 +132,6 @@ static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1, kwsysProc static void kwsysProcessSetExitException(kwsysProcess* cp, int code); static void kwsysProcessKillTree(int pid); static void kwsysProcessDisablePipeThreads(kwsysProcess* cp); -extern kwsysEXPORT int kwsysEncodedWriteArrayProcessFwd9x(const char* fname); /*--------------------------------------------------------------------------*/ /* A structure containing synchronization data for each thread. */ @@ -233,15 +218,6 @@ struct kwsysProcess_s /* Whether to treat command lines as verbatim. */ int Verbatim; - /* On Win9x platforms, the path to the forwarding executable. */ - char* Win9x; - - /* On Win9x platforms, the resume event for the forwarding executable. */ - HANDLE Win9xResumeEvent; - - /* On Win9x platforms, the kill event for the forwarding executable. */ - HANDLE Win9xKillEvent; - /* Mutex to protect the shared index used by threads to report data. */ HANDLE SharedIndexMutex; @@ -269,9 +245,6 @@ struct kwsysProcess_s HANDLE PipeNativeSTDOUT[2]; HANDLE PipeNativeSTDERR[2]; - /* Handle to automatically delete the Win9x forwarding executable. */ - HANDLE Win9xHandle; - /* ------------- Data managed per call to Execute ------------- */ /* The exceptional behavior that terminated the process, if any. */ @@ -311,7 +284,7 @@ struct kwsysProcess_s for pipes to close after process termination. */ int PipesLeft; - /* Buffer for error messages (possibly from Win9x child). */ + /* Buffer for error messages. */ char ErrorMessage[KWSYSPE_PIPE_BUFFER_SIZE+1]; /* Description for the ExitException. */ @@ -337,9 +310,6 @@ kwsysProcess* kwsysProcess_New(void) /* Process control structure. */ kwsysProcess* cp; - /* Path to Win9x forwarding executable. */ - char* win9x = 0; - /* Windows version number data. */ OSVERSIONINFO osv; @@ -365,73 +335,11 @@ kwsysProcess* kwsysProcess_New(void) GetVersionEx(&osv); if(osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { - /* This is Win9x. We need the console forwarding executable to - work-around a Windows 9x bug. */ - char fwdName[_MAX_FNAME+1] = ""; - char tempDir[_MAX_PATH+1] = ""; - - /* We will try putting the executable in the system temp - directory. Note that the returned path already has a trailing - slash. */ - DWORD length = GetTempPath(_MAX_PATH+1, tempDir); - - /* Construct the executable name from the process id and kwsysProcess - instance. This should be unique. */ - sprintf(fwdName, KWSYS_NAMESPACE_STRING "pew9xfwd_%ld_%p.exe", - GetCurrentProcessId(), cp); - - /* If we have a temp directory, use it. */ - if(length > 0 && length <= _MAX_PATH) - { - /* Allocate a buffer to hold the forwarding executable path. */ - size_t tdlen = strlen(tempDir); - win9x = (char*)malloc(tdlen + strlen(fwdName) + 2); - if(!win9x) - { - kwsysProcess_Delete(cp); - return 0; - } - - /* Construct the full path to the forwarding executable. */ - sprintf(win9x, "%s%s", tempDir, fwdName); - } - - /* If we found a place to put the forwarding executable, try to - write it. */ - if(win9x) - { - if(!kwsysEncodedWriteArrayProcessFwd9x(win9x)) - { - /* Failed to create forwarding executable. Give up. */ - free(win9x); - kwsysProcess_Delete(cp); - return 0; - } - - /* Get a handle to the file that will delete it when closed. */ - cp->Win9xHandle = CreateFile(win9x, GENERIC_READ, FILE_SHARE_READ, 0, - OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, 0); - if(cp->Win9xHandle == INVALID_HANDLE_VALUE) - { - /* We were not able to get a read handle for the forwarding - executable. It will not be deleted properly. Give up. */ - _unlink(win9x); - free(win9x); - kwsysProcess_Delete(cp); - return 0; - } - } - else - { - /* Failed to find a place to put forwarding executable. */ - kwsysProcess_Delete(cp); - return 0; - } + /* Win9x no longer supported. */ + kwsysProcess_Delete(cp); + return 0; } - /* Save the path to the forwarding executable. */ - cp->Win9x = win9x; - /* Initially no thread owns the mutex. Initialize semaphore to 1. */ if(!(cp->SharedIndexMutex = CreateSemaphore(0, 1, 1, 0))) { @@ -446,30 +354,6 @@ kwsysProcess* kwsysProcess_New(void) return 0; } - if(cp->Win9x) - { - SECURITY_ATTRIBUTES sa; - ZeroMemory(&sa, sizeof(sa)); - sa.nLength = sizeof(sa); - sa.bInheritHandle = TRUE; - - /* Create an event to tell the forwarding executable to resume the - child. */ - if(!(cp->Win9xResumeEvent = CreateEvent(&sa, TRUE, 0, 0))) - { - kwsysProcess_Delete(cp); - return 0; - } - - /* Create an event to tell the forwarding executable to kill the - child. */ - if(!(cp->Win9xKillEvent = CreateEvent(&sa, TRUE, 0, 0))) - { - kwsysProcess_Delete(cp); - return 0; - } - } - /* Create the thread to read each pipe. */ for(i=0; i < KWSYSPE_PIPE_COUNT; ++i) { @@ -620,13 +504,6 @@ void kwsysProcess_Delete(kwsysProcess* cp) kwsysProcessCleanupHandle(&cp->SharedIndexMutex); kwsysProcessCleanupHandle(&cp->Full); - /* Close the Win9x resume and kill event handles. */ - if(cp->Win9x) - { - kwsysProcessCleanupHandle(&cp->Win9xResumeEvent); - kwsysProcessCleanupHandle(&cp->Win9xKillEvent); - } - /* Free memory. */ kwsysProcess_SetCommand(cp, 0); kwsysProcess_SetWorkingDirectory(cp, 0); @@ -637,12 +514,6 @@ void kwsysProcess_Delete(kwsysProcess* cp) { free(cp->CommandExitCodes); } - if(cp->Win9x) - { - /* Close our handle to the forwarding executable file. This will - cause it to be deleted. */ - kwsysProcessCleanupHandle(&cp->Win9xHandle); - } free(cp); } @@ -1017,21 +888,6 @@ void kwsysProcess_Execute(kwsysProcess* cp) SetCurrentDirectory(cp->WorkingDirectory); } - /* Reset the Win9x resume and kill events. */ - if(cp->Win9x) - { - if(!ResetEvent(cp->Win9xResumeEvent)) - { - kwsysProcessCleanup(cp, 1); - return; - } - if(!ResetEvent(cp->Win9xKillEvent)) - { - kwsysProcessCleanup(cp, 1); - return; - } - } - /* Initialize startup info data. */ ZeroMemory(&si, sizeof(si)); si.StartupInfo.cb = sizeof(si.StartupInfo); @@ -1130,8 +986,6 @@ void kwsysProcess_Execute(kwsysProcess* cp) STD_OUTPUT_HANDLE); kwsysProcessCleanupHandleSafe(&si.StartupInfo.hStdError, STD_ERROR_HANDLE); - kwsysProcessCleanupHandle(&si.ErrorPipeRead); - kwsysProcessCleanupHandle(&si.ErrorPipeWrite); return; } } @@ -1160,16 +1014,9 @@ void kwsysProcess_Execute(kwsysProcess* cp) /* All processes in the pipeline have been started in suspended mode. Resume them all now. */ - if(cp->Win9x) - { - SetEvent(cp->Win9xResumeEvent); - } - else + for(i=0; i < cp->NumberOfCommands; ++i) { - for(i=0; i < cp->NumberOfCommands; ++i) - { - ResumeThread(cp->ProcessInformation[i].hThread); - } + ResumeThread(cp->ProcessInformation[i].hThread); } /* ---- It is no longer safe to call kwsysProcessCleanup. ----- */ @@ -1480,21 +1327,12 @@ void kwsysProcess_Kill(kwsysProcess* cp) /* Kill the children. */ cp->Killed = 1; - if(cp->Win9x) - { - /* Windows 9x. Tell the forwarding executable to kill the child. */ - SetEvent(cp->Win9xKillEvent); - } - else + for(i=0; i < cp->NumberOfCommands; ++i) { - /* Not Windows 9x. Just terminate the children. */ - for(i=0; i < cp->NumberOfCommands; ++i) - { - kwsysProcessKillTree(cp->ProcessInformation[i].dwProcessId); - // close the handle if we kill it - kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hThread); - kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hProcess); - } + kwsysProcessKillTree(cp->ProcessInformation[i].dwProcessId); + // close the handle if we kill it + kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hThread); + kwsysProcessCleanupHandle(&cp->ProcessInformation[i].hProcess); } /* We are killing the children and ignoring all data. Do not wait @@ -1815,97 +1653,13 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, } } - /* Create the child process. */ - { - BOOL r; - char* realCommand; - if(cp->Win9x) - { - /* Create an error reporting pipe for the forwarding executable. - Neither end is directly inherited. */ - if(!CreatePipe(&si->ErrorPipeRead, &si->ErrorPipeWrite, 0, 0)) - { - return 0; - } - - /* Create an inherited duplicate of the write end. This also closes - the non-inherited version. */ - if(!DuplicateHandle(GetCurrentProcess(), si->ErrorPipeWrite, - GetCurrentProcess(), &si->ErrorPipeWrite, - 0, TRUE, (DUPLICATE_CLOSE_SOURCE | - DUPLICATE_SAME_ACCESS))) - { - return 0; - } - - /* The forwarding executable is given a handle to the error pipe - and resume and kill events. */ - realCommand = (char*)malloc(strlen(cp->Win9x)+strlen(cp->Commands[index])+100); - if(!realCommand) - { - return 0; - } - sprintf(realCommand, "%s %p %p %p %d %s", cp->Win9x, - si->ErrorPipeWrite, cp->Win9xResumeEvent, cp->Win9xKillEvent, - cp->HideWindow, cp->Commands[index]); - } - else - { - realCommand = cp->Commands[index]; - } - /* Create the child in a suspended state so we can wait until all children have been created before running any one. */ - r = CreateProcess(0, realCommand, 0, 0, TRUE, - cp->Win9x? 0 : CREATE_SUSPENDED, 0, 0, - &si->StartupInfo, &cp->ProcessInformation[index]); - if(cp->Win9x) - { - /* Free memory. */ - free(realCommand); - - /* Close the error pipe write end so we can detect when the - forwarding executable closes it. */ - kwsysProcessCleanupHandle(&si->ErrorPipeWrite); - if(r) - { - /* Wait for the forwarding executable to report an error or - close the error pipe to report success. */ - DWORD total = 0; - DWORD n = 1; - while(total < KWSYSPE_PIPE_BUFFER_SIZE && n > 0) - { - if(ReadFile(si->ErrorPipeRead, cp->ErrorMessage+total, - KWSYSPE_PIPE_BUFFER_SIZE-total, &n, 0)) - { - total += n; - } - else - { - n = 0; - } - } - if(total > 0 || GetLastError() != ERROR_BROKEN_PIPE) - { - /* The forwarding executable could not run the process, or - there was an error reading from its error pipe. Preserve - the last error while cleaning up the forwarding executable - so the cleanup our caller does reports the proper error. */ - DWORD error = GetLastError(); - kwsysProcessCleanupHandle(&cp->ProcessInformation[index].hThread); - kwsysProcessCleanupHandle(&cp->ProcessInformation[index].hProcess); - SetLastError(error); - return 0; - } - } - kwsysProcessCleanupHandle(&si->ErrorPipeRead); - } - - if(!r) + if(!CreateProcess(0, cp->Commands[index], 0, 0, TRUE, CREATE_SUSPENDED, 0, + 0, &si->StartupInfo, &cp->ProcessInformation[index])) { return 0; } - } /* Successfully created this child process. Close the current process's copies of the inherited stdout and stdin handles. The @@ -2152,19 +1906,12 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) /* Cleanup any processes already started in a suspended state. */ if(cp->ProcessInformation) { - if(cp->Win9x) - { - SetEvent(cp->Win9xKillEvent); - } - else + for(i=0; i < cp->NumberOfCommands; ++i) { - for(i=0; i < cp->NumberOfCommands; ++i) + if(cp->ProcessInformation[i].hProcess) { - if(cp->ProcessInformation[i].hProcess) - { - TerminateProcess(cp->ProcessInformation[i].hProcess, 255); - WaitForSingleObject(cp->ProcessInformation[i].hProcess, INFINITE); - } + TerminateProcess(cp->ProcessInformation[i].hProcess, 255); + WaitForSingleObject(cp->ProcessInformation[i].hProcess, INFINITE); } } for(i=0; i < cp->NumberOfCommands; ++i) diff --git a/Source/kwsys/Registry.cxx b/Source/kwsys/Registry.cxx deleted file mode 100644 index cd521c9..0000000 --- a/Source/kwsys/Registry.cxx +++ /dev/null @@ -1,818 +0,0 @@ -/*============================================================================ - KWSys - Kitware System Library - Copyright 2000-2009 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. -============================================================================*/ -#include "kwsysPrivate.h" -#include KWSYS_HEADER(Registry.hxx) - -#include KWSYS_HEADER(Configure.hxx) -#include KWSYS_HEADER(ios/iostream) -#include KWSYS_HEADER(stl/string) -#include KWSYS_HEADER(stl/map) -#include KWSYS_HEADER(ios/iostream) -#include KWSYS_HEADER(ios/fstream) -#include KWSYS_HEADER(ios/sstream) -// Work-around CMake dependency scanning limitation. This must -// duplicate the above list of headers. -#if 0 -# include "Registry.hxx.in" -# include "Configure.hxx.in" -# include "kwsys_stl.hxx.in" -# include "kwsys_stl_string.hxx.in" -# include "kwsys_stl_map.hxx.in" -# include "kwsys_ios_iostream.h.in" -# include "kwsys_ios_fstream.h.in" -# include "kwsys_ios_sstream.h.in" -#endif - -#include <ctype.h> // for isspace -#include <stdio.h> -#include <string.h> /* strlen, strncpy */ -#include <stdlib.h> /* getenv */ - -#ifdef _WIN32 -# include <windows.h> -#endif - - -namespace KWSYS_NAMESPACE -{ -class RegistryHelper { -public: - RegistryHelper(Registry::RegistryType registryType); - virtual ~RegistryHelper(); - - // Read a value from the registry. - virtual bool ReadValue(const char *key, const char **value); - - // Delete a key from the registry. - virtual bool DeleteKey(const char *key); - - // Delete a value from a given key. - virtual bool DeleteValue(const char *key); - - // Set value in a given key. - virtual bool SetValue(const char *key, const char *value); - - // Open the registry at toplevel/subkey. - virtual bool Open(const char *toplevel, const char *subkey, - int readonly); - - // Close the registry. - virtual bool Close(); - - // Set the value of changed - void SetChanged(bool b) { m_Changed = b; } - void SetTopLevel(const char* tl); - const char* GetTopLevel() { return m_TopLevel.c_str(); } - - //! Read from local or global scope. On Windows this mean from local machine - // or local user. On unix this will read from $HOME/.Projectrc or - // /etc/Project - void SetGlobalScope(bool b); - bool GetGlobalScope(); - - kwsys_stl::string EncodeKey(const char* str); - kwsys_stl::string EncodeValue(const char* str); - kwsys_stl::string DecodeValue(const char* str); - -protected: - bool m_Changed; - kwsys_stl::string m_TopLevel; - bool m_GlobalScope; - -#ifdef _WIN32 - HKEY HKey; -#endif - // Strip trailing and ending spaces. - char *Strip(char *str); - void SetSubKey(const char* sk); - kwsys_stl::string CreateKey(const char *key); - - typedef kwsys_stl::map<kwsys_stl::string, kwsys_stl::string> StringToStringMap; - StringToStringMap EntriesMap; - kwsys_stl::string m_SubKey; - bool m_Empty; - bool m_SubKeySpecified; - kwsys_stl::string m_HomeDirectory; - - Registry::RegistryType m_RegistryType; -}; - -//---------------------------------------------------------------------------- -#define Registry_BUFFER_SIZE 8192 - -//---------------------------------------------------------------------------- -Registry::Registry(Registry::RegistryType registryType) -{ - m_Opened = false; - m_Locked = false; - this->Helper = 0; - this->Helper = new RegistryHelper(registryType); -} - -//---------------------------------------------------------------------------- -Registry::~Registry() -{ - if ( m_Opened ) - { - kwsys_ios::cerr << "Registry::Close should be " - "called here. The registry is not closed." - << kwsys_ios::endl; - } - delete this->Helper; -} - -//---------------------------------------------------------------------------- -void Registry::SetGlobalScope(bool b) -{ - this->Helper->SetGlobalScope(b); -} - -//---------------------------------------------------------------------------- -bool Registry::GetGlobalScope() -{ - return this->Helper->GetGlobalScope(); -} - -//---------------------------------------------------------------------------- -bool Registry::Open(const char *toplevel, - const char *subkey, int readonly) -{ - bool res = false; - if ( m_Locked ) - { - return res; - } - if ( m_Opened ) - { - if ( !this->Close() ) - { - return res; - } - } - if ( !toplevel || !*toplevel ) - { - kwsys_ios::cerr << "Registry::Opened() Toplevel not defined" - << kwsys_ios::endl; - return res; - } - - if ( isspace(toplevel[0]) || - isspace(toplevel[strlen(toplevel)-1]) ) - { - kwsys_ios::cerr << "Toplevel has to start with letter or number and end" - " with one" << kwsys_ios::endl; - return res; - } - - res = this->Helper->Open(toplevel, subkey, readonly); - if ( readonly != Registry::READONLY ) - { - m_Locked = true; - } - - if ( res ) - { - m_Opened = true; - this->Helper->SetTopLevel(toplevel); - } - return res; -} - -//---------------------------------------------------------------------------- -bool Registry::Close() -{ - bool res = false; - if ( m_Opened ) - { - res = this->Helper->Close(); - } - - if ( res ) - { - m_Opened = false; - m_Locked = false; - this->Helper->SetChanged(false); - } - return res; -} - -//---------------------------------------------------------------------------- -bool Registry::ReadValue(const char *subkey, - const char *key, - const char **value) -{ - bool res = false; - bool open = false; - if ( ! value ) - { - return res; - } - *value = 0; - if ( !m_Opened ) - { - if ( !this->Open(this->GetTopLevel(), subkey, - Registry::READONLY) ) - { - return res; - } - open = true; - } - res = this->Helper->ReadValue(key, value); - - if ( open ) - { - if ( !this->Close() ) - { - res = false; - } - } - return res; -} - -//---------------------------------------------------------------------------- -bool Registry::DeleteKey(const char *subkey, const char *key) -{ - bool res = false; - bool open = false; - if ( !m_Opened ) - { - if ( !this->Open(this->GetTopLevel(), subkey, - Registry::READWRITE) ) - { - return res; - } - open = true; - } - - res = this->Helper->DeleteKey(key); - if ( res ) - { - this->Helper->SetChanged(true); - } - - if ( open ) - { - if ( !this->Close() ) - { - res = false; - } - } - return res; -} - -//---------------------------------------------------------------------------- -bool Registry::DeleteValue(const char *subkey, const char *key) -{ - bool res = false; - bool open = false; - if ( !m_Opened ) - { - if ( !this->Open(this->GetTopLevel(), subkey, - Registry::READWRITE) ) - { - return res; - } - open = true; - } - - res = this->Helper->DeleteValue(key); - if ( res ) - { - this->Helper->SetChanged(true); - } - - if ( open ) - { - if ( !this->Close() ) - { - res = false; - } - } - return res; -} - -//---------------------------------------------------------------------------- -bool Registry::SetValue(const char *subkey, const char *key, - const char *value) -{ - bool res = false; - bool open = false; - if ( !m_Opened ) - { - if ( !this->Open(this->GetTopLevel(), subkey, - Registry::READWRITE) ) - { - return res; - } - open = true; - } - - res = this->Helper->SetValue( key, value ); - if ( res ) - { - this->Helper->SetChanged(true); - } - - if ( open ) - { - if ( !this->Close() ) - { - res = false; - } - } - return res; -} - -//---------------------------------------------------------------------------- -const char* Registry::GetTopLevel() -{ - return this->Helper->GetTopLevel(); -} - -//---------------------------------------------------------------------------- -void Registry::SetTopLevel(const char* tl) -{ - this->Helper->SetTopLevel(tl); -} - -//---------------------------------------------------------------------------- -void RegistryHelper::SetTopLevel(const char* tl) -{ - if ( tl ) - { - m_TopLevel = tl; - } - else - { - m_TopLevel = ""; - } -} - -//---------------------------------------------------------------------------- -RegistryHelper::RegistryHelper(Registry::RegistryType registryType) -{ - m_Changed = false; - m_TopLevel = ""; - m_SubKey = ""; - m_SubKeySpecified = false; - m_Empty = true; - m_GlobalScope = false; - m_RegistryType = registryType; -} - -//---------------------------------------------------------------------------- -RegistryHelper::~RegistryHelper() -{ -} - - -//---------------------------------------------------------------------------- -bool RegistryHelper::Open(const char *toplevel, const char *subkey, - int readonly) -{ - this->EntriesMap.clear(); - m_Empty = 1; - -#ifdef _WIN32 - if ( m_RegistryType == Registry::WIN32_REGISTRY) - { - HKEY scope = HKEY_CURRENT_USER; - if ( this->GetGlobalScope() ) - { - scope = HKEY_LOCAL_MACHINE; - } - int res = 0; - kwsys_ios::ostringstream str; - DWORD dwDummy; - str << "Software\\Kitware\\" << toplevel << "\\" << subkey; - if ( readonly == Registry::READONLY ) - { - res = ( RegOpenKeyEx(scope, str.str().c_str(), - 0, KEY_READ, &this->HKey) == ERROR_SUCCESS ); - } - else - { - char lpClass[] = ""; - res = ( RegCreateKeyEx(scope, str.str().c_str(), - 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, - NULL, &this->HKey, &dwDummy) == ERROR_SUCCESS ); - } - if ( res != 0 ) - { - this->SetSubKey( subkey ); - } - return (res != 0); - } -#endif - if ( m_RegistryType == Registry::FILE_REGISTRY ) - { - bool res = false; - int cc; - kwsys_ios::ostringstream str; - const char* homeDirectory; - if ( (homeDirectory = getenv("HOME")) == 0 ) - { - if ( (homeDirectory = getenv("USERPROFILE")) == 0 ) - { - return false; - } - } - m_HomeDirectory = homeDirectory; - str << m_HomeDirectory.c_str() << "/." << toplevel << "rc"; - if ( readonly == Registry::READWRITE ) - { - kwsys_ios::ofstream ofs( str.str().c_str(), kwsys_ios::ios::out|kwsys_ios::ios::app ); - if ( ofs.fail() ) - { - return false; - } - ofs.close(); - } - - kwsys_ios::ifstream *ifs = new kwsys_ios::ifstream(str.str().c_str(), kwsys_ios::ios::in -#ifndef KWSYS_IOS_USE_ANSI - | kwsys_ios::ios::nocreate -#endif - ); - if ( !ifs ) - { - return false; - } - if ( ifs->fail()) - { - delete ifs; - return false; - } - - res = true; - char buffer[Registry_BUFFER_SIZE]; - while( !ifs->fail() ) - { - ifs->getline(buffer, Registry_BUFFER_SIZE); - if ( ifs->fail() || ifs->eof() ) - { - break; - } - char *line = this->Strip(buffer); - if ( *line == '#' || *line == 0 ) - { - // Comment - continue; - } - int linelen = static_cast<int>(strlen(line)); - for ( cc = 0; cc < linelen; cc++ ) - { - if ( line[cc] == '=' ) - { - char *key = new char[ cc+1 ]; - strncpy( key, line, cc ); - key[cc] = 0; - char *value = line + cc + 1; - char *nkey = this->Strip(key); - char *nvalue = this->Strip(value); - this->EntriesMap[nkey] = this->DecodeValue(nvalue); - m_Empty = 0; - delete [] key; - break; - } - } - } - ifs->close(); - this->SetSubKey( subkey ); - delete ifs; - return res; - } - return false; -} - -//---------------------------------------------------------------------------- -bool RegistryHelper::Close() -{ -#ifdef _WIN32 - if ( m_RegistryType == Registry::WIN32_REGISTRY) - { - int res; - res = ( RegCloseKey(this->HKey) == ERROR_SUCCESS ); - return (res != 0); - } -#endif - if ( m_RegistryType == Registry::FILE_REGISTRY ) - { - if ( !m_Changed ) - { - this->SetSubKey(0); - return true; - } - - kwsys_ios::ostringstream str; - str << m_HomeDirectory.c_str() << "/." << this->GetTopLevel() << "rc"; - kwsys_ios::ofstream *ofs = new kwsys_ios::ofstream(str.str().c_str(), kwsys_ios::ios::out); - if ( !ofs ) - { - return false; - } - if ( ofs->fail()) - { - delete ofs; - return false; - } - *ofs << "# This file is automatically generated by the application" << kwsys_ios::endl - << "# If you change any lines or add new lines, note that all" << kwsys_ios::endl - << "# comments and empty lines will be deleted. Every line has" << kwsys_ios::endl - << "# to be in format: " << kwsys_ios::endl - << "# key = value" << kwsys_ios::endl - << "#" << kwsys_ios::endl; - - if ( !this->EntriesMap.empty() ) - { - RegistryHelper::StringToStringMap::iterator it; - for ( it = this->EntriesMap.begin(); - it != this->EntriesMap.end(); - ++ it ) - { - *ofs << it->first.c_str() << " = " << this->EncodeValue(it->second.c_str()).c_str() << kwsys_ios::endl; - } - } - this->EntriesMap.clear(); - ofs->close(); - delete ofs; - this->SetSubKey(0); - m_Empty = 1; - return true; - } - return false; -} - -//---------------------------------------------------------------------------- -bool RegistryHelper::ReadValue(const char *skey, const char **value) - -{ -#ifdef _WIN32 - if ( m_RegistryType == Registry::WIN32_REGISTRY) - { - kwsys_stl::string key = this->CreateKey( skey ); - if ( key.empty() ) - { - return false; - } - DWORD dwType, dwSize; - dwType = REG_SZ; - char buffer[1024]; // Replace with RegQueryInfoKey - dwSize = sizeof(buffer); - int res = ( RegQueryValueEx(this->HKey, skey, NULL, &dwType, - (BYTE *)buffer, &dwSize) == ERROR_SUCCESS ); - if ( !res ) - { - return false; - } - this->EntriesMap[key] = buffer; - RegistryHelper::StringToStringMap::iterator it - = this->EntriesMap.find(key); - *value = it->second.c_str(); - return true; - } -#endif - if ( m_RegistryType == Registry::FILE_REGISTRY ) - { - bool res = false; - kwsys_stl::string key = this->CreateKey( skey ); - if ( key.empty() ) - { - return false; - } - - RegistryHelper::StringToStringMap::iterator it - = this->EntriesMap.find(key); - if ( it != this->EntriesMap.end() ) - { - *value = it->second.c_str(); - res = true; - } - return res; - } - return false; -} - -//---------------------------------------------------------------------------- -bool RegistryHelper::DeleteKey(const char* skey) -{ -#ifdef _WIN32 - if ( m_RegistryType == Registry::WIN32_REGISTRY) - { - int res = ( RegDeleteKey( this->HKey, skey ) == ERROR_SUCCESS ); - return (res != 0); - } -#endif - if ( m_RegistryType == Registry::FILE_REGISTRY ) - { - kwsys_stl::string key = this->CreateKey( skey ); - if ( key.empty() ) - { - return false; - } - this->EntriesMap.erase(key); - return true; - } - return false; -} - -//---------------------------------------------------------------------------- -bool RegistryHelper::DeleteValue(const char *skey) -{ -#ifdef _WIN32 - if ( m_RegistryType == Registry::WIN32_REGISTRY) - { - int res = ( RegDeleteValue( this->HKey, skey ) == ERROR_SUCCESS ); - return (res != 0); - } -#endif - if ( m_RegistryType == Registry::FILE_REGISTRY ) - { - kwsys_stl::string key = this->CreateKey( skey ); - if ( key.empty() ) - { - return false; - } - this->EntriesMap.erase(key); - return true; - } - return false; -} - -//---------------------------------------------------------------------------- -bool RegistryHelper::SetValue(const char *skey, const char *value) -{ -#ifdef _WIN32 - if ( m_RegistryType == Registry::WIN32_REGISTRY) - { - DWORD len = (DWORD)(value ? strlen(value) : 0); - int res = ( RegSetValueEx(this->HKey, skey, 0, REG_SZ, - (CONST BYTE *)(const char *)value, - len+1) == ERROR_SUCCESS ); - return (res != 0); - } -#endif - if ( m_RegistryType == Registry::FILE_REGISTRY ) - { - kwsys_stl::string key = this->CreateKey( skey ); - if ( key.empty() ) - { - return 0; - } - this->EntriesMap[key] = value; - return 1; - } - return false; -} - -//---------------------------------------------------------------------------- -kwsys_stl::string RegistryHelper::CreateKey( const char *key ) -{ - if ( !m_SubKeySpecified || m_SubKey.empty() || !key ) - { - return ""; - } - kwsys_ios::ostringstream ostr; - ostr << this->EncodeKey(this->m_SubKey.c_str()).c_str() - << "\\" << this->EncodeKey(key).c_str(); - return ostr.str(); -} - -//---------------------------------------------------------------------------- -void RegistryHelper::SetSubKey(const char* sk) -{ - if ( !sk ) - { - m_SubKey = ""; - m_SubKeySpecified = false; - } - else - { - m_SubKey = sk; - m_SubKeySpecified = true; - } -} - -//---------------------------------------------------------------------------- -char *RegistryHelper::Strip(char *str) -{ - int cc; - size_t len; - char *nstr; - if ( !str ) - { - return NULL; - } - len = strlen(str); - nstr = str; - for( cc=0; cc < static_cast<int>(len); cc++ ) - { - if ( !isspace( *nstr ) ) - { - break; - } - nstr ++; - } - for( cc= static_cast<int>(strlen(nstr))-1; cc>=0; cc-- ) - { - if ( !isspace( nstr[cc] ) ) - { - nstr[cc+1] = 0; - break; - } - } - return nstr; -} - -//---------------------------------------------------------------------------- -void RegistryHelper::SetGlobalScope(bool b) -{ - m_GlobalScope = b; -} - -//---------------------------------------------------------------------------- -bool RegistryHelper::GetGlobalScope() -{ - return m_GlobalScope; -} - -//---------------------------------------------------------------------------- -kwsys_stl::string RegistryHelper::EncodeKey(const char* str) -{ - kwsys_ios::ostringstream ostr; - while ( *str ) - { - switch ( *str ) - { - case '%': case '=': case '\n': case '\r': case '\t': - char buffer[4]; - sprintf(buffer, "%%%02X", *str); - ostr << buffer; - break; - default: - ostr << *str; - } - str ++; - } - return ostr.str(); -} - -//---------------------------------------------------------------------------- -kwsys_stl::string RegistryHelper::EncodeValue(const char* str) -{ - kwsys_ios::ostringstream ostr; - while ( *str ) - { - switch ( *str ) - { - case '%': case '=': case '\n': case '\r': case '\t': - char buffer[4]; - sprintf(buffer, "%%%02X", *str); - ostr << buffer; - break; - default: - ostr << *str; - } - str ++; - } - return ostr.str(); -} - -//---------------------------------------------------------------------------- -kwsys_stl::string RegistryHelper::DecodeValue(const char* str) -{ - kwsys_ios::ostringstream ostr; - while ( *str ) - { - unsigned int val; - switch ( *str ) - { - case '%': - if ( *(str+1) && *(str+2) && sscanf(str+1, "%x", &val) == 1 ) - { - ostr << static_cast<char>(val); - str += 2; - } - else - { - ostr << *str; - } - break; - default: - ostr << *str; - } - str ++; - } - return ostr.str(); -} - -} // namespace KWSYS_NAMESPACE diff --git a/Source/kwsys/Registry.hxx.in b/Source/kwsys/Registry.hxx.in deleted file mode 100644 index ed9b010..0000000 --- a/Source/kwsys/Registry.hxx.in +++ /dev/null @@ -1,107 +0,0 @@ -/*============================================================================ - KWSys - Kitware System Library - Copyright 2000-2009 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 @KWSYS_NAMESPACE@_Registry_hxx -#define @KWSYS_NAMESPACE@_Registry_hxx - -#include <@KWSYS_NAMESPACE@/Configure.h> - -#include <@KWSYS_NAMESPACE@/stl/string> - -namespace @KWSYS_NAMESPACE@ -{ - -class RegistryHelper; - -/** \class Registry - * \brief Portable registry class - * - * This class abstracts the storing of data that can be restored - * when the program executes again. On Win32 platform it is - * implemented using the registry and on unix as a file in - * the user's home directory. - */ -class @KWSYS_NAMESPACE@_EXPORT Registry -{ -public: - enum RegistryType - { -#ifdef _WIN32 - WIN32_REGISTRY, -#endif - FILE_REGISTRY - }; - -#ifdef _WIN32 - Registry(RegistryType registryType = WIN32_REGISTRY); -#else - Registry(RegistryType registryType = FILE_REGISTRY); -#endif - - virtual ~Registry(); - - //! Read a value from the registry. - bool ReadValue(const char *subkey, const char *key, const char **value); - - //! Delete a key from the registry. - bool DeleteKey(const char *subkey, const char *key); - - //! Delete a value from a given key. - bool DeleteValue(const char *subkey, const char *key); - - //! Set value in a given key. - bool SetValue(const char *subkey, const char *key, - const char *value); - - //! Open the registry at toplevel/subkey. - bool Open(const char *toplevel, const char *subkey, - int readonly); - - //! Close the registry. - bool Close(); - - //! Read from local or global scope. On Windows this mean from local machine - // or local user. On unix this will read from $HOME/.Projectrc or - // /etc/Project - void GlobalScopeOn() { this->SetGlobalScope(1); } - void GlobalScopeOff() { this->SetGlobalScope(0); } - void SetGlobalScope(bool b); - bool GetGlobalScope(); - - // Set or get the toplevel registry key. - void SetTopLevel(const char* tl); - const char* GetTopLevel(); - - // Return true if registry opened - bool GetOpened() { return m_Opened; } - - // Should the registry be locked? - bool GetLocked() { return m_Locked; } - - enum { - READONLY, - READWRITE - }; - - // Return true if the character is space. - int IsSpace(char c); - -private: - RegistryHelper* Helper; - - bool m_Opened; - - bool m_Locked; -}; // End Class: Registry - -} // namespace @KWSYS_NAMESPACE@ - -#endif diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index e1ee873..bfdb0ed 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -9,7 +9,12 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ -#ifdef _WIN32 + +#if defined(_WIN32) +# define NOMINMAX // use our min,max +# if !defined(_WIN32_WINNT) && !(defined(_MSC_VER) && _MSC_VER < 1300) +# define _WIN32_WINNT 0x0501 +# endif # include <winsock.h> // WSADATA, include before sys/types.h #endif @@ -33,6 +38,7 @@ #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(ios/sstream) +#include KWSYS_HEADER(ios/fstream) // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. @@ -45,66 +51,142 @@ # include "kwsys_stl_iosfwd.in" # include "kwsys_ios_sstream.h.in" # include "kwsys_ios_iostream.h.in" +# include "kwsys_ios_fstream.h.in" #endif -#ifndef WIN32 +#if defined(_WIN32) +# include <windows.h> +# include <errno.h> +# if defined(KWSYS_SYS_HAS_PSAPI) +# include <psapi.h> +# endif +# if !defined(siginfo_t) +typedef int siginfo_t; +# endif +#else +# include <sys/types.h> +# include <sys/time.h> # include <sys/utsname.h> // int uname(struct utsname *buf); +# include <sys/resource.h> // getrlimit +# include <unistd.h> +# include <signal.h> +# include <fcntl.h> +# include <errno.h> // extern int errno; #endif -#ifdef _WIN32 -# include <windows.h> +#ifdef __FreeBSD__ +# include <sys/sysctl.h> +# include <fenv.h> +# include <sys/socket.h> +# include <netdb.h> +# include <netinet/in.h> +# if defined(KWSYS_SYS_HAS_IFADDRS_H) +# include <ifaddrs.h> +# define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN +# endif #endif #ifdef __APPLE__ -#include <sys/sysctl.h> -#include <mach/vm_statistics.h> -#include <mach/host_info.h> -#include <mach/mach.h> -#include <mach/mach_types.h> +# include <sys/sysctl.h> +# include <mach/vm_statistics.h> +# include <mach/host_info.h> +# include <mach/mach.h> +# include <mach/mach_types.h> +# include <fenv.h> +# include <sys/socket.h> +# include <netdb.h> +# include <netinet/in.h> +# if defined(KWSYS_SYS_HAS_IFADDRS_H) +# include <ifaddrs.h> +# define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN +# endif +# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0 >= 1050 +# include <execinfo.h> +# define KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE +# endif #endif #ifdef __linux -# include <sys/types.h> -# include <unistd.h> -# include <fcntl.h> -# include <ctype.h> // int isdigit(int c); -# include <errno.h> // extern int errno; -# include <sys/time.h> +# include <fenv.h> +# include <sys/socket.h> +# include <netdb.h> +# include <netinet/in.h> +# if defined(KWSYS_SYS_HAS_IFADDRS_H) +# include <ifaddrs.h> +# if !defined(__LSB_VERSION__) /* LSB has no getifaddrs */ +# define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN +# endif +# endif +# if defined(__GNUG__) +# include <execinfo.h> +# if !(defined(__LSB_VERSION__) && __LSB_VERSION__ < 41) +# define KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE +# endif +# endif +# if defined(KWSYS_CXX_HAS_RLIMIT64) +typedef struct rlimit64 ResourceLimitType; +# define GetResourceLimit getrlimit64 +# else +typedef struct rlimit ResourceLimitType; +# define GetResourceLimit getrlimit +# endif #elif defined( __hpux ) # include <sys/param.h> # include <sys/pstat.h> #endif #ifdef __HAIKU__ -#include <OS.h> +# include <OS.h> #endif #include <memory.h> #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <ctype.h> // int isdigit(int c); + +#if defined(KWSYS_USE_LONG_LONG) +# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG) +# define iostreamLongLong(x) (x) +# else +# define iostreamLongLong(x) ((long)x) +# endif +#elif defined(KWSYS_USE___INT64) +# if defined(KWSYS_IOS_HAS_OSTREAM___INT64) +# define iostreamLongLong(x) (x) +# else +# define iostreamLongLong(x) ((long)x) +# endif +#else +# error "No Long Long" +#endif +#if defined(KWSYS_CXX_HAS_ATOLL) +# define atoLongLong atoll +#else +# if defined(KWSYS_CXX_HAS__ATOI64) +# define atoLongLong _atoi64 +# elif defined(KWSYS_CXX_HAS_ATOL) +# define atoLongLong atol +# else +# define atoLongLong atoi +# endif +#endif namespace KWSYS_NAMESPACE { +template<typename T> +T min(T a, T b){ return a<b ? a : b; } -// Create longlong -#if KWSYS_USE_LONG_LONG - typedef long long LongLong; -#elif KWSYS_USE___INT64 - typedef __int64 LongLong; -#else -# error "No Long Long" -#endif - +extern "C" { typedef void (*SigAction)(int,siginfo_t*,void*); } // Define SystemInformationImplementation class typedef void (*DELAY_FUNC)(unsigned int uiMS); - class SystemInformationImplementation { public: + typedef SystemInformation::LongLong LongLong; SystemInformationImplementation (); ~SystemInformationImplementation (); @@ -113,6 +195,7 @@ public: kwsys_stl::string GetTypeID(); kwsys_stl::string GetFamilyID(); kwsys_stl::string GetModelID(); + kwsys_stl::string GetModelName(); kwsys_stl::string GetSteppingCode(); const char * GetExtendedProcessorName(); const char * GetProcessorSerialNumber(); @@ -122,9 +205,10 @@ public: int GetProcessorAPICID(); int GetProcessorCacheXSize(long int); bool DoesCPUSupportFeature(long int); - + const char * GetOSName(); const char * GetHostname(); + int GetFullyQualifiedDomainName(kwsys_stl::string &fqdn); const char * GetOSRelease(); const char * GetOSVersion(); const char * GetOSPlatform(); @@ -140,7 +224,23 @@ public: size_t GetTotalVirtualMemory(); size_t GetAvailableVirtualMemory(); size_t GetTotalPhysicalMemory(); - size_t GetAvailablePhysicalMemory(); + size_t GetAvailablePhysicalMemory(); + + LongLong GetProcessId(); + + // Retrieve memory information in kib + LongLong GetHostMemoryTotal(); + LongLong GetHostMemoryAvailable(const char *envVarName); + LongLong GetHostMemoryUsed(); + + LongLong GetProcMemoryAvailable( + const char *hostLimitEnvVarName, + const char *procLimitEnvVarName); + LongLong GetProcMemoryUsed(); + + // enable/disable stack trace signal handler. + static + void SetStackTraceOnError(int enable); /** Run the different checks */ void RunCPUCheck(); @@ -159,6 +259,7 @@ public: kwsys_stl::string ProcessorName; kwsys_stl::string Vendor; kwsys_stl::string SerialNumber; + kwsys_stl::string ModelName; } ID; typedef struct tagCPUPowerManagement @@ -206,7 +307,7 @@ public: enum Manufacturer { AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM, - Motorola, UnknownManufacturer + Motorola, HP, UnknownManufacturer }; protected: @@ -245,11 +346,11 @@ protected: static void Delay (unsigned int); static void DelayOverhead (unsigned int); - void FindManufacturer(); + void FindManufacturer(const kwsys_stl::string &family = ""); // For Mac bool ParseSysCtl(); - void CallSwVers(); + int CallSwVers(const char *arg, kwsys_stl::string &ver); void TrimNewline(kwsys_stl::string&); kwsys_stl::string ExtractValueFromSysCtl(const char* word); kwsys_stl::string SysCtlBuffer; @@ -281,7 +382,7 @@ protected: kwsys_stl::string Hostname; kwsys_stl::string OSRelease; kwsys_stl::string OSVersion; - kwsys_stl::string OSPlatform; + kwsys_stl::string OSPlatform; }; @@ -320,6 +421,11 @@ kwsys_stl::string SystemInformation::GetModelID() return this->Implementation->GetModelID(); } +kwsys_stl::string SystemInformation::GetModelName() +{ + return this->Implementation->GetModelName(); +} + kwsys_stl::string SystemInformation::GetSteppingCode() { return this->Implementation->GetSteppingCode(); @@ -365,6 +471,37 @@ bool SystemInformation::DoesCPUSupportFeature(long int i) return this->Implementation->DoesCPUSupportFeature(i); } +kwsys_stl::string SystemInformation::GetCPUDescription() +{ + kwsys_ios::ostringstream oss; + oss + << this->GetNumberOfPhysicalCPU() + << " core "; + if (this->GetModelName().empty()) + { + oss + << this->GetProcessorClockFrequency() + << " MHz " + << this->GetVendorString() + << " " + << this->GetExtendedProcessorName(); + } + else + { + oss << this->GetModelName(); + } + + // remove extra spaces + kwsys_stl::string tmp=oss.str(); + size_t pos; + while( (pos=tmp.find(" "))!=kwsys_stl::string::npos) + { + tmp.replace(pos,2," "); + } + + return tmp; +} + const char * SystemInformation::GetOSName() { return this->Implementation->GetOSName(); @@ -375,6 +512,13 @@ const char * SystemInformation::GetHostname() return this->Implementation->GetHostname(); } +kwsys_stl::string SystemInformation::GetFullyQualifiedDomainName() +{ + kwsys_stl::string fqdn; + this->Implementation->GetFullyQualifiedDomainName(fqdn); + return fqdn; +} + const char * SystemInformation::GetOSRelease() { return this->Implementation->GetOSRelease(); @@ -390,6 +534,46 @@ const char * SystemInformation::GetOSPlatform() return this->Implementation->GetOSPlatform(); } +int SystemInformation::GetOSIsWindows() +{ +#if defined(_WIN32) + return 1; +#else + return 0; +#endif +} + +int SystemInformation::GetOSIsLinux() +{ +#if defined(__linux) + return 1; +#else + return 0; +#endif +} + +int SystemInformation::GetOSIsApple() +{ +#if defined(__APPLE__) + return 1; +#else + return 0; +#endif +} + +kwsys_stl::string SystemInformation::GetOSDescription() +{ + kwsys_ios::ostringstream oss; + oss + << this->GetOSName() + << " " + << this->GetOSRelease() + << " " + << this->GetOSVersion(); + + return oss.str(); +} + bool SystemInformation::Is64Bits() { return this->Implementation->Is64Bits(); @@ -431,6 +615,66 @@ size_t SystemInformation::GetAvailablePhysicalMemory() return this->Implementation->GetAvailablePhysicalMemory(); } +kwsys_stl::string SystemInformation::GetMemoryDescription( + const char *hostLimitEnvVarName, + const char *procLimitEnvVarName) +{ + kwsys_ios::ostringstream oss; + oss + << "Host Total: " + << iostreamLongLong(this->GetHostMemoryTotal()) + << " KiB, Host Available: " + << iostreamLongLong(this->GetHostMemoryAvailable(hostLimitEnvVarName)) + << " KiB, Process Available: " + << iostreamLongLong( + this->GetProcMemoryAvailable(hostLimitEnvVarName,procLimitEnvVarName)) + << " KiB"; + return oss.str(); +} + +// host memory info in units of KiB. +SystemInformation::LongLong SystemInformation::GetHostMemoryTotal() +{ + return this->Implementation->GetHostMemoryTotal(); +} + +SystemInformation::LongLong +SystemInformation::GetHostMemoryAvailable(const char *hostLimitEnvVarName) +{ + return this->Implementation->GetHostMemoryAvailable(hostLimitEnvVarName); +} + +SystemInformation::LongLong SystemInformation::GetHostMemoryUsed() +{ + return this->Implementation->GetHostMemoryUsed(); +} + +// process memory info in units of KiB. +SystemInformation::LongLong +SystemInformation::GetProcMemoryAvailable( + const char *hostLimitEnvVarName, + const char *procLimitEnvVarName) +{ + return this->Implementation->GetProcMemoryAvailable( + hostLimitEnvVarName, + procLimitEnvVarName); +} + +SystemInformation::LongLong SystemInformation::GetProcMemoryUsed() +{ + return this->Implementation->GetProcMemoryUsed(); +} + +SystemInformation::LongLong SystemInformation::GetProcessId() +{ + return this->Implementation->GetProcessId(); +} + +void SystemInformation::SetStackTraceOnError(int enable) +{ + SystemInformationImplementation::SetStackTraceOnError(enable); +} + /** Run the different checks */ void SystemInformation::RunCPUCheck() { @@ -501,22 +745,365 @@ void SystemInformation::RunMemoryCheck() #define HT_CANNOT_DETECT 4 // EDX[28] Bit 28 is set if HT is supported -#define HT_BIT 0x10000000 +#define HT_BIT 0x10000000 // EAX[11:8] Bit 8-11 contains family processor ID. #define FAMILY_ID 0x0F00 -#define PENTIUM4_ID 0x0F00 +#define PENTIUM4_ID 0x0F00 // EAX[23:20] Bit 20-23 contains extended family processor ID -#define EXT_FAMILY_ID 0x0F00000 +#define EXT_FAMILY_ID 0x0F00000 // EBX[23:16] Bit 16-23 in ebx contains the number of logical -#define NUM_LOGICAL_BITS 0x00FF0000 -// processors per physical processor when execute cpuid with +#define NUM_LOGICAL_BITS 0x00FF0000 +// processors per physical processor when execute cpuid with // eax set to 1 -// EBX[31:24] Bits 24-31 (8 bits) return the 8-bit unique -#define INITIAL_APIC_ID_BITS 0xFF000000 +// EBX[31:24] Bits 24-31 (8 bits) return the 8-bit unique +#define INITIAL_APIC_ID_BITS 0xFF000000 // initial APIC ID for the processor this code is running on. // Default value = 0xff if HT is not supported +// Hide implementation details in an anonymous namespace. +namespace { +// ***************************************************************************** +#if defined(__linux) || defined(__APPLE__) +int LoadLines( + FILE *file, + kwsys_stl::vector<kwsys_stl::string> &lines) +{ + // Load each line in the given file into a the vector. + int nRead=0; + const int bufSize=1024; + char buf[bufSize]={'\0'}; + while (!feof(file) && !ferror(file)) + { + errno=0; + if (fgets(buf,bufSize,file) == 0) + { + if (ferror(file) && (errno==EINTR)) + { + clearerr(file); + } + continue; + } + lines.push_back(buf); + ++nRead; + } + if (ferror(file)) + { + return 0; + } + return nRead; +} + +# if defined(__linux) +// ***************************************************************************** +int LoadLines( + const char *fileName, + kwsys_stl::vector<kwsys_stl::string> &lines) +{ + FILE *file=fopen(fileName,"r"); + if (file==0) + { + return 0; + } + int nRead=LoadLines(file,lines); + fclose(file); + return nRead; +} +# endif + +// **************************************************************************** +template<typename T> +int NameValue( + kwsys_stl::vector<kwsys_stl::string> &lines, + kwsys_stl::string name, T &value) +{ + size_t nLines=lines.size(); + for (size_t i=0; i<nLines; ++i) + { + size_t at=lines[i].find(name); + if (at==kwsys_stl::string::npos) + { + continue; + } + kwsys_ios::istringstream is(lines[i].substr(at+name.size())); + is >> value; + return 0; + } + return -1; +} +#endif + +#if defined(__linux) +// **************************************************************************** +template<typename T> +int GetFieldsFromFile( + const char *fileName, + const char **fieldNames, + T *values) +{ + kwsys_stl::vector<kwsys_stl::string> fields; + if (!LoadLines(fileName,fields)) + { + return -1; + } + int i=0; + while (fieldNames[i]!=NULL) + { + int ierr=NameValue(fields,fieldNames[i],values[i]); + if (ierr) + { + return -(i+2); + } + i+=1; + } + return 0; +} + +// **************************************************************************** +template<typename T> +int GetFieldFromFile( + const char *fileName, + const char *fieldName, + T &value) +{ + const char *fieldNames[2]={fieldName,NULL}; + T values[1]={T(0)}; + int ierr=GetFieldsFromFile(fileName,fieldNames,values); + if (ierr) + { + return ierr; + } + value=values[0]; + return 0; +} +#endif + +// **************************************************************************** +#if defined(__APPLE__) +template<typename T> +int GetFieldsFromCommand( + const char *command, + const char **fieldNames, + T *values) +{ + FILE *file=popen(command,"r"); + if (file==0) + { + return -1; + } + kwsys_stl::vector<kwsys_stl::string> fields; + int nl=LoadLines(file,fields); + pclose(file); + if (nl==0) + { + return -1; + } + int i=0; + while (fieldNames[i]!=NULL) + { + int ierr=NameValue(fields,fieldNames[i],values[i]); + if (ierr) + { + return -(i+2); + } + i+=1; + } + return 0; +} +#endif + +// **************************************************************************** +#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) +void StacktraceSignalHandler( + int sigNo, + siginfo_t *sigInfo, + void * /*sigContext*/) +{ +#if defined(__linux) || defined(__APPLE__) + kwsys_ios::ostringstream oss; + oss + << "=========================================================" << kwsys_ios::endl + << "Process id " << getpid() << " "; + switch (sigNo) + { + case SIGFPE: + oss << "Caught SIGFPE "; + switch (sigInfo->si_code) + { +# if defined(FPE_INTDIV) + case FPE_INTDIV: + oss << "integer division by zero"; + break; +# endif + +# if defined(FPE_INTOVF) + case FPE_INTOVF: + oss << "integer overflow"; + break; +# endif + + case FPE_FLTDIV: + oss << "floating point divide by zero"; + break; + + case FPE_FLTOVF: + oss << "floating point overflow"; + break; + + case FPE_FLTUND: + oss << "floating point underflow"; + break; + + case FPE_FLTRES: + oss << "floating point inexact result"; + break; + + case FPE_FLTINV: + oss << "floating point invalid operation"; + break; + +#if defined(FPE_FLTSUB) + case FPE_FLTSUB: + oss << "floating point subscript out of range"; + break; +#endif + + default: + oss << "code " << sigInfo->si_code; + break; + } + break; + + case SIGSEGV: + oss << "Caught SIGSEGV "; + switch (sigInfo->si_code) + { + case SEGV_MAPERR: + oss << "address not mapped to object"; + break; + + case SEGV_ACCERR: + oss << "invalid permission for mapped object"; + break; + + default: + oss << "code " << sigInfo->si_code; + break; + } + break; + + case SIGINT: + oss << "Caught SIGTERM"; + break; + + case SIGTERM: + oss << "Caught SIGTERM"; + break; + + case SIGBUS: + oss << "Caught SIGBUS type "; + switch (sigInfo->si_code) + { + case BUS_ADRALN: + oss << "invalid address alignment"; + break; + +# if defined(BUS_ADRERR) + case BUS_ADRERR: + oss << "non-exestent physical address"; + break; +# endif + +# if defined(BUS_OBJERR) + case BUS_OBJERR: + oss << "object specific hardware error"; + break; +# endif + + default: + oss << "code " << sigInfo->si_code; + break; + } + break; + + case SIGILL: + oss << "Caught SIGILL "; + switch (sigInfo->si_code) + { + case ILL_ILLOPC: + oss << "illegal opcode"; + break; + +# if defined(ILL_ILLOPN) + case ILL_ILLOPN: + oss << "illegal operand"; + break; +# endif + +# if defined(ILL_ILLADR) + case ILL_ILLADR: + oss << "illegal addressing mode."; + break; +# endif + + case ILL_ILLTRP: + oss << "illegal trap"; + + case ILL_PRVOPC: + oss << "privileged opcode"; + break; + +# if defined(ILL_PRVREG) + case ILL_PRVREG: + oss << "privileged register"; + break; +# endif + +# if defined(ILL_COPROC) + case ILL_COPROC: + oss << "co-processor error"; + break; +# endif + +# if defined(ILL_BADSTK) + case ILL_BADSTK: + oss << "internal stack error"; + break; +# endif + + default: + oss << "code " << sigInfo->si_code; + break; + } + break; + + default: + oss << "Caught " << sigNo << " code " << sigInfo->si_code; + break; + } + oss << kwsys_ios::endl; +#if defined(KWSYS_SYSTEMINFORMATION_HAVE_BACKTRACE) + oss << "Program Stack:" << kwsys_ios::endl; + void *stackSymbols[128]; + int n=backtrace(stackSymbols,128); + char **stackText=backtrace_symbols(stackSymbols,n); + for (int i=0; i<n; ++i) + { + oss << " " << stackText[i] << kwsys_ios::endl; + } +#endif + oss + << "=========================================================" << kwsys_ios::endl; + kwsys_ios::cerr << oss.str() << kwsys_ios::endl; + abort(); +#else + // avoid warning C4100 + (void)sigNo; + (void)sigInfo; +#endif +} +#endif +} // anonymous namespace SystemInformationImplementation::SystemInformationImplementation() { @@ -557,6 +1144,7 @@ void SystemInformationImplementation::RunCPUCheck() { // Retrieve the CPU details. RetrieveCPUIdentity(); + this->FindManufacturer(); RetrieveCPUFeatures(); } @@ -573,13 +1161,13 @@ void SystemInformationImplementation::RunCPUCheck() if (supportsCPUID) { // Retrieve cache information. - if (!RetrieveCPUCacheDetails()) + if (!RetrieveCPUCacheDetails()) { RetrieveClassicalCPUCacheDetails(); } // Retrieve the extended CPU details. - if (!RetrieveExtendedCPUIdentity()) + if (!RetrieveExtendedCPUIdentity()) { RetrieveClassicalCPUIdentity(); } @@ -641,9 +1229,145 @@ const char * SystemInformationImplementation::GetOSName() /** Get the hostname */ const char* SystemInformationImplementation::GetHostname() { + if (this->Hostname.empty()) + { + this->Hostname="localhost"; +#if defined(_WIN32) + WORD wVersionRequested; + WSADATA wsaData; + char name[255]; + wVersionRequested = MAKEWORD(2,0); + if ( WSAStartup( wVersionRequested, &wsaData ) == 0 ) + { + gethostname(name,sizeof(name)); + WSACleanup( ); + } + this->Hostname = name; +#else + struct utsname unameInfo; + int errorFlag = uname(&unameInfo); + if(errorFlag == 0) + { + this->Hostname = unameInfo.nodename; + } +#endif + } return this->Hostname.c_str(); } +/** Get the FQDN */ +int SystemInformationImplementation::GetFullyQualifiedDomainName( + kwsys_stl::string &fqdn) +{ + // in the event of absolute failure return localhost. + fqdn="localhost"; + +#if defined(_WIN32) + int ierr; + // TODO - a more robust implementation for windows, see comments + // in unix implementation. + WSADATA wsaData; + WORD ver=MAKEWORD(2,0); + ierr=WSAStartup(ver,&wsaData); + if (ierr) + { + return -1; + } + + char base[256]={'\0'}; + ierr=gethostname(base,256); + if (ierr) + { + WSACleanup(); + return -2; + } + fqdn=base; + + HOSTENT *hent=gethostbyname(base); + if (hent) + { + fqdn=hent->h_name; + } + + WSACleanup(); + return 0; + +#elif defined(KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN) + // gethostname typical returns an alias for loopback interface + // we want the fully qualified domain name. Because there are + // any number of interfaces on this system we look for the + // first of these that contains the name returned by gethostname + // and is longer. failing that we return gethostname and indicate + // with a failure code. Return of a failure code is not necessarilly + // an indication of an error. for instance gethostname may return + // the fully qualified domain name, or there may not be one if the + // system lives on a private network such as in the case of a cluster + // node. + + int ierr=0; + char base[NI_MAXHOST]; + ierr=gethostname(base,NI_MAXHOST); + if (ierr) + { + return -1; + } + size_t baseSize=strlen(base); + fqdn=base; + + struct ifaddrs *ifas; + struct ifaddrs *ifa; + ierr=getifaddrs(&ifas); + if (ierr) + { + return -2; + } + + for (ifa=ifas; ifa!=NULL; ifa=ifa->ifa_next) + { + int fam = ifa->ifa_addr? ifa->ifa_addr->sa_family : -1; + if ((fam==AF_INET) || (fam==AF_INET6)) + { + char host[NI_MAXHOST]={'\0'}; + + int addrlen + = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)); + + ierr=getnameinfo( + ifa->ifa_addr, + addrlen, + host, + NI_MAXHOST, + NULL, + 0, + NI_NAMEREQD); + if (ierr) + { + // don't report the failure now since we may succeed on another + // interface. If all attempts fail then return the failure code. + ierr=-3; + continue; + } + + kwsys_stl::string candidate=host; + if ((candidate.find(base)!=kwsys_stl::string::npos) && baseSize<candidate.size()) + { + // success, stop now. + ierr=0; + fqdn=candidate; + break; + } + } + } + freeifaddrs(ifas); + + return ierr; +#else + /* TODO: Implement on more platforms. */ + fqdn=this->GetHostname(); + return -1; +#endif +} + /** Get the OS release */ const char* SystemInformationImplementation::GetOSRelease() { @@ -692,6 +1416,8 @@ const char * SystemInformationImplementation::GetVendorID() return "IBM"; case Motorola: return "Motorola"; + case HP: + return "Hewlett-Packard"; default: return "Unknown Manufacturer"; } @@ -721,9 +1447,15 @@ kwsys_stl::string SystemInformationImplementation::GetModelID() return str.str(); } +// Return the model name of CPU present */ +kwsys_stl::string SystemInformationImplementation::GetModelName() +{ + return this->ChipID.ModelName; +} + /** Return the stepping code of the CPU present. */ kwsys_stl::string SystemInformationImplementation::GetSteppingCode() -{ +{ kwsys_ios::ostringstream str; str << this->ChipID.Revision; return str.str(); @@ -734,8 +1466,8 @@ const char * SystemInformationImplementation::GetExtendedProcessorName() { return this->ChipID.ProcessorName.c_str(); } - -/** Return the serial number of the processor + +/** Return the serial number of the processor * in hexadecimal: xxxx-xxxx-xxxx-xxxx-xxxx-xxxx. */ const char * SystemInformationImplementation::GetProcessorSerialNumber() { @@ -870,7 +1602,7 @@ void SystemInformationImplementation::Delay(unsigned int uiMS) QueryPerformanceCounter (&StartCounter); do { - // Get the ending position of the counter. + // Get the ending position of the counter. QueryPerformanceCounter (&EndCounter); } while (EndCounter.QuadPart - StartCounter.QuadPart < x); #endif @@ -893,7 +1625,7 @@ bool SystemInformationImplementation::DoesCPUSupportCPUID() push ecx push edx #endif - ; <<CPUID>> + ; <<CPUID>> mov eax, 0 CPUID_INSTRUCTION @@ -905,7 +1637,7 @@ bool SystemInformationImplementation::DoesCPUSupportCPUID() #endif } } - __except(1) + __except(1) { // Stop the class from trying to use CPUID again! return false; @@ -939,9 +1671,9 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() push ecx push edx #endif - ; <<CPUID>> + ; <<CPUID>> ; eax = 1 --> eax: CPU ID - bits 31..16 - unused, bits 15..12 - type, bits 11..8 - family, bits 7..4 - model, bits 3..0 - mask revision - ; ebx: 31..24 - default APIC ID, 23..16 - logical processsor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID + ; ebx: 31..24 - default APIC ID, 23..16 - logical processor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID ; edx: CPU feature flags mov eax,1 CPUID_INSTRUCTION @@ -956,7 +1688,7 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() #endif } } - __except(1) + __except(1) { return false; } @@ -977,39 +1709,39 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() // Retrieve extended SSE capabilities if SSE is available. if (this->Features.HasSSE) { - + // Attempt to __try some SSE FP instructions. - __try + __try { // Perform: orps xmm0, xmm0 - _asm + _asm { _emit 0x0f _emit 0x56 - _emit 0xc0 + _emit 0xc0 } // SSE FP capable processor. this->Features.HasSSEFP = true; - } - __except(1) + } + __except(1) { // bad instruction - processor or OS cannot handle SSE FP. this->Features.HasSSEFP = false; } - } - else + } + else { // Set the advanced SSE capabilities to not available. this->Features.HasSSEFP = false; } // Retrieve Intel specific extended features. - if (this->ChipManufacturer == Intel) + if (this->ChipManufacturer == Intel) { this->Features.ExtendedFeatures.SupportsHyperthreading = ((localCPUFeatures & 0x10000000) != 0); // Intel specific: Hyperthreading --> Bit 28 this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = (this->Features.ExtendedFeatures.SupportsHyperthreading) ? ((localCPUAdvanced & 0x00FF0000) >> 16) : 1; - + if ((this->Features.ExtendedFeatures.SupportsHyperthreading) && (this->Features.HasAPIC)) { // Retrieve APIC information if there is one present. @@ -1026,7 +1758,7 @@ bool SystemInformationImplementation::RetrieveCPUFeatures() /** Find the manufacturer given the vendor id */ -void SystemInformationImplementation::FindManufacturer() +void SystemInformationImplementation::FindManufacturer(const kwsys_stl::string& family) { if (this->ChipID.Vendor == "GenuineIntel") this->ChipManufacturer = Intel; // Intel Corp. else if (this->ChipID.Vendor == "UMC UMC UMC ") this->ChipManufacturer = UMC; // United Microelectronics Corp. @@ -1042,6 +1774,7 @@ void SystemInformationImplementation::FindManufacturer() else if (this->ChipID.Vendor == "Sun") this->ChipManufacturer = Sun; // Sun Microelectronics else if (this->ChipID.Vendor == "IBM") this->ChipManufacturer = IBM; // IBM Microelectronics else if (this->ChipID.Vendor == "Motorola") this->ChipManufacturer = Motorola; // Motorola Microelectronics + else if (family.substr(0, 7) == "PA-RISC") this->ChipManufacturer = HP; // Hewlett-Packard else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer } @@ -1054,9 +1787,9 @@ bool SystemInformationImplementation::RetrieveCPUIdentity() int localCPUSignature; // Use assembly to detect CPUID information... - __try + __try { - _asm + _asm { #ifdef CPUID_AWARE_COMPILER ; we must push/pop the registers <<CPUID>> writes to, as the @@ -1078,9 +1811,9 @@ bool SystemInformationImplementation::RetrieveCPUIdentity() mov localCPUVendor[1 * TYPE int], edx mov localCPUVendor[2 * TYPE int], ecx - ; <<CPUID>> + ; <<CPUID>> ; eax = 1 --> eax: CPU ID - bits 31..16 - unused, bits 15..12 - type, bits 11..8 - family, bits 7..4 - model, bits 3..0 - mask revision - ; ebx: 31..24 - default APIC ID, 23..16 - logical processsor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID + ; ebx: 31..24 - default APIC ID, 23..16 - logical processor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID ; edx: CPU feature flags mov eax,1 CPUID_INSTRUCTION @@ -1094,7 +1827,7 @@ bool SystemInformationImplementation::RetrieveCPUIdentity() #endif } } - __except(1) + __except(1) { return false; } @@ -1107,8 +1840,6 @@ bool SystemInformationImplementation::RetrieveCPUIdentity() vbuf[12] = '\0'; this->ChipID.Vendor = vbuf; - this->FindManufacturer(); - // Retrieve the family of CPU present. this->ChipID.ExtendedFamily = ((localCPUSignature & 0x0FF00000) >> 20); // Bits 27..20 Used this->ChipID.ExtendedModel = ((localCPUSignature & 0x000F0000) >> 16); // Bits 19..16 Used @@ -1133,12 +1864,12 @@ bool SystemInformationImplementation::RetrieveCPUCacheDetails() int L2Cache[4] = { 0, 0, 0, 0 }; // Check to see if what we are about to do is supported... - if (RetrieveCPUExtendedLevelSupport (0x80000005)) + if (RetrieveCPUExtendedLevelSupport (0x80000005)) { // Use assembly to retrieve the L1 cache information ... - __try + __try { - _asm + _asm { #ifdef CPUID_AWARE_COMPILER ; we must push/pop the registers <<CPUID>> writes to, as the @@ -1169,27 +1900,27 @@ bool SystemInformationImplementation::RetrieveCPUCacheDetails() #endif } } - __except(1) + __except(1) { return false; } // Save the L1 data cache size (in KB) from ecx: bits 31..24 as well as data cache size from edx: bits 31..24. this->Features.L1CacheSize = ((L1Cache[2] & 0xFF000000) >> 24); this->Features.L1CacheSize += ((L1Cache[3] & 0xFF000000) >> 24); - } - else + } + else { // Store -1 to indicate the cache could not be queried. this->Features.L1CacheSize = -1; } // Check to see if what we are about to do is supported... - if (RetrieveCPUExtendedLevelSupport (0x80000006)) + if (RetrieveCPUExtendedLevelSupport (0x80000006)) { // Use assembly to retrieve the L2 cache information ... - __try + __try { - _asm + _asm { #ifdef CPUID_AWARE_COMPILER ; we must push/pop the registers <<CPUID>> writes to, as the @@ -1220,19 +1951,19 @@ bool SystemInformationImplementation::RetrieveCPUCacheDetails() #endif } } - __except(1) + __except(1) { return false; } // Save the L2 unified cache size (in KB) from ecx: bits 31..16. this->Features.L2CacheSize = ((L2Cache[2] & 0xFFFF0000) >> 16); - } + } else { // Store -1 to indicate the cache could not be queried. this->Features.L2CacheSize = -1; } - + // Define L3 as being not present as we cannot test for it. this->Features.L3CacheSize = -1; @@ -1294,10 +2025,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() int bob = ((TLBCacheData[0] & 0x00FF0000) >> 16); (void)bob; // Process the returned TLB and cache information. - for (int nCounter = 0; nCounter < TLBCACHE_INFO_UNITS; nCounter ++) + for (int nCounter = 0; nCounter < TLBCACHE_INFO_UNITS; nCounter ++) { // First of all - decide which unit we are dealing with. - switch (nCounter) + switch (nCounter) { // eax: bits 8..15 : bits 16..23 : bits 24..31 case 0: TLBCacheUnit = ((TLBCacheData[0] & 0x0000FF00) >> 8); break; @@ -1327,7 +2058,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() } // Now process the resulting unit to see what it means.... - switch (TLBCacheUnit) + switch (TLBCacheUnit) { case 0x00: break; case 0x01: STORE_TLBCACHE_INFO (TLBCode, 4); break; @@ -1383,7 +2114,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() case 0x90: STORE_TLBCACHE_INFO (TLBCode, 262144); break; // <-- FIXME: IA-64 Only case 0x96: STORE_TLBCACHE_INFO (TLBCode, 262144); break; // <-- FIXME: IA-64 Only case 0x9b: STORE_TLBCACHE_INFO (TLBCode, 262144); break; // <-- FIXME: IA-64 Only - + // Default case - an error has occured. default: return false; } @@ -1394,47 +2125,47 @@ bool SystemInformationImplementation::RetrieveClassicalCPUCacheDetails() } while ((TLBCacheData[0] & 0x000000FF) > TLBPassCounter); // Ok - we now have the maximum TLB, L1, L2, and L3 sizes... - if ((L1Code == -1) && (L1Data == -1) && (L1Trace == -1)) + if ((L1Code == -1) && (L1Data == -1) && (L1Trace == -1)) { this->Features.L1CacheSize = -1; } - else if ((L1Code == -1) && (L1Data == -1) && (L1Trace != -1)) + else if ((L1Code == -1) && (L1Data == -1) && (L1Trace != -1)) { this->Features.L1CacheSize = L1Trace; } - else if ((L1Code != -1) && (L1Data == -1)) + else if ((L1Code != -1) && (L1Data == -1)) { this->Features.L1CacheSize = L1Code; } - else if ((L1Code == -1) && (L1Data != -1)) + else if ((L1Code == -1) && (L1Data != -1)) { this->Features.L1CacheSize = L1Data; } - else if ((L1Code != -1) && (L1Data != -1)) + else if ((L1Code != -1) && (L1Data != -1)) { this->Features.L1CacheSize = L1Code + L1Data; } - else + else { this->Features.L1CacheSize = -1; } // Ok - we now have the maximum TLB, L1, L2, and L3 sizes... - if (L2Unified == -1) + if (L2Unified == -1) { this->Features.L2CacheSize = -1; } - else + else { this->Features.L2CacheSize = L2Unified; } // Ok - we now have the maximum TLB, L1, L2, and L3 sizes... - if (L3Unified == -1) + if (L3Unified == -1) { this->Features.L3CacheSize = -1; } - else + else { this->Features.L3CacheSize = L3Unified; } @@ -1526,19 +2257,19 @@ bool SystemInformationImplementation::RetrieveClassicalCPUClockSpeed() // Attempt to get a starting tick count. QueryPerformanceCounter (&liStart); - __try + __try { - _asm + _asm { mov eax, 0x80000000 mov ebx, CLASSICAL_CPU_FREQ_LOOP - Timer_Loop: + Timer_Loop: bsf ecx,eax dec ebx jnz Timer_Loop - } + } } - __except(1) + __except(1) { return false; } @@ -1551,22 +2282,22 @@ bool SystemInformationImplementation::RetrieveClassicalCPUClockSpeed() dDifference = (((double) liEnd.QuadPart - (double) liStart.QuadPart) / (double) liCountsPerSecond.QuadPart); // Calculate the clock speed. - if (this->ChipID.Family == 3) + if (this->ChipID.Family == 3) { // 80386 processors.... Loop time is 115 cycles! dFrequency = (((CLASSICAL_CPU_FREQ_LOOP * 115) / dDifference) / 1000000); - } - else if (this->ChipID.Family == 4) + } + else if (this->ChipID.Family == 4) { // 80486 processors.... Loop time is 47 cycles! dFrequency = (((CLASSICAL_CPU_FREQ_LOOP * 47) / dDifference) / 1000000); - } - else if (this->ChipID.Family == 5) + } + else if (this->ChipID.Family == 5) { // Pentium processors.... Loop time is 43 cycles! dFrequency = (((CLASSICAL_CPU_FREQ_LOOP * 43) / dDifference) / 1000000); } - + // Save the clock speed. this->Features.CPUSpeed = (int) dFrequency; @@ -1583,7 +2314,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev { int MaxCPUExtendedLevel = 0; - // The extended CPUID is supported by various vendors starting with the following CPU models: + // The extended CPUID is supported by various vendors starting with the following CPU models: // // Manufacturer & Chip Name | Family Model Revision // @@ -1596,27 +2327,27 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev // // We check to see if a supported processor is present... - if (this->ChipManufacturer == AMD) + if (this->ChipManufacturer == AMD) { if (this->ChipID.Family < 5) return false; if ((this->ChipID.Family == 5) && (this->ChipID.Model < 6)) return false; - } - else if (this->ChipManufacturer == Cyrix) + } + else if (this->ChipManufacturer == Cyrix) { if (this->ChipID.Family < 5) return false; if ((this->ChipID.Family == 5) && (this->ChipID.Model < 4)) return false; if ((this->ChipID.Family == 6) && (this->ChipID.Model < 5)) return false; - } - else if (this->ChipManufacturer == IDT) + } + else if (this->ChipManufacturer == IDT) { if (this->ChipID.Family < 5) return false; if ((this->ChipID.Family == 5) && (this->ChipID.Model < 8)) return false; - } - else if (this->ChipManufacturer == Transmeta) + } + else if (this->ChipManufacturer == Transmeta) { if (this->ChipID.Family < 5) return false; - } - else if (this->ChipManufacturer == Intel) + } + else if (this->ChipManufacturer == Intel) { if (this->ChipID.Family < 0xf) { @@ -1638,7 +2369,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev push ecx push edx #endif - ; <<CPUID>> + ; <<CPUID>> ; eax = 0x80000000 --> eax: maximum supported extended level mov eax,0x80000000 CPUID_INSTRUCTION @@ -1652,7 +2383,7 @@ bool SystemInformationImplementation::RetrieveCPUExtendedLevelSupport(int CPULev #endif } } - __except(1) + __except(1) { return false; } @@ -1677,7 +2408,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() { // Check that we are not using an Intel processor as it does not support this. - if (this->ChipManufacturer == Intel) + if (this->ChipManufacturer == Intel) { return false; } @@ -1692,9 +2423,9 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() int localCPUExtendedFeatures = 0; // Use assembly to detect CPUID information... - __try + __try { - _asm + _asm { #ifdef CPUID_AWARE_COMPILER ; we must push/pop the registers <<CPUID>> writes to, as the @@ -1705,9 +2436,9 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() push ecx push edx #endif - ; <<CPUID>> + ; <<CPUID>> ; eax = 0x80000001 --> eax: CPU ID - bits 31..16 - unused, bits 15..12 - type, bits 11..8 - family, bits 7..4 - model, bits 3..0 - mask revision - ; ebx: 31..24 - default APIC ID, 23..16 - logical processsor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID + ; ebx: 31..24 - default APIC ID, 23..16 - logical processor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID ; edx: CPU feature flags mov eax,0x80000001 CPUID_INSTRUCTION @@ -1721,7 +2452,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() #endif } } - __except(1) + __except(1) { return false; } @@ -1731,15 +2462,15 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures() this->Features.ExtendedFeatures.Has3DNowPlus = ((localCPUExtendedFeatures & 0x40000000) != 0); // 3DNow+ Present -- > Bit 30. this->Features.ExtendedFeatures.HasSSEMMX = ((localCPUExtendedFeatures & 0x00400000) != 0); // SSE MMX Present --> Bit 22. this->Features.ExtendedFeatures.SupportsMP = ((localCPUExtendedFeatures & 0x00080000) != 0); // MP Capable -- > Bit 19. - + // Retrieve AMD specific extended features. - if (this->ChipManufacturer == AMD) + if (this->ChipManufacturer == AMD) { this->Features.ExtendedFeatures.HasMMXPlus = ((localCPUExtendedFeatures & 0x00400000) != 0); // AMD specific: MMX-SSE --> Bit 22 } // Retrieve Cyrix specific extended features. - if (this->ChipManufacturer == Cyrix) + if (this->ChipManufacturer == Cyrix) { this->Features.ExtendedFeatures.HasMMXPlus = ((localCPUExtendedFeatures & 0x01000000) != 0); // Cyrix specific: Extended MMX --> Bit 24 } @@ -1794,7 +2525,7 @@ bool SystemInformationImplementation::RetrieveProcessorSerialNumber() #endif } } - __except(1) + __except(1) { return false; } @@ -1851,12 +2582,12 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement() push ecx push edx #endif - ; <<CPUID>> + ; <<CPUID>> ; eax = 0x80000007 --> edx: get processor power management mov eax,0x80000007 CPUID_INSTRUCTION mov localCPUPowerManagement, edx - + #ifdef CPUID_AWARE_COMPILER pop edx pop ecx @@ -1865,7 +2596,7 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement() #endif } } - __except(1) + __except(1) { return false; } @@ -1918,7 +2649,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() push ecx push edx #endif - ; <<CPUID>> + ; <<CPUID>> ; eax = 0x80000002 --> eax, ebx, ecx, edx: get processor name string (part 1) mov eax,0x80000002 CPUID_INSTRUCTION @@ -1927,7 +2658,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() mov CPUExtendedIdentity[2 * TYPE int], ecx mov CPUExtendedIdentity[3 * TYPE int], edx - ; <<CPUID>> + ; <<CPUID>> ; eax = 0x80000003 --> eax, ebx, ecx, edx: get processor name string (part 2) mov eax,0x80000003 CPUID_INSTRUCTION @@ -1936,7 +2667,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() mov CPUExtendedIdentity[6 * TYPE int], ecx mov CPUExtendedIdentity[7 * TYPE int], edx - ; <<CPUID>> + ; <<CPUID>> ; eax = 0x80000004 --> eax, ebx, ecx, edx: get processor name string (part 3) mov eax,0x80000004 CPUID_INSTRUCTION @@ -1953,7 +2684,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() #endif } } - __except(1) + __except(1) { return false; } @@ -1974,6 +2705,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() memcpy (&(nbuf[44]), &(CPUExtendedIdentity[11]), sizeof (int)); nbuf[48] = '\0'; this->ChipID.ProcessorName = nbuf; + this->ChipID.ModelName = nbuf; // Because some manufacturers have leading white space - we have to post-process the name. SystemInformationStripLeadingSpace(this->ChipID.ProcessorName); @@ -1988,13 +2720,13 @@ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() { // Start by decided which manufacturer we are using.... - switch (this->ChipManufacturer) + switch (this->ChipManufacturer) { case Intel: // Check the family / model / revision to determine the CPU ID. switch (this->ChipID.Family) { case 3: - this->ChipID.ProcessorName = "Newer i80386 family"; + this->ChipID.ProcessorName = "Newer i80386 family"; break; case 4: switch (this->ChipID.Model) { @@ -2011,7 +2743,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "P5 A-Step"; break; case 1: this->ChipID.ProcessorName = "P5"; break; @@ -2024,7 +2756,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 6: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "P6 A-Step"; break; case 1: this->ChipID.ProcessorName = "P6"; break; @@ -2044,10 +2776,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case 0xf: // Check the extended family bits... - switch (this->ChipID.ExtendedFamily) + switch (this->ChipID.ExtendedFamily) { case 0: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "Pentium IV (0.18 micron)"; break; case 1: this->ChipID.ProcessorName = "Pentium IV (0.18 micron)"; break; @@ -2070,10 +2802,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() case AMD: // Check the family / model / revision to determine the CPU ID. - switch (this->ChipID.Family) + switch (this->ChipID.Family) { case 4: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 3: this->ChipID.ProcessorName = "80486DX2"; break; case 7: this->ChipID.ProcessorName = "80486DX2 WriteBack"; break; @@ -2085,7 +2817,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "SSA5 (PR75, PR90 = PR100)"; break; case 1: this->ChipID.ProcessorName = "5k86 (PR120 = PR133)"; break; @@ -2100,7 +2832,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 6: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 1: this->ChipID.ProcessorName = "Athlon- (0.25 micron)"; break; case 2: this->ChipID.ProcessorName = "Athlon- (0.18 micron)"; break; @@ -2108,9 +2840,9 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() case 4: this->ChipID.ProcessorName = "Athlon- (Thunderbird core)"; break; case 6: this->ChipID.ProcessorName = "Athlon- (Palomino core)"; break; case 7: this->ChipID.ProcessorName = "Duron- (Morgan core)"; break; - case 8: + case 8: if (this->Features.ExtendedFeatures.SupportsMP) - this->ChipID.ProcessorName = "Athlon - MP (Thoroughbred core)"; + this->ChipID.ProcessorName = "Athlon - MP (Thoroughbred core)"; else this->ChipID.ProcessorName = "Athlon - XP (Thoroughbred core)"; break; default: this->ChipID.ProcessorName = "Unknown K7 family"; return false; @@ -2123,10 +2855,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case Transmeta: - switch (this->ChipID.Family) - { + switch (this->ChipID.Family) + { case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 4: this->ChipID.ProcessorName = "Crusoe TM3x00 and TM5x00"; break; default: this->ChipID.ProcessorName = "Unknown Crusoe family"; return false; @@ -2139,10 +2871,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case Rise: - switch (this->ChipID.Family) - { + switch (this->ChipID.Family) + { case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "mP6 (0.25 micron)"; break; case 2: this->ChipID.ProcessorName = "mP6 (0.18 micron)"; break; @@ -2156,10 +2888,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case UMC: - switch (this->ChipID.Family) - { + switch (this->ChipID.Family) + { case 4: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 1: this->ChipID.ProcessorName = "U5D"; break; case 2: this->ChipID.ProcessorName = "U5S"; break; @@ -2173,10 +2905,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case IDT: - switch (this->ChipID.Family) - { + switch (this->ChipID.Family) + { case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 4: this->ChipID.ProcessorName = "C6"; break; case 8: this->ChipID.ProcessorName = "C2"; break; @@ -2185,7 +2917,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 6: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 6: this->ChipID.ProcessorName = "VIA Cyrix III - Samuel"; break; default: this->ChipID.ProcessorName = "Unknown IDT\\Centaur family"; return false; @@ -2198,10 +2930,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case Cyrix: - switch (this->ChipID.Family) - { + switch (this->ChipID.Family) + { case 4: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 4: this->ChipID.ProcessorName = "MediaGX GX = GXm"; break; case 9: this->ChipID.ProcessorName = "5x86"; break; @@ -2209,7 +2941,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 2: this->ChipID.ProcessorName = "Cx6x86"; break; case 4: this->ChipID.ProcessorName = "MediaGX GXm"; break; @@ -2217,7 +2949,7 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() } break; case 6: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "6x86MX"; break; case 5: this->ChipID.ProcessorName = "Cyrix M2 Core"; break; @@ -2234,10 +2966,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity() break; case NexGen: - switch (this->ChipID.Family) - { + switch (this->ChipID.Family) + { case 5: - switch (this->ChipID.Model) + switch (this->ChipID.Model) { case 0: this->ChipID.ProcessorName = "Nx586 or Nx586FPU"; break; default: this->ChipID.ProcessorName = "Unknown NexGen family"; return false; @@ -2272,6 +3004,16 @@ kwsys_stl::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(k size_t pos2 = buffer.find("\n",pos); if(pos!=buffer.npos && pos2!=buffer.npos) { + // It may happen that the beginning matches, but this is still not the requested key. + // An example is looking for "cpu" when "cpu family" comes first. So we check that + // we have only spaces from here to pos, otherwise we search again. + for(size_t i=this->CurrentPositionInFile+strlen(word); i < pos; ++i) + { + if(buffer[i] != ' ' && buffer[i] != '\t') + { + return this->ExtractValueFromCpuInfoFile(buffer, word, pos2); + } + } return buffer.substr(pos+2,pos2-pos-2); } } @@ -2287,12 +3029,12 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() kwsys_stl::string buffer; FILE *fd = fopen("/proc/cpuinfo", "r" ); - if ( !fd ) + if ( !fd ) { kwsys_ios::cout << "Problem opening /proc/cpuinfo" << kwsys_ios::endl; return 0; } - + size_t fileSize = 0; while(!feof(fd)) { @@ -2336,14 +3078,14 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() #else // __CYGWIN__ // does not have "physical id" entries, neither "cpu cores" - // this has to be fixed for hyper-threading. + // this has to be fixed for hyper-threading. kwsys_stl::string cpucount = this->ExtractValueFromCpuInfoFile(buffer,"cpu count"); this->NumberOfPhysicalCPU= this->NumberOfLogicalCPU = atoi(cpucount.c_str()); #endif - // gotta have one, and if this is 0 then we get a / by 0n - // beter to have a bad answer than a crash + // gotta have one, and if this is 0 then we get a / by 0n + // better to have a bad answer than a crash if(this->NumberOfPhysicalCPU <= 0) { this->NumberOfPhysicalCPU = 1; @@ -2352,32 +3094,413 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical= this->NumberOfLogicalCPU/this->NumberOfPhysicalCPU; - // CPU speed (checking only the first proc + // CPU speed (checking only the first processor) kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz"); this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); // Chip family - this->ChipID.Family = atoi(this->ExtractValueFromCpuInfoFile(buffer,"cpu family").c_str()); - + kwsys_stl::string familyStr = + this->ExtractValueFromCpuInfoFile(buffer,"cpu family"); + if(familyStr.empty()) + { + familyStr = this->ExtractValueFromCpuInfoFile(buffer,"CPU architecture"); + } + this->ChipID.Family = atoi(familyStr.c_str()); + // Chip Vendor this->ChipID.Vendor = this->ExtractValueFromCpuInfoFile(buffer,"vendor_id"); - this->FindManufacturer(); - + this->FindManufacturer(familyStr); + + // second try for setting family + if (this->ChipID.Family == 0 && this->ChipManufacturer == HP) + { + if (familyStr == "PA-RISC 1.1a") + this->ChipID.Family = 0x11a; + else if (familyStr == "PA-RISC 2.0") + this->ChipID.Family = 0x200; + // If you really get CMake to work on a machine not belonging to + // any of those families I owe you a dinner if you get it to + // contribute nightly builds regularly. + } + // Chip Model this->ChipID.Model = atoi(this->ExtractValueFromCpuInfoFile(buffer,"model").c_str()); - this->RetrieveClassicalCPUIdentity(); + if(!this->RetrieveClassicalCPUIdentity()) + { + // Some platforms (e.g. PA-RISC) tell us their CPU name here. + // Note: x86 does not. + kwsys_stl::string cpuname = this->ExtractValueFromCpuInfoFile(buffer,"cpu"); + if(!cpuname.empty()) + { + this->ChipID.ProcessorName = cpuname; + } + } + + // Chip revision + kwsys_stl::string cpurev = this->ExtractValueFromCpuInfoFile(buffer,"stepping"); + if(cpurev.empty()) + { + cpurev = this->ExtractValueFromCpuInfoFile(buffer,"CPU revision"); + } + this->ChipID.Revision = atoi(cpurev.c_str()); + + // Chip Model Name + this->ChipID.ModelName = this->ExtractValueFromCpuInfoFile(buffer,"model name").c_str(); // L1 Cache size - kwsys_stl::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer,"cache size"); - pos = cacheSize.find(" KB"); - if(pos!=cacheSize.npos) + // Different architectures may show different names for the caches. + // Sum up everything we find. + kwsys_stl::vector<const char*> cachename; + cachename.clear(); + + cachename.push_back("cache size"); // e.g. x86 + cachename.push_back("I-cache"); // e.g. PA-RISC + cachename.push_back("D-cache"); // e.g. PA-RISC + + this->Features.L1CacheSize = 0; + for (size_t index = 0; index < cachename.size(); index ++) { - cacheSize = cacheSize.substr(0,pos); + kwsys_stl::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer,cachename[index]); + if (!cacheSize.empty()) + { + pos = cacheSize.find(" KB"); + if(pos!=cacheSize.npos) + { + cacheSize = cacheSize.substr(0,pos); + } + this->Features.L1CacheSize += atoi(cacheSize.c_str()); + } } - this->Features.L1CacheSize = atoi(cacheSize.c_str()); return 1; } +/** +Get total system RAM in units of KiB. +*/ +SystemInformation::LongLong +SystemInformationImplementation::GetHostMemoryTotal() +{ +#if defined(_WIN32) +# if defined(_MSC_VER) && _MSC_VER < 1300 + MEMORYSTATUS stat; + stat.dwLength = sizeof(stat); + GlobalMemoryStatus(&stat); + return stat.dwTotalPhys/1024; +# else + MEMORYSTATUSEX statex; + statex.dwLength=sizeof(statex); + GlobalMemoryStatusEx(&statex); + return statex.ullTotalPhys/1024; +# endif +#elif defined(__linux) + SystemInformation::LongLong memTotal=0; + int ierr=GetFieldFromFile("/proc/meminfo","MemTotal:",memTotal); + if (ierr) + { + return -1; + } + return memTotal; +#elif defined(__APPLE__) + uint64_t mem; + size_t len = sizeof(mem); + int ierr=sysctlbyname("hw.memsize", &mem, &len, NULL, 0); + if (ierr) + { + return -1; + } + return mem/1024; +#else + return 0; +#endif +} + +/** +Get total system RAM in units of KiB. This may differ from the +host total if a host-wide resource limit is applied. +*/ +SystemInformation::LongLong +SystemInformationImplementation::GetHostMemoryAvailable(const char *hostLimitEnvVarName) +{ + SystemInformation::LongLong memTotal=this->GetHostMemoryTotal(); + + // the following mechanism is provided for systems that + // apply resource limits across groups of processes. + // this is of use on certain SMP systems (eg. SGI UV) + // where the host has a large amount of ram but a given user's + // access to it is severly restricted. The system will + // apply a limit across a set of processes. Units are in KiB. + if (hostLimitEnvVarName) + { + const char *hostLimitEnvVarValue=getenv(hostLimitEnvVarName); + if (hostLimitEnvVarValue) + { + SystemInformation::LongLong hostLimit=atoLongLong(hostLimitEnvVarValue); + if (hostLimit>0) + { + memTotal=min(hostLimit,memTotal); + } + } + } + + return memTotal; +} + +/** +Get total system RAM in units of KiB. This may differ from the +host total if a per-process resource limit is applied. +*/ +SystemInformation::LongLong +SystemInformationImplementation::GetProcMemoryAvailable( + const char *hostLimitEnvVarName, + const char *procLimitEnvVarName) +{ + SystemInformation::LongLong memAvail + = this->GetHostMemoryAvailable(hostLimitEnvVarName); + + // the following mechanism is provide for systems where rlimits + // are not employed. Units are in KiB. + if (procLimitEnvVarName) + { + const char *procLimitEnvVarValue=getenv(procLimitEnvVarName); + if (procLimitEnvVarValue) + { + SystemInformation::LongLong procLimit=atoLongLong(procLimitEnvVarValue); + if (procLimit>0) + { + memAvail=min(procLimit,memAvail); + } + } + } + +#if defined(__linux) + int ierr; + ResourceLimitType rlim; + ierr=GetResourceLimit(RLIMIT_DATA,&rlim); + if ((ierr==0) && (rlim.rlim_cur != RLIM_INFINITY)) + { + memAvail=min((SystemInformation::LongLong)rlim.rlim_cur/1024,memAvail); + } + + ierr=GetResourceLimit(RLIMIT_AS,&rlim); + if ((ierr==0) && (rlim.rlim_cur != RLIM_INFINITY)) + { + memAvail=min((SystemInformation::LongLong)rlim.rlim_cur/1024,memAvail); + } +#elif defined(__APPLE__) + struct rlimit rlim; + int ierr; + ierr=getrlimit(RLIMIT_DATA,&rlim); + if ((ierr==0) && (rlim.rlim_cur != RLIM_INFINITY)) + { + memAvail=min((SystemInformation::LongLong)rlim.rlim_cur/1024,memAvail); + } + + ierr=getrlimit(RLIMIT_RSS,&rlim); + if ((ierr==0) && (rlim.rlim_cur != RLIM_INFINITY)) + { + memAvail=min((SystemInformation::LongLong)rlim.rlim_cur/1024,memAvail); + } +#endif + + return memAvail; +} + +/** +Get RAM used by all processes in the host, in units of KiB. +*/ +SystemInformation::LongLong +SystemInformationImplementation::GetHostMemoryUsed() +{ +#if defined(_WIN32) +# if defined(_MSC_VER) && _MSC_VER < 1300 + MEMORYSTATUS stat; + stat.dwLength = sizeof(stat); + GlobalMemoryStatus(&stat); + return (stat.dwTotalPhys - stat.dwAvailPhys)/1024; +# else + MEMORYSTATUSEX statex; + statex.dwLength=sizeof(statex); + GlobalMemoryStatusEx(&statex); + return (statex.ullTotalPhys - statex.ullAvailPhys)/1024; +# endif +#elif defined(__linux) + const char *names[3]={"MemTotal:","MemFree:",NULL}; + SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; + int ierr=GetFieldsFromFile("/proc/meminfo",names,values); + if (ierr) + { + return ierr; + } + SystemInformation::LongLong &memTotal=values[0]; + SystemInformation::LongLong &memFree=values[1]; + return memTotal - memFree; +#elif defined(__APPLE__) + SystemInformation::LongLong psz=getpagesize(); + if (psz<1) + { + return -1; + } + const char *names[4]={"Pages active:","Pages inactive:","Pages wired down:",NULL}; + SystemInformation::LongLong values[3]={SystemInformation::LongLong(0)}; + int ierr=GetFieldsFromCommand("vm_stat", names, values); + if (ierr) + { + return -1; + } + SystemInformation::LongLong &vmActive=values[0]; + SystemInformation::LongLong &vmInactive=values[1]; + SystemInformation::LongLong &vmWired=values[2]; + return ((vmActive+vmInactive+vmWired)*psz)/1024; +#else + return 0; +#endif +} + +/** +Get system RAM used by the process associated with the given +process id in units of KiB. +*/ +SystemInformation::LongLong +SystemInformationImplementation::GetProcMemoryUsed() +{ +#if defined(_WIN32) && defined(KWSYS_SYS_HAS_PSAPI) + long pid=GetCurrentProcessId(); + HANDLE hProc; + hProc=OpenProcess( + PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, + false, + pid); + if (hProc==0) + { + return -1; + } + PROCESS_MEMORY_COUNTERS pmc; + int ok=GetProcessMemoryInfo(hProc,&pmc,sizeof(pmc)); + CloseHandle(hProc); + if (!ok) + { + return -2; + } + return pmc.WorkingSetSize/1024; +#elif defined(__linux) + SystemInformation::LongLong memUsed=0; + int ierr=GetFieldFromFile("/proc/self/status","VmRSS:",memUsed); + if (ierr) + { + return -1; + } + return memUsed; +#elif defined(__APPLE__) + SystemInformation::LongLong memUsed=0; + pid_t pid=getpid(); + kwsys_ios::ostringstream oss; + oss << "ps -o rss= -p " << pid; + FILE *file=popen(oss.str().c_str(),"r"); + if (file==0) + { + return -1; + } + oss.str(""); + while (!feof(file) && !ferror(file)) + { + char buf[256]={'\0'}; + errno=0; + size_t nRead=fread(buf,1,256,file); + if (ferror(file) && (errno==EINTR)) + { + clearerr(file); + } + if (nRead) oss << buf; + } + int ierr=ferror(file); + pclose(file); + if (ierr) + { + return -2; + } + kwsys_ios::istringstream iss(oss.str()); + iss >> memUsed; + return memUsed; +#else + return 0; +#endif +} + +/** +Get the process id of the running process. +*/ +SystemInformation::LongLong +SystemInformationImplementation::GetProcessId() +{ +#if defined(_WIN32) + return GetCurrentProcessId(); +#elif defined(__linux) || defined(__APPLE__) + return getpid(); +#else + return -1; +#endif +} + +/** +when set print stack trace in response to common signals. +*/ +void SystemInformationImplementation::SetStackTraceOnError(int enable) +{ +#if !defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) + static int saOrigValid=0; + static struct sigaction saSEGVOrig; + static struct sigaction saTERMOrig; + static struct sigaction saINTOrig; + static struct sigaction saILLOrig; + static struct sigaction saBUSOrig; + static struct sigaction saFPEOrig; + + if (enable && !saOrigValid) + { + // save the current actions + sigaction(SIGSEGV,0,&saSEGVOrig); + sigaction(SIGTERM,0,&saTERMOrig); + sigaction(SIGINT,0,&saINTOrig); + sigaction(SIGILL,0,&saILLOrig); + sigaction(SIGBUS,0,&saBUSOrig); + sigaction(SIGFPE,0,&saFPEOrig); + + // enable read, disable write + saOrigValid=1; + + // install ours + struct sigaction sa; + sa.sa_sigaction=(SigAction)StacktraceSignalHandler; + sa.sa_flags=SA_SIGINFO|SA_RESTART; + sigemptyset(&sa.sa_mask); + + sigaction(SIGSEGV,&sa,0); + sigaction(SIGTERM,&sa,0); + sigaction(SIGINT,&sa,0); + sigaction(SIGILL,&sa,0); + sigaction(SIGBUS,&sa,0); + sigaction(SIGFPE,&sa,0); + } + else + if (!enable && saOrigValid) + { + // restore previous actions + sigaction(SIGSEGV,&saSEGVOrig,0); + sigaction(SIGTERM,&saTERMOrig,0); + sigaction(SIGINT,&saINTOrig,0); + sigaction(SIGILL,&saILLOrig,0); + sigaction(SIGBUS,&saBUSOrig,0); + sigaction(SIGFPE,&saFPEOrig,0); + + // enable write, disable read + saOrigValid=0; + } +#else + // avoid warning C4100 + (void)enable; +#endif +} + /** Query for the memory status */ int SystemInformationImplementation::QueryMemory() { @@ -2388,13 +3511,13 @@ int SystemInformationImplementation::QueryMemory() #ifdef __CYGWIN__ return 0; #elif defined(_WIN32) -#if _MSC_VER < 1300 +# if defined(_MSC_VER) && _MSC_VER < 1300 MEMORYSTATUS ms; unsigned long tv, tp, av, ap; ms.dwLength = sizeof(ms); GlobalMemoryStatus(&ms); - #define MEM_VAL(value) dw##value -#else +# define MEM_VAL(value) dw##value +# else MEMORYSTATUSEX ms; DWORDLONG tv, tp, av, ap; ms.dwLength = sizeof(ms); @@ -2402,8 +3525,8 @@ int SystemInformationImplementation::QueryMemory() { return 0; } -#define MEM_VAL(value) ull##value -#endif +# define MEM_VAL(value) ull##value +# endif tv = ms.MEM_VAL(TotalVirtual); tp = ms.MEM_VAL(TotalPhys); av = ms.MEM_VAL(AvailVirtual); @@ -2418,12 +3541,12 @@ int SystemInformationImplementation::QueryMemory() unsigned long tp=0; unsigned long av=0; unsigned long ap=0; - + char buffer[1024]; // for reading lines - + int linuxMajor = 0; int linuxMinor = 0; - + // Find the Linux kernel version first struct utsname unameInfo; int errorFlag = uname(&unameInfo); @@ -2432,31 +3555,31 @@ int SystemInformationImplementation::QueryMemory() kwsys_ios::cout << "Problem calling uname(): " << strerror(errno) << kwsys_ios::endl; return 0; } - + if( unameInfo.release!=0 && strlen(unameInfo.release)>=3 ) { // release looks like "2.6.3-15mdk-i686-up-4GB" char majorChar=unameInfo.release[0]; char minorChar=unameInfo.release[2]; - + if( isdigit(majorChar) ) { linuxMajor=majorChar-'0'; } - + if( isdigit(minorChar) ) { linuxMinor=minorChar-'0'; } } - + FILE *fd = fopen("/proc/meminfo", "r" ); - if ( !fd ) + if ( !fd ) { kwsys_ios::cout << "Problem opening /proc/meminfo" << kwsys_ios::endl; return 0; } - + if( linuxMajor>=3 || ( (linuxMajor>=2) && (linuxMinor>=6) ) ) { // new /proc/meminfo format since kernel 2.6.x @@ -2499,7 +3622,7 @@ int SystemInformationImplementation::QueryMemory() else { // /proc/meminfo format for kernel older than 2.6.x - + unsigned long temp; unsigned long cachedMem; unsigned long buffersMem; @@ -2537,7 +3660,7 @@ int SystemInformationImplementation::QueryMemory() unsigned long ap=0; struct pst_static pst; struct pst_dynamic pdy; - + unsigned long ps = 0; if (pstat_getstatic(&pst, sizeof(pst), (size_t) 1, 0) != -1) { @@ -2559,35 +3682,34 @@ int SystemInformationImplementation::QueryMemory() #else return 0; #endif - - } /** */ -size_t SystemInformationImplementation::GetTotalVirtualMemory() -{ - return this->TotalVirtualMemory; +size_t SystemInformationImplementation::GetTotalVirtualMemory() +{ + return this->TotalVirtualMemory; } /** */ -size_t SystemInformationImplementation::GetAvailableVirtualMemory() -{ - return this->AvailableVirtualMemory; +size_t SystemInformationImplementation::GetAvailableVirtualMemory() +{ + return this->AvailableVirtualMemory; } -size_t SystemInformationImplementation::GetTotalPhysicalMemory() -{ - return this->TotalPhysicalMemory; +size_t SystemInformationImplementation::GetTotalPhysicalMemory() +{ + return this->TotalPhysicalMemory; } /** */ -size_t SystemInformationImplementation::GetAvailablePhysicalMemory() -{ - return this->AvailablePhysicalMemory; +size_t SystemInformationImplementation::GetAvailablePhysicalMemory() +{ + return this->AvailablePhysicalMemory; } /** Get Cycle differences */ -LongLong SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayFunction, +SystemInformation::LongLong +SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayFunction, unsigned int uiParameter) { #if USE_ASM_INSTRUCTIONS @@ -2619,7 +3741,7 @@ LongLong SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayF mov eax1, esi ; eax2 = esi } } - __except(1) + __except(1) { return -1; } @@ -2642,7 +3764,7 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) __int64 x; // Get the frequency of the high performance counter. - if(!QueryPerformanceFrequency (&Frequency)) + if(!QueryPerformanceFrequency (&Frequency)) { return; } @@ -2650,9 +3772,9 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) // Get the starting position of the counter. QueryPerformanceCounter (&StartCounter); - + do { - // Get the ending position of the counter. + // Get the ending position of the counter. QueryPerformanceCounter (&EndCounter); } while (EndCounter.QuadPart - StartCounter.QuadPart == x); #endif @@ -2706,7 +3828,7 @@ unsigned int SystemInformationImplementation::IsHyperThreadingSupported() mov VendorId, ebx mov VendorId + 4, edx mov VendorId + 8, ecx - + mov eax, 1 // call cpuid with eax = 1 cpuid mov Regeax, eax // eax contains family processor type @@ -2743,7 +3865,7 @@ unsigned char SystemInformationImplementation::GetAPICId() unsigned int Regebx = 0; #if USE_ASM_INSTRUCTIONS - if (!this->IsHyperThreadingSupported()) + if (!this->IsHyperThreadingSupported()) { return static_cast<unsigned char>(-1); // HT not supported } // Logical processor = 1 @@ -2773,7 +3895,7 @@ int SystemInformationImplementation::CPUCount() // Number of physical processors in a non-Intel system // or in a 32-bit Intel system with Hyper-Threading technology disabled - this->NumberOfPhysicalCPU = (unsigned char) info.dwNumberOfProcessors; + this->NumberOfPhysicalCPU = (unsigned char) info.dwNumberOfProcessors; if (this->IsHyperThreadingSupported()) { @@ -2789,7 +3911,7 @@ int SystemInformationImplementation::CPUCount() DWORD_PTR dwSystemAffinity; DWORD dwAffinityMask; - // Calculate the appropriate shifts and mask based on the + // Calculate the appropriate shifts and mask based on the // number of logical processors. unsigned int i = 1; unsigned char PHY_ID_MASK = 0xFF; @@ -2801,7 +3923,7 @@ int SystemInformationImplementation::CPUCount() PHY_ID_MASK <<= 1; // PHY_ID_SHIFT++; } - + hCurrentProcessHandle = GetCurrentProcess(); GetProcessAffinityMask(hCurrentProcessHandle, &dwProcessAffinity, &dwSystemAffinity); @@ -2829,8 +3951,8 @@ int SystemInformationImplementation::CPUCount() APIC_ID = GetAPICId(); LOG_ID = APIC_ID & ~PHY_ID_MASK; - - if (LOG_ID != 0) + + if (LOG_ID != 0) { HT_Enabled = 1; } @@ -2840,7 +3962,7 @@ int SystemInformationImplementation::CPUCount() } // Reset the processor affinity SetProcessAffinityMask(hCurrentProcessHandle, dwProcessAffinity); - + if (this->NumberOfLogicalCPU == 1) // Normal P4 : HT is disabled in hardware { StatusFlag = HT_DISABLED; @@ -2853,7 +3975,7 @@ int SystemInformationImplementation::CPUCount() this->NumberOfPhysicalCPU /= (this->NumberOfLogicalCPU); StatusFlag = HT_ENABLED; } - else + else { StatusFlag = HT_SUPPORTED_NOT_ENABLED; } @@ -2891,6 +4013,7 @@ unsigned int SystemInformationImplementation::GetNumberOfPhysicalCPU() bool SystemInformationImplementation::ParseSysCtl() { #if defined(__APPLE__) + char retBuf[128]; int err = 0; uint64_t value = 0; size_t len = sizeof(value); @@ -2901,9 +4024,10 @@ bool SystemInformationImplementation::ParseSysCtl() this->AvailablePhysicalMemory = 0; vm_statistics_data_t vmstat; mach_msg_type_number_t count = HOST_VM_INFO_COUNT; - if ( host_statistics(mach_host_self(), HOST_VM_INFO, + if ( host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstat, &count) == KERN_SUCCESS ) { + len = sizeof(value); err = sysctlbyname("hw.pagesize", &value, &len, NULL, 0); int64_t available_memory = vmstat.free_count * value; this->AvailablePhysicalMemory = static_cast< size_t >( available_memory / 1048576 ); @@ -2914,7 +4038,7 @@ bool SystemInformationImplementation::ParseSysCtl() int mib[2] = { CTL_VM, VM_SWAPUSAGE }; size_t miblen = sizeof(mib) / sizeof(mib[0]); struct xsw_usage swap; - len = sizeof(struct xsw_usage); + len = sizeof(swap); err = sysctl(mib, miblen, &swap, &len, NULL, 0); if (err == 0) { @@ -2929,8 +4053,9 @@ bool SystemInformationImplementation::ParseSysCtl() // CPU Info len = sizeof(this->NumberOfPhysicalCPU); sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, NULL, 0); + len = sizeof(this->NumberOfLogicalCPU); sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, NULL, 0); - this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = + this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = this->LogicalCPUPerPhysicalCPU(); len = sizeof(value); @@ -2947,16 +4072,16 @@ bool SystemInformationImplementation::ParseSysCtl() if (err != 0) // Go back to names we know but are less descriptive { this->ChipID.Family = 0; - char retBuf[32]; - ::memset(retBuf, 0, 32); + ::memset(retBuf, 0, 128); len = 32; - err = sysctlbyname("hw.machine", &retBuf, &len, NULL, 0); + err = sysctlbyname("hw.machine", &retBuf, &len, NULL, 0); kwsys_stl::string machineBuf(retBuf); if (machineBuf.find_first_of("Power") != kwsys_stl::string::npos) { this->ChipID.Vendor = "IBM"; - len = 4; + len = sizeof(this->ChipID.Family); err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, NULL, 0); + len = sizeof(this->ChipID.Model); err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, NULL, 0); this->FindManufacturer(); } @@ -2964,35 +4089,40 @@ bool SystemInformationImplementation::ParseSysCtl() else // Should be an Intel Chip. { len = sizeof(this->ChipID.Family); - err = + err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0); - - char retBuf[128]; + ::memset(retBuf, 0, 128); len = 128; err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, NULL, 0); // Chip Vendor this->ChipID.Vendor = retBuf; this->FindManufacturer(); - - ::memset(retBuf, 0, 128); - err = - sysctlbyname("machdep.cpu.brand_string", - retBuf, &len, NULL, 0); - this->ChipID.ProcessorName = retBuf; // Chip Model len = sizeof(value); err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0); this->ChipID.Model = static_cast< int >( value ); } + + // brand string + ::memset(retBuf, 0, sizeof(retBuf)); + len = sizeof(retBuf); + err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, NULL, 0); + if (!err) + { + this->ChipID.ProcessorName = retBuf; + this->ChipID.ModelName = retBuf; + } + // Cache size len = sizeof(value); err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0); this->Features.L1CacheSize = static_cast< int >( value ); + len = sizeof(value); err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0); this->Features.L2CacheSize = static_cast< int >( value ); - + return true; #else return false; @@ -3019,7 +4149,7 @@ kwsys_stl::string SystemInformationImplementation::ExtractValueFromSysCtl(const /** Run a given process */ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector<const char*> args) -{ +{ kwsys_stl::string buffer = ""; // Run the application @@ -3085,7 +4215,7 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha args.clear(); args.push_back("kstat"); args.push_back("-p"); - + kwsys_stl::string command = arguments; size_t start = command.npos; size_t pos = command.find(' ',0); @@ -3105,7 +4235,7 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha b0 = command.find('"',b1+1); b1 = command.find('"',b0+1); } - + if(!inQuotes) { kwsys_stl::string arg = command.substr(start+1,pos-start-1); @@ -3117,7 +4247,7 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha arg.erase(quotes,1); quotes = arg.find('"'); } - args.push_back(arg.c_str()); + args.push_back(arg.c_str()); start = pos; } pos = command.find(' ',pos+1); @@ -3154,7 +4284,7 @@ bool SystemInformationImplementation::QuerySolarisInfo() this->NumberOfPhysicalCPU = static_cast<unsigned int>( atoi(this->ParseValueFromKStat("-n syste_misc -s ncpus").c_str())); this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU; - + if(this->NumberOfPhysicalCPU!=0) { this->NumberOfLogicalCPU /= this->NumberOfPhysicalCPU; @@ -3163,19 +4293,19 @@ bool SystemInformationImplementation::QuerySolarisInfo() this->CPUSpeedInMHz = static_cast<float>(atoi(this->ParseValueFromKStat("-s clock_MHz").c_str())); // Chip family - this->ChipID.Family = 0; - + this->ChipID.Family = 0; + // Chip Vendor this->ChipID.Vendor = "Sun"; this->FindManufacturer(); - + // Chip Model this->ChipID.ProcessorName = this->ParseValueFromKStat("-s cpu_type"); this->ChipID.Model = 0; // Cache size - this->Features.L1CacheSize = 0; - this->Features.L2CacheSize = 0; + this->Features.L1CacheSize = 0; + this->Features.L2CacheSize = 0; char* tail; unsigned long totalMemory = @@ -3200,16 +4330,16 @@ bool SystemInformationImplementation::QueryHaikuInfo() system_info info; get_system_info(&info); - + this->NumberOfPhysicalCPU = info.cpu_count; this->CPUSpeedInMHz = info.cpu_clock_speed / 1000000.0F; // Physical Memory this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024) ; - this->AvailablePhysicalMemory = this->TotalPhysicalMemory - + this->AvailablePhysicalMemory = this->TotalPhysicalMemory - ((info.used_pages * B_PAGE_SIZE) / (1024 * 1024)); - + // NOTE: get_system_info_etc is currently a private call so just set to 0 // until it becomes public this->TotalVirtualMemory = 0; @@ -3237,8 +4367,8 @@ bool SystemInformationImplementation::QueryHaikuInfo() this->ChipID.Type = cpu_info.eax_1.type; // Chip family - this->ChipID.Family = cpu_info.eax_1.family; - + this->ChipID.Family = cpu_info.eax_1.family; + // Chip Model this->ChipID.Model = cpu_info.eax_1.model; @@ -3365,16 +4495,16 @@ bool SystemInformationImplementation::QueryOSInformation() ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi); - if (!bOsVersionInfoEx) + if (!bOsVersionInfoEx) { osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - if (!GetVersionEx ((OSVERSIONINFO *) &osvi)) + if (!GetVersionEx ((OSVERSIONINFO *) &osvi)) { return false; } } - switch (osvi.dwPlatformId) + switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: // Test for the product. @@ -3417,40 +4547,40 @@ bool SystemInformationImplementation::QueryOSInformation() { this->OSRelease += " Personal"; } - else + else { this->OSRelease += " Professional"; } } #endif - } + } else if (osvi.wProductType == VER_NT_SERVER) { // Check for .NET Server instead of Windows XP. - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { this->OSRelease = ".NET"; } // Continue with the type detection. - if (osvi.wSuiteMask & VER_SUITE_DATACENTER) + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { this->OSRelease += " DataCenter Server"; } - else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { this->OSRelease += " Advanced Server"; } - else + else { this->OSRelease += " Server"; } } sprintf (operatingSystem, "%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); - this->OSVersion = operatingSystem; + this->OSVersion = operatingSystem; } - else + else #endif // VER_NT_WORKSTATION { HKEY hKey; @@ -3473,7 +4603,7 @@ bool SystemInformationImplementation::QueryOSInformation() { this->OSRelease += " Standard Server"; } - else + else { this->OSRelease += " Server"; } @@ -3485,7 +4615,7 @@ bool SystemInformationImplementation::QueryOSInformation() { this->OSRelease += " Enterprise Server"; } - else + else { this->OSRelease += " Advanced Server"; } @@ -3493,7 +4623,7 @@ bool SystemInformationImplementation::QueryOSInformation() } // Display version, service pack (if any), and build number. - if (osvi.dwMajorVersion <= 4) + if (osvi.dwMajorVersion <= 4) { // NB: NT 4.0 and earlier. sprintf (operatingSystem, "version %ld.%ld %s (Build %ld)", @@ -3502,30 +4632,30 @@ bool SystemInformationImplementation::QueryOSInformation() osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; - } - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) + } + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { // Windows XP and .NET server. typedef BOOL (CALLBACK* LPFNPROC) (HANDLE, BOOL *); - HINSTANCE hKernelDLL; + HINSTANCE hKernelDLL; LPFNPROC DLLProc; - + // Load the Kernel32 DLL. hKernelDLL = LoadLibrary ("kernel32"); - if (hKernelDLL != NULL) { + if (hKernelDLL != NULL) { // Only XP and .NET Server support IsWOW64Process so... Load dynamically! - DLLProc = (LPFNPROC) GetProcAddress (hKernelDLL, "IsWow64Process"); - + DLLProc = (LPFNPROC) GetProcAddress (hKernelDLL, "IsWow64Process"); + // If the function address is valid, call the function. if (DLLProc != NULL) (DLLProc) (GetCurrentProcess (), &bIsWindows64Bit); else bIsWindows64Bit = false; - + // Free the DLL module. - FreeLibrary (hKernelDLL); - } - } - else - { + FreeLibrary (hKernelDLL); + } + } + else + { // Windows 2000 and everything else. sprintf (operatingSystem,"%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; @@ -3534,32 +4664,32 @@ bool SystemInformationImplementation::QueryOSInformation() case VER_PLATFORM_WIN32_WINDOWS: // Test for the product. - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) { this->OSRelease = "95"; - if(osvi.szCSDVersion[1] == 'C') + if(osvi.szCSDVersion[1] == 'C') { this->OSRelease += "OSR 2.5"; } - else if(osvi.szCSDVersion[1] == 'B') + else if(osvi.szCSDVersion[1] == 'B') { this->OSRelease += "OSR 2"; } - } + } - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) { this->OSRelease = "98"; - if (osvi.szCSDVersion[1] == 'A' ) + if (osvi.szCSDVersion[1] == 'A' ) { this->OSRelease += "SE"; } - } + } - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { this->OSRelease = "Me"; - } + } break; case VER_PLATFORM_WIN32s: @@ -3583,7 +4713,7 @@ bool SystemInformationImplementation::QueryOSInformation() WSACleanup( ); } this->Hostname = name; - + const char* arch = getenv("PROCESSOR_ARCHITECTURE"); if(arch) { @@ -3604,51 +4734,41 @@ bool SystemInformationImplementation::QueryOSInformation() } #ifdef __APPLE__ - this->CallSwVers(); + this->OSName="Unknown Apple OS"; + this->OSRelease="Unknown product version"; + this->OSVersion="Unknown build version"; + + this->CallSwVers("-productName",this->OSName); + this->CallSwVers("-productVersion",this->OSRelease); + this->CallSwVers("-buildVersion",this->OSVersion); #endif #endif return true; - } - -void SystemInformationImplementation::CallSwVers() +int SystemInformationImplementation::CallSwVers( + const char *arg, + kwsys_stl::string &ver) { #ifdef __APPLE__ - kwsys_stl::string output; kwsys_stl::vector<const char*> args; - args.clear(); - - args.push_back("sw_vers"); - args.push_back("-productName"); - args.push_back(0); - output = this->RunProcess(args); - this->TrimNewline(output); - this->OSName = output; - args.clear(); - args.push_back("sw_vers"); - args.push_back("-productVersion"); + args.push_back(arg); args.push_back(0); - output = this->RunProcess(args); - this->TrimNewline(output); - this->OSRelease = output; - args.clear(); - - args.push_back("sw_vers"); - args.push_back("-buildVersion"); - args.push_back(0); - output = this->RunProcess(args); - this->TrimNewline(output); - this->OSVersion = output; + ver = this->RunProcess(args); + this->TrimNewline(ver); +#else + // avoid C4100 + (void)arg; + (void)ver; #endif + return 0; } - void SystemInformationImplementation::TrimNewline(kwsys_stl::string& output) -{ +{ // remove \r kwsys_stl::string::size_type pos=0; while((pos = output.find("\r", pos)) != kwsys_stl::string::npos) diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in index b6ebe6a..8f4cb4e 100644 --- a/Source/kwsys/SystemInformation.hxx.in +++ b/Source/kwsys/SystemInformation.hxx.in @@ -24,14 +24,22 @@ namespace @KWSYS_NAMESPACE@ { - -// forward declare the implementation class +// forward declare the implementation class class SystemInformationImplementation; - -class @KWSYS_NAMESPACE@_EXPORT SystemInformation -{ +class @KWSYS_NAMESPACE@_EXPORT SystemInformation +{ +#if @KWSYS_USE_LONG_LONG@ + typedef long long LongLong; +#elif @KWSYS_USE___INT64@ + typedef __int64 LongLong; +#else +# error "No Long Long" +#endif + friend class SystemInformationImplementation; + SystemInformationImplementation* Implementation; public: + SystemInformation (); ~SystemInformation (); @@ -40,6 +48,7 @@ public: kwsys_stl::string GetTypeID(); kwsys_stl::string GetFamilyID(); kwsys_stl::string GetModelID(); + kwsys_stl::string GetModelName(); kwsys_stl::string GetSteppingCode(); const char * GetExtendedProcessorName(); const char * GetProcessorSerialNumber(); @@ -49,13 +58,27 @@ public: int GetProcessorAPICID(); int GetProcessorCacheXSize(long int); bool DoesCPUSupportFeature(long int); - - const char * GetOSName(); + + // returns an informative general description of the cpu + // on this system. + kwsys_stl::string GetCPUDescription(); + const char * GetHostname(); + kwsys_stl::string GetFullyQualifiedDomainName(); + + const char * GetOSName(); const char * GetOSRelease(); const char * GetOSVersion(); const char * GetOSPlatform(); + int GetOSIsWindows(); + int GetOSIsLinux(); + int GetOSIsApple(); + + // returns an informative general description of the os + // on this system. + kwsys_stl::string GetOSDescription(); + bool Is64Bits(); unsigned int GetNumberOfLogicalCPU(); // per physical cpu @@ -63,20 +86,62 @@ public: bool DoesCPUSupportCPUID(); + // Retrieve id of the current running process + LongLong GetProcessId(); + // Retrieve memory information in megabyte. size_t GetTotalVirtualMemory(); size_t GetAvailableVirtualMemory(); size_t GetTotalPhysicalMemory(); - size_t GetAvailablePhysicalMemory(); + size_t GetAvailablePhysicalMemory(); + + // returns an informative general description if the installed and + // available ram on this system. See the GetHostMmeoryTotal, and + // Get{Host,Proc}MemoryAvailable methods for more information. + kwsys_stl::string GetMemoryDescription( + const char *hostLimitEnvVarName=NULL, + const char *procLimitEnvVarName=NULL); + + // Retrieve amount of physical memory installed on the system in KiB + // units. + LongLong GetHostMemoryTotal(); + + // Get total system RAM in units of KiB available colectivley to all + // processes in a process group. An example of a process group + // are the processes comprising an mpi program which is running in + // parallel. The amount of memory reported may differ from the host + // total if a host wide resource limit is applied. Such reource limits + // are reported to us via an applicaiton specified environment variable. + LongLong GetHostMemoryAvailable(const char *hostLimitEnvVarName=NULL); + + // Get total system RAM in units of KiB available to this process. + // This may differ from the host available if a per-process resource + // limit is applied. per-process memory limits are applied on unix + // system via rlimit api. Resource limits that are not imposed via + // rlimit api may be reported to us via an application specified + // environment variable. + LongLong GetProcMemoryAvailable( + const char *hostLimitEnvVarName=NULL, + const char *procLimitEnvVarName=NULL); + + // Get the system RAM used by all processes on the host, in units of KiB. + LongLong GetHostMemoryUsed(); + + // Get system RAM used by this process id in units of KiB. + LongLong GetProcMemoryUsed(); + + // enable/disable stack trace signal handler. In order to + // produce an informative stack trace the application should + // be dynamically linked and compiled with debug symbols. + static + void SetStackTraceOnError(int enable); /** Run the different checks */ void RunCPUCheck(); void RunOSCheck(); void RunMemoryCheck(); -private: - SystemInformationImplementation* Implementation; - }; + } // namespace @KWSYS_NAMESPACE@ /* Undefine temporary macros. */ diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 66850e9..1054d65 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1665,7 +1665,7 @@ kwsys_stl::string SystemTools::EscapeChars( kwsys_stl::string n; if (str) { - if (!chars_to_escape | !*chars_to_escape) + if (!chars_to_escape || !*chars_to_escape) { n.append(str); } @@ -2754,9 +2754,15 @@ kwsys_stl::string SystemTools::GetRealPath(const char* path) bool SystemTools::FileIsDirectory(const char* name) { + size_t length = strlen(name); + if (length == 0) + { + return false; + } + // Remove any trailing slash from the name. char buffer[KWSYS_SYSTEMTOOLS_MAXPATH]; - size_t last = strlen(name)-1; + size_t last = length-1; if(last > 0 && (name[last] == '/' || name[last] == '\\') && strcmp(name, "/") !=0) { diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index 7b73d06..ae58703 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -358,6 +358,30 @@ int main() } #endif +#ifdef TEST_KWSYS_IOS_HAS_ISTREAM___INT64 +int test_istream(kwsys_ios::istream& is, __int64& x) +{ + return (is >> x)? 1:0; +} +int main() +{ + __int64 x = 0; + return test_istream(kwsys_ios::cin, x); +} +#endif + +#ifdef TEST_KWSYS_IOS_HAS_OSTREAM___INT64 +int test_ostream(kwsys_ios::ostream& os, __int64 x) +{ + return (os << x)? 1:0; +} +int main() +{ + __int64 x = 0; + return test_ostream(kwsys_ios::cout, x); +} +#endif + #ifdef TEST_KWSYS_CHAR_IS_SIGNED /* Return 0 for char signed and 1 for char unsigned. */ int main() @@ -428,6 +452,48 @@ int main() } #endif +#ifdef TEST_KWSYS_CXX_HAS_RLIMIT64 +# if defined(KWSYS_HAS_LFS) +# define _LARGEFILE_SOURCE +# define _LARGEFILE64_SOURCE +# define _LARGE_FILES +# define _FILE_OFFSET_BITS 64 +# endif +# include <sys/resource.h> +int main() +{ + struct rlimit64 rlim; + return getrlimit64(0,&rlim); +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_ATOLL +#include <stdlib.h> +int main() +{ + const char *str="1024"; + return static_cast<int>(atoll(str)); +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_ATOL +#include <stdlib.h> +int main() +{ + const char *str="1024"; + return static_cast<int>(atol(str)); +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS__ATOI64 +#include <stdlib.h> +int main() +{ + const char *str="1024"; + return static_cast<int>(_atoi64(str)); +} +#endif + #ifdef TEST_KWSYS_CXX_TYPE_INFO /* Collect fundamental type information and save it to a CMake script. */ diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c index 877002a..ec561ea 100644 --- a/Source/kwsys/testProcess.c +++ b/Source/kwsys/testProcess.c @@ -82,6 +82,14 @@ int test3(int argc, const char* argv[]) int test4(int argc, const char* argv[]) { + /* Prepare a pointer to an invalid address. Don't use null, because + dereferencing null is undefined behaviour and compilers are free to + do whatever they want. ex: Clang will warn at compile time, or even + optimize away the write. We hope to 'outsmart' them by using + 'volatile' and a slightly larger address, based on a runtime value. */ + volatile int* invalidAddress = 0; + invalidAddress += argc?1:2; + #if defined(_WIN32) /* Avoid error diagnostic popups since we are crashing on purpose. */ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); @@ -94,11 +102,8 @@ int test4(int argc, const char* argv[]) fprintf(stderr, "Output before crash on stderr from crash test.\n"); fflush(stdout); fflush(stderr); -#if defined(__clang__) - *(int*)1 = 0; /* Clang warns about 0-ptr; undefined behavior. */ -#else - *(int*)0 = 0; -#endif + /* Provoke deliberate crash by writing to the invalid address. */ + *invalidAddress = 0; fprintf(stdout, "Output after crash on stdout from crash test.\n"); fprintf(stderr, "Output after crash on stderr from crash test.\n"); return 0; diff --git a/Source/kwsys/testRegistry.cxx b/Source/kwsys/testRegistry.cxx deleted file mode 100644 index 7e9b0d4..0000000 --- a/Source/kwsys/testRegistry.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/*============================================================================ - KWSys - Kitware System Library - Copyright 2000-2009 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. -============================================================================*/ -#include "kwsysPrivate.h" - -#include KWSYS_HEADER(Registry.hxx) -#include KWSYS_HEADER(ios/iostream) -#include <string.h> - -// Work-around CMake dependency scanning limitation. This must -// duplicate the above list of headers. -#if 0 -# include "Registry.hxx.in" -# include "kwsys_ios_iostream.h.in" -#endif - -#define IFT(x,res) if ( !x ) \ - { \ - res = 1; \ - kwsys_ios::cout << "Error in: " << #x << kwsys_ios::endl; \ - } -#define IFNT(x,res) if ( x ) \ - { \ - res = 1; \ - kwsys_ios::cout << "Error in: " << #x << kwsys_ios::endl; \ - } - -#define CHE(x,y,res) if ( x && strcmp(x,y) ) \ - { \ - res = 1; \ - kwsys_ios::cout << "Error, " << x << " != " << y << kwsys_ios::endl; \ - } - -int testRegistry(int, char*[]) -{ - int res = 0; - - kwsys::Registry reg; - reg.SetTopLevel("TestRegistry"); - - IFT(reg.SetValue("TestSubkey", "TestKey1", "Test Value 1"), res); - IFT(reg.SetValue("TestSubkey1", "TestKey2", "Test Value 2"), res); - IFT(reg.SetValue("TestSubkey", "TestKey3", "Test Value 3"), res); - IFT(reg.SetValue("TestSubkey2", "TestKey4", "Test Value 4"), res); - - const char *buffer; - IFT(reg.ReadValue("TestSubkey", "TestKey1", &buffer), res); - CHE(buffer, "Test Value 1", res); - IFT(reg.ReadValue("TestSubkey1", "TestKey2", &buffer), res); - CHE(buffer, "Test Value 2", res); - IFT(reg.ReadValue("TestSubkey", "TestKey3", &buffer), res); - CHE(buffer, "Test Value 3", res); - IFT(reg.ReadValue("TestSubkey2", "TestKey4", &buffer), res); - CHE(buffer, "Test Value 4", res); - - IFT(reg.SetValue("TestSubkey", "TestKey1", "New Test Value 1"), res); - IFT(reg.SetValue("TestSubkey1", "TestKey2", "New Test Value 2"), res); - IFT(reg.SetValue("TestSubkey", "TestKey3", "New Test Value 3"), res); - IFT(reg.SetValue("TestSubkey2", "TestKey4", "New Test Value 4"), res); - - IFT(reg.ReadValue("TestSubkey", "TestKey1", &buffer), res); - CHE(buffer, "New Test Value 1", res); - IFT(reg.ReadValue("TestSubkey1", "TestKey2", &buffer), res); - CHE(buffer, "New Test Value 2", res); - IFT(reg.ReadValue("TestSubkey", "TestKey3", &buffer), res); - CHE(buffer, "New Test Value 3", res); - IFT(reg.ReadValue("TestSubkey2", "TestKey4", &buffer), res); - CHE(buffer, "New Test Value 4", res); - - IFT( reg.DeleteValue("TestSubkey", "TestKey1"), res); - IFNT(reg.ReadValue( "TestSubkey", "TestKey1", &buffer), res); - IFT( reg.DeleteValue("TestSubkey1", "TestKey2"), res); - IFNT(reg.ReadValue( "TestSubkey1", "TestKey2", &buffer), res); - IFT( reg.DeleteValue("TestSubkey", "TestKey3"), res); - IFNT(reg.ReadValue( "TestSubkey", "TestKey3", &buffer), res); - IFT( reg.DeleteValue("TestSubkey2", "TestKey4"), res); - IFNT(reg.ReadValue( "TestSubkey2", "TestKey5", &buffer), res); - - const char* longStringWithNewLines = "Value with embedded CR and LF characters CR='\015' LF='\012' CRLF='\015\012'"; - IFT(reg.SetValue("TestSubkeyWithVeryLongInFactSoLongItsHardToImagineAnybodyWouldReallyDoItLongName", "TestKey1", longStringWithNewLines), res); - IFT(reg.ReadValue("TestSubkeyWithVeryLongInFactSoLongItsHardToImagineAnybodyWouldReallyDoItLongName", "TestKey1", &buffer), res); - CHE(buffer, longStringWithNewLines, res); - IFT(reg.DeleteValue("TestSubkeyWithVeryLongInFactSoLongItsHardToImagineAnybodyWouldReallyDoItLongName", "TestKey1"), res); - IFNT(reg.ReadValue("TestSubkeyWithVeryLongInFactSoLongItsHardToImagineAnybodyWouldReallyDoItLongName", "TestKey1", &buffer), res); - - IFT(reg.SetValue("TestSubkeyWith = EqualSignChar", "TestKey = 1", "Some value"), res); - IFT(reg.ReadValue("TestSubkeyWith = EqualSignChar", "TestKey = 1", &buffer), res); - CHE(buffer, "Some value", res); - IFT(reg.DeleteValue("TestSubkeyWith = EqualSignChar", "TestKey = 1"), res); - IFNT(reg.ReadValue("TestSubkeyWith = EqualSignChar", "TestKey = 1", &buffer), res); - - if ( res ) - { - kwsys_ios::cout << "Test failed" << kwsys_ios::endl; - } - else - { - kwsys_ios::cout << "Test passed" << kwsys_ios::endl; - } - return res; -} diff --git a/Source/kwsys/testSystemInformation.cxx b/Source/kwsys/testSystemInformation.cxx index b3afc9d..cfd7ce2 100644 --- a/Source/kwsys/testSystemInformation.cxx +++ b/Source/kwsys/testSystemInformation.cxx @@ -13,8 +13,6 @@ #include KWSYS_HEADER(SystemInformation.hxx) #include KWSYS_HEADER(ios/iostream) - - // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 @@ -22,12 +20,31 @@ # include "kwsys_ios_iostream.h.in" #endif -#define printMethod(inof, m) kwsys_ios::cout << #m << ": " \ +#if defined(KWSYS_USE_LONG_LONG) +# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG) +# define iostreamLongLong(x) (x) +# else +# define iostreamLongLong(x) ((long)x) +# endif +#elif defined(KWSYS_USE___INT64) +# if defined(KWSYS_IOS_HAS_OSTREAM___INT64) +# define iostreamLongLong(x) (x) +# else +# define iostreamLongLong(x) ((long)x) +# endif +#else +# error "No Long Long" +#endif + +#define printMethod(info, m) kwsys_ios::cout << #m << ": " \ << info.m() << "\n" -#define printMethod2(inof, m, unit) kwsys_ios::cout << #m << ": " \ +#define printMethod2(info, m, unit) kwsys_ios::cout << #m << ": " \ << info.m() << " " << unit << "\n" +#define printMethod3(info, m, unit) kwsys_ios::cout << #m << ": " \ +<< iostreamLongLong(info.m) << " " << unit << "\n" + int testSystemInformation(int, char*[]) { kwsys::SystemInformation info; @@ -35,7 +52,11 @@ int testSystemInformation(int, char*[]) info.RunOSCheck(); info.RunMemoryCheck(); printMethod(info, GetOSName); + printMethod(info, GetOSIsLinux); + printMethod(info, GetOSIsApple); + printMethod(info, GetOSIsWindows); printMethod(info, GetHostname); + printMethod(info, GetFullyQualifiedDomainName); printMethod(info, GetOSRelease); printMethod(info, GetOSVersion); printMethod(info, GetOSPlatform); @@ -45,6 +66,7 @@ int testSystemInformation(int, char*[]) printMethod(info, GetFamilyID); printMethod(info, GetModelID); printMethod(info, GetExtendedProcessorName); + printMethod(info, GetSteppingCode); printMethod(info, GetProcessorSerialNumber); printMethod2(info, GetProcessorCacheSize, "KB"); printMethod(info, GetLogicalProcessorsPerPhysical); @@ -58,6 +80,11 @@ int testSystemInformation(int, char*[]) printMethod2(info, GetAvailableVirtualMemory, "MB"); printMethod2(info, GetTotalPhysicalMemory, "MB"); printMethod2(info, GetAvailablePhysicalMemory, "MB"); + printMethod3(info, GetHostMemoryTotal(), "KiB"); + printMethod3(info, GetHostMemoryAvailable("KWSHL"), "KiB"); + printMethod3(info, GetProcMemoryAvailable("KWSHL","KWSPL"), "KiB"); + printMethod3(info, GetHostMemoryUsed(), "KiB"); + printMethod3(info, GetProcMemoryUsed(), "KiB"); //int GetProcessorCacheXSize(long int); // bool DoesCPUSupportFeature(long int); diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 2a70b6e..2792751 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -60,6 +60,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx "static const char* zot_macro_tgt = \"zot_macro_tgt\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h + "#define link_depends_no_shared_lib_value 1\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h + "#define link_depends_no_shared_exe_value 0\n") +set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt) + help_xcode_depends() message("Building project first time") @@ -125,6 +131,19 @@ else() message(SEND_ERROR "Project did not initially build properly: ${out}") endif() +if(EXISTS "${link_depends_no_shared_check_txt}") + file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1) + if("${link_depends_no_shared_check}" STREQUAL "1") + message(STATUS "link_depends_no_shared_exe is newer than link_depends_no_shared_lib as expected.") + else() + message(SEND_ERROR "Project did not initially build properly: " + "link_depends_no_shared_exe is older than link_depends_no_shared_lib.") + endif() +else() + message(SEND_ERROR "Project did not initially build properly: " + "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") +endif() + message("Waiting 3 seconds...") # any additional argument will cause ${bar} to wait forever execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) @@ -141,6 +160,9 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx "static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h + "#define link_depends_no_shared_lib_value 0\n") + if(TEST_LINK_DEPENDS) file(WRITE ${TEST_LINK_DEPENDS} "2") endif() @@ -219,3 +241,15 @@ is not newer than dependency ") endif() endif() + +if(EXISTS "${link_depends_no_shared_check_txt}") + file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1) + if("${link_depends_no_shared_check}" STREQUAL "0") + message(STATUS "link_depends_no_shared_exe is older than link_depends_no_shared_lib as expected.") + else() + message(SEND_ERROR "Project did not rebuild properly: link_depends_no_shared_exe is newer than link_depends_no_shared_lib.") + endif() +else() + message(SEND_ERROR "Project did not rebuild properly. " + "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") +endif() diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 01f5f62..f8a3d15 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -64,7 +64,8 @@ if("${CMAKE_GENERATOR}" MATCHES "Make") # Test the IMPLICIT_DEPENDS feature. set(ZOT_DEPENDS IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep.cxx) set(ZOT_CUSTOM_DEP - IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom.cxx) + IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom.cxx + CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom2.cxx ) else() # No IMPLICIT_DEPENDS...just depend directly. set(ZOT_DEPENDS DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx.in) @@ -107,3 +108,18 @@ if(TEST_LINK_DEPENDS) add_executable(linkdep linkdep.cxx) set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) endif() + +add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c + ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_lib.h) +add_executable(link_depends_no_shared_exe link_depends_no_shared_exe.c + ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_exe.h) +target_link_libraries(link_depends_no_shared_exe link_depends_no_shared_lib) +set_property(TARGET link_depends_no_shared_exe PROPERTY LINK_DEPENDS_NO_SHARED 1) +add_custom_target(link_depends_no_shared_check ALL + COMMAND ${CMAKE_COMMAND} + -Dlib=$<TARGET_FILE:link_depends_no_shared_lib> + -Dexe=$<TARGET_FILE:link_depends_no_shared_exe> + -Dout=${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_check.txt + -P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake + ) +add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe) diff --git a/Tests/BuildDepends/Project/dep_custom2.cxx b/Tests/BuildDepends/Project/dep_custom2.cxx new file mode 100644 index 0000000..ac9dee1 --- /dev/null +++ b/Tests/BuildDepends/Project/dep_custom2.cxx @@ -0,0 +1,2 @@ +#include <zot_custom.hxx.in> +// some comment diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake new file mode 100644 index 0000000..3a61137 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake @@ -0,0 +1,7 @@ +if(NOT EXISTS "${lib}" OR NOT EXISTS "${exe}") + file(REMOVE "${out}") +elseif("${exe}" IS_NEWER_THAN "${lib}") + file(WRITE "${out}" "1\n") +else() + file(WRITE "${out}" "0\n") +endif() diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_exe.c b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c new file mode 100644 index 0000000..e9113a2 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c @@ -0,0 +1,9 @@ +#include "link_depends_no_shared_exe.h" +#ifdef _WIN32 +__declspec(dllimport) +#endif +int link_depends_no_shared_lib(void); +int main() +{ + return link_depends_no_shared_lib() + link_depends_no_shared_exe_value; +} diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_lib.c b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c new file mode 100644 index 0000000..d226289 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c @@ -0,0 +1,8 @@ +#include "link_depends_no_shared_lib.h" +#ifdef _WIN32 +__declspec(dllexport) +#endif +int link_depends_no_shared_lib(void) +{ + return link_depends_no_shared_lib_value; +} diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index 1faa888..60b36fc 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -56,3 +56,10 @@ assert_property(targetA LINK_INTERFACE_LIBRARIES "") target_link_libraries(targetA depB depC) assert_property(targetA LINK_INTERFACE_LIBRARIES "") + +# Exclude depIfaceOnly from ALL so that it will only be built if something +# depends on it. As it is in the link interface of depB, targetA +# will depend on it. That dependency is what is being tested here. +add_library(depIfaceOnly SHARED EXCLUDE_FROM_ALL depIfaceOnly.cpp) +generate_export_header(depIfaceOnly) +set_property(TARGET depB APPEND PROPERTY LINK_INTERFACE_LIBRARIES depIfaceOnly) diff --git a/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp new file mode 100644 index 0000000..3b90af0 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.cpp @@ -0,0 +1,7 @@ + +#include "depIfaceOnly.h" + +int DepIfaceOnly::foo() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h new file mode 100644 index 0000000..dddf6a5 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depIfaceOnly.h @@ -0,0 +1,7 @@ + +#include "depifaceonly_export.h" + +struct DEPIFACEONLY_EXPORT DepIfaceOnly +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp index 3c6472e..6ff65b1 100644 --- a/Tests/CMakeCommands/target_link_libraries/targetA.cpp +++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp @@ -1,6 +1,7 @@ #include "depB.h" #include "depC.h" +#include "depIfaceOnly.h" int main(int argc, char **argv) { @@ -8,5 +9,7 @@ int main(int argc, char **argv) DepB b; DepC c; - return a.foo() + b.foo() + c.foo(); + DepIfaceOnly iface_only; + + return a.foo() + b.foo() + c.foo() + iface_only.foo(); } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index bbf804b..b3302f9 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -573,6 +573,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand") + ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND}) + add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory" @@ -695,6 +697,29 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() endif() + # On Windows run the CPackWiXGenerator test + # if the WiX Toolset seems to be available + if(WIN32) + file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT) + + find_program(WIX_LIGHT_EXECUTABLE light + PATHS "${WIX_ROOT}/bin" + DOC "WiX Toolset light.exe location") + + if(WIX_LIGHT_EXECUTABLE) + add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator" + "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project CPackWiXGenerator + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" + -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake") + endif() + endif() + if(CTEST_RUN_CPackComponents) set(CPackComponents_EXTRA_OPTIONS) if(APPLE) @@ -742,7 +767,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # ACTIVE_CPACK_GENERATORS variable # now contains the list of 'active generators' set(CPackComponentsForAll_EXTRA_OPTIONS) - set(CPackRun_CPackCommand "-DCPackCommand=${CMAKE_CPACK_COMMAND}") # set up list of CPack generators list(APPEND GENLST "ZIP") if(APPLE) @@ -782,7 +806,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --graphviz=CPackComponentsForAll.dot --test-command ${CMAKE_CMAKE_COMMAND} "-DCPackComponentsForAll_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}" - "${CPackRun_CPackCommand}" "${CPackRun_CPackGen}" "${CPackRun_CPackComponentWay}" -P "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake") @@ -817,7 +840,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command ${CMAKE_CMAKE_COMMAND} -D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators - -D cpack=${CMAKE_CPACK_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators/RunCPack.cmake ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators") @@ -983,6 +1005,36 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set_tests_properties(ExternalProject PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate" + "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project ExternalProjectUpdateTest + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") + set_tests_properties(ExternalProjectUpdateSetup PROPERTIES + TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + + add_test(NAME ExternalProjectUpdate + COMMAND ${CMAKE_CMAKE_COMMAND} + -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate + -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate + -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR} + -DCMAKE_TEST_MAKEPROGRAM=${CMAKE_TEST_MAKEPROGRAM} + -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND} + -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") + set_tests_properties(ExternalProjectUpdate PROPERTIES + TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT} + WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate + DEPENDS ExternalProjectUpdateSetup ) + # do each of the tutorial steps foreach(STP RANGE 1 7) add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND} @@ -1412,6 +1464,35 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --test-command VSMidl) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl") + + if(NOT MSVC60 AND NOT CMAKE_TEST_MAKEPROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + # The test (and tested property) works with .sln files, so it's skipped when: + # * Using VS6, which doesn't use .sln files + # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file + set(_last_test "") + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild" + "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild" + --build-config ${config} + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project VSExcludeFromDefaultBuild + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command ${CMAKE_COMMAND} + -D "activeConfig=${config}" + -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}" + -D "dir=${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild" + -P "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake") + if(_last_test) + set_property(TEST VSExcludeFromDefaultBuild-${config} PROPERTY DEPENDS ${_last_test}) + endif() + set(_last_test "VSExcludeFromDefaultBuild-${config}") + endforeach() + unset(_last_test) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild") + endif() endif() if (APPLE) @@ -1878,6 +1959,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" ) + add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4 + --output-on-failure -C "\${CTestTest_CONFIG}") + add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels) set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2") set_tests_properties(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 212c758..739593c 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -70,8 +70,9 @@ endmacro() # If any of these modules reported that it was found a version number should have been # reported. -foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG HSPELL - JASPER LIBLZMA LIBXML2 LIBXSLT PERL PKG_CONFIG PostgreSQL TIFF ZLIB) +foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG + HSPELL ICOTOOL JASPER LIBLZMA LIBXML2 LIBXSLT PERL PKG_CONFIG + PostgreSQL TIFF ZLIB) check_version_string(${VTEST} ${VTEST}_VERSION_STRING) endforeach() diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 51a630f..be7ddbc 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -32,9 +32,29 @@ add_CMakeOnly_test(SelectLibraryConfigurations) add_CMakeOnly_test(TargetScope) add_CMakeOnly_test(find_library) +add_CMakeOnly_test(find_path) add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} -DTEST=ProjectInclude -DCMAKE_ARGS=-DCMAKE_PROJECT_ProjectInclude_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake ) + +include(${CMAKE_SOURCE_DIR}/Modules/CMakeParseArguments.cmake) + +function(add_major_test module) + cmake_parse_arguments(MAJOR_TEST "NOLANG" "VERSION_VAR" "VERSIONS" ${ARGN}) + foreach (_version IN LISTS MAJOR_TEST_VERSIONS) + add_test(CMakeOnly.MajorVersionSelection-${module}_${_version} + ${CMAKE_CMAKE_COMMAND} + -DTEST=MajorVersionSelection-${module}_${_version} + -DTEST_SOURCE=MajorVersionSelection + "-DCMAKE_ARGS=-DMAJOR_TEST_MODULE=${module};-DMAJOR_TEST_VERSION=${_version};-DMAJOR_TEST_NO_LANGUAGES=${MAJOR_TEST_NOLANG};-DMAJOR_TEST_VERSION_VAR=${MAJOR_TEST_VERSION_VAR}" + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + endforeach () +endfunction() + +add_major_test(PythonLibs VERSIONS 2 3 VERSION_VAR PYTHONLIBS_VERSION_STRING) +add_major_test(PythonInterp NOLANG VERSIONS 2 3 VERSION_VAR PYTHON_VERSION_STRING) +add_major_test(Qt VERSIONS 3 4 VERSION_VAR QT_VERSION_STRING) diff --git a/Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt b/Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt new file mode 100644 index 0000000..74f5451 --- /dev/null +++ b/Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 2.8) + +if (NOT MAJOR_TEST_MODULE OR NOT MAJOR_TEST_VERSION) + message(FATAL_ERROR "test selection variables not set up") +endif () + +if (MAJOR_TEST_NO_LANGUAGES) + project(major_detect_${MAJOR_TEST_MODULE}_${MAJOR_TEST_VERSION} NONE) +else () + project(major_detect_${MAJOR_TEST_MODULE}_${MAJOR_TEST_VERSION}) +endif () + +find_package(${MAJOR_TEST_MODULE} ${MAJOR_TEST_VERSION}) + +if (MAJOR_TEST_VERSION_VAR) + set(VERSION_VAR "${MAJOR_TEST_VERSION_VAR}") +else () + set(VERSION_VAR "${MAJOR_TEST_MODULE}_VERSION_STRING") +endif () + +string(TOUPPER "${MAJOR_TEST_MODULE}" MODULE_UPPER) + +if ( ( ${MAJOR_TEST_MODULE}_FOUND OR ${MODULE_UPPER}_FOUND ) AND "${VERSION_VAR}") + message(STATUS "${VERSION_VAR} is '${${VERSION_VAR}}'") + if ("${VERSION_VAR}" VERSION_LESS MAJOR_TEST_VERSION) + message(SEND_ERROR "Found version ${${VERSION_VAR}} is less than requested major version ${MAJOR_TEST_VERSION}") + endif () + math(EXPR V_PLUS_ONE "${MAJOR_TEST_VERSION} + 1") + if ("${VERSION_VAR}" VERSION_GREATER V_PLUS_ONE) + message(SEND_ERROR "Found version ${${VERSION_VAR}} is greater than requested major version ${MAJOR_TEST_VERSION}") + endif () +endif () + +if ( ( ${MAJOR_TEST_MODULE}_FOUND OR ${MODULE_UPPER}_FOUND ) AND ${MAJOR_TEST_MODULE}_VERSION_MAJOR) + message(STATUS "${MAJOR_TEST_MODULE}_VERSION_MAJOR is '${${MAJOR_TEST_MODULE}_VERSION_MAJOR}'") + if (NOT ${MAJOR_TEST_VERSION} EQUAL ${MAJOR_TEST_MODULE}_VERSION_MAJOR) + message(SEND_ERROR "We requested major version ${MAJOR_TEST_VERSION} but ${MAJOR_TEST_MODULE} set ${MAJOR_TEST_MODULE}_VERSION_MAJOR to ${${MAJOR_TEST_MODULE}_VERSION_MAJOR}") + endif () +endif () + +if ( ( ${MAJOR_TEST_MODULE}_FOUND OR ${MODULE_UPPER}_FOUND ) AND ${MODULE_UPPER}_VERSION_MAJOR) + message(STATUS "${MODULE_UPPER}_VERSION_MAJOR is '${${MODULE_UPPER}_VERSION_MAJOR}'") + if (NOT ${MAJOR_TEST_VERSION} EQUAL ${MODULE_UPPER}_VERSION_MAJOR) + message(SEND_ERROR "We requested major version ${MAJOR_TEST_VERSION} but ${MAJOR_TEST_MODULE} set ${MODULE_UPPER}_VERSION_MAJOR to ${${MODULE_UPPER}_VERSION_MAJOR}") + endif () +endif () diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index 42af068..f76db1d 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -1,4 +1,8 @@ -set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST}") +if (NOT TEST_SOURCE) + set(TEST_SOURCE "${TEST}") +endif () + +set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST_SOURCE}") set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") file(REMOVE_RECURSE "${binary_dir}") file(MAKE_DIRECTORY "${binary_dir}") diff --git a/Tests/CMakeOnly/find_library/A/libtestA.a b/Tests/CMakeOnly/find_library/A/libtestA.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CMakeOnly/find_library/A/libtestA.a diff --git a/Tests/CMakeOnly/find_library/B/libtestB.a b/Tests/CMakeOnly/find_library/B/libtestB.a new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CMakeOnly/find_library/B/libtestB.a diff --git a/Tests/CMakeOnly/find_library/CMakeLists.txt b/Tests/CMakeOnly/find_library/CMakeLists.txt index 08f9331..2d4ecaf 100644 --- a/Tests/CMakeOnly/find_library/CMakeLists.txt +++ b/Tests/CMakeOnly/find_library/CMakeLists.txt @@ -3,34 +3,34 @@ project(FindLibraryTest NONE) set(CMAKE_FIND_DEBUG_MODE 1) -macro(test_find_library expected) - get_filename_component(dir ${expected} PATH) - get_filename_component(name ${expected} NAME) - string(REGEX REPLACE "lib/?64" "lib" dir "${dir}") +macro(test_find_library desc expected) unset(LIB CACHE) - find_library(LIB - NAMES ${name} - PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${dir} - NO_DEFAULT_PATH - ) + find_library(LIB ${ARGN} NO_DEFAULT_PATH) if(LIB) # Convert to relative path for comparison to expected location. file(RELATIVE_PATH REL_LIB "${CMAKE_CURRENT_SOURCE_DIR}" "${LIB}") - # Debugging output. - if(CMAKE_FIND_DEBUG_MODE) - message(STATUS "Library ${expected} searched as ${dir}, found as [${REL_LIB}].") - endif() - # Check and report failure. if(NOT "${REL_LIB}" STREQUAL "${expected}") - message(SEND_ERROR "Library ${l} should have been [${expected}] but was [${REL_LIB}]") + message(SEND_ERROR "Library ${expected} found as [${REL_LIB}]${desc}") + elseif(CMAKE_FIND_DEBUG_MODE) + message(STATUS "Library ${expected} found as [${REL_LIB}]${desc}") endif() else() - message(SEND_ERROR "Library ${expected} searched as ${dir}, NOT FOUND!") + message(SEND_ERROR "Library ${expected} NOT FOUND${desc}") endif() endmacro() +macro(test_find_library_subst expected) + get_filename_component(dir ${expected} PATH) + get_filename_component(name ${expected} NAME) + string(REGEX REPLACE "lib/?64" "lib" dir "${dir}") + test_find_library(", searched as ${dir}" "${expected}" + NAMES ${name} + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${dir} + ) +endmacro() + set(CMAKE_FIND_LIBRARY_PREFIXES "lib") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) @@ -44,7 +44,7 @@ foreach(lib lib/libtest3.a lib/libtest3.a ) - test_find_library(${lib}) + test_find_library_subst(${lib}) endforeach() set(CMAKE_SIZEOF_VOID_P 8) @@ -57,5 +57,18 @@ foreach(lib64 lib64/A/libtest1.a lib64/libtest1.a ) - test_find_library(${lib64}) + test_find_library_subst(${lib64}) endforeach() + +test_find_library("" A/libtestA.a + NAMES testA testB + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B + ) +test_find_library("" B/libtestB.a + NAMES testB testA + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B + ) +test_find_library("" A/libtestA.a + NAMES testB testA NAMES_PER_DIR + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B + ) diff --git a/Tests/CMakeOnly/find_path/CMakeLists.txt b/Tests/CMakeOnly/find_path/CMakeLists.txt new file mode 100644 index 0000000..0e64ed4 --- /dev/null +++ b/Tests/CMakeOnly/find_path/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 2.8) +project(FindPathTest NONE) + +set(CMAKE_FIND_DEBUG_MODE 1) + +macro(test_find_path expected) + unset(HDR CACHE) + find_path(HDR ${ARGN} + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + ) + if(HDR) + # Convert to relative path for comparison to expected location. + file(RELATIVE_PATH REL_HDR "${CMAKE_CURRENT_SOURCE_DIR}" "${HDR}") + + # Check and report failure. + if(NOT "${REL_HDR}" STREQUAL "${expected}") + message(SEND_ERROR "Header ${expected} found as [${REL_HDR}]") + elseif(CMAKE_FIND_DEBUG_MODE) + message(STATUS "Header ${expected} found as [${REL_HDR}]") + endif() + else() + message(SEND_ERROR "Header ${expected} NOT FOUND") + endif() +endmacro() + +set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +set(CMAKE_LIBRARY_ARCHITECTURE arch) + +test_find_path(include NAMES test1.h) +test_find_path(include/arch NAMES test1arch.h) diff --git a/Tests/CMakeOnly/find_path/include/arch/test1arch.h b/Tests/CMakeOnly/find_path/include/arch/test1arch.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CMakeOnly/find_path/include/arch/test1arch.h diff --git a/Tests/CMakeOnly/find_path/include/test1.h b/Tests/CMakeOnly/find_path/include/test1.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CMakeOnly/find_path/include/test1.h diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake index db92905..7be7b30 100644 --- a/Tests/CMakeTests/CheckCMakeTest.cmake +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -1,30 +1,35 @@ get_filename_component(CMakeTests_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(check_cmake_test_single prefix test testfile) + message(STATUS "Test ${prefix}-${test}...") + execute_process( + COMMAND ${CMAKE_COMMAND} -P "${testfile}" + WORKING_DIRECTORY "${CMakeTests_BIN_DIR}" + OUTPUT_VARIABLE stdout + ERROR_VARIABLE stderr + RESULT_VARIABLE result + ) + string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") + string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") + if(NOT "${result}" STREQUAL "${${test}-RESULT}") + message(FATAL_ERROR + "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" + "Test ${test} output:\n" + "${out}\n" + "${err}") + endif() + if(${test}-STDERR AND NOT "${err}" MATCHES "${${test}-STDERR}") + message(FATAL_ERROR + "Test ${test} stderr does not match\n ${${test}-STDERR}\n" + "Test ${test} output:\n" + "${out}\n" + "${err}") + endif() +endfunction() + function(check_cmake_test prefix) get_filename_component(CMakeTests_BIN_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) foreach(test ${ARGN}) - message(STATUS "Test ${prefix}-${test}...") - execute_process( - COMMAND ${CMAKE_COMMAND} -P "${CMakeTests_SRC_DIR}/${prefix}-${test}.cmake" - WORKING_DIRECTORY "${CMakeTests_BIN_DIR}" - OUTPUT_VARIABLE stdout - ERROR_VARIABLE stderr - RESULT_VARIABLE result - ) - string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") - string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") - if(NOT "${result}" STREQUAL "${${test}-RESULT}") - message(FATAL_ERROR - "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" - "Test ${test} output:\n" - "${out}\n" - "${err}") - endif() - if(${test}-STDERR AND NOT "${err}" MATCHES "${${test}-STDERR}") - message(FATAL_ERROR - "Test ${test} stderr does not match\n ${${test}-STDERR}\n" - "Test ${test} output:\n" - "${out}\n" - "${err}") - endif() + check_cmake_test_single("${prefix}" "${test}" "${CMakeTests_SRC_DIR}/${prefix}-${test}.cmake") endforeach() endfunction() diff --git a/Tests/CMakeTests/File-Glob-NoArg.cmake b/Tests/CMakeTests/File-Glob-NoArg.cmake new file mode 100644 index 0000000..486f366 --- /dev/null +++ b/Tests/CMakeTests/File-Glob-NoArg.cmake @@ -0,0 +1,2 @@ +# Checking that the call without arguments get caught by the file global protection. +file(GLOB) diff --git a/Tests/CMakeTests/File-TIMESTAMP-BadArg1.cmake b/Tests/CMakeTests/File-TIMESTAMP-BadArg1.cmake new file mode 100644 index 0000000..cc15c77 --- /dev/null +++ b/Tests/CMakeTests/File-TIMESTAMP-BadArg1.cmake @@ -0,0 +1 @@ +file(TIMESTAMP "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt") diff --git a/Tests/CMakeTests/File-TIMESTAMP-NoFile.cmake b/Tests/CMakeTests/File-TIMESTAMP-NoFile.cmake new file mode 100644 index 0000000..62390e7 --- /dev/null +++ b/Tests/CMakeTests/File-TIMESTAMP-NoFile.cmake @@ -0,0 +1,2 @@ +file(TIMESTAMP "${CMAKE_CURRENT_LIST_DIR}/DoesNotExist.cmake" output) +message("~${output}~") diff --git a/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake b/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake new file mode 100644 index 0000000..d0e5fe3 --- /dev/null +++ b/Tests/CMakeTests/File-TIMESTAMP-NotBogus.cmake @@ -0,0 +1,24 @@ +set(STAMP_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/FileTimestamp-Stamp") +set(STAMP_FORMAT "%Y-%m-%d") + +string(TIMESTAMP timestamp1 "${STAMP_FORMAT}") + +file(WRITE "${STAMP_FILENAME}" "foo") +file(TIMESTAMP "${STAMP_FILENAME}" timestamp2 "${STAMP_FORMAT}") + +string(TIMESTAMP timestamp3 "${STAMP_FORMAT}") + +message(STATUS "timestamp1 [${timestamp1}]") +message(STATUS "timestamp2 [${timestamp2}]") +message(STATUS "timestamp3 [${timestamp3}]") + +if(timestamp1 STREQUAL timestamp3) + if(NOT timestamp1 STREQUAL timestamp2) + message(FATAL_ERROR + "timestamp mismatch [${timestamp1}] != [${timestamp2}]") + else() + message("all timestamps match") + endif() +else() + message(WARNING "this test may race when run at midnight") +endif() diff --git a/Tests/CMakeTests/File-TIMESTAMP-Works.cmake b/Tests/CMakeTests/File-TIMESTAMP-Works.cmake new file mode 100644 index 0000000..4351b19 --- /dev/null +++ b/Tests/CMakeTests/File-TIMESTAMP-Works.cmake @@ -0,0 +1,2 @@ +file(TIMESTAMP "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" output UTC) +message("~${output}~") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 3c3d85d..61523e6 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -12,6 +12,10 @@ set(Copy-NoDest-RESULT 1) set(Copy-NoDest-STDERR "given no DESTINATION") set(Copy-NoFile-RESULT 1) set(Copy-NoFile-STDERR "COPY cannot find.*/does_not_exist\\.txt") +set(Glob-NoArg-RESULT 1) +set(Glob-NoArg-STDERR "file must be called with at least two arguments") +set(Make_Directory-NoArg-RESULT 1) +set(Make-Directory-NoArg-STDERR "file must be called with at least two arguments") set(MD5-NoFile-RESULT 1) set(MD5-NoFile-STDERR "file MD5 failed to read file") set(MD5-BadArg1-RESULT 1) @@ -32,6 +36,14 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(TIMESTAMP-NoFile-RESULT 0) +set(TIMESTAMP-NoFile-STDERR "~~") +set(TIMESTAMP-BadArg1-RESULT 1) +set(TIMESTAMP-BadArg1-STDERR "file sub-command TIMESTAMP requires at least two arguments") +set(TIMESTAMP-NotBogus-RESULT 0) +set(TIMESTAMP-NotBogus-STDERR "all timestamps match") +set(TIMESTAMP-Works-RESULT 0) +set(TIMESTAMP-Works-STDERR "~[0-9]*-[01][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-6][0-9]Z~") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(File @@ -42,6 +54,8 @@ check_cmake_test(File Copy-LateArg Copy-NoDest Copy-NoFile + Glob-NoArg + Make_Directory-NoArg MD5-NoFile MD5-BadArg1 MD5-BadArg2 @@ -52,8 +66,17 @@ check_cmake_test(File SHA256-Works SHA384-Works SHA512-Works + TIMESTAMP-NoFile + TIMESTAMP-BadArg1 + TIMESTAMP-NotBogus + TIMESTAMP-Works ) +file(GLOB hum) +if (NOT hum STREQUAL "") + message(FATAL_ERROR "file(GLOB hum) did not return an empty string.") +endif() + # Also execute each test listed in FileTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/FileTestScript.cmake") diff --git a/Tests/CMakeTests/GetProperty-Doc-Properties.cmake b/Tests/CMakeTests/GetProperty-Doc-Properties.cmake deleted file mode 100644 index 6c2c362..0000000 --- a/Tests/CMakeTests/GetProperty-Doc-Properties.cmake +++ /dev/null @@ -1,10 +0,0 @@ -get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS) -get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS) - -if (NOT FOO_BRIEF STREQUAL "NOTFOUND") - message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'") -endif () - -if (NOT FOO_FULL STREQUAL "NOTFOUND") - message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") -endif () diff --git a/Tests/CMakeTests/GetPropertyTest.cmake.in b/Tests/CMakeTests/GetPropertyTest.cmake.in index ab96e5b..306ab72 100644 --- a/Tests/CMakeTests/GetPropertyTest.cmake.in +++ b/Tests/CMakeTests/GetPropertyTest.cmake.in @@ -1,5 +1,33 @@ include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS) +get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS) + +if (NOT FOO_BRIEF STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'") +endif () + +if (NOT FOO_FULL STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") +endif () + +get_property(test_brief GLOBAL PROPERTY ENABLED_FEATURES BRIEF_DOCS) +get_property(test_full GLOBAL PROPERTY ENABLED_FEATURES FULL_DOCS) + +if(test_brief STREQUAL "NOTFOUND") + message(SEND_ERROR "property ENABLED_FEATURES has no BRIEF_DOCS") +endif() + +if(test_full STREQUAL "NOTFOUND") + message(SEND_ERROR "property ENABLED_FEATURES has no FULL_DOCS") +endif() + +set(test_var alpha) +get_property(result VARIABLE PROPERTY test_var) +if(NOT result STREQUAL "alpha") + message(SEND_ERROR "bad value of VARIABLE PROPERTY test_var: got '${result}' instead of 'alpha'") +endif() + set(Missing-Argument-RESULT 1) set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Missing-Argument.cmake:1 \\(get_property\\):.*get_property called with incorrect number of arguments.*") @@ -28,12 +56,6 @@ check_cmake_test(GetProperty No-Property ) -set(Doc-Properties-RESULT 0) - -check_cmake_test(GetProperty - Doc-Properties -) - set(Global-Name-RESULT 1) set(Global-Name-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Global-Name.cmake:1 \\(get_property\\):.*get_property given name for GLOBAL scope\\..*") diff --git a/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake b/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake new file mode 100644 index 0000000..0a9264f --- /dev/null +++ b/Tests/CMakeTests/List-Get-CMP0007-Warn.cmake @@ -0,0 +1,6 @@ +set(thelist "" NEW OLD) + +list(GET thelist 1 thevalue) +if (NOT thevalue STREQUAL "OLD") + message(SEND_ERROR "returned element '${thevalue}', but expected 'OLD'") +endif() diff --git a/Tests/CMakeTests/List-Get-Invalid-Index.cmake b/Tests/CMakeTests/List-Get-Invalid-Index.cmake new file mode 100644 index 0000000..178295a --- /dev/null +++ b/Tests/CMakeTests/List-Get-Invalid-Index.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(GET mylist 3 result) diff --git a/Tests/CMakeTests/List-Insert-Invalid-Index.cmake b/Tests/CMakeTests/List-Insert-Invalid-Index.cmake new file mode 100644 index 0000000..4103d97 --- /dev/null +++ b/Tests/CMakeTests/List-Insert-Invalid-Index.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(INSERT mylist 3 delta) diff --git a/Tests/CMakeTests/List-Invalid-Subcommand.cmake b/Tests/CMakeTests/List-Invalid-Subcommand.cmake new file mode 100644 index 0000000..f35a118 --- /dev/null +++ b/Tests/CMakeTests/List-Invalid-Subcommand.cmake @@ -0,0 +1 @@ +list(NO_SUCH_SUBCOMMAND mylist) diff --git a/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake new file mode 100644 index 0000000..327db6a --- /dev/null +++ b/Tests/CMakeTests/List-Length-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(LENGTH mylist result one_too_many) diff --git a/Tests/CMakeTests/List-No-Arguments.cmake b/Tests/CMakeTests/List-No-Arguments.cmake new file mode 100644 index 0000000..7916aaa --- /dev/null +++ b/Tests/CMakeTests/List-No-Arguments.cmake @@ -0,0 +1 @@ +list() diff --git a/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake b/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake new file mode 100644 index 0000000..d4f3921 --- /dev/null +++ b/Tests/CMakeTests/List-Remove_At-Invalid-Index.cmake @@ -0,0 +1,2 @@ +set(mylist alpha bravo charlie) +list(REMOVE_AT mylist 3) diff --git a/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake new file mode 100644 index 0000000..5266c7f --- /dev/null +++ b/Tests/CMakeTests/List-Remove_At-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REMOVE_AT nosuchlist 0) diff --git a/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake new file mode 100644 index 0000000..218f227 --- /dev/null +++ b/Tests/CMakeTests/List-Remove_Duplicates-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REMOVE_DUPLICATES nosuchlist) diff --git a/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake new file mode 100644 index 0000000..b5eb46e --- /dev/null +++ b/Tests/CMakeTests/List-Remove_Duplicates-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(REMOVE_DUPLICATES mylist one_too_many) diff --git a/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake b/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake new file mode 100644 index 0000000..079e7fb --- /dev/null +++ b/Tests/CMakeTests/List-Remove_Item-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REMOVE_ITEM nosuchlist alpha) diff --git a/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake b/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake new file mode 100644 index 0000000..977e2cc --- /dev/null +++ b/Tests/CMakeTests/List-Reverse-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(REVERSE nosuchlist) diff --git a/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake new file mode 100644 index 0000000..3a554a0 --- /dev/null +++ b/Tests/CMakeTests/List-Reverse-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(REVERSE mylist one_too_many) diff --git a/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake b/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake new file mode 100644 index 0000000..8f48e10 --- /dev/null +++ b/Tests/CMakeTests/List-Sort-Nonexistent-List.cmake @@ -0,0 +1,2 @@ +unset(nosuchlist) +list(SORT nosuchlist) diff --git a/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake b/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake new file mode 100644 index 0000000..81b195d --- /dev/null +++ b/Tests/CMakeTests/List-Sort-Too-Many-Arguments.cmake @@ -0,0 +1 @@ +list(SORT mylist one_too_many) diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in index a167503..f0ed70f 100644 --- a/Tests/CMakeTests/ListTest.cmake.in +++ b/Tests/CMakeTests/ListTest.cmake.in @@ -1,3 +1,5 @@ +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + macro(TEST command expected) if("x${result}" STREQUAL "x${expected}") #message("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"") @@ -97,3 +99,89 @@ TEST("REVERSE empty result" "") list(SORT result) TEST("SORT empty result" "") + +set(No-Arguments-RESULT 1) +set(No-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least two arguments.*") + +# these trigger top-level condition +foreach(cmd IN ITEMS Append Find Get Insert Length Reverse Remove_At Remove_Duplicates Remove_Item Sort) + set(${cmd}-No-Arguments-RESULT 1) + set(${cmd}-No-Arguments-STDERR ".*CMake Error at List-${cmd}-No-Arguments.cmake:1 \\(list\\):.*list must be called with at least two arguments.*") + string(TOUPPER ${cmd} cmd_upper) + set(_test_file_name "${CMAKE_CURRENT_BINARY_DIR}/List-${cmd}-No-Arguments.cmake") + file(WRITE "${_test_file_name}" "list(${cmd_upper})\n") + check_cmake_test_single(List "${cmd}-No-Arguments" "${_test_file_name}") +endforeach() + +set(Get-List-Only-STDERR "at least three") +set(Find-List-Only-STDERR "three") +set(Insert-List-Only-STDERR "at least three") +set(Length-List-Only-STDERR "two") +set(Remove_At-List-Only-STDERR "at least two") +set(Remove_Item-List-Only-STDERR "two or more") + +foreach(cmd IN ITEMS Find Get Insert Length Remove_At Remove_Item) + string(TOUPPER ${cmd} cmd_upper) + set(${cmd}-List-Only-RESULT 1) + set(${cmd}-List-Only-STDERR ".*CMake Error at List-${cmd}-List-Only.cmake:1 \\(list\\):.*list sub-command ${cmd_upper} requires ${${cmd}-List-Only-STDERR} arguments.*") + set(_test_file_name "${CMAKE_CURRENT_BINARY_DIR}/List-${cmd}-List-Only.cmake") + file(WRITE "${_test_file_name}" "list(${cmd_upper} mylist)\n") + check_cmake_test_single(List "${cmd}-List-Only" "${_test_file_name}") +endforeach() + +set(Length-Too-Many-Arguments-RESULT 1) +set(Length-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Length-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command LENGTH requires two arguments.*") + +set(Reverse-Too-Many-Arguments-RESULT 1) +set(Reverse-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Reverse-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command REVERSE only takes one argument.*") + +set(Remove_Duplicates-Too-Many-Arguments-RESULT 1) +set(Remove_Duplicates-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Remove_Duplicates-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command REMOVE_DUPLICATES only takes one argument.*") + +set(Sort-Too-Many-Arguments-RESULT 1) +set(Sort-Too-Many-Arguments-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Sort-Too-Many-Arguments.cmake:1 \\(list\\):.*list sub-command SORT only takes one argument.*") + +set(Invalid-Subcommand-RESULT 1) +set(Invalid-Subcommand-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Invalid-Subcommand.cmake:1 \\(list\\):.*list does not recognize sub-command NO_SUCH_SUBCOMMAND.*") + +foreach(cmd Get Insert Remove_At) + set(${cmd}-Invalid-Index-RESULT 1) + set(${cmd}-Invalid-Index-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Invalid-Index.cmake:2 \\(list\\):.*list index: 3 out of range \\(-3, 2\\).*") +endforeach() + +foreach(cmd Remove_Item Reverse Remove_Duplicates Sort Remove_At) + string(TOUPPER ${cmd} Cmd) + set(${cmd}-Nonexistent-List-RESULT 1) + set(${cmd}-Nonexistent-List-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-${cmd}-Nonexistent-List.cmake:2 \\(list\\):.*sub-command ${Cmd} requires list to be present.*") +endforeach() + +set(Get-CMP0007-Warn-RESULT 0) +set(Get-CMP0007-Warn-STDERR ".*CMake Warning \\(dev\\) at (@CMAKE_CURRENT_SOURCE_DIR@/)?List-Get-CMP0007-Warn.cmake:3 \\(list\\):.*Policy CMP0007 is not set:.*") + +check_cmake_test(List + No-Arguments + Length-Too-Many-Arguments + Reverse-Too-Many-Arguments + Remove_Duplicates-Too-Many-Arguments + Sort-Too-Many-Arguments + Invalid-Subcommand + Get-Invalid-Index + Insert-Invalid-Index + Remove_Item-Nonexistent-List + Reverse-Nonexistent-List + Remove_Duplicates-Nonexistent-List + Sort-Nonexistent-List + Remove_At-Nonexistent-List + Remove_At-Invalid-Index + Get-CMP0007-Warn +) + +set(thelist "" NEW OLD) + +foreach (_pol ${thelist}) + cmake_policy(SET CMP0007 ${_pol}) + list(GET thelist 1 thevalue) + if (NOT thevalue STREQUAL _pol) + message(SEND_ERROR "returned element '${thevalue}', but expected '${_pol}'") + endif() +endforeach (_pol) diff --git a/Tests/CMakeTests/Make_Directory-NoArg.cmake b/Tests/CMakeTests/Make_Directory-NoArg.cmake new file mode 100644 index 0000000..25b6f89 --- /dev/null +++ b/Tests/CMakeTests/Make_Directory-NoArg.cmake @@ -0,0 +1 @@ +file(MAKE_DIRECTORY) diff --git a/Tests/CMakeTests/String-TIMESTAMP-AllSpecifiers.cmake b/Tests/CMakeTests/String-TIMESTAMP-AllSpecifiers.cmake new file mode 100644 index 0000000..2d0fcc8 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-AllSpecifiers.cmake @@ -0,0 +1,11 @@ +string(TIMESTAMP output "%d;%H;%I;%j;%m;%M;%S;%U;%w;%y;%Y") +message("~${output}~") + +list(LENGTH output output_length) + +set(expected_output_length 11) + +if(NOT output_length EQUAL ${expected_output_length}) + message(FATAL_ERROR "expected ${expected_output_length} entries in output " + "with all specifiers; found ${output_length}") +endif() diff --git a/Tests/CMakeTests/String-TIMESTAMP-BadArg1.cmake b/Tests/CMakeTests/String-TIMESTAMP-BadArg1.cmake new file mode 100644 index 0000000..8f2d9f8 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-BadArg1.cmake @@ -0,0 +1 @@ +string(TIMESTAMP) diff --git a/Tests/CMakeTests/String-TIMESTAMP-BadArg2.cmake b/Tests/CMakeTests/String-TIMESTAMP-BadArg2.cmake new file mode 100644 index 0000000..c1e5126 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-BadArg2.cmake @@ -0,0 +1 @@ +string(TIMESTAMP output_variable "%Y" UTF) diff --git a/Tests/CMakeTests/String-TIMESTAMP-BadArg3.cmake b/Tests/CMakeTests/String-TIMESTAMP-BadArg3.cmake new file mode 100644 index 0000000..3d577df --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-BadArg3.cmake @@ -0,0 +1 @@ +string(TIMESTAMP output_variable "%Y" UTC UTC) diff --git a/Tests/CMakeTests/String-TIMESTAMP-CustomFormatLocal.cmake b/Tests/CMakeTests/String-TIMESTAMP-CustomFormatLocal.cmake new file mode 100644 index 0000000..eab2a45 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-CustomFormatLocal.cmake @@ -0,0 +1,2 @@ +string(TIMESTAMP output "%S") +message("~${output}~") diff --git a/Tests/CMakeTests/String-TIMESTAMP-CustomFormatUTC.cmake b/Tests/CMakeTests/String-TIMESTAMP-CustomFormatUTC.cmake new file mode 100644 index 0000000..eab2a45 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-CustomFormatUTC.cmake @@ -0,0 +1,2 @@ +string(TIMESTAMP output "%S") +message("~${output}~") diff --git a/Tests/CMakeTests/String-TIMESTAMP-DefaultFormatLocal.cmake b/Tests/CMakeTests/String-TIMESTAMP-DefaultFormatLocal.cmake new file mode 100644 index 0000000..d7c7dde --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-DefaultFormatLocal.cmake @@ -0,0 +1,2 @@ +string(TIMESTAMP output) +message("~${output}~") diff --git a/Tests/CMakeTests/String-TIMESTAMP-DefaultFormatUTC.cmake b/Tests/CMakeTests/String-TIMESTAMP-DefaultFormatUTC.cmake new file mode 100644 index 0000000..dad6a8d --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-DefaultFormatUTC.cmake @@ -0,0 +1,2 @@ +string(TIMESTAMP output UTC) +message("~${output}~") diff --git a/Tests/CMakeTests/String-TIMESTAMP-IncompleteSpecifier.cmake b/Tests/CMakeTests/String-TIMESTAMP-IncompleteSpecifier.cmake new file mode 100644 index 0000000..ffc5656 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-IncompleteSpecifier.cmake @@ -0,0 +1,2 @@ +string(TIMESTAMP output "foobar%") +message("~${output}~") diff --git a/Tests/CMakeTests/String-TIMESTAMP-UnknownSpecifier.cmake b/Tests/CMakeTests/String-TIMESTAMP-UnknownSpecifier.cmake new file mode 100644 index 0000000..0e145e5 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-UnknownSpecifier.cmake @@ -0,0 +1,2 @@ +string(TIMESTAMP output "%g") +message("~${output}~") diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 49e7dc9..a9fe428 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -16,6 +16,26 @@ set(SHA384-Works-RESULT 0) set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") set(SHA512-Works-RESULT 0) set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") +set(TIMESTAMP-BadArg1-RESULT 1) +set(TIMESTAMP-BadArg1-STDERR "string sub-command TIMESTAMP requires at least one argument") +set(TIMESTAMP-BadArg2-RESULT 1) +set(TIMESTAMP-BadArg2-STDERR "string TIMESTAMP sub-command does not recognize option UTF") +set(TIMESTAMP-BadArg3-RESULT 1) +set(TIMESTAMP-BadArg3-STDERR "string sub-command TIMESTAMP takes at most three arguments") +set(TIMESTAMP-DefaultFormatLocal-RESULT 0) +set(TIMESTAMP-DefaultFormatLocal-STDERR "~[0-9]*-[01][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-6][0-9]~") +set(TIMESTAMP-DefaultFormatUTC-RESULT 0) +set(TIMESTAMP-DefaultFormatUTC-STDERR "~[0-9]*-[01][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-6][0-9]Z~") +set(TIMESTAMP-CustomFormatLocal-RESULT 0) +set(TIMESTAMP-CustomFormatLocal-STDERR "~([0-5][0-9])|60~") +set(TIMESTAMP-CustomFormatUTC-RESULT 0) +set(TIMESTAMP-CustomFormatUTC-STDERR "~([0-5][0-9])|60~") +set(TIMESTAMP-UnknownSpecifier-RESULT 0) +set(TIMESTAMP-UnknownSpecifier-STDERR "~%g~") +set(TIMESTAMP-IncompleteSpecifier-RESULT 0) +set(TIMESTAMP-IncompleteSpecifier-STDERR "~foobar%~") +set(TIMESTAMP-AllSpecifiers-RESULT 0) +set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(String @@ -28,6 +48,16 @@ check_cmake_test(String SHA256-Works SHA384-Works SHA512-Works + TIMESTAMP-BadArg1 + TIMESTAMP-BadArg2 + TIMESTAMP-BadArg3 + TIMESTAMP-DefaultFormatLocal + TIMESTAMP-DefaultFormatUTC + TIMESTAMP-CustomFormatLocal + TIMESTAMP-CustomFormatUTC + TIMESTAMP-UnknownSpecifier + TIMESTAMP-IncompleteSpecifier + TIMESTAMP-AllSpecifiers ) # Execute each test listed in StringTestScript.cmake: diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index 9a022c5..0b6d07d 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -9,11 +9,10 @@ endif() if(NOT CPackGen) message(FATAL_ERROR "CPackGen not set") endif() -get_filename_component(CPACK_LOCATION ${CMAKE_COMMAND} PATH) -set(CPackCommand "${CPACK_LOCATION}/cpack") -message("cpack = ${CPackCommand}") -if(NOT CPackCommand) - message(FATAL_ERROR "CPackCommand not set") + +message("CMAKE_CPACK_COMMAND = ${CMAKE_CPACK_COMMAND}") +if(NOT CMAKE_CPACK_COMMAND) + message(FATAL_ERROR "CMAKE_CPACK_COMMAND not set") endif() if(NOT CPackComponentWay) @@ -92,7 +91,7 @@ endif() message("config_args = ${config_args}") message("config_verbose = ${config_verbose}") -execute_process(COMMAND ${CPackCommand} ${config_verbose} -G ${CPackGen} ${config_args} +execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen} ${config_args} RESULT_VARIABLE CPack_result OUTPUT_VARIABLE CPack_output ERROR_VARIABLE CPack_error diff --git a/Tests/CPackTestAllGenerators/RunCPack.cmake b/Tests/CPackTestAllGenerators/RunCPack.cmake index e0c241e..952d5f4 100644 --- a/Tests/CPackTestAllGenerators/RunCPack.cmake +++ b/Tests/CPackTestAllGenerators/RunCPack.cmake @@ -1,14 +1,10 @@ -if(NOT DEFINED cpack) - message(FATAL_ERROR "cpack not defined") -endif() - if(NOT DEFINED dir) message(FATAL_ERROR "dir not defined") endif() # Analyze 'cpack --help' output for list of available generators: # -execute_process(COMMAND ${cpack} --help +execute_process(COMMAND ${CMAKE_CPACK_COMMAND} --help RESULT_VARIABLE result OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr @@ -43,7 +39,7 @@ message(STATUS "CPack generators='${generators}'") foreach(g ${generators}) message(STATUS "Calling cpack -G ${g}...") - execute_process(COMMAND ${cpack} -G ${g} + execute_process(COMMAND ${CMAKE_CPACK_COMMAND} -G ${g} RESULT_VARIABLE result OUTPUT_VARIABLE stdout ERROR_VARIABLE stderr diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt new file mode 100644 index 0000000..ce02f11 --- /dev/null +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -0,0 +1,73 @@ +cmake_minimum_required(VERSION 2.8) + +project(CPackWiXGenerator) + +add_library(mylib mylib.cpp) + +add_executable(mylibapp mylibapp.cpp) +target_link_libraries(mylibapp mylib) + +install(TARGETS mylib + ARCHIVE + DESTINATION lib + COMPONENT libraries) + +install(TARGETS mylibapp + RUNTIME + DESTINATION bin + COMPONENT applications) + +install(FILES mylib.h "file with spaces.h" + DESTINATION include + COMPONENT headers) + +set(CPACK_GENERATOR "WIX") + +set(CPACK_PACKAGE_NAME "MyLib") +set(CPACK_PACKAGE_VENDOR "CMake.org") +set(CPACK_PACKAGE_CONTACT "somebody@cmake.org") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY + "MyLib - CPack Component Installation Example") + +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "0") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example") + +set(CPACK_WIX_UPGRADE_GUID "BF20CE5E-7F7C-401D-8F7C-AB45E8D170E6") + +include(CPack) + +cpack_add_install_type(Full DISPLAY_NAME "Everything") +cpack_add_install_type(Developer) + +cpack_add_component_group(Runtime) + +cpack_add_component_group(Development + EXPANDED + DESCRIPTION "All of the tools you'll ever need to develop software") + +cpack_add_component(applications + DISPLAY_NAME "MyLib Application" + DESCRIPTION "An extremely useful application that makes use of MyLib" + GROUP Runtime + INSTALL_TYPES Full) + +cpack_add_component(documentation + DISPLAY_NAME "MyLib Documentation" + DESCRIPTION "The extensive suite of MyLib Application documentation files" + GROUP Runtime + INSTALL_TYPES Full) + +cpack_add_component(libraries + DISPLAY_NAME "Libraries" + DESCRIPTION "Static libraries used to build programs with MyLib" + GROUP Development + INSTALL_TYPES Developer Full) + +cpack_add_component(headers + DISPLAY_NAME "C++ Headers" + DESCRIPTION "C/C++ header files for use with MyLib" + GROUP Development + DEPENDS libraries + INSTALL_TYPES Developer Full) diff --git a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake new file mode 100644 index 0000000..30e33cf2 --- /dev/null +++ b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake @@ -0,0 +1,72 @@ +message(STATUS "=============================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackWiXGenerator_BINARY_DIR) + message(FATAL_ERROR "CPackWiXGenerator_BINARY_DIR not set") +endif() + +message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") +message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") +message(STATUS "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}") + +execute_process(COMMAND "${CMAKE_CPACK_COMMAND}" + RESULT_VARIABLE CPack_result + OUTPUT_VARIABLE CPack_output + ERROR_VARIABLE CPack_error + WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}") + +if(CPack_result) + message(FATAL_ERROR "CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") +else () + message(STATUS "CPack_output=${CPack_output}") +endif() + +set(expected_file_mask "*.msi") +file(GLOB installer_file "${expected_file_mask}") + +message(STATUS "installer_file='${installer_file}'") +message(STATUS "expected_file_mask='${expected_file_mask}'") + +if(NOT installer_file) + message(FATAL_ERROR "installer_file does not exist.") +endif() + +function(run_wix_command command) + file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT) + set(WIX_PROGRAM "${WIX_ROOT}/bin/${command}.exe") + + if(NOT EXISTS "${WIX_PROGRAM}") + message(FATAL_ERROR "Failed to find WiX Tool: ${WIX_PROGRAM}") + endif() + + message(STATUS "Running WiX Tool: ${command} ${ARGN}") + + execute_process(COMMAND "${WIX_PROGRAM}" ${ARGN} + RESULT_VARIABLE WIX_result + OUTPUT_VARIABLE WIX_output + ERROR_VARIABLE WIX_output + WORKING_DIRECTORY "${CPackWiXGenerator_BINARY_DIR}") + + message(STATUS "${command} Output: \n${WIX_output}") + + if(WIX_result) + message(FATAL_ERROR "WiX ${command} failed: ${WIX_result}") + endif() +endfunction() + +file(GLOB WXS_SOURCE_FILES + "${CPackWiXGenerator_BINARY_DIR}/_CPack_Packages/*/WIX/*.wxs") + +if(NOT WXS_SOURCE_FILES) + message(FATAL_ERROR "Failed finding WiX source files to validate.") +endif() + +foreach(WXS_SOURCE_FILE IN LISTS WXS_SOURCE_FILES) + run_wix_command(wixcop "${WXS_SOURCE_FILE}") +endforeach() + +# error SMOK1076 : ICE61: This product should remove only older +# versions of itself. The Maximum version is not less +# than the current product. (1.0.0 1.0.0) +run_wix_command(smoke -nologo -wx -sw1076 "${installer_file}") diff --git a/Tests/CPackWiXGenerator/file with spaces.h b/Tests/CPackWiXGenerator/file with spaces.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CPackWiXGenerator/file with spaces.h diff --git a/Tests/CPackWiXGenerator/mylib.cpp b/Tests/CPackWiXGenerator/mylib.cpp new file mode 100644 index 0000000..8ddac19 --- /dev/null +++ b/Tests/CPackWiXGenerator/mylib.cpp @@ -0,0 +1,7 @@ +#include "mylib.h" +#include "stdio.h" + +void mylib_function() +{ + printf("This is mylib"); +} diff --git a/Tests/CPackWiXGenerator/mylib.h b/Tests/CPackWiXGenerator/mylib.h new file mode 100644 index 0000000..5d0a822 --- /dev/null +++ b/Tests/CPackWiXGenerator/mylib.h @@ -0,0 +1 @@ +void mylib_function(); diff --git a/Tests/CPackWiXGenerator/mylibapp.cpp b/Tests/CPackWiXGenerator/mylibapp.cpp new file mode 100644 index 0000000..a438ac7 --- /dev/null +++ b/Tests/CPackWiXGenerator/mylibapp.cpp @@ -0,0 +1,6 @@ +#include "mylib.h" + +int main() +{ + mylib_function(); +} diff --git a/Tests/CTestLimitDashJ/CMakeLists.txt b/Tests/CTestLimitDashJ/CMakeLists.txt new file mode 100644 index 0000000..0c5950c --- /dev/null +++ b/Tests/CTestLimitDashJ/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestLimitDashJ NONE) + +# This file demonstrates http://public.kitware.com/Bug/view.php?id=12904 +# when configured with CMake 2.8.10.2 and earlier, and when running +# "ctest -j 4" in the resulting build tree. This example is hard-coded +# to assume -j 4 just to reproduce the issue easily. Adjust the +# FAIL_REGULAR_EXPRESSION and PROCESSORS values to reproduce this problem +# with a different ctest -j value... + +if(EXISTS "${CMAKE_BINARY_DIR}/Testing/Temporary/CTestCostData.txt") + message(STATUS "Removing CTestCostData.txt to force ordering by COST PROPERTY value rather than prior run data") + file(REMOVE "${CMAKE_BINARY_DIR}/Testing/Temporary/CTestCostData.txt") +endif() + +include(CTest) + +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CreateSleepDelete.cmake + ${CMAKE_CURRENT_BINARY_DIR}/CreateSleepDelete.cmake + @ONLY + ) + +foreach(n RANGE 1 100) + add_test(NAME t${n} + COMMAND ${CMAKE_CTEST_COMMAND} + -D basefilename=f${n} + -S ${CMAKE_CURRENT_BINARY_DIR}/CreateSleepDelete.cmake + ) + set_property(TEST t${n} PROPERTY FAIL_REGULAR_EXPRESSION "(c='[5-9]'|c='[1-9][0-9]+')") +endforeach() + +set_property(TEST t1 PROPERTY RUN_SERIAL 1) +set_property(TEST t1 PROPERTY PROCESSORS 4) + +set_property(TEST t51 PROPERTY RUN_SERIAL 1) +set_property(TEST t51 PROPERTY PROCESSORS 4) + +foreach(n RANGE 2 50) + set_property(TEST t${n} PROPERTY DEPENDS t1) +endforeach() +set_property(TEST t1 PROPERTY DEPENDS t51) +set_property(TEST t51 PROPERTY DEPENDS t100) + +foreach(n 50) + set_property(TEST t${n} PROPERTY COST 6) +endforeach() +foreach(n RANGE 52 99) + set_property(TEST t${n} PROPERTY COST 3) +endforeach() diff --git a/Tests/CTestLimitDashJ/CreateSleepDelete.cmake b/Tests/CTestLimitDashJ/CreateSleepDelete.cmake new file mode 100644 index 0000000..b09307f --- /dev/null +++ b/Tests/CTestLimitDashJ/CreateSleepDelete.cmake @@ -0,0 +1,48 @@ +set(CTEST_RUN_CURRENT_SCRIPT 0) + +if(NOT DEFINED basefilename) + message(FATAL_ERROR "pass -Dbasefilename=f1") +endif() + +if(NOT DEFINED ext) + set(ext "jkqvxz") +endif() + +if(NOT DEFINED sleep_interval) + set(sleep_interval 1) +endif() + +get_filename_component(self_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(filename "${self_dir}/${basefilename}.${ext}") + +# count files +file(GLOB f1 *.${ext}) +list(LENGTH f1 c1) +message("c='${c1}'") + +# write a new file +message("Writing file: filename='${filename}'") +file(WRITE "${filename}" "${filename}") + +# count files again +file(GLOB f2 *.${ext}) +list(LENGTH f2 c2) +message("c='${c2}'") + +# snooze +message("Sleeping: sleep_interval='${sleep_interval}'") +ctest_sleep(${sleep_interval}) + +# count files again +file(GLOB f3 *.${ext}) +list(LENGTH f3 c3) +message("c='${c3}'") + +# delete the file we wrote earlier +message("Removing file: filename='${filename}'") +file(REMOVE "${filename}") + +# count files again +file(GLOB f4 *.${ext}) +list(LENGTH f4 c4) +message("c='${c4}'") diff --git a/Tests/EmptyDepends/CMakeLists.txt b/Tests/EmptyDepends/CMakeLists.txt new file mode 100644 index 0000000..832d9dc --- /dev/null +++ b/Tests/EmptyDepends/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) +project(EmptyDepends) + +include(CTest) + +set(extra_dep) + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/qrc_my.cxx + COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/qrc_my.cxx" + DEPENDS "${extra_dep}" "${CMAKE_BINARY_DIR}/my.qrc") + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/my.qrc + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/my.qrc) + +add_library(qrc STATIC ${CMAKE_BINARY_DIR}/qrc_my.cxx) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 3f8e827..e24a979 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -638,6 +638,17 @@ if(do_svn_tests) "${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98) endif() +if(do_git_tests) + add_test(TutorialStep1-GIT-byhash + "${binary_base}/TutorialStep1-GIT-byhash/Tutorial" 100) + + add_test(TutorialStep1-GIT-bytag + "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99) + + add_test(TutorialStep1-GIT-master + "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98) +endif() + # InstallTree tests: # diff --git a/Tests/ExternalProjectUpdate/CMakeLists.txt b/Tests/ExternalProjectUpdate/CMakeLists.txt new file mode 100644 index 0000000..c33e90b --- /dev/null +++ b/Tests/ExternalProjectUpdate/CMakeLists.txt @@ -0,0 +1,94 @@ +cmake_minimum_required(VERSION 2.8) +project(ExternalProjectUpdateTest NONE) + +include(ExternalProject) + +find_package(Git) + +option(ExternalProjectUpdateTest_USE_FOLDERS "Enable folder grouping in IDEs." ON) +if(ExternalProjectUpdateTest_USE_FOLDERS) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +else() + set_property(GLOBAL PROPERTY USE_FOLDERS OFF) +endif() + +set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER + "CMakePredefinedTargets-in-ExternalProjectUpdateTest") + +set(base "${CMAKE_BINARY_DIR}/CMakeExternals") +set(binary_base "${base}/Build") +set_property(DIRECTORY PROPERTY EP_BASE ${base}) +set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) + +set(do_git_tests 0) + +if(GIT_EXECUTABLE) + set(do_git_tests 1) + + execute_process( + COMMAND "${GIT_EXECUTABLE}" --version + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX REPLACE "^git version (.+)$" "\\1" git_version "${ov}") + message(STATUS "git_version='${git_version}'") + + if(git_version VERSION_LESS 1.6.5) + message(STATUS "No ExternalProject git tests with git client less than version 1.6.5") + set(do_git_tests 0) + endif() +endif() + +# This should be specified from the command line. +if(NOT TEST_GIT_TAG) + set(TEST_GIT_TAG origin/master) +endif() + +if(do_git_tests) + set(local_git_repo "../../LocalRepositories/GIT") + + # Unzip/untar the git repository in our source folder so that other + # projects below may use it to test git args of ExternalProject_Add + # + set(proj SetupLocalGITRepository) + ExternalProject_Add(${proj} + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT + URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo.tgz + BUILD_COMMAND "" + CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + set(proj TutorialStep1-GIT) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_TAG ${TEST_GIT_TAG} + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") +endif() + + +# Test the testable built/installed products: +# +enable_testing() + + +# Do at least a smoke test of a built executable from each +# project's build directory... +# +# BuildTree tests: +# + +if(do_git_tests) + add_test(TutorialStep1-GIT + "${binary_base}/TutorialStep1-GIT/Tutorial" 81) +endif() + +message(STATUS "do_git_tests='${do_git_tests}'") +message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'") diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake new file mode 100644 index 0000000..5a6af57 --- /dev/null +++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake @@ -0,0 +1,94 @@ +# Set the ExternalProject GIT_TAG to desired_tag, and make sure the +# resulting checked out version is resulting_sha and rebuild. +# This check's the correct behavior of the ExternalProject UPDATE_COMMAND. +# Also verify that a fetch only occurs when fetch_expected is 1. +macro(check_a_tag desired_tag resulting_sha fetch_expected) + message( STATUS "Checking ExternalProjectUpdate to tag: ${desired_tag}" ) + + # Remove the FETCH_HEAD file, so we can check if it gets replaced with a 'git + # fetch'. + set( FETCH_HEAD_file ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT/.git/FETCH_HEAD ) + file( REMOVE ${FETCH_HEAD_file} ) + + # Configure + execute_process(COMMAND ${CMAKE_COMMAND} + -G ${CMAKE_TEST_GENERATOR} + -DTEST_GIT_TAG:STRING=${desired_tag} + ${ExternalProjectUpdate_SOURCE_DIR} + WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR} + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR "Could not configure the project.") + endif() + + # Build + execute_process(COMMAND ${CMAKE_COMMAND} + --build ${ExternalProjectUpdate_BINARY_DIR} + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR "Could not build the project.") + endif() + + # Check the resulting SHA + execute_process(COMMAND ${GIT_EXECUTABLE} + rev-list --max-count=1 HEAD + WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT + RESULT_VARIABLE error_code + OUTPUT_VARIABLE tag_sha + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(error_code) + message(FATAL_ERROR "Could not check the sha.") + endif() + + if(NOT (${tag_sha} STREQUAL ${resulting_sha})) + message(FATAL_ERROR "UPDATE_COMMAND produced + ${tag_sha} +when + ${resulting_sha} +was expected." + ) + endif() + + if( NOT EXISTS ${FETCH_HEAD_file} AND ${fetch_expected}) + message( FATAL_ERROR "Fetch did NOT occur when it was expected.") + endif() + if( EXISTS ${FETCH_HEAD_file} AND NOT ${fetch_expected}) + message( FATAL_ERROR "Fetch DID occur when it was not expected.") + endif() +endmacro() + +find_package(Git) +set(do_git_tests 0) +if(GIT_EXECUTABLE) + set(do_git_tests 1) + + execute_process( + COMMAND "${GIT_EXECUTABLE}" --version + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX REPLACE "^git version (.+)$" "\\1" git_version "${ov}") + message(STATUS "git_version='${git_version}'") + + if(git_version VERSION_LESS 1.6.5) + message(STATUS "No ExternalProject git tests with git client less than version 1.6.5") + set(do_git_tests 0) + endif() +endif() + +if(do_git_tests) + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) + check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 1) + # With the Git UPDATE_COMMAND performance patch, this will not required a + # 'git fetch' + check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 0) + check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) + check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 1) + check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 0) + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) + # This is a remote symbolic ref, so it will always trigger a 'git fetch' + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) +endif() diff --git a/Tests/ExternalProjectUpdate/gitrepo.tgz b/Tests/ExternalProjectUpdate/gitrepo.tgz Binary files differnew file mode 100644 index 0000000..87090ab --- /dev/null +++ b/Tests/ExternalProjectUpdate/gitrepo.tgz diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index bb31476..3a92d81 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -14,6 +14,9 @@ add_custom_target(check ALL -Dtest_and_1=$<AND:1> -Dtest_and_1_0=$<AND:1,0> -Dtest_and_1_1=$<AND:1,1> + # Ordinarily, the 'invalidcontent' would cause an error, but + # the '0' makes the AND abort early. + -Dtest_and_0_invalidcontent=$<AND:0,invalidcontent> -Dtest_config_0=$<CONFIG:$<CONFIGURATION>x> -Dtest_config_1=$<CONFIG:$<CONFIGURATION>> -Dtest_config_debug=$<CONFIG:Debug>$<CONFIG:DEBUG>$<CONFIG:DeBuG> @@ -28,6 +31,7 @@ add_custom_target(check ALL -Dtest_or_1=$<OR:1> -Dtest_or_1_0=$<OR:1,0> -Dtest_or_1_1=$<OR:1,1> + -Dtest_or_1_invalidcontent=$<OR:1,invalidcontent> -Dtest_bool_notfound=$<BOOL:NOTFOUND> -Dtest_bool_foo_notfound=$<BOOL:Foo-NOTFOUND> -Dtest_bool_true=$<BOOL:True> diff --git a/Tests/GeneratorExpression/check.cmake b/Tests/GeneratorExpression/check.cmake index 8745d57..af436de 100644 --- a/Tests/GeneratorExpression/check.cmake +++ b/Tests/GeneratorExpression/check.cmake @@ -15,6 +15,7 @@ check(test_and_0_1 "0") check(test_and_1 "1") check(test_and_1_0 "0") check(test_and_1_1 "1") +check(test_and_0_invalidcontent "0") check(test_config_0 "0") check(test_config_1 "1") foreach(c debug release relwithdebinfo minsizerel) @@ -30,6 +31,7 @@ check(test_or_0_1 "1") check(test_or_1 "1") check(test_or_1_0 "1") check(test_or_1_1 "1") +check(test_or_1_invalidcontent "1") check(test_bool_notfound "0") check(test_bool_foo_notfound "0") check(test_bool_true "1") diff --git a/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake b/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake new file mode 100644 index 0000000..3091e66 --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMP0019-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0019 NEW) +include(CMP0019-code.cmake) diff --git a/Tests/RunCMake/CMP0019/CMP0019-OLD.cmake b/Tests/RunCMake/CMP0019/CMP0019-OLD.cmake new file mode 100644 index 0000000..0f02f9c --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMP0019-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0019 OLD) +include(CMP0019-code.cmake) diff --git a/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt b/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt new file mode 100644 index 0000000..03faef9 --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMP0019-WARN-stderr.txt @@ -0,0 +1,40 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0019 is not set: Do not re-expand variables in include and link + information. Run "cmake --help-policy CMP0019" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. + + The following variable evaluations were encountered: + + Evaluated directory INCLUDE_DIRECTORIES + + /usr/include/\${VAR_INCLUDE};/usr/include/normal + + as + + /usr/include/VAL_INCLUDE;/usr/include/normal + + Evaluated target some_target INCLUDE_DIRECTORIES + + /usr/include/\${VAR_INCLUDE};/usr/include/normal + + as + + /usr/include/VAL_INCLUDE;/usr/include/normal + + Evaluated link directory + + /usr/lib/\${VAR_LINK_DIRS} + + as + + /usr/lib/VAL_LINK_DIRS + + Evaluated link library + + \${VAR_LINK_LIBS} + + as + + VAL_LINK_LIBS + +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0019/CMP0019-WARN.cmake b/Tests/RunCMake/CMP0019/CMP0019-WARN.cmake new file mode 100644 index 0000000..a419f30 --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMP0019-WARN.cmake @@ -0,0 +1 @@ +include(CMP0019-code.cmake) diff --git a/Tests/RunCMake/CMP0019/CMP0019-code.cmake b/Tests/RunCMake/CMP0019/CMP0019-code.cmake new file mode 100644 index 0000000..26c0e5b --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMP0019-code.cmake @@ -0,0 +1,9 @@ +set(VAR_INCLUDE "VAL_INCLUDE") +set(VAR_LINK_DIRS "VAL_LINK_DIRS") +set(VAR_LINK_LIBS "VAL_LINK_LIBS") +add_custom_target(some_target) +include_directories("/usr/include/\${VAR_INCLUDE}" /usr/include/normal) +link_directories("/usr/lib/\${VAR_LINK_DIRS}" /usr/lib/normal) +link_libraries("\${VAR_LINK_LIBS}" normal) +add_custom_target(other_target) +set_property(TARGET other_target PROPERTY INCLUDE_DIRECTORIES "") diff --git a/Tests/RunCMake/CMP0019/CMakeLists.txt b/Tests/RunCMake/CMP0019/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/CMP0019/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0019/RunCMakeTest.cmake b/Tests/RunCMake/CMP0019/RunCMakeTest.cmake new file mode 100644 index 0000000..119fc2b --- /dev/null +++ b/Tests/RunCMake/CMP0019/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0019-WARN) +run_cmake(CMP0019-OLD) +run_cmake(CMP0019-NEW) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 8c67625..cc544a3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -45,6 +45,7 @@ macro(add_RunCMake_test test) ) endmacro() +add_RunCMake_test(CMP0019) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) @@ -55,7 +56,9 @@ add_RunCMake_test(find_package) add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(list) +add_RunCMake_test(load_command) if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) + add_RunCMake_test(SolutionGlobalSections) endif() diff --git a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt index 36302db..0e48ba4 100644 --- a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt @@ -41,4 +41,13 @@ CMake Error at BadAND.cmake:1 \(add_custom_target\): Parameters to \$<AND> must resolve to either '0' or '1'. Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadAND.cmake:1 \(add_custom_target\): + Error evaluating generator expression: + + \$<AND:1,nothing> + + Parameters to \$<AND> must resolve to either '0' or '1'. +Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/GeneratorExpression/BadAND.cmake b/Tests/RunCMake/GeneratorExpression/BadAND.cmake index 265e414..8a7993f 100644 --- a/Tests/RunCMake/GeneratorExpression/BadAND.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadAND.cmake @@ -4,4 +4,5 @@ add_custom_target(check ALL COMMAND check $<AND:,> $<AND:01> $<AND:nothing> + $<AND:1,nothing> VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt index d4ccab7..eb26328 100644 --- a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt @@ -41,4 +41,13 @@ CMake Error at BadOR.cmake:1 \(add_custom_target\): Parameters to \$<OR> must resolve to either '0' or '1'. Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadOR.cmake:1 \(add_custom_target\): + Error evaluating generator expression: + + \$<OR:0,nothing> + + Parameters to \$<OR> must resolve to either '0' or '1'. +Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/GeneratorExpression/BadOR.cmake b/Tests/RunCMake/GeneratorExpression/BadOR.cmake index 0813400..c0309da 100644 --- a/Tests/RunCMake/GeneratorExpression/BadOR.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadOR.cmake @@ -4,4 +4,5 @@ add_custom_target(check ALL COMMAND check $<OR:,> $<OR:01> $<OR:nothing> + $<OR:0,nothing> VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/BadZero-result.txt b/Tests/RunCMake/GeneratorExpression/BadZero-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadZero-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt new file mode 100644 index 0000000..40db4ae --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt @@ -0,0 +1,17 @@ +CMake Error at BadZero.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<0> + + \$<0> expression requires a parameter. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadZero.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<0,> + + Expression did not evaluate to a known generator expression +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadZero.cmake b/Tests/RunCMake/GeneratorExpression/BadZero.cmake new file mode 100644 index 0000000..559a9fa --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadZero.cmake @@ -0,0 +1,5 @@ + +add_custom_target(check ALL COMMAND check + $<0> + $<0,> + VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 18a47ae..992ba79 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -5,3 +5,4 @@ run_cmake(BadOR) run_cmake(BadAND) run_cmake(BadNOT) run_cmake(BadStrEqual) +run_cmake(BadZero) diff --git a/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt b/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake b/Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake new file mode 100644 index 0000000..0f7e370 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/MorePost-check.cmake @@ -0,0 +1,5 @@ +parseGlobalSections(pre post MorePost) +testGlobalSection(post TestSec2 Key1=Value1 "Key2=Value with spaces") +testGlobalSection(post TestSec4 Key6=Value1 "Key7=Value with spaces" Key8=ValueWithoutSpaces) +testGlobalSection(post ExtensibilityGlobals) +testGlobalSection(post ExtensibilityAddIns) diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePost.cmake b/Tests/RunCMake/SolutionGlobalSections/MorePost.cmake new file mode 100644 index 0000000..2eb3f60 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/MorePost.cmake @@ -0,0 +1,2 @@ +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_POST_TestSec2 Key1=Value1 "Key2=Value with spaces") +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_POST_TestSec4 Key6=Value1 "Key7=Value with spaces" "Key8 =ValueWithoutSpaces") diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake b/Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake new file mode 100644 index 0000000..45e7419 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/MorePre-check.cmake @@ -0,0 +1,5 @@ +parseGlobalSections(pre post MorePre) +testGlobalSection(pre TestSec1 Key1=Value1 "Key2=Value with spaces") +testGlobalSection(pre TestSec3 Key3=Value1 "Key4=Value with spaces" Key5=ValueWithoutSpaces) +testGlobalSection(post ExtensibilityGlobals) +testGlobalSection(post ExtensibilityAddIns) diff --git a/Tests/RunCMake/SolutionGlobalSections/MorePre.cmake b/Tests/RunCMake/SolutionGlobalSections/MorePre.cmake new file mode 100644 index 0000000..07f4eb8 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/MorePre.cmake @@ -0,0 +1,2 @@ +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_PRE_TestSec1 Key1=Value1 "Key2=Value with spaces") +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_PRE_TestSec3 Key3=Value1 "Key4=Value with spaces" "Key5 = ValueWithoutSpaces") diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake b/Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake new file mode 100644 index 0000000..6af5156 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/OnePost-check.cmake @@ -0,0 +1,4 @@ +parseGlobalSections(pre post OnePost) +testGlobalSection(post TestSec2 Key1=Value1 "Key2=Value with spaces") +testGlobalSection(post ExtensibilityGlobals) +testGlobalSection(post ExtensibilityAddIns) diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePost.cmake b/Tests/RunCMake/SolutionGlobalSections/OnePost.cmake new file mode 100644 index 0000000..2295cfb --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/OnePost.cmake @@ -0,0 +1 @@ +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_POST_TestSec2 Key1=Value1 "Key2=Value with spaces") diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake b/Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake new file mode 100644 index 0000000..70b18b2 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/OnePre-check.cmake @@ -0,0 +1,4 @@ +parseGlobalSections(pre post OnePre) +testGlobalSection(pre TestSec1 Key1=Value1 "Key2=Value with spaces") +testGlobalSection(post ExtensibilityGlobals) +testGlobalSection(post ExtensibilityAddIns) diff --git a/Tests/RunCMake/SolutionGlobalSections/OnePre.cmake b/Tests/RunCMake/SolutionGlobalSections/OnePre.cmake new file mode 100644 index 0000000..1499b47 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/OnePre.cmake @@ -0,0 +1 @@ +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_PRE_TestSec1 Key1=Value1 "Key2=Value with spaces") diff --git a/Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake b/Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake new file mode 100644 index 0000000..a19e2e1 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/Override1-check.cmake @@ -0,0 +1,4 @@ +parseGlobalSections(pre post Override1) +testGlobalSection(post TestSec Key2=Value2 Key3=Value3) +testGlobalSection(post ExtensibilityGlobals Key1=Value1) +testGlobalSection(post ExtensibilityAddIns) diff --git a/Tests/RunCMake/SolutionGlobalSections/Override1.cmake b/Tests/RunCMake/SolutionGlobalSections/Override1.cmake new file mode 100644 index 0000000..a726c9f --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/Override1.cmake @@ -0,0 +1,2 @@ +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_POST_ExtensibilityGlobals Key1=Value1) +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_POST_TestSec Key2=Value2 Key3=Value3) diff --git a/Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake b/Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake new file mode 100644 index 0000000..d9656e1 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/Override2-check.cmake @@ -0,0 +1,4 @@ +parseGlobalSections(pre post Override2) +testGlobalSection(pre TestSec Key2=Value2 Key3=Value3) +testGlobalSection(post ExtensibilityGlobals) +testGlobalSection(post ExtensibilityAddIns Key1=Value1) diff --git a/Tests/RunCMake/SolutionGlobalSections/Override2.cmake b/Tests/RunCMake/SolutionGlobalSections/Override2.cmake new file mode 100644 index 0000000..0ce43cc --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/Override2.cmake @@ -0,0 +1,2 @@ +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_POST_ExtensibilityAddIns Key1=Value1) +set_property(DIRECTORY PROPERTY VS_GLOBAL_SECTION_PRE_TestSec Key2=Value2 Key3=Value3) diff --git a/Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake b/Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake new file mode 100644 index 0000000..322a689 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/PrePost-check.cmake @@ -0,0 +1,6 @@ +parseGlobalSections(pre post PrePost) +testGlobalSection(post Postsec Key1=Value2) +testGlobalSection(pre Presec Key1=Value1 "Key2=Value with some spaces") +testGlobalSection(post Emptysec) +testGlobalSection(post ExtensibilityGlobals) +testGlobalSection(post ExtensibilityAddIns) diff --git a/Tests/RunCMake/SolutionGlobalSections/PrePost.cmake b/Tests/RunCMake/SolutionGlobalSections/PrePost.cmake new file mode 100644 index 0000000..976c341 --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/PrePost.cmake @@ -0,0 +1,4 @@ +set_directory_properties(PROPERTIES + VS_GLOBAL_SECTION_POST_Postsec Key1=Value2 + VS_GLOBAL_SECTION_PRE_Presec "Key1=Value1;Key2= Value with some spaces" + VS_GLOBAL_SECTION_POST_Emptysec "") diff --git a/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake b/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake new file mode 100644 index 0000000..6ae158d --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/RunCMakeTest.cmake @@ -0,0 +1,10 @@ +include(RunCMake) +include(${CMAKE_CURRENT_LIST_DIR}/solution_parsing.cmake) + +run_cmake(OnePre) +run_cmake(OnePost) +run_cmake(MorePre) +run_cmake(MorePost) +run_cmake(PrePost) +run_cmake(Override1) +run_cmake(Override2) diff --git a/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake b/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake new file mode 100644 index 0000000..dd158ef --- /dev/null +++ b/Tests/RunCMake/SolutionGlobalSections/solution_parsing.cmake @@ -0,0 +1,60 @@ +macro(error text) + set(RunCMake_TEST_FAILED "${text}") + return() +endmacro() + + +macro(parseGlobalSections arg_out_pre arg_out_post testName) + set(out_pre ${arg_out_pre}) + set(out_post ${arg_out_post}) + set(sln "${RunCMake_TEST_BINARY_DIR}/${testName}.sln") + if(NOT EXISTS "${sln}") + error("Expected solution file ${sln} does not exist") + endif() + file(STRINGS "${sln}" lines) + set(sectionLines "") + set(store FALSE) + foreach(line IN LISTS lines) + if(line MATCHES "^\t*Global\n?$") + set(store TRUE) + elseif(line MATCHES "^\t*EndGlobal\n?$") + set(store FALSE) + elseif(store) + list(APPEND sectionLines "${line}") + endif() + endforeach() + set(sectionName "") + set(sectionType "") + foreach(line IN LISTS sectionLines) + if(line MATCHES "^\t*GlobalSection\\((.*)\\) *= *(pre|post)Solution\n?$") + set(sectionName "${CMAKE_MATCH_1}") + set(sectionType ${CMAKE_MATCH_2}) + list(APPEND ${out_${sectionType}} "${sectionName}") + if(DEFINED ${out_${sectionType}}_${sectionName}) + error("Section ${sectionName} defined twice") + endif() + set(${out_${sectionType}}_${sectionName} "") + elseif(line MATCHES "\t*EndGlobalSection\n?$") + set(sectionName "") + set(sectionType "") + elseif(sectionName) + string(REGEX MATCH "^\t*([^=]*)=([^\n]*)\n?$" matches "${line}") + if(NOT matches) + error("Bad syntax in solution file: '${line}'") + endif() + string(STRIP "${CMAKE_MATCH_1}" key) + string(STRIP "${CMAKE_MATCH_2}" value) + list(APPEND ${out_${sectionType}}_${sectionName} "${key}=${value}") + endif() + endforeach() +endmacro() + + +macro(testGlobalSection prefix sectionName) + if(NOT DEFINED ${prefix}_${sectionName}) + error("Section ${sectionName} does not exist") + endif() + if(NOT "${${prefix}_${sectionName}}" STREQUAL "${ARGN}") + error("Section ${sectionName} content mismatch\n expected: ${ARGN}\n actual: ${${prefix}_${sectionName}}") + endif() +endmacro() diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt index 3287d19..9c146e0 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName1.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:Invali/dTarget,INCLUDE_DIRECTORIES> Target name not supported. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt index e527e22..451888c 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName2.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:Invali/dTarget,Invali/dProperty> - Target name and property name not supported.$ + Target name and property name not supported. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt index 517debb..39692c4 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName3.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:Invali/dProperty> - Property name not supported.$ + Property name not supported. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt index eab6fb6..c3aa1b1 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName4.cmake:9 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:foo,Invali/dProperty> - Property name not supported.$ + Property name not supported. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt index e2b4fc6..1c6fad4 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt @@ -1,7 +1,9 @@ -CMake Error: +CMake Error at BadInvalidName5.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:,> \$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty target name and property name. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt index e94f52f..8b147dc 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName6.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:,ValidProperty> \$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty target name. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt index 2548215..dad6bf8 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName7.cmake:9 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:foo,> \$<TARGET_PROPERTY:...> expression requires a non-empty property name. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt index 2a98f6f..4e8c14c 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadInvalidName8.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:> \$<TARGET_PROPERTY:...> expression requires a non-empty property name. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt index d2ac7a9..3b3bab0 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt @@ -1,6 +1,8 @@ -CMake Error: +CMake Error at BadNonTarget.cmake:7 \(include_directories\): Error evaluating generator expression: \$<TARGET_PROPERTY:NonExistant,INCLUDE_DIRECTORIES> - Target "NonExistant" not found.$ + Target "NonExistant" not found. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\)$ diff --git a/Tests/RunCMake/include_directories/DebugIncludes-result.txt b/Tests/RunCMake/include_directories/DebugIncludes-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/include_directories/DebugIncludes-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt new file mode 100644 index 0000000..948def1 --- /dev/null +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -0,0 +1,42 @@ +CMake Warning at DebugIncludes.cmake:8 \(include_directories\): + Used includes: + + \* .*/Tests/RunCMake/include_directories/one + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Warning at DebugIncludes.cmake:8 \(include_directories\): + Used includes: + + \* .*/Tests/RunCMake/include_directories/two + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Warning at DebugIncludes.cmake:13 \(set_property\): + Used includes: + + \* .*/Tests/RunCMake/include_directories/three + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Warning at DebugIncludes.cmake:18 \(include_directories\): + Used includes: + + \* .*/Tests/RunCMake/include_directories/four + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Warning at DebugIncludes.cmake:25 \(set_property\): + Used includes: + + \* .*/Tests/RunCMake/include_directories/five + \* .*/Tests/RunCMake/include_directories/six + +Call Stack \(most recent call first\): + DebugIncludes.cmake:35 \(some_macro\) + DebugIncludes.cmake:38 \(some_function\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/DebugIncludes.cmake b/Tests/RunCMake/include_directories/DebugIncludes.cmake new file mode 100644 index 0000000..51daf74 --- /dev/null +++ b/Tests/RunCMake/include_directories/DebugIncludes.cmake @@ -0,0 +1,38 @@ + +project(DebugIncludes) + +set(CMAKE_DEBUG_TARGET_PROPERTIES INCLUDE_DIRECTORIES) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/DebugIncludes.cpp" "enum { dummy };\n") + +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}/one" + "${CMAKE_CURRENT_SOURCE_DIR}/two" +) + +set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_SOURCE_DIR}/three") + +add_library(lll "${CMAKE_CURRENT_BINARY_DIR}/DebugIncludes.cpp") + +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}/two" + "${CMAKE_CURRENT_SOURCE_DIR}/three" + "${CMAKE_CURRENT_SOURCE_DIR}/four" +) + +macro(some_macro) + set_property(TARGET lll APPEND PROPERTY + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/one" + "${CMAKE_CURRENT_SOURCE_DIR}/three" + "${CMAKE_CURRENT_SOURCE_DIR}/four" + "${CMAKE_CURRENT_SOURCE_DIR}/five" + "${CMAKE_CURRENT_SOURCE_DIR}/six" + ) +endmacro() + +function(some_function) + some_macro() +endfunction() + +some_function() diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index aee3f79..de37252 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -1,3 +1,4 @@ include(RunCMake) run_cmake(NotFoundContent) +run_cmake(DebugIncludes) diff --git a/Tests/RunCMake/load_command/CMakeLists.txt b/Tests/RunCMake/load_command/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/load_command/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/load_command/LoadCommandDeprecated-stderr.txt b/Tests/RunCMake/load_command/LoadCommandDeprecated-stderr.txt new file mode 100644 index 0000000..7d374b2 --- /dev/null +++ b/Tests/RunCMake/load_command/LoadCommandDeprecated-stderr.txt @@ -0,0 +1,6 @@ +CMake Warning \(dev\) at LoadCommandDeprecated.cmake:1 \(load_command\): + The "load_command" command will be removed in CMake 3.0. See command + documentation for details. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/load_command/LoadCommandDeprecated.cmake b/Tests/RunCMake/load_command/LoadCommandDeprecated.cmake new file mode 100644 index 0000000..9e9b1f4 --- /dev/null +++ b/Tests/RunCMake/load_command/LoadCommandDeprecated.cmake @@ -0,0 +1 @@ +load_command() diff --git a/Tests/RunCMake/load_command/RunCMakeTest.cmake b/Tests/RunCMake/load_command/RunCMakeTest.cmake new file mode 100644 index 0000000..9a0f98d --- /dev/null +++ b/Tests/RunCMake/load_command/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(LoadCommandDeprecated) diff --git a/Tests/VSExcludeFromDefaultBuild/CMakeLists.txt b/Tests/VSExcludeFromDefaultBuild/CMakeLists.txt new file mode 100644 index 0000000..d30414b --- /dev/null +++ b/Tests/VSExcludeFromDefaultBuild/CMakeLists.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 2.8.9) +project(VSExcludeFromDefaultBuild) + +# First step is to clear all .exe files in output so that possible past +# failures of this test do not prevent it from succeeding. +add_custom_target(ClearExes ALL + COMMAND "${CMAKE_COMMAND}" + -Ddir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/ClearExes.cmake + VERBATIM) + +# Make sure ClearExes is executed before other targets are built +function(add_test_executable target) + add_executable("${target}" ${ARGN}) + add_dependencies("${target}" ClearExes) +endfunction() + +add_test_executable(DefaultBuilt main.c) + +add_test_executable(AlwaysBuilt main.c) +set_target_properties(AlwaysBuilt PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD FALSE) + +add_test_executable(NeverBuilt main.c) +set_target_properties(NeverBuilt PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) + +foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${config} Config) + add_test_executable(BuiltIn${config} main.c) + set_target_properties(BuiltIn${config} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE EXCLUDE_FROM_DEFAULT_BUILD_${Config} FALSE) + add_test_executable(ExcludedIn${config} main.c) + set_target_properties(ExcludedIn${config} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_${Config} TRUE) +endforeach() diff --git a/Tests/VSExcludeFromDefaultBuild/ClearExes.cmake b/Tests/VSExcludeFromDefaultBuild/ClearExes.cmake new file mode 100644 index 0000000..ece30ad --- /dev/null +++ b/Tests/VSExcludeFromDefaultBuild/ClearExes.cmake @@ -0,0 +1,4 @@ +file(GLOB exeFiles "${dir}/*.exe") +foreach(exeFile IN LISTS exeFiles) + file(REMOVE "${exeFile}") +endforeach() diff --git a/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake b/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake new file mode 100644 index 0000000..8fb00bf --- /dev/null +++ b/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake @@ -0,0 +1,23 @@ +message(STATUS "Testing configuration ${activeConfig}.") + +macro(TestExists exeName) + set(exeFile "${dir}/${activeConfig}/${exeName}.exe") + if(${ARGN} EXISTS "${exeFile}") + message(STATUS "File ${exeFile} was correctly found ${ARGN} to exist.") + else() + message(FATAL_ERROR "File ${exeFile} was expected ${ARGN} to exist!") + endif() +endmacro() + +TestExists(DefaultBuilt) +TestExists(AlwaysBuilt) +TestExists(NeverBuilt NOT) +foreach(config ${allConfigs}) + if(config STREQUAL activeConfig) + TestExists(BuiltIn${config}) + TestExists(ExcludedIn${config} NOT) + else() + TestExists(BuiltIn${config} NOT) + TestExists(ExcludedIn${config}) + endif() +endforeach() diff --git a/Tests/VSExcludeFromDefaultBuild/main.c b/Tests/VSExcludeFromDefaultBuild/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/VSExcludeFromDefaultBuild/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Utilities/Git/pre-commit b/Utilities/Git/pre-commit index d308a81..a35d111 100755 --- a/Utilities/Git/pre-commit +++ b/Utilities/Git/pre-commit @@ -47,18 +47,16 @@ if test -z "$HOOKS_ALLOW_KWSYS"; then '"$(echo "$files" | sed 's/^/ /')"' -cannot be committed through Git. KWSys is kept in a CVS repository -shared by several projects. A robot replays changes committed there -into the Source/kwsys directory in CMake. Please send changes to -this directory separately. Run +should not be made directly in CMake. KWSys is kept in its own Git +repository and shared by several projects. Please visit - git reset HEAD -- Source/kwsys + http://public.kitware.com/Wiki/KWSys/Git -to unstage these changes and then +to contribute changes directly to KWSys. Run - git diff -- Source/kwsys > kwsys.patch + git reset HEAD -- Source/kwsys -to construct the patch. Alternatively, set environment variable +to unstage these changes. Alternatively, set environment variable HOOKS_ALLOW_KWSYS=1 diff --git a/Utilities/KWIML/ABI.h.in b/Utilities/KWIML/ABI.h.in index 060a520..7f4772a 100644 --- a/Utilities/KWIML/ABI.h.in +++ b/Utilities/KWIML/ABI.h.in @@ -414,6 +414,18 @@ suppression macro @KWIML@_ABI_NO_VERIFY was defined. #elif defined(__SYSC_ZARCH__) # define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +/* VAX */ +#elif defined(__vax__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* Aarch64 */ +#elif defined(__aarch64__) +# if !defined(__AARCH64EB__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +# else +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +# endif + /* Unknown CPU */ #elif !defined(@KWIML@_ABI_NO_ERROR_ENDIAN) # error "Byte order of target CPU unknown." diff --git a/Utilities/cmlibarchive/libarchive/archive_endian.h b/Utilities/cmlibarchive/libarchive/archive_endian.h index bbf58fd..3c039f7 100644 --- a/Utilities/cmlibarchive/libarchive/archive_endian.h +++ b/Utilities/cmlibarchive/libarchive/archive_endian.h @@ -64,7 +64,13 @@ archive_be16dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[0] << 8) | p[1]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p0 << 8) | p1); } static inline uint32_t @@ -72,7 +78,15 @@ archive_be32dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p3 = p[3]; + unsigned int p2 = p[2]; + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p0 << 24) | (p1 << 16) | (p2 << 8) | p3); } static inline uint64_t @@ -88,7 +102,13 @@ archive_le16dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[1] << 8) | p[0]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p1 << 8) | p0); } static inline uint32_t @@ -96,7 +116,15 @@ archive_le32dec(const void *pp) { unsigned char const *p = (unsigned char const *)pp; - return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); + /* Store into unsigned temporaries before left shifting, to avoid + promotion to signed int and then left shifting into the sign bit, + which is undefined behaviour. */ + unsigned int p3 = p[3]; + unsigned int p2 = p[2]; + unsigned int p1 = p[1]; + unsigned int p0 = p[0]; + + return ((p3 << 24) | (p2 << 16) | (p1 << 8) | p0); } static inline uint64_t @@ -93,6 +93,19 @@ else cmake_system_openvms=false fi +# Determine whether this is Linux +if echo "${cmake_system}" | grep Linux >/dev/null 2>&1; then + cmake_system_linux=true + # find out if it is a HP PA-RISC machine + if uname -m | grep parisc >/dev/null 2>&1; then + cmake_machine_parisc=true + else + cmake_machine_parisc=false + fi +else + cmake_system_linux=false +fi + # Choose the generator to use for bootstrapping. if ${cmake_system_mingw}; then # Bootstrapping from an MSYS prompt. @@ -271,18 +284,11 @@ if ${cmake_system_mingw}; then ProcessWin32 \ String \ System" - KWSYS_C_MINGW_SOURCES="\ - ProcessFwd9x \ - EncodeExecutable" - KWSYS_C_GENERATED_SOURCES="\ - cmsysProcessFwd9xEnc" else KWSYS_C_SOURCES="\ ProcessUNIX \ String \ System" - KWSYS_C_MINGW_SOURCES="" - KWSYS_C_GENERATED_SOURCES="" fi KWSYS_CXX_SOURCES="\ @@ -678,6 +684,14 @@ if ${cmake_system_haiku}; then cmake_ld_flags="${LDFLAGS} -lroot -lbe" fi +if ${cmake_system_linux}; then + # avoid binutils problem with large binaries, e.g. when building CMake in debug mode + # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230 + if ${cmake_machine_parisc}; then + cmake_ld_flags="${LDFLAGS} -Wl,--unique=.text.*" + fi +fi + #----------------------------------------------------------------------------- # Detect known toolchains on some platforms. cmake_toolchains='' @@ -1330,7 +1344,7 @@ cmake_compiler_settings_comment="/* * Sources: * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} * kwSys Sources: - * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES} + * ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} */ " @@ -1426,7 +1440,7 @@ done # Generate Makefile dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" objs="" -for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES} ${KWSYS_C_GENERATED_SOURCES}; do +for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do objs="${objs} ${a}.o" done @@ -1467,7 +1481,7 @@ for a in ${CMAKE_C_SOURCES}; do echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done -for a in ${KWSYS_C_SOURCES} ${KWSYS_C_MINGW_SOURCES}; do +for a in ${KWSYS_C_SOURCES}; do src=`cmake_escape "${cmake_source_dir}/Source/kwsys/${a}.c"` src_flags=`eval echo \\${cmake_c_flags_\${a}}` echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" @@ -1479,20 +1493,6 @@ for a in ${KWSYS_CXX_SOURCES}; do echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done -if ${cmake_system_mingw}; then - src=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9xEnc.c"` - in=`cmake_escape "${cmake_bootstrap_dir}/cmsysProcessFwd9x.exe"` - cmd=`cmake_escape "${cmake_bootstrap_dir}/cmsysEncodeExecutable.exe"` - a="cmsysProcessFwd9xEnc" - echo "${cmd} : EncodeExecutable.o" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} EncodeExecutable.o -o ${cmd}" >> "${cmake_bootstrap_dir}/Makefile" - echo "${in} : ProcessFwd9x.o" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_ld_flags} ${cmake_c_flags} ProcessFwd9x.o -o ${in}" >> "${cmake_bootstrap_dir}/Makefile" - echo "${src} : ${cmd} ${in}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmd} ${in} ${src} cmsys ProcessFwd9x" >> "${cmake_bootstrap_dir}/Makefile" - echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" - echo " ${cmake_c_compiler} ${cmake_c_flags} -I`cmake_escape \"${cmake_source_dir}/Source/kwsys\"` -DKWSYS_NAMESPACE=cmsys -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" -fi echo ' rebuild_cache: cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap" |