102 Commits

Author SHA1 Message Date
Brad King
24ff152aa0 Merge topic 'UseSWIG-legacy-user-flags'
2f88c177d0 UseSWIG: restore legacy behavior for SWIG_MODULE_<name>_EXTRA_FLAGS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Julien Schueller <schueller@phimeca.com>
Merge-request: !2245
2018-08-01 07:21:34 -04:00
Marc Chevrier
2f88c177d0 UseSWIG: restore legacy behavior for SWIG_MODULE_<name>_EXTRA_FLAGS
Fixes: #18226
2018-07-31 19:33:35 +02:00
Marc Chevrier
a3a0c3aa71 UseSWIG: add policy to manage target naming strategy. 2018-07-25 18:00:52 +02:00
Brad King
018c373f35 Merge topic 'UseSWIG-csharp-conditional'
ed289e0577 UseSWIG: Use CSharp language only if it is enabled

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ram-Z <me@rmz.io>
Acked-by: Marc Chevrier <marc.chevrier@gmail.com>
Merge-request: !2219
2018-07-19 07:08:31 -04:00
Brad King
ed289e0577 UseSWIG: Use CSharp language only if it is enabled
In commit v3.12.0-rc1~2^2 (UseSWIG: Add CSHARP variant for wrapper
files, 2018-06-08) we explicitly marked swig-generated `.cs` files as
`LANGUAGE` CSharp so that the resulting sources can be compiled.
However, this works only when the CSharp language has been enabled.

Fixes: #18184
2018-07-18 08:53:32 -04:00
Brad King
8f2b483c06 Merge branch 'backport-UseSWIG-legacy-targets' into UseSWIG-legacy-targets
Resolve conflicts by integrating changes from both sides.
2018-07-03 12:48:02 -04:00
Marc Chevrier
38ffcedd26 UseSWIG: reintroduce legacy target name management
Fixes: #18140
2018-07-03 12:46:59 -04:00
Marc Chevrier
08f2a2408d UseSWIG: add support of target property INCLUDE_DIRECTORIES consumption
Fixes: #18003
2018-06-13 17:46:16 +02:00
Brad King
93fe9fc1a2 Merge branch 'UseSWIG-csharp-variant' into release-3.12
Merge-request: !2137
2018-06-13 10:51:49 -04:00
Brad King
0247f6836c Merge topic 'UseSWIG-csharp-variant'
0c2fb4c896 UseSWIG: Add CSHARP variant for wrapper files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2137
2018-06-13 10:48:51 -04:00
Brad King
b7b4ace2be Merge topic 'UseSWIG-fix-genex'
88dd5dc9ff UseSWIG: add support for generator expressions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2143
2018-06-13 10:48:04 -04:00
Rishi Theivendran
0c2fb4c896 UseSWIG: Add CSHARP variant for wrapper files
Issue: #18065
Fixes: #18066
2018-06-12 11:34:58 -04:00
Brad King
f024f4f8a0 Merge branch 'UseSWIG-fix-genex' into release-3.12
Merge-request: !2143
2018-06-12 10:08:36 -04:00
Marc Chevrier
88dd5dc9ff UseSWIG: add support for generator expressions 2018-06-12 10:07:24 -04:00
Felix Schwitzer
156138d5f1 UseSWIG: Fix handling of SWIG_MODULE_NAME source file property
Fix a typo from commit 0bef9eb410 (UseSWIG: modernize module,
2018-01-29) that caused `UseSWIG` to ignore an eventually set property
`SWIG_MODLUE_NAME`.

Building multiple python modules using the mentioned property as
described in the docs could lead to an invalid, or even worse,
inconsistent `build.ninja` file.  The reason is that the generated list
of support files was not unique.  For each module the support file was
always named the same, namely `path/to/builddir/MODULENAME.py`.
2018-06-12 09:55:53 -04:00
Marc Chevrier
963837cf17 UseSWIG: fix erroneous generator expressions
Add note regarding multi-config generators
2018-04-10 11:28:32 +02:00
Marc Chevrier
8ab4e38373 UseSWIG: Add new behavior for better support files management
fixes: #17840
2018-04-03 12:44:55 +02:00
Marc Chevrier
51b642679b UseSWIG: fix prefix library for Java on Windows
Fixes: #17836
2018-03-22 11:18:17 -04:00
Marc Chevrier
0bef9eb410 UseSWIG: modernize module 2018-02-14 08:35:04 +01:00
Marc Chevrier
d6048bd153 UseSWIG: Re-work test framework 2018-02-14 08:35:04 +01:00
Marc Chevrier
bc3697fa51 UseSWIG: Restore support for like-named .i files in different modules
Fix logic added by commit 2ee10119ea (swig: fix incremental build in
case of removed interface files, 2017-11-06).  Name the extra targets
added for Makefile generators using both the module name and .i base
name to avoid collisions across modules.  Also make sure the extra
targets added for all .i files in a module are added as dependencies
instead of just the last one.

