]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
XDR detection. The aim is to enable it even on win7.
authorageay <ageay>
Fri, 18 Oct 2013 06:36:15 +0000 (06:36 +0000)
committerageay <ageay>
Fri, 18 Oct 2013 06:36:15 +0000 (06:36 +0000)
CMakeLists.txt
adm_local/cmake_files/CMakeLists.txt
adm_local/cmake_files/FindSalomeXDR.cmake [new file with mode: 0644]
adm_local/cmake_files/FindXDR.cmake
src/MEDLoader/CMakeLists.txt
src/MEDLoader/SauvMedConvertor.cxx

index a6e1739d86cef860bd45667685f6a2a50cfd2c8c..9fcd4febefcb1bf32079db338026302c3baa62cc 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-#IF(WIN32)
-#  INCLUDE(${PROJECT_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
-#ENDIF(WIN32)
-
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
 PROJECT(SalomeMED C CXX)
 
@@ -84,6 +80,9 @@ OPTION(SALOME_BUILD_DOC "Build MED doc." ON)
 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_METIS "Enable metis graph library in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_SCOTCH "Enable scotch graph library in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_PARMETIS "Enable parmetis graph library in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;SALOME_USE_MPI" OFF)
+IF(WIN32)
+  CMAKE_DEPENDENT_OPTION(SALOME_MED_MEDLOADER_USE_XDR "Enable use of XDR for SauvReader." ON "NOT SALOME_MED_MICROMED" OFF)
+ENDIF(WIN32)
 
 #
 # Set list of prerequisites
@@ -114,6 +113,15 @@ INCLUDE(SalomeSetupPlatform)
 IF(NOT SALOME_MED_MICROMED)
   FIND_PACKAGE(SalomeHDF5 REQUIRED)
   FIND_PACKAGE(SalomeMEDFile REQUIRED)
+  # XDR stuff
+  IF(NOT WIN32)
+    FIND_PACKAGE(SalomeXDR REQUIRED)
+  ELSE(NOT WIN32)
+    IF(SALOME_MED_MEDLOADER_USE_XDR)
+      FIND_PACKAGE(SalomeXDR REQUIRED)
+    ENDIF(SALOME_MED_MEDLOADER_USE_XDR)
+  ENDIF(NOT WIN32)
+  # End of XDR Stuff
   IF(SALOME_MED_ENABLE_PARTITIONER)
     FIND_PACKAGE(SalomeLibXml2)
     SALOME_LOG_OPTIONAL_PACKAGE(LibXml2 SALOME_MED_ENABLE_PARTITIONER)
