[mapguide-commits] r9273 - in sandbox/jng/cmake_v2: . BuildTools/WebTools/IMake Desktop/UnitTest Oem/SWIGEx Web/src Web/src/JavaApi Web/src/JavaApiEx

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Jan 4 07:49:46 PST 2018


Author: jng
Date: 2018-01-04 07:49:46 -0800 (Thu, 04 Jan 2018)
New Revision: 9273

Added:
   sandbox/jng/cmake_v2/Web/src/JavaApi/CMakeLists.txt
   sandbox/jng/cmake_v2/Web/src/JavaApiEx/CMakeLists.txt
Modified:
   sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/CMakeLists.txt
   sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/IMake.cpp
   sandbox/jng/cmake_v2/CMakeLists.txt
   sandbox/jng/cmake_v2/Desktop/UnitTest/CMakeLists.txt
   sandbox/jng/cmake_v2/Oem/SWIGEx/CMakeLists.txt
   sandbox/jng/cmake_v2/Web/src/CMakeLists.txt
Log:
Update IMake to support custom output directories and ability to resolve relative header paths in a parameter file to a custom directory. This is mainly to allow maintaining the (pristine source tree) quality of a CMake build, by being able to instruct IMake to generate its files in the build tree while still being able to resolve headers relative to the source tree. This change requires IMake adopting an actual command-line parser as space-delimited arguments no longer cut it. IMake now carries a dependency on ACE as we are using its cmdline parser facility. With this change, we can finally start adding Java support to build the Java API wrapper(s), which is walled-off behind a WITH_JAVA configuration flag.

Modified: sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/CMakeLists.txt	2018-01-04 09:43:37 UTC (rev 9272)
+++ sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -1,3 +1,6 @@
+project(imake)
+include_directories(${ACE_INCLUDE_DIR})
+
 set(IMake_SRCS
     IMake.cpp
     SimpleXmlParser.cpp
@@ -4,4 +7,5 @@
     stdafx.cpp
 )
 
-add_executable(IMake ${IMake_SRCS})
\ No newline at end of file
+add_executable(IMake ${IMake_SRCS})
+target_link_libraries(IMake ${ACE_LIBRARY})
\ No newline at end of file

Modified: sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/IMake.cpp
===================================================================
--- sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/IMake.cpp	2018-01-04 09:43:37 UTC (rev 9272)
+++ sandbox/jng/cmake_v2/BuildTools/WebTools/IMake/IMake.cpp	2018-01-04 15:49:46 UTC (rev 9273)
@@ -3,6 +3,9 @@
 
 #include "stdafx.h"
 #include "SimpleXmlParser.h"
+#include <ace/Arg_Shifter.h>
+#include <ace/Get_Opt.h>
+#include <ace/Log_Msg.h>
 
 enum Language
 {
@@ -12,7 +15,7 @@
     java
 };
 
-static char version[] = "1.2.4";
+static char version[] = "1.3.0";
 static char EXTERNAL_API_DOCUMENTATION[] = "(NOTE: This API is not officially supported and may be subject to removal in a future release without warning. Use with caution.)";
 
 static string module;
@@ -34,6 +37,7 @@
 static char charbuf[2];
 static bool translateMode;
 static Language language;
+static bool verbose;
 
 #ifdef _WIN32
 #define FILESEP '\\'
@@ -43,13 +47,13 @@
 
 void error(string msg)
 {
-    fprintf(stderr, "\nError: %s", msg.c_str());
+    fprintf(stderr, "Error: %s\n", msg.c_str());
     exit(1);
 }
 
 void warning(string msg)
 {
-    fprintf(stderr, "\nWarning: %s", msg.c_str());
+    fprintf(stderr, "Warning: %s\n", msg.c_str());
 }
 
 string parseModule(XNode* elt)
@@ -185,8 +189,20 @@
     return text;
 }
 
-void parseParameterFile(char* xmlDef)
+void findAndReplaceInString(string& subject, 
+                            const string& search,
+                            const string& replace)
 {
+    size_t pos = 0;
+    while((pos = subject.find(search, pos)) != string::npos)
+    {
+         subject.replace(pos, search.length(), replace);
+         pos += replace.length();
+    }
+}
+
+void parseParameterFile(char* xmlDef, const string& relRoot)
+{
     XNode xml;
     if(xml.Load(xmlDef) == NULL)
         error("XML parsing error");
@@ -232,6 +248,18 @@
         else if(node->name == "SwigInline" || (node->name == "Inline" && translateMode))
         {
             swigInline = parseSwigInline(node);
+
+            if (!relRoot.empty())
+            {
+                //Rewrite any relative %include statements in the inline section so they're relative to the
+                //custom root
+                string replace = "%include \"";
+                replace += relRoot;
+                replace += "/../";
+                findAndReplaceInString(swigInline, 
+                                       "%include \"../",
+                                       replace);
+            }
         }
         else if(node->name == "Typedefs")
         {
@@ -1478,16 +1506,27 @@
     }
 }
 
