-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
99 lines (80 loc) · 3.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
cmake_minimum_required (VERSION 3.0.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
project(aptdec C)
include(GNUInstallDirs)
# libpng
find_package(PNG)
# libsndfile
find_package(LibSndFile)
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)
set(EXE_C_SOURCE_FILES src/main.c src/pngio.c src/argparse/argparse.c src/util.c)
set(LIB_C_HEADER_FILES src/apt.h)
# Link with static library for aptdec executable, so we don't need to set the path
add_library(aptstatic STATIC ${LIB_C_SOURCE_FILES})
# Create shared library for 3rd party apps
add_library(apt SHARED ${LIB_C_SOURCE_FILES})
set_target_properties(apt PROPERTIES PUBLIC_HEADER ${LIB_C_HEADER_FILES})
add_compile_definitions(PALETTE_DIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/palettes")
if (PNG_FOUND AND LIBSNDFILE_FOUND)
add_executable(aptdec ${EXE_C_SOURCE_FILES})
include_directories(${PNG_PNG_INCLUDE_DIR})
include_directories(${LIBSNDFILE_INCLUDE_DIR})
target_link_libraries(aptdec PRIVATE PNG::PNG)
target_link_libraries(aptdec PRIVATE ${LIBSNDFILE_LIBRARY})
target_link_libraries(aptdec PRIVATE aptstatic)
if (MSVC)
target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC)
else()
# Math
target_link_libraries(aptdec PRIVATE m)
# Throw errors on warnings on release builds
if(CMAKE_BUILD_TYPE MATCHES "Release")
target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
else()
target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
endif()
endif()
else()
MESSAGE(WARNING "Only building apt library, as not all of the required libraries were found for aptdec.")
endif()
if (MSVC)
target_compile_options(apt PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_EXPORT)
target_compile_options(aptstatic PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC)
else()
# Math
target_link_libraries(apt PRIVATE m)
target_link_libraries(aptstatic PRIVATE m)
if(CMAKE_BUILD_TYPE MATCHES "Release")
target_compile_options(apt PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
else()
target_compile_options(apt PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
endif()
endif()
# TODO: get this from git
set(PROJECT_VERSION "v1.8.0")
# CPack
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_NAME "aptdec")
set(CPACK_PACKAGE_CONTACT "Xerbo ([email protected])")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder")
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.")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
IF(NOT WIN32)
set(CPACK_GENERATOR "DEB;TGZ")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}")
else()
#set(CPACK_GENERATOR "ZIP;NSIS")
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
if (TARGET aptdec)
file(GLOB_RECURSE DLLS *.dll)
install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
if (TARGET aptdec)
install(TARGETS aptdec RUNTIME DESTINATION bin)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes" DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME})
endif()
install(TARGETS apt PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
include(CPack)