[MOAB-dev] r1338 - in MOAB/trunk: . cmake

dcthomp at mcs.anl.gov dcthomp at mcs.anl.gov
Wed Oct 24 17:56:13 CDT 2007


Author: dcthomp
Date: 2007-10-24 17:56:13 -0500 (Wed, 24 Oct 2007)
New Revision: 1338

Added:
   MOAB/trunk/cmake/FindNetCDF.cmake
   MOAB/trunk/cmake/TestingConfig.h.in
Modified:
   MOAB/trunk/CMakeLists.txt
Log:
ENH: Add NetCDF files to build. Some of the moab_test checks
     now pass... those that fail appear to be from complications
     with out-of-source builds.


Modified: MOAB/trunk/CMakeLists.txt
===================================================================
--- MOAB/trunk/CMakeLists.txt	2007-10-24 22:26:15 UTC (rev 1337)
+++ MOAB/trunk/CMakeLists.txt	2007-10-24 22:56:13 UTC (rev 1338)
@@ -70,11 +70,11 @@
     set ( MOAB_HAVE_PTRDIFF_T ${HAVE_PTRDIFF_T} )
   endif ( NOT MOAB_FORCE_64_BIT_HANDLES AND NOT MOAB_FORCE_32_BIT_HANDLES )
 
-  # MPI
-  option ( MOAB_USE_MPI "Should MOAB be compiled with MPI support?" OFF )
-  option ( MOAB_USE_HDF "Include HDF I/O in the build?"             OFF )
-
-  # NetCDF
+  # Build options
+  option ( MOAB_USE_MPI    "Should MOAB be compiled with MPI support?"       OFF )
+  option ( MOAB_USE_HDF    "Include HDF I/O in the build?"                   OFF )
+  option ( MOAB_USE_NETCDF "Include NetCDF support (ExodusII) in the build?" OFF )
+  
   # Documentation
   # Optional tools
   option ( MOAB_BUILD_MBCONVERT    "Build the MOAB mesh converter tool?"  ON )
@@ -155,6 +155,22 @@
     ${MOAB_BINARY_DIR}
   )
 
+  if ( MOAB_USE_NETCDF )
+    find_package( NetCDF )
+    if ( NetCDF_FOUND )
+      set ( MOAB_DEFINES "${MOAB_DEFINES} -DNETCDF_FILE" )
+      set ( MOAB_LIB_SRCS
+        ${MOAB_LIB_SRCS}
+        ReadNCDF.cpp
+        WriteNCDF.cpp
+        WriteSLAC.cpp
+      )
+      include_directories(
+        ${NetCDF_INCLUDE_DIRECTORIES}
+      )
+    endif ( NetCDF_FOUND )
+  endif ( MOAB_USE_NETCDF )
+
   if ( MOAB_USE_HDF )
     # HDF5
     find_package( HDF5 )
@@ -193,7 +209,6 @@
   set_source_files_properties( ${MOAB_LIB_SRCS}
     COMPILE_FLAGS "-DIS_BUILDING_MB ${MOAB_DEFINES}"
   )
-  message( "MOAB_DEFINES=\"${MOAB_DEFINES}\"" )
   add_library( MOAB
     ${MOAB_LIB_SRCS}
   )
@@ -211,6 +226,11 @@
     )
   endif ( MOAB_USE_MPI AND MPI_FOUND )
 
+  if ( MOAB_USE_NETCDF AND NetCDF_FOUND )
+    target_link_libraries( MOAB
+      ${NetCDF_LIBRARIES}
+    )
+  endif ( MOAB_USE_NETCDF AND NetCDF_FOUND )
   ## Tools/libraries dependent on MOAB:
 
   # Zoltan

Added: MOAB/trunk/cmake/FindNetCDF.cmake
===================================================================
--- MOAB/trunk/cmake/FindNetCDF.cmake	                        (rev 0)
+++ MOAB/trunk/cmake/FindNetCDF.cmake	2007-10-24 22:56:13 UTC (rev 1338)
@@ -0,0 +1,72 @@
+#
+# Find NetCDF include directories and libraries
+#
+# NetCDF_INCLUDE_DIRECTORIES - where to find netcdf.h
+# NetCDF_LIBRARIES           - list of libraries to link against when using NetCDF
+# NetCDF_FOUND               - Do not attempt to use NetCDF if "no", "0", or undefined.
+
+set( NetCDF_PREFIX "" CACHE PATH "Path to search for NetCDF header and library files" )
+
+find_path( NetCDF_INCLUDE_DIRECTORIES netcdf.h
+  /usr/local/include
+  /usr/include
+)
+
+find_library( NetCDF_C_LIBRARY
+  NAMES netcdf
+  ${NetCDF_PREFIX}
+  ${NetCDF_PREFIX}/lib64
+  ${NetCDF_PREFIX}/lib
+  /usr/local/lib64
+  /usr/lib64
+  /usr/lib64/netcdf-3
+  /usr/local/lib
+  /usr/lib
+  /usr/lib/netcdf-3
+)
+
+find_library( NetCDF_CXX_LIBRARY
+  NAMES netcdf_c++
+  ${NetCDF_PREFIX}
+  ${NetCDF_PREFIX}/lib64
+  ${NetCDF_PREFIX}/lib
+  /usr/local/lib64
+  /usr/lib64
+  /usr/lib64/netcdf-3
+  /usr/local/lib
+  /usr/lib
+  /usr/lib/netcdf-3
+)
+
+find_library( NetCDF_FORTRAN_LIBRARY
+  NAMES netcdf_g77 netcdf_ifc netcdf_x86_64
+  ${NetCDF_PREFIX}
+  ${NetCDF_PREFIX}/lib64
+  ${NetCDF_PREFIX}/lib
+  /usr/local/lib64
+  /usr/lib64
+  /usr/lib64/netcdf-3
+  /usr/local/lib
+  /usr/lib
+  /usr/lib/netcdf-3
+)
+
+set( NetCDF_LIBRARIES
+  ${NetCDF_C_LIBRARY}
+  ${NetCDF_CXX_LIBRARY}
+  ${NetCDF_FORTRAN_LIBRARY}
+)
+
+if ( NetCDF_INCLUDE_DIRECTORIES AND NetCDF_LIBRARIES )
+  set( NetCDF_FOUND 1 )
+else ( NetCDF_INCLUDE_DIRECTORIES AND NetCDF_LIBRARIES )
+  set( NetCDF_FOUND 0 )
+endif ( NetCDF_INCLUDE_DIRECTORIES AND NetCDF_LIBRARIES )
+
+mark_as_advanced(
+  NetCDF_PREFIX
+  NetCDF_INCLUDE_DIRECTORIES
+  NetCDF_C_LIBRARY
+  NetCDF_CXX_LIBRARY
+  NetCDF_FORTRAN_LIBRARY
+)

Added: MOAB/trunk/cmake/TestingConfig.h.in
===================================================================
--- MOAB/trunk/cmake/TestingConfig.h.in	                        (rev 0)
+++ MOAB/trunk/cmake/TestingConfig.h.in	2007-10-24 22:56:13 UTC (rev 1338)
@@ -0,0 +1,3 @@
+#ifndef TEST_DIR
+#  define TEST_DIR "@MOAB_SOURCE_DIR@/test"
+#endif /* TEST_DIR */




More information about the moab-dev mailing list