From 517f95bfc517467c4d37234645c347c69bbd0871 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 2 May 2020 12:31:04 +0200 Subject: [PATCH] Support for building Static --- CMakeLists.txt | 6 +++++- conanfile.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0064a29..dc35dc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") set(CMAKE_CXX_STANDARD 17) file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp") -add_library(Arbutils SHARED ${SRC_FILES}) +if (SHARED) + add_library(Arbutils SHARED ${SRC_FILES}) +else() + add_library(Arbutils STATIC ${SRC_FILES}) +endif(SHARED) set_target_properties(Arbutils PROPERTIES LINKER_LANGUAGE CXX) if (WINDOWS) diff --git a/conanfile.py b/conanfile.py index 094f77e..dffea4f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -19,6 +19,11 @@ class ArbutilsConan(ConanFile): if self.settings.os == "Windows": self.output.warn("Noticed Windows target, setting Cmake WINDOWS=On.") cmake.definitions["WINDOWS"] = "On" + if self.options["shared"]: + self.output.info("Building shared library.") + cmake.definitions["SHARED"] = "On" + else: + self.output.info("Building static library.") cmake.configure() cmake.build() @@ -30,6 +35,7 @@ class ArbutilsConan(ConanFile): self.copy("*.hpp", dst="include/Arbutils", src="src") self.copy("*.dll", dst="bin", keep_path=False) self.copy("*.so", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) def package_info(self): self.cpp_info.libs = ["Arbutils"]