Skip to content

Commit

Permalink
added export-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jkriege2 committed Jul 20, 2020
1 parent 054199f commit 5ef1199
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ tinytiffreader.d
tinytiffreader.o
tinytiffwriter.d
tinytiffwriter.o
/*.user
42 changes: 28 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ set(HEADERS


include(CMakePackageConfigHelpers)

#include(CheckSymbolExists)
#check_symbol_exists(fopen_s "stdio.h" HAVE_FOPEN_S)
include(GenerateExportHeader)


if(TinyTIFF_BUILD_SHARED_LIBS)
Expand All @@ -30,9 +28,14 @@ if(TinyTIFF_BUILD_SHARED_LIBS)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON")
#if (HAVE_FOPEN_S)
# target_compile_definitions(${libsh_name} PRIVATE HAVE_FOPEN_S)
#endif()

generate_export_header(${libsh_name} BASE_NAME tinytiff)
target_include_directories(${libsh_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${libsh_name} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(${libsh_name} PRIVATE ${libsh_name}_EXPORTS)
endif()

if(TinyTIFF_BUILD_STATIC_LIBS)
Expand All @@ -43,10 +46,21 @@ if(TinyTIFF_BUILD_STATIC_LIBS)
target_include_directories(${lib_name} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
#if (HAVE_FOPEN_S)
# target_compile_definitions(${lib_name} PRIVATE HAVE_FOPEN_S)
#endif()
)

if(NOT TinyTIFF_BUILD_SHARED_LIBS)
generate_export_header(${lib_name} BASE_NAME tinytiff)
endif()
target_include_directories(${lib_name} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_include_directories(${lib_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(${lib_name} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(${lib_name} PUBLIC TINYTIFF_STATIC_DEFINE)

endif()

Expand All @@ -70,6 +84,7 @@ if(TinyTIFF_BUILD_SHARED_LIBS)
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${libsh_name} )

endif(TinyTIFF_BUILD_SHARED_LIBS)

if(TinyTIFF_BUILD_STATIC_LIBS)
Expand All @@ -88,12 +103,11 @@ if(TinyTIFF_BUILD_STATIC_LIBS)
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${lib_name} )
endif(TinyTIFF_BUILD_STATIC_LIBS)

install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Headers)
endif(TinyTIFF_BUILD_STATIC_LIBS)

install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT Headers)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinytiff_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
configure_file(${CMAKE_SOURCE_DIR}/readme.txt.in ${CMAKE_CURRENT_BINARY_DIR}/readme.txt @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/readme.txt" DESTINATION "${TinyTIFF_DOC_INSTALL_DIR}/${lib_name}/" )
install(FILES "${CMAKE_SOURCE_DIR}/LICENSE" DESTINATION "${TinyTIFF_DOC_INSTALL_DIR}/${lib_name}/" )
Expand Down
34 changes: 16 additions & 18 deletions src/tinytiffreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
#ifndef TINYTIFFREADER_H
#define TINYTIFFREADER_H

#ifndef TINYTIFFREADER_LIB_EXPORT
# define TINYTIFFREADER_LIB_EXPORT
#endif
#include "tinytiff_export.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -122,7 +120,7 @@ struct TinyTIFFReaderFile; // forward
permission to read it. Also if no TIFF file was detected (first twi bytes were neither 'II' nor 'MM') \c NULL is returned.
*/
TINYTIFFREADER_LIB_EXPORT TinyTIFFReaderFile* TinyTIFFReader_open(const char* filename);
TINYTIFF_EXPORT TinyTIFFReaderFile* TinyTIFFReader_open(const char* filename);


