Commit e941db22 authored by David E. DeMarle's avatar David E. DeMarle

Merge branch 'cmake-cleanup' into 'master'

Cmake cleanup

See merge request !39
parents 4fb8185c 22e0bcd5
......@@ -69,12 +69,6 @@ MACRO(ADD_TEST_C executable)
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable}${dup} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${c_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${c_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${c_binary_dir})
IF("${c_path}" STREQUAL "")
SET(c_path ${c_ldpath})
ENDIF()
......@@ -127,12 +121,6 @@ MACRO(ADD_MPI_TEST_C script files)
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${c_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${c_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${c_binary_dir})
IF("${c_path}" STREQUAL "")
SET(c_path ${c_ldpath})
ENDIF()
......
......@@ -73,12 +73,6 @@ MACRO(ADD_TEST_CXX executable)
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable}${dup} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${cxx_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${cxx_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${cxx_binary_dir})
IF("${cxx_path}" STREQUAL "")
SET(cxx_path ${cxx_ldpath})
ENDIF()
......@@ -135,12 +129,6 @@ MACRO(ADD_MPI_TEST_CXX script files)
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${cxx_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${cxx_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${cxx_binary_dir})
IF("${cxx_path}" STREQUAL "")
SET(cxx_path ${cxx_ldpath})
ENDIF()
......
......@@ -77,12 +77,6 @@ MACRO(ADD_TEST_FORTRAN executable)
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable}${dup} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${fortran_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${fortran_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${fortran_binary_dir})
IF("${fortran_path}" STREQUAL "")
SET(fortran_path ${fortran_ldpath})
ENDIF()
......@@ -143,12 +137,6 @@ MACRO(ADD_MPI_TEST_FORTRAN script files)
# Take care of windowisims
IF(WIN32)
SET_TARGET_PROPERTIES(${executable} PROPERTIES
PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${fortran_binary_dir}
LIBRARY_OUTPUT_DIRECTORY ${fortran_binary_dir}
ARCHIVE_OUTPUT_DIRECTORY ${fortran_binary_dir})
IF("${fortran_path}" STREQUAL "")
SET(fortran_path ${fortran_ldpath})
ENDIF()
......
......@@ -42,11 +42,9 @@ macro(usedoxygen_set_default name value)
endif()
endmacro()
mark_as_advanced(CLEAR DOXYGEN_EXECUTABLE)
find_package(Doxygen REQUIRED)
if(DOXYGEN_FOUND)
mark_as_advanced(FORCE DOXYGEN_EXECUTABLE)
find_file(DOXYFILE_IN "Doxyfile.in"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_ROOT}/Modules/"
NO_DEFAULT_PATH)
......
......@@ -62,7 +62,7 @@ MACRO(VersionWrite vProjectName export_name)
FOREACH(il ${include_list})
SET(includes "${includes}\n\#include \"${il}\"")
ENDFOREACH()
FILE(WRITE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${vProjectName}Version.hpp
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${vProjectName}Version.hpp
"/* Current Version of ${vProjectName}
* Major is: ${vMajor}
* Minor is: ${vMinor}
......@@ -73,7 +73,7 @@ ${includes}
extern ${export_name} ProjectVersion ${vProjectName}Version;\n"
)
FILE(WRITE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${vProjectName}Version.cpp
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${vProjectName}Version.cpp
"/* Current Version of ${vProjectName}
* Make sure to include this file in your built sources
*/
......
project(Xdmf)
cmake_minimum_required(VERSION 2.8.5)
#Needed to build DSM because relative paths are used to add its libraries
if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif ()
project(Xdmf)
if(WIN32)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
endif()
if(MSVC10)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
endif()
set(XDMF_LIBNAME "Xdmf" CACHE STRING "Name for this xdmf library to avoid collision")
......@@ -24,23 +15,16 @@ set(XDMF_MINOR_VERSION 0)
set(XDMF_PATCH_VERSION 0)
set(XDMF_VERSION "${XDMF_MAJOR_VERSION}.${XDMF_MINOR_VERSION}.${XDMF_PATCH_VERSION}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
if(BUILD_SHARED_LIBS)
set(LIBTYPE SHARED)
set(BUILD_SHARED 1)
else()
set(LIBTYPE STATIC)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/XdmfConfig.hpp)
if (WIN32)
set(XDMF_STATIC_AND_SHARED OFF)
else()
option(XDMF_STATIC_AND_SHARED
"Build both static and shared libraries" ON)
mark_as_advanced(FORCE XDMF_STATIC_AND_SHARED)
endif()
# Enable CMake testing
option(XDMF_BUILD_TESTING "Build Tests" OFF)
if(XDMF_BUILD_TESTING)
......@@ -48,13 +32,8 @@ if(XDMF_BUILD_TESTING)
include(CTest)
endif()
if (XDMF_STATIC_AND_SHARED)
add_definitions(-DXDMFSTATIC)
endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/VersionSuite)
......@@ -65,20 +44,6 @@ endif()
include(XdmfFunctions)
option(XDMF_INSTALL_NO_DEVELOPMENT "Prevent install from writing out developement files." OFF)
mark_as_advanced(XDMF_INSTALL_NO_DEVELOPMENT)
# Converting Install Prefix to an absolute path
get_filename_component(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ABSOLUTE)
# RPath
option(XDMF_SET_RPATH ON)
if (XDMF_SET_RPATH)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif ()
# Should we build with documentation
option(XDMF_BUILD_DOCUMENTATION OFF)
if(XDMF_BUILD_DOCUMENTATION)
......@@ -93,13 +58,7 @@ option(XDMF_WRAP_JAVA OFF)
find_package(TIFF)
if (TIFF_FOUND)
add_definitions(-DXDMF_BUILD_TIFF)
mark_as_advanced(FORCE TIFF_INCLUDE_DIR)
mark_as_advanced(FORCE TIFF_LIBRARIES)
mark_as_advanced(FORCE TIFF_LIBRARY)
include_directories(${TIFF_INCLUDE_DIR})
get_filename_component(TIFF_LIBRARY_DIR "${TIFF_LIBRARY}" PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${TIFF_LIBRARY_DIR})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${TIFF_LIBRARIES})
endif (TIFF_FOUND)
# Test for DSM
......@@ -109,30 +68,24 @@ if(XDMF_BUILD_DSM)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
# intel compiler requires an extra tag for CXX_FLAGS in order to properly build
STRING(REGEX MATCH "icpc" IS_INTEL "${CMAKE_CXX_COMPILER}")
if (NOT "${IS_INTEL}" STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPICH_IGNORE_CXX_SEEK")
# The Intel compiler requires an extra tag for CXX_FLAGS in order to properly build.
if (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_definitions(-DMPICH_IGNORE_CXX_SEEK)
endif ()
endif()
option(XDMF_BUILD_DSM_THREADS ON)
if (XDMF_WRAP_PYTHON)
mark_as_advanced(FORCE PYTHON_INCLUDE_MPI4PY_DIR)
set(PYTHON_INCLUDE_MPI4PY_DIR "" CACHE STRING "Directory containing mpi4py/mpi4py.i")
find_path(PYTHON_INCLUDE_MPI4PY_DIR
NAMES mpi4py/mpi4py.i
DOC "Directory containing the mpi4py/mpi4py.i file")
endif ()
add_definitions(-DXDMF_BUILD_DSM)
endif()
# If we are wrapping either, we need swig
if(XDMF_WRAP_PYTHON OR XDMF_WRAP_JAVA)
find_package(SWIG REQUIRED)
find_package(SWIG 2.0.0 REQUIRED)
include(${SWIG_USE_FILE})
if(${SWIG_VERSION} LESS 2.0.0)
message(SEND_ERROR "Swig must be version 2.0.0 or greater")
endif()
endif()
# If we are wrapping python, let's include it in the top level
......@@ -193,18 +146,6 @@ if(XDMF_WRAP_PYTHON)
add_dependencies(${python_name} "${ARGN}")
endif()
if(WIN32)
if(NOT MSVC10)
set_target_properties(${SWIG_MODULE_${python_name}Python_REAL_NAME}
PROPERTIES
PREFIX ../
IMPORT_PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()
if(APPLE)
set_target_properties(${SWIG_MODULE_${python_name}Python_REAL_NAME}
PROPERTIES
......@@ -265,15 +206,6 @@ if(XDMF_WRAP_JAVA)
swig_link_libraries(${java_name}Java ${java_name})
if(WIN32)
if(NOT MSVC10)
set_target_properties(${SWIG_MODULE_${java_name}Java_REAL_NAME}
PROPERTIES
PREFIX ../
IMPORT_PREFIX ../
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set(java_files *.java)
set(java_dest "bin")
set(separator "\;")
......@@ -323,11 +255,10 @@ if(XDMF_WRAP_JAVA)
endmacro()
endif()
include(GNUInstallDirs)
add_subdirectory(core)
include_directories(${XdmfCore_INCLUDE_DIRS} ${XdmfDSM_INCLUDE_DIRS})
link_directories(${XDMF_LIBRARY_DIRS})
include(GNUInstallDirs)
option(XDMF_BUILD_CORE_ONLY OFF)
mark_as_advanced(XDMF_BUILD_CORE_ONLY)
......@@ -360,26 +291,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfTopologyType
XdmfUnstructuredGrid)
if(XDMF_STATIC_AND_SHARED)
add_library(XdmfObjects OBJECT ${XdmfSources})
SET_TARGET_PROPERTIES(
XdmfObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(XdmfObjects PROPERTIES
POSITION_INDEPENDENT_CODE True)
add_library(${XDMF_LIBNAME} $<TARGET_OBJECTS:XdmfObjects>)
if (BUILD_SHARED_LIBS)
add_library(Xdmf_Static STATIC $<TARGET_OBJECTS:XdmfObjects>)
set_target_properties(
Xdmf_Static PROPERTIES
OUTPUT_NAME "Xdmf"
)
endif (BUILD_SHARED_LIBS)
else()
add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources})
endif()
add_library(${XDMF_LIBNAME} ${XdmfSources})
SET_TARGET_PROPERTIES(
${XDMF_LIBNAME} PROPERTIES
VERSION ${XDMF_VERSION}
......@@ -387,27 +299,14 @@ if(NOT XDMF_BUILD_CORE_ONLY)
)
if(XDMF_BUILD_DSM)
target_link_libraries(${XDMF_LIBNAME} XdmfCore XdmfDSM)
if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
target_link_libraries(Xdmf_Static XdmfCore_Static XdmfDSM_Static)
endif()
else(XDMF_BUILD_DSM)
target_link_libraries(${XDMF_LIBNAME} XdmfCore)
if(XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
target_link_libraries(Xdmf_Static XdmfCore_Static)
endif ()
endif(XDMF_BUILD_DSM)
if (COMMAND vtk_target_install)
vtk_target_install(${XDMF_LIBNAME})
endif()
if(WIN32)
if (BUILD_SHARED_LIBS)
set_target_properties(${XDMF_LIBNAME} PROPERTIES
DEFINE_SYMBOL XDMF_EXPORTS)
if(XDMF_STATIC_AND_SHARED)
set_target_properties(Xdmf_Static PROPERTIES
DEFINE_SYMBOL Xdmf_EXPORTS)
endif()
endif ()
endif()
......@@ -440,42 +339,17 @@ if(NOT XDMF_BUILD_CORE_ONLY)
add_subdirectory(utils)
endif()
if(WIN32)
set(XDMF_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/${XDMF_LIBNAME}.lib)
endif()
if(UNIX)
if (BUILD_SHARED_LIBS)
set(XDMF_LIBRARY ${CMAKE_INSTALL_LIBDIR}/lib${XDMF_LIBNAME}.so)
else (BUILD_SHARED_LIBS)
set(XDMF_LIBRARY ${CMAKE_INSTALL_LIBDIR}/lib${XDMF_LIBNAME}.a)
endif (BUILD_SHARED_LIBS)
endif(UNIX)
if(APPLE)
set(XDMF_LIBRARY ${CMAKE_INSTALL_LIBDIR}/lib${XDMF_LIBNAME}.dylib)
endif()
file(GLOB XdmfHeaders
"*.hpp"
"*.tpp"
"*.i"
"CMake/VersionSuite/*.hpp"
"${CMAKE_CURRENT_BINARY_DIR}/*.hpp"
)
if (NOT XDMF_INSTALL_NO_DEVELOPMENT)
install(FILES ${XdmfHeaders} DESTINATION include)
endif()
install(FILES ${XdmfHeaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS ${XDMF_LIBNAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
install(TARGETS Xdmf_Static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
if(WIN32 AND NOT CYGWIN)
......
project(XdmfCore)
cmake_minimum_required(VERSION 2.6)
if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif ()
include(CheckCXXSourceCompiles)
include(SetUpVersion)
include(TestBigEndian)
if(VERSION_CONTROL_AUTOUPDATE OR
NOT EXISTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/XdmfVersion.hpp)
NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/XdmfVersion.hpp)
VersionCreate(
"Xdmf"
"${XDMF_MAJOR_VERSION}" "${XDMF_MINOR_VERSION}" "${XDMF_PATCH_VERSION}"
......@@ -18,63 +14,21 @@ if(VERSION_CONTROL_AUTOUPDATE OR
endif()
if(BUILD_SHARED_LIBS)
set(LIBTYPE SHARED)
set(BUILD_SHARED 1)
else()
set(LIBTYPE STATIC)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#set(CMAKE_SKIP_BUILD_RPATH FALSE)
#set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
#set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(XDMF_BUILD_DSM OFF)
mark_as_advanced(XDMF_BUILD_DSM)
if(XDMF_BUILD_DSM)
option(XDMF_BUILD_DSM_THREADS ON)
endif()
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
mark_as_advanced(FORCE Boost_INCLUDE_DIR)
endif()
# Find HDF5_ROOT if not set
if ("$ENV{HDF5_ROOT}" STREQUAL "")
find_file (HDF5_LIB libhdf5.so HINTS ENV LD_LIBRARY_PATH)
if (NOT "${HDF5_LIB}" STREQUAL "")
get_filename_component(HDF5_LIBRARY_DIR "${HDF5_LIB}" PATH)
get_filename_component(HDF5_ROOT "${HDF5_LIBRARY_DIR}/../" ABSOLUTE)
set(ENV{HDF5_ROOT} ${HDF5_ROOT})
endif ()
endif ()
mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
if (NOT ("${vtkhdf5_LIBRARIES}" STREQUAL ""))
set(HDF5_LIBRARIES ${vtkhdf5_LIBRARIES})
set(HDF5_hdf5_LIBRARY_RELEASE ${vtkhdf5_LIBRARIES})
set(HDF5_INCLUDE_DIRS ${vtkhdf5_INCLUDE_DIRS})
set(HDF5_C_INCLUDE_DIR ${vtkhdf5_INCLUDE_DIRS})
set(HDF5_FOUND TRUE)
endif ()
find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR)
mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE)
include_directories(${HDF5_INCLUDE_DIRS})
include_directories(${HDF5_C_INCLUDE_DIR})
get_filename_component(HDF5_LIBRARY_DIR "${HDF5_hdf5_LIBRARY_RELEASE}" PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${HDF5_LIBRARY_DIR})
set(HDF5_LIBRARIES ${HDF5_hdf5_LIBRARY_RELEASE})
# FIXME: Would like to get this info from HDF5 so we don't have conflicting
# MPI versions
if(HDF5_IS_PARALLEL)
......@@ -82,41 +36,21 @@ if(HDF5_FOUND)
find_package(MPI REQUIRED)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
get_filename_component(MPI_LIBRARY_DIR ${MPI_LIBRARY} PATH)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} ${MPI_LIBRARY_DIR})
endif()
endif ()
endif()
get_filename_component(HDF5_ROOT "${HDF5_INCLUDE_DIR}/../" REALPATH)
set(HDF5_BINARY_DIRS ${HDF5_ROOT}/bin ${HDF5_ROOT}/dll)
if (NOT HDF5_LIBRARIES)
find_library (HDF5_LIBRARIES hdf5 HINTS ${HDF5_ROOT} ENV LD_LIBRARY_PATH)
endif ()
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${HDF5_LIBRARIES})
set(XDMF_HDF5_BINARY_DIRS ${HDF5_BINARY_DIRS} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} ${HDF5_BINARY_DIRS})
endif()
set(LIBXML2_LIBRARIES ${vtklibxml2_LIBRARIES})
set(LIBXML2_INCLUDE_DIR ${vtklibxml2_INCLUDE_DIRS})
set(LIBXML2_FOUND TRUE)
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
get_filename_component(LIBXML2_ROOT "${LIBXML2_INCLUDE_DIR}/../" REALPATH)
set(LIBXML2_BINARY_DIRS ${LIBXML2_ROOT}/bin)
set(LIBXML2_BINARY_DIRS ${LIBXML2_BINARY_DIRS} PARENT_SCOPE)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${LIBXML2_LIBRARIES})
set(XDMF_BINARIES ${XDMF_BINARIES} ${LIBXML2_BINARY_DIRS})
endif()
# Perform compile-time checks and generate XdmfCoreConfig.hpp
TEST_BIG_ENDIAN(XDMF_BIG_ENDIAN)
unset(HAVE_BOOST_SHARED_DYNAMIC_CAST CACHE)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIRS})
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
......@@ -156,7 +90,7 @@ set(XdmfCoreSources
XdmfSparseMatrix
XdmfSubset
XdmfSystemUtils
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/XdmfVersion
${CMAKE_CURRENT_BINARY_DIR}/XdmfVersion
XdmfVisitor
XdmfWriter)
......@@ -191,59 +125,33 @@ set(XdmfCoreSources
core/XdmfSubset
core/XdmfSystemUtils
${FOUND_TIFF_LOCATION}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/XdmfVersion
${CMAKE_CURRENT_BINARY_DIR}/XdmfVersion
core/XdmfVisitor
core/XdmfWriter
PARENT_SCOPE)
if (XDMF_STATIC_AND_SHARED)
add_library(XdmfCoreObjects OBJECT ${XdmfCoreSources})
SET_TARGET_PROPERTIES(
XdmfCoreObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(
XdmfCoreObjects PROPERTIES
POSITION_INDEPENDENT_CODE True
)
add_library(XdmfCore ${LIBTYPE} $<TARGET_OBJECTS:XdmfCoreObjects>)
if (BUILD_SHARED_LIBS)
add_library(XdmfCore_Static STATIC $<TARGET_OBJECTS:XdmfCoreObjects>)
set_target_properties(
XdmfCore_Static PROPERTIES
OUTPUT_NAME "XdmfCore"
)
endif (BUILD_SHARED_LIBS)
else()
add_library(XdmfCore ${LIBTYPE} ${XdmfCoreSources})
endif()
add_library(XdmfCore ${XdmfCoreSources})
SET_TARGET_PROPERTIES(
XdmfCore PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
link_directories(${XDMF_LIBRARY_DIRS})
target_link_libraries(XdmfCore ${XDMF_LIBRARIES})
if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
target_link_libraries(XdmfCore_Static ${XDMF_LIBRARIES})
endif()
if (COMMAND vtk_target_install)
vtk_target_install(XdmfCore)
endif()
target_link_libraries(XdmfCore
PUBLIC
${HDF5_C_LIBRARIES}
${LIBXML2_LIBRARIES})
if (TIFF_FOUND)
target_link_libraries(XdmfCore
PRIVATE
${TIFF_LIBRARIES})
endif ()
if(WIN32)
#add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
if (BUILD_SHARED_LIBS)
set_target_properties(XdmfCore PROPERTIES
DEFINE_SYMBOL XdmfCore_EXPORTS)
if (XDMF_STATIC_AND_SHARED)
set_target_properties(XdmfCore_Static PROPERTIES
DEFINE_SYMBOL XdmfCore_EXPORTS)
endif()
endif()
endif()
......@@ -259,26 +167,6 @@ if(XDMF_WRAP_PYTHON)
XDMF_SWIG_PYTHON(XdmfCore)
endif()
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} PARENT_SCOPE)
if(WIN32)
set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/XdmfCore.lib PARENT_SCOPE)
endif()
if(UNIX)
if (BUILD_SHARED_LIBS)
set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.so
PARENT_SCOPE)
else()
set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.a
PARENT_SCOPE)
endif()
endif()
if(APPLE)
set(XDMFCORE_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libXdmfCore.dylib
PARENT_SCOPE)
endif()
file(GLOB_RECURSE
XdmfCoreHeaders
"*.hpp" "*.tpp" "*.i"
......@@ -288,31 +176,15 @@ file(GLOB LokiHeaders loki/*.h)
set(XdmfCoreHeaders
${XdmfCoreHeaders}
${CMAKE_CURRENT_BINARY_DIR}/XdmfCoreConfig.hpp)
if (NOT XDMF_INSTALL_NO_DEVELOPMENT)
install(FILES ${XdmfCoreHeaders} DESTINATION include)
install(FILES ${LokiHeaders} DESTINATION include/loki)
endif()
install(FILES ${XdmfCoreHeaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${LokiHeaders} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/loki)
install(TARGETS XdmfCore
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
if (XDMF_STATIC_AND_SHARED AND BUILD_SHARED_LIBS)
install(TARGETS XdmfCore_Static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif ()
if (Boost_FOUND)
set(FOUND_BOOST_INCLUDES ${Boost_INCLUDE_DIRS})
set(XdmfCore_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${HDF5_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
CACHE INTERNAL "")
else ()
set(FOUND_BOOST_INCLUDES "")
endif ()
......@@ -326,9 +198,7 @@ set(XdmfCore_INCLUDE_DIRS
CACHE INTERNAL "")
set(XDMF_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include PARENT_SCOPE)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib)
set(XDMF_DIR ${CMAKE_INSTALL_PREFIX} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin)
if(XDMF_BUILD_DSM)
add_subdirectory(dsm)
......@@ -338,6 +208,3 @@ endif(XDMF_BUILD_DSM)
if(XDMF_BUILD_TESTING)
add_subdirectory(tests)
endif()
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} PARENT_SCOPE)
......@@ -37,7 +37,6 @@ class XdmfVisitor;
// Includes
#include <loki/Visitor.h>
#define vtk_libxml2_reference reference // Reversing VTK name mangling
#include <libxml/xmlexports.h>
#include <libxml/tree.h>
#include <libxml/uri.h>
......
project(XdmfDSM)
cmake_minimum_required(VERSION 2.6)
if (POLICY CMP0015)
cmake_policy(SET CMP0015 NEW)
endif ()
set(XdmfDSMLinkLibraries XdmfCore)
set(XdmfDSMLinkLibraryDir )
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
option(XDMF_BUILD_DSM_THREADS ON)
mark_as_advanced(Boost_INCLUDE_DIR)
include_directories(${Boost_INCLUDE_DIRS})
mark_as_advanced(FORCE Boost_INCLUDE_DIR)
#mark_as_advanced(CLEAR HDF5_C_INCLUDE_DIR)
#mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_DEBUG)
#mark_as_advanced(CLEAR HDF5_hdf5_LIBRARY_RELEASE)
#find_package(HDF5 REQUIRED)
if(HDF5_FOUND)
mark_as_advanced(FORCE HDF5_C_INCLUDE_DIR)
mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_DEBUG)
mark_as_advanced(FORCE HDF5_hdf5_LIBRARY_RELEASE)
include_directories(${HDF5_INCLUDE_DIRS})
include_directories(${HDF5_C_INCLUDE_DIR})
set(HDF5_LIBRARIES ${HDF5_hdf5_LIBRARY_RELEASE})
get_filename_component(HDF5_LIBRARY_DIR "${HDF5_hdf5_LIBRARY_RELEASE}" PATH)
set(XdmfDSMLinkLibraryDir ${XdmfDSMLinkLibraryDir} ${HDF5_LIBRARY_DIR})
# FIXME: Would like to get this info from HDF5 so we don't have conflicting
# MPI versions
if(HDF5_IS_PARALLEL)
# If MPI variables are already populated don't search again
if (NOT MPI_FOUND)
find_package(MPI REQUIRED)
endif (NOT MPI_FOUND)
if(MPI_FOUND)
include_directories(${MPI_INCLUDE_PATH})
set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
endif()
else()
message(SEND_ERROR
"Error: XdmfDSM requires a parallel enabled build of HDF5.")
endif()
set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${HDF5_LIBRARIES})
endif()
find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
set(XdmfDSMLinkLibraries ${XdmfDSMLinkLibraries} ${LIBXML2_LIBRARIES})
endif()
set(XdmfDSMSources
XdmfHDF5ControllerDSM
......@@ -89,65 +42,18 @@ if (XDMF_DSM_IS_CRAY)
add_definitions(-DXDMF_DSM_IS_CRAY)
endif (XDMF_DSM_IS_CRAY)
add_library(XdmfDSMObjects OBJECT ${XdmfDSMSources})
SET_TARGET_PROPERTIES(
XdmfDSMObjects PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
set_target_properties(XdmfDSMObjects PROPERTIES
POSITION_INDEPENDENT_CODE True)
add_library(XdmfDSM $<TARGET_OBJECTS:XdmfDSMObjects>)
add_library(XdmfDSM ${XdmfDSMSources})
SET_TARGET_PROPERTIES(
XdmfDSM PROPERTIES
VERSION ${XDMF_VERSION}
SOVERSION ${XDMF_MAJOR_VERSION}
)
if (BUILD_SHARED_LIBS)
add_library(XdmfDSM_Static STATIC $<TARGET_OBJECTS:XdmfDSMObjects>)
if (UNIX)
set_target_properties(XdmfDSM_Static PROPERTIES
OUTPUT_NAME "XdmfDSM")
endif (UNIX)
endif (BUILD_SHARED_LIBS)