No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

CMakeLists.txt 3.7 KiB

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