diff options
157 files changed, 3595 insertions, 1389 deletions
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake index 1889be2..fc042bc 100644 --- a/CMakeCPack.cmake +++ b/CMakeCPack.cmake @@ -1,205 +1,200 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -# If the cmake version includes cpack, use it -if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") - if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake") - option(CMAKE_INSTALL_DEBUG_LIBRARIES - "Install Microsoft runtime debug libraries with CMake." FALSE) - mark_as_advanced(CMAKE_INSTALL_DEBUG_LIBRARIES) - - # By default, do not warn when built on machines using only VS Express: - if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) - set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) - endif() +option(CMAKE_INSTALL_DEBUG_LIBRARIES + "Install Microsoft runtime debug libraries with CMake." FALSE) +mark_as_advanced(CMAKE_INSTALL_DEBUG_LIBRARIES) - if(CMake_INSTALL_DEPENDENCIES) - include(${CMake_SOURCE_DIR}/Modules/InstallRequiredSystemLibraries.cmake) - endif() - endif() +# By default, do not warn when built on machines using only VS Express: +if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) + set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) +endif() - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool") - set(CPACK_PACKAGE_VENDOR "Kitware") - set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") - set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") - set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") - set(CPACK_PACKAGE_VERSION "${CMake_VERSION}") - set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") - set(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-${CMake_VERSION}") +if(CMake_INSTALL_DEPENDENCIES) + include(${CMake_SOURCE_DIR}/Modules/InstallRequiredSystemLibraries.cmake) +endif() - # Installers for 32- vs. 64-bit CMake: - # - Root install directory (displayed to end user at installer-run time) - # - "NSIS package/display name" (text used in the installer GUI) - # - Registry key used to store info about the installation - if(CMAKE_CL_64) - set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") - set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool") +set(CPACK_PACKAGE_VENDOR "Kitware") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") +set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") +set(CPACK_PACKAGE_VERSION "${CMake_VERSION}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-${CMake_VERSION}") + +# Installers for 32- vs. 64-bit CMake: +# - Root install directory (displayed to end user at installer-run time) +# - "NSIS package/display name" (text used in the installer GUI) +# - Registry key used to store info about the installation +if(CMAKE_CL_64) + set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") + set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)") +else() + set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") + set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") +endif() +set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_PACKAGE_NAME}") + +if(NOT DEFINED CPACK_SYSTEM_NAME) + # make sure package is not Cygwin-unknown, for Cygwin just + # cygwin is good for the system name + if("x${CMAKE_SYSTEM_NAME}" STREQUAL "xCYGWIN") + set(CPACK_SYSTEM_NAME Cygwin) else() - set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") - set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") - endif() - set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_PACKAGE_NAME}") - - if(NOT DEFINED CPACK_SYSTEM_NAME) - # make sure package is not Cygwin-unknown, for Cygwin just - # cygwin is good for the system name - if("x${CMAKE_SYSTEM_NAME}" STREQUAL "xCYGWIN") - set(CPACK_SYSTEM_NAME Cygwin) - else() - set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) - endif() + set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) endif() - if(${CPACK_SYSTEM_NAME} MATCHES Windows) - if(CMAKE_CL_64) - set(CPACK_SYSTEM_NAME win64-x64) - set(CPACK_IFW_TARGET_DIRECTORY "@RootDir@/Program Files/${CMAKE_PROJECT_NAME}") - else() - set(CPACK_SYSTEM_NAME win32-x86) - endif() +endif() +if(${CPACK_SYSTEM_NAME} MATCHES Windows) + if(CMAKE_CL_64) + set(CPACK_SYSTEM_NAME win64-x64) + set(CPACK_IFW_TARGET_DIRECTORY "@RootDir@/Program Files/${CMAKE_PROJECT_NAME}") + else() + set(CPACK_SYSTEM_NAME win32-x86) endif() +endif() - # Components - if(CMake_INSTALL_COMPONENTS) - set(_CPACK_IFW_COMPONENTS_ALL cmake ctest cpack) - if(WIN32 AND NOT CYGWIN) - list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps) - endif() - if(APPLE) - list(APPEND _CPACK_IFW_COMPONENTS_ALL cmakexbuild) - endif() - if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME) - set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME - ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) - else() - set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME Unspecified) - endif() - list(APPEND _CPACK_IFW_COMPONENTS_ALL ${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME}) - string(TOUPPER "${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME}" - _CPACK_IFW_COMPONENT_UNSPECIFIED_UNAME) - if(BUILD_CursesDialog) - list(APPEND _CPACK_IFW_COMPONENTS_ALL ccmake) - endif() - if(BUILD_QtDialog) - list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-gui) - if(USE_LGPL) - set(_CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES "set(CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES - \"LGPLv${USE_LGPL}\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt\")") - endif() - endif() - if(SPHINX_MAN) - list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-man) - endif() - if(SPHINX_HTML) - list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-html) - endif() - if(SPHINX_SINGLEHTML) - list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-singlehtml) +# Components +if(CMake_INSTALL_COMPONENTS) + set(_CPACK_IFW_COMPONENTS_ALL cmake ctest cpack) + if(WIN32 AND NOT CYGWIN) + list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps) + endif() + if(APPLE) + list(APPEND _CPACK_IFW_COMPONENTS_ALL cmakexbuild) + endif() + if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME) + set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME + ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) + else() + set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME Unspecified) + endif() + list(APPEND _CPACK_IFW_COMPONENTS_ALL ${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME}) + string(TOUPPER "${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME}" + _CPACK_IFW_COMPONENT_UNSPECIFIED_UNAME) + if(BUILD_CursesDialog) + list(APPEND _CPACK_IFW_COMPONENTS_ALL ccmake) + endif() + if(BUILD_QtDialog) + list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-gui) + if(USE_LGPL) + set(_CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES "set(CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES + \"LGPLv${USE_LGPL}\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt\")") endif() - if(SPHINX_QTHELP) - list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-qthelp) + endif() + if(SPHINX_MAN) + list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-man) + endif() + if(SPHINX_HTML) + list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-html) + endif() + if(SPHINX_SINGLEHTML) + list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-singlehtml) + endif() + if(SPHINX_QTHELP) + list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-qthelp) + endif() + if(CMake_BUILD_DEVELOPER_REFERENCE) + if(CMake_BUILD_DEVELOPER_REFERENCE_HTML) + list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-html) endif() - if(CMake_BUILD_DEVELOPER_REFERENCE) - if(CMake_BUILD_DEVELOPER_REFERENCE_HTML) - list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-html) - endif() - if(CMake_BUILD_DEVELOPER_REFERENCE_QTHELP) - list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-qthelp) - endif() + if(CMake_BUILD_DEVELOPER_REFERENCE_QTHELP) + list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-qthelp) endif() - set(_CPACK_IFW_COMPONENTS_CONFIGURATION " - # Components - set(CPACK_COMPONENTS_ALL \"${_CPACK_IFW_COMPONENTS_ALL}\") - set(CPACK_COMPONENTS_GROUPING IGNORE) + endif() + set(_CPACK_IFW_COMPONENTS_CONFIGURATION " +# Components +set(CPACK_COMPONENTS_ALL \"${_CPACK_IFW_COMPONENTS_ALL}\") +set(CPACK_COMPONENTS_GROUPING IGNORE) ") - else() - if(BUILD_QtDialog AND USE_LGPL) - set(_CPACK_IFW_ADDITIONAL_LICENSES - "\"LGPLv${USE_LGPL}\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt\"") - endif() +else() + if(BUILD_QtDialog AND USE_LGPL) + set(_CPACK_IFW_ADDITIONAL_LICENSES + "\"LGPLv${USE_LGPL}\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt\"") endif() +endif() - # Components scripts configuration - foreach(_script - CMake - CMake.Documentation.SphinxHTML - CMake.DeveloperReference.HTML) - configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/${_script}.qs.in" - "${CMake_BINARY_DIR}/${_script}.qs" @ONLY) - endforeach() - - if(${CMAKE_SYSTEM_NAME} MATCHES Windows) - set(_CPACK_IFW_PACKAGE_ICON - "set(CPACK_IFW_PACKAGE_ICON \"${CMake_SOURCE_DIR}/Source/QtDialog/CMakeSetup.ico\")") - if(BUILD_QtDialog) - set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n") - endif() - if(SPHINX_HTML) - set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/html/index.html\", \"@StartMenuDir@/CMake Documentation.lnk\");\n") - endif() - if(CMake_BUILD_DEVELOPER_REFERENCE) - if(CMake_BUILD_DEVELOPER_REFERENCE_HTML) - set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/developer-reference/html/index.html\", \"@StartMenuDir@/CMake Developer Reference.lnk\");\n") - endif() - endif() - configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/installscript.qs.in" - "${CMake_BINARY_DIR}/installscript.qs" @ONLY - ) - install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html" - DESTINATION "${CMAKE_DOC_DIR}" - ) - if(CMake_INSTALL_COMPONENTS) - set(_CPACK_IFW_PACKAGE_SCRIPT "${CMake_BINARY_DIR}/CMake.qs") - else() - set(_CPACK_IFW_PACKAGE_SCRIPT "${CMake_BINARY_DIR}/installscript.qs") +# Components scripts configuration +foreach(_script + CMake + CMake.Documentation.SphinxHTML + CMake.DeveloperReference.HTML) + configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/${_script}.qs.in" + "${CMake_BINARY_DIR}/${_script}.qs" @ONLY) +endforeach() + +if(${CMAKE_SYSTEM_NAME} MATCHES Windows) + set(_CPACK_IFW_PACKAGE_ICON + "set(CPACK_IFW_PACKAGE_ICON \"${CMake_SOURCE_DIR}/Source/QtDialog/CMakeSetup.ico\")") + if(BUILD_QtDialog) + set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n") + endif() + if(SPHINX_HTML) + set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/html/index.html\", \"@StartMenuDir@/CMake Documentation.lnk\");\n") + endif() + if(CMake_BUILD_DEVELOPER_REFERENCE) + if(CMake_BUILD_DEVELOPER_REFERENCE_HTML) + set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/developer-reference/html/index.html\", \"@StartMenuDir@/CMake Developer Reference.lnk\");\n") endif() endif() - - if(${CMAKE_SYSTEM_NAME} MATCHES Linux) - set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${CMAKE_PROJECT_NAME}") - set(CPACK_IFW_ADMIN_TARGET_DIRECTORY "@ApplicationsDir@/${CMAKE_PROJECT_NAME}") + configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/installscript.qs.in" + "${CMake_BINARY_DIR}/installscript.qs" @ONLY + ) + install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html" + DESTINATION "${CMAKE_DOC_DIR}" + ) + if(CMake_INSTALL_COMPONENTS) + set(_CPACK_IFW_PACKAGE_SCRIPT "${CMake_BINARY_DIR}/CMake.qs") + else() + set(_CPACK_IFW_PACKAGE_SCRIPT "${CMake_BINARY_DIR}/installscript.qs") endif() +endif() - set(_CPACK_IFW_PACKAGE_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}) +if(${CMAKE_SYSTEM_NAME} MATCHES Linux) + set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${CMAKE_PROJECT_NAME}") + set(CPACK_IFW_ADMIN_TARGET_DIRECTORY "@ApplicationsDir@/${CMAKE_PROJECT_NAME}") +endif() - if(NOT DEFINED CPACK_PACKAGE_FILE_NAME) - # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache - # default to source package - system, on cygwin system is not - # needed - if(CYGWIN) - set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}") - else() - set(CPACK_PACKAGE_FILE_NAME - "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}") - endif() +set(_CPACK_IFW_PACKAGE_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}) + +if(NOT DEFINED CPACK_PACKAGE_FILE_NAME) + # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache + # default to source package - system, on cygwin system is not + # needed + if(CYGWIN) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}") + else() + set(CPACK_PACKAGE_FILE_NAME + "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}") endif() +endif() - set(CPACK_PACKAGE_CONTACT "cmake@cmake.org") +set(CPACK_PACKAGE_CONTACT "cmake@cmake.org") - if(UNIX) - set(CPACK_STRIP_FILES "${CMAKE_BIN_DIR}/ccmake;${CMAKE_BIN_DIR}/cmake;${CMAKE_BIN_DIR}/cpack;${CMAKE_BIN_DIR}/ctest") - set(CPACK_SOURCE_STRIP_FILES "") - set(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") - endif() +if(UNIX) + set(CPACK_STRIP_FILES "${CMAKE_BIN_DIR}/ccmake;${CMAKE_BIN_DIR}/cmake;${CMAKE_BIN_DIR}/cpack;${CMAKE_BIN_DIR}/ctest") + set(CPACK_SOURCE_STRIP_FILES "") + set(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake") +endif() - set(CPACK_WIX_UPGRADE_GUID "8ffd1d72-b7f1-11e2-8ee5-00238bca4991") +set(CPACK_WIX_UPGRADE_GUID "8ffd1d72-b7f1-11e2-8ee5-00238bca4991") - if(MSVC AND NOT "$ENV{WIX}" STREQUAL "") - set(WIX_CUSTOM_ACTION_ENABLED TRUE) - if(CMAKE_CONFIGURATION_TYPES) - set(WIX_CUSTOM_ACTION_MULTI_CONFIG TRUE) - else() - set(WIX_CUSTOM_ACTION_MULTI_CONFIG FALSE) - endif() +if(MSVC AND NOT "$ENV{WIX}" STREQUAL "") + set(WIX_CUSTOM_ACTION_ENABLED TRUE) + if(CMAKE_CONFIGURATION_TYPES) + set(WIX_CUSTOM_ACTION_MULTI_CONFIG TRUE) else() - set(WIX_CUSTOM_ACTION_ENABLED FALSE) + set(WIX_CUSTOM_ACTION_MULTI_CONFIG FALSE) endif() +else() + set(WIX_CUSTOM_ACTION_ENABLED FALSE) +endif() - # Set the options file that needs to be included inside CMakeCPackOptions.cmake - set(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake) - configure_file("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in" - "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY) - set(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake") +# Set the options file that needs to be included inside CMakeCPackOptions.cmake +set(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake) +configure_file("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in" + "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY) +set(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake") - # include CPack model once all variables are set - include(CPack) -endif() +# include CPack model once all variables are set +include(CPack) diff --git a/CMakeLists.txt b/CMakeLists.txt index 309e224..b8a635f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,10 @@ if(POLICY CMP0053) endif() project(CMake) +# Make sure we can find internal find_package modules only used for +# building CMake and not for shipping externally +list(INSERT CMAKE_MODULE_PATH 0 ${CMake_SOURCE_DIR}/Source/Modules) + if(CMAKE_BOOTSTRAP) # Running from bootstrap script. Set local variable and remove from cache. set(CMAKE_BOOTSTRAP 1) @@ -362,31 +366,55 @@ macro (CMAKE_BUILD_UTILITIES) set(CMAKE_COMPRESS_LIBRARIES "cmcompress") add_subdirectory(Utilities/cmcompress) CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty") - if(CMAKE_USE_SYSTEM_BZIP2) - find_package(BZip2) + + #--------------------------------------------------------------------- + # Build expat library for CMake, CTest, and libarchive. + if(CMAKE_USE_SYSTEM_EXPAT) + find_package(EXPAT) + if(NOT EXPAT_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") + endif() + set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) + set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) else() - set(BZIP2_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") - set(BZIP2_LIBRARIES cmbzip2) - add_subdirectory(Utilities/cmbzip2) - CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") + set(CMAKE_EXPAT_INCLUDES) + set(CMAKE_EXPAT_LIBRARIES cmexpat) + add_subdirectory(Utilities/cmexpat) + CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") + endif() + + #--------------------------------------------------------------------- + # Build or use system libbz2 for libarchive. + if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_BZIP2) + find_package(BZip2) + else() + set(BZIP2_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") + set(BZIP2_LIBRARIES cmbzip2) + add_subdirectory(Utilities/cmbzip2) + CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") + endif() endif() #--------------------------------------------------------------------- # Build or use system liblzma for libarchive. - if(CMAKE_USE_SYSTEM_LIBLZMA) - find_package(LibLZMA) - if(NOT LIBLZMA_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") + if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_LIBLZMA) + find_package(LibLZMA) + if(NOT LIBLZMA_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") + endif() + set(LZMA_INCLUDE_DIR ${LIBLZMA_INCLUDE_DIRS}) + set(LZMA_LIBRARY ${LIBLZMA_LIBRARIES}) + else() + add_subdirectory(Utilities/cmliblzma) + CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") + set(LZMA_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") + set(LZMA_LIBRARY cmliblzma) endif() - set(LZMA_INCLUDE_DIR ${LIBLZMA_INCLUDE_DIRS}) - set(LZMA_LIBRARY ${LIBLZMA_LIBRARIES}) - else() - add_subdirectory(Utilities/cmliblzma) - CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") - set(LZMA_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") - set(LZMA_LIBRARY cmliblzma) endif() #--------------------------------------------------------------------- @@ -399,6 +427,8 @@ macro (CMAKE_BUILD_UTILITIES) set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) else() + set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) + set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) add_definitions(-DLIBARCHIVE_STATIC) @@ -408,7 +438,7 @@ macro (CMAKE_BUILD_UTILITIES) set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found") set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found") set(ENABLE_LIBXML2 OFF CACHE INTERNAL "Enable the use of the system found libxml2 library if found") - set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system found EXPAT library if found") + set(ENABLE_EXPAT ON CACHE INTERNAL "Enable the use of the system found EXPAT library if found") set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system found PCREPOSIX library if found") set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system found LibGCC library if found") set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support") @@ -421,27 +451,10 @@ macro (CMAKE_BUILD_UTILITIES) endif() #--------------------------------------------------------------------- - # Build expat library for CMake and CTest. - if(CMAKE_USE_SYSTEM_EXPAT) - find_package(EXPAT) - if(NOT EXPAT_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") - endif() - set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) - set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) - else() - set(CMAKE_EXPAT_INCLUDES) - set(CMAKE_EXPAT_LIBRARIES cmexpat) - add_subdirectory(Utilities/cmexpat) - CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- # Build jsoncpp library. if(CMAKE_USE_SYSTEM_JSONCPP) if(NOT CMAKE_VERSION VERSION_LESS 3.0) - include(${CMake_SOURCE_DIR}/Source/Modules/FindJsonCpp.cmake) + find_package(JsonCpp) else() message(FATAL_ERROR "CMAKE_USE_SYSTEM_JSONCPP requires CMake >= 3.0") endif() @@ -487,7 +500,7 @@ int main(void) { return 0; } if(CMAKE_USE_LIBUV) if(CMAKE_USE_SYSTEM_LIBUV) if(NOT CMAKE_VERSION VERSION_LESS 3.0) - include(${CMake_SOURCE_DIR}/Source/Modules/FindLibUV.cmake) + find_package(LibUV 1.0.0) else() message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBUV requires CMake >= 3.0") endif() diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH.txt b/Help/generator/VS_TOOLSET_HOST_ARCH.txt new file mode 100644 index 0000000..58e9223 --- /dev/null +++ b/Help/generator/VS_TOOLSET_HOST_ARCH.txt @@ -0,0 +1,10 @@ +For each toolset that comes with this version of Visual Studio, there are +variants that are themselves compiled for 32-bit (x86) and 64-bit (x64) hosts +(independent of the architecture they target). By default Visual Studio +chooses the 32-bit variant even on a 64-bit host. One may request use of the +64-bit host tools by adding ``host=x64`` to the toolset specification: + +``host=x64`` + Select the 64-bit variant of the default toolset. +``<toolset>,host=x64`` + Select the 64-bit variant of the ``<toolset>`` toolset. diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst index c694443..04eef10 100644 --- a/Help/generator/Visual Studio 10 2010.rst +++ b/Help/generator/Visual Studio 10 2010.rst @@ -17,3 +17,10 @@ a target platform name optionally at the end of this generator name: For compatibility with CMake versions prior to 3.0, one may specify this generator using the name ``Visual Studio 10`` without the year component. + +Toolset Selection +^^^^^^^^^^^^^^^^^ + +The ``v100`` toolset that comes with Visual Studio 10 2010 is selected by +default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps +via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst index 2f1e729..347a153 100644 --- a/Help/generator/Visual Studio 11 2012.rst +++ b/Help/generator/Visual Studio 11 2012.rst @@ -20,3 +20,10 @@ a target platform name optionally at the end of this generator name: For compatibility with CMake versions prior to 3.0, one may specify this generator using the name "Visual Studio 11" without the year component. + +Toolset Selection +^^^^^^^^^^^^^^^^^ + +The ``v110`` toolset that comes with Visual Studio 11 2012 is selected by +default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps +via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst index 6e8545b..5071b20 100644 --- a/Help/generator/Visual Studio 12 2013.rst +++ b/Help/generator/Visual Studio 12 2013.rst @@ -17,3 +17,12 @@ a target platform name optionally at the end of this generator name: For compatibility with CMake versions prior to 3.0, one may specify this generator using the name "Visual Studio 12" without the year component. + +Toolset Selection +^^^^^^^^^^^^^^^^^ + +The ``v120`` toolset that comes with Visual Studio 12 2013 is selected by +default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps +via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. + +.. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst index 707caf9..64254b5 100644 --- a/Help/generator/Visual Studio 14 2015.rst +++ b/Help/generator/Visual Studio 14 2015.rst @@ -14,3 +14,12 @@ a target platform name optionally at the end of this generator name: ``Visual Studio 14 2015 ARM`` Specify target platform ``ARM``. + +Toolset Selection +^^^^^^^^^^^^^^^^^ + +The ``v140`` toolset that comes with Visual Studio 14 2015 is selected by +default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps +via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. + +.. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/generator/Visual Studio 15.rst b/Help/generator/Visual Studio 15.rst index ae456eb..2eb9052 100644 --- a/Help/generator/Visual Studio 15.rst +++ b/Help/generator/Visual Studio 15.rst @@ -14,3 +14,12 @@ a target platform name optionally at the end of this generator name: ``Visual Studio 15 ARM`` Specify target platform ``ARM``. + +Toolset Selection +^^^^^^^^^^^^^^^^^ + +The ``v141`` toolset that comes with Visual Studio 15 is selected by +default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps +via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. + +.. include:: VS_TOOLSET_HOST_ARCH.txt diff --git a/Help/generator/Xcode.rst b/Help/generator/Xcode.rst index d8a6790..25ff4c7 100644 --- a/Help/generator/Xcode.rst +++ b/Help/generator/Xcode.rst @@ -2,3 +2,10 @@ Xcode ----- Generate Xcode project files. + +Toolset Selection +^^^^^^^^^^^^^^^^^ + +By default Xcode is allowed to select its own default toolchain. +The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps +via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index fa0e4c1..9b3f717 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -52,13 +52,12 @@ Specify toolset name if supported by generator. Some CMake generators support a toolset name to be given to the - native build system to choose a compiler. This is supported only on - specific generators: - - :: + native build system to choose a compiler. + See the :variable:`CMAKE_GENERATOR_TOOLSET` variable. + This is supported only on specific generators: - Visual Studio >= 10 - Xcode >= 3.0 + * :ref:`Visual Studio Generators` for VS 2010 and above + * The :generator:`Xcode` generator for Xcode 3.0 and above See native build system documentation for allowed toolset names. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 271f497..fa21a1f 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -121,6 +121,7 @@ Properties on Targets /prop_tgt/AUTORCC /prop_tgt/AUTORCC_OPTIONS /prop_tgt/BINARY_DIR + /prop_tgt/BUILD_RPATH /prop_tgt/BUILD_WITH_INSTALL_RPATH /prop_tgt/BUNDLE_EXTENSION /prop_tgt/BUNDLE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index b74f867..a5b1daa 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -82,6 +82,7 @@ Variables that Provide Information /variable/CMAKE_VS_NsightTegra_VERSION /variable/CMAKE_VS_PLATFORM_NAME /variable/CMAKE_VS_PLATFORM_TOOLSET + /variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION /variable/CMAKE_XCODE_PLATFORM_TOOLSET /variable/PROJECT_BINARY_DIR @@ -159,6 +160,7 @@ Variables that Change Behavior /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY /variable/CMAKE_STAGING_PREFIX + /variable/CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE /variable/CMAKE_SYSTEM_APPBUNDLE_PATH /variable/CMAKE_SYSTEM_FRAMEWORK_PATH /variable/CMAKE_SYSTEM_IGNORE_PATH @@ -257,6 +259,7 @@ Variables that Control the Build /variable/CMAKE_AUTORCC_OPTIONS /variable/CMAKE_AUTOUIC /variable/CMAKE_AUTOUIC_OPTIONS + /variable/CMAKE_BUILD_RPATH /variable/CMAKE_BUILD_WITH_INSTALL_RPATH /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG diff --git a/Help/prop_tgt/BUILD_RPATH.rst b/Help/prop_tgt/BUILD_RPATH.rst new file mode 100644 index 0000000..27393f5 --- /dev/null +++ b/Help/prop_tgt/BUILD_RPATH.rst @@ -0,0 +1,10 @@ +BUILD_RPATH +----------- + +A :ref:`;-list <CMake Language Lists>` specifying runtime path (``RPATH``) +entries to add to binaries linked in the build tree (for platforms that +support it). The entries will *not* be used for binaries in the install +tree. See also the :prop_tgt:`INSTALL_RPATH` target property. + +This property is initialized by the value of the variable +:variable:`CMAKE_BUILD_RPATH` if it is set when a target is created. diff --git a/Help/release/3.7.rst b/Help/release/3.7.rst index 97c6f7c..3b8ade6 100644 --- a/Help/release/3.7.rst +++ b/Help/release/3.7.rst @@ -32,7 +32,7 @@ Generators with :ref:`Makefile Generators`. * The :generator:`Visual Studio 15` generator was added. This is - experimental and based on Preview 4 because this version of VS + experimental and based on Preview 5 because this version of VS has not been released. * :ref:`Visual Studio Generators` for VS 2010 and above learned to @@ -176,7 +176,14 @@ Modules * A :module:`FindICU` module was introduced to find the International Components for Unicode (ICU) libraries and programs. -* The :module:`FindMatlab` module learned to find a SIMULINK component. +* The :module:`FindMatlab` module learned to find the SIMULINK and MAT + components. + +* The :module:`FindMatlab` module :command:`matlab_add_mex` command learned + to add executables and modules. + +* The :module:`FindMatlab` module :command:`matlab_add_unit_test` command + learned to support inline Matlab test code. * The :module:`FindOpenCL` module now provides imported targets. @@ -242,6 +249,10 @@ CPack :variable:`CPACK_RPM_SOURCE_PKG_BUILD_PARAMS` and :variable:`CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX`. +* The CPack NSIS generator now supports + :variable:`CPACK_NSIS_<compName>_INSTALL_DIRECTORY`. + This can be used to set component specific installation directories. + * The CPack WIX generator now supports :variable:`CPACK_WIX_SKIP_PROGRAM_FOLDER` to allow specification of a custom absolute installation prefix outside diff --git a/Help/release/dev/add-BUILD_RPATH.rst b/Help/release/dev/add-BUILD_RPATH.rst new file mode 100644 index 0000000..0d69e45 --- /dev/null +++ b/Help/release/dev/add-BUILD_RPATH.rst @@ -0,0 +1,6 @@ +add-BUILD_RPATH +--------------- + +* A :variable:`CMAKE_BUILD_RPATH` variable and corresponding + :prop_tgt:`BUILD_RPATH` target property were added to support custom + ``RPATH`` locations to be added to binaries in the build tree. diff --git a/Help/release/dev/cpack-rpm-single-debuginfo.rst b/Help/release/dev/cpack-rpm-single-debuginfo.rst new file mode 100644 index 0000000..34a710d --- /dev/null +++ b/Help/release/dev/cpack-rpm-single-debuginfo.rst @@ -0,0 +1,11 @@ +cpack-rpm-single-debuginfo +-------------------------- + +* The :module:`CPackRPM` module learned to generate main component package + which forces generation of a rpm for defined component without component + suffix in filename and package name. + See :variable:`CPACK_RPM_MAIN_COMPONENT` variable. + +* The :module:`CPackRPM` module learned to generate a single debuginfo package + on demand even if components packagin is used. + See :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` variable. diff --git a/Help/release/dev/st2-exclude-patterns-variable.rst b/Help/release/dev/st2-exclude-patterns-variable.rst new file mode 100644 index 0000000..8706c1f --- /dev/null +++ b/Help/release/dev/st2-exclude-patterns-variable.rst @@ -0,0 +1,7 @@ +st2-exclude-patterns-variable +----------------------------- + +* The :generator:`Sublime Text 2` extra generator no longer excludes the + build tree from the ``.sublime-project`` when it is inside the source tree. + The :variable:`CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE` variable + was added to control the behavior explicitly. diff --git a/Help/release/dev/vs-host-x64-tools.rst b/Help/release/dev/vs-host-x64-tools.rst new file mode 100644 index 0000000..e42881a --- /dev/null +++ b/Help/release/dev/vs-host-x64-tools.rst @@ -0,0 +1,7 @@ +vs-host-x64-tools +----------------- + +* The :ref:`Visual Studio Generators` for VS 2013 and above learned to + support a ``host=x64`` option in the :variable:`CMAKE_GENERATOR_TOOLSET` + value (e.g. via the :manual:`cmake(1)` ``-T`` option) to request use + of a VS 64-bit toolchain on 64-bit hosts. diff --git a/Help/variable/CMAKE_BUILD_RPATH.rst b/Help/variable/CMAKE_BUILD_RPATH.rst new file mode 100644 index 0000000..f20eb41 --- /dev/null +++ b/Help/variable/CMAKE_BUILD_RPATH.rst @@ -0,0 +1,10 @@ +CMAKE_BUILD_RPATH +----------------- + +A :ref:`;-list <CMake Language Lists>` specifying runtime path (``RPATH``) +entries to add to binaries linked in the build tree (for platforms that +support it). The entries will *not* be used for binaries in the install +tree. See also the :variable:`CMAKE_INSTALL_RPATH` variable. + +This is used to initialize the :prop_tgt:`BUILD_RPATH` target property +for all targets. diff --git a/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst b/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst index 4aede03..33cdf6c 100644 --- a/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst +++ b/Help/variable/CMAKE_CODELITE_USE_TARGETS.rst @@ -3,5 +3,6 @@ CMAKE_CODELITE_USE_TARGETS Change the way the CodeLite generator creates projectfiles. -If this variable is set to ``ON`` the generator creates projectfiles -based on targets rather than projects. +If this variable evaluates to ``ON`` at the end of the top-level +``CMakeLists.txt`` file, the generator creates projectfiles based on targets +rather than projects. diff --git a/Help/variable/CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE.rst b/Help/variable/CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE.rst new file mode 100644 index 0000000..d654425 --- /dev/null +++ b/Help/variable/CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE.rst @@ -0,0 +1,7 @@ +CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE +--------------------------------------- + +If this variable evaluates to ``ON`` at the end of the top-level +``CMakeLists.txt`` file, the :generator:`Sublime Text 2` extra generator +excludes the build tree from the ``.sublime-project`` if it is inside the +source tree. diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst new file mode 100644 index 0000000..4c04e97 --- /dev/null +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst @@ -0,0 +1,10 @@ +CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE +------------------------------------------- + +Visual Studio preferred tool architecture. + +The :ref:`Visual Studio Generators` for VS 2013 and above support optional +selection of a 64-bit toolchain on 64-bit hosts by specifying a ``host=64`` +value in the :variable:`CMAKE_GENERATOR_TOOLSET` option. CMake provides +the selected toolchain architecture preference in this variable (either +``x64`` or empty). diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 145efc6..59d8ab6 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -182,6 +182,11 @@ Id flags: ${testflags} else() set(id_toolset "") endif() + if(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE) + set(id_PreferredToolArchitecture "<PreferredToolArchitecture>${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}</PreferredToolArchitecture>") + else() + set(id_PreferredToolArchitecture "") + endif() if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone") set(id_system "<ApplicationType>Windows Phone</ApplicationType>") elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 3bbaae9..6017ce3 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -95,6 +95,17 @@ # and it is up to the packager to set the variables in a manner that will # prevent such errors. # +# .. variable:: CPACK_RPM_MAIN_COMPONENT +# +# Main component that is packaged without component suffix. +# +# * Mandatory : NO +# * Default : - +# +# This variable can be set to any component or group name so that component or +# group rpm package is generated without component suffix in filename and +# package name. +# # .. variable:: CPACK_RPM_PACKAGE_VERSION # # The RPM package version. @@ -792,6 +803,26 @@ # * Mandatory : NO # * Default : - # +# .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE +# +# Create a single debuginfo package even if components packaging is set. +# +# * Mandatory : NO +# * Default : OFF +# +# When this variable is enabled it produces a single debuginfo package even if +# component packaging is enabled. +# +# When using this feature in combination with components packaging and there is +# more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT` +# to be set. +# +# .. note:: +# +# If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables +# is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to +# ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set. +# # Packaging of sources (SRPM) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ # @@ -1427,7 +1458,8 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}" RESULT_VARIABLE OBJDUMP_EXEC_RESULT - OUTPUT_VARIABLE OBJDUMP_OUT) + OUTPUT_VARIABLE OBJDUMP_OUT + ERROR_QUIET) # Check that if the given file was executable or not if(NOT OBJDUMP_EXEC_RESULT) string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT) @@ -1476,16 +1508,22 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) endif() endforeach() - list(REMOVE_DUPLICATES mkdir_list_) - unset(TMP_RPM_DEBUGINFO_INSTALL) - foreach(part_ IN LISTS mkdir_list_) - string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n") - endforeach() + list(LENGTH mkdir_list_ len_) + if(len_) + list(REMOVE_DUPLICATES mkdir_list_) + unset(TMP_RPM_DEBUGINFO_INSTALL) + foreach(part_ IN LISTS mkdir_list_) + string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n") + endforeach() + endif() - list(REMOVE_DUPLICATES cp_list_) - foreach(part_ IN LISTS cp_list_) - string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n") - endforeach() + list(LENGTH cp_list_ len_) + if(len_) + list(REMOVE_DUPLICATES cp_list_) + foreach(part_ IN LISTS cp_list_) + string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n") + endforeach() + endif() if(NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS) set(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug) @@ -1500,29 +1538,34 @@ function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR) message("CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}") endif() - list(REMOVE_DUPLICATES additional_sources_) - unset(additional_sources_all_) - foreach(source_ IN LISTS additional_sources_) - string(REPLACE "/" ";" split_source_ " ${source_}") - list(REMOVE_AT split_source_ 0) - unset(tmp_path_) - # Now generate all segments of the path - foreach(segment_ IN LISTS split_source_) - string(APPEND tmp_path_ "/${segment_}") - list(APPEND additional_sources_all_ "${tmp_path_}") + list(LENGTH additional_sources_ len_) + if(len_) + list(REMOVE_DUPLICATES additional_sources_) + unset(additional_sources_all_) + foreach(source_ IN LISTS additional_sources_) + string(REPLACE "/" ";" split_source_ " ${source_}") + list(REMOVE_AT split_source_ 0) + unset(tmp_path_) + # Now generate all segments of the path + foreach(segment_ IN LISTS split_source_) + string(APPEND tmp_path_ "/${segment_}") + list(APPEND additional_sources_all_ "${tmp_path_}") + endforeach() endforeach() - endforeach() - list(REMOVE_DUPLICATES additional_sources_all_) - list(REMOVE_ITEM additional_sources_all_ ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}) + list(REMOVE_DUPLICATES additional_sources_all_) + list(REMOVE_ITEM additional_sources_all_ + ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}) - unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES) - foreach(source_ IN LISTS additional_sources_all_) - string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n") - endforeach() + unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES) + foreach(source_ IN LISTS additional_sources_all_) + string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n") + endforeach() + endif() set(TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE) - set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}" PARENT_SCOPE) + set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}" + PARENT_SCOPE) endfunction() function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME) @@ -1637,10 +1680,16 @@ function(cpack_rpm_generate_package) endif() if(CPACK_RPM_PACKAGE_COMPONENT) - string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") - cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME" - "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME" - "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME") + string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}" + CPACK_RPM_MAIN_COMPONENT_UPPER) + + if(NOT CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER) + string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") + + cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME") + endif() endif() # CPACK_RPM_PACKAGE_VERSION (mandatory) @@ -2047,7 +2096,7 @@ function(cpack_rpm_generate_package) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_PACKAGE" "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_PACKAGE" "CPACK_RPM_DEBUGINFO_PACKAGE") - if(CPACK_RPM_DEBUGINFO_PACKAGE) + if(CPACK_RPM_DEBUGINFO_PACKAGE OR (CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND NOT GENERATE_SPEC_PARTS)) cpack_rpm_variable_fallback("CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX" "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_BUILD_SOURCE_DIRS_PREFIX" "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_BUILD_SOURCE_DIRS_PREFIX" @@ -2055,9 +2104,81 @@ function(cpack_rpm_generate_package) if(NOT CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX) set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}") endif() - cpack_rpm_debugsymbol_check("${CPACK_RPM_INSTALL_FILES}" "${WDIR}") - set(TMP_RPM_DEBUGINFO " + if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS) + file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files" + "${CPACK_RPM_INSTALL_FILES}") + else() + if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND CPACK_RPM_PACKAGE_COMPONENT) + # this part is only required by components packaging - with monolithic + # packages we can be certain that there are no other components present + # so CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is a noop + if(CPACK_RPM_DEBUGINFO_PACKAGE) + # only add current package files to debuginfo list if debuginfo + # generation is enabled for current package + set(install_files_ "${CPACK_RPM_INSTALL_FILES}") + else() + unset(install_files_) + endif() + + file(GLOB files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.files") + + foreach(f_ IN LISTS files_) + file(READ "${f_}" tmp_) + string(APPEND install_files_ ";${tmp_}") + endforeach() + + # if there were other components/groups so we need to move files from them + # to current component otherwise those files won't be found + file(GLOB components_ LIST_DIRECTORIES true RELATIVE + "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" + "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/*") + foreach(component_ IN LISTS components_) + string(TOUPPER "${component_}" component_dir_upper_) + if(component_dir_upper_ STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER) + # skip current component + continue() + endif() + + cmake_policy(PUSH) + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES false RELATIVE + "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}" + "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*") + cmake_policy(POP) + + foreach(f_ IN LISTS files_for_move_) + get_filename_component(dir_path_ "${f_}" DIRECTORY) + set(src_file_ + "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}") + + # check that we are not overriding an existing file that doesn't + # match the file that we want to copy + if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}") + execute_process( + COMMAND ${CMAKE_COMMAND} -E compare_files "${src_file_}" "${WDIR}/${f_}" + RESULT_VARIABLE res_ + ) + if(res_) + message(FATAL_ERROR "CPackRPM:Error: File on path '${WDIR}/${f_}'" + " already exists but is a different than the one in component" + " '${component_}'! Packages will not be generated.") + endif() + endif() + + file(MAKE_DIRECTORY "${WDIR}/${dir_path_}") + file(RENAME "${src_file_}" + "${WDIR}/${f_}") + endforeach() + endforeach() + + cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}") + else() + cpack_rpm_debugsymbol_check("${CPACK_RPM_INSTALL_FILES}" "${WDIR}") + endif() + + if(TMP_DEBUGINFO_ADDITIONAL_SOURCES) + set(TMP_RPM_DEBUGINFO " # Modified version of %%debug_package macro # defined in /usr/lib/rpm/macros as that one # can't handle injection of extra source files. @@ -2076,6 +2197,15 @@ package or when debugging this package. ${TMP_DEBUGINFO_ADDITIONAL_SOURCES} %endif ") + elseif(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE) + message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested" + " but will not be generated as no source files were found!") + else() + message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested" + " but will not be generated as no source files were found! Component: '" + "${CPACK_RPM_PACKAGE_COMPONENT}'.") + endif() + endif() endif() # Prepare install files @@ -2152,12 +2282,25 @@ ${TMP_DEBUGINFO_ADDITIONAL_SOURCES} cmake_policy(POP) else() # old file name format for back compatibility - set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") + string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}" + CPACK_RPM_MAIN_COMPONENT_UPPER) + + if(CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER) + # this is the main component so ignore the component filename part + set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.rpm") + else() + set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") + endif() endif() # else example: #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") - if(NOT CPACK_RPM_DEBUGINFO_PACKAGE) + if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS) + string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" expected_filename_) + + file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.rpm_name" + "${expected_filename_};${CPACK_RPM_FILE_NAME}") + elseif(NOT CPACK_RPM_DEBUGINFO_PACKAGE) set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}") endif() endif() @@ -2252,7 +2395,54 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@CPACK_RPM_SPEC_CHANGELOG\@ " ) + + elseif(GENERATE_SPEC_PARTS) # binary rpm with single debuginfo package + file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in + "# -*- rpm-spec -*- +%package -n \@CPACK_RPM_PACKAGE_NAME\@ +Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ +Version: \@CPACK_RPM_PACKAGE_VERSION\@ +Release: \@CPACK_RPM_PACKAGE_RELEASE\@ +License: \@CPACK_RPM_PACKAGE_LICENSE\@ +Group: \@CPACK_RPM_PACKAGE_GROUP\@ +Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ + +\@TMP_RPM_URL\@ +\@TMP_RPM_REQUIRES\@ +\@TMP_RPM_REQUIRES_PRE\@ +\@TMP_RPM_REQUIRES_POST\@ +\@TMP_RPM_REQUIRES_PREUN\@ +\@TMP_RPM_REQUIRES_POSTUN\@ +\@TMP_RPM_PROVIDES\@ +\@TMP_RPM_OBSOLETES\@ +\@TMP_RPM_CONFLICTS\@ +\@TMP_RPM_AUTOPROV\@ +\@TMP_RPM_AUTOREQ\@ +\@TMP_RPM_AUTOREQPROV\@ +\@TMP_RPM_BUILDARCH\@ +\@TMP_RPM_PREFIXES\@ + +%description -n \@CPACK_RPM_PACKAGE_NAME\@ +\@CPACK_RPM_PACKAGE_DESCRIPTION\@ + +%files -n \@CPACK_RPM_PACKAGE_NAME\@ +%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@) +\@CPACK_RPM_INSTALL_FILES\@ +\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@ +\@CPACK_RPM_USER_INSTALL_FILES\@ +" + ) + else() # binary rpm + if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE) + # find generated spec file and take its name + file(GLOB spec_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.spec") + + foreach(f_ IN LISTS spec_files_) + file(READ "${f_}" tmp_) + string(APPEND TMP_OTHER_COMPONENTS "\n${tmp_}\n") + endforeach() + endif() # We should generate a USER spec file template: # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE @@ -2338,6 +2528,8 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT %changelog \@CPACK_RPM_SPEC_CHANGELOG\@ + +\@TMP_OTHER_COMPONENTS\@ " ) endif() @@ -2364,60 +2556,90 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) endif() - if(RPMBUILD_EXECUTABLE) - # Now call rpmbuild using the SPECFILE - execute_process( - COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS} - --define "_topdir ${CPACK_RPM_DIRECTORY}" - --buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" - --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}" - "${CPACK_RPM_BINARY_SPECFILE}" - WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" - RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT - ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err" - OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out") - if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) - file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR) - file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT) - message("CPackRPM:Debug: You may consult rpmbuild logs in: ") - message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err") - message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") - message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out") - message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***") + if(NOT GENERATE_SPEC_PARTS) # generate package + if(RPMBUILD_EXECUTABLE) + # Now call rpmbuild using the SPECFILE + execute_process( + COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS} + --define "_topdir ${CPACK_RPM_DIRECTORY}" + --buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}" + "${CPACK_RPM_BINARY_SPECFILE}" + WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT + ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err" + OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out") + if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) + file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR) + file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT) + message("CPackRPM:Debug: You may consult rpmbuild logs in: ") + message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err") + message("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out") + message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***") + endif() + else() + if(ALIEN_EXECUTABLE) + message(FATAL_ERROR "RPM packaging through alien not done (yet)") + endif() endif() - else() - if(ALIEN_EXECUTABLE) - message(FATAL_ERROR "RPM packaging through alien not done (yet)") + + # find generated rpm files and take their names + cmake_policy(PUSH) + # Tell file(GLOB_RECURSE) not to follow directory symlinks + # even if the project does not set this policy to NEW. + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm" + "${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm") + cmake_policy(POP) + + if(NOT GENERATED_FILES) + message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}") endif() - endif() - # find generated rpm files and take their names - cmake_policy(PUSH) - # Tell file(GLOB_RECURSE) not to follow directory symlinks - # even if the project does not set this policy to NEW. - cmake_policy(SET CMP0009 NEW) - file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm" - "${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm") - cmake_policy(POP) + unset(expected_filenames_) + unset(filenames_) + if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") + string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" efn_) + list(APPEND expected_filenames_ "${efn_}") + list(APPEND filenames_ "${CPACK_RPM_FILE_NAME}") + endif() - if(NOT GENERATED_FILES) - message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}") - endif() + # check if other files have to be renamed + file(GLOB rename_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.rpm_name") + if(rename_files_) + foreach(f_ IN LISTS rename_files_) + file(READ "${f_}" tmp_) + list(GET tmp_ 0 efn_) + list(APPEND expected_filenames_ "${efn_}") + list(GET tmp_ 1 fn_) + list(APPEND filenames_ "${fn_}") + endforeach() + endif() - if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") - string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" EXPECTED_FILENAME) + if(expected_filenames_) + foreach(F IN LISTS GENERATED_FILES) + unset(matched_) + foreach(expected_ IN LISTS expected_filenames_) + if(F MATCHES ".*/${expected_}") + list(FIND expected_filenames_ "${expected_}" idx_) + list(GET filenames_ ${idx_} filename_) + get_filename_component(FILE_PATH "${F}" DIRECTORY) + file(RENAME "${F}" "${FILE_PATH}/${filename_}") + list(APPEND new_files_list_ "${FILE_PATH}/${filename_}") + set(matched_ "YES") + + break() + endif() + endforeach() - foreach(F IN LISTS GENERATED_FILES) - if(F MATCHES ".*/${EXPECTED_FILENAME}") - get_filename_component(FILE_PATH "${F}" DIRECTORY) - file(RENAME "${F}" "${FILE_PATH}/${CPACK_RPM_FILE_NAME}") - list(APPEND new_files_list_ "${FILE_PATH}/${CPACK_RPM_FILE_NAME}") - else() - list(APPEND new_files_list_ "${F}") - endif() - endforeach() + if(NOT matched_) + list(APPEND new_files_list_ "${F}") + endif() + endforeach() - set(GENERATED_FILES "${new_files_list_}") + set(GENERATED_FILES "${new_files_list_}") + endif() endif() set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE) diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index 2870a11..50be9cb 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -16,6 +16,9 @@ @id_WindowsSDKDesktopARMSupport@ </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup> + @id_PreferredToolArchitecture@ + </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> @id_toolset@ diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index bbeeeed..4ba8537 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1160,7 +1160,7 @@ function(_ep_command_line_to_initial_cache var args force) endif() else() # Assume this is a list to append to the last var - list(APPEND accumulator "${line}") + string(APPEND accumulator ";${line}") endif() endforeach() # Catch the final line of the args diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 184fb05..9bd7a30 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1313,13 +1313,13 @@ string(APPEND _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") + string(APPEND _boost_RELEASE_ABI_TAG "p") + string(APPEND _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") + string(APPEND _boost_RELEASE_ABI_TAG "n") + string(APPEND _boost_DEBUG_ABI_TAG "n") endif() if(Boost_DEBUG) @@ -1390,9 +1390,9 @@ endif() 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}) + list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a) else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) endif() endif() @@ -1418,7 +1418,7 @@ endif() 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) + set(_boost_STATIC_RUNTIME_WORKAROUND TRUE) endif() endif() @@ -1681,13 +1681,11 @@ if(Boost_FOUND) endif() if(EXISTS "${_boost_LIB_DIR}/lib") - set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib) + string(APPEND _boost_LIB_DIR /lib) + elseif(EXISTS "${_boost_LIB_DIR}/stage/lib") + string(APPEND _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() + set(_boost_LIB_DIR "") endif() if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index 39dc171..a61d4a8 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -131,6 +131,7 @@ function(_Ice_FIND) set(ice_versions 3 3.6 + 3.6.3 3.6.2 3.6.1 3.6.0 diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 6beacce..b7f2db5 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -737,9 +737,9 @@ endfunction() # added to the Matlab path. # ``CUSTOM_MATLAB_COMMAND`` # Matlab script command to run as the test. -# IIf this is not set, then the following is run: -# "runtests('matlab_file_name'), exit(max([ans(1,:).Failed])) -# matlab_file_name comes from UNITTEST_FILE without the .m. +# If this is not set, then the following is run: +# ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))`` +# where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension. # ``UNITTEST_PRECOMMAND`` # Matlab script command to be ran before the file # containing the test (eg. GPU device initialisation based on CMake @@ -753,7 +753,7 @@ endfunction() # ``MATLAB_ADDITIONAL_STARTUP_OPTIONS`` # a list of additional option in order # to run Matlab from the command line. -# -nosplash -nodesktop -nodisplay are always added. +# ``-nosplash -nodesktop -nodisplay`` are always added. # ``TEST_ARGS`` # Additional options provided to the add_test command. These # options are added to the default options (eg. "CONFIGURATIONS Release") @@ -763,7 +763,7 @@ endfunction() # ``WORKING_DIRECTORY`` # This will be the working directory for the test. If specified it will # also be the output directory used for the log file of the test run. -# If not specifed the temporary directory ${CMAKE_BINARY_DIR}/Matlab will +# If not specifed the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will # be used as the working directory and the log location. # function(matlab_add_unit_test) @@ -844,7 +844,6 @@ endfunction() # the same folder without any processing, with the same name as the final # mex file, and with extension `.m`. In that case, typing ``help <name>`` # in Matlab prints the documentation contained in this file. -# # ``MODULE`` or ``SHARED`` may be given to specify the type of library to be # created. ``EXECUTABLE`` may be given to create an executable instead of # a library. If no type is given explicitly, the type is ``SHARED``. @@ -1246,8 +1245,8 @@ if(_numbers_of_matlab_roots GREATER 0) endif() -# check if the root changed against the previous defined one, if so -# clear all the cached variables +# check if the root changed wrt. the previous defined one, if so +# clear all the cached variables for being able to reconfigure properly if(DEFINED Matlab_ROOT_DIR_LAST_CACHED) if(NOT Matlab_ROOT_DIR_LAST_CACHED STREQUAL Matlab_ROOT_DIR) @@ -1260,6 +1259,7 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED) Matlab_ENG_LIBRARY Matlab_MAT_LIBRARY Matlab_MEX_EXTENSION + Matlab_SIMULINK_INCLUDE_DIR # internal Matlab_MEXEXTENSIONS_PROG diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 10c07c2..3ffd5a7 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -136,9 +136,11 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) foreach(FIL ${ARGN}) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(FIL_WE ${FIL} NAME_WE) - get_filename_component(FIL_DIR ${FIL} DIRECTORY) - if(FIL_DIR) - set(FIL_WE "${FIL_DIR}/${FIL_WE}") + if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH) + get_filename_component(FIL_DIR ${FIL} DIRECTORY) + if(FIL_DIR) + set(FIL_WE "${FIL_DIR}/${FIL_WE}") + endif() endif() list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") @@ -197,9 +199,11 @@ function(PROTOBUF_GENERATE_PYTHON SRCS) foreach(FIL ${ARGN}) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(FIL_WE ${FIL} NAME_WE) - get_filename_component(FIL_DIR ${FIL} DIRECTORY) - if(FIL_DIR) - set(FIL_WE "${FIL_DIR}/${FIL_WE}") + if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH) + get_filename_component(FIL_DIR ${FIL} DIRECTORY) + if(FIL_DIR) + set(FIL_WE "${FIL_DIR}/${FIL_WE}") + endif() endif() list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py") @@ -260,7 +264,7 @@ function(_protobuf_find_libraries name filename) mark_as_advanced(${name}_LIBRARY_RELEASE) find_library(${name}_LIBRARY_DEBUG - NAMES ${filename} + NAMES ${filename}d ${filename} PATHS ${Protobuf_SRC_ROOT_FOLDER}/vsprojects/${_PROTOBUF_ARCH_DIR}Debug) mark_as_advanced(${name}_LIBRARY_DEBUG) diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index c0cdd98..4e4411f 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -122,11 +122,10 @@ if(NOT APPLE) find_package(Threads) endif() -# MinGW needs an additional library, mwindows -# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows -# (Actually on second look, I think it only needs one of the m* libraries.) +# MinGW needs an additional link flag, -mwindows +# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -mwindows if(MINGW) - set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") + set(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "link flags for MinGW") endif() if(SDL_LIBRARY_TEMP) diff --git a/Modules/Platform/Android/ndk-stl-c++.cmake b/Modules/Platform/Android/ndk-stl-c++.cmake index 14748a1..b27015d 100644 --- a/Modules/Platform/Android/ndk-stl-c++.cmake +++ b/Modules/Platform/Android/ndk-stl-c++.cmake @@ -3,7 +3,15 @@ set(_ANDROID_STL_RTTI 1) set(_ANDROID_STL_EXCEPTIONS 1) macro(__android_stl_cxx lang filename) # Add the include directory. - __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" 1) + if(EXISTS "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include/cstddef") + # r12 and below + __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include" 1) + __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++abi/libcxxabi/include" 1) + else() + # r13 and above + __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/include" 1) + __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++abi/include" 1) + endif() # Add a secondary include directory if it exists. __android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/android/support/include" 0) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index bb085ac..c09bac4 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -105,8 +105,6 @@ if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5") set(CMAKE_LINK_DEPENDENT_LIBRARY_FILES 1) endif() -set(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w) -set(CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w) set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") set(CMAKE_CXX_CREATE_SHARED_LIBRARY diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ec49481..048667a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -300,6 +300,8 @@ set(SRCS cmInstallDirectoryGenerator.cxx cmLinkedTree.h cmLinkItem.h + cmLinkLineComputer.cxx + cmLinkLineComputer.h cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c @@ -318,6 +320,8 @@ set(SRCS cmMakefileUtilityTargetGenerator.cxx cmMessenger.cxx cmMessenger.h + cmMSVC60LinkLineComputer.cxx + cmMSVC60LinkLineComputer.h cmOSXBundleGenerator.cxx cmOSXBundleGenerator.h cmOutputConverter.cxx @@ -384,6 +388,8 @@ set(SRCS cm_sha2.c cm_utf8.h cm_utf8.c + cm_codecvt.hxx + cm_codecvt.cxx ) set(COMMAND_INCLUDES "#include \"cmTargetPropCommandBase.cxx\"\n") @@ -543,6 +549,8 @@ set(SRCS ${SRCS} cmNinjaNormalTargetGenerator.h cmNinjaUtilityTargetGenerator.cxx cmNinjaUtilityTargetGenerator.h + cmNinjaLinkLineComputer.cxx + cmNinjaLinkLineComputer.h ) # Temporary variable for tools targets diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 51a0fff..3640ea8 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) -set(CMake_VERSION_MINOR 6) -set(CMake_VERSION_PATCH 20161003) +set(CMake_VERSION_MINOR 7) +set(CMake_VERSION_PATCH 20161017) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 9232ffc..db20998 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -32,16 +32,6 @@ class cmMakefile; cmCPackLog_msg.str().c_str()); \ } while (0) -#ifdef cerr -#undef cerr -#endif -#define cerr no_cerr_use_cmCPack_Log - -#ifdef cout -#undef cout -#endif -#define cout no_cout_use_cmCPack_Log - /** \class cmCPackGenerator * \brief A superclass of all CPack Generators * diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index be429fe..317f613 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -15,8 +15,6 @@ cmCPackLog::cmCPackLog() this->NewLine = true; this->LastTag = cmCPackLog::NOTAG; -#undef cerr -#undef cout this->DefaultOutput = &std::cout; this->DefaultError = &std::cerr; diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h index 0831843..370879d 100644 --- a/Source/CPack/cmCPackLog.h +++ b/Source/CPack/cmCPackLog.h @@ -19,16 +19,6 @@ (ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str()); \ } while (0) -#ifdef cerr -#undef cerr -#endif -#define cerr no_cerr_use_cmCPack_Log - -#ifdef cout -#undef cout -#endif -#define cout no_cout_use_cmCPack_Log - /** \class cmCPackLog * \brief A container for CPack generators * diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index bd55206..9817327 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -105,39 +105,224 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) packageFileNames.clear(); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); - // The default behavior is to have one package by component group - // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. - if (!ignoreGroup) { - std::map<std::string, cmCPackComponentGroup>::iterator compGIt; - for (compGIt = this->ComponentGroups.begin(); - compGIt != this->ComponentGroups.end(); ++compGIt) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " - << compGIt->first << std::endl); - retval &= PackageOnePack(initialTopLevel, compGIt->first); + const char* mainComponent = this->GetOption("CPACK_RPM_MAIN_COMPONENT"); + + if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE") && + !this->IsOn("CPACK_RPM_DEBUGINFO_PACKAGE")) { + // check if we need to set CPACK_RPM_DEBUGINFO_PACKAGE because non of + // the components is setting per component debuginfo package variable + bool shouldSet = true; + + if (ignoreGroup) { + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) { + std::string component(compIt->first); + std::transform(component.begin(), component.end(), component.begin(), + ::toupper); + + if (this->IsOn("CPACK_RPM_" + compIt->first + "_DEBUGINFO_PACKAGE") || + this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { + shouldSet = false; + break; + } + } + } else { + std::map<std::string, cmCPackComponentGroup>::iterator compGIt; + for (compGIt = this->ComponentGroups.begin(); + compGIt != this->ComponentGroups.end(); ++compGIt) { + std::string component(compGIt->first); + std::transform(component.begin(), component.end(), component.begin(), + ::toupper); + + if (this->IsOn("CPACK_RPM_" + compGIt->first + "_DEBUGINFO_PACKAGE") || + this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { + shouldSet = false; + break; + } + } + + if (shouldSet) { + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt = this->Components.begin(); + compIt != this->Components.end(); ++compIt) { + // Does the component belong to a group? + if (compIt->second.Group == CM_NULLPTR) { + std::string component(compIt->first); + std::transform(component.begin(), component.end(), + component.begin(), ::toupper); + + if (this->IsOn("CPACK_RPM_" + compIt->first + + "_DEBUGINFO_PACKAGE") || + this->IsOn("CPACK_RPM_" + component + "_DEBUGINFO_PACKAGE")) { + shouldSet = false; + break; + } + } + } + } + } + + if (shouldSet) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Setting " + << "CPACK_RPM_DEBUGINFO_PACKAGE because " + << "CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is set but " + << " none of the " + << "CPACK_RPM_<component>_DEBUGINFO_PACKAGE variables " + << "are set." << std::endl); + this->SetOption("CPACK_RPM_DEBUGINFO_PACKAGE", "ON"); } - // Handle Orphan components (components not belonging to any groups) - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - // Does the component belong to a group? - if (compIt->second.Group == CM_NULLPTR) { - cmCPackLogger( - cmCPackLog::LOG_VERBOSE, "Component <" - << compIt->second.Name - << "> does not belong to any group, package it separately." - << std::endl); + } + + if (mainComponent) { + if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE")) { + this->SetOption("GENERATE_SPEC_PARTS", "ON"); + } + + std::string mainComponentUpper(mainComponent); + std::transform(mainComponentUpper.begin(), mainComponentUpper.end(), + mainComponentUpper.begin(), ::toupper); + + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreGroup) { + std::map<std::string, cmCPackComponentGroup>::iterator mainCompGIt = + this->ComponentGroups.end(); + + std::map<std::string, cmCPackComponentGroup>::iterator compGIt; + for (compGIt = this->ComponentGroups.begin(); + compGIt != this->ComponentGroups.end(); ++compGIt) { + std::string component(compGIt->first); + std::transform(component.begin(), component.end(), component.begin(), + ::toupper); + + if (mainComponentUpper == component) { + // main component will be handled last + mainCompGIt = compGIt; + continue; + } + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " + << compGIt->first << std::endl); + retval &= PackageOnePack(initialTopLevel, compGIt->first); + } + // Handle Orphan components (components not belonging to any groups) + std::map<std::string, cmCPackComponent>::iterator mainCompIt = + this->Components.end(); + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) { + // Does the component belong to a group? + if (compIt->second.Group == CM_NULLPTR) { + std::string component(compIt->first); + std::transform(component.begin(), component.end(), component.begin(), + ::toupper); + + if (mainComponentUpper == component) { + // main component will be handled last + mainCompIt = compIt; + continue; + } + + cmCPackLogger( + cmCPackLog::LOG_VERBOSE, "Component <" + << compIt->second.Name + << "> does not belong to any group, package it separately." + << std::endl); + retval &= PackageOnePack(initialTopLevel, compIt->first); + } + } + + if (retval) { + this->SetOption("GENERATE_SPEC_PARTS", "OFF"); + + if (mainCompGIt != this->ComponentGroups.end()) { + retval &= PackageOnePack(initialTopLevel, mainCompGIt->first); + } else if (mainCompIt != this->Components.end()) { + retval &= PackageOnePack(initialTopLevel, mainCompIt->first); + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set" + << " to non existing component.\n"); + retval = 0; + } + } + } + // CPACK_COMPONENTS_IGNORE_GROUPS is set + // We build 1 package per component + else { + std::map<std::string, cmCPackComponent>::iterator mainCompIt = + this->Components.end(); + + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) { + std::string component(compIt->first); + std::transform(component.begin(), component.end(), component.begin(), + ::toupper); + + if (mainComponentUpper == component) { + // main component will be handled last + mainCompIt = compIt; + continue; + } + retval &= PackageOnePack(initialTopLevel, compIt->first); } + + if (retval) { + this->SetOption("GENERATE_SPEC_PARTS", "OFF"); + + if (mainCompIt != this->Components.end()) { + retval &= PackageOnePack(initialTopLevel, mainCompIt->first); + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set" + << " to non existing component.\n"); + retval = 0; + } + } } - } - // CPACK_COMPONENTS_IGNORE_GROUPS is set - // We build 1 package per component - else { - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - retval &= PackageOnePack(initialTopLevel, compIt->first); + } else if (!this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE") || + this->Components.size() == 1) { + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreGroup) { + std::map<std::string, cmCPackComponentGroup>::iterator compGIt; + for (compGIt = this->ComponentGroups.begin(); + compGIt != this->ComponentGroups.end(); ++compGIt) { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " + << compGIt->first << std::endl); + retval &= PackageOnePack(initialTopLevel, compGIt->first); + } + // Handle Orphan components (components not belonging to any groups) + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) { + // Does the component belong to a group? + if (compIt->second.Group == CM_NULLPTR) { + cmCPackLogger( + cmCPackLog::LOG_VERBOSE, "Component <" + << compIt->second.Name + << "> does not belong to any group, package it separately." + << std::endl); + retval &= PackageOnePack(initialTopLevel, compIt->first); + } + } + } + // CPACK_COMPONENTS_IGNORE_GROUPS is set + // We build 1 package per component + else { + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) { + retval &= PackageOnePack(initialTopLevel, compIt->first); + } } + } else { + cmCPackLogger( + cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT not set but" + << " it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE" + << " being set.\n"); + retval = 0; } if (retval) { @@ -156,6 +341,10 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne( packageFileNames.clear(); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + if (this->IsOn("CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE")) { + this->SetOption("CPACK_RPM_DEBUGINFO_PACKAGE", "ON"); + } + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging all groups in one package..." "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)" diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 5c45b14..a3281ab 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -415,9 +415,7 @@ int main(int argc, char const* const* argv) } doc.SetSection("Generators", v); -#undef cout return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1; -#define cout no_cout_use_cmCPack_Log } if (cmSystemTools::GetErrorOccuredFlag()) { diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index b37db30..0052a16 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -375,11 +375,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml) xml.StartElement("DefectList"); for (cc = 0; cc < this->GlobalResults.size(); cc++) { if (this->GlobalResults[cc]) { -#ifdef cerr -#undef cerr -#endif std::cerr.width(35); -#define cerr no_cerr cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, this->ResultStringsLong[cc] << " - " << this->GlobalResults[cc] << std::endl, diff --git a/Source/QtIFW/cmake.org.html b/Source/QtIFW/cmake.org.html index cf5649d..001d634 100644 --- a/Source/QtIFW/cmake.org.html +++ b/Source/QtIFW/cmake.org.html @@ -1,6 +1,6 @@ <html> <head> -<meta http-equiv="Refresh" content="0; url=http://cmake.org/" /> +<meta http-equiv="Refresh" content="0; url=https://cmake.org/" /> </head> <body> </body> diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 3a08aea..56a469d 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -162,7 +162,14 @@ void CCONV cmAddLinkDirectoryForTarget(void* arg, const char* tgt, const char* d) { cmMakefile* mf = static_cast<cmMakefile*>(arg); - mf->AddLinkDirectoryForTarget(tgt, d); + cmTarget* t = mf->FindLocalNonAliasTarget(tgt); + if (!t) { + cmSystemTools::Error( + "Attempt to add link directories to non-existent target: ", tgt, + " for directory ", d); + return; + } + t->AddLinkDirectory(d); } void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs, @@ -330,6 +337,35 @@ void CCONV cmAddCustomCommandToTarget(void* arg, const char* target, cctype, no_comment, no_working_dir); } +static void addLinkLibrary(cmMakefile* mf, std::string const& target, + std::string const& lib, cmTargetLinkLibraryType llt) +{ + cmTarget* t = mf->FindLocalNonAliasTarget(target); + if (!t) { + std::ostringstream e; + e << "Attempt to add link library \"" << lib << "\" to target \"" << target + << "\" which is not built in this directory."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + + cmTarget* tgt = mf->GetGlobalGenerator()->FindTarget(lib); + if (tgt && (tgt->GetType() != cmState::STATIC_LIBRARY) && + (tgt->GetType() != cmState::SHARED_LIBRARY) && + (tgt->GetType() != cmState::INTERFACE_LIBRARY) && + !tgt->IsExecutableWithExports()) { + std::ostringstream e; + e << "Target \"" << lib << "\" of type " + << cmState::GetTargetTypeName(tgt->GetType()) + << " may not be linked into another target. " + << "One may link only to STATIC or SHARED libraries, or " + << "to executables with the ENABLE_EXPORTS property set."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + } + + t->AddLinkLibrary(*mf, lib, llt); +} + void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt, const char* value, int libtype) { @@ -337,13 +373,13 @@ void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt, switch (libtype) { case CM_LIBRARY_GENERAL: - mf->AddLinkLibraryForTarget(tgt, value, GENERAL_LibraryType); + addLinkLibrary(mf, tgt, value, GENERAL_LibraryType); break; case CM_LIBRARY_DEBUG: - mf->AddLinkLibraryForTarget(tgt, value, DEBUG_LibraryType); + addLinkLibrary(mf, tgt, value, DEBUG_LibraryType); break; case CM_LIBRARY_OPTIMIZED: - mf->AddLinkLibraryForTarget(tgt, value, OPTIMIZED_LibraryType); + addLinkLibrary(mf, tgt, value, OPTIMIZED_LibraryType); break; } } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1824d94..7dc9e33 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2651,13 +2651,6 @@ static const char* cmCTestStringLogType[] = { "DEBUG", "ERROR_MESSAGE", CM_NULLPTR }; -#ifdef cerr -#undef cerr -#endif -#ifdef cout -#undef cout -#endif - #define cmCTestLogOutputFileLine(stream) \ if (this->ShowLineNumbers) { \ (stream) << std::endl << file << ":" << line << " "; \ diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 6887a31..b995fa1 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -12,6 +12,7 @@ #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" #include "cmGlobalCommonGenerator.h" +#include "cmLinkLineComputer.h" #include "cmLocalCommonGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -59,7 +60,8 @@ void cmCommonTargetGenerator::AddFeatureFlags(std::string& flags, } } -void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) +void cmCommonTargetGenerator::AddModuleDefinitionFlag( + cmLinkLineComputer* linkLineComputer, std::string& flags) { if (!this->ModuleDefinitionFile) { return; @@ -75,8 +77,10 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) // Append the flag and value. Use ConvertToLinkReference to help // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; - flag += (this->LocalGenerator->ConvertToLinkReference( - this->ModuleDefinitionFile->GetFullPath())); + flag += this->LocalGenerator->ConvertToOutputFormat( + linkLineComputer->ConvertToLinkReference( + this->ModuleDefinitionFile->GetFullPath()), + cmOutputConverter::SHELL); this->LocalGenerator->AppendFlags(flags, flag); } diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 707b81e..fe27038 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -16,6 +16,7 @@ class cmGlobalCommonGenerator; class cmLocalCommonGenerator; class cmMakefile; class cmSourceFile; +class cmLinkLineComputer; /** \class cmCommonTargetGenerator * \brief Common infrastructure for Makefile and Ninja per-target generators @@ -37,7 +38,8 @@ protected: bool GetFeatureAsBool(const std::string& feature); // Helper to add flag for windows .def file. - void AddModuleDefinitionFlag(std::string& flags); + void AddModuleDefinitionFlag(cmLinkLineComputer* linkLineComputer, + std::string& flags); cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index dc8236d..0807ef8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1710,6 +1710,12 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } + if (use_build_rpath) { + // Add directories explicitly specified by user + if (const char* build_rpath = this->Target->GetProperty("BUILD_RPATH")) { + cmCLI_ExpandListUnique(build_rpath, runtimeDirs, emitted); + } + } if (use_build_rpath || use_link_rpath) { std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); const char* stagePath = diff --git a/Source/cmConvertMSBuildXMLToJSON.py b/Source/cmConvertMSBuildXMLToJSON.py new file mode 100644 index 0000000..93ab8a8 --- /dev/null +++ b/Source/cmConvertMSBuildXMLToJSON.py @@ -0,0 +1,453 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +import argparse +import codecs +import copy +import logging +import json +import os + +from collections import OrderedDict +from xml.dom.minidom import parse, parseString, Element + + +class VSFlags: + """Flags corresponding to cmIDEFlagTable.""" + UserValue = "UserValue" # (1 << 0) + UserIgnored = "UserIgnored" # (1 << 1) + UserRequired = "UserRequired" # (1 << 2) + Continue = "Continue" #(1 << 3) + SemicolonAppendable = "SemicolonAppendable" # (1 << 4) + UserFollowing = "UserFollowing" # (1 << 5) + CaseInsensitive = "CaseInsensitive" # (1 << 6) + UserValueIgnored = [UserValue, UserIgnored] + UserValueRequired = [UserValue, UserRequired] + + +def vsflags(*args): + """Combines the flags.""" + values = [] + + for arg in args: + __append_list(values, arg) + + return values + + +def read_msbuild_xml(path, values={}): + """Reads the MS Build XML file at the path and returns its contents. + + Keyword arguments: + values -- The map to append the contents to (default {}) + """ + + # Attempt to read the file contents + try: + document = parse(path) + except Exception as e: + logging.exception('Could not read MS Build XML file at %s', path) + return values + + # Convert the XML to JSON format + logging.info('Processing MS Build XML file at %s', path) + + # Get the rule node + rule = document.getElementsByTagName('Rule')[0] + + rule_name = rule.attributes['Name'].value + + logging.info('Found rules for %s', rule_name) + + # Proprocess Argument values + __preprocess_arguments(rule) + + # Get all the values + converted_values = [] + __convert(rule, 'EnumProperty', converted_values, __convert_enum) + __convert(rule, 'BoolProperty', converted_values, __convert_bool) + __convert(rule, 'StringListProperty', converted_values, + __convert_string_list) + __convert(rule, 'StringProperty', converted_values, __convert_string) + __convert(rule, 'IntProperty', converted_values, __convert_string) + + values[rule_name] = converted_values + + return values + + +def read_msbuild_json(path, values=[]): + """Reads the MS Build JSON file at the path and returns its contents. + + Keyword arguments: + values -- The list to append the contents to (default []) + """ + if not os.path.exists(path): + logging.info('Could not find MS Build JSON file at %s', path) + return values + + try: + values.extend(__read_json_file(path)) + except Exception as e: + logging.exception('Could not read MS Build JSON file at %s', path) + return values + + logging.info('Processing MS Build JSON file at %s', path) + + return values + + +def main(): + """Script entrypoint.""" + # Parse the arguments + parser = argparse.ArgumentParser( + description='Convert MSBuild XML to JSON format') + + parser.add_argument( + '-t', '--toolchain', help='The name of the toolchain', required=True) + parser.add_argument( + '-o', '--output', help='The output directory', default='') + parser.add_argument( + '-r', + '--overwrite', + help='Whether previously output should be overwritten', + dest='overwrite', + action='store_true') + parser.set_defaults(overwrite=False) + parser.add_argument( + '-d', + '--debug', + help="Debug tool output", + action="store_const", + dest="loglevel", + const=logging.DEBUG, + default=logging.WARNING) + parser.add_argument( + '-v', + '--verbose', + help="Verbose output", + action="store_const", + dest="loglevel", + const=logging.INFO) + parser.add_argument('input', help='The input files', nargs='+') + + args = parser.parse_args() + + toolchain = args.toolchain + + logging.basicConfig(level=args.loglevel) + logging.info('Creating %s toolchain files', toolchain) + + values = {} + + # Iterate through the inputs + for input in args.input: + input = __get_path(input) + + read_msbuild_xml(input, values) + + # Determine if the output directory needs to be created + output_dir = __get_path(args.output) + + if not os.path.exists(output_dir): + os.mkdir(output_dir) + logging.info('Created output directory %s', output_dir) + + for key, value in values.items(): + output_path = __output_path(toolchain, key, output_dir) + + if os.path.exists(output_path) and not args.overwrite: + logging.info('Comparing previous output to current') + + __merge_json_values(value, read_msbuild_json(output_path)) + else: + logging.info('Original output will be overwritten') + + logging.info('Writing MS Build JSON file at %s', output_path) + + __write_json_file(output_path, value) + + +########################################################################################### +# private joining functions +def __merge_json_values(current, previous): + """Merges the values between the current and previous run of the script.""" + for value in current: + name = value['name'] + + # Find the previous value + previous_value = __find_and_remove_value(previous, value) + + if previous_value is not None: + flags = value['flags'] + previous_flags = previous_value['flags'] + + if flags != previous_flags: + logging.warning( + 'Flags for %s are different. Using previous value.', name) + + value['flags'] = previous_flags + else: + logging.warning('Value %s is a new value', name) + + for value in previous: + name = value['name'] + logging.warning( + 'Value %s not present in current run. Appending value.', name) + + current.append(value) + + +def __find_and_remove_value(list, compare): + """Finds the value in the list that corresponds with the value of compare.""" + # next throws if there are no matches + try: + found = next(value for value in list + if value['name'] == compare['name'] and value['switch'] == + compare['switch']) + except: + return None + + list.remove(found) + + return found + + +########################################################################################### +# private xml functions +def __convert(root, tag, values, func): + """Converts the tag type found in the root and converts them using the func + and appends them to the values. + """ + elements = root.getElementsByTagName(tag) + + for element in elements: + converted = func(element) + + # Append to the list + __append_list(values, converted) + + +def __convert_enum(node): + """Converts an EnumProperty node to JSON format.""" + name = __get_attribute(node, 'Name') + logging.debug('Found EnumProperty named %s', name) + + converted_values = [] + + for value in node.getElementsByTagName('EnumValue'): + converted = __convert_node(value) + + converted['value'] = converted['name'] + converted['name'] = name + + # Modify flags when there is an argument child + __with_argument(value, converted) + + converted_values.append(converted) + + return converted_values + + +def __convert_bool(node): + """Converts an BoolProperty node to JSON format.""" + converted = __convert_node(node, default_value='true') + + # Check for a switch for reversing the value + reverse_switch = __get_attribute(node, 'ReverseSwitch') + + if reverse_switch: + converted_reverse = copy.deepcopy(converted) + + converted_reverse['switch'] = reverse_switch + converted_reverse['value'] = 'false' + + return [converted_reverse, converted] + + # Modify flags when there is an argument child + __with_argument(node, converted) + + return __check_for_flag(converted) + + +def __convert_string_list(node): + """Converts a StringListProperty node to JSON format.""" + converted = __convert_node(node) + + # Determine flags for the string list + flags = vsflags(VSFlags.UserValue) + + # Check for a separator to determine if it is semicolon appendable + # If not present assume the value should be ; + separator = __get_attribute(node, 'Separator', default_value=';') + + if separator == ';': + flags = vsflags(flags, VSFlags.SemicolonAppendable) + + converted['flags'] = flags + + return __check_for_flag(converted) + + +def __convert_string(node): + """Converts a StringProperty node to JSON format.""" + converted = __convert_node(node, default_flags=vsflags(VSFlags.UserValue)) + + return __check_for_flag(converted) + + +def __convert_node(node, default_value='', default_flags=vsflags()): + """Converts a XML node to a JSON equivalent.""" + name = __get_attribute(node, 'Name') + logging.debug('Found %s named %s', node.tagName, name) + + converted = {} + converted['name'] = name + converted['switch'] = __get_attribute(node, 'Switch') + converted['comment'] = __get_attribute(node, 'DisplayName') + converted['value'] = default_value + + # Check for the Flags attribute in case it was created during preprocessing + flags = __get_attribute(node, 'Flags') + + if flags: + flags = flags.split(',') + else: + flags = default_flags + + converted['flags'] = flags + + return converted + + +def __check_for_flag(value): + """Checks whether the value has a switch value. + + If not then returns None as it should not be added. + """ + if value['switch']: + return value + else: + logging.warning('Skipping %s which has no command line switch', + value['name']) + return None + + +def __with_argument(node, value): + """Modifies the flags in value if the node contains an Argument.""" + arguments = node.getElementsByTagName('Argument') + + if arguments: + logging.debug('Found argument within %s', value['name']) + value['flags'] = vsflags(VSFlags.UserValueIgnored, VSFlags.Continue) + + +def __preprocess_arguments(root): + """Preprocesses occurrances of Argument within the root. + + Argument XML values reference other values within the document by name. The + referenced value does not contain a switch. This function will add the + switch associated with the argument. + """ + # Set the flags to require a value + flags = ','.join(vsflags(VSFlags.UserValueRequired)) + + # Search through the arguments + arguments = root.getElementsByTagName('Argument') + + for argument in arguments: + reference = __get_attribute(argument, 'Property') + found = None + + # Look for the argument within the root's children + for child in root.childNodes: + # Ignore Text nodes + if isinstance(child, Element): + name = __get_attribute(child, 'Name') + + if name == reference: + found = child + break + + if found is not None: + logging.info('Found property named %s', reference) + # Get the associated switch + switch = __get_attribute(argument.parentNode, 'Switch') + + # See if there is already a switch associated with the element. + if __get_attribute(found, 'Switch'): + logging.debug('Copying node %s', reference) + clone = found.cloneNode(True) + root.insertBefore(clone, found) + found = clone + + found.setAttribute('Switch', switch) + found.setAttribute('Flags', flags) + else: + logging.warning('Could not find property named %s', reference) + + +def __get_attribute(node, name, default_value=''): + """Retrieves the attribute of the given name from the node. + + If not present then the default_value is used. + """ + if node.hasAttribute(name): + return node.attributes[name].value.strip() + else: + return default_value + + +########################################################################################### +# private path functions +def __get_path(path): + """Gets the path to the file.""" + if not os.path.isabs(path): + path = os.path.join(os.getcwd(), path) + + return os.path.normpath(path) + + +def __output_path(toolchain, rule, output_dir): + """Gets the output path for a file given the toolchain, rule and output_dir""" + filename = '%s_%s.json' % (toolchain, rule) + return os.path.join(output_dir, filename) + + +########################################################################################### +# private JSON file functions +def __read_json_file(path): + """Reads a JSON file at the path.""" + with open(path, 'r') as f: + return json.load(f) + + +def __write_json_file(path, values): + """Writes a JSON file at the path with the values provided.""" + # Sort the keys to ensure ordering + sort_order = ['name', 'switch', 'comment', 'value', 'flags'] + sorted_values = [ + OrderedDict( + sorted( + value.items(), key=lambda value: sort_order.index(value[0]))) + for value in values + ] + + with open(path, 'w') as f: + json.dump(sorted_values, f, indent=2, separators=(',', ': ')) + + +########################################################################################### +# private list helpers +def __append_list(append_to, value): + """Appends the value to the list.""" + if value is not None: + if isinstance(value, list): + append_to.extend(value) + else: + append_to.append(value) + +########################################################################################### +# main entry point +if __name__ == "__main__": + main() diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index c1c8880..aaa9d3a 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -198,16 +198,13 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, stamp += ".mod.stamp"; fcStream << "\n"; fcStream << " \"" - << this->LocalGenerator->ConvertToRelativePath(currentBinDir, - mod_lower) + << this->MaybeConvertToRelativePath(currentBinDir, mod_lower) << "\"\n"; fcStream << " \"" - << this->LocalGenerator->ConvertToRelativePath(currentBinDir, - mod_upper) + << this->MaybeConvertToRelativePath(currentBinDir, mod_upper) << "\"\n"; fcStream << " \"" - << this->LocalGenerator->ConvertToRelativePath(currentBinDir, - stamp) + << this->MaybeConvertToRelativePath(currentBinDir, stamp) << "\"\n"; } fcStream << " )\n"; @@ -323,17 +320,16 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, // Write the include dependencies to the output stream. std::string binDir = this->LocalGenerator->GetBinaryDirectory(); - std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj); + std::string obj_i = this->MaybeConvertToRelativePath(binDir, obj); std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str()); internalDepends << obj_i << std::endl; internalDepends << " " << src << std::endl; for (std::set<std::string>::const_iterator i = info.Includes.begin(); i != info.Includes.end(); ++i) { - makeDepends - << obj_m << ": " - << cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str()) - << std::endl; + makeDepends << obj_m << ": " + << cmSystemTools::ConvertToOutputPath( + this->MaybeConvertToRelativePath(binDir, *i).c_str()) + << std::endl; internalDepends << " " << *i << std::endl; } makeDepends << std::endl; @@ -359,7 +355,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, proxy += *i; proxy += ".mod.proxy"; proxy = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str()); + this->MaybeConvertToRelativePath(binDir, proxy).c_str()); // since we require some things add them to our list of requirements makeDepends << obj_m << ".requires: " << proxy << std::endl; @@ -375,8 +371,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, if (!required->second.empty()) { // This module is known. Depend on its timestamp file. std::string stampFile = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, required->second) - .c_str()); + this->MaybeConvertToRelativePath(binDir, required->second).c_str()); makeDepends << obj_m << ": " << stampFile << "\n"; } else { // This module is not known to CMake. Try to locate it where @@ -384,7 +379,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, std::string module; if (this->FindModule(*i, module)) { module = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, module).c_str()); + this->MaybeConvertToRelativePath(binDir, module).c_str()); makeDepends << obj_m << ": " << module << "\n"; } } @@ -398,7 +393,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, proxy += *i; proxy += ".mod.proxy"; proxy = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, proxy).c_str()); + this->MaybeConvertToRelativePath(binDir, proxy).c_str()); makeDepends << proxy << ": " << obj_m << ".provides" << std::endl; } @@ -420,14 +415,14 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, modFile += "/"; modFile += *i; modFile = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath(binDir, modFile), + this->MaybeConvertToRelativePath(binDir, modFile), cmOutputConverter::SHELL); std::string stampFile = stamp_dir; stampFile += "/"; stampFile += m; stampFile += ".mod.stamp"; stampFile = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath(binDir, stampFile), + this->MaybeConvertToRelativePath(binDir, stampFile), cmOutputConverter::SHELL); makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile << " " << stampFile; @@ -448,7 +443,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj, std::string driver = this->TargetDirectory; driver += "/build"; driver = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->ConvertToRelativePath(binDir, driver).c_str()); + this->MaybeConvertToRelativePath(binDir, driver).c_str()); makeDepends << driver << ": " << obj_m << ".provides.build\n"; } @@ -708,3 +703,13 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, // content. return cmFortranStreamsDiffer(finModFile, finStampFile); } + +std::string cmDependsFortran::MaybeConvertToRelativePath( + std::string const& base, std::string const& path) +{ + if (!cmOutputConverter::ContainedInDirectory( + base, path, this->LocalGenerator->GetStateSnapshot().GetDirectory())) { + return path; + } + return cmOutputConverter::ForceToRelativePath(base, path); +} diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index 8d347f4..90b82d4 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -78,6 +78,9 @@ protected: private: cmDependsFortran(cmDependsFortran const&); // Purposely not implemented. void operator=(cmDependsFortran const&); // Purposely not implemented. + + std::string MaybeConvertToRelativePath(std::string const& base, + std::string const& path); }; #endif diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 2d86674..0655da9 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -132,18 +132,13 @@ public: // Forward to the per-class implementation. virtual unsigned int GetNumberOfSections() const = 0; - virtual unsigned int GetDynamicEntryCount() = 0; virtual unsigned long GetDynamicEntryPosition(int j) = 0; + virtual cmELF::DynamicEntryList GetDynamicEntries() = 0; + virtual std::vector<char> EncodeDynamicEntries( + const cmELF::DynamicEntryList&) = 0; virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0; virtual void PrintInfo(std::ostream& os) const = 0; - bool ReadBytes(unsigned long pos, unsigned long size, char* buf) - { - this->Stream.seekg(pos); - this->Stream.read(buf, size); - return !this->Stream.fail(); - } - // Lookup the SONAME in the DYNAMIC section. StringEntry const* GetSOName() { @@ -246,10 +241,13 @@ public: return static_cast<unsigned int>(this->ELFHeader.e_shnum); } - // Get the file position and size of a dynamic section entry. - unsigned int GetDynamicEntryCount() CM_OVERRIDE; + // Get the file position of a dynamic section entry. unsigned long GetDynamicEntryPosition(int j) CM_OVERRIDE; + cmELF::DynamicEntryList GetDynamicEntries() CM_OVERRIDE; + std::vector<char> EncodeDynamicEntries(const cmELF::DynamicEntryList&) + CM_OVERRIDE; + // Lookup a string from the dynamic section with the given tag. StringEntry const* GetDynamicSectionString(unsigned int tag) CM_OVERRIDE; @@ -289,6 +287,10 @@ public: } private: + // ByteSwap(ELF_Dyn) assumes d_val and d_ptr are the same size + typedef char dyn_size_assert + [sizeof(ELF_Dyn().d_un.d_val) == sizeof(ELF_Dyn().d_un.d_ptr) ? 1 : -1]; + void ByteSwap(ELF_Ehdr& elf_header) { cmELFByteSwap(elf_header.e_type); @@ -323,121 +325,7 @@ private: void ByteSwap(ELF_Dyn& dyn) { cmELFByteSwap(dyn.d_tag); - switch (dyn.d_tag) { - case DT_NULL: /* dyn.d_un ignored */ - break; - case DT_NEEDED: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_PLTRELSZ: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_PLTGOT: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_HASH: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_STRTAB: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_SYMTAB: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_RELA: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_RELASZ: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_RELAENT: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_STRSZ: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_SYMENT: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_INIT: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_FINI: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_SONAME: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_RPATH: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_SYMBOLIC: /* dyn.d_un ignored */ - break; - case DT_REL: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_RELSZ: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_RELENT: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_PLTREL: - cmELFByteSwap(dyn.d_un.d_val); - break; - case DT_DEBUG: - cmELFByteSwap(dyn.d_un.d_ptr); - break; - case DT_TEXTREL: /* dyn.d_un ignored */ - break; - case DT_JMPREL: - cmELFByteSwap(dyn.d_un.d_ptr); - break; -#ifdef T_BIND_NOW - case T_BIND_NOW: /* dyn.d_un ignored */ - break; -#endif -#ifdef DT_INIT_ARRAY - case DT_INIT_ARRAY: - cmELFByteSwap(dyn.d_un.d_ptr); - break; -#endif -#ifdef DT_FINI_ARRAY - case DT_FINI_ARRAY: - cmELFByteSwap(dyn.d_un.d_ptr); - break; -#endif -#ifdef DT_INIT_ARRAYSZ - case DT_INIT_ARRAYSZ: - cmELFByteSwap(dyn.d_un.d_val); - break; -#endif -#ifdef DT_FINI_ARRAYSZ - case DT_FINI_ARRAYSZ: - cmELFByteSwap(dyn.d_un.d_val); - break; -#endif -#ifdef DT_RUNPATH - case DT_RUNPATH: - cmELFByteSwap(dyn.d_un.d_val); - break; -#endif -#ifdef DT_FLAGS - case DT_FLAGS: - cmELFByteSwap(dyn.d_un.d_val); - break; -#endif -#ifdef DT_PREINIT_ARRAY - case DT_PREINIT_ARRAY: - cmELFByteSwap(dyn.d_un.d_ptr); - break; -#endif -#ifdef DT_PREINIT_ARRAYSZ - case DT_PREINIT_ARRAYSZ: - cmELFByteSwap(dyn.d_un.d_val); - break; -#endif - } + cmELFByteSwap(dyn.d_un.d_val); } bool FileTypeValid(ELF_Half et) @@ -636,30 +524,64 @@ bool cmELFInternalImpl<Types>::LoadDynamicSection() } template <class Types> -unsigned int cmELFInternalImpl<Types>::GetDynamicEntryCount() +unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j) { if (!this->LoadDynamicSection()) { return 0; } - for (unsigned int i = 0; i < this->DynamicSectionEntries.size(); ++i) { - if (this->DynamicSectionEntries[i].d_tag == DT_NULL) { - return i; - } + if (j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size())) { + return 0; } - return static_cast<unsigned int>(this->DynamicSectionEntries.size()); + ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; + return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j); } template <class Types> -unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j) +cmELF::DynamicEntryList cmELFInternalImpl<Types>::GetDynamicEntries() { + cmELF::DynamicEntryList result; + + // Ensure entries have been read from file if (!this->LoadDynamicSection()) { - return 0; + return result; } - if (j < 0 || j >= static_cast<int>(this->DynamicSectionEntries.size())) { - return 0; + + // Copy into public array + result.reserve(this->DynamicSectionEntries.size()); + for (typename std::vector<ELF_Dyn>::iterator di = + this->DynamicSectionEntries.begin(); + di != this->DynamicSectionEntries.end(); ++di) { + ELF_Dyn& dyn = *di; + result.push_back( + std::pair<unsigned long, unsigned long>(dyn.d_tag, dyn.d_un.d_val)); } - ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex]; - return static_cast<unsigned long>(sec.sh_offset + sec.sh_entsize * j); + + return result; +} + +template <class Types> +std::vector<char> cmELFInternalImpl<Types>::EncodeDynamicEntries( + const cmELF::DynamicEntryList& entries) +{ + std::vector<char> result; + result.reserve(sizeof(ELF_Dyn) * entries.size()); + + for (cmELF::DynamicEntryList::const_iterator it = entries.begin(); + it != entries.end(); it++) { + // Store the entry in an ELF_Dyn, byteswap it, then serialize to chars + ELF_Dyn dyn; + dyn.d_tag = static_cast<tagtype>(it->first); + dyn.d_un.d_val = static_cast<tagtype>(it->second); + + if (this->NeedSwap) { + ByteSwap(dyn); + } + + char* pdyn = reinterpret_cast<char*>(&dyn); + result.insert(result.end(), pdyn, pdyn + sizeof(ELF_Dyn)); + } + + return result; } template <class Types> @@ -752,6 +674,15 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString( //============================================================================ // External class implementation. +const long cmELF::TagRPath = DT_RPATH; +const long cmELF::TagRunPath = DT_RUNPATH; + +#ifdef DT_MIPS_RLD_MAP_REL +const long cmELF::TagMipsRldMapRel = DT_MIPS_RLD_MAP_REL; +#else +const long cmELF::TagMipsRldMapRel = 0; +#endif + cmELF::cmELF(const char* fname) : Internal(CM_NULLPTR) { @@ -839,28 +770,31 @@ unsigned int cmELF::GetNumberOfSections() const return 0; } -unsigned int cmELF::GetDynamicEntryCount() const +unsigned long cmELF::GetDynamicEntryPosition(int index) const { if (this->Valid()) { - return this->Internal->GetDynamicEntryCount(); + return this->Internal->GetDynamicEntryPosition(index); } return 0; } -unsigned long cmELF::GetDynamicEntryPosition(int index) const +cmELF::DynamicEntryList cmELF::GetDynamicEntries() const { if (this->Valid()) { - return this->Internal->GetDynamicEntryPosition(index); + return this->Internal->GetDynamicEntries(); } - return 0; + + return cmELF::DynamicEntryList(); } -bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const +std::vector<char> cmELF::EncodeDynamicEntries( + const cmELF::DynamicEntryList& dentries) const { if (this->Valid()) { - return this->Internal->ReadBytes(pos, size, buf); + return this->Internal->EncodeDynamicEntries(dentries); } - return false; + + return std::vector<char>(); } bool cmELF::GetSOName(std::string& soname) diff --git a/Source/cmELF.h b/Source/cmELF.h index 7e7c1d6..763a240 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -7,6 +7,8 @@ #include <iosfwd> #include <string> +#include <utility> +#include <vector> #if !defined(CMAKE_USE_ELF_PARSER) #error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled." @@ -61,22 +63,27 @@ public: int IndexInSection; }; + /** Represent entire dynamic section header */ + typedef std::vector<std::pair<long, unsigned long> > DynamicEntryList; + /** Get the type of the file opened. */ FileType GetFileType() const; /** Get the number of ELF sections present. */ unsigned int GetNumberOfSections() const; - /** Get the number of DYNAMIC section entries before the first - DT_NULL. Returns zero on error. */ - unsigned int GetDynamicEntryCount() const; - /** Get the position of a DYNAMIC section header entry. Returns zero on error. */ unsigned long GetDynamicEntryPosition(int index) const; - /** Read bytes from the file. */ - bool ReadBytes(unsigned long pos, unsigned long size, char* buf) const; + /** Get a copy of all the DYNAMIC section header entries. + Returns an empty vector on error */ + DynamicEntryList GetDynamicEntries() const; + + /** Encodes a DYNAMIC section header entry list into a char vector according + to the type of ELF file this is */ + std::vector<char> EncodeDynamicEntries( + const DynamicEntryList& entries) const; /** Get the SONAME field if any. */ bool GetSOName(std::string& soname); @@ -91,6 +98,10 @@ public: /** Print human-readable information about the ELF file. */ void PrintInfo(std::ostream& os) const; + /** Interesting dynamic tags. + If the tag is 0, it does not exist in the host ELF implementation */ + static const long TagRPath, TagRunPath, TagMipsRldMapRel; + private: friend class cmELFInternal; bool Valid() const; diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index bb02311..f5e6628 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -9,6 +9,8 @@ #include "cmMakefile.h" #include "cmTargetExport.h" +#include <algorithm> + cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator() { this->LG = CM_NULLPTR; @@ -164,6 +166,16 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( } } } + + // Tell the NDK build system if prebuilt static libraries use C++. + if (target->GetType() == cmState::STATIC_LIBRARY) { + cmLinkImplementation const* li = target->GetLinkImplementation(config); + if (std::find(li->Languages.begin(), li->Languages.end(), "CXX") != + li->Languages.end()) { + os << "LOCAL_HAS_CPP := true\n"; + } + } + switch (target->GetType()) { case cmState::SHARED_LIBRARY: case cmState::MODULE_LIBRARY: diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 629c5b6..360c852 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -60,7 +60,6 @@ void cmExtraCodeLiteGenerator::Generate() // loop projects and locate the root project. // and extract the information for creating the worspace // root makefile - const cmMakefile* rmf = CM_NULLPTR; for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = projectMap.begin(); it != projectMap.end(); ++it) { @@ -75,7 +74,6 @@ void cmExtraCodeLiteGenerator::Generate() workspaceFileName = workspaceOutputDir + "/"; workspaceFileName += workspaceProjectName + ".workspace"; this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory(); - rmf = it->second[0]->GetMakefile(); ; break; } @@ -89,7 +87,7 @@ void cmExtraCodeLiteGenerator::Generate() xml.Attribute("Name", workspaceProjectName); bool const targetsAreProjects = - rmf && rmf->IsOn("CMAKE_CODELITE_USE_TARGETS"); + this->GlobalGenerator->GlobalSettingIsOn("CMAKE_CODELITE_USE_TARGETS"); std::vector<std::string> ProjectNames; if (targetsAreProjects) { diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 5ae969b..41f82a2 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -55,10 +55,14 @@ cmExtraSublimeTextGenerator::GetFactory() cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator() : cmExternalMakefileProjectGenerator() { + this->ExcludeBuildFolder = false; } void cmExtraSublimeTextGenerator::Generate() { + this->ExcludeBuildFolder = this->GlobalGenerator->GlobalSettingIsOn( + "CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE"); + // for each sub project in the project create a sublime text 2 project for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); @@ -84,6 +88,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile( const std::vector<cmLocalGenerator*>& lgs, const std::string& filename) { const cmMakefile* mf = lgs[0]->GetMakefile(); + cmGeneratedFileStream fout(filename.c_str()); if (!fout) { return; @@ -102,8 +107,10 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile( if ((!outputRelativeToSourceRoot.empty()) && ((outputRelativeToSourceRoot.length() < 3) || (outputRelativeToSourceRoot.substr(0, 3) != "../"))) { - fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" - << outputRelativeToSourceRoot << "\"]"; + if (this->ExcludeBuildFolder) { + fout << ",\n\t\t\t\"folder_exclude_patterns\": [\"" + << outputRelativeToSourceRoot << "\"]"; + } } } else { fout << "\t{\n\t\t\t\"path\": \"./\""; diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index c917992..0c58221 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -64,6 +64,8 @@ private: std::string ComputeDefines(cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt); + + bool ExcludeBuildFolder; }; #endif diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index b97590b..41ec8b4 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -12,7 +12,7 @@ namespace { void on_directory_change(uv_fs_event_t* handle, const char* filename, int events, int status); -void on_handle_close(uv_handle_t* handle); +void on_fs_close(uv_handle_t* handle); } // namespace class cmIBaseWatcher @@ -177,7 +177,7 @@ public: { if (this->Handle) { uv_fs_event_stop(this->Handle); - uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_handle_close); + uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_fs_close); this->Handle = nullptr; } cmVirtualDirectoryWatcher::StopWatching(); @@ -292,9 +292,9 @@ void on_directory_change(uv_fs_event_t* handle, const char* filename, watcher->Trigger(pathSegment, events, status); } -void on_handle_close(uv_handle_t* handle) +void on_fs_close(uv_handle_t* handle) { - delete (reinterpret_cast<uv_fs_event_t*>(handle)); + delete reinterpret_cast<uv_fs_event_t*>(handle); } } // namespace diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 02717a4..6cdb7f5 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -10,13 +10,21 @@ #include <cm_zlib.h> #endif -cmGeneratedFileStream::cmGeneratedFileStream() +cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding) : cmGeneratedFileStreamBase() , Stream() { +#ifdef CMAKE_BUILD_WITH_CMAKE + if (encoding != codecvt::None) { + imbue(std::locale(getloc(), new codecvt(encoding))); + } +#else + static_cast<void>(encoding); +#endif } -cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet) +cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet, + Encoding encoding) : cmGeneratedFileStreamBase(name) , Stream(TempName.c_str()) { @@ -26,6 +34,13 @@ cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet) this->TempName.c_str()); cmSystemTools::ReportLastSystemError(""); } +#ifdef CMAKE_BUILD_WITH_CMAKE + if (encoding != codecvt::None) { + imbue(std::locale(getloc(), new codecvt(encoding))); + } +#else + static_cast<void>(encoding); +#endif } cmGeneratedFileStream::~cmGeneratedFileStream() diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 515954c..a027b01 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -5,6 +5,7 @@ #include <cmConfigure.h> +#include <cm_codecvt.hxx> #include <cmsys/FStream.hxx> #include <string> @@ -71,12 +72,13 @@ class cmGeneratedFileStream : private cmGeneratedFileStreamBase, { public: typedef cmsys::ofstream Stream; + typedef codecvt::Encoding Encoding; /** * This constructor prepares a default stream. The open method must * be used before writing to the stream. */ - cmGeneratedFileStream(); + cmGeneratedFileStream(Encoding encoding = codecvt::None); /** * This constructor takes the name of the file to be generated. It @@ -84,7 +86,8 @@ public: * file cannot be opened an error message is produced unless the * second argument is set to true. */ - cmGeneratedFileStream(const char* name, bool quiet = false); + cmGeneratedFileStream(const char* name, bool quiet = false, + Encoding encoding = codecvt::None); /** * The destructor checks the stream status to be sure the temporary diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e8d66a2..7eb0ebf 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4965,6 +4965,9 @@ bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { return false; } + if (this->GetProperty("BUILD_RPATH")) { + return true; + } if (cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config)) { return !impl->Libraries.empty(); diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 959dfdb..5fbaea4 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -5,6 +5,7 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalGhsMultiGenerator.h" +#include "cmLinkLineComputer.h" #include "cmLocalGhsMultiGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" @@ -244,7 +245,7 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config, flags, this->GeneratorTarget, lang); // Append old-style preprocessor definition flags. - if (std::string(" ") != std::string(this->Makefile->GetDefineFlags())) { + if (this->Makefile->GetDefineFlags() != " ") { this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags()); } @@ -362,9 +363,15 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries( this->GeneratorTarget->GetCreateRuleVariable(language, config); bool useWatcomQuote = this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE"); + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->GetGlobalGenerator()->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); + this->LocalGenerator->GetTargetFlags( - config, linkLibraries, flags, linkFlags, frameworkPath, linkPath, - this->GeneratorTarget, useWatcomQuote); + linkLineComputer.get(), config, linkLibraries, flags, linkFlags, + frameworkPath, linkPath, this->GeneratorTarget); linkFlags = cmSystemTools::TrimWhitespace(linkFlags); if (!linkPath.empty()) { diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a446862..1aa6af1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -20,7 +20,9 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmInstallGenerator.h" +#include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" +#include "cmMSVC60LinkLineComputer.h" #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmPolicies.h" @@ -1007,6 +1009,25 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, } } +const char* cmGlobalGenerator::GetGlobalSetting(std::string const& name) const +{ + assert(!this->Makefiles.empty()); + return this->Makefiles[0]->GetDefinition(name); +} + +bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const +{ + assert(!this->Makefiles.empty()); + return this->Makefiles[0]->IsOn(name); +} + +const char* cmGlobalGenerator::GetSafeGlobalSetting( + std::string const& name) const +{ + assert(!this->Makefiles.empty()); + return this->Makefiles[0]->GetSafeDefinition(name); +} + bool cmGlobalGenerator::IgnoreFile(const char* ext) const { if (!this->GetLanguageFromExtension(ext).empty()) { @@ -1393,6 +1414,18 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets() return autogenTargets; } +cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir) const +{ + return new cmLinkLineComputer(outputConverter, stateDir); +} + +cmLinkLineComputer* cmGlobalGenerator::CreateMSVC60LinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir) const +{ + return new cmMSVC60LinkLineComputer(outputConverter, stateDir); +} + void cmGlobalGenerator::FinalizeTargetCompileInfo() { std::vector<std::string> const langs = diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 4120b52..38eaa76 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -10,6 +10,7 @@ #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" +#include "cm_codecvt.hxx" #include <iosfwd> #include <map> @@ -33,7 +34,9 @@ class cmExportBuildFileGenerator; class cmExternalMakefileProjectGenerator; class cmGeneratorTarget; class cmLocalGenerator; +class cmLinkLineComputer; class cmMakefile; +class cmOutputConverter; class cmake; /** \class cmGlobalGenerator @@ -60,6 +63,12 @@ public: return this->GetName() == name; } + /** Get encoding used by generator for makefile files */ + virtual codecvt::Encoding GetMakefileEncoding() const + { + return codecvt::None; + } + /** Tell the generator about the target system. */ virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; } @@ -98,6 +107,12 @@ public: */ virtual void Generate(); + virtual cmLinkLineComputer* CreateLinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir) const; + + cmLinkLineComputer* CreateMSVC60LinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir) const; + /** * Set/Get and Clear the enabled languages. */ @@ -194,6 +209,10 @@ public: cmExportSetMap& GetExportSets() { return this->ExportSets; } + const char* GetGlobalSetting(std::string const& name) const; + bool GlobalSettingIsOn(std::string const& name) const; + const char* GetSafeGlobalSetting(std::string const& name) const; + /** Add a file to the manifest of generated targets for a configuration. */ void AddToManifest(std::string const& f); diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index f169e76..6eb2124 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -26,6 +26,12 @@ public: } static std::string GetActualName() { return "NMake Makefiles"; } + /** Get encoding used by generator for makefile files */ + codecvt::Encoding GetMakefileEncoding() const CM_OVERRIDE + { + return codecvt::ANSI; + } + /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f5a0e68..67df038 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -11,6 +11,7 @@ #include "cmLocalGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmMakefile.h" +#include "cmNinjaLinkLineComputer.h" #include "cmOutputConverter.h" #include "cmState.h" #include "cmSystemTools.h" @@ -64,6 +65,14 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, os << "# " << comment.substr(lpos) << "\n\n"; } +cmLinkLineComputer* cmGlobalNinjaGenerator::CreateLinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory /* stateDir */) const +{ + return new cmNinjaLinkLineComputer( + outputConverter, + this->LocalGenerators[0]->GetStateSnapshot().GetDirectory(), this); +} + std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name) { // Ninja rule names must match "[a-zA-Z0-9_.-]+". Use ".xx" to encode @@ -830,7 +839,8 @@ static void EnsureTrailingSlash(std::string& path) #endif } -std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path) +std::string cmGlobalNinjaGenerator::ConvertToNinjaPath( + const std::string& path) const { cmLocalNinjaGenerator* ng = static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]); @@ -1421,7 +1431,8 @@ void cmGlobalNinjaGenerator::InitOutputPathPrefix() EnsureTrailingSlash(this->OutputPathPrefix); } -std::string cmGlobalNinjaGenerator::NinjaOutputPath(std::string const& path) +std::string cmGlobalNinjaGenerator::NinjaOutputPath( + std::string const& path) const { if (!this->HasOutputPathPrefix() || cmSystemTools::FileIsFullPath(path)) { return path; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index dcf7406..6b77a2b 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -70,6 +70,10 @@ public: std::string EncodePath(const std::string& path); static std::string EncodeDepfileSpace(const std::string& path); + cmLinkLineComputer* CreateLinkLineComputer( + cmOutputConverter* outputConverter, + cmState::Directory stateDir) const CM_OVERRIDE; + /** * Write the given @a comment to the output stream @a os. It * handles new line character properly. @@ -233,7 +237,7 @@ public: return this->RulesFileStream; } - std::string ConvertToNinjaPath(const std::string& path); + std::string ConvertToNinjaPath(const std::string& path) const; std::string ConvertToNinjaFolderRule(const std::string& path); struct MapToNinjaPathImpl @@ -333,7 +337,7 @@ public: bool SupportsConsolePool() const; bool SupportsImplicitOuts() const; - std::string NinjaOutputPath(std::string const& path); + std::string NinjaOutputPath(std::string const& path) const; bool HasOutputPathPrefix() const { return !this->OutputPathPrefix.empty(); } void StripNinjaOutputPathPrefixAsSuffix(std::string& path); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 4a5cc77..daacef0 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -201,7 +201,8 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() this->GetCMakeInstance()->GetHomeOutputDirectory(); makefileName += cmake::GetCMakeFilesDirectory(); makefileName += "/Makefile2"; - cmGeneratedFileStream makefileStream(makefileName.c_str()); + cmGeneratedFileStream makefileStream(makefileName.c_str(), false, + this->GetMakefileEncoding()); if (!makefileStream) { return; } @@ -306,16 +307,12 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // reset lg to the first makefile lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]); - // Build the path to the cache file. - std::string cache = this->GetCMakeInstance()->GetHomeOutputDirectory(); - cache += "/CMakeCache.txt"; - std::string currentBinDir = lg->GetCurrentBinaryDirectory(); // Save the list to the cmake file. cmakefileStream << "# The top level Makefile was generated from the following files:\n" << "set(CMAKE_MAKEFILE_DEPENDS\n" - << " \"" << lg->ConvertToRelativePath(currentBinDir, cache) << "\"\n"; + << " \"CMakeCache.txt\"\n"; for (std::vector<std::string>::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, *i) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index caaac87..02ffa41 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -145,10 +145,36 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( return false; } - this->GeneratorToolset = ts; + if (!this->ParseGeneratorToolset(ts, mf)) { + return false; + } if (const char* toolset = this->GetPlatformToolset()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset); } + if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch); + } + return true; +} + +bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset( + std::string const& ts, cmMakefile* mf) +{ + if (ts.find_first_of(",=") != ts.npos) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not recognize the toolset\n" + " " << ts << "\n" + "that was specified."; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + + this->GeneratorToolset = ts; return true; } @@ -322,6 +348,15 @@ const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const return 0; } +const char* +cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const +{ + if (!this->GeneratorToolsetHostArchitecture.empty()) { + return this->GeneratorToolsetHostArchitecture.c_str(); + } + return CM_NULLPTR; +} + void cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf) { this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 19c60aa..f8a50ac 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -22,6 +22,7 @@ public: virtual bool SetSystemName(std::string const& s, cmMakefile* mf); virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf); virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); + virtual bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, const std::string& makeProgram, @@ -48,6 +49,9 @@ public: /** The toolset name for the target platform. */ const char* GetPlatformToolset() const; + /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */ + const char* GetPlatformToolsetHostArchitecture() const; + /** Return the CMAKE_SYSTEM_NAME. */ std::string const& GetSystemName() const { return this->SystemName; } @@ -101,6 +105,7 @@ protected: std::string const& GetMSBuildCommand(); std::string GeneratorToolset; + std::string GeneratorToolsetHostArchitecture; std::string DefaultPlatformToolset; std::string WindowsTargetPlatformVersion; std::string SystemName; diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 5fdeec7..ec7916c 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -96,6 +96,21 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName( return false; } +bool cmGlobalVisualStudio12Generator::ParseGeneratorToolset( + std::string const& ts, cmMakefile* mf) +{ + std::string::size_type ts_end = ts.size(); + if (cmHasLiteralSuffix(ts, ",host=x64")) { + this->GeneratorToolsetHostArchitecture = "x64"; + ts_end -= 9; + } else if (ts == "host=x64") { + this->GeneratorToolsetHostArchitecture = "x64"; + ts_end = 0; + } + return this->cmGlobalVisualStudio11Generator::ParseGeneratorToolset( + ts.substr(0, ts_end), mf); +} + bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf) { if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) { diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 78bb637..cdda512 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -22,6 +22,9 @@ public: // version number virtual const char* GetToolsVersion() { return "12.0"; } protected: + bool ParseGeneratorToolset(std::string const& ts, + cmMakefile* mf) CM_OVERRIDE; + virtual bool InitializeWindowsPhone(cmMakefile* mf); virtual bool InitializeWindowsStore(cmMakefile* mf); virtual bool SelectWindowsPhoneToolset(std::string& toolset) const; diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx index 4d62f2b..a833a5f 100644 --- a/Source/cmGlobalVisualStudio15Generator.cxx +++ b/Source/cmGlobalVisualStudio15Generator.cxx @@ -79,7 +79,7 @@ cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\15.0\\Setup\\VC;" "ProductDir", vc15Express, cmSystemTools::KeyWOW64_32); - this->DefaultPlatformToolset = "v140"; + this->DefaultPlatformToolset = "v141"; this->Version = VS15; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4ff612d..0ddfc9a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -220,6 +220,19 @@ bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts, cmMakefile* mf) { if (this->XcodeVersion >= 30) { + if (ts.find_first_of(",=") != ts.npos) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not recognize the toolset\n" + " " << ts << "\n" + "that was specified."; + /* clang-format on */ + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } this->GeneratorToolset = ts; if (!this->GeneratorToolset.empty()) { mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", @@ -3325,14 +3338,14 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p) { // We force conversion because Xcode breakpoints do not work unless // they are in a file named relative to the source tree. - return this->CurrentLocalGenerator->ConvertToRelativePath( - this->ProjectSourceDirectoryComponents, p, true); + return cmOutputConverter::ForceToRelativePath( + cmSystemTools::JoinPath(this->ProjectSourceDirectoryComponents), p); } std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p) { return this->CurrentLocalGenerator->ConvertToRelativePath( - this->ProjectOutputDirectoryComponents, p); + cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p); } std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p) diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index bb0e27b..4202cf5 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -20,7 +20,7 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args, "a library"); return false; } - this->Makefile->AddLinkLibrary(*i, DEBUG_LibraryType); + this->Makefile->AppendProperty("LINK_LIBRARIES", "debug"); } else if (*i == "optimized") { ++i; if (i == args.end()) { @@ -28,10 +28,9 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args, "a library"); return false; } - this->Makefile->AddLinkLibrary(*i, OPTIMIZED_LibraryType); - } else { - this->Makefile->AddLinkLibrary(*i); + this->Makefile->AppendProperty("LINK_LIBRARIES", "optimized"); } + this->Makefile->AppendProperty("LINK_LIBRARIES", i->c_str()); } return true; diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx new file mode 100644 index 0000000..24f3578 --- /dev/null +++ b/Source/cmLinkLineComputer.cxx @@ -0,0 +1,179 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmLinkLineComputer.h" +#include "cmComputeLinkInformation.h" +#include "cmGeneratorTarget.h" +#include "cmOutputConverter.h" + +cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter, + cmState::Directory stateDir) + : StateDir(stateDir) + , OutputConverter(outputConverter) + , ForResponse(false) + , UseWatcomQuote(false) + , Relink(false) +{ +} + +cmLinkLineComputer::~cmLinkLineComputer() +{ +} + +void cmLinkLineComputer::SetUseWatcomQuote(bool useWatcomQuote) +{ + this->UseWatcomQuote = useWatcomQuote; +} + +void cmLinkLineComputer::SetForResponse(bool forResponse) +{ + this->ForResponse = forResponse; +} + +void cmLinkLineComputer::SetRelink(bool relink) +{ + this->Relink = relink; +} + +std::string cmLinkLineComputer::ConvertToLinkReference( + std::string const& lib) const +{ + std::string relLib = lib; + + if (cmOutputConverter::ContainedInDirectory( + this->StateDir.GetCurrentBinary(), lib, this->StateDir)) { + relLib = cmOutputConverter::ForceToRelativePath( + this->StateDir.GetCurrentBinary(), lib); + } + return relLib; +} + +std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) +{ + std::string linkLibs; + typedef cmComputeLinkInformation::ItemVector ItemVector; + ItemVector const& items = cli.GetItems(); + for (ItemVector::const_iterator li = items.begin(); li != items.end(); + ++li) { + if (li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) { + continue; + } + if (li->IsPath) { + linkLibs += + this->ConvertToOutputFormat(this->ConvertToLinkReference(li->Value)); + } else { + linkLibs += li->Value; + } + linkLibs += " "; + } + return linkLibs; +} + +std::string cmLinkLineComputer::ConvertToOutputFormat(std::string const& input) +{ + cmOutputConverter::OutputFormat shellFormat = (this->ForResponse) + ? cmOutputConverter::RESPONSE + : ((this->UseWatcomQuote) ? cmOutputConverter::WATCOMQUOTE + : cmOutputConverter::SHELL); + + return this->OutputConverter->ConvertToOutputFormat(input, shellFormat); +} + +std::string cmLinkLineComputer::ConvertToOutputForExisting( + std::string const& input) +{ + cmOutputConverter::OutputFormat shellFormat = (this->ForResponse) + ? cmOutputConverter::RESPONSE + : ((this->UseWatcomQuote) ? cmOutputConverter::WATCOMQUOTE + : cmOutputConverter::SHELL); + + return this->OutputConverter->ConvertToOutputForExisting(input, shellFormat); +} + +std::string cmLinkLineComputer::ComputeLinkPath( + cmComputeLinkInformation& cli, std::string const& libPathFlag, + std::string const& libPathTerminator) +{ + std::string linkPath; + std::vector<std::string> const& libDirs = cli.GetDirectories(); + for (std::vector<std::string>::const_iterator libDir = libDirs.begin(); + libDir != libDirs.end(); ++libDir) { + std::string libpath = this->ConvertToOutputForExisting(*libDir); + linkPath += " " + libPathFlag; + linkPath += libpath; + linkPath += libPathTerminator; + linkPath += " "; + } + return linkPath; +} + +std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli) +{ + std::string rpath; + // Check what kind of rpath flags to use. + if (cli.GetRuntimeSep().empty()) { + // Each rpath entry gets its own option ("-R a -R b -R c") + std::vector<std::string> runtimeDirs; + cli.GetRPath(runtimeDirs, this->Relink); + + for (std::vector<std::string>::iterator ri = runtimeDirs.begin(); + ri != runtimeDirs.end(); ++ri) { + rpath += cli.GetRuntimeFlag(); + rpath += this->ConvertToOutputFormat(*ri); + rpath += " "; + } + } else { + // All rpath entries are combined ("-Wl,-rpath,a:b:c"). + std::string rpathString = cli.GetRPathString(this->Relink); + + // Store the rpath option in the stream. + if (!rpathString.empty()) { + rpath += cli.GetRuntimeFlag(); + rpath += + this->OutputConverter->EscapeForShell(rpathString, !this->ForResponse); + rpath += " "; + } + } + return rpath; +} + +std::string cmLinkLineComputer::ComputeFrameworkPath( + cmComputeLinkInformation& cli, std::string const& fwSearchFlag) +{ + std::string frameworkPath; + if (!fwSearchFlag.empty()) { + std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths(); + for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); + fdi != fwDirs.end(); ++fdi) { + frameworkPath += fwSearchFlag; + frameworkPath += this->ConvertToOutputFormat(*fdi); + frameworkPath += " "; + } + } + return frameworkPath; +} + +std::string cmLinkLineComputer::ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString) +{ + std::ostringstream fout; + fout << this->ComputeRPath(cli); + + // Write the library flags to the build rule. + fout << this->ComputeLinkLibs(cli); + + // Add the linker runtime search path if any. + std::string rpath_link = cli.GetRPathLinkString(); + if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { + fout << cli.GetRPathLinkFlag(); + fout << this->OutputConverter->EscapeForShell(rpath_link, + !this->ForResponse); + fout << " "; + } + + if (!stdLibString.empty()) { + fout << stdLibString << " "; + } + + return fout.str(); +} diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h new file mode 100644 index 0000000..1fb9b24 --- /dev/null +++ b/Source/cmLinkLineComputer.h @@ -0,0 +1,50 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmLinkLineComputer_h +#define cmLinkLineComputer_h + +#include "cmState.h" + +class cmComputeLinkInformation; +class cmOutputConverter; + +class cmLinkLineComputer +{ +public: + cmLinkLineComputer(cmOutputConverter* outputConverter, + cmState::Directory stateDir); + virtual ~cmLinkLineComputer(); + + void SetUseWatcomQuote(bool useWatcomQuote); + void SetForResponse(bool forResponse); + void SetRelink(bool relink); + + virtual std::string ConvertToLinkReference(std::string const& input) const; + + std::string ComputeLinkPath(cmComputeLinkInformation& cli, + std::string const& libPathFlag, + std::string const& libPathTerminator); + + std::string ComputeFrameworkPath(cmComputeLinkInformation& cli, + std::string const& fwSearchFlag); + + std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, + std::string const& stdLibString); + +private: + std::string ComputeLinkLibs(cmComputeLinkInformation& cli); + std::string ComputeRPath(cmComputeLinkInformation& cli); + + std::string ConvertToOutputFormat(std::string const& input); + std::string ConvertToOutputForExisting(std::string const& input); + + cmState::Directory StateDir; + cmOutputConverter* OutputConverter; + + bool ForResponse; + bool UseWatcomQuote; + bool Relink; +}; + +#endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f24b717..3b19694 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -12,6 +12,7 @@ #include "cmInstallGenerator.h" #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" +#include "cmLinkLineComputer.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmSystemTools.h" @@ -1148,11 +1149,12 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, } void cmLocalGenerator::GetTargetFlags( - const std::string& config, std::string& linkLibs, std::string& flags, - std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target, bool useWatcomQuote) + cmLinkLineComputer* linkLineComputer, const std::string& config, + std::string& linkLibs, std::string& flags, std::string& linkFlags, + std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target) { const std::string buildType = cmSystemTools::UpperCase(config); + cmComputeLinkInformation* pcli = target->GetLinkInformation(config); const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library @@ -1176,12 +1178,13 @@ void cmLocalGenerator::GetTargetFlags( !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { std::vector<cmSourceFile*> sources; target->GetSourceFiles(sources, buildType); + std::string defFlag = + this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); for (std::vector<cmSourceFile*>::const_iterator i = sources.begin(); i != sources.end(); ++i) { cmSourceFile* sf = *i; if (sf->GetExtension() == "def") { - linkFlags += - this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); + linkFlags += defFlag; linkFlags += this->ConvertToOutputFormat( cmSystemTools::CollapseFullPath(sf->GetFullPath()), SHELL); linkFlags += " "; @@ -1202,8 +1205,10 @@ void cmLocalGenerator::GetTargetFlags( linkFlags += " "; } } - this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target, - false, false, useWatcomQuote); + if (pcli) { + this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, + frameworkPath, linkPath); + } } break; case cmState::EXECUTABLE: { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); @@ -1222,8 +1227,10 @@ void cmLocalGenerator::GetTargetFlags( return; } this->AddLanguageFlags(flags, linkLanguage, buildType); - this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, *target, - false, false, useWatcomQuote); + if (pcli) { + this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, + frameworkPath, linkPath); + } if (cmSystemTools::IsOn( this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + @@ -1248,6 +1255,14 @@ void cmLocalGenerator::GetTargetFlags( linkFlags += this->Makefile->GetSafeDefinition(exportFlagVar); linkFlags += " "; } + + std::string cmp0065Flags = + this->GetLinkLibsCMP0065(linkLanguage, *target); + if (!cmp0065Flags.empty()) { + linkFlags += cmp0065Flags; + linkFlags += " "; + } + const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1374,63 +1389,18 @@ std::string cmLocalGenerator::GetTargetFortranFlags( return std::string(); } -std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, - OutputFormat format) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - // Work-ardound command line parsing limitations in MSVC 6.0 - if (this->Makefile->IsOn("MSVC60")) { - // Search for the last space. - std::string::size_type pos = lib.rfind(' '); - if (pos != lib.npos) { - // Find the slash after the last space, if any. - pos = lib.find('/', pos); - - // Convert the portion of the path with a space to a short path. - std::string sp; - if (cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp)) { - // Append the rest of the path with no space. - sp += lib.substr(pos); - - // Convert to an output path. - return this->ConvertToOutputFormat(sp.c_str(), format); - } - } - } -#endif - - // Normal behavior. - return this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), lib), - format); -} - /** * Output the linking rules on a command line. For executables, * targetLibrary should be a NULL pointer. For libraries, it should point * to the name of the library. This will not link a library against itself. */ -void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, - std::string& frameworkPath, - std::string& linkPath, - cmGeneratorTarget& tgt, bool relink, - bool forResponseFile, - bool useWatcomQuote) -{ - OutputFormat shellFormat = - (forResponseFile) ? RESPONSE : ((useWatcomQuote) ? WATCOMQUOTE : SHELL); - bool escapeAllowMakeVars = !forResponseFile; - std::ostringstream fout; - std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); - if (!pcli) { - return; - } +void cmLocalGenerator::OutputLinkLibraries( + cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer, + std::string& linkLibraries, std::string& frameworkPath, + std::string& linkPath) +{ cmComputeLinkInformation& cli = *pcli; - // Collect library linking flags command line options. - std::string linkLibs; - std::string linkLanguage = cli.GetLinkLanguage(); std::string libPathFlag = @@ -1438,6 +1408,34 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, std::string libPathTerminator = this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); + // Add standard libraries for this language. + std::string standardLibsVar = "CMAKE_"; + standardLibsVar += cli.GetLinkLanguage(); + standardLibsVar += "_STANDARD_LIBRARIES"; + std::string stdLibString; + if (const char* stdLibs = this->Makefile->GetDefinition(standardLibsVar)) { + stdLibString = stdLibs; + } + + // Append the framework search path flags. + std::string fwSearchFlagVar = "CMAKE_"; + fwSearchFlagVar += linkLanguage; + fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; + std::string fwSearchFlag = + this->Makefile->GetSafeDefinition(fwSearchFlagVar); + + frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag); + linkPath = + linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator); + + linkLibraries = linkLineComputer->ComputeLinkLibraries(cli, stdLibString); +} + +std::string cmLocalGenerator::GetLinkLibsCMP0065( + std::string const& linkLanguage, cmGeneratorTarget& tgt) const +{ + std::string linkFlags; + // Flags to link an executable to shared libraries. if (tgt.GetType() == cmState::EXECUTABLE && this->StateSnapshot.GetState()->GetGlobalPropertyAsBool( @@ -1476,100 +1474,10 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; linkFlagsVar += linkLanguage; linkFlagsVar += "_FLAGS"; - linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); - linkLibs += " "; - } - } - - // Append the framework search path flags. - std::string fwSearchFlagVar = "CMAKE_"; - fwSearchFlagVar += linkLanguage; - fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; - const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar); - if (fwSearchFlag && *fwSearchFlag) { - std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths(); - for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); - fdi != fwDirs.end(); ++fdi) { - frameworkPath += fwSearchFlag; - frameworkPath += this->ConvertToOutputFormat(*fdi, shellFormat); - frameworkPath += " "; - } - } - - // Append the library search path flags. - std::vector<std::string> const& libDirs = cli.GetDirectories(); - for (std::vector<std::string>::const_iterator libDir = libDirs.begin(); - libDir != libDirs.end(); ++libDir) { - std::string libpath = - this->ConvertToOutputForExisting(*libDir, shellFormat); - linkPath += " " + libPathFlag; - linkPath += libpath; - linkPath += libPathTerminator; - linkPath += " "; - } - - // Append the link items. - typedef cmComputeLinkInformation::ItemVector ItemVector; - ItemVector const& items = cli.GetItems(); - for (ItemVector::const_iterator li = items.begin(); li != items.end(); - ++li) { - if (li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) { - continue; - } - if (li->IsPath) { - linkLibs += this->ConvertToLinkReference(li->Value, shellFormat); - } else { - linkLibs += li->Value; - } - linkLibs += " "; - } - - // Check what kind of rpath flags to use. - if (cli.GetRuntimeSep().empty()) { - // Each rpath entry gets its own option ("-R a -R b -R c") - std::vector<std::string> runtimeDirs; - cli.GetRPath(runtimeDirs, relink); - - std::string rpath; - for (std::vector<std::string>::iterator ri = runtimeDirs.begin(); - ri != runtimeDirs.end(); ++ri) { - rpath += cli.GetRuntimeFlag(); - rpath += this->ConvertToOutputFormat(*ri, shellFormat); - rpath += " "; - } - fout << rpath; - } else { - // All rpath entries are combined ("-Wl,-rpath,a:b:c"). - std::string rpath = cli.GetRPathString(relink); - - // Store the rpath option in the stream. - if (!rpath.empty()) { - fout << cli.GetRuntimeFlag(); - fout << this->EscapeForShell(rpath, escapeAllowMakeVars); - fout << " "; + linkFlags = this->Makefile->GetSafeDefinition(linkFlagsVar); } } - - // Write the library flags to the build rule. - fout << linkLibs; - - // Add the linker runtime search path if any. - std::string rpath_link = cli.GetRPathLinkString(); - if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { - fout << cli.GetRPathLinkFlag(); - fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars); - fout << " "; - } - - // Add standard libraries for this language. - std::string standardLibsVar = "CMAKE_"; - standardLibsVar += cli.GetLinkLanguage(); - standardLibsVar += "_STANDARD_LIBRARIES"; - if (const char* stdLibs = this->Makefile->GetDefinition(standardLibsVar)) { - fout << stdLibs << " "; - } - - linkLibraries = fout.str(); + return linkFlags; } void cmLocalGenerator::AddArchitectureFlags(std::string& flags, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 19469be..69c4101 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -19,11 +19,13 @@ #include <string> #include <vector> +class cmComputeLinkInformation; class cmCustomCommandGenerator; class cmGeneratorTarget; class cmGlobalGenerator; class cmMakefile; class cmSourceFile; +class cmLinkLineComputer; /** \class cmLocalGenerator * \brief Create required build files for a directory. @@ -82,6 +84,9 @@ public: return this->GlobalGenerator; } + std::string GetLinkLibsCMP0065(std::string const& linkLanguage, + cmGeneratorTarget& tgt) const; + cmState* GetState() const; cmState::Snapshot GetStateSnapshot() const; @@ -309,10 +314,11 @@ public: /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ - void GetTargetFlags(const std::string& config, std::string& linkLibs, + void GetTargetFlags(cmLinkLineComputer* linkLineComputer, + const std::string& config, std::string& linkLibs, std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target, bool useWatcomQuote); + cmGeneratorTarget* target); void GetTargetDefines(cmGeneratorTarget const* target, std::string const& config, std::string const& lang, std::set<std::string>& defines) const; @@ -342,10 +348,10 @@ public: protected: ///! put all the libraries for a target on into the given stream - void OutputLinkLibraries(std::string& linkLibraries, - std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget&, bool relink, - bool forResponseFile, bool useWatcomQuote); + void OutputLinkLibraries(cmComputeLinkInformation* pcli, + cmLinkLineComputer* linkLineComputer, + std::string& linkLibraries, + std::string& frameworkPath, std::string& linkPath); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, @@ -367,10 +373,6 @@ protected: std::string& CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max); - virtual std::string ConvertToLinkReference( - std::string const& lib, - cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL); - /** Check whether the native build system supports the given definition. Issues a warning. */ virtual bool CheckDefinition(std::string const& define) const; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 11b87e3..e25eb0f 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -120,13 +120,6 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() // Virtual protected methods. -std::string cmLocalNinjaGenerator::ConvertToLinkReference( - std::string const& lib, cmOutputConverter::OutputFormat format) -{ - std::string path = this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(lib); - return this->ConvertToOutputFormat(path, format); -} - std::string cmLocalNinjaGenerator::ConvertToIncludeReference( std::string const& path, cmOutputConverter::OutputFormat format, bool forceFullPaths) @@ -489,15 +482,12 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( std::string output; const std::vector<std::string>& outputs = ccg.GetOutputs(); if (!outputs.empty()) { + output = outputs[0]; if (ccg.GetWorkingDirectory().empty()) { - output = this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), - outputs[0]), - cmOutputConverter::SHELL); - } else { output = - this->ConvertToOutputFormat(outputs[0], cmOutputConverter::SHELL); + this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), output); } + output = this->ConvertToOutputFormat(output, cmOutputConverter::SHELL); } vars.Output = output.c_str(); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 875f8c6..b04788d 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -76,10 +76,6 @@ public: void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg, cmNinjaDeps& ninjaDeps); - std::string ConvertToLinkReference(std::string const& lib, - cmOutputConverter::OutputFormat format = - cmOutputConverter::SHELL) CM_OVERRIDE; - void ComputeObjectFilenames( std::map<cmSourceFile const*, std::string>& mapping, cmGeneratorTarget const* gt = CM_NULLPTR) CM_OVERRIDE; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 8825b46..02eef59 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -141,7 +141,7 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath() { // Compute the path to use when referencing the current output // directory from the top output directory. - this->HomeRelativeOutputPath = this->ConvertToRelativePath( + this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath( this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); if (this->HomeRelativeOutputPath == ".") { this->HomeRelativeOutputPath = ""; @@ -230,7 +230,9 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); + cmGeneratedFileStream ruleFileStream( + ruleFileNameFull.c_str(), false, + this->GlobalGenerator->GetMakefileEncoding()); if (!ruleFileStream) { return; } @@ -548,7 +550,8 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule( // Construct the left hand side of the rule. std::string tgt = cmSystemTools::ConvertToOutputPath( - this->ConvertToRelativePath(this->GetBinaryDirectory(), target).c_str()); + this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target) + .c_str()); const char* space = ""; if (tgt.size() == 1) { @@ -577,7 +580,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule( dep != depends.end(); ++dep) { replace = *dep; replace = cmSystemTools::ConvertToOutputPath( - this->ConvertToRelativePath(binDir, replace).c_str()); + this->MaybeConvertToRelativePath(binDir, replace).c_str()); os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n"; } } @@ -969,7 +972,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // working directory will be the start-output directory. bool had_slash = cmd.find('/') != cmd.npos; if (workingDir.empty()) { - cmd = this->ConvertToRelativePath(currentBinDir, cmd); + cmd = this->MaybeConvertToRelativePath(currentBinDir, cmd); } bool has_slash = cmd.find('/') != cmd.npos; if (had_slash && !has_slash) { @@ -992,16 +995,13 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( std::string output; const std::vector<std::string>& outputs = ccg.GetOutputs(); if (!outputs.empty()) { + output = outputs[0]; if (workingDir.empty()) { - output = this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), - outputs[0]), - cmOutputConverter::SHELL); - - } else { - output = this->ConvertToOutputFormat(outputs[0], - cmOutputConverter::SHELL); + output = this->MaybeConvertToRelativePath( + this->GetCurrentBinaryDirectory(), output); } + output = + this->ConvertToOutputFormat(output, cmOutputConverter::SHELL); } vars.Output = output.c_str(); @@ -1082,14 +1082,15 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( fout << "file(REMOVE_RECURSE\n"; for (std::vector<std::string>::const_iterator f = files.begin(); f != files.end(); ++f) { - std::string fc = this->ConvertToRelativePath(currentBinDir, *f); + std::string fc = this->MaybeConvertToRelativePath(currentBinDir, *f); fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n"; } fout << ")\n"; } std::string remove = "$(CMAKE_COMMAND) -P "; remove += this->ConvertToOutputFormat( - this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), cleanfile), + this->MaybeConvertToRelativePath(this->GetCurrentBinaryDirectory(), + cleanfile), cmOutputConverter::SHELL); commands.push_back(remove); @@ -1415,7 +1416,9 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // because the make tool may try to reload it needlessly otherwise. std::string ruleFileNameFull = dir; ruleFileNameFull += "/depend.make"; - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); + cmGeneratedFileStream ruleFileStream( + ruleFileNameFull.c_str(), false, + this->GlobalGenerator->GetMakefileEncoding()); ruleFileStream.SetCopyIfDifferent(true); if (!ruleFileStream) { return false; @@ -1427,7 +1430,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( std::string internalRuleFileNameFull = dir; internalRuleFileNameFull += "/depend.internal"; cmGeneratedFileStream internalRuleFileStream( - internalRuleFileNameFull.c_str()); + internalRuleFileNameFull.c_str(), false, + this->GlobalGenerator->GetMakefileEncoding()); if (!internalRuleFileStream) { return false; } @@ -1858,7 +1862,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( } for (std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { - cmakefileStream << " \"" << this->ConvertToRelativePath(binaryDir, *i) + cmakefileStream << " \"" + << this->MaybeConvertToRelativePath(binaryDir, *i) << "\"\n"; } cmakefileStream << " )\n"; @@ -1923,7 +1928,7 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall( if (!tgt.empty()) { // The make target is always relative to the top of the build tree. std::string tgt2 = - this->ConvertToRelativePath(this->GetBinaryDirectory(), tgt); + this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), tgt); // The target may have been written with windows paths. cmSystemTools::ConvertToOutputSlashes(tgt2); @@ -2095,3 +2100,13 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand( std::bind1st(std::plus<std::string>(), prefix)); } } + +std::string cmLocalUnixMakefileGenerator3::MaybeConvertToRelativePath( + std::string const& base, std::string const& path) +{ + if (!cmOutputConverter::ContainedInDirectory( + base, path, this->GetStateSnapshot().GetDirectory())) { + return path; + } + return cmOutputConverter::ForceToRelativePath(base, path); +} diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index fc5c8e7..c3ecda4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -184,6 +184,9 @@ public: // Eclipse generator. void GetIndividualFileTargets(std::vector<std::string>& targets); + std::string MaybeConvertToRelativePath(std::string const& base, + std::string const& path); + protected: void WriteLocalMakefile(); diff --git a/Source/cmMSVC60LinkLineComputer.cxx b/Source/cmMSVC60LinkLineComputer.cxx new file mode 100644 index 0000000..2b6df2a --- /dev/null +++ b/Source/cmMSVC60LinkLineComputer.cxx @@ -0,0 +1,36 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmMSVC60LinkLineComputer.h" + +#include "cmSystemTools.h" + +cmMSVC60LinkLineComputer::cmMSVC60LinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir) + : cmLinkLineComputer(outputConverter, stateDir) +{ +} + +std::string cmMSVC60LinkLineComputer::ConvertToLinkReference( + std::string const& lib) const +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + // Work-ardound command line parsing limitations in MSVC 6.0 + // Search for the last space. + std::string::size_type pos = lib.rfind(' '); + if (pos != lib.npos) { + // Find the slash after the last space, if any. + pos = lib.find('/', pos); + + // Convert the portion of the path with a space to a short path. + std::string sp; + if (cmSystemTools::GetShortPath(lib.substr(0, pos).c_str(), sp)) { + // Append the rest of the path with no space. + sp += lib.substr(pos); + return sp; + } + } +#endif + + return cmLinkLineComputer::ConvertToLinkReference(lib); +} diff --git a/Source/cmMSVC60LinkLineComputer.h b/Source/cmMSVC60LinkLineComputer.h new file mode 100644 index 0000000..ca9da31 --- /dev/null +++ b/Source/cmMSVC60LinkLineComputer.h @@ -0,0 +1,19 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmMSVC60LinkLineComputer_h +#define cmMSVC60LinkLineComputer_h + +#include "cmLinkLineComputer.h" + +class cmMSVC60LinkLineComputer : public cmLinkLineComputer +{ +public: + cmMSVC60LinkLineComputer(cmOutputConverter* outputConverter, + cmState::Directory stateDir); + + std::string ConvertToLinkReference(std::string const& input) const + CM_OVERRIDE; +}; + +#endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index df993ce..c3111c0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1207,71 +1207,6 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) return true; } -void cmMakefile::AddLinkLibrary(const std::string& lib, - cmTargetLinkLibraryType llt) -{ - cmTarget::LibraryID tmp; - tmp.first = lib; - tmp.second = llt; - this->LinkLibraries.push_back(tmp); -} - -void cmMakefile::AddLinkLibraryForTarget(const std::string& target, - const std::string& lib, - cmTargetLinkLibraryType llt) -{ - cmTargets::iterator i = this->Targets.find(target); - if (i != this->Targets.end()) { - cmTarget* tgt = this->GetGlobalGenerator()->FindTarget(lib); - if (tgt) { - // if it is not a static or shared library then you can not link to it - if (!((tgt->GetType() == cmState::STATIC_LIBRARY) || - (tgt->GetType() == cmState::SHARED_LIBRARY) || - (tgt->GetType() == cmState::INTERFACE_LIBRARY) || - tgt->IsExecutableWithExports())) { - std::ostringstream e; - e << "Target \"" << lib << "\" of type " - << cmState::GetTargetTypeName(tgt->GetType()) - << " may not be linked into another target. " - << "One may link only to STATIC or SHARED libraries, or " - << "to executables with the ENABLE_EXPORTS property set."; - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - } - } - i->second.AddLinkLibrary(*this, target, lib, llt); - } else { - std::ostringstream e; - e << "Attempt to add link library \"" << lib << "\" to target \"" << target - << "\" which is not built in this directory."; - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - -void cmMakefile::AddLinkDirectoryForTarget(const std::string& target, - const std::string& d) -{ - cmTargets::iterator i = this->Targets.find(target); - if (i != this->Targets.end()) { - if (this->IsAlias(target)) { - std::ostringstream e; - e << "ALIAS target \"" << target << "\" " - << "may not be linked into another target."; - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - i->second.AddLinkDirectory(d); - } else { - cmSystemTools::Error( - "Attempt to add link directories to non-existent target: ", - target.c_str(), " for directory ", d.c_str()); - } -} - -void cmMakefile::AddLinkLibrary(const std::string& lib) -{ - this->AddLinkLibrary(lib, GENERAL_LibraryType); -} - void cmMakefile::InitializeFromParent(cmMakefile* parent) { this->SystemIncludeDirectories = parent->SystemIncludeDirectories; @@ -1303,7 +1238,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) } // link libraries - this->LinkLibraries = parent->LinkLibraries; + this->SetProperty("LINK_LIBRARIES", parent->GetProperty("LINK_LIBRARIES")); // link directories this->SetProperty("LINK_DIRECTORIES", @@ -1835,8 +1770,7 @@ void cmMakefile::SetProjectName(std::string const& p) this->StateSnapshot.SetProjectName(p); } -void cmMakefile::AddGlobalLinkInformation(const std::string& name, - cmTarget& target) +void cmMakefile::AddGlobalLinkInformation(cmTarget& target) { // for these targets do not add anything switch (target.GetType()) { @@ -1857,13 +1791,34 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name, if (*j->rbegin() == '/') { newdir = j->substr(0, j->size() - 1); } - if (std::find(this->LinkDirectories.begin(), this->LinkDirectories.end(), - newdir) == this->LinkDirectories.end()) { - target.AddLinkDirectory(*j); + target.AddLinkDirectory(*j); + } + } + + if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { + std::vector<std::string> linkLibs; + cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs); + + for (std::vector<std::string>::iterator j = linkLibs.begin(); + j != linkLibs.end(); ++j) { + std::string libraryName = *j; + cmTargetLinkLibraryType libType = GENERAL_LibraryType; + if (libraryName == "optimized") { + libType = OPTIMIZED_LibraryType; + ++j; + libraryName = *j; + } else if (libraryName == "debug") { + libType = DEBUG_LibraryType; + ++j; + libraryName = *j; } + // This is equivalent to the target_link_libraries plain signature. + target.AddLinkLibrary(*this, libraryName, libType); + target.AppendProperty( + "INTERFACE_LINK_LIBRARIES", + target.GetDebugGeneratorExpressions(libraryName, libType).c_str()); } } - target.MergeLinkLibraries(*this, name, this->LinkLibraries); } void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName) @@ -1877,14 +1832,9 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, const std::vector<std::string>& srcs, bool excludeFromAll) { - // wrong type ? default to STATIC - if ((type != cmState::STATIC_LIBRARY) && (type != cmState::SHARED_LIBRARY) && - (type != cmState::MODULE_LIBRARY) && (type != cmState::OBJECT_LIBRARY) && - (type != cmState::INTERFACE_LIBRARY)) { - this->IssueMessage(cmake::INTERNAL_ERROR, - "cmMakefile::AddLibrary given invalid target type."); - type = cmState::STATIC_LIBRARY; - } + assert(type == cmState::STATIC_LIBRARY || type == cmState::SHARED_LIBRARY || + type == cmState::MODULE_LIBRARY || type == cmState::OBJECT_LIBRARY || + type == cmState::INTERFACE_LIBRARY); cmTarget* target = this->AddNewTarget(type, lname); // Clear its dependencies. Otherwise, dependencies might persist @@ -1895,7 +1845,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); - this->AddGlobalLinkInformation(lname, *target); + this->AddGlobalLinkInformation(*target); return target; } @@ -1908,7 +1858,7 @@ cmTarget* cmMakefile::AddExecutable(const char* exeName, target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); - this->AddGlobalLinkInformation(exeName, *target); + this->AddGlobalLinkInformation(*target); return target; } @@ -2125,19 +2075,32 @@ void cmMakefile::ExpandVariablesCMP0019() } } } - for (cmTarget::LinkLibraryVectorType::iterator l = - this->LinkLibraries.begin(); - l != this->LinkLibraries.end(); ++l) { - if (mightExpandVariablesCMP0019(l->first.c_str())) { - std::string orig = l->first; - this->ExpandVariablesInString(l->first, true, true); - if (pol == cmPolicies::WARN && l->first != orig) { - /* clang-format off */ + + if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { + std::vector<std::string> linkLibs; + cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs); + + for (std::vector<std::string>::iterator l = linkLibs.begin(); + l != linkLibs.end(); ++l) { + std::string libName = *l; + if (libName == "optimized") { + ++l; + libName = *l; + } else if (libName == "debug") { + ++l; + libName = *l; + } + if (mightExpandVariablesCMP0019(libName.c_str())) { + std::string orig = libName; + this->ExpandVariablesInString(libName, true, true); + if (pol == cmPolicies::WARN && libName != orig) { + /* clang-format off */ w << "Evaluated link library\n" << " " << orig << "\n" << "as\n" - << " " << l->first << "\n"; - /* clang-format on */ + << " " << libName << "\n"; + /* clang-format on */ + } } } } @@ -3970,10 +3933,8 @@ cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus( bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var) { // Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting. - if (!var.empty()) { - if (const char* val = this->GetDefinition(var)) { - return cmSystemTools::IsOn(val); - } + if (const char* val = this->GetDefinition(var)) { + return cmSystemTools::IsOn(val); } // Enable optional policy warnings with --debug-output, --trace, // or --trace-expand. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 40344ce..0116ce1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -197,15 +197,6 @@ public: const char* comment = CM_NULLPTR, bool uses_terminal = false); /** - * Add a link library to the build. - */ - void AddLinkLibrary(const std::string&); - void AddLinkLibrary(const std::string&, cmTargetLinkLibraryType type); - void AddLinkLibraryForTarget(const std::string& tgt, const std::string&, - cmTargetLinkLibraryType type); - void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d); - - /** * Add a subdirectory to the build. */ void AddSubDirectory(const std::string& fullSrcDir, @@ -447,7 +438,7 @@ public: /** * Get a list of preprocessor define flags. */ - const char* GetDefineFlags() const { return this->DefineFlags.c_str(); } + std::string GetDefineFlags() const { return this->DefineFlags; } /** * Make sure CMake can write this file @@ -781,7 +772,7 @@ public: protected: // add link libraries and directories to the target - void AddGlobalLinkInformation(const std::string& name, cmTarget& target); + void AddGlobalLinkInformation(cmTarget& target); // Check for a an unused variable void LogUnused(const char* reason, const std::string& name) const; @@ -805,9 +796,6 @@ protected: // Tests std::map<std::string, cmTest*> Tests; - // The link-library paths. Order matters, use std::vector (not std::set). - std::vector<std::string> LinkDirectories; - // The set of include directories that are marked as system include // directories. std::set<std::string> SystemIncludeDirectories; @@ -815,8 +803,6 @@ protected: std::vector<std::string> ListFiles; std::vector<std::string> OutputFiles; - cmTarget::LinkLibraryVectorType LinkLibraries; - std::vector<cmInstallGenerator*> InstallGenerators; std::vector<cmTestGenerator*> TestGenerators; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index cb20117..ed34ce6 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -5,6 +5,7 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" @@ -130,16 +131,16 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) targetFullPathPDB, cmOutputConverter::SHELL); // Convert to the output path to use in constructing commands. std::string targetOutPath = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath), cmOutputConverter::SHELL); std::string targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal), cmOutputConverter::SHELL); std::string targetOutPathImport = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport), cmOutputConverter::SHELL); @@ -192,7 +193,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->AppendFlags( linkFlags, this->Makefile->GetDefinition(export_flag_var)); } - if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { + + this->LocalGenerator->AppendFlags(linkFlags, + this->LocalGenerator->GetLinkLibsCMP0065( + linkLanguage, *this->GeneratorTarget)); + + if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { this->LocalGenerator->AppendFlags(linkFlags, " -Wl,--no-as-needed"); } @@ -210,32 +216,39 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->AppendFlags( linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); - this->AddModuleDefinitionFlag(linkFlags); + { + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + + this->AddModuleDefinitionFlag(linkLineComputer.get(), linkFlags); + } // Construct a list of files associated with this executable that // may need to be cleaned. std::vector<std::string> exeCleanFiles; - exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath)); #ifdef _WIN32 // There may be a manifest file for this target. Add it to the // clean set just in case. - exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), (targetFullPath + ".manifest").c_str())); #endif if (targetNameReal != targetName) { - exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal)); } if (!targetNameImport.empty()) { - exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); std::string implib; if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { - exeCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), implib)); } } @@ -243,7 +256,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // List the PDB for cleaning only when the whole target is // cleaned. We do not want to delete the .pdb file just before // linking the target. - this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB)); // Add the pre-build and pre-link rules building but not when relinking. @@ -291,10 +304,18 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Set path conversion for link script shells. this->LocalGenerator->SetLinkScriptShell(useLinkScript); + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetForResponse(useResponseFileForLibs); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); + linkLineComputer->SetRelink(relink); + // Collect up flags to link in needed libraries. std::string linkLibs; - this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends, - useWatcomQuote); + this->CreateLinkLibs(linkLineComputer.get(), linkLibs, + useResponseFileForLibs, depends); // Construct object file lists that may be needed to expand the // rule. @@ -318,7 +339,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objectDir), cmOutputConverter::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -326,7 +347,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) ? cmOutputConverter::WATCOMQUOTE : cmOutputConverter::SHELL; std::string target = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal), output); vars.Target = target.c_str(); @@ -354,7 +375,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.LinkFlags = linkFlags.c_str(); vars.Manifests = manifests.c_str(); - if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { + if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); cmakeCommand += " -E __run_iwyu --lwyu="; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b969bfb..a19d70e 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -5,6 +5,7 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" @@ -159,9 +160,15 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) this->LocalGenerator->AddConfigVariableFlags( extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); - this->AddModuleDefinitionFlag(extraFlags); - if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + + this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags); + + if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { this->LocalGenerator->AppendFlags(extraFlags, " -Wl,--no-as-needed"); } this->WriteLibraryRules(linkRuleVar, extraFlags, relink); @@ -184,7 +191,13 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags( extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName); - this->AddModuleDefinitionFlag(extraFlags); + + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + + this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags); this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } @@ -305,20 +318,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( targetFullPathPDB, cmOutputConverter::SHELL); std::string targetOutPath = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath), cmOutputConverter::SHELL); std::string targetOutPathSO = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO), cmOutputConverter::SHELL); std::string targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal), cmOutputConverter::SHELL); std::string targetOutPathImport = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport), cmOutputConverter::SHELL); @@ -352,38 +365,26 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress); } - const char* forbiddenFlagVar = CM_NULLPTR; - switch (this->GeneratorTarget->GetType()) { - case cmState::SHARED_LIBRARY: - forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS"; - break; - case cmState::MODULE_LIBRARY: - forbiddenFlagVar = "_CREATE_SHARED_MODULE_FORBIDDEN_FLAGS"; - break; - default: - break; - } - // Clean files associated with this library. std::vector<std::string> libCleanFiles; - libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath)); if (targetNameReal != targetName) { - libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal)); } if (targetNameSO != targetName && targetNameSO != targetNameReal) { - libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO)); } if (!targetNameImport.empty()) { - libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); std::string implib; if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { - libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), implib)); } } @@ -391,14 +392,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // List the PDB for cleaning only when the whole target is // cleaned. We do not want to delete the .pdb file just before // linking the target. - this->CleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB)); #ifdef _WIN32 // There may be a manifest file for this target. Add it to the // clean set just in case. if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { - libCleanFiles.push_back(this->LocalGenerator->ConvertToRelativePath( + libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), (targetFullPath + ".manifest").c_str())); } @@ -491,8 +492,17 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Collect up flags to link in needed libraries. std::string linkLibs; if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { - this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends, - useWatcomQuote); + + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->CreateLinkLineComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetForResponse(useResponseFileForLibs); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); + linkLineComputer->SetRelink(relink); + + this->CreateLinkLibs(linkLineComputer.get(), linkLibs, + useResponseFileForLibs, depends); } // Construct object file lists that may be needed to expand the @@ -537,7 +547,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objectDir), cmOutputConverter::SHELL); @@ -546,7 +556,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( ? cmOutputConverter::WATCOMQUOTE : cmOutputConverter::SHELL; std::string target = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal), output); vars.Target = target.c_str(); @@ -585,11 +595,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->AddArchitectureFlags( langFlags, this->GeneratorTarget, linkLanguage, this->ConfigName); - // remove any language flags that might not work with the - // particular os - if (forbiddenFlagVar) { - this->RemoveForbiddenFlags(forbiddenFlagVar, linkLanguage, langFlags); - } vars.LanguageCompileFlags = langFlags.c_str(); // Construct the main link rule and expand placeholders. @@ -638,7 +643,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Get the set of commands. std::string linkRule = this->GetLinkRule(linkRuleVar); cmSystemTools::ExpandListArgument(linkRule, real_link_commands); - if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE") && + if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE") && (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) { std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e70f09e..84ae726 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -10,6 +10,7 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" @@ -110,7 +111,8 @@ void cmMakefileTargetGenerator::CreateRuleFile() // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. this->BuildFileStream = - new cmGeneratedFileStream(this->BuildFileNameFull.c_str()); + new cmGeneratedFileStream(this->BuildFileNameFull.c_str(), false, + this->GlobalGenerator->GetMakefileEncoding()); this->BuildFileStream->SetCopyIfDifferent(true); if (!this->BuildFileStream) { return; @@ -166,7 +168,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() for (std::vector<std::string>::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { this->CleanFiles.push_back( - this->LocalGenerator->ConvertToRelativePath(currentBinDir, *o)); + this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *o)); } } } @@ -209,8 +211,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() << this->GlobalGenerator->IncludeDirective << " " << root << cmSystemTools::ConvertToOutputPath( this->LocalGenerator - ->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(), - dependFileNameFull) + ->MaybeConvertToRelativePath( + this->LocalGenerator->GetBinaryDirectory(), dependFileNameFull) .c_str()) << "\n\n"; @@ -221,7 +223,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() << this->GlobalGenerator->IncludeDirective << " " << root << cmSystemTools::ConvertToOutputPath( this->LocalGenerator - ->ConvertToRelativePath( + ->MaybeConvertToRelativePath( this->LocalGenerator->GetBinaryDirectory(), this->ProgressFileNameFull) .c_str()) @@ -231,7 +233,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() // make sure the depend file exists if (!cmSystemTools::FileExists(dependFileNameFull.c_str())) { // Write an empty dependency file. - cmGeneratedFileStream depFileStream(dependFileNameFull.c_str()); + cmGeneratedFileStream depFileStream( + dependFileNameFull.c_str(), false, + this->GlobalGenerator->GetMakefileEncoding()); depFileStream << "# Empty dependencies file for " << this->GeneratorTarget->GetName() << ".\n" << "# This may be replaced when dependencies are built." @@ -243,7 +247,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() this->FlagFileNameFull = this->TargetBuildDirectoryFull; this->FlagFileNameFull += "/flags.make"; this->FlagFileStream = - new cmGeneratedFileStream(this->FlagFileNameFull.c_str()); + new cmGeneratedFileStream(this->FlagFileNameFull.c_str(), false, + this->GlobalGenerator->GetMakefileEncoding()); this->FlagFileStream->SetCopyIfDifferent(true); if (!this->FlagFileStream) { return; @@ -256,8 +261,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() << this->GlobalGenerator->IncludeDirective << " " << root << cmSystemTools::ConvertToOutputPath( this->LocalGenerator - ->ConvertToRelativePath(this->LocalGenerator->GetBinaryDirectory(), - this->FlagFileNameFull) + ->MaybeConvertToRelativePath( + this->LocalGenerator->GetBinaryDirectory(), + this->FlagFileNameFull) .c_str()) << "\n\n"; } @@ -314,9 +320,9 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()( output += "/"; output += cmSystemTools::GetFilenameName(input); this->Generator->CleanFiles.push_back( - this->Generator->LocalGenerator->ConvertToRelativePath( + this->Generator->LocalGenerator->MaybeConvertToRelativePath( this->Generator->LocalGenerator->GetCurrentBinaryDirectory(), output)); - output = this->Generator->LocalGenerator->ConvertToRelativePath( + output = this->Generator->LocalGenerator->MaybeConvertToRelativePath( this->Generator->LocalGenerator->GetBinaryDirectory(), output); // Create a rule to copy the content into the bundle. @@ -518,13 +524,13 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal), cmOutputConverter::SHELL); targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat( targetFullPathPDB, cmOutputConverter::SHELL); targetOutPathCompilePDB = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathCompilePDB), cmOutputConverter::SHELL); @@ -550,13 +556,13 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( vars.Object = shellObj.c_str(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); objectDir = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objectDir), cmOutputConverter::SHELL); vars.ObjectDir = objectDir.c_str(); std::string objectFileDir = cmSystemTools::GetFilenamePath(obj); objectFileDir = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objectFileDir), cmOutputConverter::SHELL); vars.ObjectFileDir = objectFileDir.c_str(); @@ -904,7 +910,7 @@ bool cmMakefileTargetGenerator::WriteMakeRule( // Touch the extra output so "make" knows that it was updated, // but only if the output was acually created. std::string const out = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath(binDir, *o), + this->LocalGenerator->MaybeConvertToRelativePath(binDir, *o), cmOutputConverter::SHELL); std::vector<std::string> output_commands; @@ -1200,10 +1206,9 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( for (std::vector<std::string>::const_iterator i = this->ExternalObjects.begin(); i != this->ExternalObjects.end(); ++i) { - object = this->LocalGenerator->ConvertToRelativePath(currentBinDir, *i); - *this->BuildFileStream << " " << lineContinue << "\n" - << this->Makefile->GetSafeDefinition( - "CMAKE_OBJECT_NAME"); + object = + this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *i); + *this->BuildFileStream << " " << lineContinue << "\n"; *this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath( i->c_str(), useWatcomQuote); } @@ -1211,21 +1216,16 @@ void cmMakefileTargetGenerator::WriteObjectsVariable( << "\n"; } -void cmMakefileTargetGenerator::WriteObjectsString(std::string& buildObjs) -{ - std::vector<std::string> objStrings; - this->WriteObjectsStrings(objStrings); - buildObjs = objStrings[0]; -} - class cmMakefileTargetGeneratorObjectStrings { public: cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings, - cmLocalUnixMakefileGenerator3* lg, + cmOutputConverter* outputConverter, + cmState::Directory stateDir, std::string::size_type limit) : Strings(strings) - , LocalGenerator(lg) + , OutputConverter(outputConverter) + , StateDir(stateDir) , LengthLimit(limit) { this->Space = ""; @@ -1233,10 +1233,8 @@ public: void Feed(std::string const& obj) { // Construct the name of the next object. - this->NextObject = this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( - this->LocalGenerator->GetCurrentBinaryDirectory(), obj), - cmOutputConverter::RESPONSE); + this->NextObject = this->OutputConverter->ConvertToOutputFormat( + this->MaybeConvertToRelativePath(obj), cmOutputConverter::RESPONSE); // Roll over to next string if the limit will be exceeded. if (this->LengthLimit != std::string::npos && @@ -1256,8 +1254,19 @@ public: } void Done() { this->Strings.push_back(this->CurrentString); } private: + std::string MaybeConvertToRelativePath(std::string const& obj) + { + if (!cmOutputConverter::ContainedInDirectory( + this->StateDir.GetCurrentBinary(), obj, this->StateDir)) { + return obj; + } + return cmOutputConverter::ForceToRelativePath( + this->StateDir.GetCurrentBinary(), obj); + } + std::vector<std::string>& Strings; - cmLocalUnixMakefileGenerator3* LocalGenerator; + cmOutputConverter* OutputConverter; + cmState::Directory StateDir; std::string::size_type LengthLimit; std::string CurrentString; std::string NextObject; @@ -1267,8 +1276,9 @@ private: void cmMakefileTargetGenerator::WriteObjectsStrings( std::vector<std::string>& objStrings, std::string::size_type limit) { - cmMakefileTargetGeneratorObjectStrings helper(objStrings, - this->LocalGenerator, limit); + cmMakefileTargetGeneratorObjectStrings helper( + objStrings, this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit); for (std::vector<std::string>::const_iterator i = this->Objects.begin(); i != this->Objects.end(); ++i) { helper.Feed(*i); @@ -1289,7 +1299,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget); std::string buildTargetRuleName = dir; buildTargetRuleName += relink ? "/preinstall" : "/build"; - buildTargetRuleName = this->LocalGenerator->ConvertToRelativePath( + buildTargetRuleName = this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetBinaryDirectory(), buildTargetRuleName); // Build the list of target outputs to drive. @@ -1410,52 +1420,6 @@ void cmMakefileTargetGenerator::CloseFileStreams() delete this->FlagFileStream; } -void cmMakefileTargetGenerator::RemoveForbiddenFlags( - const char* flagVar, const std::string& linkLang, std::string& linkFlags) -{ - // check for language flags that are not allowed at link time, and - // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool - // which fails, there may be more] - - std::string removeFlags = "CMAKE_"; - removeFlags += linkLang; - removeFlags += flagVar; - std::string removeflags = this->Makefile->GetSafeDefinition(removeFlags); - std::vector<std::string> removeList; - cmSystemTools::ExpandListArgument(removeflags, removeList); - - for (std::vector<std::string>::iterator i = removeList.begin(); - i != removeList.end(); ++i) { - std::string tmp; - std::string::size_type lastPosition = 0; - - for (;;) { - std::string::size_type position = linkFlags.find(*i, lastPosition); - - if (position == std::string::npos) { - tmp += linkFlags.substr(lastPosition); - break; - } else { - std::string::size_type prefixLength = position - lastPosition; - tmp += linkFlags.substr(lastPosition, prefixLength); - lastPosition = position + i->length(); - - bool validFlagStart = - position == 0 || isspace(linkFlags[position - 1]); - - bool validFlagEnd = - lastPosition == linkFlags.size() || isspace(linkFlags[lastPosition]); - - if (!validFlagStart || !validFlagEnd) { - tmp += *i; - } - } - } - - linkFlags = tmp; - } -} - void cmMakefileTargetGenerator::CreateLinkScript( const char* name, std::vector<std::string> const& link_commands, std::vector<std::string>& makefile_commands, @@ -1479,7 +1443,7 @@ void cmMakefileTargetGenerator::CreateLinkScript( // Create the makefile command to invoke the link script. std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script "; link_command += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), linkScriptName), cmOutputConverter::SHELL); link_command += " --verbose=$(VERBOSE)"; @@ -1577,15 +1541,28 @@ std::string cmMakefileTargetGenerator::CreateResponseFile( return responseFileName; } +cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir) +{ + if (this->Makefile->IsOn("MSVC60")) { + return this->GlobalGenerator->CreateMSVC60LinkLineComputer(outputConverter, + stateDir); + } + return this->GlobalGenerator->CreateLinkLineComputer(outputConverter, + stateDir); +} + void cmMakefileTargetGenerator::CreateLinkLibs( - std::string& linkLibs, bool relink, bool useResponseFile, - std::vector<std::string>& makefile_depends, bool useWatcomQuote) + cmLinkLineComputer* linkLineComputer, std::string& linkLibs, + bool useResponseFile, std::vector<std::string>& makefile_depends) { std::string frameworkPath; std::string linkPath; - this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, relink, - useResponseFile, useWatcomQuote); + std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + cmComputeLinkInformation* pcli = + this->GeneratorTarget->GetLinkInformation(config); + this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, + frameworkPath, linkPath); linkLibs = frameworkPath + linkPath + linkLibs; if (useResponseFile && linkLibs.find_first_not_of(' ') != linkLibs.npos) { @@ -1659,7 +1636,9 @@ void cmMakefileTargetGenerator::CreateObjectLists( } } else if (useLinkScript) { if (!useArchiveRules) { - this->WriteObjectsString(buildObjs); + std::vector<std::string> objStrings; + this->WriteObjectsStrings(objStrings); + buildObjs = objStrings[0]; } } else { buildObjs = "$("; @@ -1716,14 +1695,14 @@ void cmMakefileTargetGenerator::GenDefFile( cmd, cmOutputConverter::SHELL); cmd += " -E __create_def "; cmd += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), name_of_def_file), cmOutputConverter::SHELL); cmd += " "; std::string objlist_file = name_of_def_file; objlist_file += ".objs"; cmd += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), cmOutputConverter::SHELL); real_link_commands.insert(real_link_commands.begin(), cmd); @@ -1744,7 +1723,7 @@ void cmMakefileTargetGenerator::GenDefFile( linkFlags += " "; linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->LocalGenerator->ConvertToOutputFormat( - this->LocalGenerator->ConvertToRelativePath( + this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), name_of_def_file), cmOutputConverter::SHELL); linkFlags += " "; diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index df7b6aa..4c61011 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -20,6 +20,7 @@ class cmGeneratedFileStream; class cmGeneratorTarget; class cmGlobalUnixMakefileGenerator3; class cmSourceFile; +class cmLinkLineComputer; /** \class cmMakefileTargetGenerator * \brief Support Routines for writing makefiles @@ -112,7 +113,6 @@ protected: void WriteObjectsVariable(std::string& variableName, std::string& variableNameExternal, bool useWatcomQuote); - void WriteObjectsString(std::string& buildObjs); void WriteObjectsStrings(std::vector<std::string>& objStrings, std::string::size_type limit = std::string::npos); @@ -140,6 +140,9 @@ protected: std::vector<std::string>& makefile_commands, std::vector<std::string>& makefile_depends); + cmLinkLineComputer* CreateLinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir); + /** Create a response file with the given set of options. Returns the relative path from the target build working directory to the response file name. */ @@ -150,9 +153,9 @@ protected: bool CheckUseResponseFileForLibraries(std::string const& l) const; /** Create list of flags for link libraries. */ - void CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile, - std::vector<std::string>& makefile_depends, - bool useWatcomQuote); + void CreateLinkLibs(cmLinkLineComputer* linkLineComputer, + std::string& linkLibs, bool useResponseFile, + std::vector<std::string>& makefile_depends); /** Create lists of object files for linking and cleaning. */ void CreateObjectLists(bool useLinkScript, bool useArchiveRules, @@ -168,8 +171,6 @@ protected: const std::string& lang) CM_OVERRIDE; virtual void CloseFileStreams(); - void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang, - std::string& linkFlags); cmLocalUnixMakefileGenerator3* LocalGenerator; cmGlobalUnixMakefileGenerator3* GlobalGenerator; diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index f40c8fa..ecb29cb 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -46,7 +46,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() << this->GlobalGenerator->IncludeDirective << " " << root << cmSystemTools::ConvertToOutputPath( this->LocalGenerator - ->ConvertToRelativePath( + ->MaybeConvertToRelativePath( this->LocalGenerator->GetBinaryDirectory(), this->ProgressFileNameFull) .c_str()) diff --git a/Source/cmNinjaLinkLineComputer.cxx b/Source/cmNinjaLinkLineComputer.cxx new file mode 100644 index 0000000..3dcb20b --- /dev/null +++ b/Source/cmNinjaLinkLineComputer.cxx @@ -0,0 +1,19 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmNinjaLinkLineComputer.h" +#include "cmGlobalNinjaGenerator.h" + +cmNinjaLinkLineComputer::cmNinjaLinkLineComputer( + cmOutputConverter* outputConverter, cmState::Directory stateDir, + cmGlobalNinjaGenerator const* gg) + : cmLinkLineComputer(outputConverter, stateDir) + , GG(gg) +{ +} + +std::string cmNinjaLinkLineComputer::ConvertToLinkReference( + std::string const& lib) const +{ + return GG->ConvertToNinjaPath(lib); +} diff --git a/Source/cmNinjaLinkLineComputer.h b/Source/cmNinjaLinkLineComputer.h new file mode 100644 index 0000000..a108568 --- /dev/null +++ b/Source/cmNinjaLinkLineComputer.h @@ -0,0 +1,26 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmNinjaLinkLineComputer_h +#define cmNinjaLinkLineComputer_h + +#include "cmLinkLineComputer.h" +#include "cmState.h" + +class cmGlobalNinjaGenerator; + +class cmNinjaLinkLineComputer : public cmLinkLineComputer +{ +public: + cmNinjaLinkLineComputer(cmOutputConverter* outputConverter, + cmState::Directory stateDir, + cmGlobalNinjaGenerator const* gg); + + std::string ConvertToLinkReference(std::string const& input) const + CM_OVERRIDE; + +private: + cmGlobalNinjaGenerator const* GG; +}; + +#endif diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 095c703..d729114 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -8,6 +8,7 @@ #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmGlobalNinjaGenerator.h" +#include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmMakefile.h" @@ -315,7 +316,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() const char* linkCmd = mf->GetDefinition(linkCmdVar); if (linkCmd) { cmSystemTools::ExpandListArgument(linkCmd, linkCmds); - if (this->GetGeneratorTarget()->GetProperty("LINK_WHAT_YOU_USE")) { + if (this->GetGeneratorTarget()->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); @@ -470,9 +471,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["TARGET_FILE"] = localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL); - localGen.GetTargetFlags(this->GetConfigName(), vars["LINK_LIBRARIES"], - vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, - linkPath, &genTarget, useWatcomQuote); + CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( + this->GetGlobalGenerator()->CreateLinkLineComputer( + this->GetLocalGenerator(), + this->GetLocalGenerator()->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); + + localGen.GetTargetFlags( + linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"], + vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget); if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && (gt.GetType() == cmState::SHARED_LIBRARY || gt.IsExecutableWithExports())) { @@ -497,7 +504,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->addPoolNinjaVariable("JOB_POOL_LINK", >, vars); - this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); + this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"]); vars["LINK_FLAGS"] = cmGlobalNinjaGenerator::EncodeLiteral(vars["LINK_FLAGS"]); @@ -505,7 +512,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LINK_PATH"] = frameworkPath + linkPath; std::string lwyuFlags; - if (genTarget.GetProperty("LINK_WHAT_YOU_USE")) { + if (genTarget.GetPropertyAsBool("LINK_WHAT_YOU_USE")) { lwyuFlags = " -Wl,--no-as-needed"; } @@ -645,7 +652,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string postBuildCmdLine = localGen.BuildCommandLine(postBuildCmdLines); cmNinjaVars symlinkVars; - if (targetOutput == targetOutputReal) { + bool const symlinkNeeded = + (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple()); + if (!symlinkNeeded) { vars["POST_BUILD"] = postBuildCmdLine; } else { vars["POST_BUILD"] = ":"; @@ -687,7 +696,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() commandLineLengthLimit, &usedResponseFile); this->WriteLinkRule(usedResponseFile); - if (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple()) { + if (symlinkNeeded) { if (targetType == cmState::EXECUTABLE) { globalGen.WriteBuild( this->GetBuildFileStream(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index fb2581d..46a6161 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -427,7 +427,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) : mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); cldeps = "\""; cldeps += cmSystemTools::GetCMClDepsCommand(); - cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \""; + cldeps += "\" " + lang + " " + vars.Source + " \"$DEP_FILE\" $out \""; cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); cldeps += "\" \"" + cl + "\" "; } diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 2ef603b..84a433c 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -76,44 +76,35 @@ static bool cmOutputConverterNotAbove(const char* a, const char* b) cmSystemTools::IsSubDirectory(a, b)); } -std::string cmOutputConverter::ConvertToRelativePath( - const std::vector<std::string>& local, const std::string& in_remote, - bool force) const +bool cmOutputConverter::ContainedInDirectory(std::string const& local_path, + std::string const& remote_path, + cmState::Directory directory) { - std::string local_path = cmSystemTools::JoinPath(local); - return force ? this->ForceToRelativePath(local_path, in_remote) - : this->ConvertToRelativePath(local_path, in_remote); + const std::string relativePathTopBinary = + directory.GetRelativePathTopBinary(); + const std::string relativePathTopSource = + directory.GetRelativePathTopSource(); + + const bool bothInBinary = + cmOutputConverterNotAbove(local_path.c_str(), + relativePathTopBinary.c_str()) && + cmOutputConverterNotAbove(remote_path.c_str(), + relativePathTopBinary.c_str()); + + const bool bothInSource = + cmOutputConverterNotAbove(local_path.c_str(), + relativePathTopSource.c_str()) && + cmOutputConverterNotAbove(remote_path.c_str(), + relativePathTopSource.c_str()); + + return bothInSource || bothInBinary; } std::string cmOutputConverter::ConvertToRelativePath( std::string const& local_path, std::string const& remote_path) const { - // The paths should never be quoted. - assert(local_path[0] != '\"'); - assert(remote_path[0] != '\"'); - - // The local path should never have a trailing slash. - assert(local_path.empty() || local_path[local_path.size() - 1] != '/'); - - // If the path is already relative then just return the path. - if (!cmSystemTools::FileIsFullPath(remote_path.c_str())) { - return remote_path; - } - - // Skip conversion if the path and local are not both in the source - // or both in the binary tree. - if (!((cmOutputConverterNotAbove( - local_path.c_str(), - this->StateSnapshot.GetDirectory().GetRelativePathTopBinary()) && - cmOutputConverterNotAbove( - remote_path.c_str(), - this->StateSnapshot.GetDirectory().GetRelativePathTopBinary())) || - (cmOutputConverterNotAbove( - local_path.c_str(), - this->StateSnapshot.GetDirectory().GetRelativePathTopSource()) && - cmOutputConverterNotAbove( - remote_path.c_str(), - this->StateSnapshot.GetDirectory().GetRelativePathTopSource())))) { + if (!ContainedInDirectory(local_path, remote_path, + this->StateSnapshot.GetDirectory())) { return remote_path; } @@ -248,10 +239,11 @@ std::string cmOutputConverter::EscapeForShell(const std::string& str, if (this->GetState()->UseNMake()) { flags |= Shell_Flag_NMake; } + if (!this->GetState()->UseWindowsShell()) { + flags |= Shell_Flag_IsUnix; + } - return this->GetState()->UseWindowsShell() - ? Shell_GetArgumentForWindows(str.c_str(), flags) - : Shell_GetArgumentForUnix(str.c_str(), flags); + return Shell__GetArgument(str.c_str(), flags); } std::string cmOutputConverter::EscapeForCMake(const std::string& str) @@ -280,7 +272,7 @@ std::string cmOutputConverter::EscapeForCMake(const std::string& str) std::string cmOutputConverter::EscapeWindowsShellArgument(const char* arg, int shell_flags) { - return Shell_GetArgumentForWindows(arg, shell_flags); + return Shell__GetArgument(arg, shell_flags); } cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat( @@ -366,10 +358,10 @@ int cmOutputConverter::Shell__CharNeedsQuotesOnWindows(char c) (c == '>') || (c == '|') || (c == '^')); } -int cmOutputConverter::Shell__CharNeedsQuotes(char c, int isUnix, int flags) +int cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags) { /* On Windows the built-in command shell echo never needs quotes. */ - if (!isUnix && (flags & Shell_Flag_EchoWindows)) { + if (!(flags & Shell_Flag_IsUnix) && (flags & Shell_Flag_EchoWindows)) { return 0; } @@ -378,7 +370,7 @@ int cmOutputConverter::Shell__CharNeedsQuotes(char c, int isUnix, int flags) return 1; } - if (isUnix) { + if (flags & Shell_Flag_IsUnix) { /* On UNIX several special characters need quotes to preserve them. */ if (Shell__CharNeedsQuotesOnUnix(c)) { return 1; @@ -436,8 +428,7 @@ flag later when we understand applications of this better. */ #define KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES 0 -int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix, - int flags) +int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int flags) { /* The empty string needs quotes. */ if (!*in) { @@ -469,14 +460,14 @@ int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix, } /* Check whether this character needs quotes. */ - if (Shell__CharNeedsQuotes(*c, isUnix, flags)) { + if (Shell__CharNeedsQuotes(*c, flags)) { return 1; } } } /* On Windows some single character arguments need quotes. */ - if (!isUnix && *in && !*(in + 1)) { + if (flags & Shell_Flag_IsUnix && *in && !*(in + 1)) { char c = *in; if ((c == '?') || (c == '&') || (c == '^') || (c == '|') || (c == '#')) { return 1; @@ -486,8 +477,7 @@ int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int isUnix, return 0; } -std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix, - int flags) +std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags) { std::ostringstream out; @@ -498,11 +488,11 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix, int windows_backslashes = 0; /* Whether the argument must be quoted. */ - int needQuotes = Shell__ArgumentNeedsQuotes(in, isUnix, flags); + int needQuotes = Shell__ArgumentNeedsQuotes(in, flags); if (needQuotes) { /* Add the opening quote for this argument. */ if (flags & Shell_Flag_WatcomQuote) { - if (isUnix) { + if (flags & Shell_Flag_IsUnix) { out << '"'; } out << '\''; @@ -534,7 +524,7 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix, } /* Check whether this character needs escaping for the shell. */ - if (isUnix) { + if (flags & Shell_Flag_IsUnix) { /* On Unix a few special characters need escaping even inside a quoted argument. */ if (*c == '\\' || *c == '"' || *c == '`' || *c == '$') { @@ -631,7 +621,7 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix, /* Add the closing quote for this argument. */ if (flags & Shell_Flag_WatcomQuote) { out << '\''; - if (isUnix) { + if (flags & Shell_Flag_IsUnix) { out << '"'; } } else { @@ -641,15 +631,3 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int isUnix, return out.str(); } - -std::string cmOutputConverter::Shell_GetArgumentForWindows(const char* in, - int flags) -{ - return Shell__GetArgument(in, 0, flags); -} - -std::string cmOutputConverter::Shell_GetArgumentForUnix(const char* in, - int flags) -{ - return Shell__GetArgument(in, 1, flags); -} diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 5979eaa..71cacab 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -33,8 +33,7 @@ public: void SetLinkScriptShell(bool linkScriptShell); /** - * Flags to pass to Shell_GetArgumentForWindows or - * Shell_GetArgumentForUnix. These modify the generated + * Flags to pass to Shell_GetArgument. These modify the generated * quoting and escape sequences to work under alternative * environments. */ @@ -67,18 +66,10 @@ public: Shell_Flag_AllowMakeVariables = (1 << 6), /** The target shell quoting uses extra single Quotes for Watcom tools. */ - Shell_Flag_WatcomQuote = (1 << 7) - }; + Shell_Flag_WatcomQuote = (1 << 7), - /** - * Transform the given command line argument for use in a Windows or - * Unix shell. Returns a pointer to the end of the command line - * argument in the provided output buffer. Flags may be passed to - * modify the generated quoting and escape sequences to work under - * alternative environments. - */ - static std::string Shell_GetArgumentForWindows(const char* in, int flags); - static std::string Shell_GetArgumentForUnix(const char* in, int flags); + Shell_Flag_IsUnix = (1 << 8) + }; std::string EscapeForShell(const std::string& str, bool makeVars = false, bool forEcho = false, @@ -99,16 +90,9 @@ public: }; static FortranFormat GetFortranFormat(const char* value); - /** - * Convert the given remote path to a relative path with respect to - * the given local path. The local path must be given in component - * form (see SystemTools::SplitPath) without a trailing slash. The - * remote path must use forward slashes and not already be escaped - * or quoted. - */ - std::string ConvertToRelativePath(const std::vector<std::string>& local, - const std::string& in_remote, - bool force = false) const; + static bool ContainedInDirectory(std::string const& local_path, + std::string const& remote_path, + cmState::Directory directory); /** * Convert the given remote path to a relative path with respect to @@ -134,11 +118,11 @@ private: static int Shell__CharIsWhitespace(char c); static int Shell__CharNeedsQuotesOnUnix(char c); static int Shell__CharNeedsQuotesOnWindows(char c); - static int Shell__CharNeedsQuotes(char c, int isUnix, int flags); + static int Shell__CharNeedsQuotes(char c, int flags); static int Shell__CharIsMakeVariableName(char c); static const char* Shell__SkipMakeVariables(const char* c); - static int Shell__ArgumentNeedsQuotes(const char* in, int isUnix, int flags); - static std::string Shell__GetArgument(const char* in, int isUnix, int flags); + static int Shell__ArgumentNeedsQuotes(const char* in, int flags); + static std::string Shell__GetArgument(const char* in, int flags); private: cmState::Snapshot StateSnapshot; diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index c9822d3..a814d16 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -30,7 +30,7 @@ void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf) if (nread >= 0) { conn->ReadData(std::string(buf->base, buf->base + nread)); } else { - conn->HandleEof(); + conn->TriggerShutdown(); } delete[](buf->base); @@ -56,6 +56,28 @@ void on_new_connection(uv_stream_t* stream, int status) conn->Connect(stream); } +void on_signal(uv_signal_t* signal, int signum) +{ + auto conn = reinterpret_cast<cmServerConnection*>(signal->data); + (void)(signum); + conn->TriggerShutdown(); +} + +void on_signal_close(uv_handle_t* handle) +{ + delete reinterpret_cast<uv_signal_t*>(handle); +} + +void on_pipe_close(uv_handle_t* handle) +{ + delete reinterpret_cast<uv_pipe_t*>(handle); +} + +void on_tty_close(uv_handle_t* handle) +{ + delete reinterpret_cast<uv_tty_t*>(handle); +} + } // namespace class LoopGuard @@ -64,19 +86,25 @@ public: LoopGuard(cmServerConnection* connection) : Connection(connection) { - Connection->mLoop = uv_default_loop(); - if (Connection->mLoop) { - Connection->mFileMonitor = new cmFileMonitor(Connection->mLoop); + this->Connection->mLoop = uv_default_loop(); + if (!this->Connection->mLoop) { + return; } + this->Connection->mFileMonitor = + new cmFileMonitor(this->Connection->mLoop); } ~LoopGuard() { - if (Connection->mFileMonitor) { - delete Connection->mFileMonitor; + if (!this->Connection->mLoop) { + return; } - uv_loop_close(Connection->mLoop); - Connection->mLoop = nullptr; + + if (this->Connection->mFileMonitor) { + delete this->Connection->mFileMonitor; + } + uv_loop_close(this->Connection->mLoop); + this->Connection->mLoop = nullptr; } private: @@ -111,6 +139,16 @@ bool cmServerConnection::ProcessEvents(std::string* errorMessage) return false; } + this->SIGINTHandler = new uv_signal_t; + uv_signal_init(this->mLoop, this->SIGINTHandler); + this->SIGINTHandler->data = static_cast<void*>(this); + uv_signal_start(this->SIGINTHandler, &on_signal, SIGINT); + + this->SIGHUPHandler = new uv_signal_t; + uv_signal_init(this->mLoop, this->SIGHUPHandler); + this->SIGHUPHandler->data = static_cast<void*>(this); + uv_signal_start(this->SIGHUPHandler, &on_signal, SIGHUP); + if (!DoSetup(errorMessage)) { return false; } @@ -162,9 +200,21 @@ void cmServerConnection::ReadData(const std::string& data) } } -void cmServerConnection::HandleEof() +void cmServerConnection::TriggerShutdown() { this->FileMonitor()->StopMonitoring(); + + uv_signal_stop(this->SIGINTHandler); + uv_signal_stop(this->SIGHUPHandler); + + uv_close(reinterpret_cast<uv_handle_t*>(this->SIGINTHandler), + &on_signal_close); // delete handle + uv_close(reinterpret_cast<uv_handle_t*>(this->SIGHUPHandler), + &on_signal_close); // delete handle + + this->SIGINTHandler = nullptr; + this->SIGHUPHandler = nullptr; + this->TearDown(); } @@ -194,30 +244,42 @@ void cmServerConnection::SendGreetings() Server->PrintHello(); } +cmServerStdIoConnection::cmServerStdIoConnection() +{ + this->Input.tty = nullptr; + this->Output.tty = nullptr; +} + bool cmServerStdIoConnection::DoSetup(std::string* errorMessage) { (void)(errorMessage); if (uv_guess_handle(1) == UV_TTY) { - uv_tty_init(this->Loop(), &this->Input.tty, 0, 1); - uv_tty_set_mode(&this->Input.tty, UV_TTY_MODE_NORMAL); - Input.tty.data = this; - this->ReadStream = reinterpret_cast<uv_stream_t*>(&this->Input.tty); - - uv_tty_init(this->Loop(), &this->Output.tty, 1, 0); - uv_tty_set_mode(&this->Output.tty, UV_TTY_MODE_NORMAL); - Output.tty.data = this; - this->WriteStream = reinterpret_cast<uv_stream_t*>(&this->Output.tty); + usesTty = true; + this->Input.tty = new uv_tty_t; + uv_tty_init(this->Loop(), this->Input.tty, 0, 1); + uv_tty_set_mode(this->Input.tty, UV_TTY_MODE_NORMAL); + Input.tty->data = this; + this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.tty); + + this->Output.tty = new uv_tty_t; + uv_tty_init(this->Loop(), this->Output.tty, 1, 0); + uv_tty_set_mode(this->Output.tty, UV_TTY_MODE_NORMAL); + Output.tty->data = this; + this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.tty); } else { - uv_pipe_init(this->Loop(), &this->Input.pipe, 0); - uv_pipe_open(&this->Input.pipe, 0); - Input.pipe.data = this; - this->ReadStream = reinterpret_cast<uv_stream_t*>(&this->Input.pipe); - - uv_pipe_init(this->Loop(), &this->Output.pipe, 0); - uv_pipe_open(&this->Output.pipe, 1); - Output.pipe.data = this; - this->WriteStream = reinterpret_cast<uv_stream_t*>(&this->Output.pipe); + usesTty = false; + this->Input.pipe = new uv_pipe_t; + uv_pipe_init(this->Loop(), this->Input.pipe, 0); + uv_pipe_open(this->Input.pipe, 0); + Input.pipe->data = this; + this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.pipe); + + this->Output.pipe = new uv_pipe_t; + uv_pipe_init(this->Loop(), this->Output.pipe, 0); + uv_pipe_open(this->Output.pipe, 1); + Output.pipe->data = this; + this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.pipe); } SendGreetings(); @@ -228,26 +290,35 @@ bool cmServerStdIoConnection::DoSetup(std::string* errorMessage) void cmServerStdIoConnection::TearDown() { - uv_close(reinterpret_cast<uv_handle_t*>(this->ReadStream), nullptr); + if (usesTty) { + uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty), &on_tty_close); + uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty), &on_tty_close); + this->Input.tty = nullptr; + this->Output.tty = nullptr; + } else { + uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe), &on_pipe_close); + uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe), + &on_pipe_close); + this->Input.pipe = nullptr; + this->Input.pipe = nullptr; + } this->ReadStream = nullptr; - uv_close(reinterpret_cast<uv_handle_t*>(this->WriteStream), nullptr); this->WriteStream = nullptr; } cmServerPipeConnection::cmServerPipeConnection(const std::string& name) : PipeName(name) { - this->ServerPipe.data = nullptr; - this->ClientPipe.data = nullptr; } bool cmServerPipeConnection::DoSetup(std::string* errorMessage) { - uv_pipe_init(this->Loop(), &this->ServerPipe, 0); - this->ServerPipe.data = this; + this->ServerPipe = new uv_pipe_t; + uv_pipe_init(this->Loop(), this->ServerPipe, 0); + this->ServerPipe->data = this; int r; - if ((r = uv_pipe_bind(&this->ServerPipe, this->PipeName.c_str())) != 0) { + if ((r = uv_pipe_bind(this->ServerPipe, this->PipeName.c_str())) != 0) { *errorMessage = std::string("Internal Error with ") + this->PipeName + ": " + uv_err_name(r); return false; @@ -265,31 +336,34 @@ bool cmServerPipeConnection::DoSetup(std::string* errorMessage) void cmServerPipeConnection::TearDown() { - if (this->WriteStream->data) { - uv_close(reinterpret_cast<uv_handle_t*>(this->WriteStream), nullptr); + if (this->ClientPipe) { + uv_close(reinterpret_cast<uv_handle_t*>(this->ClientPipe), &on_pipe_close); this->WriteStream->data = nullptr; } - uv_close(reinterpret_cast<uv_handle_t*>(&this->ServerPipe), nullptr); + uv_close(reinterpret_cast<uv_handle_t*>(&this->ServerPipe), &on_pipe_close); + this->ClientPipe = nullptr; + this->ServerPipe = nullptr; this->WriteStream = nullptr; this->ReadStream = nullptr; } void cmServerPipeConnection::Connect(uv_stream_t* server) { - if (this->ClientPipe.data == this) { + if (this->ClientPipe) { // Accept and close all pipes but the first: - uv_pipe_t rejectPipe; + uv_pipe_t* rejectPipe = new uv_pipe_t; - uv_pipe_init(this->Loop(), &rejectPipe, 0); - auto rejecter = reinterpret_cast<uv_stream_t*>(&rejectPipe); + uv_pipe_init(this->Loop(), rejectPipe, 0); + auto rejecter = reinterpret_cast<uv_stream_t*>(rejectPipe); uv_accept(server, rejecter); - uv_close(reinterpret_cast<uv_handle_t*>(rejecter), nullptr); + uv_close(reinterpret_cast<uv_handle_t*>(rejecter), &on_pipe_close); return; } - uv_pipe_init(this->Loop(), &this->ClientPipe, 0); - this->ClientPipe.data = this; + this->ClientPipe = new uv_pipe_t; + uv_pipe_init(this->Loop(), this->ClientPipe, 0); + this->ClientPipe->data = this; auto client = reinterpret_cast<uv_stream_t*>(&this->ClientPipe); if (uv_accept(server, client) != 0) { uv_close(reinterpret_cast<uv_handle_t*>(client), nullptr); diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h index 78842e7..3efe28d 100644 --- a/Source/cmServerConnection.h +++ b/Source/cmServerConnection.h @@ -24,7 +24,7 @@ public: bool ProcessEvents(std::string* errorMessage); void ReadData(const std::string& data); - void HandleEof(); + void TriggerShutdown(); void WriteData(const std::string& data); void ProcessNextRequest(); @@ -51,6 +51,8 @@ private: uv_loop_t* mLoop = nullptr; cmFileMonitor* mFileMonitor = nullptr; cmServer* Server = nullptr; + uv_signal_t* SIGINTHandler = nullptr; + uv_signal_t* SIGHUPHandler = nullptr; friend class LoopGuard; }; @@ -58,6 +60,7 @@ private: class cmServerStdIoConnection : public cmServerConnection { public: + cmServerStdIoConnection(); bool DoSetup(std::string* errorMessage) override; void TearDown() override; @@ -65,10 +68,12 @@ public: private: typedef union { - uv_tty_t tty; - uv_pipe_t pipe; + uv_tty_t* tty; + uv_pipe_t* pipe; } InOutUnion; + bool usesTty = false; + InOutUnion Input; InOutUnion Output; }; @@ -85,6 +90,6 @@ public: private: const std::string PipeName; - uv_pipe_t ServerPipe; - uv_pipe_t ClientPipe; + uv_pipe_t* ServerPipe = nullptr; + uv_pipe_t* ClientPipe = nullptr; }; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index a2bdf49..e0fcb75 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -7,6 +7,7 @@ #include "cmFileMonitor.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmLinkLineComputer.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -728,8 +729,10 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, std::string linkLanguageFlags; std::string frameworkPath; std::string linkPath; - lg->GetTargetFlags(config, linkLibs, linkLanguageFlags, linkFlags, - frameworkPath, linkPath, target, false); + cmLinkLineComputer linkLineComputer(lg, + lg->GetStateSnapshot().GetDirectory()); + lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags, + linkFlags, frameworkPath, linkPath, target); linkLibs = cmSystemTools::TrimWhitespace(linkLibs); linkFlags = cmSystemTools::TrimWhitespace(linkFlags); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3d8fdf5..0a3a1ab 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1499,6 +1499,7 @@ void list_item_verbose(FILE* out, struct archive_entry* entry) { fprintf(out, " -> %s", archive_entry_symlink(entry)); } + fflush(out); } long copy_data(struct archive* ar, struct archive* aw) @@ -2518,9 +2519,9 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, std::swap(se[0], se[1]); } - // Get the size of the dynamic section header. - unsigned int count = elf.GetDynamicEntryCount(); - if (count == 0) { + // Obtain a copy of the dynamic entries + cmELF::DynamicEntryList dentries = elf.GetDynamicEntries(); + if (dentries.empty()) { // This should happen only for invalid ELF files where a DT_NULL // appears before the end of the table. if (emsg) { @@ -2536,40 +2537,46 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, zeroSize[i] = se[i]->Size; } - // Get the range of file positions corresponding to each entry and - // the rest of the table after them. - unsigned long entryBegin[3] = { 0, 0, 0 }; - unsigned long entryEnd[2] = { 0, 0 }; - for (int i = 0; i < se_count; ++i) { - entryBegin[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection); - entryEnd[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection + 1); - } - entryBegin[se_count] = elf.GetDynamicEntryPosition(count); - - // The data are to be written over the old table entries starting at - // the first one being removed. - bytesBegin = entryBegin[0]; - unsigned long bytesEnd = entryBegin[se_count]; + // Get size of one DYNAMIC entry + unsigned long const sizeof_dentry = + elf.GetDynamicEntryPosition(1) - elf.GetDynamicEntryPosition(0); - // Allocate a buffer to hold the part of the file to be written. - // Initialize it with zeros. - bytes.resize(bytesEnd - bytesBegin, 0); - - // Read the part of the DYNAMIC section header that will move. - // The remainder of the buffer will be left with zeros which - // represent a DT_NULL entry. - char* data = &bytes[0]; - for (int i = 0; i < se_count; ++i) { - // Read data between the entries being removed. - unsigned long sz = entryBegin[i + 1] - entryEnd[i]; - if (sz > 0 && !elf.ReadBytes(entryEnd[i], sz, data)) { - if (emsg) { - *emsg = "Failed to read DYNAMIC section header."; + // Adjust the entry list as necessary to remove the run path + unsigned long entriesErased = 0; + for (cmELF::DynamicEntryList::iterator it = dentries.begin(); + it != dentries.end();) { + if (it->first == cmELF::TagRPath || it->first == cmELF::TagRunPath) { + it = dentries.erase(it); + entriesErased++; + continue; + } else { + if (cmELF::TagMipsRldMapRel != 0 && + it->first == cmELF::TagMipsRldMapRel) { + // Background: debuggers need to know the "linker map" which contains + // the addresses each dynamic object is loaded at. Most arches use + // the DT_DEBUG tag which the dynamic linker writes to (directly) and + // contain the location of the linker map, however on MIPS the + // .dynamic section is always read-only so this is not possible. MIPS + // objects instead contain a DT_MIPS_RLD_MAP tag which contains the + // address where the dyanmic linker will write to (an indirect + // version of DT_DEBUG). Since this doesn't work when using PIE, a + // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this + // version contains a relative offset, moving it changes the + // calculated address. This may cause the dyanmic linker to write + // into memory it should not be changing. + // + // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If + // we move it up by n bytes, we add n bytes to the value of this tag. + it->second += entriesErased * sizeof_dentry; } - return false; + + it++; } - data += sz; } + + // Encode new entries list + bytes = elf.EncodeDynamicEntries(dentries); + bytesBegin = elf.GetDynamicEntryPosition(0); } // Open the file for update. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54e0bea..651bcc8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -102,6 +102,7 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, this->SetPropertyDefault("ANDROID_JAR_DEPENDENCIES", CM_NULLPTR); this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", CM_NULLPTR); this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", CM_NULLPTR); + this->SetPropertyDefault("BUILD_RPATH", CM_NULLPTR); this->SetPropertyDefault("INSTALL_NAME_DIR", CM_NULLPTR); this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); @@ -475,23 +476,6 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) return this->Makefile->GetOrCreateSource(src); } -void cmTarget::MergeLinkLibraries(cmMakefile& mf, const std::string& selfname, - const LinkLibraryVectorType& libs) -{ - // Only add on libraries we haven't added on before. - // Assumption: the global link libraries could only grow, never shrink - LinkLibraryVectorType::const_iterator i = libs.begin(); - i += this->PrevLinkedLibraries.size(); - for (; i != libs.end(); ++i) { - // This is equivalent to the target_link_libraries plain signature. - this->AddLinkLibrary(mf, selfname, i->first, i->second); - this->AppendProperty( - "INTERFACE_LINK_LIBRARIES", - this->GetDebugGeneratorExpressions(i->first, i->second).c_str()); - } - this->PrevLinkedLibraries = libs; -} - void cmTarget::AddLinkDirectory(const std::string& d) { // Make sure we don't add unnecessary search directories. @@ -594,8 +578,7 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const } } -void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& target, - const std::string& lib, +void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib, cmTargetLinkLibraryType llt) { cmTarget* tgt = this->Makefile->FindTargetToUse(lib); @@ -613,7 +596,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& target, if (cmGeneratorExpression::Find(lib) != std::string::npos || (tgt && tgt->GetType() == cmState::INTERFACE_LIBRARY) || - (target == lib)) { + (this->Name == lib)) { return; } @@ -631,7 +614,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& target, // and we removing one instance will break the link line. Duplicates // will be appropriately eliminated at emit time. if (this->RecordDependencies) { - std::string targetEntry = target; + std::string targetEntry = this->Name; targetEntry += "_LIB_DEPENDS"; std::string dependencies; const char* old_val = mf.GetDefinition(targetEntry); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dd9097a..3d88688 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -142,8 +142,8 @@ public: */ void ClearDependencyInformation(cmMakefile& mf, const std::string& target); - void AddLinkLibrary(cmMakefile& mf, const std::string& target, - const std::string& lib, cmTargetLinkLibraryType llt); + void AddLinkLibrary(cmMakefile& mf, const std::string& lib, + cmTargetLinkLibraryType llt); enum TLLSignature { KeywordTLLSignature, @@ -153,9 +153,6 @@ public: cmListFileContext const& lfc); void GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const; - void MergeLinkLibraries(cmMakefile& mf, const std::string& selfname, - const LinkLibraryVectorType& libs); - const std::vector<std::string>& GetLinkDirectories() const; void AddLinkDirectory(const std::string& d); @@ -299,7 +296,6 @@ private: std::vector<cmCustomCommand> PreLinkCommands; std::vector<cmCustomCommand> PostBuildCommands; std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands; - LinkLibraryVectorType PrevLinkedLibraries; LinkLibraryVectorType OriginalLinkLibraries; cmMakefile* Makefile; cmTargetInternalPointer Internal; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index e714309..d1de7ef 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -338,7 +338,35 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, // Handle normal case first. if (this->CurrentProcessingState != ProcessingKeywordLinkInterface && this->CurrentProcessingState != ProcessingPlainLinkInterface) { - this->Makefile->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); + + cmTarget* t = + this->Makefile->FindLocalNonAliasTarget(this->Target->GetName()); + if (!t) { + std::ostringstream e; + e << "Attempt to add link library \"" << lib << "\" to target \"" + << this->Target->GetName() + << "\" which is not built in this directory."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + } else { + + cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(lib); + + if (tgt && (tgt->GetType() != cmState::STATIC_LIBRARY) && + (tgt->GetType() != cmState::SHARED_LIBRARY) && + (tgt->GetType() != cmState::INTERFACE_LIBRARY) && + !tgt->IsExecutableWithExports()) { + std::ostringstream e; + e << "Target \"" << lib << "\" of type " + << cmState::GetTargetTypeName(tgt->GetType()) + << " may not be linked into another target. " + << "One may link only to STATIC or SHARED libraries, or " + << "to executables with the ENABLE_EXPORTS property set."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + } + + this->Target->AddLinkLibrary(*this->Makefile, lib, llt); + } + if (this->CurrentProcessingState == ProcessingLinkLibraries) { this->Target->AppendProperty( "INTERFACE_LINK_LIBRARIES", diff --git a/Source/cmVS140CLFlagTable.h b/Source/cmVS140CLFlagTable.h new file mode 100644 index 0000000..317cc18 --- /dev/null +++ b/Source/cmVS140CLFlagTable.h @@ -0,0 +1,237 @@ +static cmVS7FlagTable cmVS140CLFlagTable[] = { + + // Enum Properties + { "DebugInformationFormat", "", "None", "None", 0 }, + { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 }, + { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 }, + { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue", + "EditAndContinue", 0 }, + + { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 }, + { "WarningLevel", "W1", "Level1", "Level1", 0 }, + { "WarningLevel", "W2", "Level2", "Level2", 0 }, + { "WarningLevel", "W3", "Level3", "Level3", 0 }, + { "WarningLevel", "W4", "Level4", "Level4", 0 }, + { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 }, + + { "Optimization", "", "Custom", "Custom", 0 }, + { "Optimization", "Od", "Disabled", "Disabled", 0 }, + { "Optimization", "O1", "Minimize Size", "MinSpace", 0 }, + { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 }, + { "Optimization", "Ox", "Full Optimization", "Full", 0 }, + + { "InlineFunctionExpansion", "", "Default", "Default", 0 }, + { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 }, + { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline", + 0 }, + { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 }, + + { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 }, + { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 }, + { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 }, + + { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 }, + { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 }, + { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow", + 0 }, + { "ExceptionHandling", "", "No", "false", 0 }, + + { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck", + 0 }, + { "BasicRuntimeChecks", "RTCu", "Uninitialized variables", + "UninitializedLocalUsageCheck", 0 }, + { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)", + "EnableFastChecks", 0 }, + { "BasicRuntimeChecks", "", "Default", "Default", 0 }, + + { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 }, + { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 }, + { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 }, + { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL", + "MultiThreadedDebugDLL", 0 }, + + { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 }, + { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 }, + { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 }, + { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 }, + { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 }, + { "StructMemberAlignment", "", "Default", "Default", 0 }, + + { "BufferSecurityCheck", "GS-", "Disable Security Check", "false", 0 }, + { "BufferSecurityCheck", "GS", "Enable Security Check", "true", 0 }, + + { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions", + "StreamingSIMDExtensions", 0 }, + { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2", + "StreamingSIMDExtensions2", 0 }, + { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions", + "AdvancedVectorExtensions", 0 }, + { "EnableEnhancedInstructionSet", "arch:AVX2", + "Advanced Vector Extensions 2", "AdvancedVectorExtensions2", 0 }, + { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions", + "NoExtensions", 0 }, + { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 }, + + { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 }, + { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 }, + { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 }, + + { "PrecompiledHeader", "Yc", "Create", "Create", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "PrecompiledHeader", "Yu", "Use", "Use", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 }, + + { "AssemblerOutput", "", "No Listing", "NoListing", 0 }, + { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 }, + { "AssemblerOutput", "FAc", "Assembly With Machine Code", + "AssemblyAndMachineCode", 0 }, + { "AssemblerOutput", "FAs", "Assembly With Source Code", + "AssemblyAndSourceCode", 0 }, + { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 }, + + { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 }, + { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 }, + { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 }, + { "CallingConvention", "Gv", "__vectorcall", "VectorCall", 0 }, + + { "CompileAs", "", "Default", "Default", 0 }, + { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 }, + { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 }, + + { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 }, + { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt", + 0 }, + { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue", + 0 }, + { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 }, + + { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 }, + { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 }, + { "CompileAsManaged", "clr:pure", + "Pure MSIL Common Language RunTime Support", "Pure", 0 }, + { "CompileAsManaged", "clr:safe", + "Safe MSIL Common Language RunTime Support", "Safe", 0 }, + { "CompileAsManaged", "clr:oldSyntax", + "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 }, + + { "CppLanguageStandard", "", "Default", "Default", 0 }, + { "CppLanguageStandard", "std=c++98", "C++03", "c++98", 0 }, + { "CppLanguageStandard", "std=c++11", "C++11", "c++11", 0 }, + { "CppLanguageStandard", "std=c++1y", "C++14", "c++1y", 0 }, + { "CppLanguageStandard", "std=c++14", "C++14", "c++1y", 0 }, + { "CppLanguageStandard", "std=gnu++98", "C++03 (GNU Dialect)", "gnu++98", + 0 }, + { "CppLanguageStandard", "std=gnu++11", "C++11 (GNU Dialect)", "gnu++11", + 0 }, + { "CppLanguageStandard", "std=gnu++1y", "C++14 (GNU Dialect)", "gnu++1y", + 0 }, + { "CppLanguageStandard", "std=gnu++14", "C++14 (GNU Dialect)", "gnu++1y", + 0 }, + + // Bool Properties + { "CompileAsWinRT", "ZW", "", "true", 0 }, + { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 }, + { "SuppressStartupBanner", "nologo", "", "true", 0 }, + { "TreatWarningAsError", "WX-", "", "false", 0 }, + { "TreatWarningAsError", "WX", "", "true", 0 }, + { "SDLCheck", "sdl-", "", "false", 0 }, + { "SDLCheck", "sdl", "", "true", 0 }, + { "IntrinsicFunctions", "Oi", "", "true", 0 }, + { "OmitFramePointers", "Oy-", "", "false", 0 }, + { "OmitFramePointers", "Oy", "", "true", 0 }, + { "EnableFiberSafeOptimizations", "GT", "", "true", 0 }, + { "WholeProgramOptimization", "GL", "", "true", 0 }, + { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 }, + { "IgnoreStandardIncludePath", "X", "", "true", 0 }, + { "PreprocessToFile", "P", "", "true", 0 }, + { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 }, + { "PreprocessKeepComments", "C", "", "true", 0 }, + { "StringPooling", "GF-", "", "false", 0 }, + { "StringPooling", "GF", "", "true", 0 }, + { "MinimalRebuild", "Gm-", "", "false", 0 }, + { "MinimalRebuild", "Gm", "", "true", 0 }, + { "SmallerTypeCheck", "RTCc", "", "true", 0 }, + { "FunctionLevelLinking", "Gy-", "", "false", 0 }, + { "FunctionLevelLinking", "Gy", "", "true", 0 }, + { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 }, + { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 }, + { "FloatingPointExceptions", "fp:except-", "", "false", 0 }, + { "FloatingPointExceptions", "fp:except", "", "true", 0 }, + { "CreateHotpatchableImage", "hotpatch", "", "true", 0 }, + { "DisableLanguageExtensions", "Za", "", "true", 0 }, + { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 }, + { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 }, + { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 }, + { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 }, + { "RuntimeTypeInfo", "GR-", "", "false", 0 }, + { "RuntimeTypeInfo", "GR", "", "true", 0 }, + { "OpenMPSupport", "openmp-", "", "false", 0 }, + { "OpenMPSupport", "openmp", "", "true", 0 }, + { "ExpandAttributedSource", "Fx", "", "true", 0 }, + { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 }, + { "ShowIncludes", "showIncludes", "", "true", 0 }, + { "EnablePREfast", "analyze-", "", "false", 0 }, + { "EnablePREfast", "analyze", "", "true", 0 }, + { "UseFullPaths", "FC", "", "true", 0 }, + { "OmitDefaultLibName", "Zl", "", "true", 0 }, + + // Bool Properties With Argument + { "MultiProcessorCompilation", "MP", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "ProcessorNumber", "MP", "Multi-processor Compilation", "", + cmVS7FlagTable::UserValueRequired }, + { "GenerateXMLDocumentationFiles", "doc", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "", + cmVS7FlagTable::UserValueRequired }, + { "BrowseInformation", "FR", "", "true", + cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue }, + { "BrowseInformationFile", "FR", "Enable Browse Information", "", + cmVS7FlagTable::UserValueRequired }, + + // String List Properties + { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "UndefinePreprocessorDefinitions", "U", + "Undefine Preprocessor Definitions", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "ForcedIncludeFiles", "FI", "Forced Include File", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "ForcedUsingFiles", "FU", "Forced #using File", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "PREfastLog", "analyze:log", "Code Analysis Log", "", + cmVS7FlagTable::UserFollowing }, + { "PREfastAdditionalPlugins", "analyze:plugin", + "Additional Code Analysis Native plugins", "", + cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors", + "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable }, + + // String Properties + // Skip [TrackerLogDirectory] - no command line Switch. + { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "", + cmVS7FlagTable::UserValue }, + { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "", + cmVS7FlagTable::UserValueRequired }, + { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "", + cmVS7FlagTable::UserValueRequired }, + { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "", + cmVS7FlagTable::UserValue }, + { "AssemblerListingLocation", "Fa", "ASM List Location", "", + cmVS7FlagTable::UserValue }, + { "ObjectFileName", "Fo", "Object File Name", "", + cmVS7FlagTable::UserValue }, + { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "", + cmVS7FlagTable::UserValue }, + // Skip [XMLDocumentationFileName] - no command line Switch. + // Skip [BrowseInformationFile] - no command line Switch. + // Skip [AdditionalOptions] - no command line Switch. + { 0, 0, 0, 0, 0 } +}; diff --git a/Source/cmVS14CLFlagTable.h b/Source/cmVS141CLFlagTable.h index c48db68..895b3e8 100644 --- a/Source/cmVS14CLFlagTable.h +++ b/Source/cmVS141CLFlagTable.h @@ -1,4 +1,4 @@ -static cmVS7FlagTable cmVS14CLFlagTable[] = { +static cmVS7FlagTable cmVS141CLFlagTable[] = { // Enum Properties { "DebugInformationFormat", "", "None", "None", 0 }, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d81f59d..8524ecc 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -25,7 +25,8 @@ #include "cmVS12LinkFlagTable.h" #include "cmVS12MASMFlagTable.h" #include "cmVS12RCFlagTable.h" -#include "cmVS14CLFlagTable.h" +#include "cmVS140CLFlagTable.h" +#include "cmVS141CLFlagTable.h" #include "cmVS14LibFlagTable.h" #include "cmVS14LinkFlagTable.h" #include "cmVS14MASMFlagTable.h" @@ -43,7 +44,13 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const cmGlobalVisualStudioGenerator::VSVersion v = this->LocalGenerator->GetVersion(); if (v >= cmGlobalVisualStudioGenerator::VS14) { - return cmVS14CLFlagTable; + // FIXME: All flag table selection should be based on the toolset name. + // See issue #16153. For now, treat VS 15's toolset as a special case. + const char* toolset = this->GlobalGenerator->GetPlatformToolset(); + if (toolset && cmHasLiteralPrefix(toolset, "v141")) { + return cmVS141CLFlagTable; + } + return cmVS140CLFlagTable; } else if (v >= cmGlobalVisualStudioGenerator::VS12) { return cmVS12CLFlagTable; } else if (v == cmGlobalVisualStudioGenerator::VS11) { @@ -322,6 +329,15 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("</PropertyGroup>\n", 1); } + if (const char* hostArch = + this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) { + this->WriteString("<PropertyGroup>\n", 1); + this->WriteString("<PreferredToolArchitecture>", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(hostArch) + << "</PreferredToolArchitecture>\n"; + this->WriteString("</PropertyGroup>\n", 1); + } + this->WriteProjectConfigurations(); this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1); this->WriteString("<ProjectGUID>", 2); @@ -2736,8 +2752,10 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) << "\\</AppxPackageArtifactsDir>\n"; this->WriteString("<ProjectPriFullPath>", 2); - (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) - << "\\resources.pri</ProjectPriFullPath>\n"; + std::string resourcePriFile = + this->DefaultArtifactDir + "/resources.pri"; + this->ConvertToWindowsSlash(resourcePriFile); + (*this->BuildFileStream) << resourcePriFile << "</ProjectPriFullPath>\n"; // If we are missing files and we don't have a certificate and // aren't targeting WP8.0, add a default certificate diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx new file mode 100644 index 0000000..869dd32 --- /dev/null +++ b/Source/cm_codecvt.cxx @@ -0,0 +1,215 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cm_codecvt.hxx" +#include <limits> + +#if defined(_WIN32) +#include <windows.h> +#undef max +#include <cmsys/Encoding.hxx> +#endif + +codecvt::codecvt(Encoding e) + : m_lastState(0) +#if defined(_WIN32) + , m_codepage(0) +#endif +{ + switch (e) { + case codecvt::ANSI: +#if defined(_WIN32) + m_noconv = false; + m_codepage = CP_ACP; + break; +#endif + // We don't know which ANSI encoding to use for other platforms than + // Windows so we don't do any conversion there + case codecvt::UTF8: + // Assume internal encoding is UTF-8 + case codecvt::None: + // No encoding + default: + m_noconv = true; + } +} + +codecvt::~codecvt(){}; + +bool codecvt::do_always_noconv() const throw() +{ + return m_noconv; +}; + +std::codecvt_base::result codecvt::do_out(mbstate_t& state, const char* from, + const char* from_end, + const char*& from_next, char* to, + char* to_end, char*& to_next) const +{ + if (m_noconv) { + return noconv; + } + std::codecvt_base::result res = error; +#if defined(_WIN32) + from_next = from; + to_next = to; + bool convert = true; + size_t count = from_end - from; + const char* data = from; + unsigned int& stateId = reinterpret_cast<unsigned int&>(state); + if (count == 0) { + return codecvt::ok; + } else if (count == 1) { + if (stateId == 0) { + // decode first byte for UTF-8 + if ((*from & 0xF8) == 0xF0 || // 1111 0xxx; 4 bytes for codepoint + (*from & 0xF0) == 0xE0 || // 1110 xxxx; 3 bytes for codepoint + (*from & 0xE0) == 0xC0) // 110x xxxx; 2 bytes for codepoint + { + stateId = findStateId(); + codecvt::State& s = m_states.at(stateId - 1); + s.bytes[0] = *from; + convert = false; + if ((*from & 0xF8) == 0xF0) { + s.totalBytes = 4; + } else if ((*from & 0xF0) == 0xE0) { + s.totalBytes = 3; + } else if ((*from & 0xE0) == 0xC0) { + s.totalBytes = 2; + } + s.bytesLeft = s.totalBytes - 1; + }; + // else 1 byte for codepoint + } else { + codecvt::State& s = m_states.at(stateId - 1); + s.bytes[s.totalBytes - s.bytesLeft] = *from; + s.bytesLeft--; + data = s.bytes; + count = s.totalBytes - s.bytesLeft; + if ((*from & 0xC0) == 0x80) { // 10xx xxxx + convert = s.bytesLeft == 0; + } else { + // invalid multi-byte + convert = true; + } + if (convert) { + s.used = false; + if (stateId == m_lastState) { + m_lastState--; + } + stateId = 0; + } + } + if (convert) { + std::wstring wide = cmsys::Encoding::ToWide(std::string(data, count)); + int r = WideCharToMultiByte(m_codepage, 0, wide.c_str(), + static_cast<int>(wide.size()), to, + to_end - to, NULL, NULL); + if (r > 0) { + from_next = from_end; + to_next = to + r; + res = ok; + } + } else { + res = partial; + from_next = from_end; + to_next = to; + } + } +#else + static_cast<void>(state); + static_cast<void>(from); + static_cast<void>(from_end); + static_cast<void>(from_next); + static_cast<void>(to); + static_cast<void>(to_end); + static_cast<void>(to_next); + res = codecvt::noconv; +#endif + return res; +}; + +std::codecvt_base::result codecvt::do_unshift(mbstate_t& state, char* to, + char* to_end, + char*& to_next) const +{ + std::codecvt_base::result res = error; + to_next = to; +#if defined(_WIN32) + unsigned int& stateId = reinterpret_cast<unsigned int&>(state); + if (stateId > 0) { + codecvt::State& s = m_states.at(stateId - 1); + s.used = false; + if (stateId == m_lastState) { + m_lastState--; + } + stateId = 0; + std::wstring wide = cmsys::Encoding::ToWide( + std::string(s.bytes, s.totalBytes - s.bytesLeft)); + int r = WideCharToMultiByte(m_codepage, 0, wide.c_str(), + static_cast<int>(wide.size()), to, to_end - to, + NULL, NULL); + if (r > 0) { + to_next = to + r; + res = ok; + } + } else { + res = ok; + } +#else + static_cast<void>(state); + static_cast<void>(to_end); + res = ok; +#endif + return res; +}; + +int codecvt::do_max_length() const throw() +{ + return 4; +}; + +int codecvt::do_encoding() const throw() +{ + return 0; +}; + +unsigned int codecvt::findStateId() const +{ + unsigned int stateId = 0; + bool add = false; + const unsigned int maxSize = std::numeric_limits<unsigned int>::max(); + if (m_lastState >= maxSize) { + m_lastState = 0; + } + if (m_states.size() <= m_lastState) { + add = true; + } else { + unsigned int i = m_lastState; + while (i < maxSize) { + codecvt::State& s = m_states.at(i); + i++; + if (!s.used) { + m_lastState = i; + stateId = m_lastState; + s.used = true; + s.totalBytes = 0; + s.bytesLeft = 0; + break; + } + if (i >= m_states.size()) { + i = 0; + } + if (i == m_lastState) { + add = true; + break; + } + } + }; + if (add) { + codecvt::State s = { true, 0, 0, { 0, 0, 0, 0 } }; + m_states.push_back(s); + m_lastState = (unsigned int)m_states.size(); + stateId = m_lastState; + } + return stateId; +}; diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx new file mode 100644 index 0000000..5f16bd8 --- /dev/null +++ b/Source/cm_codecvt.hxx @@ -0,0 +1,57 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_codecvt_hxx +#define cm_codecvt_hxx + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <locale> +#include <vector> + +class codecvt : public std::codecvt<char, char, mbstate_t> +{ +public: + enum Encoding + { + None, + UTF8, + ANSI + }; + +#ifdef CMAKE_BUILD_WITH_CMAKE + + codecvt(Encoding e); + +protected: + ~codecvt() CM_OVERRIDE; + bool do_always_noconv() const throw() CM_OVERRIDE; + result do_out(mbstate_t& state, const char* from, const char* from_end, + const char*& from_next, char* to, char* to_end, + char*& to_next) const CM_OVERRIDE; + result do_unshift(mbstate_t& state, char* to, char*, + char*& to_next) const CM_OVERRIDE; + int do_max_length() const throw() CM_OVERRIDE; + int do_encoding() const throw() CM_OVERRIDE; + +private: + typedef struct + { + bool used; + unsigned char totalBytes; + unsigned char bytesLeft; + char bytes[4]; + } State; + + unsigned int findStateId() const; + + bool m_noconv; + mutable std::vector<State> m_states; + mutable unsigned int m_lastState; +#if defined(_WIN32) + unsigned int m_codepage; +#endif + +#endif +}; + +#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 14124f8..5936d77 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -12,6 +12,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmGlobalGeneratorFactory.h" +#include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessenger.h" @@ -568,7 +569,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) cmSystemTools::ExpandListArgument(libs, libList); for (std::vector<std::string>::const_iterator libIt = libList.begin(); libIt != libList.end(); ++libIt) { - mf->AddLinkLibraryForTarget(targetName, *libIt, GENERAL_LibraryType); + tgt->AddLinkLibrary(*mf, *libIt, GENERAL_LibraryType); } std::string buildType = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); @@ -582,8 +583,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args) gg->CreateGenerationObjects(); cmGeneratorTarget* gtgt = gg->FindGeneratorTarget(tgt->GetName()); cmLocalGenerator* lg = gtgt->GetLocalGenerator(); - lg->GetTargetFlags(buildType, linkLibs, flags, linkFlags, frameworkPath, - linkPath, gtgt, false); + cmLinkLineComputer linkLineComputer(lg, + lg->GetStateSnapshot().GetDirectory()); + lg->GetTargetFlags(&linkLineComputer, buildType, linkLibs, flags, + linkFlags, frameworkPath, linkPath, gtgt); linkLibs = frameworkPath + linkPath + linkLibs; printf("%s\n", linkLibs.c_str()); @@ -929,7 +932,7 @@ void cmake::GetRegisteredGenerators( gen != genList.end(); ++gen) { GeneratorInfo info; info.name = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - (*i)->GetName(), *gen); + *gen, (*i)->GetName()); info.baseName = *gen; info.extraName = (*i)->GetName(); info.supportsPlatform = false; @@ -1310,54 +1313,7 @@ int cmake::ActualConfigure() cmSystemTools::SetForceUnixPaths( this->GlobalGenerator->GetForceUnixPaths()); } else { -#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) - std::string installedCompiler; - // Try to find the newest VS installed on the computer and - // use that as a default if -G is not specified - const std::string vsregBase = - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"; - std::vector<std::string> vsVerions; - vsVerions.push_back("VisualStudio\\"); - vsVerions.push_back("VCExpress\\"); - vsVerions.push_back("WDExpress\\"); - struct VSRegistryEntryName - { - const char* MSVersion; - const char* GeneratorName; - }; - VSRegistryEntryName version[] = { - /* clang-format needs this comment to break after the opening brace */ - { "7.1", "Visual Studio 7 .NET 2003" }, - { "8.0", "Visual Studio 8 2005" }, - { "9.0", "Visual Studio 9 2008" }, - { "10.0", "Visual Studio 10 2010" }, - { "11.0", "Visual Studio 11 2012" }, - { "12.0", "Visual Studio 12 2013" }, - { "14.0", "Visual Studio 14 2015" }, - { "15.0", "Visual Studio 15" }, - { 0, 0 } - }; - for (int i = 0; version[i].MSVersion != 0; i++) { - for (size_t b = 0; b < vsVerions.size(); b++) { - std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion; - reg += ";InstallDir]"; - cmSystemTools::ExpandRegistryValues(reg, cmSystemTools::KeyWOW64_32); - if (!(reg == "/registry")) { - installedCompiler = version[i].GeneratorName; - break; - } - } - } - cmGlobalGenerator* gen = - this->CreateGlobalGenerator(installedCompiler.c_str()); - if (!gen) { - gen = new cmGlobalNMakeMakefileGenerator(this); - } - this->SetGlobalGenerator(gen); - std::cout << "-- Building for: " << gen->GetName() << "\n"; -#else - this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this)); -#endif + this->CreateDefaultGlobalGenerator(); } if (!this->GlobalGenerator) { cmSystemTools::Error("Could not create generator"); @@ -1485,6 +1441,63 @@ int cmake::ActualConfigure() return 0; } +void cmake::CreateDefaultGlobalGenerator() +{ +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) + std::string found; + // Try to find the newest VS installed on the computer and + // use that as a default if -G is not specified + const std::string vsregBase = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"; + static const char* const vsVariants[] = { + /* clang-format needs this comment to break after the opening brace */ + "VisualStudio\\", "VCExpress\\", "WDExpress\\" + }; + struct VSVersionedGenerator + { + const char* MSVersion; + const char* GeneratorName; + }; + static VSVersionedGenerator const vsGenerators[] = { + { "15.0", "Visual Studio 15" }, // + { "14.0", "Visual Studio 14 2015" }, // + { "12.0", "Visual Studio 12 2013" }, // + { "11.0", "Visual Studio 11 2012" }, // + { "10.0", "Visual Studio 10 2010" }, // + { "9.0", "Visual Studio 9 2008" }, // + { "8.0", "Visual Studio 8 2005" }, // + { "7.1", "Visual Studio 7 .NET 2003" } + }; + static const char* const vsEntries[] = { + "\\Setup\\VC;ProductDir", // + ";InstallDir" // + }; + for (VSVersionedGenerator const* g = cmArrayBegin(vsGenerators); + found.empty() && g != cmArrayEnd(vsGenerators); ++g) { + for (const char* const* v = cmArrayBegin(vsVariants); + found.empty() && v != cmArrayEnd(vsVariants); ++v) { + for (const char* const* e = cmArrayBegin(vsEntries); + found.empty() && e != cmArrayEnd(vsEntries); ++e) { + std::string const reg = vsregBase + *v + g->MSVersion + *e; + std::string dir; + if (cmSystemTools::ReadRegistryValue(reg, dir, + cmSystemTools::KeyWOW64_32) && + cmSystemTools::PathExists(dir)) { + found = g->GeneratorName; + } + } + } + } + cmGlobalGenerator* gen = this->CreateGlobalGenerator(found); + if (!gen) { + gen = new cmGlobalNMakeMakefileGenerator(this); + } + this->SetGlobalGenerator(gen); + std::cout << "-- Building for: " << gen->GetName() << "\n"; +#else + this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this)); +#endif +} + void cmake::PreLoadCMakeFiles() { std::vector<std::string> args; diff --git a/Source/cmake.h b/Source/cmake.h index ae1a502..865748b 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -500,6 +500,8 @@ private: // Print a list of valid generators to stderr. void PrintGeneratorList(); + void CreateDefaultGlobalGenerator(); + /** * Convert a message type between a warning and an error, based on the state * of the error output CMake variables, in the cache. diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 1fb39ff..8ab17b9 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -163,11 +163,7 @@ int main(int argc, char const* const* argv) doc.SetSection("Name", cmDocumentationName); doc.SetSection("Usage", cmDocumentationUsage); doc.PrependSection("Options", cmDocumentationOptions); -#ifdef cout -#undef cout -#endif return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1; -#define cout no_cout_use_cmCTestLog } } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c97af25..5da715f 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2716,17 +2716,15 @@ unsigned long SystemTools::FileLength(const std::string& filename) return length; } -int SystemTools::Strucmp(const char *s1, const char *s2) -{ - // lifted from Graphvis http://www.graphviz.org - while ((*s1 != '\0') - && (tolower(*s1) == tolower(*s2))) - { - s1++; - s2++; - } - - return tolower(*s1) - tolower(*s2); +int SystemTools::Strucmp(const char* l, const char* r) +{ + int lc; + int rc; + do { + lc = tolower(*l++); + rc = tolower(*r++); + } while(lc == rc && lc); + return lc - rc; } // return file's modified time diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 56fcc5d..23832da 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -20,16 +20,9 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) # now set up the test: - if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" - CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n" - ) - else() - get_target_property(cmakeLocation cmake LOCATION) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" - "CMAKE = \"${cmakeLocation}\"\n" - ) - endif() + file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/cmakeExecutable.mk" + CONTENT "CMAKE = \"$<TARGET_FILE:cmake>\"\n" + ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt index 29f9838..271aaf1 100644 --- a/Tests/Framework/CMakeLists.txt +++ b/Tests/Framework/CMakeLists.txt @@ -51,6 +51,11 @@ install(TARGETS foo bar # duplicate install rules for the pieces of the framework. ) +# test that framework post-build commands run +add_custom_command(TARGET foo POST_BUILD COMMAND ${CMAKE_COMMAND} -E touch foo-post-build) +add_custom_target(fooCustom ALL COMMAND ${CMAKE_COMMAND} -E copy foo-post-build foo-custom) +add_dependencies(fooCustom foo) + # Make a static library and apply the framework properties to it to verify # that everything still builds correctly, but it will not actually produce # a framework... The framework properties only apply when the library type diff --git a/Tests/MacRuntimePath/A/CMakeLists.txt b/Tests/MacRuntimePath/A/CMakeLists.txt index ade0a3c..bf937e6 100644 --- a/Tests/MacRuntimePath/A/CMakeLists.txt +++ b/Tests/MacRuntimePath/A/CMakeLists.txt @@ -40,21 +40,30 @@ target_link_libraries(test3 framework) add_executable(test4 test1.cpp) target_link_libraries(test4 shared2) +# executable to test a shared library dependency with build rpath +add_executable(test5 test1.cpp) + +# avoid linking by 'target_link_libraries' so CMake +# will not be able to set correct RPATH automatically +add_dependencies(test5 shared) +target_link_libraries(test5 "$<TARGET_FILE:shared>") +set_target_properties(test5 PROPERTIES BUILD_RPATH "@loader_path/../lib") + set_target_properties(shared shared2 framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") -set_target_properties(test1 test2 test3 test4 PROPERTIES +set_target_properties(test1 test2 test3 test4 test5 PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${config} CONFIG) set_target_properties(shared shared2 framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_CURRENT_BINARY_DIR}/${config}/lib") - set_target_properties(test1 test2 test3 test4 PROPERTIES + set_target_properties(test1 test2 test3 test4 test5 PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin") endforeach() -foreach(test test1 test2 test3 test4) +foreach(test test1 test2 test3 test4 test5) add_custom_target(${test}_run ALL COMMAND ${test} DEPENDS ${test} diff --git a/Tests/RunCMake/Android/android.cxx b/Tests/RunCMake/Android/android.cxx index e6a6cda..2dee8f9 100644 --- a/Tests/RunCMake/Android/android.cxx +++ b/Tests/RunCMake/Android/android.cxx @@ -6,6 +6,9 @@ #ifndef STL_SYSTEM #include <exception> #include <typeinfo> +#ifndef STL_STLPORT +#include <cxxabi.h> +#endif #ifndef STL_GABI #include <iostream> #include <string> diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index 7eac5d6..d803c98 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -17,8 +17,8 @@ foreach(f endif() endforeach() -string(APPEND CMAKE_C_FLAGS " -Werror") -string(APPEND CMAKE_CXX_FLAGS " -Werror") +string(APPEND CMAKE_C_FLAGS " -Werror -Wno-attributes") +string(APPEND CMAKE_CXX_FLAGS " -Werror -Wno-attributes") string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-no-undefined") if(CMAKE_ANDROID_NDK) @@ -43,6 +43,8 @@ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "system") add_definitions(-DSTL_SYSTEM) elseif(CMAKE_ANDROID_STL_TYPE MATCHES [[^gabi\+\+]]) add_definitions(-DSTL_GABI) +elseif(CMAKE_ANDROID_STL_TYPE MATCHES [[^stlport]]) + add_definitions(-DSTL_STLPORT) endif() string(REPLACE "-" "_" abi "${CMAKE_ANDROID_ARCH_ABI}") diff --git a/Tests/RunCMake/AndroidMK/AndroidMK.cmake b/Tests/RunCMake/AndroidMK/AndroidMK.cmake index ed21e58..2596e8c 100644 --- a/Tests/RunCMake/AndroidMK/AndroidMK.cmake +++ b/Tests/RunCMake/AndroidMK/AndroidMK.cmake @@ -2,7 +2,7 @@ project(build) set(CMAKE_BUILD_TYPE Debug) add_library(foo foo.cxx) add_library(car foo.cxx) -add_library(bar foo.cxx) +add_library(bar bar.c) add_library(dog foo.cxx) target_link_libraries(foo car bar dog debug -lm) export(TARGETS bar dog car foo ANDROID_MK diff --git a/Tests/RunCMake/AndroidMK/bar.c b/Tests/RunCMake/AndroidMK/bar.c new file mode 100644 index 0000000..e1f4df6 --- /dev/null +++ b/Tests/RunCMake/AndroidMK/bar.c @@ -0,0 +1,3 @@ +void bar(void) +{ +} diff --git a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt index def8fcb..bbf67a5 100644 --- a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt +++ b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt @@ -7,11 +7,13 @@ include.*PREBUILT_STATIC_LIBRARY.* include.*CLEAR_VARS.* LOCAL_MODULE.*dog LOCAL_SRC_FILES.*.*dog.* +LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* .* include.*CLEAR_VARS.* LOCAL_MODULE.*car LOCAL_SRC_FILES.*.*car.* +LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* .* include.*CLEAR_VARS.* @@ -20,4 +22,5 @@ LOCAL_SRC_FILES.*.*foo.* LOCAL_CPP_FEATURES.*rtti exceptions LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_EXPORT_LDLIBS := -lm +LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt index 1bdb308..3515fb9 100644 --- a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt +++ b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt @@ -9,11 +9,13 @@ include.*PREBUILT_STATIC_LIBRARY.* include.*CLEAR_VARS. LOCAL_MODULE.*dog LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*dog.* +LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* include.*CLEAR_VARS.* LOCAL_MODULE.*car LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*car.* +LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* include.*CLEAR_VARS.* @@ -22,4 +24,5 @@ LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo.* LOCAL_CPP_FEATURES.*rtti exceptions LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_EXPORT_LDLIBS := -lm +LOCAL_HAS_CPP := true include.*PREBUILT_STATIC_LIBRARY.* diff --git a/Tests/RunCMake/CPack/MAIN_COMPONENT.cmake b/Tests/RunCMake/CPack/MAIN_COMPONENT.cmake new file mode 100644 index 0000000..99c6cae --- /dev/null +++ b/Tests/RunCMake/CPack/MAIN_COMPONENT.cmake @@ -0,0 +1,14 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT applications) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) +install(FILES CMakeLists.txt DESTINATION bas COMPONENT libs) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") + set(CPACK_RPM_MAIN_COMPONENT "") +else() + set(CPACK_RPM_MAIN_COMPONENT "applications") + set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") +endif() + +set(CPACK_PACKAGE_NAME "main_component") diff --git a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-ExpectedFiles.cmake new file mode 100644 index 0000000..69603dd --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-ExpectedFiles.cmake @@ -0,0 +1,13 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "0") + +if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid") + set(EXPECTED_FILES_COUNT "3") + set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm") + set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") + set(EXPECTED_FILE_2 "main_component*-headers.rpm") + set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") + set(EXPECTED_FILE_3 "main_component*-libs.rpm") + set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/CMakeLists.txt$") +endif() diff --git a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-found-stderr.txt b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-found-stderr.txt new file mode 100644 index 0000000..dff163d --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-found-stderr.txt @@ -0,0 +1,3 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component-headers.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component-libs.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/MAIN_COMPONENT-build-found-subtest/_CPack_Packages/.*/RPM/SPECS/main_component.spec$ diff --git a/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-invalid-stderr.txt b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-invalid-stderr.txt new file mode 100644 index 0000000..4d8ac6e --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/MAIN_COMPONENT-invalid-stderr.txt @@ -0,0 +1 @@ +CPACK_RPM_MAIN_COMPONENT set to non existing component. diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-ExpectedFiles.cmake new file mode 100644 index 0000000..dc49343 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-ExpectedFiles.cmake @@ -0,0 +1,30 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "0") + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") + set(EXPECTED_FILES_COUNT "4") + set(EXPECTED_FILE_1 "single_debuginfo-0.1.1-1.*.rpm") + set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") + set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm") + set(EXPECTED_FILE_CONTENT_2 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$") + set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm") + set(EXPECTED_FILE_CONTENT_3 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$") + + set(EXPECTED_FILE_4 "single_debuginfo-debuginfo*.rpm") + set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1 "single_debuginfo-0*-applications.rpm") + set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") + + set(EXPECTED_FILE_2 "single_debuginfo-applications-debuginfo*.rpm") + set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_components") + set(EXPECTED_FILES_COUNT "2") + set(EXPECTED_FILE_1 "single_debuginfo-0*.rpm") + set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$") + + set(EXPECTED_FILE_2 "single_debuginfo-debuginfo*.rpm") + set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*") +endif() diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_components-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_components-stderr.txt new file mode 100644 index 0000000..d80939f --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_components-stderr.txt @@ -0,0 +1 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_components-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_debuginfo-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_debuginfo-stderr.txt new file mode 100644 index 0000000..86396db --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_debuginfo-stderr.txt @@ -0,0 +1,3 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-headers.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-libs.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_main_component-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_main_component-stderr.txt new file mode 100644 index 0000000..454283c --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-no_main_component-stderr.txt @@ -0,0 +1 @@ +CPack Error: CPACK_RPM_MAIN_COMPONENT not set but it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE being set. diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component-stderr.txt new file mode 100644 index 0000000..080c4ff --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component-stderr.txt @@ -0,0 +1 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-applications.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_main-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_main-stderr.txt new file mode 100644 index 0000000..665597c --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_main-stderr.txt @@ -0,0 +1 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component_main-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_no_debuginfo-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_no_debuginfo-stderr.txt new file mode 100644 index 0000000..b64b1f5 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-one_component_no_debuginfo-stderr.txt @@ -0,0 +1 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-one_component_no_debuginfo-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-applications.spec$ diff --git a/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-valid-stderr.txt b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-valid-stderr.txt new file mode 100644 index 0000000..f4c1bef --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/SINGLE_DEBUGINFO-valid-stderr.txt @@ -0,0 +1,3 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-headers.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo-libs.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/SINGLE_DEBUGINFO-build-valid-subtest/_CPack_Packages/.*/RPM/SPECS/single_debuginfo.spec$ diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 60d42ac..474ee33 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -12,11 +12,13 @@ run_cpack_test(DEPENDENCIES "RPM;DEB" true) run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(CUSTOM_NAMES "RPM;DEB" true) +run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false) run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) run_cpack_test(RPM_DIST "RPM" false) run_cpack_test(INSTALL_SCRIPTS "RPM" false) run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true) run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true) run_cpack_test(DEBUGINFO "RPM" true) +run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true) run_cpack_test(LONG_FILENAMES "DEB" false) run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false) diff --git a/Tests/RunCMake/CPack/SINGLE_DEBUGINFO.cmake b/Tests/RunCMake/CPack/SINGLE_DEBUGINFO.cmake new file mode 100644 index 0000000..ae4995e --- /dev/null +++ b/Tests/RunCMake/CPack/SINGLE_DEBUGINFO.cmake @@ -0,0 +1,56 @@ +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +# PGI compiler doesn't add build id to binaries by default +if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI") + string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id") + string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id") +endif() + +if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "no_components") + set(CPACK_RPM_COMPONENT_INSTALL "ON") +endif() + +set(CMAKE_BUILD_TYPE Debug) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n") +add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(test_prog test_lib) + +install(TARGETS test_prog DESTINATION foo COMPONENT applications) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_main_component" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") + install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) + install(TARGETS test_lib DESTINATION bas COMPONENT libs) +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") + set(CPACK_COMPONENTS_ALL applications) +endif() + +set(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE ON) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") + set(CPACK_RPM_MAIN_COMPONENT "applications") + set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT") +endif() + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_main_component" + OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component") + set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON) +endif() + +set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src") + +set(CPACK_PACKAGE_NAME "single_debuginfo") diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 8bc2a58..ad2a651 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -27,10 +27,12 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) expected_content_list "${PACKAGE_CONTENT}") if(NOT expected_content_list) + string(REPLACE "\n" "\n actual> " msg_actual "\n${PACKAGE_CONTENT}") + string(REPLACE "\n" "\n expect> " msg_expected "\n${EXPECTED_FILE_CONTENT_${file_no_}}") message(FATAL_ERROR "Unexpected file content for file No. '${file_no_}'!\n" - " Content: '${PACKAGE_CONTENT}'\n\n" - " Expected: '${EXPECTED_FILE_CONTENT_${file_no_}}'" + "The content was:${msg_actual}\n" + "which does not match:${msg_expected}\n" "${output_error_message}") endif() else() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake index c350a63..cb48be7 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake @@ -15,3 +15,12 @@ if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) set(RunCMake_TEST_FAILED "Expected forced FOO argument") return() endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_LIST \"A;B;C\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_LIST argument in cache") + return() +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected forced TEST_LIST argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake index 62b1640..1f76fd0 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake @@ -5,4 +5,6 @@ include(ExternalProject) ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" - CMAKE_CACHE_ARGS "-DFOO:STRING=$<1:BAR>$<0:BAD>") + CMAKE_CACHE_ARGS + "-DFOO:STRING=$<1:BAR>$<0:BAD>" + "-DTEST_LIST:STRING=A;B;C") diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake index aeee11f..c84932d 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake @@ -15,3 +15,12 @@ if("${CMAKE_MATCH_0}" MATCHES FORCE) set(RunCMake_TEST_FAILED "Expected not forced FOO argument") return() endif() + +if(NOT "${_cache}" MATCHES "set\\(TEST_LIST \"A;B;C\".+\\)") + set(RunCMake_TEST_FAILED "Cannot find TEST_LIST argument in cache") + return() +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected not forced TEST_LIST argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake index 3a83dbe..1b619c8 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake @@ -5,4 +5,6 @@ include(ExternalProject) ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" - CMAKE_CACHE_DEFAULT_ARGS "-DFOO:STRING=$<1:BAR>$<0:BAD>") + CMAKE_CACHE_DEFAULT_ARGS + "-DFOO:STRING=$<1:BAR>$<0:BAD>" + "-DTEST_LIST:STRING=A;B;C") diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-stderr.txt new file mode 100644 index 0000000..5737e95 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + .* + + does not recognize the toolset + + Test Toolset,host=x6[45] + + that was specified\.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArch.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index 283a2a0..e8ce47d 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -6,6 +6,21 @@ run_cmake(NoToolset) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]|Xcode" AND NOT XCODE_BELOW_3) set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolset) + if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[245]") + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") + run_cmake(TestToolsetHostArchBoth) + set(RunCMake_GENERATOR_TOOLSET ",host=x64") + run_cmake(TestToolsetHostArchOnly) + set(RunCMake_GENERATOR_TOOLSET "host=x64") + run_cmake(TestToolsetHostArchOnly) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset") + run_cmake(TestToolsetHostArchNone) + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x65") + run_cmake(BadToolsetHostArch) + else() + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") + run_cmake(BadToolsetHostArch) + endif() else() set(RunCMake_GENERATOR_TOOLSET "Bad Toolset") run_cmake(BadToolset) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth-stdout.txt new file mode 100644 index 0000000..f0b6d46 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='x64' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth.cmake new file mode 100644 index 0000000..26926f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchBoth.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt new file mode 100644 index 0000000..576b40c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake new file mode 100644 index 0000000..26926f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt new file mode 100644 index 0000000..8271bd4 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+' +-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='x64' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake new file mode 100644 index 0000000..26926f9 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake @@ -0,0 +1,2 @@ +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'") diff --git a/Utilities/GitSetup/config b/Utilities/GitSetup/config index b7d5423..d69a679 100644 --- a/Utilities/GitSetup/config +++ b/Utilities/GitSetup/config @@ -1,5 +1,5 @@ [hooks] - url = http://cmake.org/cmake.git + url = https://cmake.org/cmake.git [ssh] host = cmake.org key = id_git_cmake diff --git a/Utilities/Release/README b/Utilities/Release/README index ed1d52e..11de1c3 100644 --- a/Utilities/Release/README +++ b/Utilities/Release/README @@ -1,7 +1,7 @@ To create a cmake release, make sure the "release" tag is pointing to the expected git commit: -http://cmake.org/gitweb?p=cmake.git;a=shortlog;h=refs/heads/release +https://cmake.org/gitweb?p=cmake.git;a=shortlog;h=refs/heads/release Then as kitware@hythloth, using an up-to-date CMake: diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake index b72fc12..b9447ca 100644 --- a/Utilities/Release/linux64_release.cmake +++ b/Utilities/Release/linux64_release.cmake @@ -2,6 +2,7 @@ set(PROCESSORS 4) set(BOOTSTRAP_ARGS "--docdir=doc/cmake") set(HOST linux64) set(MAKE_PROGRAM "make") +set(CPACK_BINARY_GENERATORS "STGZ TGZ") set(CC /opt/gcc-6.1.0/bin/gcc) set(CXX /opt/gcc-6.1.0/bin/g++) set(CFLAGS "") diff --git a/Utilities/Release/osx_release.cmake b/Utilities/Release/osx_release.cmake index 27c820f..88ea39b 100644 --- a/Utilities/Release/osx_release.cmake +++ b/Utilities/Release/osx_release.cmake @@ -4,7 +4,7 @@ set(BOOTSTRAP_ARGS "--prefix=/ --docdir=doc/cmake") set(HOST dragnipur) set(MAKE_PROGRAM "make") set(MAKE "${MAKE_PROGRAM} -j5") -set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ") +set(CPACK_BINARY_GENERATORS "DragNDrop TGZ") set(CPACK_SOURCE_GENERATORS "TGZ TZ") set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size set(CC clang) diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index 04a0cac..1485d9c 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -1,6 +1,6 @@ set(CTEST_RUN_CURRENT_SCRIPT 0) if(NOT VERSION) - set(VERSION 3.6) + set(VERSION 3.7) endif() if(NOT DEFINED PROJECT_PREFIX) set(PROJECT_PREFIX cmake-${VERSION}) @@ -297,6 +297,8 @@ CMAKE_CXX_SOURCES="\ cmFileTimeComparison \ cmGlobalUnixMakefileGenerator3 \ cmLocalUnixMakefileGenerator3 \ + cmLinkLineComputer \ + cmMSVC60LinkLineComputer \ cmMakefileExecutableTargetGenerator \ cmMakefileLibraryTargetGenerator \ cmMakefileTargetGenerator \ |