CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. cmake_minimum_required(VERSION 3.0.0)
  2. if(POLICY CMP0069)
  3. cmake_policy(SET CMP0069 NEW)
  4. endif()
  5. project(HDF4CPP LANGUAGES CXX)
  6. list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
  7. set(CMAKE_CXX_STANDARD 11)
  8. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  9. set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  10. find_package(HDF4 REQUIRED)
  11. find_package(Doxygen)
  12. if (DOXYGEN_FOUND)
  13. configure_file(Doxyfile_user.in ${PROJECT_BINARY_DIR}/Doxyfile_user @ONLY IMMEDIATE)
  14. add_custom_target(docs_user
  15. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile_user
  16. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile_user
  17. )
  18. configure_file(Doxyfile_all.in ${PROJECT_BINARY_DIR}/Doxyfile_all @ONLY IMMEDIATE)
  19. add_custom_target(docs_all
  20. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile_all
  21. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile_all
  22. )
  23. else ()
  24. message(WARNING "Doxygen not found")
  25. endif ()
  26. set(HEADERS
  27. include/hdf4cpp/hdf.h
  28. include/hdf4cpp/HdfObject.h
  29. include/hdf4cpp/HdfAttribute.h
  30. include/hdf4cpp/HdfException.h
  31. include/hdf4cpp/HdfFile.h
  32. include/hdf4cpp/HdfItem.h
  33. include/hdf4cpp/HdfDefines.h)
  34. add_library(hdf4cpp
  35. lib/HdfFile.cpp
  36. lib/HdfItem.cpp
  37. lib/HdfAttribute.cpp
  38. lib/HdfException.cpp
  39. ${HEADERS}
  40. )
  41. target_include_directories(hdf4cpp
  42. PUBLIC
  43. include/
  44. ${HDF4_INCLUDE_DIRS}
  45. )
  46. target_link_libraries(hdf4cpp
  47. ${HDF4_LIBRARIES}
  48. )
  49. if (MSVC)
  50. target_compile_definitions(hdf4cpp PUBLIC
  51. NEEDS_NORETURN
  52. )
  53. endif ()
  54. option(HDF4CPP_BUILD_TESTS "Enable building tests" ON)
  55. option(HDF4CPP_BUILD_EXAMPLES "Enable building examples" ON)
  56. if (HDF4CPP_BUILD_TESTS)
  57. add_subdirectory(tests)
  58. endif()
  59. if (HDF4CPP_BUILD_EXAMPLES)
  60. add_subdirectory(examples)
  61. endif()
  62. install(TARGETS hdf4cpp DESTINATION lib)
  63. install(FILES ${HEADERS}
  64. DESTINATION "include/hdf4cpp"
  65. )