Fixes: #17704
2018-02-02 07:41:44 -05:00
Noel Eck
b844a414c7 UseSWIG: Clarify documentation of SWIG_OUTFILE_DIR
The `SWIG_OUTFILE_DIR` variable provides the option to specify an output
directory location.  This commit removes portion stating that this is
equal to the `swig -o` option since it does not set the output filename.

Fixes: #17703
Signed-off-by: Noel Eck <noel.eck@intel.com>
2018-01-31 14:22:24 -05:00
Brad King
315b0927e9 UseSWIG: Improve documentation markup 2018-01-31 14:20:17 -05:00
Brad King
ce130c7a6b UseSWIG: Convert docs to a bracket comment 2018-01-31 13:55:22 -05:00
Felix Schwitzer
2ee10119ea swig: fix incremental build in case of removed interface files
Commit v3.8.0-rc1~123^2 (UseSWIG: Automatically scan dependencies of SWIG files
for Makefiles, 2016-12-21) introduced automatic dependency scanning for files
`%include`d in a swig interface definition file. This works fine as long as no
such file is removed. But removing a dependent file breaks an incremental build
and `make` complains about a missing dependency, see #16830.

Integrate the approach proposed in the issue above into the SWIG-module, do the
workaround in a conditional step as it arises only for Makefile generators. For
other generators use the implementation before that commit.

Fixes: #17433.
2017-11-08 15:25:20 +01:00
Brad King
973ee6605b Merge topic 'UseSWIG-Java-enabled'
b4fbf677 UseSWIG: Fix when Java is enabled as a language

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1095
2017-08-03 09:33:57 -04:00
Brad King
b4fbf677bb UseSWIG: Fix when Java is enabled as a language
Since commit v3.8.0-rc1~251^2 (UseSWIG: Record generated java files as
custom command outputs, 2016-11-28) the generated `.java` files are
listed as sources in the call to `add_library` by swig_add_library.
They are listed only as the outputs of custom commands and not intended
for compilation as part of the library.

Reported-by: Alan W. Irwin <irwin@beluga.phys.uvic.ca>
2017-08-02 11:52:36 -04:00
Robert Langlois
76a0286b1d UseSWIG: Add -dllimport only if not already specified
SWIG fails with a redefined macro error when `-dllimport` is specified
more than once.  One case where you would want to specify your own
dllimport is when using SWIG with netstandard2.0.  .NET Core does not
search for shared library like Mono or .NET, so you need a fully
qualified shared library name.
2017-06-13 18:07:32 -07:00
Brad King
8ed663791b UseSWIG: Fall back to empty PREFIX for unknown languages
Teach `SWIG_ADD_LIBRARY` to fall back to an empty library prefix for
languages we don't explicitly define already.

Suggested-by: Alan W. Irwin <irwin@beluga.phys.uvic.ca>
2017-04-25 08:52:14 -04:00
Brad King
097b47b972 Merge topic 'dont-include-CMakeParseArguments'
d6877e6c Don't include CMakeParseArguments
2017-01-12 10:20:41 -05:00
Daniel Pfeifer
d6877e6c40 Don't include CMakeParseArguments
The cmake_parse_arguments command is builtin with version 3.5.
The CMakeParseArguments module is empty and exists for backwards
compatibility with CMake 3.4 and lower.

Remove the includes of CMakeParseArguments from CMake's modules.
The modules are always used with the current version of CMake.

Leave the includes in the tests, as the tests may be run with an older
version of CMake.
2017-01-11 13:14:57 +01:00
Alexey Sokolov
b8968b4b39 UseSWIG: Automatically scan dependencies of SWIG files for Makefiles
Issue: #4147
2017-01-10 13:05:59 -05:00
caryoscelus
62c4cb4b6f UseSWIG: Record generated java files as custom command outputs
When another target depends on the generated files CMake must know which
custom command generates them in order to hook up the dependency
properly.  We already do this for Python.  Add the Java files too.
2016-11-29 10:21:05 -05:00
Daniele E. Domenichelli
d5b56dd15c UseSWIG: Add USE_BUILD_SHARED_LIBS to accepted values for the TYPE arg
The new signature is

  SWIG_ADD_LIBRARY(<name>
                   [TYPE <SHARED|MODULE|STATIC|USE_BUILD_SHARED_LIBS>]
                   LANGUAGE <language>
                   SOURCES <file>...
                   )
2016-11-14 18:02:12 +01:00
Daniele E. Domenichelli
ec1d585c43 UseSWIG: Do not set PREFIX property for SHARED and STATIC lua libraries 2016-11-11 08:14:10 +01:00
Daniele E. Domenichelli
4c5b3c1cea UseSWIG: Do not set NO_SONAME property for SHARED and STATIC libraries 2016-11-11 08:14:10 +01:00
Daniele E. Domenichelli
d0a9d8bbe6 UseSWIG: Add swig_add_library macro.
swig_add_module does not allow to set the type for the library and
instead always create the library as MODULE.

