Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CMakeLists.txt 3.7 KiB

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