Commit f9567ad3 authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

Add FIND_PACKAGE use package support

parent b8c107c3
#
# Find the native EXPAT includes and library
#
# This module defines
# EXPAT_INCLUDE_DIR, where to find expat.h, etc.
# EXPAT_LIBRARIES, the libraries to link against to use EXPAT.
# EXPAT_FOUND, If false, do not try to use EXPAT.
# also defined, but not for general use are
# EXPAT_LIBRARY, where to find the EXPAT library.
FIND_PATH(EXPAT_INCLUDE_DIR expat.h
/usr/local/include
/usr/include
)
FIND_LIBRARY(EXPAT_LIBRARY expat
/usr/lib
/usr/local/lib
)
IF(EXPAT_INCLUDE_DIR)
IF(EXPAT_LIBRARY)
SET( EXPAT_FOUND "YES" )
SET( EXPAT_LIBRARIES ${EXPAT_LIBRARY} )
ENDIF(EXPAT_LIBRARY)
ENDIF(EXPAT_INCLUDE_DIR)
CMAKE_MINIMUM_REQUIRED(VERSION 1.6)
PROJECT(Xdmf)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${Xdmf_SOURCE_DIR}/CMake)
INCLUDE_DIRECTORIES(${Xdmf_SOURCE_DIR}/Ice/libsrc)
INCLUDE_DIRECTORIES(${Xdmf_SOURCE_DIR}/libsrc
${Xdmf_BINARY_DIR}/libsrc
${Xdmf_BINARY_DIR}/Ice/libsrc)
${Xdmf_BINARY_DIR}/libsrc
${Xdmf_BINARY_DIR}/Ice/libsrc)
SET (LIBRARY_OUTPUT_PATH ${Xdmf_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH ${Xdmf_BINARY_DIR}/bin/ CACHE PATH "Single output directory for building all executables.")
......@@ -17,54 +20,66 @@ SUBDIRS(Ice/libsrc)
OPTION(XDMF_HAS_NDGM "XDMF has Network Distributed Global Memory (NDGM)" OFF)
IF(XDMF_HAS_NDGM)
FIND_PATH(NDGM_DIR BuildNDGM.cmake ${Xdmf_SOURCE_DIR}/../Ndgm "Root of Source for NDGM")
IF(NDGM_DIR)
MESSAGE(STATUS "Process NDGM")
# INCLUDE(${NDGM_DIR}/BuildNDGM.cmake)
SUBDIRS(NDGM)
ENDIF(NDGM_DIR)
ADD_DEFINITIONS(-DHAVE_NDGM)
INCLUDE_DIRECTORIES(${NDGM_DIR}/libsrc)
FIND_PATH(NDGM_DIR BuildNDGM.cmake ${Xdmf_SOURCE_DIR}/../Ndgm "Root of Source for NDGM")
IF(NDGM_DIR)
MESSAGE(STATUS "Process NDGM")
# INCLUDE(${NDGM_DIR}/BuildNDGM.cmake)
SUBDIRS(NDGM)
ENDIF(NDGM_DIR)
ADD_DEFINITIONS(-DHAVE_NDGM)
INCLUDE_DIRECTORIES(${NDGM_DIR}/libsrc)
ENDIF(XDMF_HAS_NDGM)
OPTION(XDMF_BUILD_VTK "Build VTK reader" OFF)
IF(XDMF_BUILD_VTK)
# include module to find vtk
FIND_PACKAGE(VTK)
IF(VTK_FOUND)
INCLUDE(${VTK_USE_FILE})
ENDIF(VTK_FOUND)
SET(XDMF_ZLIB_LIBRARIES ${VTK_ZLIB_LIBRARIES})
SET(XDMF_ZLIB_INCLUDE_DIRS)
SET(XDMF_EXPAT_LIBRARIES ${VTK_EXPAT_LIBRARIES})
SET(XDMF_EXPAT_INCLUDE_DIRS)
ELSE(XDMF_BUILD_VTK)
SET(VTK_DIR)
FIND_PACKAGE(ZLIB)
SET(XDMF_ZLIB_LIBRARIES ${ZLIB_LIBRARY})
SET(XDMF_ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
FIND_PACKAGE(EXPAT)
SET(XDMF_EXPAT_LIBRARIES ${EXPAT_LIBRARY})
SET(XDMF_EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
ENDIF(XDMF_BUILD_VTK)
OPTION(XDMF_SYSTEM_HDF5 "Use sytstem HDF5" ON)
IF(XDMF_SYSTEM_HDF5)
FIND_LIBRARY(HDF5_LIBRARY
hdf5
/usr/lib
/opt/lib
/usr/local/lib)
hdf5
/usr/lib
/opt/lib
/usr/local/lib)
FIND_PATH(HDF5_INCLUDE_PATH
H5Ipublic.h
/usr/include
/opt/include
/usr/local/include)
H5Ipublic.h
/usr/include
/opt/include
/usr/local/include)
MESSAGE(STATUS "Using system HDF5")
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_PATH})
SET(HDF5_LIBRARY ${HDF5_LIBRARY})
ELSE(XDMF_SYSTEM_HDF5)
INCLUDE_DIRECTORIES(${Xdmf_SOURCE_DIR}/Utilities/hdf5
${Xdmf_BINARY_DIR}/Utilities/hdf5)
${Xdmf_BINARY_DIR}/Utilities/hdf5)
SUBDIRS(Utilities)
SET(HDF5_LIBRARY vtkhdf5)
ENDIF(XDMF_SYSTEM_HDF5)
FIND_PATH(EXPAT_INCLUDE_DIR expat.h
/usr/local/include
/usr/include
)
FIND_LIBRARY(EXPAT_LIBRARY expat
/usr/lib
/usr/local/lib
)
INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${XDMF_EXPAT_INCLUDE_DIRS})
SUBDIRS(libsrc binsrc)
OPTION(XDMF_BUILD_VTK "Build VTK reader" OFF)
IF(XDMF_BUILD_VTK)
SUBDIRS(vtk)
ENDIF(XDMF_BUILD_VTK)
......@@ -75,3 +90,42 @@ IF(XDMF_BUILD_TESTING)
ENABLE_TESTING()
INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
ENDIF(XDMF_BUILD_TESTING)
# This code has to be duplicated for install tree
SET(XDMF_INCLUDE_DIRS_CONFIG
${Xdmf_SOURCE_DIR}/libsrc
${Xdmf_BINARY_DIR}/libsrc
${Xdmf_BINARY_DIR}/Ice/libsrc)
SET(XDMF_LIBRARY_DIRS_CONFIG
${LIBRARY_OUTPUT_PATH})
IF(XDMF_BUILD_VTK)
SET(XDMF_INCLUDE_DIRS_CONFIG ${XDMF_INCLUDE_DIRS_CONFIG}
${Xdmf_SOURCE_DIR}/vtk)
ENDIF(XDMF_BUILD_VTK)
IF(XDMF_SYSTEM_HDF5)
SET(XDMF_INCLUDE_DIRS_CONFIG ${XDMF_INCLUDE_DIRS_CONFIG}
${Xdmf_SOURCE_DIR}/Utilities/hdf5
${Xdmf_BINARY_DIR}/Utilities/hdf5
${XDMF_ZLIB_INCLUDE_DIRS})
ENDIF(XDMF_SYSTEM_HDF5)
# Save the compiler settings so another project can import them.
INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake)
CMAKE_EXPORT_BUILD_SETTINGS(${Xdmf_BINARY_DIR}/XDMFBuildSettings.cmake)
SET(XDMF_BUILD_SETTINGS_FILE ${Xdmf_BINARY_DIR}/XDMFBuildSettings.cmake)
SET(XDMF_USE_FILE "${Xdmf_SOURCE_DIR}/UseXDMF.cmake")
SET(XDMF_EXPAT_LIBRARIES ${EXPAT_LIBRARY})
SET(XDMF_EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
SET(XDMF_HDF5_LIBRARIES ${HDF5_LIBRARY})
# Save library dependencies.
EXPORT_LIBRARY_DEPENDENCIES(${Xdmf_BINARY_DIR}/XDMFLibraryDepends.cmake)
SET(XDMF_LIBRARY_DEPENDS_FILE ${Xdmf_BINARY_DIR}/XDMFLibraryDepends.cmake)
CONFIGURE_FILE(${Xdmf_SOURCE_DIR}/XDMFConfig.cmake.in
${Xdmf_BINARY_DIR}/XDMFConfig.cmake @ONLY IMMEDIATE)
#
# This module is provided as XDMF_USE_FILE by XDMFConfig.cmake. It can
# be INCLUDEd in a project to load the needed compiler and linker
# settings to use XDMF.
#
# Load the compiler settings used for XDMF.
IF(XDMF_BUILD_SETTINGS_FILE)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeImportBuildSettings.cmake)
CMAKE_IMPORT_BUILD_SETTINGS(${XDMF_BUILD_SETTINGS_FILE})
ENDIF(XDMF_BUILD_SETTINGS_FILE)
# Add include directories needed to use XDMF.
INCLUDE_DIRECTORIES(${XDMF_INCLUDE_DIRS})
# Add link directories needed to use XDMF.
LINK_DIRECTORIES(${XDMF_LIBRARY_DIRS})
......@@ -20,8 +20,6 @@ INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindZLIB.cmake)
# This macro checks if the symbol exists in the library and if it
# does, it appends library to the list.
SET(LINK_LIBS "")
......@@ -406,10 +404,10 @@ CONFIGURE_FILE(${VTKHDF5_SOURCE_DIR}/H5pubconf.${CONFIG_FILE_EXT}.in
SET(common_SRCS ${common_SRCS} ${VTKHDF5_BINARY_DIR}/H5Tinit.c)
SET_SOURCE_FILES_PROPERTIES (${VTKHDF5_BINARY_DIR}/H5Tinit.c GENERATED)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${XDMF_ZLIB_INCLUDE_DIRS})
ADD_LIBRARY(vtkhdf5 STATIC ${common_SRCS})
TARGET_LINK_LIBRARIES(vtkhdf5 ${LINK_LIBS} ${ZLIB_LIBRARY})
TARGET_LINK_LIBRARIES(vtkhdf5 ${LINK_LIBS} ${XDMF_ZLIB_LIBRARIES})
IF(WIN32)
SET(EXE_EXT ".exe")
......
#-----------------------------------------------------------------------------
#
# XDMFConfig.cmake - XDMF CMake configuration file for external projects.
#
# This file is configured by XDMF and used by the UseXDMF.cmake module
# to load XDMF's settings for an external project.
# The XDMF include file directories.
SET(XDMF_INCLUDE_DIRS "@XDMF_INCLUDE_DIRS_CONFIG@")
# The XDMF library directories.
SET(XDMF_LIBRARY_DIRS "@XDMF_LIBRARY_DIRS_CONFIG@")
# The location of the UseXDMF.cmake file.
SET(XDMF_USE_FILE "@XDMF_USE_FILE@")
# The build settings file.
SET(XDMF_BUILD_SETTINGS_FILE "@XDMF_BUILD_SETTINGS_FILE@")
# The names of utility libraries used by XDMF.
SET(XDMF_HDF5_LIBRARIES "@XDMF_HDF5_LIBRARIES@")
SET(XDMF_ZLIB_LIBRARIES "@XDMF_ZLIB_LIBRARIES@")
SET(XDMF_EXPAT_LIBRARIES "@XDMF_EXPAT_LIBRARIES@")
# The location of VTK
SET(XDMF_VTK_DIR "@VTK_DIR@")
# The XDMF library dependencies.
IF(NOT XDMF_NO_LIBRARY_DEPENDS)
INCLUDE("@XDMF_LIBRARY_DEPENDS_FILE@")
ENDIF(NOT XDMF_NO_LIBRARY_DEPENDS)
......@@ -5,12 +5,8 @@ vtkXdmfReader
vtkXdmfDataArray
)
# include module to find vtk
INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
# if vtk was found include the use vtk file
IF (VTK_FOUND)
INCLUDE(${VTK_USE_FILE})
ADD_LIBRARY(vtkXdmf SHARED ${Xdmf_SRCS})
TARGET_LINK_LIBRARIES(vtkXdmf vtkIO Xdmf)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment