Commit af08019b authored by Ben Boeckel's avatar Ben Boeckel

cmake: use VTK's module system

parent 34fdf55d
......@@ -5,8 +5,12 @@
# This allows you to turn on and off the auto
# update of the (project name)Version.hpp file
if (FALSE) # XXX(kitware): force settings
SET(VERSION_CONTROL_AUTOUPDATE OFF CACHE BOOL "Automaticaly Update The Version")
MARK_AS_ADVANCED(VERSION_CONTROL_AUTOUPDATE)
else ()
set(VERSION_CONTROL_AUTOUPDATE OFF)
endif ()
# We need to make sure we have the header file
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/CMake/VersionSuite)
......
if (FALSE) # XXX(kitware): use VTK's CMake policies
cmake_minimum_required(VERSION 2.8.5)
endif ()
project(Xdmf)
......@@ -8,16 +10,20 @@ if(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
endif()
if (FALSE) # XXX(kitware): force settings
set(XDMF_LIBNAME "Xdmf" CACHE STRING "Name for this xdmf library to avoid collision")
endif ()
set(XDMF_MAJOR_VERSION 3)
set(XDMF_MINOR_VERSION 0)
set(XDMF_PATCH_VERSION 0)
set(XDMF_VERSION "${XDMF_MAJOR_VERSION}.${XDMF_MINOR_VERSION}.${XDMF_PATCH_VERSION}")
if (FALSE) # XXX(kitware): VTK's module system handles output directories
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")
endif ()
if(BUILD_SHARED_LIBS)
set(BUILD_SHARED 1)
......@@ -25,12 +31,16 @@ endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/XdmfConfig.hpp)
if (FALSE) # XXX(kitware): force settings
# Enable CMake testing
option(XDMF_BUILD_TESTING "Build Tests" OFF)
if(XDMF_BUILD_TESTING)
enable_testing()
include(CTest)
endif()
else ()
set(XDMF_BUILD_TESTING OFF)
endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
......@@ -45,25 +55,40 @@ endif()
include(XdmfFunctions)
# Should we build with documentation
if (FALSE) # XXX(kitware): force settings
option(XDMF_BUILD_DOCUMENTATION OFF)
else ()
set(XDMF_BUILD_DOCUMENTATION OFF)
endif ()
if(XDMF_BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif()
if (FALSE) # XXX(kitware): force settings
# Wrapper Setup
option(XDMF_WRAP_PYTHON OFF)
option(XDMF_WRAP_JAVA OFF)
else ()
set(XDMF_WRAP_PYTHON OFF)
set(XDMF_WRAP_JAVA OFF)
endif ()
if (FALSE) # XXX(kitware): VTK's module system handles dependencies
#check for TIFF
find_package(TIFF)
if (TIFF_FOUND)
add_definitions(-DXDMF_BUILD_TIFF)
include_directories(${TIFF_INCLUDE_DIR})
endif (TIFF_FOUND)
endif ()
if (FALSE) # XXX(kitware): force settings
# Test for DSM
option(XDMF_BUILD_DSM OFF)
mark_as_advanced(XDMF_BUILD_DSM)
else ()
set(XDMF_BUILD_ON OFF)
endif ()
if(XDMF_BUILD_DSM)
find_package(MPI REQUIRED)
if(MPI_FOUND)
......@@ -260,8 +285,12 @@ include(GNUInstallDirs)
add_subdirectory(core)
include_directories(${XdmfCore_INCLUDE_DIRS} ${XdmfDSM_INCLUDE_DIRS})
if (FALSE) # XXX(kitware): force settings
option(XDMF_BUILD_CORE_ONLY OFF)
mark_as_advanced(XDMF_BUILD_CORE_ONLY)
else ()
set(XDMF_BUILD_CORE_ONLY OFF)
endif ()
if(NOT XDMF_BUILD_CORE_ONLY)
set(XdmfSources
XdmfAggregate
......@@ -291,6 +320,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
XdmfTopologyType
XdmfUnstructuredGrid)
if (FALSE)
add_library(${XDMF_LIBNAME} ${XdmfSources})
SET_TARGET_PROPERTIES(
${XDMF_LIBNAME} PROPERTIES
......@@ -302,6 +332,24 @@ if(NOT XDMF_BUILD_CORE_ONLY)
else(XDMF_BUILD_DSM)
target_link_libraries(${XDMF_LIBNAME} XdmfCore)
endif(XDMF_BUILD_DSM)
else ()
set(sources)
set(headers)
foreach (xdmf_source IN LISTS XdmfSources)
list(APPEND sources
"${xdmf_source}.cpp")
list(APPEND headers
"${xdmf_source}.hpp")
endforeach ()
vtk_module_add_module(VTK::xdmf3
SOURCES ${sources}
HEADERS ${headers}
HEADERS_SUBDIR "vtkxdmf3")
target_link_libraries(xdmf3
PUBLIC
vtkxdmfcore)
endif ()
if(WIN32)
if (BUILD_SHARED_LIBS)
......@@ -334,11 +382,16 @@ if(NOT XDMF_BUILD_CORE_ONLY)
add_subdirectory(tests)
endif()
if (FALSE) # XXX(kitware): force settings
option(XDMF_BUILD_UTILS OFF)
else ()
set(XDMF_BUILD_UTILS OFF)
endif ()
if(XDMF_BUILD_UTILS)
add_subdirectory(utils)
endif()
if (FALSE) # XXX(kitware): VTK's module system handles installation
file(GLOB XdmfHeaders
"*.hpp"
"*.tpp"
......@@ -350,6 +403,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif ()
endif()
if(WIN32 AND NOT CYGWIN)
......@@ -358,6 +412,8 @@ else()
set(DEF_INSTALL_CMAKE_DIR
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
endif()
if (FALSE) # XXX(kitware): VTK's module system handles installation
xdmf_create_config_file(${PROJECT_NAME})
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION ${DEF_INSTALL_CMAKE_DIR})
endif ()
......@@ -7,3 +7,4 @@ symbols to avoid conflicts with other copies of the library within a single
process.
* Ignore whitespace errors for VTK's commit checks.
* Integrate the CMake build with VTK's module system.
......@@ -17,9 +17,12 @@ if(BUILD_SHARED_LIBS)
set(BUILD_SHARED 1)
endif()
if (FALSE) # XXX(kitware): use target-based include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif ()
if (FALSE) # XXX(kitware): VTK's module system handles dependencies
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
......@@ -46,6 +49,12 @@ find_package(LibXml2 REQUIRED)
if(LIBXML2_FOUND)
include_directories(${LIBXML2_INCLUDE_DIR})
endif()
else ()
vtk_module_find_package(
PACKAGE Boost
FORWARD_VERSION_REQ EXACT
VERSION_VAR "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@")
endif ()
# Perform compile-time checks and generate XdmfCoreConfig.hpp
......@@ -103,6 +112,7 @@ else ()
set(FOUND_TIFF_LOCATION "")
endif()
if (FALSE) # XXX(kitware): VTK's module system handles dependencies
set(XdmfCoreSources
core/XdmfArray
core/XdmfArrayReference
......@@ -129,7 +139,9 @@ set(XdmfCoreSources
core/XdmfVisitor
core/XdmfWriter
PARENT_SCOPE)
endif ()
if (FALSE) # XXX(kitware): use VTK's module system.
add_library(XdmfCore ${XdmfCoreSources})
SET_TARGET_PROPERTIES(
XdmfCore PROPERTIES
......@@ -146,11 +158,35 @@ if (TIFF_FOUND)
PRIVATE
${TIFF_LIBRARIES})
endif ()
else ()
set(sources)
foreach (xdmf_core_source IN LISTS XdmfCoreSources)
list(APPEND sources
"${xdmf_core_source}.cpp")
endforeach ()
add_library(vtkxdmfcore ${sources})
target_include_directories(vtkxdmfcore
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../CMake/VersionSuite>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${_vtk_build_HEADERS_DESTINATION}/vtkxdfm3/core>")
target_link_libraries(vtkxdmfcore
PUBLIC
VTK::libxml2
Boost::boost
PRIVATE
VTK::hdf5)
_vtk_module_apply_properties(vtkxdmfcore)
_vtk_module_install(vtkxdmfcore)
endif ()
if(WIN32)
#add_definitions(-D_HDF5USEDLL_ -D_HDF5USEHLDLL_)
if (BUILD_SHARED_LIBS)
set_target_properties(XdmfCore PROPERTIES
# XXX(kitware): mangle the library name.
set_target_properties(vtkxdmfcore PROPERTIES
DEFINE_SYMBOL XdmfCore_EXPORTS)
endif()
endif()
......@@ -176,12 +212,21 @@ file(GLOB LokiHeaders loki/*.h)
set(XdmfCoreHeaders
${XdmfCoreHeaders}
${CMAKE_CURRENT_BINARY_DIR}/XdmfCoreConfig.hpp)
if (FALSE)
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)
else ()
vtk_module_install_headers(
FILES ${XdmfCoreHeaders}
SUBDIR "vtkxdmf3/core")
vtk_module_install_headers(
FILES ${LokiHeaders}
SUBDIR "vtkxdmf3/core/loki")
endif ()
if (Boost_FOUND)
set(FOUND_BOOST_INCLUDES ${Boost_INCLUDE_DIRS})
......
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