1
0

CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. cmake_minimum_required(VERSION 2.8)
  2. project(HDF4CPP)
  3. list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
  4. set(CMAKE_CXX_STANDARD 11)
  5. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  6. set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  7. find_package(HDF4 REQUIRED)
  8. find_package(Doxygen)
  9. if (DOXYGEN_FOUND)
  10. configure_file(Doxyfile_user.in ${PROJECT_BINARY_DIR}/Doxyfile_user @ONLY IMMEDIATE)
  11. add_custom_target(docs_user
  12. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile_user
  13. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile_user
  14. )
  15. configure_file(Doxyfile_all.in ${PROJECT_BINARY_DIR}/Doxyfile_all @ONLY IMMEDIATE)
  16. add_custom_target(docs_all
  17. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile_all
  18. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile_all
  19. )
  20. else ()
  21. message(WARNING "Doxygen not found")
  22. endif ()
  23. set(HEADERS
  24. include/hdf4cpp/hdf.h
  25. include/hdf4cpp/HdfObject.h
  26. include/hdf4cpp/HdfAttribute.h
  27. include/hdf4cpp/HdfException.h
  28. include/hdf4cpp/HdfFile.h
  29. include/hdf4cpp/HdfItem.h
  30. include/hdf4cpp/HdfDefines.h)
  31. add_library(hdf4cpp
  32. lib/HdfFile.cpp
  33. lib/HdfItem.cpp
  34. lib/HdfAttribute.cpp
  35. lib/HdfException.cpp
  36. ${HEADERS}
  37. )
  38. target_include_directories(hdf4cpp
  39. PUBLIC
  40. include/
  41. ${HDF4_INCLUDE_DIRS}
  42. )
  43. target_link_libraries(hdf4cpp
  44. ${HDF4_LIBRARIES}
  45. )
  46. if (MSVC)
  47. target_compile_definitions(hdf4cpp PUBLIC
  48. NEEDS_NORETURN
  49. )
  50. endif ()
  51. enable_testing()
  52. find_package(GTest REQUIRED)
  53. find_package(Threads REQUIRED)
  54. add_executable(hdf4cpp-tests
  55. tests/HdfFileTest.cpp)
  56. target_include_directories(hdf4cpp-tests
  57. PRIVATE
  58. ${GTEST_INCLUDE_DIRS}
  59. )
  60. target_link_libraries(hdf4cpp-tests
  61. ${GTEST_BOTH_LIBRARIES}
  62. ${CMAKE_THREAD_LIBS_INIT}
  63. hdf4cpp
  64. )
  65. target_compile_definitions(hdf4cpp-tests PRIVATE
  66. GTEST_DONT_DEFINE_FAIL
  67. GTEST_DONT_DEFINE_SUCCEED)
  68. if (NOT DEFINED TEST_DATA_PATH)
  69. set(TEST_DATA_PATH "${PROJECT_SOURCE_DIR}/tests/test_data/")
  70. message(STATUS "No path to test data defined, using ${TEST_DATA_PATH} as default")
  71. endif ()
  72. target_compile_definitions(hdf4cpp-tests PRIVATE
  73. "TEST_DATA_PATH=\"${TEST_DATA_PATH}\"")
  74. add_test(
  75. NAME hdf4cpp
  76. COMMAND hdf4cpp-tests --gtest_output=xml:${PROJECT_BINARY_DIR}/test_details.xml
  77. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} # we need the serialized test data for the integration test
  78. )
  79. add_subdirectory(examples)
  80. install(TARGETS hdf4cpp DESTINATION lib)
  81. install(FILES ${HEADERS}
  82. DESTINATION "include/hdf4cpp"
  83. )