From fed839a02eca9abaebb834d3e53c583ff4304e1c Mon Sep 17 00:00:00 2001 From: alex85k Date: Wed, 18 Oct 2017 11:52:59 +0500 Subject: [PATCH] Build static lib if not defined WINGETOPT_SHARED_LIB --- CMakeLists.txt | 4 +++- src/getopt.h | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 394664c..663f0c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,11 @@ option(BUILD_SHARED_LIBS "Build the shared library" OFF) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) +add_definitions(-D_CRT_SECURE_NO_WARNINGS) + if(BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - add_definitions(-DBUILDING_WINGETOPT_DLL) + add_definitions(-DBUILDING_WINGETOPT_DLL -DWINGETOPT_SHARED_LIB) endif() add_library(wingetopt src/getopt.c src/getopt.h) diff --git a/src/getopt.h b/src/getopt.h index 7c9b01d..f3f864b 100644 --- a/src/getopt.h +++ b/src/getopt.h @@ -15,10 +15,14 @@ /* All the headers include this file. */ #include -#if defined( BUILDING_WINGETOPT_DLL ) -#define WINGETOPT_API __declspec(dllexport) +#if defined( WINGETOPT_SHARED_LIB ) +# if defined( BUILDING_WINGETOPT_DLL ) +# define WINGETOPT_API __declspec(dllexport) +# else +# define WINGETOPT_API __declspec(dllimport) +# endif #else -#define WINGETOPT_API __declspec(dllimport) +# define WINGETOPT_API #endif #ifdef __cplusplus