Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 

101 рядки
3.7 KiB

  1. cmake_minimum_required (VERSION 3.0.0)
  2. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
  3. project(aptdec)
  4. # libpng
  5. find_package(PNG)
  6. # libsndfile
  7. find_package(LibSndFile)
  8. set(LIB_C_SOURCE_FILES src/color.c src/dsp.c src/filter.c src/image.c src/libs/reg.c src/libs/median.c)
  9. set(EXE_C_SOURCE_FILES src/main.c src/pngio.c src/libs/argparse.c)
  10. set(LIB_C_HEADER_FILES src/apt.h)
  11. # Link with static library for aptdec executable, so we don't need to set the path
  12. add_library(aptstatic STATIC ${LIB_C_SOURCE_FILES})
  13. # Create shared library for 3rd party apps
  14. add_library(apt SHARED ${LIB_C_SOURCE_FILES})
  15. add_compile_definitions(PALETTE_DIR="../palettes")
  16. if (PNG_FOUND AND LIBSNDFILE_FOUND)
  17. add_executable(aptdec ${EXE_C_SOURCE_FILES})
  18. include_directories(${PNG_PNG_INCLUDE_DIR})
  19. include_directories(${LIBSNDFILE_INCLUDE_DIR})
  20. target_link_libraries(aptdec PRIVATE PNG::PNG)
  21. target_link_libraries(aptdec PRIVATE ${LIBSNDFILE_LIBRARY})
  22. target_link_libraries(aptdec PRIVATE aptstatic)
  23. if (MSVC)
  24. target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC)
  25. else()
  26. # Math
  27. target_link_libraries(aptdec PRIVATE m)
  28. # Throw errors on warnings on release builds
  29. if(CMAKE_BUILD_TYPE MATCHES "Release")
  30. target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers -Werror)
  31. else()
  32. target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic)
  33. endif()
  34. endif()
  35. else()
  36. MESSAGE(STATUS "WARNING: Only building apt library, as not all of the required libraries were found for aptdec.")
  37. endif()
  38. if (MSVC)
  39. target_compile_options(apt PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_EXPORT)
  40. target_compile_options(aptstatic PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC)
  41. else()
  42. # Math
  43. target_link_libraries(apt PRIVATE m)
  44. target_link_libraries(aptstatic PRIVATE m)
  45. if(CMAKE_BUILD_TYPE MATCHES "Release")
  46. target_compile_options(apt PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers -Werror)
  47. else()
  48. target_compile_options(apt PRIVATE -Wall -Wextra -pedantic)
  49. endif()
  50. endif()
  51. # TODO: get this from git
  52. set(PROJECT_VERSION "1.7.0")
  53. # CPack
  54. set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
  55. set(CPACK_PACKAGE_NAME "aptdec")
  56. set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)")
  57. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder")
  58. set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS program that decodes images transmitted by NOAA weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.")
  59. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
  60. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  61. IF(NOT WIN32)
  62. set(CPACK_GENERATOR "DEB;TGZ")
  63. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}")
  64. if (TARGET aptdec)
  65. install(TARGETS aptdec DESTINATION "bin/")
  66. install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/")
  67. endif()
  68. install(TARGETS apt LIBRARY DESTINATION lib)
  69. install(FILES ${LIB_C_HEADER_FILES} DESTINATION include/apt )
  70. else()
  71. #set(CPACK_GENERATOR "ZIP;NSIS")
  72. set(CPACK_GENERATOR "ZIP")
  73. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
  74. if (TARGET aptdec)
  75. install(TARGETS aptdec DESTINATION "bin/")
  76. file(GLOB_RECURSE DLLS *.dll)
  77. install(FILES ${DLLS} DESTINATION "bin/")
  78. endif()
  79. install(TARGETS apt DESTINATION "bin/")
  80. install(FILES ${LIB_C_HEADER_FILES} DESTINATION include/apt )
  81. install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/")
  82. endif()
  83. include(CPack)