Commit Graph

63 Commits

Author SHA1 Message Date
Kyle Edwards
966a9eece3 Merge topic 'function-var-current'
24fdd51f45 Refactor: Replace CMAKE_CURRENT_LIST_DIR with CMAKE_CURRENT_FUNCTION_LIST_DIR
90e3e2a777 cmFunctionCommand: Introduce `CMAKE_CURRENT_FUNCTION*` variables
dd54290dab Refactor: Modernize `function` command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !4000
2019-12-12 14:00:41 -05:00
Alex Turbov
24fdd51f45 Refactor: Replace CMAKE_CURRENT_LIST_DIR with CMAKE_CURRENT_FUNCTION_LIST_DIR
Some modules define an intermediate global scope visible variables
to access "resource" files from functions.
Now these variables could be eliminated.
2019-12-10 16:43:27 +02:00
Nathan Burles
8d47b97a69 UseJava: Use correct path separator in javadoc
For both classpath and sourcepath.
2019-11-20 10:38:44 -05:00
Nathan Burles
1b27ac78ac UseJava: Use list(APPEND) to simplify javadoc option construction 2019-11-20 10:38:44 -05:00
Nathan Burles
c7a4b1a58e UseJava: Extract the path separator to module level
It is currently only defined within the add_jar function, but is needed
inside other functions in this module.
2019-11-20 10:38:44 -05:00
Sebastian Holtermann
8c47be28cc UseJava: Use ADDITIONAL_CLEAN_FILES for cleaning
Replace use of the deprecated `ADDITIONAL_MAKE_CLEAN_FILES` directory property
with the new `ADDITIONAL_CLEAN_FILES` directory property.
2019-05-15 15:31:05 +02:00
Robert Maynard
359e2d401d UseJava: Refactor documentation for better formatting
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
2019-05-15 22:54:15 +10:00
Marc Chevrier
95ef818c7d UseJava: clean-up if() expressions
Fixes: #18836
2019-01-28 18:43:50 +01:00
Marc Chevrier
5aa88f0e02 UseJava: add_jar: rebuild jar on dependencies changes
Fixes: #18683
2018-12-11 15:17:24 +01:00
Kitware Robot
df4ed1e9ff Help: Convert remaining modules to block-style comments 2018-10-22 11:09:34 -04:00
Brad King
ea54a9c666 Merge branch 'backport-java-new-packaging' into java-new-packaging
Fix conflicts by combining the changes from both sides.
2018-04-25 09:19:35 -04:00
Marc Chevrier
5482f485b8 FindJava, FindJNI, UseJava: update for version 10 support
* new version format
* new registry layout on Windows

Fixes: #17938
2018-04-25 09:18:53 -04:00
luz.paz
193082a3c8 MAINT: Misc. typos
Found via `codespell -q 3 -I ../cmake-whitelist.txt`.
2018-02-13 11:24:30 -05:00
Marc Chevrier
4829ea239a add_jar: add option GENERATE_NATIVE_HEADERS 2018-01-22 17:15:59 +01:00
luzpaz
777e87ae00 Fix trivial typos in text
Some are user facing.

