Skip to content

Commit

Permalink
Fixed some strange behavior in FindHDF4.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenwintersberger committed Dec 10, 2015
1 parent 23100e6 commit 30cb237
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 65 deletions.
36 changes: 25 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ set (NXLTVERSINFO "${NEXUS_VERSION_MAJOR}:${NEXUS_VERSION_MINOR}:${NEXUS_VERSION
#-----------------------------------------------------------------------------
# define command line options by which the user can configure the build
#-----------------------------------------------------------------------------
option(ENABLE_HDF5 "Build with HDF5 support" ON)
option(ENABLE_HDF4 "Build with HDF4 support" OFF)
option(ENABLE_MXML "Build with XML support" OFF)
option(ENABLE_CONTRIB "Build the user contributions" OFF)
option(ENABLE_HDF5 "Build with HDF5 support" ON)
option(ENABLE_HDF4 "Build with HDF4 support" OFF)
option(ENABLE_MXML "Build with XML support" OFF)
option(ENABLE_CONTRIB "Build the user contributions" OFF)
option(ENABLE_FORTRAN90 "Build the Fortran 90 bindings" OFF)
option(ENABLE_FORTRAN77 "Build the Fortran 77 bindings" OFF)
option(ENABLE_JAVA "Build Java bindings" OFF)
Expand Down Expand Up @@ -125,6 +125,9 @@ include(FindPkgConfig)
#------------------------------------------------------------------------------
set(NAPI_LINK_LIBS)

#------------------------------------------------------------------------------
# if requested by the user - check for MXMLlibraries
#------------------------------------------------------------------------------
if(ENABLE_MXML)
include(FindMXML)
# the required libraries are appended to
Expand All @@ -135,11 +138,14 @@ else()
message(STATUS "Build without MXML support!")
endif()

#------------------------------------------------------------------------------
# if requested by the user - check for HDF4 libraries
#------------------------------------------------------------------------------
if(ENABLE_HDF4)
include(FindHDF4)

message(STATUS "HDF4 library found in: ${HDF4_LIBRARY_DIR}")
message(STATUS "HDF4 headers found in: ${HDF4_INCLUDE_DIR}")
message(STATUS "HDF4 library found in: ${HDF4_LIBRARY_DIRS}")
message(STATUS "HDF4 headers found in: ${HDF4_INCLUDE_DIRS}")

# the required libraries are appended to
# NAPI_LINK_LIBS by this module
Expand All @@ -148,6 +154,9 @@ else()
message(STATUS "Build without HDF4 support!")
endif()

#------------------------------------------------------------------------------
# if requested by the user - check for HDF5 libraries
#------------------------------------------------------------------------------
if(ENABLE_HDF5)

message (STATUS "${HDF5_COMPONENTS}")
Expand All @@ -172,6 +181,11 @@ else()
message(STATUS "Build without HDF5 support!")
endif()

message(STATUS "Link with: ${NAPI_LINK_LIBS}")

#------------------------------------------------------------------------------
# enable FORTRAN bindings if requested by the user
#------------------------------------------------------------------------------
if(ENABLE_FORTRAN90 OR ENABLE_FORTRAN77)
enable_language(Fortran)
endif()
Expand Down Expand Up @@ -222,11 +236,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NX_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NX_CFLAGS}")

# Recurse into the subdirectories.
add_subdirectory (include)
add_subdirectory (src)
add_subdirectory (test)
add_subdirectory (bindings)
add_subdirectory (scripts)
add_subdirectory (include) #install header files
add_subdirectory (src) #build the binaries
add_subdirectory (test) #build the tests
add_subdirectory (bindings) #build the language bindings
add_subdirectory (scripts) #install pkg-config files

#on user request utility applications will be built
if(ENABLE_APPS)
Expand Down
58 changes: 29 additions & 29 deletions cmake_include/FindHDF4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,45 @@
#
#=============================================================================

<<<<<<< HEAD
find_library(HDF4_LIBRARIES NAMES df mfhdf PATH_SUFFIXES hdf)
find_library(HDF4_DF_LIBRARY NAMES df PATH_SUFFIXES hdf)
find_library(HDF4_MFHDF_LIBRARY NAMES mfhdf PATH_SUFFIXES hdf)
message(STATUS "DF library found: ${HDF4_DF_LIBRARY}")
message(STATUS "MFHDF library found: ${HDF4_MFHDF_LIBRARY}")

