diff options
58 files changed, 547 insertions, 459 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 645be1d..3eac45f 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -117,7 +117,7 @@ Available logical expressions are: .. code-block:: cmake add_library(myapp_c foo.c) - add_library(myapp_cxx foo.c) + add_library(myapp_cxx bar.cpp) target_compile_options(myapp_cxx PUBLIC -fno-exceptions) add_executable(myapp main.cpp) target_link_libraries(myapp myapp_c myapp_cxx) diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 072d7c5..27c75dc 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -31,6 +31,7 @@ Properties of Global Scope /prop_gbl/FIND_LIBRARY_USE_LIB64_PATHS /prop_gbl/FIND_LIBRARY_USE_LIBX32_PATHS /prop_gbl/FIND_LIBRARY_USE_OPENBSD_VERSIONING + /prop_gbl/GENERATOR_IS_MULTI_CONFIG /prop_gbl/GLOBAL_DEPENDS_DEBUG_MODE /prop_gbl/GLOBAL_DEPENDS_NO_CYCLES /prop_gbl/IN_TRY_COMPILE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9d8d596..c45574f 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -40,8 +40,6 @@ Variables that Provide Information /variable/CMAKE_FIND_PACKAGE_NAME /variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION /variable/CMAKE_FIND_PACKAGE_SORT_ORDER - /variable/CMAKE_GCC_AR - /variable/CMAKE_GCC_RANLIB /variable/CMAKE_GENERATOR /variable/CMAKE_GENERATOR_PLATFORM /variable/CMAKE_GENERATOR_TOOLSET @@ -50,6 +48,8 @@ Variables that Provide Information /variable/CMAKE_IMPORT_LIBRARY_SUFFIX /variable/CMAKE_JOB_POOL_COMPILE /variable/CMAKE_JOB_POOL_LINK + /variable/CMAKE_LANG_COMPILER_AR + /variable/CMAKE_LANG_COMPILER_RANLIB /variable/CMAKE_LINK_LIBRARY_SUFFIX /variable/CMAKE_LINK_SEARCH_END_STATIC /variable/CMAKE_LINK_SEARCH_START_STATIC diff --git a/Help/prop_gbl/GENERATOR_IS_MULTI_CONFIG.rst b/Help/prop_gbl/GENERATOR_IS_MULTI_CONFIG.rst new file mode 100644 index 0000000..b8ec8a6 --- /dev/null +++ b/Help/prop_gbl/GENERATOR_IS_MULTI_CONFIG.rst @@ -0,0 +1,9 @@ +GENERATOR_IS_MULTI_CONFIG +------------------------- + +Read-only property that is true on multi-configuration generators. + +True when using a multi-configuration generator +(such as :ref:`Visual Studio Generators` or :generator:`Xcode`). +Multi-config generators use :variable:`CMAKE_CONFIGURATION_TYPES` +as the set of configurations and ignore :variable:`CMAKE_BUILD_TYPE`. diff --git a/Help/release/dev/compiler_archiving_tools.rst b/Help/release/dev/compiler_archiving_tools.rst new file mode 100644 index 0000000..de3471d --- /dev/null +++ b/Help/release/dev/compiler_archiving_tools.rst @@ -0,0 +1,8 @@ +compiler_archiving_tools +------------------------ + +* A :variable:`CMAKE_<LANG>_COMPILER_AR` variable was added to hold + the path to the GCC/Clang wrapper of ``ar``. + +* A :variable:`CMAKE_<LANG>_COMPILER_RANLIB` variable was added to hold + the path to the GCC/Clang wrapper of ``ranlib``. diff --git a/Help/release/dev/cpack-sign-uninstaller.rst b/Help/release/dev/cpack-sign-uninstaller.rst deleted file mode 100644 index ff2b402..0000000 --- a/Help/release/dev/cpack-sign-uninstaller.rst +++ /dev/null @@ -1,5 +0,0 @@ -cpack-sign_uninstaller ----------------------- - -* The :module:`CPackNSIS` module learned to sign the uninstaller - when using :variable:`CPACK_NSIS_SIGN_UNINSTALLER` variable. diff --git a/Help/release/dev/gcc_archiving_tools.rst b/Help/release/dev/gcc_archiving_tools.rst deleted file mode 100644 index b3cc7d6..0000000 --- a/Help/release/dev/gcc_archiving_tools.rst +++ /dev/null @@ -1,8 +0,0 @@ -gcc_archiving_tools -------------------- - -* The :variable:`CMAKE_GCC_AR` variable with the path to GCC wrapper of ``ar`` - utility was added. - -* The :variable:`CMAKE_GCC_RANLIB` variable with the path to GCC wrapper of - ``ranlib`` utility was added. diff --git a/Help/release/dev/prop-is-multi-config.rst b/Help/release/dev/prop-is-multi-config.rst new file mode 100644 index 0000000..52de563 --- /dev/null +++ b/Help/release/dev/prop-is-multi-config.rst @@ -0,0 +1,6 @@ +prop-is-multi-config +-------------------- + +* A :prop_gbl:`GENERATOR_IS_MULTI_CONFIG` global property was + added to determine whether the current generator is a multi-configuration + generator (such as :ref:`Visual Studio Generators` or :generator:`Xcode`). diff --git a/Help/variable/CMAKE_GCC_AR.rst b/Help/variable/CMAKE_LANG_COMPILER_AR.rst index ac90b46..b83a1d4 100644 --- a/Help/variable/CMAKE_GCC_AR.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_AR.rst @@ -1,7 +1,7 @@ -CMAKE_GCC_AR ------------- +CMAKE_<LANG>_COMPILER_AR +------------------------ A wrapper around ``ar`` adding the appropriate ``--plugin`` option for the -GCC compiler. For other compilers variable is not defined. +compiler. See also :variable:`CMAKE_AR`. diff --git a/Help/variable/CMAKE_GCC_RANLIB.rst b/Help/variable/CMAKE_LANG_COMPILER_RANLIB.rst index 3d42aba..945160b 100644 --- a/Help/variable/CMAKE_GCC_RANLIB.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_RANLIB.rst @@ -1,7 +1,7 @@ -CMAKE_GCC_RANLIB ----------------- +CMAKE_<LANG>_COMPILER_RANLIB +---------------------------- A wrapper around ``ranlib`` adding the appropriate ``--plugin`` option for the -GCC compiler. For other compilers variable is not defined. +compiler. See also :variable:`CMAKE_RANLIB`. diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index ad65698..7b94d0f 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -1,9 +1,9 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER "@_CMAKE_ASM_COMPILER@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ARG1 "@_CMAKE_ASM_COMPILER_ARG1@") set(CMAKE_AR "@CMAKE_AR@") -set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") +set(CMAKE_ASM@ASM_DIALECT@_COMPILER_AR "@_CMAKE_ASM_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") -set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") +set(CMAKE_ASM@ASM_DIALECT@_COMPILER_RANLIB "@_CMAKE_ASM_COMPILER_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1) set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@") diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index ab068a2..974a579 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -13,10 +13,11 @@ set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@") set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@") @SET_MSVC_C_ARCHITECTURE_ID@ +@SET_CMAKE_XCODE_CURRENT_ARCH@ set(CMAKE_AR "@CMAKE_AR@") -set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") +set(CMAKE_C_COMPILER_AR "@CMAKE_C_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") -set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") +set(CMAKE_C_COMPILER_RANLIB "@CMAKE_C_COMPILER_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) set(CMAKE_C_COMPILER_LOADED 1) diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 27c8881..fda7950 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -14,10 +14,11 @@ set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") @SET_MSVC_CXX_ARCHITECTURE_ID@ +@SET_CMAKE_XCODE_CURRENT_ARCH@ set(CMAKE_AR "@CMAKE_AR@") -set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") +set(CMAKE_CXX_COMPILER_AR "@CMAKE_CXX_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") -set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") +set(CMAKE_CXX_COMPILER_RANLIB "@CMAKE_CXX_COMPILER_RANLIB@") set(CMAKE_LINKER "@CMAKE_LINKER@") set(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) set(CMAKE_CXX_COMPILER_LOADED 1) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 7d5e2b2..87c6b28 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -157,6 +157,8 @@ set(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}") set(_CMAKE_ASM_COMPILER_ID "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") set(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}") set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") +set(_CMAKE_ASM_COMPILER_AR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_AR}") +set(_CMAKE_ASM_COMPILER_RANLIB "${CMAKE_ASM${ASM_DIALECT}_COMPILER_RANLIB}") # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in @@ -165,3 +167,5 @@ configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in set(_CMAKE_ASM_COMPILER) set(_CMAKE_ASM_COMPILER_ARG1) set(_CMAKE_ASM_COMPILER_ENV_VAR) +set(_CMAKE_ASM_COMPILER_AR) +set(_CMAKE_ASM_COMPILER_RANLIB) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 5d9850d..3caccde 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -175,6 +175,11 @@ if(MSVC_C_ARCHITECTURE_ID) "set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})") endif() +if(CMAKE_C_XCODE_CURRENT_ARCH) + set(SET_CMAKE_XCODE_CURRENT_ARCH + "set(CMAKE_XCODE_CURRENT_ARCH ${CMAKE_C_XCODE_CURRENT_ARCH})") +endif() + # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 4d85150..9150962 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -170,6 +170,11 @@ if(MSVC_CXX_ARCHITECTURE_ID) "set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})") endif() +if(CMAKE_CXX_XCODE_CURRENT_ARCH) + set(SET_CMAKE_XCODE_CURRENT_ARCH + "set(CMAKE_XCODE_CURRENT_ARCH ${CMAKE_CXX_XCODE_CURRENT_ARCH})") +endif() + # configure all variables set in this file configure_file(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 1abbc01..687263a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -104,6 +104,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) + set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_${lang}_XCODE_CURRENT_ARCH}" PARENT_SCOPE) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang}_COMPILER_WRAPPER}" PARENT_SCOPE) @@ -358,6 +359,9 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} endif() endif() endif() + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CURRENT_ARCH=([^%\r\n]+)[\r\n]") + set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_MATCH_1}" PARENT_SCOPE) + endif() else() execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index c49621b..d521190 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -8,9 +8,9 @@ set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@") set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@") @SET_MSVC_Fortran_ARCHITECTURE_ID@ set(CMAKE_AR "@CMAKE_AR@") -set(CMAKE_GCC_AR "@CMAKE_GCC_AR@") +set(CMAKE_Fortran_COMPILER_AR "@CMAKE_Fortran_COMPILER_AR@") set(CMAKE_RANLIB "@CMAKE_RANLIB@") -set(CMAKE_GCC_RANLIB "@CMAKE_GCC_RANLIB@") +set(CMAKE_Fortran_COMPILER_RANLIB "@CMAKE_Fortran_COMPILER_RANLIB@") set(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@) set(CMAKE_Fortran_COMPILER_LOADED 1) set(CMAKE_Fortran_COMPILER_WORKS @CMAKE_Fortran_COMPILER_WORKS@) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 3469d34..3273443 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -49,8 +49,12 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj if("${cmd}" MATCHES "${linker_regex}") string(APPEND log " link line: [${line}]\n") string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}") + set(skip_value_of "") foreach(arg IN LISTS args) - if("${arg}" MATCHES "^-L(.:)?[/\\]") + if(skip_value_of) + string(APPEND log " arg [${arg}] ==> skip value of ${skip_value_of}\n") + set(skip_value_of "") + elseif("${arg}" MATCHES "^-L(.:)?[/\\]") # Unix search path. string(REGEX REPLACE "^-L" "" dir "${arg}") list(APPEND implicit_dirs_tmp ${dir}) @@ -66,6 +70,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj set(lib "${CMAKE_MATCH_1}") list(APPEND implicit_libs_tmp ${lib}) string(APPEND log " arg [${arg}] ==> lib [${lib}]\n") + elseif("${arg}" STREQUAL "-lto_library") + # ld argument "-lto_library <path>" + set(skip_value_of "${arg}") + string(APPEND log " arg [${arg}] ==> ignore, skip following value\n") elseif("${arg}" MATCHES "^-l([^:].*)$") # Unix library. set(lib "${CMAKE_MATCH_1}") diff --git a/Modules/CPackNSIS.cmake b/Modules/CPackNSIS.cmake index 37fedf3..18d1871 100644 --- a/Modules/CPackNSIS.cmake +++ b/Modules/CPackNSIS.cmake @@ -133,10 +133,6 @@ # "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html" # "CMake Help" "https://cmake.org" "CMake Web Site") # -# .. variable:: CPACK_NSIS_SIGN_UNINSTALLER -# -# Specify a command to use for signing the uninstaller. The command will -# be invoked a path to the uninstaller as its only argument. #FIXME we should put NSIS specific code here #FIXME but I'm not doing it because I'm not able to test it... diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 5a36e4c..1dc37d4 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -243,20 +243,20 @@ # # .. variable:: CPACK_WIX_ROOT_FEATURE_TITLE # -# Sets the name of the root install feature in the WIX installer. Same as -# CPACK_COMPONENT_<compName>_DISPLAY_NAME for components. +# Sets the name of the root install feature in the WIX installer. Same as +# CPACK_COMPONENT_<compName>_DISPLAY_NAME for components. # # .. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION # -# Sets the description of the root install feature in the WIX installer. Same as -# CPACK_COMPONENT_<compName>_DESCRIPTION for components. +# Sets the description of the root install feature in the WIX installer. Same as +# CPACK_COMPONENT_<compName>_DESCRIPTION for components. # # .. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER # -# If this variable is set to true, the default install location -# of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly. -# The install location will not be located relatively below -# ProgramFiles or ProgramFiles64. +# If this variable is set to true, the default install location +# of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly. +# The install location will not be located relatively below +# ProgramFiles or ProgramFiles64. # # .. note:: # Installers created with this feature do not take differences @@ -270,14 +270,22 @@ # # .. variable:: CPACK_WIX_ROOT_FOLDER_ID # -# This variable allows specification of a custom root folder ID. -# The generator specific ``<64>`` token can be used for -# folder IDs that come in 32-bit and 64-bit variants. -# In 32-bit builds the token will expand empty while in 64-bit builds -# it will expand to ``64``. +# This variable allows specification of a custom root folder ID. +# The generator specific ``<64>`` token can be used for +# folder IDs that come in 32-bit and 64-bit variants. +# In 32-bit builds the token will expand empty while in 64-bit builds +# it will expand to ``64``. # -# When unset generated installers will default installing to -# ``ProgramFiles<64>Folder``. +# When unset generated installers will default installing to +# ``ProgramFiles<64>Folder``. +# +# .. variable:: CPACK_WIX_ROOT +# +# This variable can optionally be set to the root directory +# of a custom WiX Toolset installation. +# +# When unspecified CPack will try to locate a WiX Toolset +# installation via the ``WIX`` environment variable instead. # if(NOT CPACK_WIX_ROOT) diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index 31c1bd3..712a95e 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -67,7 +67,7 @@ endmacro() # Run IPO/LTO test macro(_ipo_run_language_check language) - set(testdir "${CMAKE_CURRENT_BINARY_DIR}/_CMakeLTOTest-${language}") + set(testdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/_CMakeLTOTest-${language}") file(REMOVE_RECURSE "${testdir}") file(MAKE_DIRECTORY "${testdir}") @@ -93,11 +93,14 @@ macro(_ipo_run_language_check language) string(COMPARE EQUAL "${language}" "C" is_c) string(COMPARE EQUAL "${language}" "CXX" is_cxx) + string(COMPARE EQUAL "${language}" "Fortran" is_fortran) if(is_c) set(copy_sources foo.c main.c) elseif(is_cxx) set(copy_sources foo.cpp main.cpp) + elseif(is_fortran) + set(copy_sources foo.f main.f) else() message(FATAL_ERROR "Language not supported") endif() @@ -204,12 +207,6 @@ function(check_ipo_supported) endif() endif() - list(FIND languages "Fortran" result) - if(NOT result EQUAL -1) - _ipo_not_supported("Fortran is not supported") - return() - endif() - if(NOT _CMAKE_IPO_SUPPORTED_BY_CMAKE) _ipo_not_supported("CMake doesn't support IPO for current compiler") return() diff --git a/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in b/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in new file mode 100644 index 0000000..9fab077 --- /dev/null +++ b/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION "@CMAKE_VERSION@") +project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES Fortran) + +cmake_policy(SET CMP0069 NEW) + +add_library(foo foo.f) +add_executable(boo main.f) +target_link_libraries(boo PUBLIC foo) diff --git a/Modules/CheckIPOSupported/foo.f b/Modules/CheckIPOSupported/foo.f new file mode 100644 index 0000000..945d2d5 --- /dev/null +++ b/Modules/CheckIPOSupported/foo.f @@ -0,0 +1,2 @@ + SUBROUTINE FOO + END diff --git a/Modules/CheckIPOSupported/main.f b/Modules/CheckIPOSupported/main.f new file mode 100644 index 0000000..9d1de9f --- /dev/null +++ b/Modules/CheckIPOSupported/main.f @@ -0,0 +1,3 @@ + PROGRAM BOO + CALL FOO() + END diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake index 466d4cf..1aa0219 100644 --- a/Modules/Compiler/GNU-FindBinUtils.cmake +++ b/Modules/Compiler/GNU-FindBinUtils.cmake @@ -9,7 +9,7 @@ string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) # http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ar.1.html -find_program(CMAKE_GCC_AR NAMES +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar" "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" HINTS ${__gcc_hints} @@ -17,7 +17,7 @@ find_program(CMAKE_GCC_AR NAMES ) # http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html -find_program(CMAKE_GCC_RANLIB NAMES +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib" "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" HINTS ${__gcc_hints} diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 4b1c598..0a510f5 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -73,15 +73,15 @@ macro(__compiler_gnu lang) # # [1]: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Optimize-Options.html set(CMAKE_${lang}_ARCHIVE_CREATE_IPO - "${CMAKE_GCC_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>" + "${CMAKE_${lang}_COMPILER_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>" ) set(CMAKE_${lang}_ARCHIVE_APPEND_IPO - "${CMAKE_GCC_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>" + "${CMAKE_${lang}_COMPILER_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>" ) set(CMAKE_${lang}_ARCHIVE_FINISH_IPO - "${CMAKE_GCC_RANLIB} <TARGET>" + "${CMAKE_${lang}_COMPILER_RANLIB} <TARGET>" ) endif() endmacro() diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index 22ad4f6..84f48ae 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -58,7 +58,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"GCC_VERSION=$GCC_VERSION\""; + shellScript = "echo \"GCC_VERSION=$GCC_VERSION\" ; echo \"CURRENT_ARCH=$CURRENT_ARCH\""; showEnvVarsInLog = 0; }; 2C18F0B515DC1DCE00593670 = { diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 34dc98c..b812845 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -531,6 +531,15 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git else() set(git_clone_shallow_options "--depth 1") endif() + if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5) + # Use `git checkout <tree-ish> --` to avoid ambiguity with a local path. + set(git_checkout_explicit-- "--") + else() + # Use `git checkout <branch>` even though this risks ambiguity with a + # local path. Unfortunately we cannot use `git checkout <tree-ish> --` + # because that will not search for remote branch names, a common use case. + set(git_checkout_explicit-- "") + endif() file(WRITE ${script_filename} "if(\"${git_tag}\" STREQUAL \"\") message(FATAL_ERROR \"Tag for git checkout should not be empty.\") @@ -600,11 +609,8 @@ if(error_code) message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\") endif() -# Use `git checkout <branch>` even though this risks ambiguity with a -# local path. Unfortunately we cannot use `git checkout <tree-ish> --` -# because that will not search for remote branch names, a common use case. execute_process( - COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag} + COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag} ${git_checkout_explicit--} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 2dd08e1..1d75720 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -127,7 +127,10 @@ # ('n' tag). Default is OFF. # Boost_COMPILER - Set to the compiler-specific library suffix # (e.g. "-gcc43"). Default is auto-computed -# for the C++ compiler in use. +# for the C++ compiler in use. A list may be +# used if multiple compatible suffixes should +# be tested for, in decreasing order of +# preference. # Boost_THREADAPI - Suffix for "thread" component library name, # such as "pthread" or "win32". Names with # and without this suffix will both be tried. @@ -428,7 +431,7 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) set(_boost_COMPILER "-ghs") elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) - set(_boost_COMPILER "-vc141") + set(_boost_COMPILER "-vc141;-vc140") elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) set(_boost_COMPILER "-vc140") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) @@ -901,7 +904,8 @@ macro(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlib set(_arch_suffix 32) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) - list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-15.0) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.1) + list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19) list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18) @@ -1119,6 +1123,12 @@ if(NOT Boost_INCLUDE_DIR) if( Boost_NO_SYSTEM_PATHS) list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() + if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + foreach(ver ${_Boost_KNOWN_VERSIONS}) + string(REPLACE "." "_" ver "${ver}") + list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS "C:/local/boost_${ver}") + endforeach() + endif() list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS C:/boost/include C:/boost @@ -1392,12 +1402,16 @@ foreach(c DEBUG RELEASE) if( Boost_NO_SYSTEM_PATHS ) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() + foreach(ver ${_Boost_KNOWN_VERSIONS}) + string(REPLACE "." "_" ver "${ver}") + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/local/boost_${ver}") + endforeach() + _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost") list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} PATHS C:/boost/lib C:/boost /sw/local/lib ) - _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost") endif() endif() endforeach() @@ -1524,17 +1538,24 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # # Find RELEASE libraries # + unset(_boost_RELEASE_NAMES) + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ) + endforeach() set(_boost_RELEASE_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) + endforeach() list(APPEND _boost_RELEASE_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) endif() @@ -1565,18 +1586,25 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # # Find DEBUG libraries # - set(_boost_DEBUG_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + unset(_boost_DEBUG_NAMES) + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} ) + endforeach() + list(APPEND _boost_DEBUG_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") + foreach(compiler IN LISTS _boost_COMPILER) + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) + endforeach() list(APPEND _boost_DEBUG_NAMES - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) endif() diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 6b76c25..e323430 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -67,6 +67,13 @@ # -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files # when CUDA_BUILD_EMULATION is TRUE. # +# CUDA_LINK_LIBRARIES_KEYWORD (Default "") +# -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal +# target_link_libraries calls. The default is to use no keyword which +# uses the old "plain" form of target_link_libraries. Note that is matters +# because whatever is used inside the FindCUDA module must also be used +# outside - the two forms of target_link_libraries cannot be mixed. +# # CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) # -- Set to the path you wish to have the generated files placed. If it is # blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. @@ -1740,12 +1747,12 @@ macro(CUDA_ADD_LIBRARY cuda_target) # variable will have been defined. CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - target_link_libraries(${cuda_target} + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_LIBRARIES} ) if(CUDA_SEPARABLE_COMPILATION) - target_link_libraries(${cuda_target} + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cudadevrt_LIBRARY} ) endif() @@ -1790,7 +1797,7 @@ macro(CUDA_ADD_EXECUTABLE cuda_target) # variable will have been defined. CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}") - target_link_libraries(${cuda_target} + target_link_libraries(${cuda_target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_LIBRARIES} ) @@ -1876,9 +1883,9 @@ endmacro() ############################################################################### macro(CUDA_ADD_CUFFT_TO_TARGET target) if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_cufftemu_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufftemu_LIBRARY}) else() - target_link_libraries(${target} ${CUDA_cufft_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cufft_LIBRARY}) endif() endmacro() @@ -1889,9 +1896,9 @@ endmacro() ############################################################################### macro(CUDA_ADD_CUBLAS_TO_TARGET target) if (CUDA_BUILD_EMULATION) - target_link_libraries(${target} ${CUDA_cublasemu_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublasemu_LIBRARY}) else() - target_link_libraries(${target} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) + target_link_libraries(${target} ${CUDA_LINK_LIBRARIES_KEYWORD} ${CUDA_cublas_LIBRARY} ${CUDA_cublas_device_LIBRARY}) endif() endmacro() diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 4f6aa75..9001888 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -29,34 +29,6 @@ ;-------------------------------- ;General -!ifdef INNER - OutFile "${TEMPINSTALLER}.exe" - SetCompress off ; for speed -!else - ; Call makensis again, defining INNER. This writes an installer for us which, when - ; it is invoked, will just write the uninstaller to some location, and then exit. - ; Be sure to substitute the name of this script here. - !tempfile TEMPINSTALLER - !tempfile TEMPUNINSTALLER - !system "$\"${NSISDIR}\makensis$\" /DTEMPINSTALLER=$\"${TEMPINSTALLER}$\" /DTEMPUNINSTALLER=$\"${TEMPUNINSTALLER}$\" /DINNER $\"@CPACK_TEMPORARY_DIRECTORY@/../project.nsi$\"" = 0 - - ; So now run that installer we just created as %TEMP%\tempinstaller.exe. Since it - ; calls quit the return value isn't zero. - - !system "$\"${TEMPINSTALLER}.exe$\"" = 2 - - ; That will have written an uninstaller binary for us. Now we sign it with your - ; favourite code signing tool. - - !tempfile INCEXIST - !system 'if exist "@CPACK_NSIS_SIGN_UNINSTALLER@" echo !define HAVE_SIGN_UNINST > "${INCEXIST}"' - !include "${INCEXIST}" - !delfile "${INCEXIST}" - !ifdef HAVE_SIGN_UNINST - !system '"@CPACK_NSIS_SIGN_UNINSTALLER@" "${TEMPUNINSTALLER}.exe"' = 0 - !endif - - ; Good. Now we can carry on writing the real installer. ;Name and file Name "@CPACK_NSIS_PACKAGE_NAME@" @@ -64,7 +36,6 @@ ;Set compression SetCompressor @CPACK_NSIS_COMPRESSOR@ -!endif ;Require administrator access RequestExecutionLevel admin @@ -588,10 +559,8 @@ FunctionEnd !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH -!ifdef INNER !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES -!endif ;-------------------------------- ;Languages @@ -673,10 +642,7 @@ Section "-Core installation" WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR ;Create uninstaller -!ifndef INNER - ; this packages the signed uninstaller - File "/oname=Uninstall.exe" "${TEMPUNINSTALLER}.exe" -!endif + WriteUninstaller "$INSTDIR\Uninstall.exe" Push "DisplayName" Push "@CPACK_NSIS_DISPLAY_NAME@" Call ConditionalAddToRegisty @@ -835,7 +801,6 @@ FunctionEnd ;-------------------------------- ;Uninstaller Section -!ifdef INNER Section "Uninstall" ReadRegStr $START_MENU SHCTX \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu" @@ -921,7 +886,6 @@ Section "Uninstall" Call un.RemoveFromPath doNotRemoveFromPath: SectionEnd -!endif ;-------------------------------- ; determine admin versus local install @@ -934,14 +898,6 @@ SectionEnd ; "Program Files" for AllUsers, "My Documents" for JustMe... Function .onInit -!ifdef INNER - ; If INNER is defined, then we aren't supposed to do anything except write out - ; the installer. This is better than processing a command line option as it means - ; this entire code path is not present in the final (real) installer. - - WriteUninstaller "${TEMPUNINSTALLER}.exe" - Quit ; just bail out quickly when running the "inner" installer -!endif StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString" diff --git a/Source/.gitattributes b/Source/.gitattributes index 1cec8a3..f69ad9d 100644 --- a/Source/.gitattributes +++ b/Source/.gitattributes @@ -17,5 +17,4 @@ /cmListFileLexer.c generated # Do not format third-party sources. -/bindexplib.* -format.clang-format /kwsys/** -format.clang-format diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f8cec3c..a762308 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 8) -set(CMake_VERSION_PATCH 20170404) +set(CMake_VERSION_PATCH 20170406) #set(CMake_VERSION_RC 1) diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 47c7565..75a2177 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -68,81 +68,88 @@ #include <iostream> #include <windows.h> -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 +#ifndef IMAGE_FILE_MACHINE_ARMNT +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#endif - /* bigobj specifics */ - DWORD NumberOfSections; // extended from WORD - DWORD PointerToSymbolTable; - DWORD NumberOfSymbols; +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; +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; +typedef cmIMAGE_SYMBOL_EX UNALIGNED* cmPIMAGE_SYMBOL_EX; -PIMAGE_SECTION_HEADER GetSectionHeaderOffset(PIMAGE_FILE_HEADER - pImageFileHeader) +PIMAGE_SECTION_HEADER GetSectionHeaderOffset( + PIMAGE_FILE_HEADER pImageFileHeader) { - return (PIMAGE_SECTION_HEADER) - ((DWORD_PTR)pImageFileHeader + - IMAGE_SIZEOF_FILE_HEADER + - pImageFileHeader->SizeOfOptionalHeader); + return (PIMAGE_SECTION_HEADER)((DWORD_PTR)pImageFileHeader + + IMAGE_SIZEOF_FILE_HEADER + + pImageFileHeader->SizeOfOptionalHeader); } -PIMAGE_SECTION_HEADER GetSectionHeaderOffset(cmANON_OBJECT_HEADER_BIGOBJ* - pImageFileHeader) +PIMAGE_SECTION_HEADER GetSectionHeaderOffset( + cmANON_OBJECT_HEADER_BIGOBJ* pImageFileHeader) { - return (PIMAGE_SECTION_HEADER) - ((DWORD_PTR)pImageFileHeader + - sizeof(cmANON_OBJECT_HEADER_BIGOBJ)); + 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; +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); + 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; - } + 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; + size = 0; + return 0; } template < @@ -162,68 +169,18 @@ public: *---------------------------------------------------------------------- */ - DumpSymbols(ObjectHeaderType* ih, - std::set<std::string>& symbols, - std::set<std::string>& dataSymbols, - bool is64) - :Symbols(symbols), DataSymbols(dataSymbols) - { - this->ObjectImageHeader = ih; - this->SymbolTable = (SymbolTableType*) - ((DWORD_PTR)this->ObjectImageHeader - + this->ObjectImageHeader->PointerToSymbolTable); - this->SectionHeaders = - GetSectionHeaderOffset(this->ObjectImageHeader); - this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; - this->Is64Bit = is64; - } - - /* - *---------------------------------------------------------------------- - * 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; + DumpSymbols(ObjectHeaderType* ih, std::set<std::string>& symbols, + std::set<std::string>& dataSymbols, bool isI386) + : Symbols(symbols) + , DataSymbols(dataSymbols) + { + this->ObjectImageHeader = ih; + this->SymbolTable = + (SymbolTableType*)((DWORD_PTR) this->ObjectImageHeader + + this->ObjectImageHeader->PointerToSymbolTable); + this->SectionHeaders = GetSectionHeaderOffset(this->ObjectImageHeader); + this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; + this->IsI386 = isI386; } /* @@ -233,9 +190,7 @@ public: * Dump an object file's exported symbols. *---------------------------------------------------------------------- */ - void DumpObjFile() { - this->DumpExternalsObjects(); - } + void DumpObjFile() { this->DumpExternalsObjects(); } /* *---------------------------------------------------------------------- @@ -244,7 +199,8 @@ public: * Dumps a COFF symbol table from an OBJ. *---------------------------------------------------------------------- */ - void DumpExternalsObjects() { + void DumpExternalsObjects() + { unsigned i; PSTR stringTable; std::string symbol; @@ -252,83 +208,66 @@ public: /* * The string table apparently starts right after the symbol table */ - stringTable = (PSTR)&this->SymbolTable[this->SymbolCount]; + stringTable = (PSTR) & this->SymbolTable[this->SymbolCount]; SymbolTableType* pSymbolTable = this->SymbolTable; - for ( i=0; i < this->SymbolCount; i++ ) { + 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; - } + (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); - } + // 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); } - // For 64 bit builds we don't need to remove _ - if(!this->Is64Bit) - { - if (symbol[0] == '_') - { - symbol.erase(0,1); - } + } + // For i386 builds we don't need to remove _ + if (this->IsI386 && symbol[0] == '_') { + symbol.erase(0, 1); + } + + /* + 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 + this->DataSymbols.insert(symbol); + } else { + if (pSymbolTable->Type || !(SectChar & IMAGE_SCN_MEM_READ) || + (SectChar & IMAGE_SCN_MEM_EXECUTE)) { + this->Symbols.insert(symbol); + } else { + // printf(" strange symbol: %s \n",symbol.c_str()); } - /* - 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 - this->DataSymbols.insert(symbol); - } else { - if ( pSymbolTable->Type || - !(SectChar & IMAGE_SCN_MEM_READ) || - (SectChar & IMAGE_SCN_MEM_EXECUTE)) { - this->Symbols.insert(symbol); - } 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); - this->DataSymbols.insert(symbol); - } + } + } } /* @@ -339,89 +278,85 @@ public: pSymbolTable++; } } + private: std::set<std::string>& Symbols; std::set<std::string>& DataSymbols; DWORD_PTR SymbolCount; PIMAGE_SECTION_HEADER SectionHeaders; ObjectHeaderType* ObjectImageHeader; - SymbolTableType* SymbolTable; - bool Is64Bit; + SymbolTableType* SymbolTable; + bool IsI386; }; -bool -DumpFile(const char* filename, - std::set<std::string>& symbols, - std::set<std::string>& dataSymbols) +bool DumpFile(const char* filename, std::set<std::string>& symbols, + std::set<std::string>& dataSymbols) { - HANDLE hFile; - HANDLE hFileMapping; - LPVOID lpFileBase; - PIMAGE_DOS_HEADER dosHeader; + 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); + 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; - } + 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; - } + 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; - } + 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, symbols, dataSymbols, - (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)); + 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 COFF OBJ file??? */ + else if (((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARMNT)) && + (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, symbols, dataSymbols, + (dosHeader->e_magic == IMAGE_FILE_MACHINE_I386)); + 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, symbols, dataSymbols, + (h->Machine == IMAGE_FILE_MACHINE_I386)); 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, symbols, - dataSymbols, - (h->Machine == IMAGE_FILE_MACHINE_AMD64)); - symbolDumper.DumpObjFile(); - } else { - printf("unrecognized file format in '%s'\n", filename); - return false; - } - } - UnmapViewOfFile(lpFileBase); - CloseHandle(hFileMapping); - CloseHandle(hFile); - return true; + } else { + printf("unrecognized file format in '%s'\n", filename); + return false; + } + } + UnmapViewOfFile(lpFileBase); + CloseHandle(hFileMapping); + CloseHandle(hFile); + return true; } bool bindexplib::AddObjectFile(const char* filename) @@ -431,35 +366,35 @@ bool bindexplib::AddObjectFile(const char* filename) bool bindexplib::AddDefinitionFile(const char* filename) { - cmsys::ifstream infile(filename); - if (!infile) { - fprintf(stderr, "Couldn't open definition file '%s'\n", filename); - return false; - } - std::string str; - while (std::getline(infile, str)) { - // skip the LIBRAY and EXPORTS lines (if any) - if ((str.compare(0,7,"LIBRARY") == 0) || - (str.compare(0,7,"EXPORTS") == 0)) { - continue; - } - // remove leading tabs & spaces - str.erase(0, str.find_first_not_of(" \t")); - std::size_t found = str.find(" \t DATA"); - if (found != std::string::npos) { - str.erase (found, std::string::npos); - this->DataSymbols.insert(str); - } else { - this->Symbols.insert(str); - } - } - infile.close(); - return true; + cmsys::ifstream infile(filename); + if (!infile) { + fprintf(stderr, "Couldn't open definition file '%s'\n", filename); + return false; + } + std::string str; + while (std::getline(infile, str)) { + // skip the LIBRAY and EXPORTS lines (if any) + if ((str.compare(0, 7, "LIBRARY") == 0) || + (str.compare(0, 7, "EXPORTS") == 0)) { + continue; + } + // remove leading tabs & spaces + str.erase(0, str.find_first_not_of(" \t")); + std::size_t found = str.find(" \t DATA"); + if (found != std::string::npos) { + str.erase(found, std::string::npos); + this->DataSymbols.insert(str); + } else { + this->Symbols.insert(str); + } + } + infile.close(); + return true; } void bindexplib::WriteFile(FILE* file) { - fprintf(file,"EXPORTS \n"); + fprintf(file, "EXPORTS \n"); for (std::set<std::string>::const_iterator i = this->DataSymbols.begin(); i != this->DataSymbols.end(); ++i) { fprintf(file, "\t%s \t DATA\n", i->c_str()); diff --git a/Source/bindexplib.h b/Source/bindexplib.h index 7f0615f..51fe49d 100644 --- a/Source/bindexplib.h +++ b/Source/bindexplib.h @@ -16,6 +16,7 @@ public: bool AddDefinitionFile(const char* filename); bool AddObjectFile(const char* filename); void WriteFile(FILE* file); + private: std::set<std::string> Symbols; std::set<std::string> DataSymbols; diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index fd7da18..856d42e 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -349,6 +349,87 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles( } } +void cmExtraCodeLiteGenerator::CreateFoldersAndFiles( + std::set<std::string>& cFiles, cmXMLWriter& xml, + const std::string& projectPath) +{ + std::vector<std::string> tmp_path; + std::vector<std::string> components; + size_t numOfEndEl = 0; + + for (std::set<std::string>::const_iterator it = cFiles.begin(); + it != cFiles.end(); ++it) { + std::string frelapath = + cmSystemTools::RelativePath(projectPath.c_str(), it->c_str()); + cmsys::SystemTools::SplitPath(frelapath, components, false); + components.pop_back(); // erase last member -> it is file, not folder + components.erase(components.begin()); // erase "root" + + size_t sizeOfSkip = 0; + + for (size_t i = 0; i < components.size(); ++i) { + // skip relative path + if (components[i] == ".." || components[i] == ".") { + sizeOfSkip++; + continue; + } + + // same folder + if (tmp_path.size() > i - sizeOfSkip && + tmp_path[i - sizeOfSkip] == components[i]) { + continue; + } + + // delete "old" subfolders + if (tmp_path.size() > i - sizeOfSkip) { + numOfEndEl = tmp_path.size() - i + sizeOfSkip; + tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end()); + for (; numOfEndEl--;) { + xml.EndElement(); + } + } + + // add folder + xml.StartElement("VirtualDirectory"); + xml.Attribute("Name", components[i]); + tmp_path.push_back(components[i]); + } + + // delete "old" subfolders + numOfEndEl = tmp_path.size() - components.size() + sizeOfSkip; + if (numOfEndEl) { + tmp_path.erase(tmp_path.end() - numOfEndEl, tmp_path.end()); + for (; numOfEndEl--;) { + xml.EndElement(); + } + } + + // add file + xml.StartElement("File"); + xml.Attribute("Name", frelapath); + xml.EndElement(); + } + + // end of folders + numOfEndEl = tmp_path.size(); + for (; numOfEndEl--;) { + xml.EndElement(); + } +} + +void cmExtraCodeLiteGenerator::CreateFoldersAndFiles( + std::map<std::string, cmSourceFile*>& cFiles, cmXMLWriter& xml, + const std::string& projectPath) +{ + std::set<std::string> s; + for (std::map<std::string, cmSourceFile*>::const_iterator it = + cFiles.begin(); + it != cFiles.end(); ++it) { + s.insert(it->first); + } + this->CreateFoldersAndFiles(s, xml, projectPath); +} + void cmExtraCodeLiteGenerator::CreateProjectSourceEntries( std::map<std::string, cmSourceFile*>& cFiles, std::set<std::string>& otherFiles, cmXMLWriter* _xml, @@ -366,26 +447,12 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries( // insert all source files in the codelite project // first the C/C++ implementation files, then all others - for (std::map<std::string, cmSourceFile*>::const_iterator sit = - cFiles.begin(); - sit != cFiles.end(); ++sit) { - xml.StartElement("File"); - std::string fpath(sit->first); - std::string frelapath = - cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()); - xml.Attribute("Name", frelapath); - xml.EndElement(); - } + this->CreateFoldersAndFiles(cFiles, xml, projectPath); xml.EndElement(); // VirtualDirectory + xml.StartElement("VirtualDirectory"); xml.Attribute("Name", "include"); - for (std::set<std::string>::const_iterator sit = otherFiles.begin(); - sit != otherFiles.end(); ++sit) { - xml.StartElement("File"); - xml.Attribute( - "Name", cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str())); - xml.EndElement(); - } + this->CreateFoldersAndFiles(otherFiles, xml, projectPath); xml.EndElement(); // VirtualDirectory // Get the number of CPUs. We use this information for the make -jN diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h index 773515d..3263eb6 100644 --- a/Source/cmExtraCodeLiteGenerator.h +++ b/Source/cmExtraCodeLiteGenerator.h @@ -50,6 +50,10 @@ protected: const cmMakefile* mf, const std::string& projectType, const std::string& targetName); + void CreateFoldersAndFiles(std::set<std::string>& cFiles, cmXMLWriter& xml, + const std::string& projectPath); + void CreateFoldersAndFiles(std::map<std::string, cmSourceFile*>& cFiles, + cmXMLWriter& xml, const std::string& projectPath); public: cmExtraCodeLiteGenerator(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 851290a..ce83e2e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -96,6 +96,7 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) this->ConfigureDoneCMP0026AndCMP0024 = false; this->FirstTimeProgress = 0.0f; + cm->GetState()->SetIsGeneratorMultiConfig(false); cm->GetState()->SetMinGWMake(false); cm->GetState()->SetMSYSShell(false); cm->GetState()->SetNMake(false); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index eb92b83..6d16881 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -20,6 +20,7 @@ cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm) : cmGlobalGenerator(cm) { + cm->GetState()->SetIsGeneratorMultiConfig(true); cm->GetState()->SetWindowsShell(true); cm->GetState()->SetWindowsVSIDE(true); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 416af14..febe95d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -151,6 +151,8 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm, this->CurrentMakefile = 0; this->CurrentLocalGenerator = 0; this->XcodeBuildCommandInitialized = false; + + cm->GetState()->SetIsGeneratorMultiConfig(true); } cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 18d5ea1..0f49731 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,6 +20,7 @@ cmState::cmState() : IsInTryCompile(false) + , IsGeneratorMultiConfig(false) , WindowsShell(false) , WindowsVSIDE(false) , WatcomWMake(false) @@ -364,6 +365,16 @@ void cmState::SetIsInTryCompile(bool b) this->IsInTryCompile = b; } +bool cmState::GetIsGeneratorMultiConfig() const +{ + return this->IsGeneratorMultiConfig; +} + +void cmState::SetIsGeneratorMultiConfig(bool b) +{ + this->IsGeneratorMultiConfig = b; +} + void cmState::RenameCommand(std::string const& oldName, std::string const& newName) { @@ -481,6 +492,9 @@ const char* cmState::GetGlobalProperty(const std::string& prop) } else if (prop == "IN_TRY_COMPILE") { this->SetGlobalProperty("IN_TRY_COMPILE", this->IsInTryCompile ? "1" : "0"); + } else if (prop == "GENERATOR_IS_MULTI_CONFIG") { + this->SetGlobalProperty("GENERATOR_IS_MULTI_CONFIG", + this->IsGeneratorMultiConfig ? "1" : "0"); } else if (prop == "ENABLED_LANGUAGES") { std::string langs; langs = cmJoin(this->EnabledLanguages, ";"); diff --git a/Source/cmState.h b/Source/cmState.h index 41ffcdc..5659023 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -116,6 +116,9 @@ public: bool GetIsInTryCompile() const; void SetIsInTryCompile(bool b); + bool GetIsGeneratorMultiConfig() const; + void SetIsGeneratorMultiConfig(bool b); + cmCommand* GetCommand(std::string const& name) const; void AddCommand(cmCommand* command); void RemoveUnscriptableCommands(); @@ -174,6 +177,7 @@ private: std::string SourceDirectory; std::string BinaryDirectory; bool IsInTryCompile; + bool IsGeneratorMultiConfig; bool WindowsShell; bool WindowsVSIDE; bool WatcomWMake; diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 8f842d6..7eb679c 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -56,7 +56,10 @@ if (NOT QT4_FOUND) endif () macro(check_version_string MODULE_NAME VERSION_VAR) - if (${MODULE_NAME}_FOUND) + string(FIND " ${CMake_TEST_CMakeOnly.AllFindModules_NO_VERSION} " " ${MODULE_NAME} " _exclude_pos) + if (NOT _exclude_pos EQUAL -1) + message(STATUS "excluding check of ${VERSION_VAR}='${${VERSION_VAR}}' due to local configuration") + elseif (${MODULE_NAME}_FOUND) if (DEFINED ${VERSION_VAR}) message(STATUS "${VERSION_VAR}='${${VERSION_VAR}}'") if (NOT ${VERSION_VAR} MATCHES "^[0-9]") diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index d44c836..2b25766 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -37,7 +37,11 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio ([^789]|[789][0-9])") add_CMakeOnly_test(CompilerIdCSharp) endif() -add_CMakeOnly_test(AllFindModules) +add_test(CMakeOnly.AllFindModules ${CMAKE_CMAKE_COMMAND} + -DTEST=AllFindModules + -DCMAKE_ARGS=-DCMake_TEST_CMakeOnly.AllFindModules_NO_VERSION=${CMake_TEST_CMakeOnly.AllFindModules_NO_VERSION} + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) add_CMakeOnly_test(SelectLibraryConfigurations) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index d5524c3..1cca35d 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -53,10 +53,7 @@ set(EndStuff_PreArgs ) AddCMakeTest(EndStuff "${EndStuff_PreArgs}") -set(GetPrerequisites_PreArgs - "-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}" - ) -AddCMakeTest(GetPrerequisites "${GetPrerequisites_PreArgs}") +AddCMakeTest(GetPrerequisites "-DConfiguration:STRING=$<CONFIGURATION>") if(GIT_EXECUTABLE) set(PolicyCheck_PreArgs diff --git a/Tests/CMakeTests/GetPrerequisitesTest.cmake.in b/Tests/CMakeTests/GetPrerequisitesTest.cmake.in index 89ca735..7325b87 100644 --- a/Tests/CMakeTests/GetPrerequisitesTest.cmake.in +++ b/Tests/CMakeTests/GetPrerequisitesTest.cmake.in @@ -2,18 +2,15 @@ # include(GetPrerequisites) -set(CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@") -set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") set(CMAKE_EXECUTABLE_SUFFIX "@CMAKE_EXECUTABLE_SUFFIX@") message(STATUS "=============================================================================") message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") message(STATUS "") -message(STATUS "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'") -message(STATUS "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}'") +message(STATUS "Configuration '${Configuration}'") +message(STATUS "CMAKE_COMMAND='${CMAKE_COMMAND}'") message(STATUS "CMAKE_EXECUTABLE_SUFFIX='${CMAKE_EXECUTABLE_SUFFIX}'") -message(STATUS "CTEST_CONFIGURATION_TYPE='${CTEST_CONFIGURATION_TYPE}'") message(STATUS "") diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in index d6d2357..58e2bf9 100644 --- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -261,6 +261,12 @@ set(mac_absoft_libs "af90math;afio;amisc;absoftmain;af77math;m;mv") set(mac_absoft_dirs "/Applications/Absoft11.1/lib;/usr/lib/i686-apple-darwin10/4.2.1;/usr/lib/gcc/i686-apple-darwin10/4.2.1;/usr/lib") list(APPEND platforms mac_absoft) +# Xcode 8.3: clang++ dummy.cpp -v +set(mac_clang_v_text " \"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld\" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.12.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -o a.out /var/folders/hc/95l7dhnx459c57g4yg_6yd8c0000gp/T/dummy-384ea1.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.1.0/lib/darwin/libclang_rt.osx.a") +set(mac_clang_v_libs "c++") +set(mac_clang_v_dirs "") +list(APPEND platforms mac_clang_v) + #----------------------------------------------------------------------------- # Sun diff --git a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake index 812f79b..588a75d 100644 --- a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake @@ -2,7 +2,6 @@ include(RunCMake) run_cmake(unparsed-arguments) run_cmake(user-lang-unknown) -run_cmake(user-lang-fortran) run_cmake(default-lang-none) run_cmake(not-supported-by-cmake) run_cmake(not-supported-by-compiler) diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt deleted file mode 100644 index 2cb595d..0000000 --- a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): - IPO is not supported \(Fortran is not supported\)\. -Call Stack \(most recent call first\): - .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\) - user-lang-fortran\.cmake:[0-9]+ \(check_ipo_supported\) - CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake deleted file mode 100644 index 275dbd9..0000000 --- a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake +++ /dev/null @@ -1 +0,0 @@ -check_ipo_supported(LANGUAGES "Fortran") diff --git a/Tests/RunCMake/get_property/IsMultiConfig-stdout.txt b/Tests/RunCMake/get_property/IsMultiConfig-stdout.txt new file mode 100644 index 0000000..9808674 --- /dev/null +++ b/Tests/RunCMake/get_property/IsMultiConfig-stdout.txt @@ -0,0 +1 @@ +-- GENERATOR_IS_MULTI_CONFIG=1 diff --git a/Tests/RunCMake/get_property/IsMultiConfig.cmake b/Tests/RunCMake/get_property/IsMultiConfig.cmake new file mode 100644 index 0000000..64d5ff6 --- /dev/null +++ b/Tests/RunCMake/get_property/IsMultiConfig.cmake @@ -0,0 +1,2 @@ +get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +message(STATUS "GENERATOR_IS_MULTI_CONFIG=${is_multi_config}") diff --git a/Tests/RunCMake/get_property/NotMultiConfig-stdout.txt b/Tests/RunCMake/get_property/NotMultiConfig-stdout.txt new file mode 100644 index 0000000..8e0f895 --- /dev/null +++ b/Tests/RunCMake/get_property/NotMultiConfig-stdout.txt @@ -0,0 +1 @@ +-- GENERATOR_IS_MULTI_CONFIG=0 diff --git a/Tests/RunCMake/get_property/NotMultiConfig.cmake b/Tests/RunCMake/get_property/NotMultiConfig.cmake new file mode 100644 index 0000000..59172d5 --- /dev/null +++ b/Tests/RunCMake/get_property/NotMultiConfig.cmake @@ -0,0 +1 @@ +include(IsMultiConfig.cmake) diff --git a/Tests/RunCMake/get_property/RunCMakeTest.cmake b/Tests/RunCMake/get_property/RunCMakeTest.cmake index 00eef34..017990f 100644 --- a/Tests/RunCMake/get_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/get_property/RunCMakeTest.cmake @@ -22,3 +22,9 @@ run_cmake(NoTarget) run_cmake(NoSource) run_cmake(NoProperty) run_cmake(NoCache) + +if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") + run_cmake(IsMultiConfig) +else() + run_cmake(NotMultiConfig) +endif() diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt index 8913406..e7eaa8d 100644 --- a/Tests/Server/CMakeLists.txt +++ b/Tests/Server/CMakeLists.txt @@ -5,6 +5,7 @@ find_package(PythonInterp REQUIRED) macro(do_test bsname file) execute_process(COMMAND ${PYTHON_EXECUTABLE} + -B # no .pyc files "${CMAKE_SOURCE_DIR}/server-test.py" "${CMAKE_COMMAND}" "${CMAKE_SOURCE_DIR}/${file}" |