您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CMakeLists.txt 3.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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(libaptdecstatic STATIC ${LIB_C_SOURCE_FILES})
  13. # Create shared library for 3rd party apps
  14. add_library(libaptdec 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 libaptdecstatic)
  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 libaptdec, as not all of the required libraries were found.")
  37. endif()
  38. if (MSVC)
  39. target_compile_options(libaptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_EXPORT)
  40. else()
  41. # Math
  42. target_link_libraries(libaptdec PRIVATE m)
  43. target_link_libraries(libaptdecstatic PRIVATE m)
  44. if(CMAKE_BUILD_TYPE MATCHES "Release")
  45. target_compile_options(libaptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers -Werror)
  46. else()
  47. target_compile_options(libaptdec PRIVATE -Wall -Wextra -pedantic)
  48. endif()
  49. endif()
  50. # TODO: get this from git
  51. set(PROJECT_VERSION "1.7.0")
  52. # CPack
  53. set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
  54. set(CPACK_PACKAGE_NAME "aptdec")
  55. set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)")
  56. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder")
  57. 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.")
  58. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
  59. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
  60. IF(NOT WIN32)
  61. set(CPACK_GENERATOR "DEB;TGZ")
  62. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}")
  63. if (TARGET aptdec)
  64. install(TARGETS aptdec DESTINATION "bin/")
  65. install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/")
  66. endif()
  67. install(TARGETS libaptdec LIBRARY DESTINATION lib)
  68. install(FILES ${LIB_C_HEADER_FILES} DESTINATION include/apt )
  69. else()
  70. #set(CPACK_GENERATOR "ZIP;NSIS")
  71. set(CPACK_GENERATOR "ZIP")
  72. set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
  73. if (TARGET aptdec)
  74. install(TARGETS aptdec DESTINATION "bin/")
  75. file(GLOB_RECURSE DLLS *.dll)
  76. install(FILES ${DLLS} DESTINATION "bin/")
  77. endif()
  78. install(TARGETS libaptdec DESTINATION "bin/")
  79. install(FILES ${LIB_C_HEADER_FILES} DESTINATION include/apt )
  80. install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/")
  81. endif()
  82. include(CPack)