2 # This script create a list of compiled Java class files to be added to a
3 # jar file. This avoids including cmake files which get created in the
7 #=============================================================================
8 # Copyright 2010-2011 Andreas schneider <asn@redhat.com>
10 # Distributed under the OSI-approved BSD License (the "License");
11 # see accompanying file Copyright.txt for details.
13 # This software is distributed WITHOUT ANY WARRANTY; without even the
14 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 # See the License for more information.
16 #=============================================================================
17 # (To distribute this file outside of CMake, substitute the full
18 # License text for the above reference.)
20 if (CMAKE_JAVA_CLASS_OUTPUT_PATH)
21 if (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}")
23 set(_JAVA_GLOBBED_FILES)
24 if (CMAKE_JAR_CLASSES_PREFIX)
25 foreach(JAR_CLASS_PREFIX ${CMAKE_JAR_CLASSES_PREFIX})
26 message(STATUS "JAR_CLASS_PREFIX: ${JAR_CLASS_PREFIX}")
28 file(GLOB_RECURSE _JAVA_GLOBBED_TMP_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${JAR_CLASS_PREFIX}/*.class")
29 if (_JAVA_GLOBBED_TMP_FILES)
30 list(APPEND _JAVA_GLOBBED_FILES ${_JAVA_GLOBBED_TMP_FILES})
34 file(GLOB_RECURSE _JAVA_GLOBBED_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/*.class")
37 set(_JAVA_CLASS_FILES)
38 # file(GLOB_RECURSE foo RELATIVE) is broken so we need this.
39 foreach(_JAVA_GLOBBED_FILE ${_JAVA_GLOBBED_FILES})
40 file(RELATIVE_PATH _JAVA_CLASS_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ${_JAVA_GLOBBED_FILE})
41 set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES}${_JAVA_CLASS_FILE}\n)
45 file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist ${_JAVA_CLASS_FILES})
48 message(SEND_ERROR "FATAL: Java class output path doesn't exist")
51 message(SEND_ERROR "FATAL: Can't find CMAKE_JAVA_CLASS_OUTPUT_PATH")