/*! \brief close a given TIFF file
Expand All @@ -132,7 +130,7 @@ TINYTIFFREADER_LIB_EXPORT TinyTIFFReaderFile* TinyTIFFReader_open(const char* fi
This function also releases memory allocated in TinyTIFFReader_open() in \a tiff.
*/
TINYTIFFREADER_LIB_EXPORT void TinyTIFFReader_close(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT void TinyTIFFReader_close(TinyTIFFReaderFile* tiff);

/*! \brief returns a pointer to the last error message
\ingroup tinytiffreader
Expand All @@ -141,31 +139,31 @@ TINYTIFFREADER_LIB_EXPORT void TinyTIFFReader_close(TinyTIFFReaderFile* tiff);
\note the pointer is accessible as long as the TIFF file has not been closed using TinyTIFFReader_close()
*/
TINYTIFFREADER_LIB_EXPORT const char* TinyTIFFReader_getLastError(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT const char* TinyTIFFReader_getLastError(TinyTIFFReaderFile* tiff);

/*! \brief returns TRUE (non-zero) when there was an error in the last function call, or FALSE (zero) if there was no error
\ingroup tinytiffreader
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_wasError(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT int TinyTIFFReader_wasError(TinyTIFFReaderFile* tiff);

/*! \brief returns TRUE (non-zero) when there was no error in the last function call, or FALSE (zero) if there was an error
\ingroup tinytiffreader
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_success(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT int TinyTIFFReader_success(TinyTIFFReaderFile* tiff);

/*! \brief returns TRUE (non-zero) if another frame exists in the TIFF file
\ingroup tinytiffreader
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_hasNext(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT int TinyTIFFReader_hasNext(TinyTIFFReaderFile* tiff);

/*! \brief reads the next frame from a multi-frame TIFF
\ingroup tinytiffreader
Expand All @@ -174,7 +172,7 @@ TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_hasNext(TinyTIFFReaderFile* tiff);
\return TRUE (non-zero) if another frame exists in the TIFF file
*/
TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_readNext(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT int TinyTIFFReader_readNext(TinyTIFFReaderFile* tiff);


/*! \brief return the width of the current frame
Expand All @@ -183,23 +181,23 @@ TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_readNext(TinyTIFFReaderFile* tiff);
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT uint32_t TinyTIFFReader_getWidth(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT uint32_t TinyTIFFReader_getWidth(TinyTIFFReaderFile* tiff);

/*! \brief return the height of the current frame
\ingroup tinytiffreader
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT uint32_t TinyTIFFReader_getHeight(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT uint32_t TinyTIFFReader_getHeight(TinyTIFFReaderFile* tiff);

/*! \brief return the image description of the current frame
\ingroup tinytiffreader
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT std::string TinyTIFFReader_getImageDescription(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT std::string TinyTIFFReader_getImageDescription(TinyTIFFReaderFile* tiff);


#define TINYTIFFREADER_SAMPLEFORMAT_UINT 1
Expand All @@ -213,7 +211,7 @@ TINYTIFFREADER_LIB_EXPORT std::string TinyTIFFReader_getImageDescription(TinyTIF
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT uint16_t TinyTIFFReader_getSampleFormat(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT uint16_t TinyTIFFReader_getSampleFormat(TinyTIFFReaderFile* tiff);

/*! \brief return the bits per sample of the current frame
\ingroup tinytiffreader
Expand All @@ -222,14 +220,14 @@ TINYTIFFREADER_LIB_EXPORT uint16_t TinyTIFFReader_getSampleFormat(TinyTIFFReader
\param sample return bits for the given sample number [default: 0]
*/
TINYTIFFREADER_LIB_EXPORT uint16_t TinyTIFFReader_getBitsPerSample(TinyTIFFReaderFile* tiff, int sample=0);
TINYTIFF_EXPORT uint16_t TinyTIFFReader_getBitsPerSample(TinyTIFFReaderFile* tiff, int sample=0);
/*! \brief return the samples per pixel of the current frame
\ingroup tinytiffreader
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT uint16_t TinyTIFFReader_getSamplesPerPixel(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT uint16_t TinyTIFFReader_getSamplesPerPixel(TinyTIFFReaderFile* tiff);

/*! \brief read the given sample from the current frame into the given buffer,
the byteorder is transformed to the byteorder of the system!
Expand All @@ -244,7 +242,7 @@ TINYTIFFREADER_LIB_EXPORT uint16_t TinyTIFFReader_getSamplesPerPixel(TinyTIFFRea
(taking width, height and bitsPerSample into account).
*/
TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_getSampleData(TinyTIFFReaderFile* tiff, void* buffer, uint16_t sample);
TINYTIFF_EXPORT int TinyTIFFReader_getSampleData(TinyTIFFReaderFile* tiff, void* buffer, uint16_t sample);



Expand All @@ -254,7 +252,7 @@ TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_getSampleData(TinyTIFFReaderFile* t
\param tiff TIFF file
*/
TINYTIFFREADER_LIB_EXPORT uint32_t TinyTIFFReader_countFrames(TinyTIFFReaderFile* tiff);
TINYTIFF_EXPORT uint32_t TinyTIFFReader_countFrames(TinyTIFFReaderFile* tiff);



Expand Down
18 changes: 8 additions & 10 deletions src/tinytiffwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#ifndef TINYTIFFWRITER_H
#define TINYTIFFWRITER_H

#ifndef TINYTIFFWRITER_LIB_EXPORT
# define TINYTIFFWRITER_LIB_EXPORT
#endif
#include "tinytiff_export.h"

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -133,7 +131,7 @@ struct TinyTIFFFile; // forward
/** \brief maximum size of the imageDescription field in the first frame (including trailing \c 0, which has to be present!)
* \ingroup tinytiffwriter
*/
TINYTIFFWRITER_LIB_EXPORT int TinyTIFFWriter_getMaxDescriptionTextSize();
TINYTIFF_EXPORT int TinyTIFFWriter_getMaxDescriptionTextSize();


/*! \brief create a new TIFF file
Expand All @@ -146,17 +144,17 @@ TINYTIFFWRITER_LIB_EXPORT int TinyTIFFWriter_getMaxDescriptionTextSize();
\return a new TinyTIFFFile pointer on success, or NULL on errors
*/
TINYTIFFWRITER_LIB_EXPORT TinyTIFFFile* TinyTIFFWriter_open(const char* filename, uint16_t bitsPerSample, uint32_t width, uint32_t height);
TINYTIFF_EXPORT TinyTIFFFile* TinyTIFFWriter_open(const char* filename, uint16_t bitsPerSample, uint32_t width, uint32_t height);

/*! \brief write a new image to the give TIFF file
\ingroup tinytiffwriter
\param tiff TIFF file to write to
\param data points to the image in row-major ordering with the right bit-depth
*/
TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, void* data);
TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, float* data);
TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, double* data);
TINYTIFF_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, void* data);
TINYTIFF_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, float* data);
TINYTIFF_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, double* data);

