Skip to content

Commit

Permalink
Build static lib if not defined WINGETOPT_SHARED_LIB
Browse files Browse the repository at this point in the history
  • Loading branch information
alex85k committed Oct 18, 2017
1 parent 3a65e84 commit fed839a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 7 additions & 3 deletions src/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
/* All the headers include this file. */
#include <crtdefs.h>

#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
Expand Down

0 comments on commit fed839a

Please sign in to comment.