diff --git a/CMakeLists.txt b/CMakeLists.txt index deceb65..1283013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,15 @@ ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS") ADD_DEFINITIONS("-D_CRT_NONSTDC_NO_DEPRECATE") ENDIF(MSVC) +OPTION(ENABLE_STATIC "Enable static builds" OFF) +IF(ENABLE_STATIC) + set(BUILD_SHARED_LIBS OFF) + set(ZIP_EXTERN_OVERRIDE ON) + set(ZIP_EXTERN ON) +ELSE(ENABLE_STATIC) + set(BUILD_SHARED_LIBS ON) +ENDIF(ENABLE_STATIC) + ADD_DEFINITIONS("-DHAVE_CONFIG_H") # rpath handling: use rpath in installed binaries @@ -121,10 +130,10 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Targets ADD_SUBDIRECTORY(lib) -ADD_SUBDIRECTORY(man) -ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(regress) -ADD_SUBDIRECTORY(examples) +# ADD_SUBDIRECTORY(man) +# ADD_SUBDIRECTORY(src) +# ADD_SUBDIRECTORY(regress) +# ADD_SUBDIRECTORY(examples) # pkgconfig file SET(prefix ${CMAKE_INSTALL_PREFIX}) diff --git a/cmake-config.h.in b/cmake-config.h.in index 0d1839c..dd450ff 100644 --- a/cmake-config.h.in +++ b/cmake-config.h.in @@ -60,7 +60,7 @@ #cmakedefine WORDS_BIGENDIAN /* END DEFINES */ #define PACKAGE "@PACKAGE@" -#define VERSION "@VERSION@" +#define LIBZIP_VERSION "@VERSION@" #ifndef HAVE_SSIZE_T_LIBZIP # if SIZE_T_LIBZIP == INT_LIBZIP diff --git a/cmake-zipconf.h.in b/cmake-zipconf.h.in index 6a276f6..410c898 100644 --- a/cmake-zipconf.h.in +++ b/cmake-zipconf.h.in @@ -118,4 +118,10 @@ typedef unsigned long long zip_uint64_t; #define ZIP_INT64_MAX 0x7fffffffffffffffLL #define ZIP_UINT64_MAX 0xffffffffffffffffULL +#cmakedefine ZIP_EXTERN_OVERRIDE +#ifdef ZIP_EXTERN_OVERRIDE +#undef ZIP_EXTERN +#cmakedefine ZIP_EXTERN +#endif + #endif /* zipconf.h */ diff --git a/lib/compat.h b/lib/compat.h index 625c84e..8943587 100644 --- a/lib/compat.h +++ b/lib/compat.h @@ -42,7 +42,9 @@ #define __STDC_LIMIT_MACROS #ifdef _WIN32 +#ifndef ZIP_EXTERN_OVERRIDE #define ZIP_EXTERN __declspec(dllexport) +#endif /* for dup(), close(), etc. */ #include #endif