-void processHeaderFile(string header)
+void processHeaderFile(string header, const string& relRoot)
 {
     vector<string> tokens;
 
-    tokenize(header, tokens);
+    string theHeader;
+    if (relRoot.empty())
+    {
+        theHeader = header;
+    }
+    else
+    {
+        theHeader = relRoot;
+        theHeader += "/";
+        theHeader += header;
+    }
+    tokenize(theHeader, tokens);
 
     if(!translateMode)
     {
         //short banner about this file
-        fprintf(outfile, "\n// Definitions from file %s\n//\n", header.c_str());
+        fprintf(outfile, "\n// Definitions from file %s\n//\n", theHeader.c_str());
     }
 
     //ignore every token outside of a class definition
@@ -1522,7 +1561,10 @@
 
         //in translation mode, filters out clases which don't belong to the class list
         bool ignore = translateMode && classes.find(className) == classes.end();
-        //printf("Processing header: %s\n", className.c_str());
+        if (verbose)
+        {
+            printf("Processing header: %s\n", className.c_str());
+        }
         if(!ignore)
         {
             if(translateMode)
@@ -1647,7 +1689,7 @@
     }
 }
 
-void createSWGInterfaceFile()
+void createSWGInterfaceFile(const string& outDir, const string& relRoot)
 {
     printf("\n\nGenerating interface file %s...\n", target.c_str());
 
@@ -1665,10 +1707,22 @@
 
     if(!translateMode || language != java)
     {
-        outfile = fopen(target.c_str(), "w");
+        string swigTarget = target;
+        string swigDocTarget = docTarget;
+        if (!outDir.empty())
+        {
+            swigTarget = outDir;
+            swigTarget += "/";
+            swigTarget += target;
+            
+            swigDocTarget = outDir;
+            swigDocTarget += "/";
+            swigDocTarget += docTarget;
+        }
+        outfile = fopen(swigTarget.c_str(), "w");
         if(outfile == NULL)
             error(string("Cannot create target file ") + target);
-        docOutFile = fopen(docTarget.c_str(), "w");
+        docOutFile = fopen(swigDocTarget.c_str(), "w");
         if(docOutFile == NULL)
             error(string("Cannot create doctarget file ") + docTarget);
     }
@@ -1707,7 +1761,7 @@
 
     //process the headers
     for(vector<string>::const_iterator it = headers.begin(); it != headers.end(); it++)
-        processHeaderFile(*it);
+        processHeaderFile(*it, relRoot);
 
     if(!translateMode || language != java)
     {
@@ -1718,7 +1772,7 @@
     }
 }
 
-void createNativeFile()
+void createNativeFile(const string& outDir, const string& relRoot)
 {
     if(target.length() == 0)
         error("Target section is missing");
@@ -1760,7 +1814,7 @@
 
     //process the headers
     for(vector<string>::const_iterator it = headers.begin(); it != headers.end(); it++)
-        processHeaderFile(*it);
+        processHeaderFile(*it, relRoot);
 
     if(language == php)
         fprintf(outfile, "?>");
@@ -1779,7 +1833,7 @@
         fclose(docOutFile);
 }
 
