Permalink
Browse files

Add C# CMAKE support, fix various issues, revert ZLIB detection

  • Loading branch information...
1 parent 7b52555 commit 7337f798a24b8ebeaa281a51068636816574dd16 @szekerest szekerest committed Mar 31, 2013
Showing with 76 additions and 15 deletions.
  1. +24 −12 CMakeLists.txt
  2. +32 −0 mapscript/csharp/CMakeLists.txt
  3. +2 −2 mapscript/csharp/csmodule.i
  4. +18 −1 mapscript/csharp/swig_csharp_extensions.i
View
@@ -118,6 +118,7 @@ option(WITH_PHP "Enable Python mapscript support" OFF)
option(WITH_PERL "Enable Perl mapscript support" OFF)
option(WITH_RUBY "Enable Ruby mapscript support" OFF)
option(WITH_JAVA "Enable Java mapscript support" OFF)
+option(WITH_CSHARP "Enable C# mapscript support" OFF)
option(WITH_POINT_Z_M "include Z and M coordinates in point structure (advanced, not recommended)" OFF)
option(WITH_ORACLESPATIAL "include oracle spatial database input support" OFF)
if(WIN32)
@@ -156,6 +157,18 @@ renderers/agg/src/clipper.cpp
)
include_directories(renderers/agg/include)
+if(WIN32)
+ set(REGEX_SOURCES ${REGEX_DIR}/regex.c)
+ include_directories(${REGEX_DIR})
+ add_definitions(-DREGEX_MALLOC -DUSE_GENERIC_MS_NINT -DHAVE_STRING_H)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
+ set(REGEX_MALLOC 1)
+ set(USE_GENERIC_MS_NINT 1)
+ set(HAVE_STRING_H 0)
+else(WIN32)
+ set(REGEX_SOURCES "")
+endif(WIN32)
+
set(mapserver_SOURCES
cgiutil.c mapgeos.c maporaclespatial.c mapsearch.c mapwms.c classobject.c
mapgml.c mapoutput.c mapwmslayer.c layerobject.c mapgraticule.c mapows.c
@@ -173,7 +186,7 @@ mapogcfiltercommon.c maprendering.c mapwcs20.c mapgd.c mapogcsld.c
mapresample.c mapwfs.c mapgdal.c mapogcsos.c mapscale.c mapwfs11.c
mapgeomtransform.c mapogroutput.c mapsde.c mapwfslayer.c mapagg.cpp mapkml.cpp
mapgeomutil.cpp mapkmlrenderer.cpp
-mapogr.cpp mapcontour.c )
+mapogr.cpp mapcontour.c ${REGEX_SOURCES})
add_library(mapserver SHARED ${mapserver_SOURCES} ${agg_SOURCES})
set_target_properties( mapserver PROPERTIES
@@ -201,16 +214,6 @@ add_executable(shp2img shp2img.c)
target_link_libraries(shp2img ${MAPSERVER_LIBMAPSERVER})
-
-find_package(ZLIB)
-if(ZLIB_FOUND)
- include_directories(${ZLIB_INCLUDE_DIR})
- ms_link_libraries( ${ZLIB_LIBRARY})
- set(USE_ZLIB 1)
-else(ZLIB_FOUND)
- report_mandatory_not_found(ZLIB)
-endif(ZLIB_FOUND)
-
find_package(PNG)
if(PNG_FOUND)
include_directories(${PNG_INCLUDE_DIR})
@@ -625,10 +628,19 @@ if(WITH_JAVA)
set(USE_JAVA_MAPSCRIPT 1)
endif(WITH_JAVA)
+if(WITH_CSHARP)
+ add_subdirectory("mapscript/csharp")
+ set(USE_CSHARP_MAPSCRIPT 1)
+endif(WITH_CSHARP)
+
if(UNIX)
ms_link_libraries( ${CMAKE_DL_LIBS} m )
endif(UNIX)
+if (WIN32)
+ms_link_libraries( ${MS_EXTERNAL_LIBS})
+endif (WIN32)
+
configure_file (
"${PROJECT_SOURCE_DIR}/mapserver-config.h.in"
"${PROJECT_BINARY_DIR}/mapserver-config.h"
@@ -658,7 +670,6 @@ endmacro()
message(STATUS "* Summary of configured options for this build")
message(STATUS " * Mandatory components")
-message(STATUS " * zlib: ${ZLIB_LIBRARY}")
message(STATUS " * png: ${PNG_LIBRARY}")
message(STATUS " * jpeg: ${JPEG_LIBRARY}")
message(STATUS " * freetype: ${FREETYPE_LIBRARY}")
@@ -701,6 +712,7 @@ status_optional_feature("PHP" "${USE_PHP_MAPSCRIPT}")
status_optional_feature("PERL" "${USE_PERL_MAPSCRIPT}")
status_optional_feature("RUBY" "${USE_RUBY_MAPSCRIPT}")
status_optional_feature("JAVA" "${USE_JAVA_MAPSCRIPT}")
+status_optional_feature("C#" "${USE_CSHARP_MAPSCRIPT}")
status_optional_feature("Apache Module (Experimental)" "${USE_APACHE_MODULE}")
include_directories("${PROJECT_BINARY_DIR}")
@@ -0,0 +1,32 @@
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(${SWIG_USE_FILE})
+
+FIND_PROGRAM (CSHARP_COMPILER NAMES csc gmcs gmcs2)
+
+IF (CSHARP_COMPILER)
+ MESSAGE(STATUS "Found CSharp compiler: ${CSHARP_COMPILER}")
+ELSE (CSHARP_COMPILER)
+ MESSAGE(FATAL_ERROR "Could not find csharp compiler")
+ENDIF (CSHARP_COMPILER)
+
+MARK_AS_ADVANCED(CSHARP_COMPILER)
+
+include_directories(${PROJECT_SOURCE_DIR}/mapscript/swiginc)
+include_directories(${PROJECT_SOURCE_DIR}/mapscript/)
+include_directories(${PROJECT_SOURCE_DIR}/mapscript/csharp)
+SET (CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}")
+SET( CMAKE_SWIG_FLAGS -namespace OSGeo.MapServer ${MAPSERVER_COMPILE_DEFINITIONS} -DWIN32)
+SWIG_ADD_MODULE(csharpmapscript csharp ../mapscript.i)
+
+SWIG_LINK_LIBRARIES(csharpmapscript ${MAPSERVER_LIBMAPSERVER})
+
+ADD_CUSTOM_COMMAND(TARGET csharpmapscript
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ POST_BUILD
+ COMMAND ${CSHARP_COMPILER} /t:library /out:mapscript_csharp.dll *.cs config\\AssemblyInfo.cs
+ COMMENT "Compiling c# source files, creating mapscript_csharp.dll"
+ )
+
+get_target_property(LOC_MAPSCRIPT_LIB ${SWIG_MODULE_csharpmapscript_REAL_NAME} LOCATION)
+install(FILES ${LOC_MAPSCRIPT_LIB} DESTINATION lib)
+
@@ -264,7 +264,7 @@ static SWIG_CSharpByteArrayHelperCallback SWIG_csharp_bytearray_callback = NULL;
%ignore imageObj::write;
-%typemap(cscode) imageObj %{
+%typemap(cscode) imageObj, struct imageObj %{
private byte[] gdbuffer;
private void CreateByteArray(IntPtr data, int size)
{
@@ -290,7 +290,7 @@ static SWIG_CSharpByteArrayHelperCallback SWIG_csharp_bytearray_callback = NULL;
%csmethodmodifiers processLegendTemplate "private";
%csmethodmodifiers processQueryTemplate "private";
-%typemap(cscode) mapObj %{
+%typemap(cscode) mapObj, struct mapObj %{
public string processTemplate(int bGenerateImages, string[] names, string[] values)
{
if (names.Length != values.Length)
@@ -36,37 +36,50 @@
%}
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE {
+ /* %typemap(csout, excode=SWIGEXCODE) SWIGTYPE */
$&csclassname ret = new $&csclassname($imcall, true, null);$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE, new="1") SWIGTYPE & {
+ /* typemap(csout, excode=SWIGEXCODE, new="1") SWIGTYPE & */
$csclassname ret = new $csclassname($imcall, $owner, ThisOwn_$owner());$excode
return ret;
}
%typemap(csout, excode=SWIGEXCODE, new="1") SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) {
+ /* %typemap(csout, excode=SWIGEXCODE, new="1") SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) */
IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner, ThisOwn_$owner());$excode
return ret;
}
+%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{
+ /* %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE */
+ get {
+ $&csclassname ret = new $&csclassname($imcall, $owner, ThisOwn_$owner());$excode
+ return ret;
+ } %}
%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{
+ /* %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & */
get {
$csclassname ret = new $csclassname($imcall, $owner, ThisOwn_$owner());$excode
return ret;
} %}
-%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+%typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, struct SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+ /* %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) */
get {
IntPtr cPtr = $imcall;
$csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner, ThisOwn_$owner());$excode
return ret;
} %}
%typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& {
+ /* %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *& */
IntPtr cPtr = $imcall;
$*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner, ThisOwn_$owner());$excode
return ret;
}
// Proxy classes (base classes, ie, not derived classes)
%typemap(csbody) SWIGTYPE %{
+ /* %typemap(csbody) SWIGTYPE */
private HandleRef swigCPtr;
protected bool swigCMemOwn;
protected object swigParentRef;
@@ -110,6 +123,7 @@
// Derived proxy classes
%typemap(csbody_derived) SWIGTYPE %{
+ /* %typemap(csbody_derived) SWIGTYPE */
private HandleRef swigCPtr;
internal $csclassname(IntPtr cPtr, bool cMemoryOwn, object parent) : base($modulePINVOKE.$csclassnameUpcast(cPtr), cMemoryOwn, parent) {
@@ -146,6 +160,7 @@
// Typewrapper classes
%typemap(csbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
+ /* %typemap(csbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) */
private HandleRef swigCPtr;
internal $csclassname(IntPtr cPtr, bool futureUse, object parent) {
@@ -162,6 +177,7 @@
%}
%typemap(csfinalize) SWIGTYPE %{
+ /* %typemap(csfinalize) SWIGTYPE */
~$csclassname() {
Dispose();
}
@@ -200,6 +216,7 @@
%typemap(csin) SWIGTYPE *SETREFERENCE "$csclassname.getCPtrAndSetReference($csinput, ThisOwn_false())"
%pragma(csharp) modulecode=%{
+ /* %pragma(csharp) modulecode */
internal class $moduleObject : IDisposable {
public virtual void Dispose() {

0 comments on commit 7337f79

Please sign in to comment.