From 0d7c1e7c0b7612c550d518d15528c91a7b5db46d Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Thu, 9 Aug 2012 23:55:04 -0500
Subject: [PATCH] Updated the remaining build scripts.

The remaining build scripts have been updated to automatically
find the source codes.

Ticket #62
---
 base/ca/src/CMakeLists.txt                         |  65 +++++++-----
 base/java-tools/src/CMakeLists.txt                 | 114 ++++++++++++---------
 base/kra/src/CMakeLists.txt                        |  72 +++++++------
 base/ocsp/src/CMakeLists.txt                       |  62 ++++++-----
 base/silent/src/CMakeLists.txt                     |  95 ++++++++---------
 base/symkey/src/CMakeLists.txt                     |  52 ++++++++--
 base/symkey/src/com/netscape/symkey/CMakeLists.txt |   2 +-
 base/tks/src/CMakeLists.txt                        |  59 +++++++----
 dogtag/console-ui/src/CMakeLists.txt               |  41 +++++---
 9 files changed, 339 insertions(+), 223 deletions(-)

diff --git a/base/ca/src/CMakeLists.txt b/base/ca/src/CMakeLists.txt
index cd0c352a8eb2e0791f53e259fab363864d860953..09cea8ac27168e1c9c61febedb45cc82cb098321 100644
--- a/base/ca/src/CMakeLists.txt
+++ b/base/ca/src/CMakeLists.txt
@@ -31,34 +31,47 @@ find_file(JAXRS_API_JAR
         /usr/share/java/resteasy
 )
 