index dff494ff0fa7e6bbd51b98bce582b7d602029ec1..b6efc064922d7ff4fc0dfc6311982b833d02a2cc 100644 (file)
@@ -19,6 +19,7 @@
 
 SET(admlocal_cmake_DATA
   FindXDR.cmake
+  FindSalomeXDR.cmake
   FindMetis.cmake
   FindSalomeMetis.cmake
   FindParMetis.cmake
diff --git a/adm_local/cmake_files/FindSalomeXDR.cmake b/adm_local/cmake_files/FindSalomeXDR.cmake
new file mode 100644 (file)
index 0000000..36d0917
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Anthony Geay
+#
+
+# XDR detection dor Salome
+#
+#  !! Please read the generic detection procedure in SalomeMacros.cmake !!
+#
+
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(XDR XDR_FOUND 1)
+#MARK_AS_ADVANCED()
+
+#SALOME_ACCUMULATE_HEADERS(XDR_INCLUDE_DIRS) # useless here because XDR is used only in CXX of MEDLoader
index ceb451aa27c661edd45b364dbceddeebebb3d47f..e13f04e740e084e344cca8a28f9fff759824d895 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-# ------
-#
-MESSAGE(STATUS "Check for xdr ...")
-
-# ------
-
-IF(XDR_IS_MANDATORY STREQUAL 0)
-  SET(XDR_IS_MANDATORY 0)
-  SET(XDR_IS_OPTIONAL 1)
-ENDIF(XDR_IS_MANDATORY STREQUAL 0)
-IF(XDR_IS_OPTIONAL STREQUAL 0)
-  SET(XDR_IS_MANDATORY 1)
-  SET(XDR_IS_OPTIONAL 0)
-ENDIF(XDR_IS_OPTIONAL STREQUAL 0)
-IF(NOT XDR_IS_MANDATORY AND NOT XDR_IS_OPTIONAL)
-  SET(XDR_IS_MANDATORY 0)
-  SET(XDR_IS_OPTIONAL 1)
-ENDIF(NOT XDR_IS_MANDATORY AND NOT XDR_IS_OPTIONAL)
-
-# ------
-
-SET(XDR_STATUS 1)
-IF(WITHOUT_XDR OR WITH_XDR STREQUAL 0)
-  SET(XDR_STATUS 0)
-  MESSAGE(STATUS "xdr disabled from command line.")
-ENDIF(WITHOUT_XDR OR WITH_XDR STREQUAL 0)
-
-# ------
-
-IF(XDR_STATUS)
-  IF(WITH_XDR)
-    SET(XDR_ROOT_USER ${WITH_XDR})
-  ELSE(WITH_XDR)
-    SET(XDR_ROOT_USER $ENV{XDR_ROOT})
-  ENDIF(WITH_XDR)
-ENDIF(XDR_STATUS)
-
-# -----
-
-IF(XDR_STATUS)
-  IF(XDR_ROOT_USER)
-    SET(XDR_FIND_PATHS_OPTION NO_DEFAULT_PATH)
-  ELSE(XDR_ROOT_USER)
-    SET(XDR_FIND_PATHS_OPTION)
-  ENDIF(XDR_ROOT_USER)
-ENDIF(XDR_STATUS)
-
-# -----
-
-IF(XDR_STATUS)
-  IF(XDR_ROOT_USER)
-    SET(XDR_INCLUDE_PATHS ${XDR_ROOT_USER} ${XDR_ROOT_USER}/include)
-  ELSE(XDR_ROOT_USER)
-    SET(XDR_INCLUDE_PATHS)
-  ENDIF(XDR_ROOT_USER)
-  SET(XDR_INCLUDE_TO_FIND rpc/xdr.h)
-  FIND_PATH(XDR_INCLUDE_DIR ${XDR_INCLUDE_TO_FIND} PATHS ${XDR_INCLUDE_PATHS} ${XDR_FIND_PATHS_OPTION})
-  IF(XDR_INCLUDE_DIR)
-    IF(XDR_ROOT_USER)
-      SET(XDR_INCLUDES -I${XDR_INCLUDE_DIR} -I${XDR_INCLUDE_DIR}/src/msvc)# to remove
-      SET(XDR_INCLUDE_DIRS ${XDR_INCLUDE_DIR} ${XDR_INCLUDE_DIR}/src/msvc)
-    ENDIF(XDR_ROOT_USER)
-    MESSAGE(STATUS "${XDR_INCLUDE_TO_FIND} found in ${XDR_INCLUDE_DIR}")
-  ELSE(XDR_INCLUDE_DIR)
-    SET(XDR_STATUS 0)
-    IF(XDR_ROOT_USER)
-      MESSAGE(STATUS "${XDR_INCLUDE_TO_FIND} not found in ${XDR_INCLUDE_PATHS}, check your XDR installation.")
-    ELSE(XDR_ROOT_USER)
-      MESSAGE(STATUS "${XDR_INCLUDE_TO_FIND} not found on system, try to use WITH_XDR option or XDR_ROOT environment variable.")
-    ENDIF(XDR_ROOT_USER)
-  ENDIF(XDR_INCLUDE_DIR)
-ENDIF(XDR_STATUS)
-
-# ----
-
-IF(XDR_STATUS)
-  IF(XDR_ROOT_USER)
-    SET(XDR_LIB_PATHS ${XDR_ROOT_USER}/lib)
-  ELSE(XDR_ROOT_USER)
-    SET(XDR_LIB_PATHS)
-  ENDIF(XDR_ROOT_USER)
-ENDIF(XDR_STATUS)
-
-IF(XDR_STATUS)
-  FIND_LIBRARY(XDR_LIB xdr PATHS ${XDR_LIB_PATHS} ${XDR_FIND_PATHS_OPTION})
-  SET(XDR_LIBS)
-  IF(XDR_LIB)
-    SET(XDR_LIBS ${XDR_LIBS} ${XDR_LIB})
-    MESSAGE(STATUS "xdr lib found: ${XDR_LIB}")
-  ELSE(XDR_LIB)
-    SET(XDR_STATUS 0)
-    IF(XDR_ROOT_USER)
-      MESSAGE(STATUS "xdr lib not found in ${XDR_LIB_PATHS}, check your XDR installation.")
-    ELSE(XDR_ROOT_USER)
-      MESSAGE(STATUS "xdr lib not found on system, try to use WITH_XDR option or XDR_ROOT environment variable.")
-    ENDIF(XDR_ROOT_USER)
-  ENDIF(XDR_LIB)
-ENDIF(XDR_STATUS)
-
-# ----
-
-IF(XDR_STATUS)
-  SET(XDR_IS_OK 1)
-  SET(XDR_CPPFLAGS -DHAS_XDR ${XDR_INCLUDES})# to remove
-  SET(XDR_DEFINITIONS "-DHAS_XDR")
-ELSE(XDR_STATUS)
-  IF(XDR_IS_MANDATORY)
-    MESSAGE(FATAL_ERROR "xdr not found ... mandatory ... abort")
-  ELSE(XDR_IS_MANDATORY)
-    MESSAGE(STATUS "xdr not found ... optional ... disabled")
-  ENDIF(XDR_IS_MANDATORY)
-ENDIF(XDR_STATUS)
-
-# ------
+MESSAGE(STATUS "Check for XDR ...")
+SET(XDR_ROOT_DIR $ENV{XDR_ROOT_DIR} CACHE PATH "Path to the XDR.")
+IF(XDR_ROOT_DIR)
+  LIST(APPEND CMAKE_LIBRARY_PATH "${XDR_ROOT_DIR}/lib")
+  LIST(APPEND CMAKE_INCLUDE_PATH "${XDR_ROOT_DIR}/include")
+ENDIF(XDR_ROOT_DIR)
+
+FIND_LIBRARY(XDR_LIBRARIES xdr)
+FIND_PATH(XDR_INCLUDE_DIRS rpc/xdr.h)
+SET(XDR_DEFINITIONS "-DHAS_XDR")
+SET(XDR_FOUND 1)
+
+IF(WIN32)
+  LIST(APPEND XDR_INCLUDE_DIRS "${XDR_ROOT_DIR}/src/msvc")
+ENDIF(WIN32)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(XDR REQUIRED_VARS XDR_FOUND)
index c633ab39c31df69e893874b7f677b2e853b51106..d892e056943ef59c3413545a5f0b41f4c67f6c2c 100644 (file)
@@ -58,7 +58,7 @@ SET(medloader_SOURCES
   )
 
 ADD_LIBRARY(medloader SHARED ${medloader_SOURCES})
-SET_TARGET_PROPERTIES(medloader PROPERTIES COMPILE_FLAGS "")
+SET_TARGET_PROPERTIES(medloader PROPERTIES COMPILE_FLAGS "${XDR_DEFINITIONS}")
 TARGET_LINK_LIBRARIES(medloader medcoupling ${MEDFILE_C_LIBRARIES} ${HDF5_LIBRARIES})
 INSTALL(TARGETS medloader EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
index 059d2f6d43b44667e8efc6dc16cc93a03414429b..1fbd660e63a1a7dee2c017d1a4cc327f3460bd66 100644 (file)
 
 #ifdef WIN32
 #include <io.h>
-#endif
-
-#ifndef WIN32
-#define HAS_XDR
+#else
 #include <unistd.h>
 #endif