Arjen Markus <[EMAIL PROTECTED]> writes:

> Perhaps we can do this even simpler:
> Use CMake itself to write this file. Whether we use single or double
> precision is controlled via a CMake variable/option, PL_DOUBLE.
> So we can use this to write the one or two lines we need to write.
>

I have attached a patch that implements your suggestion.  The patch also
include my other Fortran changes that have not been applied yet.

Index: plstubs.h
===================================================================
--- plstubs.h	(revision 8450)
+++ plstubs.h	(working copy)
@@ -52,7 +52,7 @@
 #define STUB_L		2
 #define STUB_U		3
 #define STUB_FORTRAN	4
-#define STUB_WINFORTRAN	5
+#define STUB_STDCALL	5
 
 #ifndef STUB_LINKAGE
 
@@ -90,11 +90,17 @@
 #endif
 #endif
 
-#ifdef WIN32				/* MS-DOS based */
-#define STUB_LINKAGE STUB_WINFORTRAN
+#ifdef WIN32				/* Windows 32-bit */
+#ifdef IVF                              /* Intel Visual Fortran */
+#define STUB_LINKAGE STUB_U
+#elif defined(CVF)
+#define STUB_LINKAGE_STUB_U
+#elif defined(_MSC_VER)
+#define STUB_LINKAGE STUB_STDCALL
+#else
+#define STUB_LINKAGE STUB_STDCALL
 #endif
-
-#ifdef MSDOS				/* MS-DOS based */
+#elif defined(MSDOS)				/* MS-DOS based */
 #define STUB_LINKAGE STUB_FORTRAN
 #endif
 
@@ -119,7 +125,7 @@
 #elif STUB_LINKAGE == STUB_U
 #define FNAME(x,y)	x
 
-#elif STUB_LINKAGE == STUB_WINFORTRAN
+#elif STUB_LINKAGE == STUB_STDCALL
 #define FNAME(x,y)	PLDLLIMPEXP __stdcall x
 
 #elif STUB_LINKAGE == STUB_FORTRAN
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 8450)
+++ CMakeLists.txt	(working copy)
@@ -29,27 +29,36 @@
 ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-# Build plflt to determine KIND for PLFLT
-set(plflt_SRC
-plflt.c
-)
+# Generate the include file that specifies the kind of floating
+# point (single vs double) PLplot supports
+#
+FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/plflt.inc" INC_FILE)
+FILE(WRITE "${INC_FILE}"
+     "! Include file to control the kind of floating point number\n"
+     "! used by PLplot (single vs double)\n"
+     "! This file is automatically generated by CMake\n")
+if(PL_DOUBLE)
+  FILE(APPEND "${INC_FILE}"
+       "integer, parameter :: plflt   = kind(1.0d0)\n")
+else(PL_DOUBLE)
+  FILE(APPEND "${INC_FILE}"
+       "integer, parameter :: plflt   = kind(1.0)\n")
+endif(PL_DOUBLE)
 
-add_executable(plflt ${plflt_SRC})
-
-get_target_property(
-plflt_LOCATION
-plflt
-LOCATION
-)
-
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc
-  COMMAND ${CMAKE_CURRENT_BINARY_DIR}/plflt
-  DEPENDS ${plflt_LOCATION}
-)
-
+# Mark the include file as being generated
 set_source_files_properties(plflt.inc PROPERTIES GENERATED ON)
 
 ## Build C part of F95 bindings
+if(WIN32)
+  # Set the flags for the C compiler. The C stubs need to have the
+  # correct case and calling convention for the Fortran compiler
+  IF(TARGET_FORTRAN MATCHES "IVF")
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DIVF")
+  ELSEIF(TARGET_FORTRAN MATCHES "CVF")
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DCVF")
+  ENDIF(TARGET_FORTRAN MATCHES "IVF")
+endif(WIN32)
+
 set(plplotf95c${LIB_TAG}_LIB_SRCS
 plstubs.h
 sc3d.c
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to