diff options
64 files changed, 1384 insertions, 28 deletions
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake index 22ca8cf..ce10ad0 100644 --- a/CMakeCPack.cmake +++ b/CMakeCPack.cmake @@ -65,6 +65,61 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") endif() endif() + # Components + if(CMake_INSTALL_COMPONENTS) + set(_CPACK_IFW_COMPONENTS_ALL cmake ctest cpack) + 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) + set(_CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES "set(CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES + \"LGPLv2.1\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt\")") + 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() + set(_CPACK_IFW_COMPONENTS_CONFIGURATION " + # Components + set(CPACK_COMPONENTS_ALL \"${_CPACK_IFW_COMPONENTS_ALL}\") + set(CPACK_COMPONENTS_GROUPING IGNORE) +") + else() + if(BUILD_QtDialog AND CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) + set(_CPACK_IFW_ADDITIONAL_LICENSES + "\"LGPLv2.1\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt\"") + endif() + endif() + + # Components scripts configuration + foreach(_script + CMake + CMake.Documentation.SphinxHTML) + 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\")") @@ -78,9 +133,13 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") "${CMake_BINARY_DIR}/installscript.qs" @ONLY ) install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html" - DESTINATION "." + DESTINATION "${CMAKE_DOC_DIR}" ) - set(_CPACK_IFW_PACKAGE_SCRIPT "set(CPACK_IFW_COMPONENT_GROUP_CMAKE_SCRIPT \"${CMake_BINARY_DIR}/installscript.qs\")") + 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() if(${CMAKE_SYSTEM_NAME} MATCHES Linux) diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index 6003565..a1e425a 100644 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -32,6 +32,7 @@ endif() include("@QT_DIALOG_CPACK_OPTIONS_FILE@" OPTIONAL) if(CPACK_GENERATOR MATCHES "IFW") + # Installer configuration set(CPACK_IFW_PACKAGE_TITLE "CMake Build Tool") set(CPACK_IFW_PRODUCT_URL "http://www.cmake.org") @@ -40,21 +41,132 @@ if(CPACK_GENERATOR MATCHES "IFW") "@CMake_SOURCE_DIR@/Source/QtDialog/CMakeSetup128.png") set(CPACK_IFW_PACKAGE_CONTROL_SCRIPT "@CMake_SOURCE_DIR@/Source/QtIFW/controlscript.qs") + # Uninstaller configuration set(CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME "cmake-maintenance") + @_CPACK_IFW_COMPONENTS_CONFIGURATION@ + # Unspecified + set(CPACK_IFW_COMPONENT_@_CPACK_IFW_COMPONENT_UNSPECIFIED_UNAME@_VERSION + "@_CPACK_IFW_PACKAGE_VERSION@") + # Package configuration group set(CPACK_IFW_PACKAGE_GROUP CMake) + # Group configuration + + # CMake set(CPACK_COMPONENT_GROUP_CMAKE_DISPLAY_NAME "@CPACK_PACKAGE_NAME@") set(CPACK_COMPONENT_GROUP_CMAKE_DESCRIPTION "@CPACK_PACKAGE_DESCRIPTION_SUMMARY@") - # IFW group configuration set(CPACK_IFW_COMPONENT_GROUP_CMAKE_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") set(CPACK_IFW_COMPONENT_GROUP_CMAKE_LICENSES - "@CPACK_PACKAGE_NAME@ Copyright" "@CPACK_RESOURCE_FILE_LICENSE@") - @_CPACK_IFW_PACKAGE_SCRIPT@ + "@CPACK_PACKAGE_NAME@ Copyright" "@CPACK_RESOURCE_FILE_LICENSE@" + @_CPACK_IFW_ADDITIONAL_LICENSES@) + set(CPACK_IFW_COMPONENT_GROUP_CMAKE_SCRIPT "@_CPACK_IFW_PACKAGE_SCRIPT@") + set(CPACK_IFW_COMPONENT_GROUP_CMAKE_PRIORITY 100) + + # Tools + set(CPACK_COMPONENT_GROUP_TOOLS_DISPLAY_NAME "Command-Line Tools") + set(CPACK_COMPONENT_GROUP_TOOLS_DESCRIPTION + "Command-Line Tools: cmake, ctest and cpack") + set(CPACK_COMPONENT_GROUP_TOOLS_PARENT_GROUP CMake) + set(CPACK_IFW_COMPONENT_GROUP_TOOLS_PRIORITY 90) + set(CPACK_IFW_COMPONENT_GROUP_TOOLS_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_CMAKE_DISPLAY_NAME "cmake") + set(CPACK_COMPONENT_CMAKE_DESCRIPTION + "The \"cmake\" executable is the CMake command-line interface") + set(CPACK_COMPONENT_CMAKE_REQUIRED TRUE) + set(CPACK_COMPONENT_CMAKE_GROUP Tools) + set(CPACK_IFW_COMPONENT_CMAKE_NAME "CMake") + set(CPACK_IFW_COMPONENT_CMAKE_PRIORITY 89) + set(CPACK_IFW_COMPONENT_CMAKE_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_CTEST_DISPLAY_NAME "ctest") + set(CPACK_COMPONENT_CTEST_DESCRIPTION + "The \"ctest\" executable is the CMake test driver program") + set(CPACK_COMPONENT_CTEST_REQUIRED TRUE) + set(CPACK_COMPONENT_CTEST_GROUP Tools) + set(CPACK_IFW_COMPONENT_CTEST_NAME "CTest") + set(CPACK_IFW_COMPONENT_CTEST_PRIORITY 88) + set(CPACK_IFW_COMPONENT_CTEST_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_CPACK_DISPLAY_NAME "cpack") + set(CPACK_COMPONENT_CPACK_DESCRIPTION + "The \"cpack\" executable is the CMake packaging program") + set(CPACK_COMPONENT_CPACK_REQUIRED TRUE) + set(CPACK_COMPONENT_CPACK_GROUP Tools) + set(CPACK_IFW_COMPONENT_CPACK_NAME "CPack") + set(CPACK_IFW_COMPONENT_CPACK_PRIORITY 87) + set(CPACK_IFW_COMPONENT_CPACK_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_CMAKEXBUILD_DISPLAY_NAME "cmakexbuild") + set(CPACK_COMPONENT_CMAKEXBUILD_DESCRIPTION + "The \"cmakexbuild\" executable is a wrapper program for \"xcodebuild\"") + set(CPACK_COMPONENT_CMAKEXBUILD_REQUIRED TRUE) + set(CPACK_COMPONENT_CMAKEXBUILD_GROUP Tools) + set(CPACK_IFW_COMPONENT_CMAKEXBUILD_NAME "CMakeXBuild") + set(CPACK_IFW_COMPONENT_CMAKEXBUILD_PRIORITY 86) + set(CPACK_IFW_COMPONENT_CMAKEXBUILD_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + # Dialogs + set(CPACK_COMPONENT_GROUP_DIALOGS_DISPLAY_NAME "Interactive Dialogs") + set(CPACK_COMPONENT_GROUP_DIALOGS_DESCRIPTION + "Interactive Dialogs with Console and GUI interfaces") + set(CPACK_COMPONENT_GROUP_DIALOGS_PARENT_GROUP CMake) + set(CPACK_IFW_COMPONENT_GROUP_DIALOGS_PRIORITY 80) + set(CPACK_IFW_COMPONENT_GROUP_DIALOGS_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_CMAKE-GUI_DISPLAY_NAME "cmake-gui") + set(CPACK_COMPONENT_CMAKE-GUI_GROUP Dialogs) + set(CPACK_IFW_COMPONENT_CMAKE-GUI_NAME "QtGUI") + set(CPACK_IFW_COMPONENT_CMAKE-GUI_SCRIPT + "@CMake_SOURCE_DIR@/Source/QtIFW/CMake.Dialogs.QtGUI.qs") + set(CPACK_IFW_COMPONENT_CMAKE-GUI_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + @_CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES@ + + set(CPACK_COMPONENT_CCMAKE_DISPLAY_NAME "ccmake") + set(CPACK_COMPONENT_CCMAKE_GROUP Dialogs) + set(CPACK_IFW_COMPONENT_CCMAKE_NAME "CursesGUI") + set(CPACK_IFW_COMPONENT_CCMAKE_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + # Documentation + set(CPACK_COMPONENT_GROUP_DOCUMENTATION_DISPLAY_NAME "Documentation") + set(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION + "CMake Documentation in different formats (html, man, qch)") + set(CPACK_COMPONENT_GROUP_DOCUMENTATION_PARENT_GROUP CMake) + set(CPACK_IFW_COMPONENT_GROUP_DOCUMENTATION_PRIORITY 60) + set(CPACK_IFW_COMPONENT_GROUP_DOCUMENTATION_VERSION + "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_SPHINX-MAN_DISPLAY_NAME "man") + set(CPACK_COMPONENT_SPHINX-MAN_GROUP Documentation) + set(CPACK_COMPONENT_SPHINX-MAN_DISABLED TRUE) + set(CPACK_IFW_COMPONENT_SPHINX-MAN_NAME "SphinxMan") + set(CPACK_IFW_COMPONENT_SPHINX-MAN_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_SPHINX-HTML_DISPLAY_NAME "HTML") + set(CPACK_COMPONENT_SPHINX-HTML_GROUP Documentation) + set(CPACK_IFW_COMPONENT_SPHINX-HTML_NAME "SphinxHTML") + set(CPACK_IFW_COMPONENT_SPHINX-HTML_SCRIPT + "@CMake_BINARY_DIR@/CMake.Documentation.SphinxHTML.qs") + set(CPACK_IFW_COMPONENT_SPHINX-HTML_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_SPHINX-SINGLEHTML_DISPLAY_NAME "Single HTML") + set(CPACK_COMPONENT_SPHINX-SINGLEHTML_GROUP Documentation) + set(CPACK_COMPONENT_SPHINX-SINGLEHTML_DISABLED TRUE) + set(CPACK_IFW_COMPONENT_SPHINX-SINGLEHTML_NAME "SphinxSingleHTML") + set(CPACK_IFW_COMPONENT_SPHINX-SINGLEHTML_VERSION + "@_CPACK_IFW_PACKAGE_VERSION@") + + set(CPACK_COMPONENT_SPHINX-QTHELP_DISPLAY_NAME "Qt Compressed Help") + set(CPACK_COMPONENT_SPHINX-QTHELP_GROUP Documentation) + set(CPACK_COMPONENT_SPHINX-QTHELP_DISABLED TRUE) + set(CPACK_IFW_COMPONENT_SPHINX-QTHELP_NAME "SphinxQtHelp") + set(CPACK_IFW_COMPONENT_SPHINX-QTHELP_VERSION "@_CPACK_IFW_PACKAGE_VERSION@") + endif() if(CPACK_GENERATOR MATCHES "CygwinSource") diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b91ab8..5e94028 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,17 @@ if(CMAKE_ENCODING_UTF8) set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) endif() +# option to use COMPONENT with install command +option(CMake_INSTALL_COMPONENTS "Using components when installing" OFF) +mark_as_advanced(CMake_INSTALL_COMPONENTS) +macro(CMake_OPTIONAL_COMPONENT NAME) + if(CMake_INSTALL_COMPONENTS) + set(COMPONENT COMPONENT ${NAME}) + else() + set(COMPONENT) + endif() +endmacro() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 9a60a10..b767ed6 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -251,6 +251,7 @@ Properties on Targets /prop_tgt/VS_WINRT_EXTENSIONS /prop_tgt/VS_WINRT_REFERENCES /prop_tgt/WIN32_EXECUTABLE + /prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS /prop_tgt/XCODE_ATTRIBUTE_an-attribute /prop_tgt/XCTEST diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index adbc40b..f54436a 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -275,6 +275,7 @@ Variables that Control the Build /variable/CMAKE_USE_RELATIVE_PATHS /variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD + /variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS /variable/CMAKE_WIN32_EXECUTABLE /variable/CMAKE_XCODE_ATTRIBUTE_an-attribute /variable/EXECUTABLE_OUTPUT_PATH diff --git a/Help/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.rst b/Help/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.rst new file mode 100644 index 0000000..3f48af8 --- /dev/null +++ b/Help/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.rst @@ -0,0 +1,18 @@ +WINDOWS_EXPORT_ALL_SYMBOLS +-------------------------- + +This property is implemented only for MS-compatible tools on Windows. + +Enable this boolean property to automatically create a module definition +(``.def``) file with all global symbols found in the input ``.obj`` files +for a ``SHARED`` library on Windows. The module definition file will be +passed to the linker causing all symbols to be exported from the ``.dll``. +For global *data* symbols, ``__declspec(dllimport)`` must still be used when +compiling against the code in the ``.dll``. All other function symbols will +be automatically exported and imported by callers. This simplifies porting +projects to Windows by reducing the need for explicit ``dllexport`` markup, +even in ``C++`` classes. + +This property is initialized by the value of +the :variable:`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` variable if it is set +when a target is created. diff --git a/Help/release/dev/add-apple-swift-language.rst b/Help/release/dev/add-apple-swift-language.rst new file mode 100644 index 0000000..60ce5d8 --- /dev/null +++ b/Help/release/dev/add-apple-swift-language.rst @@ -0,0 +1,9 @@ +add-apple-swift-language +------------------------ + +* CMake learned rudimentary support for the Apple Swift language. When using + the :generator:`Xcode` generator with Xcode 6.1 or higher, one may enable + the ``Swift`` language with the :command:`enable_language` command or the + :command:`project` command (this is an error with other generators or when + Xcode is too old). Then one may list ``.swift`` source files in targets + for compilation. diff --git a/Help/release/dev/auto_export_dll_symbols.rst b/Help/release/dev/auto_export_dll_symbols.rst new file mode 100644 index 0000000..9db2b5e --- /dev/null +++ b/Help/release/dev/auto_export_dll_symbols.rst @@ -0,0 +1,6 @@ +auto_export_dll_symbols +----------------------- + +* On Windows with MS-compatible tools, CMake learned to optionally + generate a module definition (``.def``) file for ``SHARED`` libraries. + See the :prop_tgt:`WINDOWS_EXPORT_ALL_SYMBOLS` target property. diff --git a/Help/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.rst b/Help/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.rst new file mode 100644 index 0000000..1636842 --- /dev/null +++ b/Help/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.rst @@ -0,0 +1,6 @@ +CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS +-------------------------------- + +Default value for :prop_tgt:`WINDOWS_EXPORT_ALL_SYMBOLS` target property. +This variable is used to initialize the property on each target as it is +created. diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake new file mode 100644 index 0000000..bff1ae9 --- /dev/null +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -0,0 +1,53 @@ + +#============================================================================= +# Copyright 2002-2015 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) + +if("${CMAKE_GENERATOR}" STREQUAL "Xcode") + if(XCODE_VERSION VERSION_LESS 6.1) + message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}") + endif() + set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift) + _cmake_find_compiler_path(Swift) +else() + message(FATAL_ERROR "Swift language not supported by \"${CMAKE_GENERATOR}\" generator") +endif() + +# Build a small source file to identify the compiler. +if(NOT CMAKE_Swift_COMPILER_ID_RUN) + set(CMAKE_Swift_COMPILER_ID_RUN 1) + + list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) + set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") + + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) + + # Try to identify the compiler. + set(CMAKE_Swift_COMPILER_ID) + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(Swift "" CompilerId/main.swift) +endif() + +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_Swift_COMPILER}" PATH) +endif () + +include(CMakeFindBinUtils) + +# configure variables set in this file for fast reload later on +configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake + @ONLY + ) diff --git a/Modules/CMakeSwiftCompiler.cmake.in b/Modules/CMakeSwiftCompiler.cmake.in new file mode 100644 index 0000000..45f0a31 --- /dev/null +++ b/Modules/CMakeSwiftCompiler.cmake.in @@ -0,0 +1,5 @@ +set(CMAKE_Swift_COMPILER "@CMAKE_Swift_COMPILER@") +set(CMAKE_Swift_COMPILER_ID "@CMAKE_Swift_COMPILER_ID@") + +set(CMAKE_Swift_COMPILER_ID_RUN 1) +set(CMAKE_Swift_SOURCE_FILE_EXTENSIONS swift) diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake new file mode 100644 index 0000000..61ad928 --- /dev/null +++ b/Modules/CMakeSwiftInformation.cmake @@ -0,0 +1,41 @@ + +#============================================================================= +# Copyright 2004-2015 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(CMAKE_Swift_OUTPUT_EXTENSION .o) + +# Load compiler-specific information. +if(CMAKE_Swift_COMPILER_ID) + include(Compiler/${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL) +endif() + +# load the system- and compiler specific files +if(CMAKE_Swift_COMPILER_ID) + # load a hardware specific file, mostly useful for embedded compilers + if(CMAKE_SYSTEM_PROCESSOR) + include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + endif() + include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL) +endif() + +# for most systems a module is the same as a shared library +# so unless the variable CMAKE_MODULE_EXISTS is set just +# copy the values from the LIBRARY variables +if(NOT CMAKE_MODULE_EXISTS) + set(CMAKE_SHARED_MODULE_Swift_FLAGS ${CMAKE_SHARED_LIBRARY_Swift_FLAGS}) + set(CMAKE_SHARED_MODULE_CREATE_Swift_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Swift_FLAGS}) +endif() + +include(CMakeCommonLanguageInclude) + +set(CMAKE_Swift_INFORMATION_LOADED 1) diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake new file mode 100644 index 0000000..9186426 --- /dev/null +++ b/Modules/CMakeTestSwiftCompiler.cmake @@ -0,0 +1,15 @@ + +#============================================================================= +# Copyright 2003-2015 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(CMAKE_Swift_COMPILER_WORKS 1) diff --git a/Modules/CompilerId/main.swift.in b/Modules/CompilerId/main.swift.in new file mode 100644 index 0000000..962e857 --- /dev/null +++ b/Modules/CompilerId/main.swift.in @@ -0,0 +1 @@ +println("CMakeSwiftCompilerId") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 2537e39..f72a7f2 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -46,8 +46,10 @@ else() set(_PLATFORM_LINK_FLAGS "") endif() +set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1) if(CMAKE_GENERATOR MATCHES "Visual Studio 6") set (CMAKE_NO_BUILD_TYPE 1) + set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 0) # not implemented for VS6 endif() if(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio") set (CMAKE_NO_BUILD_TYPE 1) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6d012fd..6940187 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -430,6 +430,7 @@ if (WIN32) set(SRCS ${SRCS} cmCallVisualStudioMacro.cxx cmCallVisualStudioMacro.h + bindexplib.cxx ) if(NOT UNIX) @@ -734,9 +735,17 @@ endif() include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) -install(TARGETS cmake ctest cpack DESTINATION bin) +# Install tools + +set(_tools cmake ctest cpack) + if(APPLE) - install(TARGETS cmakexbuild DESTINATION bin) + list(APPEND _tools cmakexbuild) endif() +foreach(_tool ${_tools}) + CMake_OPTIONAL_COMPONENT(${_tool}) + install(TARGETS ${_tool} DESTINATION bin ${COMPONENT}) +endforeach() + install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d573101..1348c2789 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 3) -set(CMake_VERSION_PATCH 20150707) +set(CMake_VERSION_PATCH 20150708) #set(CMake_VERSION_RC 1) diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 7d4e88c..93ff425 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -47,4 +47,5 @@ else() target_link_libraries(ccmake cmForm) endif() -install(TARGETS ccmake DESTINATION bin) +CMake_OPTIONAL_COMPONENT(ccmake) +install(TARGETS ccmake DESTINATION bin ${COMPONENT}) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 168f57d..038c411 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -14,6 +14,7 @@ project(QtDialog) if(POLICY CMP0020) cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required endif() +CMake_OPTIONAL_COMPONENT(cmake-gui) find_package(Qt5Widgets QUIET) if (Qt5Widgets_FOUND) include_directories(${Qt5Widgets_INCLUDE_DIRS}) @@ -47,7 +48,8 @@ if (Qt5Widgets_FOUND) get_filename_component(_qt_plugin_type "${_qt_plugin_type}" NAME) set(_qt_plugin_dest "PlugIns/${_qt_plugin_type}") install(FILES "${_qt_plugin_path}" - DESTINATION "${_qt_plugin_dest}") + DESTINATION "${_qt_plugin_dest}" + ${COMPONENT}) set(${_qt_plugins_var} "${${_qt_plugins_var}};\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_qt_plugin_dest}/${_qt_plugin_file}") else() @@ -58,7 +60,8 @@ if (Qt5Widgets_FOUND) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = PlugIns\n") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" - DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources") + DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources" + ${COMPONENT}) endif() if(WIN32 AND TARGET Qt5::Core) @@ -130,7 +133,8 @@ endif() if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) install(FILES ${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt - DESTINATION ${CMAKE_DATA_DIR}/Licenses) + DESTINATION ${CMAKE_DATA_DIR}/Licenses + ${COMPONENT}) set_property(SOURCE CMakeSetupDialog.cxx PROPERTY COMPILE_DEFINITIONS CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) endif() @@ -163,27 +167,36 @@ if(APPLE) ) endif() set(CMAKE_INSTALL_DESTINATION_ARGS - BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}") + BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" ${COMPONENT}) -install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS}) +install(TARGETS cmake-gui + RUNTIME DESTINATION bin ${COMPONENT} + ${CMAKE_INSTALL_DESTINATION_ARGS}) if(UNIX AND NOT APPLE) foreach (size IN ITEMS 32 128) install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeSetup${size}.png" DESTINATION "share/icons/hicolor/${size}x${size}/apps" + ${COMPONENT} RENAME "CMakeSetup.png") endforeach () # install a desktop file so CMake appears in the application start menu # with an icon - install(FILES CMake.desktop DESTINATION share/applications ) - install(FILES cmakecache.xml DESTINATION share/mime/packages ) + install(FILES CMake.desktop + DESTINATION share/applications + ${COMPONENT}) + install(FILES cmakecache.xml + DESTINATION share/mime/packages + ${COMPONENT}) endif() if(APPLE) - install(CODE "execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui - WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)") + install(CODE " + execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui + WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin) + " ${COMPONENT}) endif() if(APPLE OR WIN32) @@ -197,7 +210,7 @@ if(APPLE OR WIN32) include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\") set(BU_CHMOD_BUNDLE_ITEMS ON) fixup_bundle(\"${fixup_exe}\" \"${QT_PLUGINS}\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\") - ") + " ${COMPONENT}) endif() set(CMAKE_PACKAGE_QTGUI TRUE) diff --git a/Source/QtIFW/CMake.Dialogs.QtGUI.qs b/Source/QtIFW/CMake.Dialogs.QtGUI.qs new file mode 100644 index 0000000..219a0a9 --- /dev/null +++ b/Source/QtIFW/CMake.Dialogs.QtGUI.qs @@ -0,0 +1,21 @@ +// Component: CMake.Dialogs.QtGUI + +function Component() +{ + // Default constructor +} + +Component.prototype.createOperations = function() +{ + // Create shortcut + if (installer.value("os") === "win") { + + component.addOperation("CreateShortcut", + installer.value("TargetDir") + "/bin/cmake-gui.exe", + installer.value("StartMenuDir") + "/CMake (cmake-gui).lnk"); + + } + + // Call default implementation + component.createOperations(); +} diff --git a/Source/QtIFW/CMake.Documentation.SphinxHTML.qs.in b/Source/QtIFW/CMake.Documentation.SphinxHTML.qs.in new file mode 100644 index 0000000..5c929e8 --- /dev/null +++ b/Source/QtIFW/CMake.Documentation.SphinxHTML.qs.in @@ -0,0 +1,21 @@ +// Component: CMake.Documentation.SphinxHTML + +function Component() +{ + // Default constructor +} + +Component.prototype.createOperations = function() +{ + // Create shortcut + if (installer.value("os") === "win") { + + component.addOperation("CreateShortcut", + installer.value("TargetDir") + "/@CMAKE_DOC_DIR@/html/index.html", + installer.value("StartMenuDir") + "/CMake Documentation.lnk"); + + } + + // Call default implementation + component.createOperations(); +} diff --git a/Source/QtIFW/CMake.qs.in b/Source/QtIFW/CMake.qs.in new file mode 100644 index 0000000..828cc7c --- /dev/null +++ b/Source/QtIFW/CMake.qs.in @@ -0,0 +1,22 @@ +function Component() +{ + // Default constructor +} + +Component.prototype.createOperations = function() +{ + // Create shortcut + if (installer.value("os") === "win") { + + component.addOperation("CreateShortcut", + installer.value("TargetDir") + "/@CMAKE_DOC_DIR@/cmake.org.html", + installer.value("StartMenuDir") + "/CMake Web Site.lnk"); + + component.addOperation("CreateShortcut", + installer.value("TargetDir") + "/cmake-maintenance.exe", + installer.value("StartMenuDir") + "/CMake Maintenance Tool.lnk"); + } + + // Call default implementation + component.createOperations(); +} diff --git a/Source/QtIFW/installscript.qs.in b/Source/QtIFW/installscript.qs.in index 570dba1..3411e34 100644 --- a/Source/QtIFW/installscript.qs.in +++ b/Source/QtIFW/installscript.qs.in @@ -5,20 +5,20 @@ function Component() Component.prototype.createOperations = function() { - // call default implementation to actually install applications! - component.createOperations(); - // Create shortcut if (installer.value("os") === "win") { @_CPACK_IFW_SHORTCUT_OPTIONAL@ component.addOperation("CreateShortcut", - installer.value("TargetDir") + "/cmake.org.html", + installer.value("TargetDir") + "/@CMAKE_DOC_DIR@/cmake.org.html", installer.value("StartMenuDir") + "/CMake Web Site.lnk"); component.addOperation("CreateShortcut", installer.value("TargetDir") + "/cmake-maintenance.exe", installer.value("StartMenuDir") + "/CMake Maintenance Tool.lnk"); } + + // Call default implementation + component.createOperations(); } diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx new file mode 100644 index 0000000..11e3f34 --- /dev/null +++ b/Source/bindexplib.cxx @@ -0,0 +1,428 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +/*------------------------------------------------------------------------- + Portions of this source have been derived from the 'bindexplib' tool + provided by the CERN ROOT Data Analysis Framework project (root.cern.ch). + Permission has been granted by Pere Mato <pere.mato@cern.ch> to distribute + this derived work under the CMake license. +-------------------------------------------------------------------------*/ + +/* +*---------------------------------------------------------------------- +* Program: dumpexts.exe +* Author: Gordon Chaffee +* +* History: The real functionality of this file was written by +* Matt Pietrek in 1993 in his pedump utility. I've +* modified it to dump the externals in a bunch of object +* files to create a .def file. +* +* Notes: Visual C++ puts an underscore before each exported symbol. +* This file removes them. I don't know if this is a problem +* this other compilers. If _MSC_VER is defined, +* the underscore is removed. If not, it isn't. To get a +* full dump of an object file, use the -f option. This can +* help determine the something that may be different with a +* compiler other than Visual C++. +* ====================================== +* Corrections (Axel 2006-04-04): +* Conversion to C++. Mostly. +* + * Extension (Axel 2006-03-15) + * As soon as an object file contains an /EXPORT directive (which + * is generated by the compiler when a symbol is declared as + * declspec(dllexport)) no to-be-exported symbols are printed, + * as the linker will see these directives, and if those directives + * are present we only export selectively (i.e. we trust the + * programmer). + * + * ====================================== +* ====================================== +* Corrections (Valery Fine 23/02/98): +* +* The "(vector) deleting destructor" MUST not be exported +* To recognize it the following test are introduced: +* "@@UAEPAXI@Z" scalar deleting dtor +* "@@QAEPAXI@Z" vector deleting dtor +* "AEPAXI@Z" vector deleting dtor with thunk adjustor +* ====================================== +* Corrections (Valery Fine 12/02/97): +* +* It created a wrong EXPORTS for the global pointers and constants. +* The Section Header has been involved to discover the missing information +* Now the pointers are correctly supplied supplied with "DATA" descriptor +* the constants with no extra descriptor. +* +* Corrections (Valery Fine 16/09/96): +* +* It didn't work for C++ code with global variables and class definitons +* The DumpExternalObject function has been introduced to generate .DEF file +* +* Author: Valery Fine 16/09/96 (E-mail: fine@vxcern.cern.ch) +*---------------------------------------------------------------------- +*/ + +#include <cmsys/Encoding.hxx> +#include <windows.h> +#include <stdio.h> +#include <string> +#include <fstream> +#include <iostream> + +typedef struct cmANON_OBJECT_HEADER_BIGOBJ { + /* same as ANON_OBJECT_HEADER_V2 */ + WORD Sig1; // Must be IMAGE_FILE_MACHINE_UNKNOWN + WORD Sig2; // Must be 0xffff + WORD Version; // >= 2 (implies the Flags field is present) + WORD Machine; // Actual machine - IMAGE_FILE_MACHINE_xxx + DWORD TimeDateStamp; + CLSID ClassID; // {D1BAA1C7-BAEE-4ba9-AF20-FAF66AA4DCB8} + DWORD SizeOfData; // Size of data that follows the header + DWORD Flags; // 0x1 -> contains metadata + DWORD MetaDataSize; // Size of CLR metadata + DWORD MetaDataOffset; // Offset of CLR metadata + + /* bigobj specifics */ + DWORD NumberOfSections; // extended from WORD + DWORD PointerToSymbolTable; + DWORD NumberOfSymbols; +} cmANON_OBJECT_HEADER_BIGOBJ; + +typedef struct _cmIMAGE_SYMBOL_EX { + union { + BYTE ShortName[8]; + struct { + DWORD Short; // if 0, use LongName + DWORD Long; // offset into string table + } Name; + DWORD LongName[2]; // PBYTE [2] + } N; + DWORD Value; + LONG SectionNumber; + WORD Type; + BYTE StorageClass; + BYTE NumberOfAuxSymbols; +} cmIMAGE_SYMBOL_EX; +typedef cmIMAGE_SYMBOL_EX UNALIGNED *cmPIMAGE_SYMBOL_EX; + +PIMAGE_SECTION_HEADER GetSectionHeaderOffset(PIMAGE_FILE_HEADER + pImageFileHeader) +{ + return (PIMAGE_SECTION_HEADER) + ((DWORD_PTR)pImageFileHeader + + IMAGE_SIZEOF_FILE_HEADER + + pImageFileHeader->SizeOfOptionalHeader); +} + +PIMAGE_SECTION_HEADER GetSectionHeaderOffset(cmANON_OBJECT_HEADER_BIGOBJ* + pImageFileHeader) +{ + return (PIMAGE_SECTION_HEADER) + ((DWORD_PTR)pImageFileHeader + + sizeof(cmANON_OBJECT_HEADER_BIGOBJ)); +} + +/* ++ * Utility func, strstr with size ++ */ +const char* StrNStr(const char* start, const char* find, size_t &size) { + size_t len; + const char* hint; + + if (!start || !find || !size) { + size = 0; + return 0; + } + len = strlen(find); + + while ((hint = (const char*) memchr(start, find[0], size-len+1))) { + size -= (hint - start); + if (!strncmp(hint, find, len)) + return hint; + start = hint + 1; + } + + size = 0; + return 0; +} + +template < + // cmANON_OBJECT_HEADER_BIGOBJ or IMAGE_FILE_HEADER + class ObjectHeaderType, + // cmPIMAGE_SYMBOL_EX or PIMAGE_SYMBOL + class SymbolTableType> +class DumpSymbols +{ +public: + /* + *---------------------------------------------------------------------- + * Constructor -- + * + * Initialize variables from pointer to object header. + * + *---------------------------------------------------------------------- + */ + + DumpSymbols(ObjectHeaderType* ih, + FILE* fout) { + this->ObjectImageHeader = ih; + this->SymbolTable = (SymbolTableType*) + ((DWORD_PTR)this->ObjectImageHeader + + this->ObjectImageHeader->PointerToSymbolTable); + this->FileOut = fout; + this->SectionHeaders = + GetSectionHeaderOffset(this->ObjectImageHeader); + this->ImportFlag = true; + this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; + } + + /* + *---------------------------------------------------------------------- + * HaveExportedObjects -- + * + * Returns true if export directives (declspec(dllexport)) exist. + * + *---------------------------------------------------------------------- + */ + + bool HaveExportedObjects() { + WORD i = 0; + size_t size = 0; + const char * rawdata = 0; + PIMAGE_SECTION_HEADER pDirectivesSectionHeader = 0; + PIMAGE_SECTION_HEADER pSectionHeaders = this->SectionHeaders; + for(i = 0; (i < this->ObjectImageHeader->NumberOfSections && + !pDirectivesSectionHeader); i++) + if (!strncmp((const char*)&pSectionHeaders[i].Name[0], ".drectve",8)) + pDirectivesSectionHeader = &pSectionHeaders[i]; + if (!pDirectivesSectionHeader) return 0; + + rawdata=(const char*) + this->ObjectImageHeader+pDirectivesSectionHeader->PointerToRawData; + if (!pDirectivesSectionHeader->PointerToRawData || !rawdata) return 0; + + size = pDirectivesSectionHeader->SizeOfRawData; + const char* posImportFlag = rawdata; + while ((posImportFlag = StrNStr(posImportFlag, " /EXPORT:", size))) { + const char* lookingForDict = posImportFlag + 9; + if (!strncmp(lookingForDict, "_G__cpp_",8) || + !strncmp(lookingForDict, "_G__set_cpp_",12)) { + posImportFlag = lookingForDict; + continue; + } + + const char* lookingForDATA = posImportFlag + 9; + while (*(++lookingForDATA) && *lookingForDATA != ' '); + lookingForDATA -= 5; + // ignore DATA exports + if (strncmp(lookingForDATA, ",DATA", 5)) break; + posImportFlag = lookingForDATA + 5; + } + if(posImportFlag) { + return true; + } + return false; + } + + /* + *---------------------------------------------------------------------- + * DumpObjFile -- + * + * Dump an object file's exported symbols. + *---------------------------------------------------------------------- + */ + void DumpObjFile() { + if(!HaveExportedObjects()) { + this->DumpExternalsObjects(); + } + } + + /* + *---------------------------------------------------------------------- + * DumpExternalsObjects -- + * + * Dumps a COFF symbol table from an OBJ. + *---------------------------------------------------------------------- + */ + void DumpExternalsObjects() { + unsigned i; + PSTR stringTable; + std::string symbol; + DWORD SectChar; + /* + * The string table apparently starts right after the symbol table + */ + stringTable = (PSTR)&this->SymbolTable[this->SymbolCount]; + SymbolTableType* pSymbolTable = this->SymbolTable; + for ( i=0; i < this->SymbolCount; i++ ) { + if (pSymbolTable->SectionNumber > 0 && + ( pSymbolTable->Type == 0x20 || pSymbolTable->Type == 0x0)) { + if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) { + /* + * The name of the Function entry points + */ + if (pSymbolTable->N.Name.Short != 0) { + symbol = ""; + symbol.insert(0, (const char *)pSymbolTable->N.ShortName, 8); + } else { + symbol = stringTable + pSymbolTable->N.Name.Long; + } + + // clear out any leading spaces + while (isspace(symbol[0])) symbol.erase(0,1); + // if it starts with _ and has an @ then it is a __cdecl + // so remove the @ stuff for the export + if(symbol[0] == '_') { + std::string::size_type posAt = symbol.find('@'); + if (posAt != std::string::npos) { + symbol.erase(posAt); + } + } + if (symbol[0] == '_') symbol.erase(0,1); + if (this->ImportFlag) { + this->ImportFlag = false; + fprintf(this->FileOut,"EXPORTS \n"); + } + /* + Check whether it is "Scalar deleting destructor" and + "Vector deleting destructor" + */ + const char *scalarPrefix = "??_G"; + const char *vectorPrefix = "??_E"; + // original code had a check for + // symbol.find("real@") == std::string::npos) + // but if this disallows memmber functions with the name real + // if scalarPrefix and vectorPrefix are not found then print + // the symbol + if (symbol.compare(0, 4, scalarPrefix) && + symbol.compare(0, 4, vectorPrefix) ) + { + SectChar = + this-> + SectionHeaders[pSymbolTable->SectionNumber-1].Characteristics; + if (!pSymbolTable->Type && (SectChar & IMAGE_SCN_MEM_WRITE)) { + // Read only (i.e. constants) must be excluded + fprintf(this->FileOut, "\t%s \t DATA\n", symbol.c_str()); + } else { + if ( pSymbolTable->Type || + !(SectChar & IMAGE_SCN_MEM_READ)) { + fprintf(this->FileOut, "\t%s\n", symbol.c_str()); + } else { + // printf(" strange symbol: %s \n",symbol.c_str()); + } + } + } + } + } + else if (pSymbolTable->SectionNumber == IMAGE_SYM_UNDEFINED && + !pSymbolTable->Type && 0) { + /* + * The IMPORT global variable entry points + */ + if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) { + symbol = stringTable + pSymbolTable->N.Name.Long; + while (isspace(symbol[0])) symbol.erase(0,1); + if (symbol[0] == '_') symbol.erase(0,1); + if (!this->ImportFlag) { + this->ImportFlag = true; + fprintf(this->FileOut,"IMPORTS \n"); + } + fprintf(this->FileOut, "\t%s DATA \n", symbol.c_str()+1); + } + } + + /* + * Take into account any aux symbols + */ + i += pSymbolTable->NumberOfAuxSymbols; + pSymbolTable += pSymbolTable->NumberOfAuxSymbols; + pSymbolTable++; + } + } +private: + bool ImportFlag; + FILE* FileOut; + DWORD_PTR SymbolCount; + PIMAGE_SECTION_HEADER SectionHeaders; + ObjectHeaderType* ObjectImageHeader; + SymbolTableType* SymbolTable; +}; + +bool +DumpFile(const char* filename, FILE *fout) +{ + HANDLE hFile; + HANDLE hFileMapping; + LPVOID lpFileBase; + PIMAGE_DOS_HEADER dosHeader; + + hFile = CreateFileW(cmsys::Encoding::ToWide(filename).c_str(), + GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + + if (hFile == INVALID_HANDLE_VALUE) { + fprintf(stderr, "Couldn't open file '%s' with CreateFile()\n", filename); + return false; + } + + hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hFileMapping == 0) { + CloseHandle(hFile); + fprintf(stderr, "Couldn't open file mapping with CreateFileMapping()\n"); + return false; + } + + lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); + if (lpFileBase == 0) { + CloseHandle(hFileMapping); + CloseHandle(hFile); + fprintf(stderr, "Couldn't map view of file with MapViewOfFile()\n"); + return false; + } + + dosHeader = (PIMAGE_DOS_HEADER)lpFileBase; + if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { + fprintf(stderr, "File is an executable. I don't dump those.\n"); + return false; + } + /* Does it look like a i386 COFF OBJ file??? */ + else if ( + ((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)) + && (dosHeader->e_sp == 0) + ) { + /* + * The two tests above aren't what they look like. They're + * really checking for IMAGE_FILE_HEADER.Machine == i386 (0x14C) + * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0; + */ + DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> + symbolDumper((PIMAGE_FILE_HEADER) lpFileBase, fout); + symbolDumper.DumpObjFile(); + } else { + // check for /bigobj format + cmANON_OBJECT_HEADER_BIGOBJ* h = + (cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase; + if(h->Sig1 == 0x0 && h->Sig2 == 0xffff) { + DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> + symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*) lpFileBase, fout); + symbolDumper.DumpObjFile(); + } else { + printf("unrecognized file format in '%s'\n", filename); + return false; + } + } + UnmapViewOfFile(lpFileBase); + CloseHandle(hFileMapping); + CloseHandle(hFile); + return true; +} diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 438d60e..1d583eb 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -13,12 +13,14 @@ #include "cmGlobalVisualStudioGenerator.h" #include "cmCallVisualStudioMacro.h" +#include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudioGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" #include <cmsys/Encoding.hxx> +#include "cmAlgorithms.h" //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm) @@ -896,3 +898,71 @@ std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir( } return tmp; } + +void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( + cmGeneratorTarget* gt, std::vector<cmCustomCommand>& commands, + std::string const& configName) +{ + std::vector<std::string> outputs; + std::string deffile = gt->ObjectDirectory; + deffile += "/exportall.def"; + outputs.push_back(deffile); + std::vector<std::string> empty; + std::vector<cmSourceFile const*> objectSources; + gt->GetObjectSources(objectSources, configName); + std::map<cmSourceFile const*, std::string> mapping; + for(std::vector<cmSourceFile const*>::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + gt->LocalGenerator-> + ComputeObjectFilenames(mapping, gt); + std::string obj_dir = gt->ObjectDirectory; + std::string cmakeCommand = cmSystemTools::GetCMakeCommand(); + cmSystemTools::ConvertToWindowsExtendedPath(cmakeCommand); + cmCustomCommandLine cmdl; + cmdl.push_back(cmakeCommand); + cmdl.push_back("-E"); + cmdl.push_back("__create_def"); + cmdl.push_back(deffile); + std::string obj_dir_expanded = obj_dir; + cmSystemTools::ReplaceString(obj_dir_expanded, + this->GetCMakeCFGIntDir(), + configName.c_str()); + std::string objs_file = obj_dir_expanded; + cmSystemTools::MakeDirectory(objs_file.c_str()); + objs_file += "/objects.txt"; + cmdl.push_back(objs_file); + cmGeneratedFileStream fout(objs_file.c_str()); + if(!fout) + { + cmSystemTools::Error("could not open ", objs_file.c_str()); + return; + } + for(std::vector<cmSourceFile const*>::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + // Find the object file name corresponding to this source file. + std::map<cmSourceFile const*, std::string>::const_iterator + map_it = mapping.find(*it); + // It must exist because we populated the mapping just above. + assert(!map_it->second.empty()); + std::string objFile = obj_dir + map_it->second; + // replace $(ConfigurationName) in the object names + cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(), + configName.c_str()); + if(cmHasLiteralSuffix(objFile, ".obj")) + { + fout << objFile << "\n"; + } + } + cmCustomCommandLines commandLines; + commandLines.push_back(cmdl); + cmCustomCommand command(gt->Target->GetMakefile(), + outputs, empty, empty, + commandLines, + "Auto build dll exports", + "."); + commands.push_back(command); +} diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 41843b3..8e2d6a4 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -103,6 +103,10 @@ public: const std::string& config) const; void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + + void AddSymbolExportCommand( + cmGeneratorTarget*, std::vector<cmCustomCommand>& commands, + std::string const& configName); protected: virtual void Generate(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 505929e..21075bb 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -843,6 +843,10 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, { sourcecode += ".c.objc"; } + else if (ext == "swift") + { + sourcecode += ".swift"; + } else if(ext == "plist") { sourcecode += ".text.plist"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dc3a16d..a0e9e4d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1081,6 +1081,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + if (target.GetType() == cmTarget::SHARED_LIBRARY && + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) + { + if (target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)/exportall.def"); + } + } switch(target.GetType()) { case cmTarget::UNKNOWN_LIBRARY: @@ -2015,7 +2023,28 @@ void cmLocalVisualStudio7Generator // Add pre-link event. tool = this->FortranProject? "VFPreLinkEventTool":"VCPreLinkEventTool"; event.Start(tool); - event.Write(target.GetPreLinkCommands()); + bool addedPrelink = false; + if (target.GetType() == cmTarget::SHARED_LIBRARY && + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) + { + if (target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + addedPrelink = true; + std::vector<cmCustomCommand> commands = + target.GetPreLinkCommands(); + cmGlobalVisualStudioGenerator* gg + = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator); + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + gg->AddSymbolExportCommand( + gt, commands, configName); + event.Write(commands); + } + } + if (!addedPrelink) + { + event.Write(target.GetPreLinkCommands()); + } cmsys::auto_ptr<cmCustomCommand> pcc( this->MaybeCreateImplibDir(target, configName, this->FortranProject)); if(pcc.get()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 660027c..696dcc4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmSourceFile.h" #include "cmTarget.h" #include "cmake.h" +#include "cmAlgorithms.h" //---------------------------------------------------------------------------- cmMakefileLibraryTargetGenerator @@ -563,6 +564,58 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules useResponseFileForObjects, buildObjs, depends, useWatcomQuote); + // maybe create .def file from list of objects + if (this->Target->GetType() == cmTarget::SHARED_LIBRARY && + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) + { + if(this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + std::string name_of_def_file = + this->Target->GetSupportDirectory(); + name_of_def_file += std::string("/") + + this->Target->GetName(); + name_of_def_file += ".def"; + std::string cmd = cmSystemTools::GetCMakeCommand(); + cmd = this->Convert(cmd, cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + cmd += " -E __create_def "; + cmd += this->Convert(name_of_def_file, + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + cmd += " "; + std::string objlist_file = name_of_def_file; + objlist_file += ".objs"; + cmd += this->Convert(objlist_file, + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + real_link_commands.push_back(cmd); + // create a list of obj files for the -E __create_def to read + cmGeneratedFileStream fout(objlist_file.c_str()); + for(std::vector<std::string>::const_iterator i = this->Objects.begin(); + i != this->Objects.end(); ++i) + { + if(cmHasLiteralSuffix(*i, ".obj")) + { + fout << *i << "\n"; + } + } + for(std::vector<std::string>::const_iterator i = + this->ExternalObjects.begin(); + i != this->ExternalObjects.end(); ++i) + { + fout << *i << "\n"; + } + // now add the def file link flag + linkFlags += " "; + linkFlags += + this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); + linkFlags += this->Convert(name_of_def_file, + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + linkFlags += " "; + } + } + cmLocalGenerator::RuleVariables vars; vars.TargetPDB = targetOutPathPDB.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2fe53bf..88da09b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -486,6 +486,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() linkPath, &genTarget, useWatcomQuote); + if(this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") + && target.GetType() == cmTarget::SHARED_LIBRARY) + { + if(target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + std::string dllname = targetOutput; + std::string name_of_def_file + = target.GetSupportDirectory(); + name_of_def_file += "/" + target.GetName(); + name_of_def_file += ".def "; + vars["LINK_FLAGS"] += " /DEF:"; + vars["LINK_FLAGS"] += this->GetLocalGenerator() + ->ConvertToOutputFormat(name_of_def_file.c_str(), + cmLocalGenerator::SHELL); + } + } this->addPoolNinjaVariable("JOB_POOL_LINK", &target, vars); @@ -600,6 +616,44 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } + // maybe create .def file from list of objects + if (target.GetType() == cmTarget::SHARED_LIBRARY && + this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) + { + if(target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + std::string cmakeCommand = + this->GetLocalGenerator()->ConvertToOutputFormat( + cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); + std::string dllname = targetOutput; + std::string name_of_def_file + = target.GetSupportDirectory(); + name_of_def_file += "/" + target.GetName(); + name_of_def_file += ".def"; + std::string cmd = cmakeCommand; + cmd += " -E __create_def "; + cmd += this->GetLocalGenerator() + ->ConvertToOutputFormat(name_of_def_file.c_str(), + cmLocalGenerator::SHELL); + cmd += " "; + cmNinjaDeps objs = this->GetObjects(); + std::string obj_list_file = name_of_def_file; + obj_list_file += ".objs"; + cmd += this->GetLocalGenerator() + ->ConvertToOutputFormat(obj_list_file.c_str(), + cmLocalGenerator::SHELL); + preLinkCmdLines.push_back(cmd); + // create a list of obj files for the -E __create_def to read + cmGeneratedFileStream fout(obj_list_file.c_str()); + for(cmNinjaDeps::iterator i=objs.begin(); i != objs.end(); ++i) + { + if(cmHasLiteralSuffix(*i, ".obj")) + { + fout << *i << "\n"; + } + } + } + } // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for // the link commands. if (!preLinkCmdLines.empty()) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4b031bc..d309927 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -429,6 +429,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } + if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY) + { + this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", 0); + } + if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) { this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 591c2db..a2f9bca 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2466,6 +2466,15 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) "%(IgnoreSpecificDefaultLibraries)"); } + if (this->Target->GetType() == cmTarget::SHARED_LIBRARY && + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) + { + if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + linkOptions.AddFlag("ModuleDefinitionFile", "$(IntDir)exportall.def"); + } + } + this->LinkOptions[config] = pOptions.release(); return true; } @@ -2613,8 +2622,25 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() void cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) { - this->WriteEvent("PreLinkEvent", - this->Target->GetPreLinkCommands(), configName); + bool addedPrelink = false; + if (this->Target->GetType() == cmTarget::SHARED_LIBRARY && + this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) + { + if (this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) + { + addedPrelink = true; + std::vector<cmCustomCommand> commands = + this->Target->GetPreLinkCommands(); + this->GlobalGenerator->AddSymbolExportCommand( + this->GeneratorTarget, commands, configName); + this->WriteEvent("PreLinkEvent", commands, configName); + } + } + if (!addedPrelink) + { + this->WriteEvent("PreLinkEvent", + this->Target->GetPreLinkCommands(), configName); + } this->WriteEvent("PreBuildEvent", this->Target->GetPreBuildCommands(), configName); this->WriteEvent("PostBuildEvent", diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 3ea2186..63838b4 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -34,6 +34,10 @@ #include <time.h> #include <stdlib.h> // required for atoi +#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +// defined in binexplib.cxx +bool DumpFile(const char* filename, FILE *fout); +#endif void CMakeCommandUsage(const char* program) { @@ -211,6 +215,41 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 0; } +#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) + else if(args[1] == "__create_def") + { + if(args.size() < 4) + { + std::cerr << + "__create_def Usage: -E __create_def outfile.def objlistfile\n"; + return 1; + } + FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+"); + if(!fout) + { + std::cerr << "could not open output .def file: " << args[2].c_str() + << "\n"; + return 1; + } + cmsys::ifstream fin(args[3].c_str(), + std::ios::in | std::ios::binary); + if(!fin) + { + std::cerr << "could not open object list file: " << args[3].c_str() + << "\n"; + return 1; + } + std::string objfile; + while(cmSystemTools::GetLineFromStream(fin, objfile)) + { + if (!DumpFile(objfile.c_str(), fout)) + { + return 1; + } + } + return 0; + } +#endif // run include what you use command and then run the compile // command. This is an internal undocumented option and should // only be used by CMake itself when running iwyu. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8865063..8de1c79 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -260,6 +260,12 @@ if(BUILD_TESTING) ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) set_tests_properties(MissingSourceFile PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") + if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6.1) + if(CMAKE_GENERATOR STREQUAL "Xcode") + ADD_TEST_MACRO(SwiftMix SwiftMix) + ADD_TEST_MACRO(SwiftOnly SwiftOnly) + endif() + endif() if(CMAKE_Fortran_COMPILER) ADD_TEST_MACRO(FortranOnly FortranOnly) endif() diff --git a/Tests/RunCMake/AutoExportDll/AutoExport.cmake b/Tests/RunCMake/AutoExportDll/AutoExport.cmake new file mode 100644 index 0000000..3b2b2c5 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AutoExport.cmake @@ -0,0 +1,7 @@ +project(autoexport) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${autoexport_BINARY_DIR}/bin) +add_subdirectory(sub) +add_library(autoexport SHARED hello.cxx world.cxx foo.c) +add_executable(say say.cxx) +target_link_libraries(say autoexport autoexport2) diff --git a/Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt b/Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt new file mode 100644 index 0000000..d483c2c --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AutoExportBuild-stderr.txt @@ -0,0 +1 @@ +^.*$ diff --git a/Tests/RunCMake/AutoExportDll/CMakeLists.txt b/Tests/RunCMake/AutoExportDll/CMakeLists.txt new file mode 100644 index 0000000..18dfd26 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake new file mode 100644 index 0000000..3784a6a --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -0,0 +1,26 @@ +include(RunCMake) +set(RunCMake_TEST_NO_CLEAN TRUE) +set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/AutoExport-build") +# start by cleaning up because we don't clean up along the way +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +# configure the AutoExport test +run_cmake(AutoExport) +unset(RunCMake_TEST_OPTIONS) +# don't run this test on VS 6 as it is not supported +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 6|Watcom WMake|Borland Makefiles") + return() +endif() +# we build debug so the say.exe will be found in Debug/say.exe for +# Visual Studio generators +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") + set(INTDIR "Debug/") +endif() +# build AutoExport +run_cmake_command(AutoExportBuild ${CMAKE_COMMAND} --build + ${RunCMake_TEST_BINARY_DIR} --config Debug --clean-first) +# run the executable that uses symbols from the dll +if(WIN32) + set(EXE_EXT ".exe") +endif() +run_cmake_command(AutoExportRun + ${RunCMake_BINARY_DIR}/AutoExport-build/bin/${INTDIR}say${EXE_EXT}) diff --git a/Tests/RunCMake/AutoExportDll/foo.c b/Tests/RunCMake/AutoExportDll/foo.c new file mode 100644 index 0000000..4b1318b --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/foo.c @@ -0,0 +1,15 @@ +#ifdef _MSC_VER +#include "windows.h" +#else +#define WINAPI +#endif + +int WINAPI foo() +{ + return 10; +} + +int bar() +{ + return 5; +} diff --git a/Tests/RunCMake/AutoExportDll/hello.cxx b/Tests/RunCMake/AutoExportDll/hello.cxx new file mode 100644 index 0000000..3933fc1 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/hello.cxx @@ -0,0 +1,13 @@ +#include <stdio.h> +#include "hello.h" +int Hello::Data = 0; +void Hello::real() +{ + return; +} +void hello() +{ + printf("hello"); +} +void Hello::operator delete[](void*) {}; +void Hello::operator delete(void*) {}; diff --git a/Tests/RunCMake/AutoExportDll/hello.h b/Tests/RunCMake/AutoExportDll/hello.h new file mode 100644 index 0000000..3749b97 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/hello.h @@ -0,0 +1,18 @@ +#ifndef _MSC_VER +#define winexport +#else +#ifdef autoexport_EXPORTS +#define winexport +#else +#define winexport __declspec(dllimport) +#endif +#endif + +class Hello +{ +public: + static winexport int Data; + void real(); + static void operator delete[](void*); + static void operator delete(void*); +}; diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx new file mode 100644 index 0000000..655b3c2 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/say.cxx @@ -0,0 +1,37 @@ +#include <stdio.h> +#include "hello.h" +#ifdef _MSC_VER +#include "windows.h" +#else +#define WINAPI +#endif + +extern "C" +{ +// test __cdecl stuff + int WINAPI foo(); +// test regular C + int bar(); +} + +// test c++ functions +// forward declare hello and world +void hello(); +void world(); + +int main() +{ + // test static data (needs declspec to work) + Hello::Data = 120; + Hello h; + h.real(); + hello(); + printf(" "); + world(); + printf("\n"); + foo(); + printf("\n"); + bar(); + printf("\n"); + return 0; +} diff --git a/Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt b/Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt new file mode 100644 index 0000000..8b70e7d --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/sub/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(autoexport2 SHARED sub.cxx) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Try msvc "big" object format. + target_compile_options(autoexport2 PRIVATE /bigobj) +endif() diff --git a/Tests/RunCMake/AutoExportDll/sub/sub.cxx b/Tests/RunCMake/AutoExportDll/sub/sub.cxx new file mode 100644 index 0000000..9766b41 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/sub/sub.cxx @@ -0,0 +1,4 @@ +int sub() +{ + return 10; +} diff --git a/Tests/RunCMake/AutoExportDll/world.cxx b/Tests/RunCMake/AutoExportDll/world.cxx new file mode 100644 index 0000000..3a54df3 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/world.cxx @@ -0,0 +1,6 @@ +#include "stdio.h" + +void world() +{ + printf("world"); +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index bc706d3..c0ac5c8 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -59,6 +59,10 @@ function(add_RunCMake_test_group test types) endforeach() endfunction() +if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 6.1) + set(Swift_ARGS -DXCODE_BELOW_6_1=1) +endif() + if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3) set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1) endif() @@ -132,6 +136,7 @@ add_RunCMake_test(GNUInstallDirs) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(Swift) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetSources) add_RunCMake_test(find_dependency) @@ -266,3 +271,6 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") endif() add_RunCMake_test_group(CPack "DEB;RPM") +# add a test to make sure symbols are exported from a shared library +# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used +add_RunCMake_test(AutoExportDll) diff --git a/Tests/RunCMake/Swift/CMakeLists.txt b/Tests/RunCMake/Swift/CMakeLists.txt new file mode 100644 index 0000000..74b3ff8 --- /dev/null +++ b/Tests/RunCMake/Swift/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Swift/Enable-stdout.txt b/Tests/RunCMake/Swift/Enable-stdout.txt new file mode 100644 index 0000000..39e133f --- /dev/null +++ b/Tests/RunCMake/Swift/Enable-stdout.txt @@ -0,0 +1 @@ +-- The Swift compiler identification is Apple diff --git a/Tests/RunCMake/Swift/Enable.cmake b/Tests/RunCMake/Swift/Enable.cmake new file mode 100644 index 0000000..19f297a --- /dev/null +++ b/Tests/RunCMake/Swift/Enable.cmake @@ -0,0 +1 @@ +enable_language(Swift) diff --git a/Tests/RunCMake/Swift/NotSupported-result.txt b/Tests/RunCMake/Swift/NotSupported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Swift/NotSupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Swift/NotSupported-stderr.txt b/Tests/RunCMake/Swift/NotSupported-stderr.txt new file mode 100644 index 0000000..9a9c23f --- /dev/null +++ b/Tests/RunCMake/Swift/NotSupported-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at .*/Modules/CMakeDetermineSwiftCompiler.cmake:[0-9]+ \(message\): + Swift language not supported by "[^"]*" generator +Call Stack \(most recent call first\): + NotSupported.cmake:[0-9]+ \(enable_language\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Swift/NotSupported.cmake b/Tests/RunCMake/Swift/NotSupported.cmake new file mode 100644 index 0000000..19f297a --- /dev/null +++ b/Tests/RunCMake/Swift/NotSupported.cmake @@ -0,0 +1 @@ +enable_language(Swift) diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake new file mode 100644 index 0000000..0a57121 --- /dev/null +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) + +if(RunCMake_GENERATOR STREQUAL Xcode) + if(XCODE_BELOW_6_1) + run_cmake(XcodeTooOld) + else() + run_cmake(Enable) + endif() +else() + run_cmake(NotSupported) +endif() diff --git a/Tests/RunCMake/Swift/XcodeTooOld-result.txt b/Tests/RunCMake/Swift/XcodeTooOld-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Swift/XcodeTooOld-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Swift/XcodeTooOld-stderr.txt b/Tests/RunCMake/Swift/XcodeTooOld-stderr.txt new file mode 100644 index 0000000..8d18f29 --- /dev/null +++ b/Tests/RunCMake/Swift/XcodeTooOld-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at .*/Modules/CMakeDetermineSwiftCompiler.cmake:[0-9]+ \(message\): + Swift language not supported by Xcode [0-9.]+ +Call Stack \(most recent call first\): + XcodeTooOld.cmake:[0-9]+ \(enable_language\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Swift/XcodeTooOld.cmake b/Tests/RunCMake/Swift/XcodeTooOld.cmake new file mode 100644 index 0000000..19f297a --- /dev/null +++ b/Tests/RunCMake/Swift/XcodeTooOld.cmake @@ -0,0 +1 @@ +enable_language(Swift) diff --git a/Tests/SwiftMix/CMain.c b/Tests/SwiftMix/CMain.c new file mode 100644 index 0000000..13e2f8c --- /dev/null +++ b/Tests/SwiftMix/CMain.c @@ -0,0 +1,4 @@ +extern int ObjCMain(int argc, char const* const argv[]); +int main(int argc, char* argv[]) { + return ObjCMain(argc, argv); +} diff --git a/Tests/SwiftMix/CMakeLists.txt b/Tests/SwiftMix/CMakeLists.txt new file mode 100644 index 0000000..5e50470 --- /dev/null +++ b/Tests/SwiftMix/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.3) +project(SwiftMix C Swift) + +add_executable(SwiftMix CMain.c ObjCMain.m SwiftMain.swift ObjC-Swift.h) +set_property(TARGET SwiftMix PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "ObjC-Swift.h") diff --git a/Tests/SwiftMix/ObjC-Swift.h b/Tests/SwiftMix/ObjC-Swift.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/SwiftMix/ObjC-Swift.h diff --git a/Tests/SwiftMix/ObjCMain.m b/Tests/SwiftMix/ObjCMain.m new file mode 100644 index 0000000..7fa90ae --- /dev/null +++ b/Tests/SwiftMix/ObjCMain.m @@ -0,0 +1,4 @@ +#import "SwiftMix-Swift.h" +int ObjCMain(int argc, char const* const argv[]) { + return [SwiftMainClass SwiftMain:argc argv:argv]; +} diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift new file mode 100644 index 0000000..9af9883 --- /dev/null +++ b/Tests/SwiftMix/SwiftMain.swift @@ -0,0 +1,10 @@ +@objc class SwiftMainClass { + class func SwiftMain(argc:Int, argv:UnsafePointer<UnsafePointer<CChar>>) -> Int32 { + println("argc: \(argc)") + for (var i = 0; i < argc; ++i) { + var argi = String.fromCString(argv[i]) + println("arg[\(i)]: \(argi)"); + } + return 0; + } +} diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt new file mode 100644 index 0000000..5cb9739 --- /dev/null +++ b/Tests/SwiftOnly/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.3) +project(SwiftOnly Swift) + +add_executable(SwiftOnly main.swift) diff --git a/Tests/SwiftOnly/main.swift b/Tests/SwiftOnly/main.swift new file mode 100644 index 0000000..67be986 --- /dev/null +++ b/Tests/SwiftOnly/main.swift @@ -0,0 +1 @@ +println("SwiftOnly") diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index a755ca1..1baca35 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -19,6 +19,9 @@ if(NOT CMake_SOURCE_DIR) include(${CMake_SOURCE_DIR}/Source/CMakeInstallDestinations.cmake) unset(CMAKE_DATA_DIR) unset(CMAKE_DATA_DIR CACHE) + macro(CMake_OPTIONAL_COMPONENT) + set(COMPONENT "") + endmacro() endif() project(CMakeHelp NONE) @@ -153,28 +156,35 @@ if(SPHINX_MAN) if("x${m}" MATCHES "^x(.+)\\.([1-9])\\.rst$") set(name "${CMAKE_MATCH_1}") set(sec "${CMAKE_MATCH_2}") + CMake_OPTIONAL_COMPONENT(sphinx-man) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/${name}.${sec} - DESTINATION ${CMAKE_MAN_DIR}/man${sec}) + DESTINATION ${CMAKE_MAN_DIR}/man${sec} + ${COMPONENT}) endif() endforeach() endif() if(SPHINX_HTML) + CMake_OPTIONAL_COMPONENT(sphinx-html) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_DOC_DIR} + ${COMPONENT} PATTERN .buildinfo EXCLUDE ) endif() if(SPHINX_SINGLEHTML) + CMake_OPTIONAL_COMPONENT(sphinx-singlehtml) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/singlehtml DESTINATION ${CMAKE_DOC_DIR} + ${COMPONENT} PATTERN .buildinfo EXCLUDE ) endif() if(SPHINX_QTHELP) + CMake_OPTIONAL_COMPONENT(sphinx-qthelp) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake-${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}.qch - DESTINATION ${CMAKE_DOC_DIR} + DESTINATION ${CMAKE_DOC_DIR} ${COMPONENT} ) endif() |