summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/cmake_minimum_required.rst4
-rw-r--r--Help/command/cmake_policy.rst5
-rw-r--r--Help/release/3.12.rst3
-rw-r--r--Modules/UseSWIG.cmake164
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx6
-rw-r--r--Tests/UseSWIG/BasicConfiguration.cmake1
-rw-r--r--Tests/UseSWIG/ModuleVersion2/CMakeLists.txt1
-rw-r--r--Tests/UseSWIG/MultipleModules/CMakeLists.txt1
-rw-r--r--Tests/UseSWIG/MultiplePython/CMakeLists.txt1
9 files changed, 131 insertions, 55 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/release/3.12.rst b/Help/release/3.12.rst
index 4d1135e..79ebc8e 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
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/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)