summaryrefslogtreecommitdiffstats
path: root/pki/cmake
diff options
context:
space:
mode:
authorasn <asn@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-12-17 21:15:11 +0000
committerasn <asn@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-12-17 21:15:11 +0000
commit363c7ee48c704d8c332072fb34a4aed7948ee5fe (patch)
tree13469d1a510ed7d3f7e13eab3ed5fbf1a92904a5 /pki/cmake
parent760e90a9d139cbc9f8905d93e096fbda3e73e65c (diff)
downloadpki-363c7ee48c704d8c332072fb34a4aed7948ee5fe.tar.gz
pki-363c7ee48c704d8c332072fb34a4aed7948ee5fe.tar.xz
pki-363c7ee48c704d8c332072fb34a4aed7948ee5fe.zip
cmake: Added a find_jar function from Ben Boeckel.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@1650 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/cmake')
-rw-r--r--pki/cmake/Modules/UseJava.cmake112
1 files changed, 111 insertions, 1 deletions
diff --git a/pki/cmake/Modules/UseJava.cmake b/pki/cmake/Modules/UseJava.cmake
index 2d715df0..79ac6253 100644
--- a/pki/cmake/Modules/UseJava.cmake
+++ b/pki/cmake/Modules/UseJava.cmake
@@ -67,13 +67,31 @@
# <target>_CLASS_DIR The directory where the class files can be
# found. For example to use them with javah.
#
+# find_jar(
+# <VAR>
+# name | NAMES name1 [name2 ...]
+# [PATHS path1 [path2 ... ENV var]]
+# [VERSIONS version1 [version2]]
+# [DOC "cache documentation string"]
+# )
+#
+# This command is used to find a full path to the named jar. A cache entry
+# named by <VAR> is created to stor the result of this command. If the full
+# path to a jar is found the result is stored in the variable and the search
+# will not repeated unless the variable is cleared. If nothing is found, the
+# result will be <VAR>-NOTFOUND, and the search will be attempted again next
+# time find_jar is invoked with the same variable.
+# The name of the full path to a file that is searched for is specified by
+# the names listed after NAMES argument. Additional search locations can be
+# specified after the PATHS argument. If you require special a version of a
+# jar file you can specify it with the VERSIONS argument. The argument after
+# DOC will be used for the documentation string in the cache.
#
# install_jar(TARGET_NAME DESTINATION)
#
# This command installs the TARGET_NAME files to the given DESTINATION. It
# should be called in the same scope as add_jar() or it will fail.
#
-#
# install_jni_symlink(TARGET_NAME DESTINATION)
#
# This command installs the TARGET_NAME JNI symlinks to the given
@@ -82,6 +100,7 @@
#
#=============================================================================
# Copyright 2010 Andreas schneider <asn@redhat.com>
+# Copyright 2010 Ben Boeckel <ben.boeckel@kitware.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -287,3 +306,94 @@ function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION)
endif (${_TARGET_NAME}_JNI_SYMLINK)
endfunction(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION)
+function (find_jar VARIABLE)
+ set(_jar_names)
+ set(_jar_files)
+ set(_jar_versions)
+ set(_jar_paths
+ /usr/share/java/
+ /usr/local/share/java/
+ ${Java_JAR_PATHS})
+ set(_jar_doc "NOTSET")
+
+ set(_state "name")
+
+ foreach (arg ${ARGN})
+ if (${_state} STREQUAL "name")
+ if (${arg} STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (${arg} STREQUAL "NAMES")
+ set(_state "names")
+ elseif (${arg} STREQUAL "PATHS")
+ set(_state "paths")
+ elseif (${arg} STREQUAL "DOC")
+ set(_state "doc")
+ else (${arg} STREQUAL "NAMES")
+ set(_jar_names ${arg})
+ if (_jar_doc STREQUAL "NOTSET")
+ set(_jar_doc "Finding ${arg} jar")
+ endif (_jar_doc STREQUAL "NOTSET")
+ endif (${arg} STREQUAL "VERSIONS")
+ elseif (${_state} STREQUAL "versions")
+ if (${arg} STREQUAL "NAMES")
+ set(_state "names")
+ elseif (${arg} STREQUAL "PATHS")
+ set(_state "paths")
+ elseif (${arg} STREQUAL "DOC")
+ set(_state "doc")
+ else (${arg} STREQUAL "NAMES")
+ set(_jar_versions ${_jar_versions} ${arg})
+ endif (${arg} STREQUAL "NAMES")
+ elseif (${_state} STREQUAL "names")
+ if (${arg} STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (${arg} STREQUAL "PATHS")
+ set(_state "paths")
+ elseif (${arg} STREQUAL "DOC")
+ set(_state "doc")
+ else (${arg} STREQUAL "VERSIONS")
+ set(_jar_names ${_jar_names} ${arg})
+ if (_jar_doc STREQUAL "NOTSET")
+ set(_jar_doc "Finding ${arg} jar")
+ endif (_jar_doc STREQUAL "NOTSET")
+ endif (${arg} STREQUAL "VERSIONS")
+ elseif (${_state} STREQUAL "paths")
+ if (${arg} STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (${arg} STREQUAL "NAMES")
+ set(_state "names")
+ elseif (${arg} STREQUAL "DOC")
+ set(_state "doc")
+ else (${arg} STREQUAL "VERSIONS")
+ set(_jar_paths ${_jar_paths} ${arg})
+ endif (${arg} STREQUAL "VERSIONS")
+ elseif (${_state} STREQUAL "doc")
+ if (${arg} STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (${arg} STREQUAL "NAMES")
+ set(_state "names")
+ elseif (${arg} STREQUAL "PATHS")
+ set(_state "paths")
+ else (${arg} STREQUAL "VERSIONS")
+ set(_jar_doc ${arg})
+ endif (${arg} STREQUAL "VERSIONS")
+ endif (${_state} STREQUAL "name")
+ endforeach (arg ${ARGN})
+
+ if (${_jar_names} STREQUAL "")
+ message(FATAL_ERROR "find_jar: No name to search for given")
+ endif (${_jar_names} STREQUAL "")
+
+ foreach (jar_name ${_jar_names})
+ foreach (version ${_jar_versions})
+ set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
+ endforeach (version ${_jar_versions})
+ set(_jar_files ${_jar_files} ${jar_name}.jar)
+ endforeach (jar_name ${_jar_names})
+
+ find_file(${VARIABLE}
+ NAMES ${_jar_files}
+ PATHS ${_jar_paths}
+ DOC ${_jar_doc}
+ NO_DEFAULT_PATH)
+endfunction (find_jar VARIABLE)