diff --git a/.gitignore b/.gitignore index bf5b590b..8992f54d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ .vs/* V*/ *.user -Makefile.9 \ No newline at end of file +Makefile.9 +build/ +install/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..a07d2406 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 3.20) +project(PoissonRecon) + +option(BUILD_SHARED_LIB "Builds PoissonRecon as a shared library artifact" OFF) +option(BUILD_EXECUTABLE "Builds PoissonRecon as a command-line application" ON) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +find_package(Threads REQUIRED) + +if (MSVC) + string(JOIN " " CMAKE_CXX_FLAGS_RELEASE + ${CMAKE_CXX_FLAGS_RELEASE} + -DRELEASE + -DNOMINMAX + -DWIN32_LEAN_AND_MEAN + /bigobj + ) +else() + string(JOIN " " CMAKE_CXX_FLAGS_RELEASE + ${CMAKE_CXX_FLAGS_RELEASE} + -DRELEASE + -Ofast + -funroll-loops + -ffast-math + -Wno-deprecated + -Wno-invalid-offsetof + -Wno-dangling-else + ) +endif() + +string(JOIN " " CMAKE_EXE_LINKER_FLAGS_RELEASE + ${CMAKE_EXE_LINKER_FLAGS_RELEASE} + ${CMAKE_CXX_FLAGS_RELEASE} +) + +file(GLOB_RECURSE SRCS_ZLIB "ZLIB/*.c") +add_library(ZLIB STATIC ${SRCS_ZLIB}) + +file(GLOB_RECURSE SRCS_PNG "PNG/*.c") +add_library(PNG STATIC ${SRCS_PNG}) + +file(GLOB_RECURSE SRCS_JPEG "JPEG/*.cpp") +add_library(JPEG STATIC ${SRCS_JPEG}) + +include_directories(${CMAKE_CURRENT_LIST_DIR} JPEG ZLIB PNG) + +if (BUILD_SHARED_LIB) + message(STATUS "PoissonRecon: Building shared library") + add_library(PoissonRecon SHARED Src/PoissonRecon.cpp) + target_link_libraries(PoissonRecon PRIVATE PNG ZLIB JPEG Threads::Threads) + target_compile_definitions(PoissonRecon PRIVATE -Dmain=PoissonRecon) + install( + TARGETS PoissonRecon + EXPORT PoissonRecon + INCLUDES DESTINATION include + FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} + ) + install( + EXPORT PoissonRecon + NAMESPACE PoissonRecon:: + DESTINATION lib/cmake/PoissonRecon + ) +endif() + +if (BUILD_EXECUTABLE) + message(STATUS "PoissonRecon: Building executable") + add_executable(PoissonReconApp Src/PoissonRecon.cpp) + target_link_libraries(PoissonReconApp PRIVATE PNG ZLIB JPEG Threads::Threads) + install(TARGETS PoissonReconApp) +endif() diff --git a/PNG/png.c b/PNG/png.c index 63ae86e3..c00b5015 100644 --- a/PNG/png.c +++ b/PNG/png.c @@ -2,7 +2,7 @@ /* png.c - location for general purpose libpng functions * * Last changed in libpng 1.2.21 October 4, 2007 - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -10,13 +10,13 @@ #define PNG_INTERNAL #define PNG_NO_EXTERN -#include "png.h" +#include "PNG/png.h" -/* Generate a compiler error if there is an old png.h in the search path. */ +/* Generate a compiler error if there is an old PNG/png.h in the search path. */ typedef version_1_2_29 Your_png_h_is_not_version_1_2_29; /* Version information for C files. This had better match the version - * string defined in png.h. */ + * string defined in PNG/png.h. */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ @@ -68,7 +68,7 @@ PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h + * it, uncomment it here and in PNG/png.h PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ @@ -702,10 +702,10 @@ png_get_copyright(png_structp png_ptr) /* The following return the library version as a short string in the * format 1.0.0 through 99.99.99zz. To get the version of *.h files * used with your application, print out PNG_LIBPNG_VER_STRING, which - * is defined in png.h. + * is defined in PNG/png.h. * Note: now there is no difference between png_get_libpng_ver() and * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, - * it is guaranteed that png.c uses the correct version of png.h. + * it is guaranteed that png.c uses the correct version of PNG/png.h. */ png_charp PNGAPI png_get_libpng_ver(png_structp png_ptr) diff --git a/PNG/pngerror.c b/PNG/pngerror.c index b364fc00..716a2552 100644 --- a/PNG/pngerror.c +++ b/PNG/pngerror.c @@ -2,7 +2,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * * Last changed in libpng 1.2.22 [October 13, 2007] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -14,7 +14,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) static void /* PRIVATE */ diff --git a/PNG/pngget.c b/PNG/pngget.c index a0e90bb6..0ea92d1e 100644 --- a/PNG/pngget.c +++ b/PNG/pngget.c @@ -2,14 +2,14 @@ /* pngget.c - retrieval of values from info struct * * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) diff --git a/PNG/pngmem.c b/PNG/pngmem.c index 13cc60c0..ca7de0cc 100644 --- a/PNG/pngmem.c +++ b/PNG/pngmem.c @@ -2,7 +2,7 @@ /* pngmem.c - stub functions for memory allocation * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -15,13 +15,13 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Borland DOS special memory handler */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ +/* if you change this, be sure to change the one in PNG/png.h also */ /* Allocate memory for a png_struct. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance. */ @@ -95,7 +95,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, /* Allocate memory. For reasonable files, size should never exceed * 64K. However, zlib may allocate more then 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does + * it not to. See zconf.h and PNG/png.h for more information. zlib does * need to allocate exactly 64K, so whatever you call here must * have the ability to do that. * @@ -421,7 +421,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, /* Allocate memory. For reasonable files, size should never exceed 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does + it not to. See zconf.h and PNG/png.h for more information. zlib does need to allocate exactly 64K, so whatever you call here must have the ability to do that. */ diff --git a/PNG/pngpread.c b/PNG/pngpread.c index aa7151c4..fac66894 100644 --- a/PNG/pngpread.c +++ b/PNG/pngpread.c @@ -2,14 +2,14 @@ /* pngpread.c - read a png file in push mode * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #ifdef PNG_PROGRESSIVE_READ_SUPPORTED @@ -1004,7 +1004,7 @@ png_read_push_finish_row(png_structp png_ptr) PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h + * it, uncomment it here and in PNG/png.h PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ #endif diff --git a/PNG/pngread.c b/PNG/pngread.c index bd8bcd98..b1746a1e 100644 --- a/PNG/pngread.c +++ b/PNG/pngread.c @@ -2,7 +2,7 @@ /* pngread.c - read a PNG file * * Last changed in libpng 1.2.25 [February 18, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -12,7 +12,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) @@ -118,7 +118,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, if (user_png_ver) { png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", + "Application was compiled with PNG/png.h from libpng-%.20s", user_png_ver); png_warning(png_ptr, msg); } @@ -200,7 +200,7 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, if (user_png_ver) { png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", + "Application was compiled with PNG/png.h from libpng-%.20s", user_png_ver); png_warning(png_ptr, msg); } diff --git a/PNG/pngrio.c b/PNG/pngrio.c index 7d2522f1..ddcd3bc6 100644 --- a/PNG/pngrio.c +++ b/PNG/pngrio.c @@ -2,7 +2,7 @@ /* pngrio.c - functions for data input * * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -16,7 +16,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) diff --git a/PNG/pngrtran.c b/PNG/pngrtran.c index 873b22cf..8626ebbd 100644 --- a/PNG/pngrtran.c +++ b/PNG/pngrtran.c @@ -2,7 +2,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -14,7 +14,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) @@ -1067,7 +1067,7 @@ png_init_read_transformations(png_structp png_ptr) } else if (png_ptr->trans[i] != 0xff) { - /* The png_composite() macro is defined in png.h */ + /* The png_composite() macro is defined in PNG/png.h */ png_composite(palette[i].red, palette[i].red, png_ptr->trans[i], back.red); png_composite(palette[i].green, palette[i].green, diff --git a/PNG/pngrutil.c b/PNG/pngrutil.c index 531cb057..00048adf 100644 --- a/PNG/pngrutil.c +++ b/PNG/pngrutil.c @@ -2,7 +2,7 @@ /* pngrutil.c - utilities to read a PNG file * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -12,7 +12,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) diff --git a/PNG/pngset.c b/PNG/pngset.c index 8b25ca50..c05f81c1 100644 --- a/PNG/pngset.c +++ b/PNG/pngset.c @@ -2,7 +2,7 @@ /* pngset.c - storage of image information into info struct * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -14,7 +14,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) diff --git a/PNG/pngtest.c b/PNG/pngtest.c index 60980c27..78d4cd2c 100644 --- a/PNG/pngtest.c +++ b/PNG/pngtest.c @@ -2,7 +2,7 @@ /* pngtest.c - a simple test program to test libpng * * Last changed in libpng 1.2.27 - [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -28,7 +28,7 @@ * of files at once by typing "pngtest -m file1.png file2.png ..." */ -#include "png.h" +#include "PNG/png.h" #if defined(_WIN32_WCE) # if _WIN32_WCE < 211 @@ -59,7 +59,7 @@ # endif #endif -/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ +/* Makes pngtest verbose so we can find problems (needs to be before PNG/png.h) */ #ifndef PNG_DEBUG # define PNG_DEBUG 0 #endif @@ -471,7 +471,7 @@ pngtest_error(png_structp png_ptr, png_const_charp message) /* Allocate memory. For reasonable files, size should never exceed 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does + it not to. See zconf.h and PNG/png.h for more information. zlib does need to allocate exactly 64K, so whatever you call here must have the ability to do that. @@ -1344,8 +1344,8 @@ main(int argc, char *argv[]) if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) { fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); + "Warning: versions are different between PNG/png.h and png.c\n"); + fprintf(STDERR, " PNG/png.h version: %s\n", PNG_LIBPNG_VER_STRING); fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); ++ierror; } @@ -1559,5 +1559,5 @@ main(int argc, char *argv[]) return (int)(ierror != 0); } -/* Generate a compiler error if there is an old png.h in the search path. */ +/* Generate a compiler error if there is an old PNG/png.h in the search path. */ typedef version_1_2_29 your_png_h_is_not_version_1_2_29; diff --git a/PNG/pngtrans.c b/PNG/pngtrans.c index 16400950..a85ddef1 100644 --- a/PNG/pngtrans.c +++ b/PNG/pngtrans.c @@ -2,14 +2,14 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) diff --git a/PNG/pngwio.c b/PNG/pngwio.c index 371a4fad..9b4b96bb 100644 --- a/PNG/pngwio.c +++ b/PNG/pngwio.c @@ -2,7 +2,7 @@ /* pngwio.c - functions for data output * * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -16,7 +16,7 @@ */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #ifdef PNG_WRITE_SUPPORTED /* Write the data to whatever output you are using. The default routine diff --git a/PNG/pngwrite.c b/PNG/pngwrite.c index 7d02ad7d..501d9ce5 100644 --- a/PNG/pngwrite.c +++ b/PNG/pngwrite.c @@ -2,15 +2,15 @@ /* pngwrite.c - general routines to write a PNG file * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ -/* get internal access to png.h */ +/* get internal access to PNG/png.h */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #ifdef PNG_WRITE_SUPPORTED /* Writes all the PNG information. This is the suggested way to use the @@ -510,7 +510,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, if (user_png_ver) { png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", + "Application was compiled with PNG/png.h from libpng-%.20s", user_png_ver); png_warning(png_ptr, msg); } @@ -582,7 +582,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, if (user_png_ver) { png_snprintf(msg, 80, - "Application was compiled with png.h from libpng-%.20s", + "Application was compiled with PNG/png.h from libpng-%.20s", user_png_ver); png_warning(png_ptr, msg); } diff --git a/PNG/pngwtran.c b/PNG/pngwtran.c index 0372fe65..335a78a6 100644 --- a/PNG/pngwtran.c +++ b/PNG/pngwtran.c @@ -2,14 +2,14 @@ /* pngwtran.c - transforms the data in a row for PNG writers * * Last changed in libpng 1.2.9 April 14, 2006 - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #ifdef PNG_WRITE_SUPPORTED /* Transform the data according to the user's wishes. The order of diff --git a/PNG/pngwutil.c b/PNG/pngwutil.c index 0774080b..1069f082 100644 --- a/PNG/pngwutil.c +++ b/PNG/pngwutil.c @@ -2,14 +2,14 @@ /* pngwutil.c - utilities to write a PNG file * * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h + * For conditions of distribution and use, see copyright notice in PNG/png.h * Copyright (c) 1998-2008 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL -#include "png.h" +#include "PNG/png.h" #ifdef PNG_WRITE_SUPPORTED /* Place a 32-bit number into a buffer in PNG byte order. We work diff --git a/Src/Image.h b/Src/Image.h index 067147f0..2fb11862 100644 --- a/Src/Image.h +++ b/Src/Image.h @@ -108,7 +108,7 @@ struct TiledImageWriter : public ImageWriter #endif // SUPPORT_TILES -// [WARNING] Need to include "png.h" before "jpeg.h" so that "setjmp.h" is not already included (?) +// [WARNING] Need to include "PNG/png.h" before "jpeg.h" so that "setjmp.h" is not already included (?) #include "PNG.h" #include "JPEG.h" diff --git a/scripts/ubuntu/README.md b/scripts/ubuntu/README.md new file mode 100644 index 00000000..eb842b89 --- /dev/null +++ b/scripts/ubuntu/README.md @@ -0,0 +1,14 @@ +Usage: + +```sh +./configure.sh +./build.sh +``` + +Builds in release mode by default. + +```sh +./clean.sh +``` + +Cleans both build and install directories. diff --git a/scripts/ubuntu/archive.sh b/scripts/ubuntu/archive.sh new file mode 100755 index 00000000..5a4bca1e --- /dev/null +++ b/scripts/ubuntu/archive.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source common.sh +tar -czf ubuntu.tar.gz -C $INSTALL_DIR . + diff --git a/scripts/ubuntu/build.sh b/scripts/ubuntu/build.sh new file mode 100755 index 00000000..ba28d2c4 --- /dev/null +++ b/scripts/ubuntu/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source common.sh + +cmake --build $BUILD_DIR --config $BUILD_TYPE -j $NUM_CPU diff --git a/scripts/ubuntu/clean.sh b/scripts/ubuntu/clean.sh new file mode 100755 index 00000000..d6b8f938 --- /dev/null +++ b/scripts/ubuntu/clean.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source common.sh + +rm -r $BUILD_DIR $INSTALL_DIR diff --git a/scripts/ubuntu/common.sh b/scripts/ubuntu/common.sh new file mode 100644 index 00000000..fd02aa65 --- /dev/null +++ b/scripts/ubuntu/common.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e +set -u + +SCRIPTS_DIR=$PWD +PROJECT_ROOT=$(realpath $SCRIPTS_DIR/../../) +PLATFORM=ubuntu +BUILD_DIR=$PROJECT_ROOT/build/$PLATFORM +INSTALL_DIR=$PROJECT_ROOT/install/$PLATFORM +BUILD_TYPE=Release +NUM_CPU=$(nproc) + +mkdir -p $BUILD_DIR $INSTALL_DIR diff --git a/scripts/ubuntu/configure.sh b/scripts/ubuntu/configure.sh new file mode 100755 index 00000000..265190c0 --- /dev/null +++ b/scripts/ubuntu/configure.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source common.sh + +set -x + +cmake \ + -S $PROJECT_ROOT \ + -B $BUILD_DIR \ + -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE diff --git a/scripts/ubuntu/install.sh b/scripts/ubuntu/install.sh new file mode 100755 index 00000000..c3783af9 --- /dev/null +++ b/scripts/ubuntu/install.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source common.sh + +cmake --build $BUILD_DIR --config $BUILD_TYPE --target install -j $NUM_CPU diff --git a/scripts/windows/README.md b/scripts/windows/README.md new file mode 100644 index 00000000..aecad714 --- /dev/null +++ b/scripts/windows/README.md @@ -0,0 +1,14 @@ +Usage: + +```powershell +./configure.ps1 +./build.ps1 +``` + +Builds in release mode by default. + +```powershell +./clean.ps1 +``` + +Cleans both build and install directories. diff --git a/scripts/windows/archive.ps1 b/scripts/windows/archive.ps1 new file mode 100644 index 00000000..cdc64131 --- /dev/null +++ b/scripts/windows/archive.ps1 @@ -0,0 +1,16 @@ +. "./common.ps1" + +try +{ + tar -czf windows.tar.gz -C $INSTALL_DIR . +} +catch [System.SystemException] +{ + Write-Output "Error occured:" + Write-Output $_ +} +finally +{ + cd $SCRIPTS_DIR +} + diff --git a/scripts/windows/build.ps1 b/scripts/windows/build.ps1 new file mode 100644 index 00000000..ae461831 --- /dev/null +++ b/scripts/windows/build.ps1 @@ -0,0 +1,16 @@ +. "./common.ps1" + +try +{ + powershell -nologo -command "cmake --build $BUILD_DIR --config $BUILD_TYPE -j $CPU_COUNT" +} +catch [System.SystemException] +{ + Write-Output "Error occured:" + Write-Output $_ +} +finally +{ + cd $SCRIPTS_DIR +} + diff --git a/scripts/windows/clean.ps1 b/scripts/windows/clean.ps1 new file mode 100644 index 00000000..bbe56f71 --- /dev/null +++ b/scripts/windows/clean.ps1 @@ -0,0 +1,17 @@ +. "./common.ps1" + +try +{ + rm -r $BUILD_DIR + rm -r $INSTALL_DIR +} +catch [System.SystemException] +{ + Write-Output "Error occured:" + Write-Output $_ +} +finally +{ + cd $SCRIPTS_DIR +} + diff --git a/scripts/windows/common.ps1 b/scripts/windows/common.ps1 new file mode 100644 index 00000000..970cfe33 --- /dev/null +++ b/scripts/windows/common.ps1 @@ -0,0 +1,21 @@ +# Exit on error: +$ErrorActionPreference = "Stop" + +Set-Variable -Name PLATFORM -Value "windows" +Set-Variable -Name SCRIPTS_DIR -Value (Get-Location) +Set-Variable -Name PROJECT_ROOT -Value $SCRIPTS_DIR\..\..\ +Set-Variable -Name INSTALL_DIR -Value $PROJECT_ROOT\install\$PLATFORM +Set-Variable -Name BUILD_DIR -Value $PROJECT_ROOT\build\$PLATFORM +# FIXME +Set-Variable -Name CPU_COUNT -Value 8 +Set-Variable -Name BUILD_TYPE -Value Release + +# Settle on specific toolchain version: +$CMAKE_FLAGS = " -G 'Visual Studio 17 2022'" +$CMAKE_FLAGS = " -T 'v143'" +$CMAKE_FLAGS += " -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR" +$CMAKE_FLAGS += " -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL" + +New-Item $INSTALL_DIR -ItemType Directory -Force +New-Item $BUILD_DIR -ItemType Directory -Force + diff --git a/scripts/windows/configure.ps1 b/scripts/windows/configure.ps1 new file mode 100644 index 00000000..ff30adaf --- /dev/null +++ b/scripts/windows/configure.ps1 @@ -0,0 +1,16 @@ +. "./common.ps1" + +try +{ + powershell -nologo -command "cmake -B $BUILD_DIR -S $PROJECT_ROOT $CMAKE_FLAGS" +} +catch [System.SystemException] +{ + Write-Output "Error occured:" + Write-Output $_ +} +finally +{ + cd $SCRIPTS_DIR +} + diff --git a/scripts/windows/install.ps1 b/scripts/windows/install.ps1 new file mode 100644 index 00000000..4df3cdff --- /dev/null +++ b/scripts/windows/install.ps1 @@ -0,0 +1,16 @@ +. "./common.ps1" + +try +{ + powershell -nologo -command "cmake --build $BUILD_DIR --config $BUILD_TYPE --target install -j $CPU_COUNT" +} +catch [System.SystemException] +{ + Write-Output "Error occured:" + Write-Output $_ +} +finally +{ + cd $SCRIPTS_DIR +} +