You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

100 lines
3.6 KiB

  1. cmake_minimum_required(VERSION 3.0.0)
  2. set(CMAKE_C_STANDARD 99)
  3. set(CMAKE_C_EXTENSIONS OFF)
  4. # Get version
  5. find_package(Git)
  6. if (GIT_FOUND)
  7. execute_process(COMMAND ${GIT_EXECUTABLE} describe --tag WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE)
  8. set(VERSION "${GIT_TAG}")
  9. else()
  10. set(VERSION "Unknown")
  11. endif()
  12. project(aptdec C)
  13. include(GNUInstallDirs)
  14. # aptdec-cli
  15. find_package(PNG)
  16. find_path(SNDFILE_INCLUDE_DIR sndfile.h)
  17. find_library(SNDFILE_LIBRARIES NAMES sndfile libsndfile)
  18. if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR)
  19. set(APTDEC_CLI_SOURCE_FILES
  20. aptdec-cli/argparse/argparse.c
  21. aptdec-cli/main.c
  22. aptdec-cli/pngio.c
  23. aptdec-cli/util.c
  24. )
  25. add_executable(aptdec-cli ${APTDEC_CLI_SOURCE_FILES})
  26. target_compile_definitions(aptdec-cli PRIVATE "VERSION=\"${VERSION}\"")
  27. target_include_directories(aptdec-cli PRIVATE ${PNG_INCLUDE_DIRS})
  28. target_include_directories(aptdec-cli PRIVATE ${SNDFILE_INCLUDE_DIR})
  29. target_include_directories(aptdec-cli PRIVATE libaptdec/include/)
  30. target_link_libraries(aptdec-cli PRIVATE ${PNG_LIBRARIES})
  31. target_link_libraries(aptdec-cli PRIVATE ${SNDFILE_LIBRARIES})
  32. target_link_libraries(aptdec-cli PRIVATE aptdec)
  33. if(MSVC)
  34. target_compile_options(aptdec-cli PRIVATE /D_CRT_SECURE_NO_WARNINGS=1)
  35. else()
  36. target_link_libraries(aptdec-cli PRIVATE m)
  37. target_compile_options(aptdec-cli PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
  38. endif()
  39. install(TARGETS aptdec-cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  40. file(GLOB LUTS luts/*.png)
  41. install(FILES ${LUTS} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/aptdec/luts)
  42. else()
  43. message(WARNING "Not building aptdec-cli as some/all required dependencies are missing, libaptdec will still be built")
  44. endif()
  45. # libaptdec
  46. set(LIBAPTDEC_HEADER_FILES libaptdec/include/aptdec.h)
  47. set(LIBAPTDEC_SOURCE_FILES
  48. libaptdec/algebra.c
  49. libaptdec/calibration.c
  50. libaptdec/color.c
  51. libaptdec/dsp.c
  52. libaptdec/filter.c
  53. libaptdec/image.c
  54. libaptdec/util.c
  55. libaptdec/effects.c
  56. )
  57. add_library(aptdec SHARED ${LIBAPTDEC_SOURCE_FILES})
  58. set_target_properties(aptdec PROPERTIES PUBLIC_HEADER ${LIBAPTDEC_HEADER_FILES})
  59. target_include_directories(aptdec PRIVATE libaptdec/include/)
  60. target_compile_definitions(aptdec PRIVATE "VERSION=\"${VERSION}\"")
  61. if(MSVC)
  62. target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPTDEC_API_EXPORT)
  63. else()
  64. target_link_libraries(aptdec PRIVATE m)
  65. target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
  66. endif()
  67. install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
  68. # Packaging
  69. set(CPACK_PACKAGE_VERSION "${VERSION}")
  70. set(CPACK_PACKAGE_NAME "aptdec")
  71. set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)")
  72. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder")
  73. set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS library/program that decodes images transmitted by the NOAA POES weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.")
  74. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}")
  75. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  76. if(WIN32)
  77. file(GLOB DLLS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/*.dll)
  78. install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR})
  79. set(CPACK_GENERATOR "ZIP")
  80. else()
  81. set(CPACK_GENERATOR "DEB;TGZ")
  82. endif()
  83. include(CPack)