/*! \brief close a given TIFF file
\ingroup tinytiffwriter
Expand All @@ -180,7 +178,7 @@ TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_writeImage(TinyTIFFFile* tiff, dou
This function also releases memory allocated in TinyTIFFWriter_open() in \a tiff.
*/
TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_close(TinyTIFFFile* tiff, double pixel_width=0, double pixel_height=0, double frametime=0, double deltaz=0);
TINYTIFF_EXPORT void TinyTIFFWriter_close(TinyTIFFFile* tiff, double pixel_width=0, double pixel_height=0, double frametime=0, double deltaz=0);


/*! \brief close a given TIFF file and write the given string into the IMageDescription tag of the first frame in the file.
Expand All @@ -192,7 +190,7 @@ TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_close(TinyTIFFFile* tiff, double p
This function also releases memory allocated in TinyTIFFWriter_open() in \a tiff.
*/
TINYTIFFWRITER_LIB_EXPORT void TinyTIFFWriter_close(TinyTIFFFile* tiff, const char* imageDescription);
TINYTIFF_EXPORT void TinyTIFFWriter_close(TinyTIFFFile* tiff, const char* imageDescription);

#endif // TINYTIFFWRITER_H

1 change: 0 additions & 1 deletion tests/tinytiffreader_test/tinytiffreader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "tinytiffhighrestimer.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
Expand Down

0 comments on commit 5ef1199

Please sign in to comment.