This patch adds the new swig_add_library command with this signature:

  SWIG_ADD_LIBRARY(<name>
                   [TYPE <SHARED|MODULE|STATIC>]
                   LANGUAGE <language>
                   SOURCES <file>...
                   )

The swig_add_module is deprecated in favour of swig_add_library.

Closes: #16415
2016-11-11 08:13:47 +01:00
Cong Zhang
8444b984a2 UseSWIG: Add option to specify swig output file directory
`swig` has two output-related options:

* `-o <outfile>`: Set name of C/C++ output file to <outfile>
* `-outdir <dir>`: Set language-specific files output directory to <dir>

We already have `CMAKE_SWIG_OUTDIR` for the latter.  Add a new
`SWIG_OUTFILE_DIR` option for the former.
2016-11-01 10:10:08 -04:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Daniel Pfeifer
5d0d980d99 Use string(APPEND) in Modules
Automate with:

find Modules -type f -print0 | xargs -0 perl -i -0pe \
's/set\(([a-zA-Z0-9_]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
2016-07-28 00:41:13 +02:00
Ben Webb
96a8890c7d FindSWIG: Do not generate erroneous outputs with -noproxy
Generally for a module foo, SWIG generates (in Python mode)
an extension module _foo.so and a proxy Python module foo.py.
However, if -noproxy is specified, instead it builds only foo.so
(without the leading underscore). The custom command generated
by CMake correctly handles the removal of this underscore when
-noproxy is given; however, it still adds foo.py to the expected
outputs. This upsets build tools that expect foo.py to be generated
(for example, 'make' will run the SWIG command twice). Fix this
by removing foo.py from the set of extra generated files when
-noproxy is specified.
2015-09-09 10:01:06 -04:00
Nils Gladitz
32a2f41402 Revert "add_custom_command: Diagnose MAIN_DEPENDENCY limitation."
This reverts commit 242c3966 (add_custom_command: Diagnose
MAIN_DEPENDENCY limitation, 2015-03-09) and the follow up commit
b372a99a (UseSWIG: Do not use MAIN_DEPENDENCY on custom commands,
2015-03-26).

I misdiagnosed the underlying issue that prompted creation of policy CMP0057.
The actual issue surfaces when a single custom command's MAIN_DEPENDENCY
is listed in more than one target; this issue will have to be addressed
independently.
2015-04-30 10:20:20 -04:00
Tuukka Pasanen
dd7e31bc15 UseSWIG: Fix module name detection with relative source file (#15508)
When SWIG_GET_EXTRA_OUTPUT_FILES checks to see if a source file exists
for use in reading the module name, it must pass an absolute path to
the if(EXISTS) command.  Teach SWIG_ADD_SOURCE_TO_MODULE to give it
the absolute path it already knows.
2015-04-15 11:39:44 -04:00
Felix Schwitzer
b372a99a13 UseSWIG: Do not use MAIN_DEPENDENCY on custom commands (#15480)
Add the dependency on the main swig input source file as a normal
DEPENDS option.  We cannot use MAIN_DEPENDENCY because if there are
multiple target languages then multiple custom commands would want to
use the same MAIN_DEPENDENCY, but at most one custom command may specify
a given source file as its MAIN_DEPENDENCY.  Exposed by a CMP0057
warning.
2015-03-30 09:35:43 -04:00
Brad King
458c9e95de UseSWIG: Avoid if() auto-dereferene in quoted arguments
Protect against variables named "CSHARP", "PERL", "PYTHON", or "UNKNOWN"
when CMP0054 is not set to NEW.

Reported-by: Tuukka Pasanen <tuukka@iocaste.ilmi.fi>
2015-03-09 16:35:08 -04:00
Julien Schueller
9de113a943 UseSWIG: Fix R module prefix 2014-10-14 09:41:58 -04:00
Brad King
2196cae4ec Merge topic 'UseSWIG-fix-noproxy-check'
e932ac9c UseSWIG: Fix check for noproxy flag (#14990)
2014-06-27 09:42:54 -04:00
Brad King
e932ac9cad UseSWIG: Fix check for noproxy flag (#14990)
The check for this flag added by commit v3.0.0-rc1~284^2 (UseSWIG: Name
python module according to swig flags, 2013-11-26) can get false
positives on flags like "-noproxydel".  Improve the check to match only
"-noproxy".

Suggested-by: Garth Wells <gnw20@cam.ac.uk>
2014-06-25 13:57:24 -04:00
Julien Schueller
a3b1be5e69 UseSWIG: Add support for Go and Lua 2014-04-29 09:56:18 -04:00
Brad King
ad8041e335 Merge topic 'UseSWIG-guess_module_name'
2c96192f UseSWIG: Revise and format documentation
e147c5c5 UseSWIG: Detect module name from interface file (#10080)
2014-04-21 09:32:23 -04:00