message(STATUS "HDF4 libraries: ${HDF4_LIBRARIES}")
=======
set(HDF4_LIBRARIES df mfhdf)

#------------------------------------------------------------------------------
# find the runtime binaries of the HDF4 library
#------------------------------------------------------------------------------
find_library(HDF4_LIBRARIES NAMES df mfhdf
find_library(HDF4_DF_LIBRARY NAMES df hdf
HINTS ENV HDF4_ROOT
PATH_SUFFIXES hdf)


if(HDF4_DF_LIBRARY MATCHES HDF4_DF_LIBRARY-NOTFOUND)
message(FATAL_ERROR "Could not find HDF4 DF library!")
else()
get_filename_component(HDF4_LIBRARY_DIRS ${HDF4_DF_LIBRARY} PATH)
message(STATUS "Found HDF4 DF library: ${HDF4_DF_LIBRARY}")
message(STATUS "HDF4 libary path: ${HDF4_LIBRARY_DIRS}")
endif()

find_library(HDF4_MFHDF_LIBRARY NAMES mfhdf
HINTS ENV HDF4_ROOT
PATH_SUFFIXES hdf)

find_library(_HDF4_DF_LIBRARY NAMES df hdf
HINTS ENV
HDF4_ROOT PATH_SUFFIXES hdf)
>>>>>>> 336bba8dd4b92aa97c0684b1285f94d575b23f8a
if(HDF4_MFHDF_LIBRARY MATCHES HDF4_MFHDF_LIBRARY-NOTFOUND)
message(FATAL_ERROR "Could not find HDF5 MFHDF library!")
else()
message(STATUS "Found HDF4 MFHDF library: ${HDF4_MFHDF_LIBRARY}")
endif()

#if the binaries have been found their parent directory has to be
#extracted from the total path
get_filename_component(HDF4_LIBRARY_DIRS ${_HDF4_DF_LIBRARY} PATH)

#------------------------------------------------------------------------------
# find the HDF4 header file
#------------------------------------------------------------------------------
find_path (HDF4_INCLUDE_DIR mfhdf.h HINTS ENV HDF4_ROOT PATH_SUFFIXES hdf)

include ( FindPackageHandleStandardArgs )
find_package_handle_standard_args( HDF4 DEFAULT_MSG HDF4_LIBRARIES HDF4_INCLUDE_DIR )

if(NOT HDF4_FOUND)
#the user has explicitely requested HDF4 support but the required libraries
#could not be found
message(FATAL_ERROR "User requested HDF4 not found!")
find_path(HDF4_INCLUDE_DIRS mfhdf.h
HINTS ENV HDF4_ROOT
PATH_SUFFIXES hdf)

if(HDF4_INCLUDE_DIRS MATCHES HDF4_INCLUDE_DIRS-NOTFOUND)
message(FATAL_ERROR "Could not find HDF4 header files")
else()
message(STATUS "Found HDF4 header files in: ${HDF4_INCLUDE_DIRS}")
endif()

#------------------------------------------------------------------------------
Expand All @@ -74,6 +74,6 @@ find_package(JPEG REQUIRED)
#------------------------------------------------------------------------------
# add libraries to the link list for NAPI
#------------------------------------------------------------------------------
list(APPEND NAPI_LINK_LIBS ${_HDF4_DF_LIBRARY} mfhdf jpeg)
include_directories ( SYSTEM ${HDF4_INCLUDE_DIR} )
list(APPEND NAPI_LINK_LIBS ${HDF4_DF_LIBRARY} ${HDF4_MFHDF_LIBRARY} jpeg)
include_directories ( SYSTEM ${HDF4_INCLUDE_DIRS} )
link_directories(${HDF4_LIBRARY_DIRS})
40 changes: 15 additions & 25 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,16 @@ link_directories(${HDF5_LIBRARY_DIRS}
#------------------------------------------------------------------------------
if(WITH_HDF5)
add_executable(napi_test_hdf5 napi_test.c)
target_link_libraries(napi_test_hdf5 NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test_hdf5 NeXus_Shared_Library)
add_test(NAME "NAPI-C-HDF5-test" COMMAND napi_test_hdf5)
add_executable(napi_attra_test_hdf5 napi_attra_test.c)
target_link_libraries(napi_attra_test_hdf5 NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_attra_test_hdf5 NeXus_Shared_Library)
add_test(NAME "NAPI-C-HDF5-attra-test" COMMAND napi_attra_test_hdf5)
endif()

if(WITH_HDF4)
add_executable(napi_test_hdf4 napi_test.c)
target_link_libraries(napi_test_hdf4 NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test_hdf4 NeXus_Shared_Library)
add_test(NAME "NAPI-C-HDF4-test"
COMMAND napi_test_hdf4)
add_executable(napi_attra_test_hdf4 napi_attra_test.c)
Expand All @@ -65,18 +62,17 @@ endif()

if(WITH_MXML)
add_executable(napi_test-xml napi_test.c)
target_link_libraries(napi_test-xml NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test-xml NeXus_Shared_Library)
add_test(NAME "NAPI-C-MXML-test"
COMMAND napi_test-xml)

add_executable(napi_test-xml-table napi_test.c)
target_link_libraries(napi_test-xml-table NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test-xml-table NeXus_Shared_Library)
add_test(NAME "NAPI-C-MXML-TABLE-test"
COMMAND napi_test-xml-table)

add_executable(napi_attra_test_xml napi_attra_test.c)
target_link_libraries(napi_attra_test_xml NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_attra_test_xml NeXus_Shared_Library)
add_test(NAME "NAPI-C-MXML-attra-test" COMMAND napi_attra_test_xml)
set_tests_properties("NAPI-C-MXML-attra-test" PROPERTIES WILL_FAIL TRUE)
endif()
Expand All @@ -85,16 +81,15 @@ endif()
# (most probably a) regression test
#------------------------------------------------------------------------------
add_executable(leak_test1 leak_test1.c)
target_link_libraries(leak_test1 NeXus_Shared_Library ${NAPI_LINK_LIBS})
target_link_libraries(leak_test1 NeXus_Shared_Library)
add_test(NAME "NAPI-C-leak-test-1"
COMMAND leak_test1)

#------------------------------------------------------------------------------
# Add test for unlimited dimensions
#------------------------------------------------------------------------------
add_executable(test_nxunlimited test_nxunlimited.c)
target_link_libraries(test_nxunlimited NeXus_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(test_nxunlimited NeXus_Shared_Library)
add_test(NAME "NAPI-C-test-nxunlimited"
COMMAND test_nxunlimited)

Expand All @@ -108,22 +103,19 @@ if(ENABLE_CXX)

if(WITH_HDF5)
add_executable(napi_test_cpp-hdf5 napi_test_cpp.cxx)
target_link_libraries(napi_test_cpp-hdf5 NeXus_CPP_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test_cpp-hdf5 NeXus_CPP_Shared_Library)
add_test(NAME "NAPI-C++-HDF5-test" COMMAND napi_test_cpp-hdf5)
endif()

if(WITH_HDF4)
add_executable(napi_test_cpp-hdf4 napi_test_cpp.cxx)
target_link_libraries(napi_test_cpp-hdf4 NeXus_CPP_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test_cpp-hdf4 NeXus_CPP_Shared_Library)
add_test(NAME "NAPI-C++-HDF4-test" COMMAND napi_test_cpp-hdf4)
endif()

if(WITH_MXML)
add_executable(napi_test_cpp-xml napi_test_cpp.cxx)
target_link_libraries(napi_test_cpp-xml NeXus_CPP_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(napi_test_cpp-xml NeXus_CPP_Shared_Library)
add_test(NAME "NAPI-C++-MXML-test" COMMAND napi_test_cpp-xml)

# add_executable(napi_test_cpp-xml-table napi_test_cpp.cxx)
Expand All @@ -137,14 +129,12 @@ if(ENABLE_CXX)
# build leak tests
#--------------------------------------------------------------------------
add_executable(leak_test2 leak_test2.cxx)
target_link_libraries(leak_test2 NeXus_CPP_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(leak_test2 NeXus_CPP_Shared_Library)
add_test(NAME "NAPI-C++-leak-test-2"
COMMAND leak_test2)

add_executable(leak_test3 leak_test3.cxx)
target_link_libraries(leak_test3 NeXus_CPP_Shared_Library
${NAPI_LINK_LIBS})
target_link_libraries(leak_test3 NeXus_CPP_Shared_Library)
add_test(NAME "NAPI-C++-leak-test-3"
COMMAND leak_test3)
endif()
Expand Down

0 comments on commit 30cb237

Please sign in to comment.