fix windows DLL build

This commit is contained in:
Geoff McLane 2015-01-28 17:15:44 +01:00
parent 59974e0bb0
commit 85070acd8c
3 changed files with 48 additions and 24 deletions

View file

@ -16,7 +16,8 @@ set( tidy_DAY 20 )
# Allow developer to select is Dynamic or static library built # Allow developer to select is Dynamic or static library built
set( LIB_TYPE STATIC ) # set default static 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) if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "*** Have SIZEOF void * = 8, so 64-bit") message(STATUS "*** Have SIZEOF void * = 8, so 64-bit")
@ -115,6 +116,14 @@ set_target_properties( ${name} PROPERTIES
set_target_properties( ${name} PROPERTIES set_target_properties( ${name} PROPERTIES
VERSION ${LIBTIDY_VERSION} VERSION ${LIBTIDY_VERSION}
SOVERSION ${TIDY_MAJOR_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} ) list ( APPEND add_LIBS ${name} )
install(TARGETS ${name} install(TARGETS ${name}
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
@ -132,14 +141,21 @@ target_link_libraries( ${name} ${add_LIBS} )
if (MSVC) if (MSVC)
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d ) set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
endif () endif ()
if (BUILD_SHARED_LIB)
set_target_properties( ${name} PROPERTIES
COMPILE_FLAGS "-DBUILD_SHARED_LIB"
)
endif ()
install (TARGETS ${name} DESTINATION bin) install (TARGETS ${name} DESTINATION bin)
if (BUILD_TAB2SPACE)
set(name tab2space) set(name tab2space)
add_executable( ${name} ${BINDIR}/tab2space.c ) add_executable( ${name} ${BINDIR}/tab2space.c )
if (MSVC) if (MSVC)
set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d ) set_target_properties( ${name} PROPERTIES DEBUG_POSTFIX d )
endif () endif ()
# no INSTALL of this 'local' tool # no INSTALL of this 'local' tool
endif ()
# eof # eof

View file

@ -495,8 +495,14 @@ extern "C" {
#if defined(_WIN32) #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 ) #define TIDY_EXPORT __declspec( dllexport )
#else
#define TIDY_EXPORT __declspec( dllimport )
#endif
#else
#define TIDY_EXPORT extern
#endif #endif
#ifndef TIDY_CALL #ifndef TIDY_CALL

View file

@ -27,6 +27,8 @@
// Debug log file output // Debug log file output
#ifndef _SPRTF_HXX_ #ifndef _SPRTF_HXX_
#define _SPRTF_HXX_ #define _SPRTF_HXX_
#include "platform.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -36,32 +38,32 @@ extern "C" {
#define MCDECL #define MCDECL
#endif #endif
extern int add_std_out( int val ); TIDY_EXPORT int add_std_out( int val );
extern int add_sys_time( int val ); TIDY_EXPORT int add_sys_time( int val );
extern int add_sys_date( int val ); TIDY_EXPORT int add_sys_date( int val );
extern int add_screen_out( int val ); TIDY_EXPORT int add_screen_out( int val );
extern int add_list_out( int val ); TIDY_EXPORT int add_list_out( int val );
extern int add_append_log( int val ); TIDY_EXPORT int add_append_log( int val );
extern int open_log_file( void ); TIDY_EXPORT int open_log_file( void );
extern void close_log_file( void ); TIDY_EXPORT void close_log_file( void );
extern void set_log_file( char * nf, int open ); TIDY_EXPORT void set_log_file( char * nf, int open );
extern char * get_log_file( void ); 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 #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) ) #define EndBuf(a) ( a + strlen(a) )
extern char *get_date_stg(); TIDY_EXPORT char *get_date_stg();
extern char *get_time_stg(); TIDY_EXPORT char *get_time_stg();
extern char *get_date_time_stg(); TIDY_EXPORT char *get_date_time_stg();
#ifdef _MSC_VER #ifdef _MSC_VER
extern int gettimeofday(struct timeval *tp, void *tzp); TIDY_EXPORT int gettimeofday(struct timeval *tp, void *tzp);
#endif #endif
#ifndef SPRTF #ifndef SPRTF