Skip to content

Commit

Permalink
added CMAAKE-generated export headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jkriege2 committed Jul 20, 2020
1 parent 0a51b38 commit afa10ea
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 64 deletions.
30 changes: 25 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(HEADERS


include(CMakePackageConfigHelpers)

include(GenerateExportHeader)
include(CheckSymbolExists)
check_symbol_exists(fopen_s "stdio.h" HAVE_FOPEN_S)
check_symbol_exists(sprintf_s "stdio.h" HAVE_SPRINTF_S)
Expand Down Expand Up @@ -56,6 +56,14 @@ if(TinyMAT_BUILD_SHARED_LIBS)
target_compile_definitions(${libsh_name} PUBLIC TINYMAT_USES_QVARIANT)
target_link_libraries(${libsh_name} PUBLIC Qt5::Core)
endif()

generate_export_header(${libsh_name} BASE_NAME tinymatwriter)
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(TinyMAT_BUILD_STATIC_LIBS)
Expand Down Expand Up @@ -92,6 +100,20 @@ if(TinyMAT_BUILD_STATIC_LIBS)
target_link_libraries(${lib_name} PUBLIC Qt5::Core)
endif()


if(NOT TinyMAT_BUILD_SHARED_LIBS)
generate_export_header(${lib_name} BASE_NAME tinymatwriter)
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 TINYMATWRITER_STATIC_DEFINE)
endif()


Expand Down Expand Up @@ -134,10 +156,8 @@ if(TinyMAT_BUILD_STATIC_LIBS)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${lib_name} )
endif(TinyMAT_BUILD_STATIC_LIBS)

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

install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT Headers)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinymatwriter_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 "${TinyMAT_DOC_INSTALL_DIR}/${lib_name}/" )
install(FILES "${CMAKE_SOURCE_DIR}/LICENSE" DESTINATION "${TinyMAT_DOC_INSTALL_DIR}/${lib_name}/" )
Expand Down
14 changes: 7 additions & 7 deletions src/tinymatwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ void TinyMATWriter_writeStruct(TinyMATWriterFile *mat, const char *name, const s
mat->endStruct();
}

TINYMATWRITER_LIB_EXPORT void TinyMATWriter_startCellArray(TinyMATWriterFile * mat, const char * name, const int32_t * sizes, uint32_t ndims)
void TinyMATWriter_startCellArray(TinyMATWriterFile * mat, const char * name, const int32_t * sizes, uint32_t ndims)
{
mat->addStructItemName(name);
mat->startCell();
Expand Down Expand Up @@ -1628,7 +1628,7 @@ TINYMATWRITER_LIB_EXPORT void TinyMATWriter_startCellArray(TinyMATWriterFile * m

}

TINYMATWRITER_LIB_EXPORT void TinyMATWriter_endCellArray(TinyMATWriterFile * mat)
void TinyMATWriter_endCellArray(TinyMATWriterFile * mat)
{
TinyMATWriterCell& cell = mat->lastCell();

Expand Down Expand Up @@ -2020,7 +2020,7 @@ void TinyMATWriter_writeStringVector(TinyMATWriterFile *mat, const char *name, c
#endif

#ifdef TINYMAT_USES_OPENCV
TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeCVMat(TinyMATWriterFile* mat, const char* name, const cv::Mat& img) {
void TinyMATWriter_writeCVMat(TinyMATWriterFile* mat, const char* name, const cv::Mat& img) {
if (img.rows<=0 || img.cols<=0) {
//throw std::runtime_error("OpenCV Matrix has too many dimensions or is empty");
TinyMATWriter_writeEmptyMatrix(mat, name);
Expand Down Expand Up @@ -2050,7 +2050,7 @@ TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeCVMat(TinyMATWriterFile* mat, c
}

template <>
TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2d>& data_vec) {
void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2d>& data_vec) {
if (data_vec.size() <= 0) TinyMATWriter_writeEmptyMatrix(mat, name);
int32_t siz[2] = { 2, (int32_t)data_vec.size() };
double* tmp = (double*)malloc(data_vec.size() * 2 * sizeof(double));
Expand All @@ -2066,7 +2066,7 @@ TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFil
}

template <>
TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2i>& data_vec) {
void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2i>& data_vec) {
if (data_vec.size() <= 0) TinyMATWriter_writeEmptyMatrix(mat, name);
int32_t siz[2] = { 2, (int32_t)data_vec.size() };
int* tmp = (int*)malloc(data_vec.size() * 2 * sizeof(int));
Expand All @@ -2082,7 +2082,7 @@ TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFil
}

template <>
TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2f>& data_vec) {
void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2f>& data_vec) {
if (data_vec.size() <= 0) TinyMATWriter_writeEmptyMatrix(mat, name);
int32_t siz[2] = { 2, (int32_t)data_vec.size() };
float* tmp = (float*)malloc(data_vec.size() * 2 * sizeof(float));
Expand All @@ -2098,7 +2098,7 @@ TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFil
}

template <>
TINYMATWRITER_LIB_EXPORT void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2l>& data_vec) {
void TinyMATWriter_writeContainerAsRow(TinyMATWriterFile* mat, const char* name, const std::vector<cv::Point2l>& data_vec) {
if (data_vec.size() <= 0) TinyMATWriter_writeEmptyMatrix(mat, name);
int32_t siz[2] = { 2, (int32_t)data_vec.size() };
int64_t* tmp = (int64_t*)malloc(data_vec.size() * 2 * sizeof(int64_t));
Expand Down
Loading

0 comments on commit afa10ea

Please sign in to comment.