-void createInterfaceFile(char* paramFile)
+void createInterfaceFile(const char* paramFile, const string& outDir, const string& relRoot)
 {
     FILE* file = fopen(paramFile, "r");
     if(file == NULL)
@@ -1796,32 +1850,180 @@
     char* end = strchr(data, 255);
     *end = '\0';
 
-    parseParameterFile(data);
+    parseParameterFile(data, relRoot);
 
     if(!translateMode)
-        createSWGInterfaceFile();
+        createSWGInterfaceFile(outDir, relRoot);
     else
-        createNativeFile();
+        createNativeFile(outDir, relRoot);
 
 }
 
 void usage()
 {
     printf("\nUsage:");
-    printf("\nIMake parameterFile lang [generation_path_or_folder]");
+    printf("\nIMake -p parameterFile -l lang [-o generation_path_or_folder] [-r header_resolution_root]");
     printf("\n      parameterFile: XML description of generation parameters\n");
-    printf("\n      lang: Target language (PHP, C# or Java).\n");
+    printf("\n      lang: Target language (PHP, C# or Java). Case-sensitive\n");
     printf("\n      generation_path_or_folder: Do not generate SWIG.  Generate constant definitions.");
     printf("\n                                 For PHP and C#, pathname of the constant file.");
     printf("\n                                 For Java, folder where the constant files are created");
+    printf("\n      header_resolution_root: If specified, headers in the parameter file will be resolved relative to the specified path");
+    printf("\n");
     exit(1);
 }
 
 int main(int argc, char* argv[])
 {
     printf("\nIMake - SWIG Interface generator");
-    printf("\nVersion %s", version);
+    printf("\nVersion %s\n\n", version);
 
+    static const ACE_TCHAR options[] = ACE_TEXT ("p:l:o:r:t");  
+    ACE_Get_Opt cmd_opts (argc, argv, options);
+
+    string pFile;
+    string relRoot;
+    string outDir;
+    translateMode = false;
+    verbose = false;
+    language = unknown;
+
+    int option;
+    while ((option = cmd_opts ()) != EOF)
+    {
+        const ACE_TCHAR* arg = cmd_opts.opt_arg();
+        const char* sArg = ACE_TEXT_ALWAYS_CHAR(arg);
+        if (verbose)
+            printf("Found option: %c\n", (char)option);
+        switch (option) 
+        {
+            case 't':
+                {
+                    translateMode = true;
+                }
+                break;
+            case 'p':
+                {
+                    pFile = sArg;
+                }
+                break;
+            case 'l':
+                {
+                    if(!strcmp(sArg, "PHP"))
+                    {
+                        language = php;
+                    }
+                    else if(!strcmp(sArg, "C#"))
+                    {
+                        language = csharp;
+                        rootObjectMethods["Equals"] = 1;
+                        rootObjectMethods["GetHashCode"] = 1;
+                        rootObjectMethods["GetType"] = 1;
+                        rootObjectMethods["ReferenceEquals"] = 1;
+                        rootObjectMethods["ToString"] = 1;
+                    }
+                    else if(!strcmp(sArg, "Java"))
+                    {
+                        language = java;
+                    }
+                }
+                break;
+            case 'o':
+                {
+                    outDir = sArg;
+                }
+                break;
+            case 'r':
+                {
+                    relRoot = sArg;
+                }
+                break;
+        }
+    }
+
+    //Basic validation
+    if (language == unknown)
+    {
+        printf("ERROR: Invalid language or no language specified\n");
+        usage();
+    }
+    else
+    {
+        switch (language)
+        {
+            case csharp:
+                printf("INFO: Language mode: C#\n");
+                break;
+            case php:
+                printf("INFO: Language mode: PHP\n");
+                break;
+            case java:
+                printf("INFO: Language mode: Java\n");
+                break;
+        }
+    }
+
+    if (verbose)
+    {
+        printf("INFO: Verbose mode is ON\n");
+    }
+    else
+    {
+        printf("INFO: Verbose mode is OFF\n");
+    }
+
+    if (pFile.empty())
+    {
+        printf("ERROR: No parameter file specified\n");
+        usage();
+    }
+    else
+    {
+        printf("INFO: Parameter file: %s\n", pFile.c_str());
+    }
+
+    if (translateMode)
+    {
+        printf("INFO: Translate (generate constants) mode is ON\n");
+    }
+    else
+    {
+        printf("INFO: Translate (generate constants) mode is OFF. IMake will be generating the SWIG input file\n");
+    }
+
+    if (!outDir.empty())
+    {
+        printf("INFO: Auto-generated files will be output to: %s\n", outDir.c_str());
+    }
+    else
+    {
+        printf("INFO: Auto-generated files will be output to this directory\n");
+    }
+
+    if (!relRoot.empty())
+    {
+        printf("INFO: Headers will be resolved relative to: %s\n", relRoot.c_str());
+    }
+    else
+    {
+        printf("INFO: Headers will be resolved relative to this directory\n");
+    }
+
+    if (translateMode)
+    {
+        if (!outDir.empty())
+            target = outDir;
+        else
+            target = ".";
+        if (verbose)
+            printf("INFO: Target is set to: %s\n", target.c_str());
+    }
+
+    createInterfaceFile(pFile.c_str(), outDir, relRoot);
+
+    return 0;
+
+    /*
     if(argc < 3)
         usage();
 
@@ -1856,4 +2058,5 @@
     createInterfaceFile(argv[1]);
 
     return 0;
+    */
 }

