From 449373deb3dba60b52964cbd86ebe0021d019cfb Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 3 Dec 2010 17:26:37 -0500 Subject: [svn-r19870] Add tests for examples. Tested: local linux --- c++/examples/CMakeLists.txt | 4 ++- config/cmake/FindHDF5.cmake | 60 ++++++++++++++++++++++--------- config/cmake/hdf5-config.cmake.build.in | 5 +++ config/cmake/hdf5-config.cmake.install.in | 5 +++ examples/CMakeLists.txt | 12 +++++++ fortran/examples/CMakeLists.txt | 10 ++++++ hl/c++/examples/CMakeLists.txt | 44 +++++++++++------------ hl/examples/CMakeLists.txt | 34 ++++++++++++++++++ hl/fortran/examples/CMakeLists.txt | 5 +++ 9 files changed, 139 insertions(+), 40 deletions(-) diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt index a650db5..053cbd5 100644 --- a/c++/examples/CMakeLists.txt +++ b/c++/examples/CMakeLists.txt @@ -26,6 +26,8 @@ FOREACH (example ${examples}) TARGET_WIN_PROPERTIES (cpp_ex_${example}) TARGET_LINK_LIBRARIES (cpp_ex_${example} ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) - ADD_TEST (NAME cpp_ex_${example} COMMAND $) + IF (BUILD_TESTING) + ADD_TEST (NAME cpp_ex_${example} COMMAND $) + ENDIF (BUILD_TESTING) ENDFOREACH (example ${examples}) diff --git a/config/cmake/FindHDF5.cmake b/config/cmake/FindHDF5.cmake index 4e448ca..3c3f6d6 100644 --- a/config/cmake/FindHDF5.cmake +++ b/config/cmake/FindHDF5.cmake @@ -15,11 +15,12 @@ # HDF5_VERSION_MINOR - minor part (e.g. 5) # # The following boolean vars will be defined -# HDF5_ENABLE_PARALLEL - 1 if HDF5 parallel supported -# HDF5_BUILD_FORTRAN - 1 if HDF5 was compiled with fortran on -# HDF5_BUILD_CPP_LIB - 1 if HDF5 was compiled with cpp on -# HDF5_BUILD_TOOLS - 1 if HDF5 was compiled with tools on -# HDF5_BUILD_HL_LIB - 1 if HDF5 was compiled with parallel on +# HDF5_ENABLE_PARALLEL - 1 if HDF5 parallel supported +# HDF5_BUILD_FORTRAN - 1 if HDF5 was compiled with fortran on +# HDF5_BUILD_CPP_LIB - 1 if HDF5 was compiled with cpp on +# HDF5_BUILD_TOOLS - 1 if HDF5 was compiled with tools on +# HDF5_BUILD_HL_LIB - 1 if HDF5 was compiled with high level on +# HDF5_BUILD_HL_CPP_LIB - 1 if HDF5 was compiled with high level and cpp on # # Target names that are valid (depending on enabled options) # will be the following @@ -35,22 +36,49 @@ # hdf5_hl_cpp : High Level cpp interface library # # To aid in finding HDF5 as part of a subproject set -# HDF5_ROOT_DIR_HINT to the location where HDF5-config.cmake lies +# HDF5_ROOT_DIR_HINT to the location where hdf5-config.cmake lies -FIND_PATH (HDF5_ROOT_DIR "HDF5-config.cmake" - ${HDF5_ROOT_DIR_HINT} - /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 - "C:/Program Files/HDF5/lib" +INCLUDE (SelectLibraryConfigurations) +INCLUDE (FindPackageHandleStandardArgs) + +# The HINTS option should only be used for values computed from the system. +SET (_HDF5_HINTS + $ENV{HOME}/.local + $ENV{HDF5_ROOT} + $ENV{HDF5_ROOT_DIR_HINT} +) +# Hard-coded guesses should still go in PATHS. This ensures that the user +# environment can always override hard guesses. +SET (_HDF5_PATHS + $ENV{HOME}/.local + $ENV{HDF5_ROOT} + $ENV{HDF5_ROOT_DIR_HINT} + /usr/lib/hdf5 + /usr/share/hdf5 + /usr/local/hdf5 + /usr/local/hdf5/share ) -FIND_PATH (HDF5_INCLUDE_DIR "H5public.h" - ${HDF5_ROOT_DIR}/../include +FIND_PATH (HDF5_ROOT_DIR "hdf5-config.cmake" + HINTS ${_HDF5_HINTS} + PATHS ${_HDF5_PATHS} + PATH_SUFFIXES + lib/cmake/hdf5-1.8.6 ) +FIND_PATH (HDF5_INCLUDE_DIRS "H5public.h" + HINTS ${_HDF5_HINTS} + PATHS ${_HDF5_PATHS} + PATH_SUFFIXES + include + Include +) + +# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of +# HDF5_INCLUDE_DIRS +SET ( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) + IF (HDF5_INCLUDE_DIR) SET (HDF5_FOUND "YES") - INCLUDE (${HDF5_ROOT_DIR}/HDF5-config.cmake) + INCLUDE (${HDF5_ROOT_DIR}/hdf5-config.cmake) ENDIF (HDF5_INCLUDE_DIR) diff --git a/config/cmake/hdf5-config.cmake.build.in b/config/cmake/hdf5-config.cmake.build.in index 32bab7c..9c8aec3 100644 --- a/config/cmake/hdf5-config.cmake.build.in +++ b/config/cmake/hdf5-config.cmake.build.in @@ -11,6 +11,7 @@ SET (HDF5_BUILD_FORTRAN @HDF5_BUILD_FORTRAN@) SET (HDF5_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@) SET (HDF5_BUILD_TOOLS @HDF5_BUILD_TOOLS@) SET (HDF5_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@) +SET (HDF5_BUILD_HL_CPP_LIB @HDF5_BUILD_HL_CPP_LIB@) #----------------------------------------------------------------------------- # Directories @@ -29,6 +30,10 @@ IF (HDF5_BUILD_HL_LIB) SET (HDF5_INCLUDE_DIR_HL ${HDF5_INCLUDE_DIR} ) ENDIF (HDF5_BUILD_HL_LIB) +IF (HDF5_BUILD_HL_CPP_LIB) + SET (HDF5_INCLUDE_DIR_HL_CPP ${HDF5_INCLUDE_DIR} ) +ENDIF (HDF5_BUILD_HL_CPP_LIB) + IF (HDF5_BUILD_TOOLS) SET (HDF5_INCLUDE_DIR_TOOLS ${HDF5_INCLUDE_DIR} ) ENDIF (HDF5_BUILD_TOOLS) diff --git a/config/cmake/hdf5-config.cmake.install.in b/config/cmake/hdf5-config.cmake.install.in index ba5ba9a..8a1bffb 100644 --- a/config/cmake/hdf5-config.cmake.install.in +++ b/config/cmake/hdf5-config.cmake.install.in @@ -11,6 +11,7 @@ SET (HDF5_BUILD_FORTRAN @HDF5_BUILD_FORTRAN@) SET (HDF5_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@) SET (HDF5_BUILD_TOOLS @HDF5_BUILD_TOOLS@) SET (HDF5_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@) +SET (HDF5_BUILD_HL_CPP_LIB @HDF5_BUILD_HL_CPP_LIB@) #----------------------------------------------------------------------------- # Directories @@ -25,6 +26,10 @@ IF (HDF5_BUILD_CPP_LIB) SET (HDF5_INCLUDE_DIR_CPP "@CMAKE_INSTALL_PREFIX@/include/cpp" ) ENDIF (HDF5_BUILD_CPP_LIB) +IF (HDF5_BUILD_HL_CPP_LIB) + SET (HDF5_INCLUDE_DIR_HL_CPP "@CMAKE_INSTALL_PREFIX@/include/hl/cpp" ) +ENDIF (HDF5_BUILD_HL_CPP_LIB) + IF (HDF5_BUILD_HL_LIB) SET (HDF5_INCLUDE_DIR_HL "@CMAKE_INSTALL_PREFIX@/include/hl" ) ENDIF (HDF5_BUILD_HL_LIB) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71eaa34..4ea3f86 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -27,11 +27,23 @@ FOREACH (example ${examples}) H5_NAMING (${example}) TARGET_WIN_PROPERTIES (${example}) TARGET_LINK_LIBRARIES (${example} ${HDF5_LIB_TARGET}) + + IF (BUILD_TESTING) + ADD_TEST (NAME ${example} COMMAND $) + ENDIF (BUILD_TESTING) ENDFOREACH (example ${examples}) +IF (BUILD_TESTING) + FILE (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w) +ENDIF (BUILD_TESTING) + IF (H5_HAVE_PARALLEL) ADD_EXECUTABLE (ph5example ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c) H5_NAMING (ph5example) TARGET_WIN_PROPERTIES (ph5example) TARGET_LINK_LIBRARIES (ph5example ${HDF5_LIB_TARGET}) + + IF (BUILD_TESTING) + ADD_TEST (NAME ph5example COMMAND $) + ENDIF (BUILD_TESTING) ENDIF (H5_HAVE_PARALLEL) diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 6fe6cc7..0b36d03 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -50,6 +50,11 @@ FOREACH (example ${examples}) ${HDF5_LIB_TARGET} ) SET_TARGET_PROPERTIES (f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran) + + IF (BUILD_TESTING) + ADD_TEST (NAME f90_ex_${example} COMMAND $) + ENDIF (BUILD_TESTING) + ENDFOREACH (example ${examples}) IF (H5_HAVE_PARALLEL) @@ -67,4 +72,9 @@ IF (H5_HAVE_PARALLEL) ${HDF5_LIB_TARGET} ) SET_TARGET_PROPERTIES (f90_ex_ph5example PROPERTIES LINKER_LANGUAGE Fortran) + + IF (BUILD_TESTING) + ADD_TEST (NAME f90_ex_ph5example COMMAND $) + ENDIF (BUILD_TESTING) + ENDIF (H5_HAVE_PARALLEL) diff --git a/hl/c++/examples/CMakeLists.txt b/hl/c++/examples/CMakeLists.txt index 23b0db3..1e9682c 100644 --- a/hl/c++/examples/CMakeLists.txt +++ b/hl/c++/examples/CMakeLists.txt @@ -10,29 +10,27 @@ INCLUDE_DIRECTORIES (${HDF5_HL_CPP_SRC_DIR}/src) # -------------------------------------------------------------------- # Add in the examples for the Packet Table codes # -------------------------------------------------------------------- -IF (HDF5_BUILD_EXAMPLES) - ADD_EXECUTABLE (ptExampleFL ${HDF5_HL_CPP_EXAMPLES_SOURCE_DIR}/ptExampleFL.cpp) - H5_NAMING (ptExampleFL) - TARGET_WIN_PROPERTIES (ptExampleFL) - TARGET_LINK_LIBRARIES ( - ptExampleFL - ${HDF5_HL_CPP_LIB_TARGET} - ${HDF5_HL_LIB_TARGET} - ${HDF5_LIB_TARGET} - ) +ADD_EXECUTABLE (ptExampleFL ${HDF5_HL_CPP_EXAMPLES_SOURCE_DIR}/ptExampleFL.cpp) +H5_NAMING (ptExampleFL) +TARGET_WIN_PROPERTIES (ptExampleFL) +TARGET_LINK_LIBRARIES ( + ptExampleFL + ${HDF5_HL_CPP_LIB_TARGET} + ${HDF5_HL_LIB_TARGET} + ${HDF5_LIB_TARGET} +) - ADD_TEST (NAME cpp_hl_ex_ptExampleFL COMMAND $) - - ADD_EXECUTABLE (ptExampleVL ${HDF5_HL_CPP_EXAMPLES_SOURCE_DIR}/ptExampleVL.cpp) - H5_NAMING (ptExampleVL) - TARGET_WIN_PROPERTIES (ptExampleVL) - TARGET_LINK_LIBRARIES ( - ptExampleVL - ${HDF5_HL_CPP_LIB_TARGET} - ${HDF5_HL_LIB_TARGET} - ${HDF5_LIB_TARGET} - ) +ADD_EXECUTABLE (ptExampleVL ${HDF5_HL_CPP_EXAMPLES_SOURCE_DIR}/ptExampleVL.cpp) +H5_NAMING (ptExampleVL) +TARGET_WIN_PROPERTIES (ptExampleVL) +TARGET_LINK_LIBRARIES ( + ptExampleVL + ${HDF5_HL_CPP_LIB_TARGET} + ${HDF5_HL_LIB_TARGET} + ${HDF5_LIB_TARGET} +) +IF (BUILD_TESTING) + ADD_TEST (NAME cpp_hl_ex_ptExampleFL COMMAND $) ADD_TEST (NAME cpp_hl_ex_ptExampleVL COMMAND $) - -ENDIF (HDF5_BUILD_EXAMPLES) +ENDIF (BUILD_TESTING) diff --git a/hl/examples/CMakeLists.txt b/hl/examples/CMakeLists.txt index 227f066..b229aa9 100644 --- a/hl/examples/CMakeLists.txt +++ b/hl/examples/CMakeLists.txt @@ -1,6 +1,20 @@ cmake_minimum_required (VERSION 2.8) PROJECT (HDF5_HL_EXAMPLES ) +SET (HDF5_TEST_FILES +) + +FOREACH (h5_file ${HDF5_TEST_FILES}) + SET (dest "${PROJECT_BINARY_DIR}/${h5_file}") + #MESSAGE (STATUS " Copying ${h5_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5dump + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/${h5_file} ${dest} + ) +ENDFOREACH (h5_file ${HDF5_TEST_FILES}) + #----------------------------------------------------------------------------- # Define Sources #----------------------------------------------------------------------------- @@ -32,6 +46,26 @@ FOREACH (example ${examples}) H5_NAMING (hl_ex_${example}) TARGET_WIN_PROPERTIES (hl_ex_${example}) TARGET_LINK_LIBRARIES (hl_ex_${example} ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) + + IF (BUILD_TESTING) + ADD_TEST (NAME hl_ex_${example} COMMAND $) + ENDIF (BUILD_TESTING) ENDFOREACH (example ${examples}) +IF (BUILD_TESTING) + SET (HDF5_TEST_FILES + image24pixel.txt + image8.txt + ) + FOREACH (h5_file ${HDF5_TEST_FILES}) + SET (dest "${PROJECT_BINARY_DIR}/${h5_file}") + #MESSAGE (STATUS " Copying ${h5_file}") + ADD_CUSTOM_COMMAND ( + TARGET hl_ex_ex_ds1 + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${PROJECT_SOURCE_DIR}/${h5_file} ${dest} + ) + ENDFOREACH (h5_file ${HDF5_TEST_FILES}) +ENDIF (BUILD_TESTING) diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index 5e20da3..7f1dec5 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -26,4 +26,9 @@ FOREACH (example ${examples}) ${HDF5_LIB_TARGET} ) SET_TARGET_PROPERTIES (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran) + + IF (BUILD_TESTING) + ADD_TEST (NAME hl_f90_ex_${example} COMMAND $) + ENDIF (BUILD_TESTING) + ENDFOREACH (example ${examples}) -- cgit v0.12