Skip to content

Commit

Permalink
Merge pull request #113 from sigurdstorve/improve-cmake-hdf5
Browse files Browse the repository at this point in the history
Improve cmake hdf5
  • Loading branch information
sigurdstorve committed Dec 27, 2016
2 parents aaf3187 + 39e5a62 commit 97b63f2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
15 changes: 6 additions & 9 deletions src/CMakeLists.txt
Expand Up @@ -34,15 +34,12 @@ include_directories(${PROJECT_SOURCE_DIR})
find_package(Boost REQUIRED)

if (BCSIM_BUILD_UTILS OR BCSIM_BUILD_QT5_GUI)
# Note: Using the new-style find_package() from HDF5 which
# makes available imported targets.
# Then it is no longer needed to do manually do include_directories()
find_package(HDF5 REQUIRED)
if (NOT TARGET hdf5-shared)
message(FATAL_ERROR "Imported target hdf5-shared is not available")
endif()
if (NOT TARGET hdf5_cpp-shared)
message(FATAL_ERROR "Imported target hdf5_cpp-shared is not available")
# Note: Prefer the new-style find_package() for HDF5 which creates imported targets.
# Then it is no longer needed to manually do include_directories().
find_package(HDF5 REQUIRED COMPONENTS C CXX)
if (NOT TARGET hdf5-shared OR NOT TARGET hdf5_cpp-shared)
message(WARNING "Could not find imported HDF5 targets. Using module-mode instead.")
include_directories(${HDF5_INCLUDE_DIRS})
endif()
endif()

Expand Down
8 changes: 6 additions & 2 deletions src/python/CMakeLists.txt
Expand Up @@ -26,9 +26,13 @@ target_link_libraries(pyrfsim
Boost::python
Boost::system
LibBCSim
hdf5-static
hdf5_cpp-static
)
if (TARGET hdf5-shared AND TARGET hdf5_cpp-shared)
target_link_libraries(pyrfsim hdf5-shared hdf5_cpp-shared)
else()
target_link_libraries(pyrfsim ${HDF5_LIBRARIES})
endif()

set_target_properties(pyrfsim PROPERTIES PREFIX "")
if (WIN32)
set_target_properties(pyrfsim PROPERTIES SUFFIX ".pyd")
Expand Down
9 changes: 7 additions & 2 deletions src/qt5gui/CMakeLists.txt
Expand Up @@ -92,10 +92,15 @@ target_link_libraries(BCSimGUI
Boost::boost
LibBCSim
LibBCSimUtils # BCSimCUDA also?
hdf5-static
hdf5_cpp-static
trianglemesh3d
)

if (TARGET hdf5-shared AND TARGET hdf5_cpp-shared)
target_link_libraries(BCSimGUI hdf5-shared hdf5_cpp-shared)
else()
target_link_libraries(BCSimGUI ${HDF5_LIBRARIES})
endif()

if (WIN32)
target_link_libraries(BCSimGUI Qt5::WinMain)
endif()
Expand Down
8 changes: 6 additions & 2 deletions src/utils/CMakeLists.txt
Expand Up @@ -25,11 +25,15 @@ list(APPEND UTILS_LIBRARY_SOURCE_FILES

add_library(LibBCSimUtils ${UTILS_LIBRARY_SOURCE_FILES})
target_link_libraries(LibBCSimUtils
hdf5-static
hdf5_cpp-static
Boost::boost
)

if (TARGET hdf5-shared AND TARGET hdf5_cpp-shared)
target_link_libraries(LibBCSimUtils hdf5-shared hdf5_cpp-shared)
else()
target_link_libraries(LibBCSimUtils ${HDF5_LIBRARIES})
endif()

if (BCSIM_ENABLE_CUDA)
# Needed because we're going to interact with the CUDA runtime API
# to query the number and type of available GPUs.
Expand Down

0 comments on commit 97b63f2

Please sign in to comment.