Modified: sandbox/jng/cmake_v2/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/CMakeLists.txt	2018-01-04 09:43:37 UTC (rev 9272)
+++ sandbox/jng/cmake_v2/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -80,6 +80,21 @@
 find_package(FDO REQUIRED)
 find_package(CppUnit REQUIRED)
 
+# Set internal tool paths
+set(IMAKE_TOOL ${CMAKE_CURRENT_BINARY_DIR}/BuildTools/WebTools/IMake/IMake)
+set(SWIG_TOOL ${CMAKE_CURRENT_BINARY_DIR}/Oem/SWIGEx/swig)
+set(SWIG_LIB_PATH ${CMAKE_CURRENT_BINARY_DIR}/Oem/SWIGEx/Lib)
+
+# Set common commands.
+set(MOVE_COMMAND "mv")
+
+if (WITH_JAVA)
+    find_package(Java REQUIRED)
+    find_package(JNI REQUIRED)
+else (WITH_JAVA)
+    message(STATUS "Skipping optional Java support")
+endif (WITH_JAVA)
+
 add_subdirectory(BuildTools)
 add_subdirectory(Oem)
 add_subdirectory(Common)

Modified: sandbox/jng/cmake_v2/Desktop/UnitTest/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/Desktop/UnitTest/CMakeLists.txt	2018-01-04 09:43:37 UTC (rev 9272)
+++ sandbox/jng/cmake_v2/Desktop/UnitTest/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -15,7 +15,7 @@
     ${MG_COMMON_DIR}/Stylization
 )
 
