diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b98b29..99f54c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,8 @@ set( tidy_DAY 20 ) # Allow developer to select is Dynamic or static library built set( LIB_TYPE STATIC ) # set default static -option( BUILD_SHARED_LIB "Build Shared Library" OFF ) +option( BUILD_SHARED_LIB "Set ON to build Shared (DLL) Library" OFF ) +option( BUILD_TAB2SPACE "Set ON to build utility app, tab2space" OFF ) if (CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "*** Have SIZEOF void * = 8, so 64-bit") @@ -115,6 +116,14 @@ set_target_properties( ${name} PROPERTIES set_target_properties( ${name} PROPERTIES VERSION ${LIBTIDY_VERSION} SOVERSION ${TIDY_MAJOR_VERSION} ) +if (BUILD_SHARED_LIB) +set_target_properties( ${name} PROPERTIES + COMPILE_FLAGS "-DBUILD_SHARED_LIB" + ) +set_target_properties( ${name} PROPERTIES + COMPILE_FLAGS "-DBUILDING_SHARED_LIB" + ) +endif () list ( APPEND add_LIBS ${name} ) install(TARGETS ${name} RUNTIME DESTINATION bin @@ -132,14 +141,21 @@ target_link_libraries( ${name} ${add_LIBS} ) if (MSVC) set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d ) endif () +if (BUILD_SHARED_LIB) +set_target_properties( ${name} PROPERTIES + COMPILE_FLAGS "-DBUILD_SHARED_LIB" + ) +endif () install (TARGETS ${name} DESTINATION bin) -set(name tab2space) -add_executable( ${name} ${BINDIR}/tab2space.c ) -if (MSVC) - set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d ) +if (BUILD_TAB2SPACE) + set(name tab2space) + add_executable( ${name} ${BINDIR}/tab2space.c ) + if (MSVC) + set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d ) + endif () + # no INSTALL of this 'local' tool endif () -# no INSTALL of this 'local' tool # eof diff --git a/include/platform.h b/include/platform.h index 632e458..3b60114 100644 --- a/include/platform.h +++ b/include/platform.h @@ -495,8 +495,14 @@ extern "C" { #if defined(_WIN32) -#if (defined(_USRDLL) || defined(_WINDLL)) && !defined(TIDY_EXPORT) +#if (defined(_USRDLL) || defined(_WINDLL)) || defined(BUILD_SHARED_LIB) && !defined(TIDY_EXPORT) +#ifdef BUILDING_SHARED_LIB #define TIDY_EXPORT __declspec( dllexport ) +#else +#define TIDY_EXPORT __declspec( dllimport ) +#endif +#else +#define TIDY_EXPORT extern #endif #ifndef TIDY_CALL diff --git a/src/sprtf.h b/src/sprtf.h index 23db8ae..97c9765 100644 --- a/src/sprtf.h +++ b/src/sprtf.h @@ -27,6 +27,8 @@ // Debug log file output #ifndef _SPRTF_HXX_ #define _SPRTF_HXX_ +#include "platform.h" + #ifdef __cplusplus extern "C" { #endif @@ -36,32 +38,32 @@ extern "C" { #define MCDECL #endif -extern int add_std_out( int val ); -extern int add_sys_time( int val ); -extern int add_sys_date( int val ); +TIDY_EXPORT int add_std_out( int val ); +TIDY_EXPORT int add_sys_time( int val ); +TIDY_EXPORT int add_sys_date( int val ); -extern int add_screen_out( int val ); -extern int add_list_out( int val ); -extern int add_append_log( int val ); +TIDY_EXPORT int add_screen_out( int val ); +TIDY_EXPORT int add_list_out( int val ); +TIDY_EXPORT int add_append_log( int val ); -extern int open_log_file( void ); -extern void close_log_file( void ); -extern void set_log_file( char * nf, int open ); -extern char * get_log_file( void ); +TIDY_EXPORT int open_log_file( void ); +TIDY_EXPORT void close_log_file( void ); +TIDY_EXPORT void set_log_file( char * nf, int open ); +TIDY_EXPORT char * get_log_file( void ); -extern int MCDECL sprtf( const char *pf, ... ); +TIDY_EXPORT int MCDECL sprtf( const char *pf, ... ); #define M_MAX_SPRTF 2048 -extern int direct_out_it( char *cp ); +TIDY_EXPORT int direct_out_it( char *cp ); -extern char *GetNxtBuf(); +TIDY_EXPORT char *GetNxtBuf(); #define EndBuf(a) ( a + strlen(a) ) -extern char *get_date_stg(); -extern char *get_time_stg(); -extern char *get_date_time_stg(); +TIDY_EXPORT char *get_date_stg(); +TIDY_EXPORT char *get_time_stg(); +TIDY_EXPORT char *get_date_time_stg(); #ifdef _MSC_VER -extern int gettimeofday(struct timeval *tp, void *tzp); +TIDY_EXPORT int gettimeofday(struct timeval *tp, void *tzp); #endif #ifndef SPRTF