summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2010-05-13 16:01:50 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2010-05-13 16:01:50 (GMT)
commitae06433ab0ca13838c2762c8fad165a041d64c42 (patch)
tree72d645731c00953c3daf6dad8a1cf0dc97326943 /c++
parent940931aa853602b0b6edfd4ca1a6526fd7975dd2 (diff)
downloadhdf5-ae06433ab0ca13838c2762c8fad165a041d64c42.zip
hdf5-ae06433ab0ca13838c2762c8fad165a041d64c42.tar.gz
hdf5-ae06433ab0ca13838c2762c8fad165a041d64c42.tar.bz2
[svn-r18793] Add files to support building library with CMake
Tested: Local linux
Diffstat (limited to 'c++')
-rw-r--r--c++/CMakeLists.txt46
-rw-r--r--c++/examples/CMakeLists.txt27
-rw-r--r--c++/src/CMakeLists.txt113
-rw-r--r--c++/test/CMakeLists.txt47
4 files changed, 233 insertions, 0 deletions
diff --git a/c++/CMakeLists.txt b/c++/CMakeLists.txt
new file mode 100644
index 0000000..b1edc06
--- /dev/null
+++ b/c++/CMakeLists.txt
@@ -0,0 +1,46 @@
+cmake_minimum_required (VERSION 2.8)
+PROJECT (HDF5_CPP)
+
+#-----------------------------------------------------------------------------
+# Shared/Static Libs
+#-----------------------------------------------------------------------------
+IF (BUILD_SHARED_LIBS)
+ SET (CPP_BUILT_AS_DYNAMIC_LIB 1)
+ENDIF (BUILD_SHARED_LIBS)
+
+#-----------------------------------------------------------------------------
+# Generate configure file
+#-----------------------------------------------------------------------------
+CONFIGURE_FILE (${HDF5_SOURCE_DIR}/Resources/H5cxx_config.h.in
+ ${HDF5_BINARY_DIR}/H5cxx_pubconf.h
+)
+
+#-----------------------------------------------------------------------------
+# Setup Include directories
+#-----------------------------------------------------------------------------
+INCLUDE_DIRECTORIES (${HDF5_CPP_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES (${HDF5_BINARY_DIR})
+
+#-----------------------------------------------------------------------------
+# Parallel/MPI, prevent spurious cpp/cxx warnings
+#-----------------------------------------------------------------------------
+IF (H5_HAVE_PARALLEL)
+ ADD_DEFINITIONS ("-DMPICH_SKIP_MPICXX")
+ ADD_DEFINITIONS ("-DMPICH_IGNORE_CXX_SEEK")
+ENDIF (H5_HAVE_PARALLEL)
+
+ADD_SUBDIRECTORY (${HDF5_CPP_SOURCE_DIR}/src ${HDF5_CPP_BINARY_DIR}/src)
+
+#-----------------------------------------------------------------------------
+# Build the CPP Examples
+#-----------------------------------------------------------------------------
+IF (HDF5_BUILD_EXAMPLES)
+ ADD_SUBDIRECTORY (${HDF5_CPP_SOURCE_DIR}/examples ${HDF5_CPP_BINARY_DIR}/examples)
+ENDIF (HDF5_BUILD_EXAMPLES)
+
+#-----------------------------------------------------------------------------
+# Build the CPP unit tests
+#-----------------------------------------------------------------------------
+IF (BUILD_TESTING)
+ ADD_SUBDIRECTORY (${HDF5_CPP_SOURCE_DIR}/test ${HDF5_CPP_BINARY_DIR}/test)
+ENDIF (BUILD_TESTING)
diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt
new file mode 100644
index 0000000..1a9602a
--- /dev/null
+++ b/c++/examples/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required (VERSION 2.8)
+# --------------------------------------------------------------------
+# Notes: When creating examples they should be prefixed
+# with "cpp_ex_". This allows for easier filtering of the examples.
+# --------------------------------------------------------------------
+
+PROJECT (HDF5_CPP_EXAMPLES)
+
+#-----------------------------------------------------------------------------
+# Define examples
+#-----------------------------------------------------------------------------
+
+SET (examples
+ create
+ readdata
+ writedata
+ compound
+ extend_ds
+ chunks
+ h5group
+)
+
+FOREACH (example ${examples})
+ ADD_EXECUTABLE (cpp_ex_${example} ${HDF5_CPP_EXAMPLES_SOURCE_DIR}/${example}.cpp)
+ H5_NAMING (cpp_ex_${example})
+ TARGET_LINK_LIBRARIES (cpp_ex_${example} ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET})
+ENDFOREACH (example ${examples})
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
new file mode 100644
index 0000000..3658e57
--- /dev/null
+++ b/c++/src/CMakeLists.txt
@@ -0,0 +1,113 @@
+cmake_minimum_required (VERSION 2.8)
+PROJECT (HDF5_CPP_SRC)
+
+#-----------------------------------------------------------------------------
+# Shared/Static Libs
+#-----------------------------------------------------------------------------
+IF (BUILD_SHARED_LIBS)
+ SET (CPP_BUILT_AS_DYNAMIC_LIB 1)
+ENDIF (BUILD_SHARED_LIBS)
+
+#-----------------------------------------------------------------------------
+# Generate configure file
+#-----------------------------------------------------------------------------
+CONFIGURE_FILE (${HDF5_SOURCE_DIR}/Resources/H5cxx_config.h.in
+ ${HDF5_BINARY_DIR}/H5cxx_pubconf.h
+)
+
+#-----------------------------------------------------------------------------
+# Define cpp Library
+#-----------------------------------------------------------------------------
+SET (CPP_SRCS
+ ${HDF5_CPP_SOURCE_DIR}/src/H5AbstractDs.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5ArrayType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5AtomType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Attribute.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5CommonFG.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5CompType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DataSet.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DataSpace.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DataType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DcreatProp.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DxferProp.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5EnumType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Exception.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5FaccProp.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5FcreatProp.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5File.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5FloatType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Group.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5IdComponent.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5IntType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Library.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Object.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5PredType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5PropList.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5StrType.cpp
+ ${HDF5_CPP_SOURCE_DIR}/src/H5VarLenType.cpp
+)
+
+SET (CPP_HDRS
+ ${HDF5_CPP_SOURCE_DIR}/src/H5AbstractDs.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Alltypes.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5ArrayType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5AtomType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Attribute.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Classes.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5CommonFG.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5CompType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Cpp.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5CppDoc.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DataSet.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DataSpace.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DataType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DcreatProp.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5DxferProp.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5EnumType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Exception.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5FaccProp.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5FcreatProp.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5File.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5FloatType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Group.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5IdComponent.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Include.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5IntType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Library.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5Object.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5PredType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5PropList.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5StrType.h
+ ${HDF5_CPP_SOURCE_DIR}/src/H5VarLenType.h
+)
+
+ADD_LIBRARY (${HDF5_CPP_LIB_TARGET} ${LIB_TYPE} ${CPP_SRCS} ${CPP_HDRS})
+TARGET_LINK_LIBRARIES (${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET})
+SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIB_TARGET}")
+H5_SET_LIB_OPTIONS (${HDF5_CPP_LIB_TARGET} ${HDF5_CPP_LIB_NAME} ${LIB_TYPE})
+
+#-----------------------------------------------------------------------------
+# Add file(s) to CMake Install
+#-----------------------------------------------------------------------------
+INSTALL (
+ FILES
+ ${CPP_HDRS}
+ DESTINATION
+ include/cpp
+)
+
+#-----------------------------------------------------------------------------
+# Add Target(s) to CMake Install for import into other projects
+#-----------------------------------------------------------------------------
+IF (HDF5_EXPORTED_TARGETS)
+ INSTALL (
+ TARGETS
+ ${HDF5_CPP_LIB_TARGET}
+ EXPORT
+ ${HDF5_EXPORTED_TARGETS}
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin
+ )
+ENDIF (HDF5_EXPORTED_TARGETS)
+
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
new file mode 100644
index 0000000..ac72772
--- /dev/null
+++ b/c++/test/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required (VERSION 2.8)
+# --------------------------------------------------------------------
+# Notes: When creating unit test executables they should be prefixed
+# with "cpp_". This allows for easier filtering of the test suite when
+# using ctest. An example would be
+# ctest -R cpp_
+# which would only run the C++ based unit tests.
+# --------------------------------------------------------------------
+
+PROJECT (HDF5_CPP_TEST)
+
+#-----------------------------------------------------------------------------
+# Define Sources
+#-----------------------------------------------------------------------------
+SET (CPP_TEST_SRCS
+ ${HDF5_CPP_TEST_SOURCE_DIR}/testhdf5.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tattr.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tcompound.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tfile.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tfilter.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/th5s.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tlinks.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/trefer.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/ttypes.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/tvlstr.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/dsets.cpp
+ ${HDF5_CPP_TEST_SOURCE_DIR}/h5cpputil.cpp
+)
+
+#-----------------------------------------------------------------------------
+# Generate the H5srcdir_str.h file containing user settings needed by compilation
+#-----------------------------------------------------------------------------
+SET (srcdir ${CMAKE_CURRENT_SOURCE_DIR})
+CONFIGURE_FILE (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY)
+INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR})
+
+INCLUDE_DIRECTORIES (${HDF5_TEST_SOURCE_DIR} )
+
+ADD_EXECUTABLE (cpp_testhdf5 ${CPP_TEST_SRCS} )
+H5_NAMING (cpp_testhdf5)
+TARGET_LINK_LIBRARIES (cpp_testhdf5
+ ${HDF5_CPP_LIB_TARGET}
+ ${HDF5_LIB_TARGET}
+ ${HDF5_TEST_LIB_TARGET}
+)
+
+ADD_TEST (NAME cpp_testhdf5 COMMAND $<TARGET_FILE:cpp_testhdf5>)