-set (UnitTest_SRCS
+set (MgDesktopUnitTest_SRCS
     main.cpp
     TestFeatureService.cpp
     #TestKmlService.cpp
@@ -29,9 +29,11 @@
     TestTileService.cpp
 )
 
-add_executable(UnitTest ${UnitTest_SRCS})
+add_executable(MgDesktopUnitTest ${MgDesktopUnitTest_SRCS})
+set_target_properties( MgDesktopUnitTest
+    PROPERTIES OUTPUT_NAME "UnitTest" )
 
-target_link_libraries(UnitTest
+target_link_libraries(MgDesktopUnitTest
     ${ACE_LIBRARY}
     ${FDO_LIBRARY}
     ${XERCESC_LIBRARIES}

Modified: sandbox/jng/cmake_v2/Oem/SWIGEx/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/Oem/SWIGEx/CMakeLists.txt	2018-01-04 09:43:37 UTC (rev 9272)
+++ sandbox/jng/cmake_v2/Oem/SWIGEx/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -67,4 +67,5 @@
     Source/Preprocessor/expr.c
 )
 
-add_executable(swig ${Swig_SRCS})
\ No newline at end of file
+add_executable(swig ${Swig_SRCS})
+file(COPY "Lib" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file

Modified: sandbox/jng/cmake_v2/Web/src/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/Web/src/CMakeLists.txt	2018-01-04 09:43:37 UTC (rev 9272)
+++ sandbox/jng/cmake_v2/Web/src/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -3,6 +3,12 @@
 add_subdirectory(HttpHandler)
 #add_subdirectory(CgiAgent)
 #add_subdirectory(PhpApi)
-#add_subdirectory(JavaApi)
-#add_subdirectory(JavaApiEx)
-#add_subdirectory(ApacheAgent)
\ No newline at end of file
+if (WITH_JAVA)
+    add_subdirectory(JavaApi)
+    add_subdirectory(JavaApiEx)
+endif (WITH_JAVA)
+#add_subdirectory(ApacheAgent)
+
+# Needed for api binding generation
+file(COPY "MapGuideApi" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "WEB-INF" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file

Added: sandbox/jng/cmake_v2/Web/src/JavaApi/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/Web/src/JavaApi/CMakeLists.txt	                        (rev 0)
+++ sandbox/jng/cmake_v2/Web/src/JavaApi/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -0,0 +1,78 @@
+include_directories(${JNI_INCLUDE_DIRS}
+    ${MG_COMMON_DIR}/MdfModel
+    ${MG_COMMON_DIR}/Foundation
+    ${MG_COMMON_DIR}/Geometry
+    ${MG_COMMON_DIR}/PlatformBase
+    ${MG_COMMON_DIR}/MapGuideCommon
+    ${ACE_INCLUDE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../HttpHandler
+    ${CMAKE_CURRENT_SOURCE_DIR}/../WebSupport
+    ${CMAKE_CURRENT_SOURCE_DIR}/../WebApp
+    ${XERCESC_INCLUDE_DIR}
+)
+
+add_definitions(-DJAVA)
+add_definitions(-fno-strict-aliasing -fno-var-tracking-assignments)
+
+set(MapGuideJavaApi_SRCS
+    ${CMAKE_CURRENT_BINARY_DIR}/MgApi_wrap.cpp
+)
+
+add_custom_command(OUTPUT ${MapGuideJavaApi_SRCS}
+    COMMAND ${CMAKE_COMMAND} -E remove -f 
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.class
+    COMMAND ${IMAKE_TOOL} -p ../MapGuideApi/MapGuideApiGen.xml
+            -l Java
+            -r ${CMAKE_CURRENT_SOURCE_DIR}
+            -o ${CMAKE_CURRENT_BINARY_DIR}
+            -i ${CMAKE_CURRENT_BINARY_DIR}
+    COMMAND ${CMAKE_COMMAND} -E copy
+            ${CMAKE_CURRENT_BINARY_DIR}/java.i
+            ${CMAKE_CURRENT_BINARY_DIR}/language.i
+    COMMAND ${IMAKE_TOOL} -p ${CMAKE_CURRENT_BINARY_DIR}/../MapGuideApi/Constants.xml 
+            -l Java 
+            -r ${CMAKE_CURRENT_SOURCE_DIR}
+            -o ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide
+            -t
+    COMMAND ${SWIG_TOOL} -dllname MapGuideJavaApi -c++ -java -DJAVA 
+            -package org.osgeo.mapguide 
+            -root MgObject -baseexception MgException -clsidcode getclassid.code -clsiddata m_cls_id 
+            -catchallcode catchall.code 
+            -dispose \"((MgDisposable*)arg1)->Release()\" 
+            -rethrow \"e->Raise()\;\" 
+            -nodefault -noconstants -module MapGuideJavaApi 
+            -o ${MapGuideJavaApi_SRCS} 
+            -lib ${SWIG_LIB_PATH} 
+            ${CMAKE_CURRENT_BINARY_DIR}/MapGuideApi.i
+    COMMAND ${MOVE_COMMAND} 
+            ${CMAKE_CURRENT_BINARY_DIR}/*.java 
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide
+    COMMAND ${Java_JAVAC_EXECUTABLE} -classpath ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.java
+    COMMAND ${Java_JAR_EXECUTABLE} -cf 
+            ${CMAKE_CURRENT_BINARY_DIR}/../WEB-INF/lib/MapGuideApi.jar
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.class
+    COMMAND ${Java_JAR_EXECUTABLE} -cf 
+            ${CMAKE_CURRENT_BINARY_DIR}/../WEB-INF/lib/MapGuideApi-sources.jar
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.java
+)
+
+add_library(MapGuideJavaApi-${MG_VERSION} SHARED ${MapGuideJavaApi_SRCS})
+
+target_link_libraries(MapGuideJavaApi-${MG_VERSION}
+    ${ACE_LIBRARY}
+    ${JNI_LIBRARIES}
+    MgFoundation-${MG_VERSION}
+    MgGeometry-${MG_VERSION}
+    MgPlatformBase-${MG_VERSION}
+    MgMapGuideCommon-${MG_VERSION}
+    MgHttpHandler-${MG_VERSION}
+    MgMdfModel-${MG_VERSION}
+    MgMdfParser-${MG_VERSION}
+    ${XERCESC_LIBRARIES}
+    MgWebApp-${MG_VERSION}
+)
+
+file(COPY "java.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "getclassid.code" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "catchall.code" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "org" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file

Added: sandbox/jng/cmake_v2/Web/src/JavaApiEx/CMakeLists.txt
===================================================================
--- sandbox/jng/cmake_v2/Web/src/JavaApiEx/CMakeLists.txt	                        (rev 0)
+++ sandbox/jng/cmake_v2/Web/src/JavaApiEx/CMakeLists.txt	2018-01-04 15:49:46 UTC (rev 9273)
@@ -0,0 +1,81 @@
+include_directories(${JNI_INCLUDE_DIRS}
+    ${MG_COMMON_DIR}/MdfModel
+    ${MG_COMMON_DIR}/Foundation
+    ${MG_COMMON_DIR}/Geometry
+    ${MG_COMMON_DIR}/PlatformBase
+    ${MG_COMMON_DIR}/MapGuideCommon
+    ${ACE_INCLUDE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../HttpHandler
+    ${CMAKE_CURRENT_SOURCE_DIR}/../WebSupport
+    ${CMAKE_CURRENT_SOURCE_DIR}/../WebApp
+    ${XERCESC_INCLUDE_DIR}
+)
+
+add_definitions(-DJAVA)
+add_definitions(-fno-strict-aliasing -fno-var-tracking-assignments)
+
+set(MapGuideJavaApiEx_SRCS
+    ${CMAKE_CURRENT_BINARY_DIR}/MgApi_wrap.cpp
+)
+
+add_custom_command(OUTPUT ${MapGuideJavaApiEx_SRCS}
+    COMMAND ${CMAKE_COMMAND} -E remove -f 
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.class
+    COMMAND ${IMAKE_TOOL} -p ../MapGuideApi/MapGuideApiGen.xml
+            -l Java
+            -r ${CMAKE_CURRENT_SOURCE_DIR}
+            -o ${CMAKE_CURRENT_BINARY_DIR}
+            -i ${CMAKE_CURRENT_BINARY_DIR}
+    COMMAND ${CMAKE_COMMAND} -E copy
+            ${CMAKE_CURRENT_BINARY_DIR}/java.i
+            ${CMAKE_CURRENT_BINARY_DIR}/language.i
+    COMMAND ${IMAKE_TOOL} -p ${CMAKE_CURRENT_BINARY_DIR}/../MapGuideApi/Constants.xml 
+            -l Java 
+            -r ${CMAKE_CURRENT_SOURCE_DIR}
+            -o ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide
+            -t
+    COMMAND ${SWIG_TOOL} -dllname MapGuideJavaApiEx -c++ -java -DJAVA 
+            -mgjavanothrow -mgjavacasing
+            -package org.osgeo.mapguide 
+            -root MgObject -baseexception MgException -clsidcode getclassid.code -clsiddata m_cls_id 
+            -catchallcode catchall.code 
+            -dispose \"((MgDisposable*)arg1)->Release()\" 
+            -rethrow \"e->Raise()\;\" 
+            -nodefault -noconstants -module MapGuideJavaApiEx 
+            -o ${MapGuideJavaApiEx_SRCS} 
+            -lib ${SWIG_LIB_PATH} 
+            ${CMAKE_CURRENT_BINARY_DIR}/MapGuideApi.i
+    COMMAND ${MOVE_COMMAND} 
+            ${CMAKE_CURRENT_BINARY_DIR}/*.java 
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide
+    COMMAND ${Java_JAVAC_EXECUTABLE} -classpath ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.java
+    COMMAND ${Java_JAR_EXECUTABLE} -cf 
+            ${CMAKE_CURRENT_BINARY_DIR}/../WEB-INF/lib/MapGuideApiEx.jar
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.class
+    COMMAND ${Java_JAR_EXECUTABLE} -cf 
+            ${CMAKE_CURRENT_BINARY_DIR}/../WEB-INF/lib/MapGuideApiEx-sources.jar
+            ${CMAKE_CURRENT_BINARY_DIR}/org/osgeo/mapguide/*.java
+)
+
+add_library(MapGuideJavaApiEx-${MG_VERSION} SHARED ${MapGuideJavaApiEx_SRCS})
+
+target_link_libraries(MapGuideJavaApiEx-${MG_VERSION}
+    ${ACE_LIBRARY}
+    ${JNI_LIBRARIES}
+    MgFoundation-${MG_VERSION}
+    MgGeometry-${MG_VERSION}
+    MgPlatformBase-${MG_VERSION}
+    MgMapGuideCommon-${MG_VERSION}
+    MgHttpHandler-${MG_VERSION}
+    MgMdfModel-${MG_VERSION}
+    MgMdfParser-${MG_VERSION}
+    ${XERCESC_LIBRARIES}
+    MgWebApp-${MG_VERSION}
+)
+
+file(COPY "java.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "getclassid.code" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "catchall.code" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+file(COPY "org" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+# Specific for JavaApiEx
+file(COPY "javaextensions.i" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
\ No newline at end of file



More information about the mapguide-commits mailing list