diff --git a/.gitignore b/.gitignore index 45599ee..6fc788b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ tinytiffreader.d tinytiffreader.o tinytiffwriter.d tinytiffwriter.o +/*.user diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4abc7f..3978b5f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) @@ -30,9 +28,14 @@ if(TinyTIFF_BUILD_SHARED_LIBS) $ ) 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 + $ + $ + ) + target_compile_definitions(${libsh_name} PRIVATE ${libsh_name}_EXPORTS) endif() if(TinyTIFF_BUILD_STATIC_LIBS) @@ -43,10 +46,21 @@ if(TinyTIFF_BUILD_STATIC_LIBS) target_include_directories(${lib_name} INTERFACE $ $ - ) - #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 + $ + $ + ) + target_include_directories(${lib_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories(${lib_name} INTERFACE + $ + $ + ) + target_compile_definitions(${lib_name} PUBLIC TINYTIFF_STATIC_DEFINE) endif() @@ -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) @@ -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}/" ) diff --git a/src/tinytiffreader.h b/src/tinytiffreader.h index 4c3e014..cb45f48 100644 --- a/src/tinytiffreader.h +++ b/src/tinytiffreader.h @@ -21,9 +21,7 @@ #ifndef TINYTIFFREADER_H #define TINYTIFFREADER_H -#ifndef TINYTIFFREADER_LIB_EXPORT -# define TINYTIFFREADER_LIB_EXPORT -#endif +#include "tinytiff_export.h" #include #include @@ -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 @@ -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 @@ -141,7 +139,7 @@ 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 @@ -149,7 +147,7 @@ TINYTIFFREADER_LIB_EXPORT const char* TinyTIFFReader_getLastError(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 @@ -157,7 +155,7 @@ TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_wasError(TinyTIFFReaderFile* tiff); \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 @@ -165,7 +163,7 @@ TINYTIFFREADER_LIB_EXPORT int TinyTIFFReader_success(TinyTIFFReaderFile* tiff); \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 @@ -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 @@ -183,7 +181,7 @@ 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 @@ -191,7 +189,7 @@ TINYTIFFREADER_LIB_EXPORT uint32_t TinyTIFFReader_getWidth(TinyTIFFReaderFile* t \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 @@ -199,7 +197,7 @@ TINYTIFFREADER_LIB_EXPORT uint32_t TinyTIFFReader_getHeight(TinyTIFFReaderFile* \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 @@ -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 @@ -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! @@ -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); @@ -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); diff --git a/src/tinytiffwriter.h b/src/tinytiffwriter.h index 6c18dd7..b3a0798 100644 --- a/src/tinytiffwriter.h +++ b/src/tinytiffwriter.h @@ -24,9 +24,7 @@ #ifndef TINYTIFFWRITER_H #define TINYTIFFWRITER_H -#ifndef TINYTIFFWRITER_LIB_EXPORT -# define TINYTIFFWRITER_LIB_EXPORT -#endif +#include "tinytiff_export.h" #include #include @@ -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 @@ -146,7 +144,7 @@ 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 @@ -154,9 +152,9 @@ TINYTIFFWRITER_LIB_EXPORT TinyTIFFFile* TinyTIFFWriter_open(const char* filename \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 @@ -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. @@ -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 diff --git a/tests/tinytiffreader_test/tinytiffreader_test.cpp b/tests/tinytiffreader_test/tinytiffreader_test.cpp index d0e3f60..75fc077 100644 --- a/tests/tinytiffreader_test/tinytiffreader_test.cpp +++ b/tests/tinytiffreader_test/tinytiffreader_test.cpp @@ -11,7 +11,6 @@ #include "tinytiffhighrestimer.h" #include #include -#include #include #include #include