From c756f7f5d90ad7591d4f96bb0da8159634943359 Mon Sep 17 00:00:00 2001 From: costan Date: Thu, 27 Jul 2017 16:31:00 -0700 Subject: [PATCH] Support both static and shared library CMake builds. This can be used to fix https://github.com/Homebrew/homebrew-core/issues/15722. --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e858493..e5a3680 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.1) PROJECT(Snappy VERSION 1.1.6 LANGUAGES C CXX) +# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make +# it prominent in the GUI. +OPTION (BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) + SET(CMAKE_INCLUDE_CURRENT_DIR ON) INCLUDE(CheckIncludeFiles) @@ -73,7 +77,7 @@ IF (WIN32) ENDIF (WIN32) # Define the main library. -ADD_LIBRARY(snappy SHARED +ADD_LIBRARY(snappy snappy-c.cc snappy-c.h snappy-sinksource.cc @@ -85,7 +89,9 @@ ADD_LIBRARY(snappy SHARED TARGET_COMPILE_DEFINITIONS(snappy PRIVATE -DHAVE_CONFIG_H) -SET_TARGET_PROPERTIES(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +IF (BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) +ENDIF (BUILD_SHARED_LIBS) INSTALL(FILES snappy.h snappy-c.h