Browse Source

Palette search directorie, basic packaging support

tags/v1.8.0
Xerbo 4 years ago
parent
commit
bb37bf0628
3 changed files with 53 additions and 20 deletions
  1. +33
    -5
      CMakeLists.txt
  2. +11
    -12
      cmake/FindLibSndFile.cmake
  3. +9
    -3
      src/pngio.c

+ 33
- 5
CMakeLists.txt View File

@@ -1,22 +1,50 @@
cmake_minimum_required (VERSION 3.0.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

project (aptdec)
set(PROJECT_VERSION "1.7.0")

project(aptdec)
file(GLOB_RECURSE C_SOURCE_FILES src/*.c)
add_executable(aptdec ${C_SOURCE_FILES})

# Math
add_compile_definitions(PALETTE_DIR="${CMAKE_SOURCE_DIR}/palettes")

# math
target_link_libraries(aptdec PRIVATE m)

# PNG
# libpng
target_link_libraries(aptdec PRIVATE PNG::PNG)
if(WIN32 AND NOT MINGW)
find_package(PNG CONFIG REQUIRED)
else()
find_package(PNG REQUIRED)
endif()
target_link_libraries(aptdec PRIVATE PNG::PNG)

# SndFile
# libsndfile
find_package(LibSndFile REQUIRED)
target_link_libraries(aptdec PRIVATE ${LIBSNDFILE_LIBRARY})

# CPack
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_NAME "aptdec")
set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

IF(NOT WIN32)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}")

install(TARGETS aptdec DESTINATION "bin/")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "lib/aptdec/palettes")
else()
set(CPACK_GENERATOR "ZIP;NSIS")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")

install(TARGETS aptdec DESTINATION "bin/")
install(FILES libpng16.dll libsndfile-1.dll libzlib.dll DESTINATION "bin/")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes/" DESTINATION "palettes/")
endif()

include(CPack)

+ 11
- 12
cmake/FindLibSndFile.cmake View File

@@ -1,20 +1,19 @@
# Find libsndfile

FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)

SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile libsndfile-1)
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)

IF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
SET(LIBSNDFILE_FOUND TRUE)
ENDIF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
ENDIF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)

IF (LIBSNDFILE_FOUND)
IF (NOT LibSndFile_FIND_QUIETLY)
MESSAGE (STATUS "Found LibSndFile: ${LIBSNDFILE_LIBRARY}")
ENDIF (NOT LibSndFile_FIND_QUIETLY)
ELSE (LIBSNDFILE_FOUND)
IF (LibSndFile_FIND_REQUIRED)
MESSAGE (FATAL_ERROR "Could not find sndfile")
ENDIF (LibSndFile_FIND_REQUIRED)
ENDIF (LIBSNDFILE_FOUND)
IF(LIBSNDFILE_FOUND)
IF(NOT LibSndFile_FIND_QUIETLY)
MESSAGE(STATUS "Found LibSndFile: ${LIBSNDFILE_LIBRARY}")
ENDIF(NOT LibSndFile_FIND_QUIETLY)
ELSE(LIBSNDFILE_FOUND)
IF(LibSndFile_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find sndfile")
ENDIF(LibSndFile_FIND_REQUIRED)
ENDIF(LIBSNDFILE_FOUND)

+ 9
- 3
src/pngio.c View File

@@ -213,10 +213,16 @@ int readRawImage(char *filename, float **prow, int *nrow) {
int readPalette(char *filename, rgb_t **pixels) {
FILE *fp = fopen(filename, "r");
if(!fp) {
fprintf(stderr, "Cannot open %s\n", filename);
return 0;
char buffer[1024];
// PALETTE_DIR is set through CMake
sprintf(buffer, PALETTE_DIR"/%s", filename);
fp = fopen(buffer, "r");
if(!fp){
fprintf(stderr, "Cannot open %s\n", filename);
return 0;
}
}

// Create reader
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if(!png) {


Loading…
Cancel
Save