Adding adding GEN_X macro for cmake export header

This commit is contained in:
Michael Tryby
2018-08-22 15:46:24 -04:00
parent c6fe1230d0
commit 0938f82c32
2 changed files with 41 additions and 35 deletions

View File

@@ -80,12 +80,15 @@ target_include_directories(epanet PUBLIC ${PROJECT_SOURCE_DIR}/include)
# create export lib so we can link against dll using Visual Studio # create export lib so we can link against dll using Visual Studio
include(GenerateExportHeader) IF (GEN_X)
GENERATE_EXPORT_HEADER(epanet include(GenerateExportHeader)
GENERATE_EXPORT_HEADER(epanet
BASE_NAME epanet BASE_NAME epanet
EXPORT_MACRO_NAME DLLEXPORT EXPORT_MACRO_NAME DLLEXPORT
EXPORT_FILE_NAME epanet_export.h EXPORT_FILE_NAME epanet_export.h
STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_export.h file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_export.h
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include) DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)
ENDIF (GEN_X)

View File

@@ -30,37 +30,40 @@
#define EN_API_FLOAT_TYPE float #define EN_API_FLOAT_TYPE float
#endif #endif
// // --- define WINDOWS #ifdef GEN_X
// #undef WINDOWS #include "epanet_export.h"
// #ifdef _WIN32 #else
// #define WINDOWS // --- define WINDOWS
// #endif #undef WINDOWS
// #ifdef __WIN32__ #ifdef _WIN32
// #define WINDOWS #define WINDOWS
// #endif #endif
#ifdef __WIN32__
#define WINDOWS
#endif
// // --- define DLLEXPORT // --- define DLLEXPORT
// #ifndef DLLEXPORT #ifndef DLLEXPORT
// #ifdef WINDOWS #ifdef WINDOWS
// #ifdef __cplusplus #ifdef __cplusplus
// #define DLLEXPORT __declspec(dllexport) #define DLLEXPORT __declspec(dllexport)
// #else #else
// #define DLLEXPORT __declspec(dllexport) __stdcall #define DLLEXPORT __declspec(dllexport) __stdcall
// #endif // __cplusplus #endif // __cplusplus
// #elif defined(CYGWIN) #elif defined(CYGWIN)
// #define DLLEXPORT __stdcall #define DLLEXPORT __stdcall
// #elif defined(__APPLE__) #elif defined(__APPLE__)
// #ifdef __cplusplus #ifdef __cplusplus
// #define DLLEXPORT #define DLLEXPORT
// #else #else
// #define DLLEXPORT #define DLLEXPORT
// #endif #endif
// #else #else
// #define DLLEXPORT #define DLLEXPORT
// #endif #endif
// #endif #endif
#endif
#include "epanet_export.h"
// --- Define the EPANET toolkit constants // --- Define the EPANET toolkit constants