Found using

    codespell -q 3 --skip="./Utilities" -I .cmake-whitelist.txt`

whereby the whitelist contained:

    ans
    dum
    helpfull
    emmited
    emmitted
    buil
    iff
    isnt
    nto
    ot
    pathes
    substract
    te
    todays
    upto
    whitespaces
2017-11-03 10:25:05 -04:00
Marc Chevrier
48dcb2f055 UseJava: add_jar OUTPUT_DIR option used only for jar generation.
Build artifacts go to CMAKE_CURRENT_BINARY_DIR subdirectory in all cases.

Fixes: #17341
2017-10-12 13:05:17 +02:00
Marc Chevrier
dead049e0b UseJava: OUTPUT_DIR must exists in all cases.
Fixes: #17316
2017-10-10 10:00:23 +02:00
Daniel Pfeifer
9e24af0137 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'
2017-05-17 11:26:11 -06:00
Matthew Woehlke
789c8de3df UseJava: Support namespaced exports
Add NAMESPACE option to export_jars and install_jar_exports. Import
JAR's as imported static libraries rather than custom targets, as this
is necessary to allow the imported targets to contain ':' in their
names. (This also means they won't show up in VS projects, which is more
consistent with other imported targets.) Also, improve the documentation
to be more stylistically consistent with documentation elsewhere.
2017-04-21 10:51:09 -04: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
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
Matthew Woehlke
0bd91ad405 UseJava: Fix race condition creating java class list
Modify logic to unconditionally create an empty class list response file
to instead only create the empty file if no classes are being compiled.
Otherwise, the response file is created via a custom command that
generates the correct list.

This fixes a race condition on certain systems (e.g. HFS on OS X) where
the dependency for creating the "correct" list can have the "same" (due
to limited precision of the filesystem) timestamp as the empty file
created at configure time, resulting in an empty class list being
incorrectly used to invoke `jar` (resulting in `jar` being unhappy that
it was not given any input files). Although one would have some hope
that this doesn't affect "real" projects, it definitely does affect the
JavaExportImport unit test, causing the same to fail randomly when run
on an HFS partition.
2016-06-09 09:12:15 -04:00
Matthew Woehlke
5341c0d84a UseJava: Add infrastructure to export targets
Add additional functions to UseJava.cmake to create "exported" targets,
similar to those of C/C++ libraries. In support of this, ensure that the
JAR_FILE property of jar targets is always an absolute path.
2016-06-07 08:50:35 -04:00
Matthew Woehlke
bcf3968851 UseJava: Fix grammar error in documentation 2016-05-31 10:30:57 -04:00
Brad King
fa382ae85e UseJava: use CMAKE_COMMAND instead of direct cmake call
Author: dancing-leaves <dancing-leaves@users.noreply.github.com>
2016-04-06 13:46:51 -04:00
Felix Geyer
49e82c15d5 Fix spelling typos in comments and documentation (#16037)
The Debian package checker tool (lintian) detected several typos in
CMake.
2016-03-29 14:31:02 -04:00
Brad King
1053db7b0c UseJava: Fix documented name of CLASSDIR property (#15936)
It is not `CLASS_DIR`.
2016-01-26 09:27:21 -05:00
Marc Chevrier
18c3714f4f UseJava: Fix create_javah CLASSPATH handling on Windows
Preserve semicolons in the value.
2016-01-19 10:36:11 -05:00
Marc Chevrier
56c11eee13 UseJava: Allow relative path to manifest file just as with other sources 2015-12-03 09:24:26 -05:00
Marc Chevrier
4476feac33 UseJava: Add support for javah tool
Add a `create_javah` API.
2015-08-21 09:30:08 -04:00
Marc Chevrier
cc23f0e9d3 UseJava: Teach install_jar new DESTINATION and COMPONENT options 2015-08-04 11:19:44 -04:00
Marc Chevrier
3d287de4ea UseJava: Teach add_jar to support file syntax for sources 2015-08-04 11:19:43 -04:00
Mark Studenka
a21e8df0da UseJava: Fix add_jar argument parsing (#14655)
Since commit v2.8.11~63^2 (UseJava.cmake: require explicit request to
include jars, 2013-03-26) the argument parsing always overrides the
variable settings even if the corresponding arguments are not passed.
Re-order logic to fix this.
2015-03-20 10:46:13 -04:00
Lorenz Witte
7a373d5e55 UseJava: Fix classpath separator on WIN32 cross compilation (#15206)
The condition to use ";" as classpath separator includes a check for the
switch "WIN32" which is a target switch.  When cross-compiling for a
non-windows target, this switch is not present and the separator
defaults to ":".  It should check for "CMAKE_HOST_WIN32" instead.
2014-10-14 10:02:19 -04:00
Bruno Nova
2abd8efecb UseJava: Copy resource files before compiling the jar (#13360)
Co-Author: Mary Ellen Foster <mefoster@gmail.com>
2014-03-20 09:50:47 -04:00
Stephen Kelly
efc43cde8f Help: Fix some erroneous code block markers in Module docs.
There are many style errors in these files. This patch fixes only
the syntactical errors.

The script which ported these to rst tripped on some incorrectly
formatted blocks in the original input documentation.  Use a new
script to find problematic code (and then fix them manually):

  #!/usr/bin/env python

  import os

  rootDir = '.'

  def checkFile(fname):

    f = open(fname)
    lines = f.readlines()
    started = False
    counter = 0
    for l in lines:
      if "#" in l:
        started = True
      elif started:
        return
      lin = l.find("(")
      if lin != -1 and l.find(")", lin) == -1 and \
          not "(To distribute this file outside of CMake, substitute the full" in l:
        for lp in lines[counter+1:]:
          if lp == "# ::\n":
            print "\n\n######### " + fname + "\n\n"
            print ''.join(lines[max(counter-2, 0):counter+6])
            break
          elif lp == "#\n" :
            continue
          break
      counter += 1

  for dirName, subdirList, fileList in os.walk(rootDir):
      for fname in fileList:
          checkFile(os.path.join(dirName, fname))
2014-01-07 09:52:56 -05:00
Kitware Robot
f051814ed0 Convert builtin help to reStructuredText source files
Run the convert-help.bash script to convert documentation:

 ./convert-help.bash "/path/to/CMake-build/bin"

Then remove it.
2013-10-15 14:12:03 -04:00
Simon Levermann
69aff17d38 UseJava: Add support for the jar 'm' (Manifest) option 2013-09-23 14:54:33 +02:00
Brad King
53431ea259 UseJava: Update notice of copyright by Kitware 2013-07-17 08:33:34 -04:00
Graham Markall
177c0516ce UseJava: Pass sources to javac using response file (#13028)
The command line string passed to javac can exceed the 8191-character
limit on Windows when there are a large number of files to compile.
To avoid this, the list of sources is written to a file which is then
passed to javac as an argfile.  Spaces in paths are dealt with by
enclosing each file in quotes, and separating files with a newline.
2013-07-16 13:29:00 -04:00
Matthew Woehlke
b41771dfeb UseJava.cmake: document add_jar compat shim
Document the logic that parses for backward compatibility the old
variables that were used to control add_jar prior to named argument
support. In particular, document that the reason this logic exists is
for backward compatibility, and that new features do not need to add to
it.
2013-06-17 12:26:24 -04:00
Brad King
9c1393217c Merge topic 'use-java-use-parse-arguments'
81b5fb5 UseJava.cmake: fully use cmake_parse_arguments in add_jar
2013-05-28 10:42:12 -04:00
Gregoire Lejeune
778aacc864 Allow using Java in a cross-compilation toolchain
Since Java is a portable language, if you want to use Java when
cross-compiling, UseJava uses the JVM installed on the host.  So in this
case, we must use set CMAKE_JAVA_INCLUDE_FLAG_SEP for the current host.
2013-05-08 11:45:34 -04:00
Matthew Woehlke
81b5fb5b0d UseJava.cmake: fully use cmake_parse_arguments in add_jar
Modify add_jar to fully use named arguments, rather than cmake
variables, for specifying output names/directories, etc. For backward
compatibility, the old variables are still honored if set, although
named arguments will override them.
2013-03-28 10:36:33 -04:00
Matthew Woehlke
8a2fca8cd7 UseJava.cmake: require explicit request to include jars
Modify add_jar to (partly) use cmake_parse_arguments, and to require
using the named argument list INCLUDE_JARS to specify jar files (or jar
targets) to use as dependencies when creating a jar. This preserves the
ability to have such, while restoring the historic behavior that jar
files listed as sources are ignored. (The code now explicitly ignores
them, however, rather than adding them to an unused local variable, so
that it is more clear that nothing is being done with them.)
2013-03-28 10:35:42 -04:00
Matthew Woehlke
adeafad488 UseJava.cmake: accept jar targets in add_jar
Modify add_jar to also accepts jars by target name.
2013-03-13 17:34:50 -04:00
Matthew Woehlke
53a05b8f51 UseJava.cmake: fix passing jars to add_jar
Fix setting classpath when encountering a jar argument to add_jar to
actually set the variable that is used to specify the classpath to
javac, instead of just uselessly appending the jar to
CMAKE_JAVA_INCLUDE_PATH (which is never used again at the point where it
is modified). Also, list jars so specified as dependencies of compiling
the java sources for the jar target.
2013-03-13 17:30:16 -04:00
Matthew Woehlke
45c8e4b181 UseJava.cmake: simplify path logic
Move logic to determine relative path to .java file to after the file
extension check, so that it only executes when it is actually used.
2013-03-13 17:29:14 -04:00
Kitware Robot
9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00