diff options
27 files changed, 146 insertions, 162 deletions
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst index 7c02190..2f1ab60 100644 --- a/Help/command/cmake_minimum_required.rst +++ b/Help/command/cmake_minimum_required.rst @@ -13,6 +13,10 @@ If the running version of CMake is lower than the ``<min>`` required version it will stop processing the project and report an error. The optional ``<max>`` version, if specified, must be at least the ``<min>`` version and affects policy settings as described below. +If the running version of CMake is older than 3.12, the extra ``...`` +dots will be seen as version component separators, resulting in the +``...<max>`` part being ignored and preserving the pre-3.12 behavior +of basing policies on ``<min>``. The ``FATAL_ERROR`` option is accepted but ignored by CMake 2.6 and higher. It should be specified so CMake versions 2.4 and lower fail diff --git a/Help/command/cmake_policy.rst b/Help/command/cmake_policy.rst index 6a8dd62..c3f7cfb 100644 --- a/Help/command/cmake_policy.rst +++ b/Help/command/cmake_policy.rst @@ -30,7 +30,10 @@ encourage projects to set policies based on CMake versions:: ``major.minor[.patch[.tweak]]``, and the ``...`` is literal. The ``<min>`` version must be at least ``2.4`` and at most the running version of CMake. The ``<max>`` version, if specified, must be at least the ``<min>`` version -but may exceed the running version of CMake. +but may exceed the running version of CMake. If the running version of +CMake is older than 3.12, the extra ``...`` dots will be seen as version +component separators, resulting in the ``...<max>`` part being ignored and +preserving the pre-3.12 behavior of basing policies on ``<min>``. This specifies that the current CMake code is written for the given range of CMake versions. All policies known to the running version of CMake diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst index 6379730..fcc2c07 100644 --- a/Help/command/target_link_libraries.rst +++ b/Help/command/target_link_libraries.rst @@ -18,7 +18,7 @@ All of them have the general form:: target_link_libraries(<target> ... <item>... ...) -The named ``<target>`` must have been created by +The named ``<target>`` must have been created in the current directory by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. Repeated calls for the same ``<target>`` append items in the order called. diff --git a/Help/release/3.12.rst b/Help/release/3.12.rst index 4d1135e..f6fdb5a 100644 --- a/Help/release/3.12.rst +++ b/Help/release/3.12.rst @@ -34,7 +34,8 @@ Commands * The :command:`cmake_minimum_required` and :command:`cmake_policy(VERSION)` commands now accept a version range using the form ``<min>[...<max>]``. The ``<min>`` version is required but policies are set based on the - ``<max>`` version. This allows projects to specify a range of versions + older of the running CMake version and the version specified by + ``<max>``. This allows projects to specify a range of versions for which they have been updated and avoid explicit policy settings. * The :command:`file(GLOB)` and :command:`file(GLOB_RECURSE)` commands @@ -81,9 +82,6 @@ Commands :ref:`Object Libraries`. Linking to an object library uses its object files in direct dependents and also propagates usage requirements. -* The :command:`target_link_libraries` command may now be called - to modify targets created outside the current directory. - Variables --------- diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index 8f35fc7..b57a46e 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -36,6 +36,9 @@ # This is because, the lua location is not standardized and may exist in # locations other than lua/ +cmake_policy(PUSH) # Policies apply to functions at definition-time +cmake_policy(SET CMP0012 NEW) # For while(TRUE) + unset(_lua_include_subdirs) unset(_lua_library_names) unset(_lua_append_versions) @@ -236,3 +239,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua VERSION_VAR LUA_VERSION_STRING) mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY) + +cmake_policy(POP) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 7127b8f..b306181 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -30,6 +30,12 @@ Defines the following command for use with ``SWIG``: .. note:: + The variable ``SWIG_MODULE_<name>_REAL_NAME`` will be set to the name + of the swig module target library. This variable is useless if variable + ``UseSWIG_TARGET_NAME_PREFERENCE`` is set to ``STANDARD``. + + .. note:: + For multi-config generators, this module does not support configuration-specific files generated by ``SWIG``. All build configurations must result in the same generated source file. @@ -70,14 +76,29 @@ Defines the following command for use with ``SWIG``: identified as sources for the ``SWIG`` tool. Other files will be handled in the standard way. -.. note:: + .. note:: + + If ``UseSWIG_MODULE_VERSION`` is set to 2, it is **strongly** recommended + to use a dedicated directory unique to the target when either the + ``OUTPUT_DIR`` option or the ``CMAKE_SWIG_OUTDIR`` variable are specified. + The output directory contents are erased as part of the target build, so + to prevent interference between targets or losing other important files, + each target should have its own dedicated output directory. + +.. command:: swig_link_libraries + + Link libraries to swig module:: + + swig_link_libraries(<name> <item>...) + + This command has same capabilities as :command:`target_link_libraries` + command. + + .. note:: - If ``UseSWIG_MODULE_VERSION`` is set to 2, it is **strongly** recommended - to use a dedicated directory unique to the target when either the - ``OUTPUT_DIR`` option or the ``CMAKE_SWIG_OUTDIR`` variable are specified. - The output directory contents are erased as part of the target build, so - to prevent interference between targets or losing other important files, each - target should have its own dedicated output directory. + If variable ``UseSWIG_TARGET_NAME_PREFERENCE`` is set to ``STANDARD``, this + command is deprecated and :command:`target_link_libraries` command must be + used instead. Source file properties on module files **must** be set before the invocation of the ``swig_add_library`` command to specify special behavior of SWIG and @@ -123,6 +144,7 @@ input files. .. code-block:: cmake + set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD) swig_add_library(mymod LANGUAGE python SOURCES mymod.i) set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2) set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb) @@ -143,6 +165,7 @@ information about support files generated by ``SWIG`` interface compilation. .. code-block:: cmake + set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD) swig_add_library(mymod LANGUAGE python SOURCES mymod.i) get_property(support_files TARGET mymod PROPERTY SWIG_SUPPORT_FILES) @@ -160,6 +183,13 @@ information about support files generated by ``SWIG`` interface compilation. Some variables can be set to customize the behavior of ``swig_add_library`` as well as ``SWIG``: +``UseSWIG_TARGET_NAME_PREFERENCE`` + Specify target name strategy. + + * Set to ``LEGACY`` or undefined: legacy strategy is applied. Variable + ``SWIG_MODULE_<name>_REAL_NAME`` must be used to get real target name. + * Set to ``STANDARD``: target name matches specified name. + ``UseSWIG_MODULE_VERSION`` Specify different behaviors for ``UseSWIG`` module. @@ -302,23 +332,29 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) set(workingdir "${outdir}") endif() + if(SWIG_TARGET_NAME) + set(target_name ${SWIG_TARGET_NAME}) + else() + set(target_name ${name}) + endif() + set (swig_source_file_flags ${CMAKE_SWIG_FLAGS}) # handle various swig compile flags properties get_source_file_property (include_directories "${infile}" INCLUDE_DIRECTORIES) if (include_directories) list (APPEND swig_source_file_flags "$<$<BOOL:${include_directories}>:-I$<JOIN:${include_directories},$<SEMICOLON>-I>>") endif() - set (property "$<TARGET_PROPERTY:${name},SWIG_INCLUDE_DIRECTORIES>") - list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:$<TARGET_GENEX_EVAL:${name},${property}>,$<SEMICOLON>-I>>") + set (property "$<TARGET_PROPERTY:${target_name},SWIG_INCLUDE_DIRECTORIES>") + list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-I>>") - set (property "$<TARGET_PROPERTY:${name},SWIG_COMPILE_DEFINITIONS>") - list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:$<TARGET_GENEX_EVAL:${name},${property}>,$<SEMICOLON>-D>>") + set (property "$<TARGET_PROPERTY:${target_name},SWIG_COMPILE_DEFINITIONS>") + list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-D>>") get_source_file_property (compile_definitions "${infile}" COMPILE_DEFINITIONS) if (compile_definitions) list (APPEND swig_source_file_flags "$<$<BOOL:${compile_definitions}>:-D$<JOIN:${compile_definitions},$<SEMICOLON>-D>>") endif() - list (APPEND swig_source_file_flags "$<TARGET_GENEX_EVAL:${name},$<TARGET_PROPERTY:${name},SWIG_COMPILE_OPTIONS>>") + list (APPEND swig_source_file_flags "$<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_COMPILE_OPTIONS>>") get_source_file_property (compile_options "${infile}" COMPILE_OPTIONS) if (compile_options) list (APPEND swig_source_file_flags ${compile_options}) @@ -377,7 +413,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) list (APPEND swig_extra_flags ${SWIG_MODULE_${name}_EXTRA_FLAGS}) # dependencies - set (swig_dependencies ${SWIG_MODULE_${name}_EXTRA_DEPS} $<TARGET_PROPERTY:${name},SWIG_DEPENDS>) + set (swig_dependencies ${SWIG_MODULE_${name}_EXTRA_DEPS} $<TARGET_PROPERTY:${target_name},SWIG_DEPENDS>) get_source_file_property(file_depends "${infile}" DEPENDS) if (file_depends) list (APPEND swig_dependencies ${file_depends}) @@ -434,13 +470,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ## add all properties for generated file to various properties get_property (include_directories SOURCE "${infile}" PROPERTY GENERATED_INCLUDE_DIRECTORIES) - set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY INCLUDE_DIRECTORIES ${include_directories} $<TARGET_GENEX_EVAL:${name},$<TARGET_PROPERTY:${name},SWIG_GENERATED_INCLUDE_DIRECTORIES>>) + set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY INCLUDE_DIRECTORIES ${include_directories} $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_INCLUDE_DIRECTORIES>>) get_property (compile_definitions SOURCE "${infile}" PROPERTY GENERATED_COMPILE_DEFINITIONS) - set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_DEFINITIONS $<TARGET_GENEX_EVAL:${name},$<TARGET_PROPERTY:${name},SWIG_GENERATED_COMPILE_DEFINITIONS>> ${compile_definitions}) + set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_DEFINITIONS $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_COMPILE_DEFINITIONS>> ${compile_definitions}) get_property (compile_options SOURCE "${infile}" PROPERTY GENERATED_COMPILE_OPTIONS) - set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:${name},$<TARGET_PROPERTY:${name},SWIG_GENERATED_COMPILE_OPTIONS>> ${compile_options}) + set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_COMPILE_OPTIONS>> ${compile_options}) set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files} PARENT_SCOPE) @@ -469,13 +505,6 @@ function(SWIG_ADD_LIBRARY name) set(multiValueArgs SOURCES) cmake_parse_arguments(_SAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if (TARGET ${name}) - # a target with same name is already defined. - # call NOW add_library command to raise the most useful error message - add_library(${name}) - return() - endif() - if (_SAM_UNPARSED_ARGUMENTS) message(FATAL_ERROR "SWIG_ADD_LIBRARY: ${_SAM_UNPARSED_ARGUMENTS}: unexpected arguments") endif() @@ -494,16 +523,44 @@ function(SWIG_ADD_LIBRARY name) unset(_SAM_TYPE) endif() + if (NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE) + set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY) + elseif (NOT UseSWIG_TARGET_NAME_PREFERENCE MATCHES "^(LEGACY|STANDARD)$") + message (FATAL_ERROR "UseSWIG_TARGET_NAME_PREFERENCE: ${UseSWIG_TARGET_NAME_PREFERENCE}: invalid value. 'LEGACY' or 'STANDARD' is expected.") + endif() + if (NOT DEFINED UseSWIG_MODULE_VERSION) set (UseSWIG_MODULE_VERSION 1) elseif (NOT UseSWIG_MODULE_VERSION MATCHES "^(1|2)$") message (FATAL_ERROR "UseSWIG_MODULE_VERSION: ${UseSWIG_MODULE_VERSION}: invalid value. 1 or 2 is expected.") endif() - set (workingdir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${name}.dir") + set (SWIG_MODULE_${name}_NOPROXY ${_SAM_NO_PROXY}) + swig_module_initialize(${name} ${_SAM_LANGUAGE}) + + # compute real target name. + if (UseSWIG_TARGET_NAME_PREFERENCE STREQUAL "LEGACY" AND + SWIG_MODULE_${name}_LANGUAGE STREQUAL "PYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY) + # swig will produce a module.py containing an 'import _modulename' statement, + # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32), + # unless the -noproxy flag is used + set(target_name "_${name}") + else() + set(target_name "${name}") + endif() + + if (TARGET ${target_name}) + # a target with same name is already defined. + # call NOW add_library command to raise the most useful error message + add_library(${target_name}) + return() + endif() + + set (workingdir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target_name}.dir") # set special variable to pass extra information to command SWIG_ADD_SOURCE_TO_MODULE # which cannot be changed due to legacy compatibility set (SWIG_WORKING_DIR "${workingdir}") + set (SWIG_TARGET_NAME "${target_name}") set (outputdir "${_SAM_OUTPUT_DIR}") if (NOT _SAM_OUTPUT_DIR) @@ -535,9 +592,6 @@ function(SWIG_ADD_LIBRARY name) set(CMAKE_SWIG_OUTDIR "${outputdir}") set(SWIG_OUTFILE_DIR "${outfiledir}") - set (SWIG_MODULE_${name}_NOPROXY ${_SAM_NO_PROXY}) - swig_module_initialize(${name} ${_SAM_LANGUAGE}) - set(swig_dot_i_sources ${_SAM_SOURCES}) list(FILTER swig_dot_i_sources INCLUDE REGEX "\\.i$") if (NOT swig_dot_i_sources) @@ -563,24 +617,24 @@ function(SWIG_ADD_LIBRARY name) set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${outputdir}") endif() - add_library(${name} + add_library(${target_name} ${_SAM_TYPE} ${swig_generated_sources} ${swig_other_sources}) if(CMAKE_GENERATOR MATCHES "Make") # see IMPLICIT_DEPENDS above add_custom_target(${name}_swig_compilation DEPENDS ${swig_generated_timestamps}) - add_dependencies(${name} ${name}_swig_compilation) + add_dependencies(${target_name} ${name}_swig_compilation) endif() if(_SAM_TYPE STREQUAL "MODULE") - set_target_properties(${name} PROPERTIES NO_SONAME ON) + set_target_properties(${target_name} PROPERTIES NO_SONAME ON) endif() string(TOLOWER "${_SAM_LANGUAGE}" swig_lowercase_language) if (swig_lowercase_language STREQUAL "octave") - set_target_properties(${name} PROPERTIES PREFIX "") - set_target_properties(${name} PROPERTIES SUFFIX ".oct") + set_target_properties(${target_name} PROPERTIES PREFIX "") + set_target_properties(${target_name} PROPERTIES SUFFIX ".oct") elseif (swig_lowercase_language STREQUAL "go") - set_target_properties(${name} PROPERTIES PREFIX "") + set_target_properties(${target_name} PROPERTIES PREFIX "") elseif (swig_lowercase_language STREQUAL "java") # In java you want: # System.loadLibrary("LIBRARY"); @@ -589,23 +643,23 @@ function(SWIG_ADD_LIBRARY name) # Windows: LIBRARY.dll # Linux : libLIBRARY.so if (APPLE) - set_target_properties (${name} PROPERTIES SUFFIX ".jnilib") + set_target_properties (${target_name} PROPERTIES SUFFIX ".jnilib") endif() if ((WIN32 AND MINGW) OR CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL MSYS) - set_target_properties(${name} PROPERTIES PREFIX "") + set_target_properties(${target_name} PROPERTIES PREFIX "") endif() elseif (swig_lowercase_language STREQUAL "lua") if(_SAM_TYPE STREQUAL "MODULE") - set_target_properties(${name} PROPERTIES PREFIX "") + set_target_properties(${target_name} PROPERTIES PREFIX "") endif() elseif (swig_lowercase_language STREQUAL "python") - if (SWIG_MODULE_${name}_NOPROXY) - set_target_properties(${name} PROPERTIES PREFIX "") - else() + if (UseSWIG_TARGET_NAME_PREFERENCE STREQUAL "STANDARD" AND NOT SWIG_MODULE_${name}_NOPROXY) # swig will produce a module.py containing an 'import _modulename' statement, # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32), # unless the -noproxy flag is used - set_target_properties(${name} PROPERTIES PREFIX "_") + set_target_properties(${target_name} PROPERTIES PREFIX "_") + else() + set_target_properties(${target_name} PROPERTIES PREFIX "") endif() # Python extension modules on Windows must have the extension ".pyd" # instead of ".dll" as of Python 2.5. Older python versions do support @@ -616,10 +670,10 @@ function(SWIG_ADD_LIBRARY name) # .pyd is now the only filename extension that will be searched for. # </quote> if(WIN32 AND NOT CYGWIN) - set_target_properties(${name} PROPERTIES SUFFIX ".pyd") + set_target_properties(${target_name} PROPERTIES SUFFIX ".pyd") endif() elseif (swig_lowercase_language STREQUAL "r") - set_target_properties(${name} PROPERTIES PREFIX "") + set_target_properties(${target_name} PROPERTIES PREFIX "") elseif (swig_lowercase_language STREQUAL "ruby") # In ruby you want: # require 'LIBRARY' @@ -627,23 +681,23 @@ function(SWIG_ADD_LIBRARY name) # MacOS : LIBRARY.bundle # Windows: LIBRARY.dll # Linux : LIBRARY.so - set_target_properties (${name} PROPERTIES PREFIX "") + set_target_properties (${target_name} PROPERTIES PREFIX "") if (APPLE) - set_target_properties (${name} PROPERTIES SUFFIX ".bundle") + set_target_properties (${target_name} PROPERTIES SUFFIX ".bundle") endif () elseif (swig_lowercase_language STREQUAL "perl") # assume empty prefix because we expect the module to be dynamically loaded - set_target_properties (${name} PROPERTIES PREFIX "") + set_target_properties (${target_name} PROPERTIES PREFIX "") if (APPLE) - set_target_properties (${name} PROPERTIES SUFFIX ".dylib") + set_target_properties (${target_name} PROPERTIES SUFFIX ".dylib") endif () else() # assume empty prefix because we expect the module to be dynamically loaded - set_target_properties (${name} PROPERTIES PREFIX "") + set_target_properties (${target_name} PROPERTIES PREFIX "") endif () # target property SWIG_SUPPORT_FILES_DIRECTORY specify output directory of support files - set_property (TARGET ${name} PROPERTY SWIG_SUPPORT_FILES_DIRECTORY "${outputdir}") + set_property (TARGET ${target_name} PROPERTY SWIG_SUPPORT_FILES_DIRECTORY "${outputdir}") # target property SWIG_SUPPORT_FILES lists principal proxy support files if (NOT SWIG_MODULE_${name}_NOPROXY) string(TOUPPER "${_SAM_LANGUAGE}" swig_uppercase_language) @@ -656,13 +710,13 @@ function(SWIG_ADD_LIBRARY name) if (swig_all_support_files) list(REMOVE_DUPLICATES swig_all_support_files) endif() - set_property (TARGET ${name} PROPERTY SWIG_SUPPORT_FILES ${swig_all_support_files}) + set_property (TARGET ${target_name} PROPERTY SWIG_SUPPORT_FILES ${swig_all_support_files}) endif() # to ensure legacy behavior, export some variables set (SWIG_MODULE_${name}_LANGUAGE "${SWIG_MODULE_${name}_LANGUAGE}" PARENT_SCOPE) set (SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" PARENT_SCOPE) - set (SWIG_MODULE_${name}_REAL_NAME "${name}" PARENT_SCOPE) + set (SWIG_MODULE_${name}_REAL_NAME "${target_name}" PARENT_SCOPE) set (SWIG_MODULE_${name}_NOPROXY "${SWIG_MODULE_${name}_NOPROXY}" PARENT_SCOPE) set (SWIG_MODULE_${name}_EXTRA_FLAGS "${SWIG_MODULE_${name}_EXTRA_FLAGS}" PARENT_SCOPE) # the last one is a bit crazy but it is documented, so... @@ -674,10 +728,14 @@ endfunction() # Like TARGET_LINK_LIBRARIES but for swig modules # function(SWIG_LINK_LIBRARIES name) - message(DEPRECATION "SWIG_LINK_LIBRARIES is deprecated. Use TARGET_LINK_LIBRARIES instead.") - if(SWIG_MODULE_${name}_REAL_NAME) + if (UseSWIG_TARGET_NAME_PREFERENCE STREQUAL "STANDARD") + message(DEPRECATION "SWIG_LINK_LIBRARIES is deprecated. Use TARGET_LINK_LIBRARIES instead.") target_link_libraries(${name} ${ARGN}) else() - message(SEND_ERROR "Cannot find Swig library \"${name}\".") + if(SWIG_MODULE_${name}_REAL_NAME) + target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN}) + else() + message(SEND_ERROR "Cannot find Swig library \"${name}\".") + endif() endif() endfunction() diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 93cdf41..8a4c004 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -664,6 +664,12 @@ int cmCPackDebGenerator::createDeb() cmGeneratedFileStream debStream; debStream.Open(outputPath.c_str(), false, true); cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd"); + + // uid/gid should be the one of the root user, and this root user has + // always uid/gid equal to 0. + deb.SetUIDAndGID(0u, 0u); + deb.SetUNAMEAndGNAME("root", "root"); + if (!deb.Add(tlDir + "debian-binary", tlDir.length()) || !deb.Add(tlDir + "control.tar.gz", tlDir.length()) || !deb.Add(tlDir + "data.tar" + compression_suffix, tlDir.length())) { diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 73f9a2e..1bbcf46 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -365,7 +365,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, if (this->CurrentProcessingState != ProcessingKeywordLinkInterface && this->CurrentProcessingState != ProcessingPlainLinkInterface) { - // Find target on the LHS locally + // Assure that the target on the LHS was created in the current directory. cmTarget* t = this->Makefile->FindLocalNonAliasTarget(this->Target->GetName()); if (!t) { @@ -378,18 +378,11 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, } } } - - // If no local target has been found, find it in the global scope - if (!t) { - t = this->Makefile->GetGlobalGenerator()->FindTarget( - this->Target->GetName(), true); - } - if (!t) { std::ostringstream e; e << "Attempt to add link library \"" << lib << "\" to target \"" << this->Target->GetName() - << "\" which does not exist or is an alias target."; + << "\" which is not built in this directory."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index d61fa5f..97b0888 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -8,10 +8,7 @@ run_cmake(ImportedTarget) run_cmake(ImportedTargetFailure) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) -run_cmake(SubDirImportedTarget) run_cmake(SubDirTarget) -run_cmake(SubDirTarget-UNKNOWN-IMPORTED) -run_cmake(SubDirTarget-UNKNOWN-IMPORTED-GLOBAL) run_cmake(SharedDepNotTarget) run_cmake(StaticPrivateDepNotExported) run_cmake(StaticPrivateDepNotTarget) diff --git a/Tests/RunCMake/target_link_libraries/SubDirImportedTarget-stdout.txt b/Tests/RunCMake/target_link_libraries/SubDirImportedTarget-stdout.txt deleted file mode 100644 index a7ef260..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirImportedTarget-stdout.txt +++ /dev/null @@ -1,4 +0,0 @@ --- mainexeUnknownImportedGlobal: mainlib;sublib --- mainlibUnknownImportedGlobal: mainlib;sublib --- subexeUnknownImportedGlobal: mainlib;sublib --- sublibUnknownImportedGlobal: mainlib;sublib diff --git a/Tests/RunCMake/target_link_libraries/SubDirImportedTarget.cmake b/Tests/RunCMake/target_link_libraries/SubDirImportedTarget.cmake deleted file mode 100644 index 738280b..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirImportedTarget.cmake +++ /dev/null @@ -1,17 +0,0 @@ -enable_language(C) - -add_executable(mainexeUnknownImportedGlobal IMPORTED GLOBAL) -add_library(mainlibUnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) -add_library(mainlib empty.c) - -add_subdirectory(SubDirImportedTarget) - -target_link_libraries(subexeUnknownImportedGlobal INTERFACE mainlib) -target_link_libraries(subexeUnknownImportedGlobal INTERFACE sublib) -get_property(subexeUnknownImportedGlobal_libs TARGET subexeUnknownImportedGlobal PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "subexeUnknownImportedGlobal: ${subexeUnknownImportedGlobal_libs}") - -target_link_libraries(sublibUnknownImportedGlobal INTERFACE mainlib) -target_link_libraries(sublibUnknownImportedGlobal INTERFACE sublib) -get_property(sublibUnknownImportedGlobal_libs TARGET sublibUnknownImportedGlobal PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "sublibUnknownImportedGlobal: ${sublibUnknownImportedGlobal_libs}") diff --git a/Tests/RunCMake/target_link_libraries/SubDirImportedTarget/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/SubDirImportedTarget/CMakeLists.txt deleted file mode 100644 index d67a01c..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirImportedTarget/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_executable(subexeUnknownImportedGlobal IMPORTED GLOBAL) -add_library(sublibUnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) -add_library(sublib ../empty.c) - -target_link_libraries(mainexeUnknownImportedGlobal INTERFACE mainlib) -target_link_libraries(mainexeUnknownImportedGlobal INTERFACE sublib) -get_property(mainexeUnknownImportedGlobal_libs TARGET mainexeUnknownImportedGlobal PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "mainexeUnknownImportedGlobal: ${mainexeUnknownImportedGlobal_libs}") - -target_link_libraries(mainlibUnknownImportedGlobal INTERFACE mainlib) -target_link_libraries(mainlibUnknownImportedGlobal INTERFACE sublib) -get_property(mainlibUnknownImportedGlobal_libs TARGET mainlibUnknownImportedGlobal PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "mainlibUnknownImportedGlobal: ${mainlibUnknownImportedGlobal_libs}") diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL-stdout.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL-stdout.txt deleted file mode 100644 index a8c77cb..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL-stdout.txt +++ /dev/null @@ -1,2 +0,0 @@ --- mainexe: mainlibUnknownImportedGlobal;sublibUnknownImportedGlobal --- subexe: mainlibUnknownImportedGlobal;sublibUnknownImportedGlobal diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL.cmake deleted file mode 100644 index 04d64e6..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(C) - -add_executable(mainexe empty.c) -add_library(mainlibUnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) - -add_subdirectory(SubDirTarget-UNKNOWN-IMPORTED-GLOBAL) - -target_link_libraries(subexe mainlibUnknownImportedGlobal) -target_link_libraries(subexe sublibUnknownImportedGlobal) -get_property(subexe_libs TARGET subexe PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "subexe: ${subexe_libs}") diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL/CMakeLists.txt deleted file mode 100644 index 6c0c8b2..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-GLOBAL/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(subexe ../empty.c) -add_library(sublibUnknownImportedGlobal UNKNOWN IMPORTED GLOBAL) - -target_link_libraries(mainexe mainlibUnknownImportedGlobal) -target_link_libraries(mainexe sublibUnknownImportedGlobal) -get_property(mainexe_libs TARGET mainexe PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "mainexe: ${mainexe_libs}") diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-stdout.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-stdout.txt deleted file mode 100644 index 4980dc9..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED-stdout.txt +++ /dev/null @@ -1,2 +0,0 @@ --- mainexe: mainlibUnknownImported;sublibUnknownImported --- subexe: mainlibUnknownImported;sublibUnknownImported diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED.cmake b/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED.cmake deleted file mode 100644 index e476a3f..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED.cmake +++ /dev/null @@ -1,11 +0,0 @@ -enable_language(C) - -add_executable(mainexe empty.c) -add_library(mainlibUnknownImported UNKNOWN IMPORTED) - -add_subdirectory(SubDirTarget-UNKNOWN-IMPORTED) - -target_link_libraries(subexe mainlibUnknownImported) -target_link_libraries(subexe sublibUnknownImported) -get_property(subexe_libs TARGET subexe PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "subexe: ${subexe_libs}") diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED/CMakeLists.txt deleted file mode 100644 index 4a40a68..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-UNKNOWN-IMPORTED/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_executable(subexe ../empty.c) -add_library(sublibUnknownImported UNKNOWN IMPORTED) - -target_link_libraries(mainexe mainlibUnknownImported) -target_link_libraries(mainexe sublibUnknownImported) -get_property(mainexe_libs TARGET mainexe PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "mainexe: ${mainexe_libs}") diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt new file mode 100644 index 0000000..5cd1f23 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at SubDirTarget.cmake:[0-9]+ \(target_link_libraries\): + Attempt to add link library "m" to target "subexe" which is not built in + this directory. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-stdout.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-stdout.txt deleted file mode 100644 index 646f984..0000000 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget-stdout.txt +++ /dev/null @@ -1,2 +0,0 @@ --- mainexe: mainlib;sublib --- subexe: mainlib;sublib diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake b/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake index 55c658d..32431ce 100644 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake @@ -1,11 +1,3 @@ enable_language(C) - -add_executable(mainexe empty.c) -add_library(mainlib empty.c) - add_subdirectory(SubDirTarget) - -target_link_libraries(subexe mainlib) -target_link_libraries(subexe sublib) -get_property(subexe_libs TARGET subexe PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "subexe: ${subexe_libs}") +target_link_libraries(subexe m) diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt index 3d956a8..b0b2380 100644 --- a/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt @@ -1,7 +1 @@ add_executable(subexe ../empty.c) -add_library(sublib ../empty.c) - -target_link_libraries(mainexe mainlib) -target_link_libraries(mainexe sublib) -get_property(mainexe_libs TARGET mainexe PROPERTY INTERFACE_LINK_LIBRARIES) -message(STATUS "mainexe: ${mainexe_libs}") diff --git a/Tests/UseSWIG/BasicConfiguration.cmake b/Tests/UseSWIG/BasicConfiguration.cmake index fd3ac40..ad34d39 100644 --- a/Tests/UseSWIG/BasicConfiguration.cmake +++ b/Tests/UseSWIG/BasicConfiguration.cmake @@ -58,6 +58,7 @@ if(${language} MATCHES lua) set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES}) endif() +set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) unset(CMAKE_SWIG_FLAGS) set (CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt index 3f9d363..452f9e2 100644 --- a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt +++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt @@ -16,6 +16,7 @@ else() set (PS ":") endif() +set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) set (UseSWIG_MODULE_VERSION 2) unset(CMAKE_SWIG_FLAGS) diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt index 578825f..25dd6b3 100644 --- a/Tests/UseSWIG/MultipleModules/CMakeLists.txt +++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt @@ -19,6 +19,7 @@ else() set (PS ":") endif() +set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) unset(CMAKE_SWIG_FLAGS) set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON) diff --git a/Tests/UseSWIG/MultiplePython/CMakeLists.txt b/Tests/UseSWIG/MultiplePython/CMakeLists.txt index a5e3eed..a1651fb 100644 --- a/Tests/UseSWIG/MultiplePython/CMakeLists.txt +++ b/Tests/UseSWIG/MultiplePython/CMakeLists.txt @@ -17,6 +17,7 @@ else() set (PS ":") endif() +set(UseSWIG_TARGET_NAME_PREFERENCE STANDARD) unset(CMAKE_SWIG_FLAGS) set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON) |