Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

CMakeLists.txt 4.0 KiB

pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
pirms 1 gada
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. if (USE_ADDRESS_SANITIZER)
  40. target_compile_options(aptdec-cli PRIVATE -fsanitize=address)
  41. target_link_options(aptdec-cli PRIVATE -fsanitize=address)
  42. endif()
  43. install(TARGETS aptdec-cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  44. file(GLOB LUTS luts/*.png)
  45. install(FILES ${LUTS} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/aptdec/luts)
  46. else()
  47. message(WARNING "Not building aptdec-cli as some/all required dependencies are missing, libaptdec will still be built")
  48. endif()
  49. # libaptdec
  50. set(LIBAPTDEC_HEADER_FILES libaptdec/include/aptdec.h)
  51. set(LIBAPTDEC_SOURCE_FILES
  52. libaptdec/algebra.c
  53. libaptdec/calibration.c
  54. libaptdec/color.c
  55. libaptdec/dsp.c
  56. libaptdec/filter.c
  57. libaptdec/image.c
  58. libaptdec/util.c
  59. libaptdec/effects.c
  60. )
  61. add_library(aptdec SHARED ${LIBAPTDEC_SOURCE_FILES})
  62. set_target_properties(aptdec PROPERTIES PUBLIC_HEADER ${LIBAPTDEC_HEADER_FILES})
  63. target_include_directories(aptdec PRIVATE libaptdec/include/)
  64. target_compile_definitions(aptdec PRIVATE "VERSION=\"${VERSION}\"")
  65. if(MSVC)
  66. target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPTDEC_API_EXPORT)
  67. else()
  68. target_link_libraries(aptdec PRIVATE m)
  69. target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
  70. endif()
  71. if (USE_ADDRESS_SANITIZER)
  72. target_compile_options(aptdec PRIVATE -fsanitize=address)
  73. target_link_options(aptdec PRIVATE -fsanitize=address)
  74. endif()
  75. install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
  76. # Packaging
  77. string(REPLACE v "" CPACK_PACKAGE_VERSION ${VERSION})
  78. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
  79. set(CPACK_PACKAGE_NAME "aptdec")
  80. set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)")
  81. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder")
  82. 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.")
  83. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}")
  84. set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsndfile1, libpng16-16")
  85. if(WIN32)
  86. file(GLOB DLLS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/*.dll)
  87. install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR})
  88. set(CPACK_GENERATOR "ZIP")
  89. else()
  90. set(CPACK_GENERATOR "DEB;TGZ")
  91. endif()
  92. include(CPack)