-# identify java sources
-set(pki-ca_java_SRCS
-    com/netscape/ca/CMSCRLExtensions.java
-    com/netscape/ca/CAService.java
-    com/netscape/ca/SigningUnit.java
-    com/netscape/ca/CRLWithExpiredCerts.java
-    com/netscape/ca/CRLIssuingPoint.java
-    com/netscape/ca/CAPolicy.java
-    com/netscape/ca/CertificateAuthority.java
-    com/netscape/ca/CertificateAuthorityApplication.java
+# build pki-ca
+javac(pki-ca-classes
+    SOURCES
+        com/netscape/ca/*.java
+    CLASSPATH
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
+        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
+        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    DEPENDS
+        symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore
 )
 
+jar(pki-ca-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-ca-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/ca/*.class
+    DEPENDS
+        pki-ca-classes
+)
 
-# set classpath
-set(CMAKE_JAVA_INCLUDE_PATH
-    ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
-    ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-    ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-    ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR})
-
-
-# set version
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
-
+link(pki-ca
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-ca.jar
+    DEST
+        pki-ca-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-ca-jar
+)
 
-# build pki-ca.jar
-add_jar(pki-ca ${pki-ca_java_SRCS})
-add_dependencies(pki-ca symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore)
-install_jar(pki-ca ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_CA_JAR ${pki-ca_JAR_FILE} CACHE INTERNAL "pki-ca jar file")
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-ca.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-ca-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
 
+set(PKI_CA_JAR ${CMAKE_BINARY_DIR}/dist/pki-ca.jar CACHE INTERNAL "pki-ca jar file")
diff --git a/base/java-tools/src/CMakeLists.txt b/base/java-tools/src/CMakeLists.txt
index e6152dcf997e05736f11c85d27e71feb7169f303..8249a0086915936bec3f5c13ae0bac43cb5f8df2 100644
--- a/base/java-tools/src/CMakeLists.txt
+++ b/base/java-tools/src/CMakeLists.txt
@@ -31,59 +31,81 @@ find_file(XERCES_JAR
         /usr/share/java
 )
 
-set(pki-tools_java_SRCS
-    com/netscape/cmstools/PrettyPrintCrl.java
-    com/netscape/cmstools/BtoA.java
-    com/netscape/cmstools/PasswordCache.java
-    com/netscape/cmstools/OCSPClient.java
-    com/netscape/cmstools/PKCS12Export.java
-    com/netscape/cmstools/TestCRLSigning.java
-    com/netscape/cmstools/CRMFPopClient.java
-    com/netscape/cmstools/AuditVerify.java
-    com/netscape/cmstools/PrettyPrintCert.java
-    com/netscape/cmstools/HttpClient.java
-    com/netscape/cmstools/GenExtKeyUsage.java
-    com/netscape/cmstools/CMCRevoke.java
-    com/netscape/cmstools/TokenInfo.java
-    com/netscape/cmstools/CMCEnroll.java
-    com/netscape/cmstools/ExtJoiner.java
-    com/netscape/cmstools/CMCRequest.java
-    com/netscape/cmstools/AtoB.java
-    com/netscape/cmstools/GenIssuerAltNameExt.java
-    com/netscape/cmstools/GenSubjectAltNameExt.java
-    com/netscape/cmstools/CMCResponse.java
-    com/netscape/cmstools/PKCS10Client.java
-    com/netscape/cmstools/DRMTool.java
-)
-
-set(CMAKE_JAVA_INCLUDE_PATH
-    ${PKI_NSUTIL_JAR} ${PKI_CMSUTIL_JAR}
-    ${XALAN_JAR} ${XERCES_JAR}
-    ${JSS_JAR} ${COMMONS_CODEC_JAR})
-
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
-
 # build pki-tools
-add_jar(pki-tools ${pki-tools_java_SRCS})
-add_dependencies(pki-tools pki-nsutil pki-cmsutil)
+javac(pki-tools-classes
+    SOURCES
+        com/netscape/cmstools/*.java
+    CLASSPATH
+        ${PKI_NSUTIL_JAR} ${PKI_CMSUTIL_JAR}
+        ${XALAN_JAR} ${XERCES_JAR}
+        ${JSS_JAR} ${COMMONS_CODEC_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    DEPENDS
+        pki-nsutil pki-cmsutil
+)
+
+jar(pki-tools-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-tools-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/cmstools/*.class
+    DEPENDS
+        pki-tools-classes
+)
+
+link(pki-tools
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-tools.jar
+    DEST
+        pki-tools-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-tools-jar
+)
+
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-tools.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-tools-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
+
 install(
     FILES
         com/netscape/cmstools/DRMTool.cfg
     DESTINATION
-        ${SHARE_INSTALL_PREFIX}/pki/java-tools/
+        ${SHARE_INSTALL_PREFIX}/pki/java-tools
 )
-install_jar(pki-tools ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_TOOLS_JAR ${pki-tools_JAR_FILE} CACHE INTERNAL "pki-tools jar file")
+
+set(PKI_TOOLS_JAR ${CMAKE_BINARY_DIR}/dist/pki-tools.jar CACHE INTERNAL "pki-tools jar file")
 
 if(WITH_JAVADOC)
-    create_javadoc(pki-java-tools-${APPLICATION_VERSION}
-        FILES ${pki-tools_java_SRCS}
-        CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-        WINDOWTITLE "pki-java-tools"
-        DOCTITLE "<h1>pki-java-tools</h1>"
-        AUTHOR TRUE
-        USE TRUE
-        VERSION TRUE
+    javadoc(pki-tools-javadoc
+        DEST
+            ${CMAKE_CURRENT_BINARY_DIR}/javadoc/pki-java-tools-${APPLICATION_VERSION}
+        SUBPACKAGES
+            com.netscape.cmstools
+        CLASSPATH
+            ${PKI_NSUTIL_JAR} ${PKI_CMSUTIL_JAR}
+            ${XALAN_JAR} ${XERCES_JAR}
+            ${JSS_JAR} ${COMMONS_CODEC_JAR}
+        OPTIONS
+            -windowtitle 'pki-java-tools'
+            -doctitle '<h1>pki-java-tools</h1>'
+            -author
+            -use
+            -version
+        DEPENDS
+            pki-tools
+    )
+
+    install(
+        FILES
+            ${CMAKE_CURRENT_BINARY_DIR}/javadoc/pki-java-tools-${APPLICATION_VERSION}
+        DESTINATION
+            ${CMAKE_INSTALL_PREFIX}/share/javadoc
     )
-    add_dependencies(pki-java-tools-${APPLICATION_VERSION}_javadoc pki-tools)
 endif(WITH_JAVADOC)
diff --git a/base/kra/src/CMakeLists.txt b/base/kra/src/CMakeLists.txt
index 71056ffa64ad963b62e4655079f407e586800a58..5f5e3f01662cf3939e2901cd750fa358ed220d51 100644
--- a/base/kra/src/CMakeLists.txt
+++ b/base/kra/src/CMakeLists.txt
@@ -76,41 +76,47 @@ find_file(SYMKEY_JAR
 )
 
 
-# identify java sources
-set(pki-kra_java_SRCS
-    com/netscape/kra/KeyRecoveryAuthority.java
-    com/netscape/kra/KeyRecoveryAuthorityApplication.java
-    com/netscape/kra/EnrollmentService.java
-    com/netscape/kra/RecoveryService.java
-    com/netscape/kra/SecurityDataRecoveryService.java
-    com/netscape/kra/TokenKeyRecoveryService.java
-    com/netscape/kra/EncryptionUnit.java
-    com/netscape/kra/KRAService.java
-    com/netscape/kra/NetkeyKeygenService.java
-    com/netscape/kra/SecurityDataService.java
-    com/netscape/kra/KRANotify.java
-    com/netscape/kra/KRAPolicy.java
-    com/netscape/kra/TransportKeyUnit.java
-    com/netscape/kra/StorageKeyUnit.java
-    com/netscape/kra/ArchiveOptions.java
+# build pki-kra
+javac(pki-kra-classes
+    SOURCES
+        com/netscape/kra/*.java
+    CLASSPATH
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
+        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
+        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    DEPENDS
+        symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore
 )
 
+jar(pki-kra-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-kra-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/kra/*.class
+    DEPENDS
+        pki-kra-classes
+)
 
-# set classpath
-set(CMAKE_JAVA_INCLUDE_PATH
-    ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
-    ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-    ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-    ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR})
-
-
-# set version
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
-
+link(pki-kra
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-kra.jar
+    DEST
+        pki-kra-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-kra-jar
+)
 
-# build pki-kra.jar
-add_jar(pki-kra ${pki-kra_java_SRCS})
-add_dependencies(pki-kra symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore)
-install_jar(pki-kra ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_KRA_JAR ${pki-kra_JAR_FILE} CACHE INTERNAL "pki-kra jar file")
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-kra.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-kra-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
 
+set(PKI_KRA_JAR ${CMAKE_BINARY_DIR}/dist/pki-kra.jar CACHE INTERNAL "pki-kra jar file")
diff --git a/base/ocsp/src/CMakeLists.txt b/base/ocsp/src/CMakeLists.txt
index 932b4d23446d93f51752cb73206039e1cf6884ab..34b1ec4c26155eb237661d31dc0083f1b4bd3d38 100644
--- a/base/ocsp/src/CMakeLists.txt
+++ b/base/ocsp/src/CMakeLists.txt
@@ -76,31 +76,47 @@ find_file(SYMKEY_JAR
 )
 
 
-# identify java sources
-set(pki-ocsp_java_SRCS
-    com/netscape/ocsp/OCSPResources.java
-    com/netscape/ocsp/OCSPAuthority.java
-    com/netscape/ocsp/OCSPApplication.java
-    com/netscape/ocsp/SigningUnit.java
-    com/netscape/ocsp/EOCSPException.java
+# build pki-ocsp
+javac(pki-ocsp-classes
+    SOURCES
+        com/netscape/ocsp/*.java
+    CLASSPATH
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
+        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
+        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    DEPENDS
+        symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore
 )
 
+jar(pki-ocsp-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-ocsp-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/ocsp/*.class
+    DEPENDS
+        pki-ocsp-classes
+)
 
-# set classpath
-set(CMAKE_JAVA_INCLUDE_PATH
-    ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
-    ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-    ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-    ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR})
-
-
-# set version
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
-
+link(pki-ocsp
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-ocsp.jar
+    DEST
+        pki-ocsp-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-ocsp-jar
+)
 
-# build pki-ocsp.jar
-add_jar(pki-ocsp ${pki-ocsp_java_SRCS})
-add_dependencies(pki-ocsp symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore)
-install_jar(pki-ocsp ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_OCSP_JAR ${pki-ocsp_JAR_FILE} CACHE INTERNAL "pki-ocsp jar file")
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-ocsp.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-ocsp-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
 
+set(PKI_OCSP_JAR ${CMAKE_BINARY_DIR}/dist/pki-ocsp.jar CACHE INTERNAL "pki-ocsp jar file")
diff --git a/base/silent/src/CMakeLists.txt b/base/silent/src/CMakeLists.txt
index a3e6034f87f92804d8b1480fe47312416ab5ef3c..0240439ce1fdf2bc0ea2c540cecbf6ef203f923d 100644
--- a/base/silent/src/CMakeLists.txt
+++ b/base/silent/src/CMakeLists.txt
@@ -24,59 +24,50 @@ find_file(XERCES_JAR
         /usr/share/java
 )
 
-set(pki-silent_java_SRCS
-     com/netscape/pkisilent/ConfigureTKS.java
-     com/netscape/pkisilent/ConfigureCA.java
-     com/netscape/pkisilent/argparser/CharHolder.java
-     com/netscape/pkisilent/argparser/ArgParseException.java
-     com/netscape/pkisilent/argparser/StringHolder.java
-     com/netscape/pkisilent/argparser/SimpleExample.java
-     com/netscape/pkisilent/argparser/ArgParser.java
-     com/netscape/pkisilent/argparser/DoubleHolder.java
-     com/netscape/pkisilent/argparser/ObjectHolder.java
-     com/netscape/pkisilent/argparser/FloatHolder.java
-     com/netscape/pkisilent/argparser/BooleanHolder.java
-     com/netscape/pkisilent/argparser/StringScanException.java
-     com/netscape/pkisilent/argparser/StringScanner.java
-     com/netscape/pkisilent/argparser/LongHolder.java
-     com/netscape/pkisilent/argparser/IntHolder.java
-     com/netscape/pkisilent/ConfigureTPS.java
-     com/netscape/pkisilent/http/HTTPClient.java
-     com/netscape/pkisilent/http/HTMLDocument.java
-     com/netscape/pkisilent/http/HTTPResponse.java
-     com/netscape/pkisilent/http/CertSelection.java
-     com/netscape/pkisilent/common/Request.java
-     com/netscape/pkisilent/common/CertificateRecord.java
-     com/netscape/pkisilent/common/Utilities.java
-     com/netscape/pkisilent/common/ComCrypto.java
-     com/netscape/pkisilent/common/BaseState.java
-     com/netscape/pkisilent/common/CMSLDAP.java
-     com/netscape/pkisilent/common/CMSConfig.java
-     com/netscape/pkisilent/common/PostQuery.java
-     com/netscape/pkisilent/common/ServerInfo.java
-     com/netscape/pkisilent/common/UserEnroll.java
-     com/netscape/pkisilent/common/ParseXML.java
-     com/netscape/pkisilent/common/CMSProperties.java
-     com/netscape/pkisilent/common/DirEnroll.java
-     com/netscape/pkisilent/common/Con2Agent.java
-     com/netscape/pkisilent/common/TestClient.java
-     com/netscape/pkisilent/common/CMSTask.java
-     com/netscape/pkisilent/ConfigureOCSP.java
-     com/netscape/pkisilent/ConfigureRA.java
-     com/netscape/pkisilent/ConfigureSubCA.java
-     com/netscape/pkisilent/ConfigureDRM.java
-     com/netscape/pkisilent/PKISilent.java
+# build pki-silent
+javac(pki-silent-classes
+    SOURCES
+        com/netscape/pkisilent/*.java
+    CLASSPATH
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR}
+        ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
+        ${LDAPJDK_JAR} ${XERCES_JAR}
+        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    DEPENDS
+        symkey pki-cmsutil pki-nsutil pki-certsrv pki-cms
 )
 
-set(CMAKE_JAVA_INCLUDE_PATH
-    ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR}
-    ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-    ${LDAPJDK_JAR} ${XERCES_JAR}
-    ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR})
+jar(pki-silent-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-silent-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/pkisilent/*.class
+    EXCLUDE
+        com/netscape/pkisilent/argparser/ArgParserTest*.class
+        com/netscape/pkisilent/common/checkRequest.class
+    DEPENDS
+        pki-silent-classes
+)
+
+link(pki-silent
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-silent.jar
+    DEST
+        pki-silent-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-silent-jar
+)
 
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-silent.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-silent-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
 
-add_jar(pki-silent ${pki-silent_java_SRCS})
-add_dependencies(pki-silent symkey pki-cmsutil pki-nsutil pki-certsrv pki-cms)
-install_jar(pki-silent ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_SILENT_JAR ${pki-silent_JAR_FILE} CACHE INTERNAL "pki-silent jar file")
+set(PKI_SILENT_JAR ${CMAKE_BINARY_DIR}/dist/pki-silent.jar CACHE INTERNAL "pki-silent jar file")
diff --git a/base/symkey/src/CMakeLists.txt b/base/symkey/src/CMakeLists.txt
index 599a7cb5a60ac3819bbb5f466c724197e6dfd78b..b4d19060266d9c054848241e19218b4681543da8 100644
--- a/base/symkey/src/CMakeLists.txt
+++ b/base/symkey/src/CMakeLists.txt
@@ -8,17 +8,49 @@ find_file(JSS_JAR
     /usr/share/java
 )
 
-set(symkey_java_SRCS
-    com/netscape/symkey/SessionKey.java
+# build symkey
+javac(symkey-classes
+    SOURCES
+        com/netscape/symkey/*.java
+    CLASSPATH
+        ${JSS_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
 )
 
-set(CMAKE_JNI_TARGET TRUE)
-set(CMAKE_JAVA_INCLUDE_PATH ${JSS_JAR})
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
+jar(symkey-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/symkey-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/symkey/*.class
+    DEPENDS
+        symkey-classes
+)
+
+link(symkey
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/symkey.jar
+    DEST
+        symkey-${APPLICATION_VERSION}.jar
+    DEPENDS
+        symkey-jar
+)
 
-add_jar(symkey ${symkey_java_SRCS})
-install_jar(symkey ${LIB_INSTALL_DIR}/symkey)
-install_jni_symlink(symkey ${JAVA_LIB_INSTALL_DIR})
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/symkey.jar
+        ${CMAKE_BINARY_DIR}/dist/symkey-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${LIB_INSTALL_DIR}/symkey
+)
+
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/symkey.jar
+    DESTINATION
+        ${JAVA_LIB_INSTALL_DIR}
+)
 
-set(SYMKEY_JAVA_OBJECT_DIR ${symkey_CLASS_DIR} PARENT_SCOPE)
-set(SYMKEY_JAR ${symkey_JAR_FILE} CACHE INTERNAL "symkey jar file")
+set(SYMKEY_JAR ${CMAKE_BINARY_DIR}/dist/symkey.jar CACHE INTERNAL "symkey jar file")
diff --git a/base/symkey/src/com/netscape/symkey/CMakeLists.txt b/base/symkey/src/com/netscape/symkey/CMakeLists.txt
index 47d40a3f1dbb9380368a7c762b20a02d6e661540..683d86dd104acc6a365e18406ca5b4384855ad93 100644
--- a/base/symkey/src/com/netscape/symkey/CMakeLists.txt
+++ b/base/symkey/src/com/netscape/symkey/CMakeLists.txt
@@ -41,7 +41,7 @@ add_custom_command(
         ${symkey_library_HDRS}
     COMMAND
         ${JAVA_HEADER}
-            -classpath ${SYMKEY_JAVA_OBJECT_DIR}:${JAVA_LIB_INSTALL_DIR}/jss4.jar
+            -classpath ${CMAKE_BINARY_DIR}/classes:${JAVA_LIB_INSTALL_DIR}/jss4.jar
             -jni -d ${CMAKE_CURRENT_BINARY_DIR}
             com.netscape.symkey.SessionKey
 )
diff --git a/base/tks/src/CMakeLists.txt b/base/tks/src/CMakeLists.txt
index dfd3d566865f7788f376bc47106a0acab5ddd907..10660f51111ab0c2e0daa8e734b23873ae4deb57 100644
--- a/base/tks/src/CMakeLists.txt
+++ b/base/tks/src/CMakeLists.txt
@@ -77,28 +77,47 @@ find_file(SYMKEY_JAR
 )
 
 
-# identify java sources
-set(pki-tks_java_SRCS
-    com/netscape/tks/TKSAuthority.java
-    com/netscape/tks/TKSApplication.java
+# build pki-tks
+javac(pki-tks-classes
+    SOURCES
+        com/netscape/tks/*.java
+    CLASSPATH
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
+        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
+        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+    OUTPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    DEPENDS
+        symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore
 )
 
+jar(pki-tks-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-tks-${APPLICATION_VERSION}.jar
+    INPUT_DIR
+        ${CMAKE_BINARY_DIR}/classes
+    FILES
+        com/netscape/tks/*.class
+    DEPENDS
+        pki-tks-classes
+)
 
-# set classpath
-set(CMAKE_JAVA_INCLUDE_PATH
-    ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
-    ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-    ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-    ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR})
-
-
-# set version
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
-
+link(pki-tks
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-tks.jar
+    DEST
+        pki-tks-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-tks-jar
+)
 
-# build pki-tks.jar
-add_jar(pki-tks ${pki-tks_java_SRCS})
-add_dependencies(pki-tks symkey pki-nsutil pki-cmsutil pki-certsrv pki-cms pki-cmscore)
-install_jar(pki-tks ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_TKS_JAR ${pki-tks_JAR_FILE} CACHE INTERNAL "pki-tks jar file")
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-tks.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-tks-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
 
+set(PKI_TKS_JAR ${CMAKE_BINARY_DIR}/dist/pki-tks.jar CACHE INTERNAL "pki-tks jar file")
diff --git a/dogtag/console-ui/src/CMakeLists.txt b/dogtag/console-ui/src/CMakeLists.txt
index bc8995a12212a84a5ed787b18e9347ef7234e184..c6c4fcb3bdc9391d633d4032470de07962b9d9f5 100644
--- a/dogtag/console-ui/src/CMakeLists.txt
+++ b/dogtag/console-ui/src/CMakeLists.txt
@@ -1,18 +1,35 @@
 set(pki-console-theme_java Java)
 
-set(pki-console-theme_java_RCS
-    CMSAdminRS.properties
-    com/netscape/management/client/theme/theme.properties
-    com/netscape/management/client/theme/images/login.gif
-    com/netscape/management/client/theme/images/ConsoleBanner.gif
-    com/netscape/management/client/theme/images/logo16.gif
-    com/netscape/management/client/theme/images/logo32.gif
-    com/netscape/admin/certsrv/theme/certmgmt.gif
+jar(pki-console-theme-jar
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/pki-console-theme-${APPLICATION_VERSION}.jar
+    FILES
+        CMSAdminRS.properties
+        com/netscape/management/client/theme/theme.properties
+        com/netscape/management/client/theme/images/login.gif
+        com/netscape/management/client/theme/images/ConsoleBanner.gif
+        com/netscape/management/client/theme/images/logo16.gif
+        com/netscape/management/client/theme/images/logo32.gif
+        com/netscape/admin/certsrv/theme/certmgmt.gif
 )
 
-set(CMAKE_JAVA_TARGET_VERSION ${APPLICATION_VERSION})
+link(pki-console-theme
+    SOURCE
+        ${CMAKE_BINARY_DIR}/dist/pki-console-theme.jar
+    DEST
+        pki-console-theme-${APPLICATION_VERSION}.jar
+    DEPENDS
+        pki-console-theme-jar
+)
 
-add_jar(pki-console-theme ${pki-console-theme_java_RCS})
-install_jar(pki-console-theme ${JAVA_JAR_INSTALL_DIR}/pki)
-set(PKI_CONSOLE_THEME_JAR ${pki-console-theme_JAR_FILE} CACHE INTERNAL "pki-console-theme jar file")
+install(
+    FILES
+        ${CMAKE_BINARY_DIR}/dist/pki-console-theme.jar
+        ${CMAKE_BINARY_DIR}/dist/pki-console-theme-${APPLICATION_VERSION}.jar
+    DESTINATION
+        ${JAVA_JAR_INSTALL_DIR}/pki
+)
 
+set(PKI_CONSOLE_THEME_JAR ${CMAKE_BINARY_DIR}/dist/pki-console-theme.jar
+    CACHE INTERNAL "pki-console-theme jar file"
+)
-- 
1.7.11.2

