From fb0a7c0f7f791cbdb60efb73ffb3e263ad2e721b Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 19 Jul 2018 12:02:42 +0200 Subject: [PATCH] Added option to compile to static library --- CMakeLists.txt | 14 ++++++++++++-- packages/gentoo/mastodon-cpp-0.0.0.ebuild | 5 ++++- packages/gentoo/mastodon-cpp-9999.ebuild | 6 +++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3486a9..0c2be8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,8 @@ else() endif() add_library(mastodon-cpp SHARED ${sources}) set_target_properties(mastodon-cpp PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${mastodon-cpp_VERSION_MAJOR} + VERSION ${PROJECT_VERSION} + SOVERSION ${mastodon-cpp_VERSION_MAJOR} ) if(WITHOUT_EASY) @@ -71,6 +71,12 @@ else() target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES} ${JSONCPP_LIBRARIES}) endif() +if(WITH_STATIC) + add_library(mastodon-cpp_static STATIC ${sources}) + set_target_properties(mastodon-cpp_static PROPERTIES + OUTPUT_NAME mastodon-cpp) +endif() + # Compile examples if(WITH_EXAMPLES) file(GLOB sources_examples examples/*.cpp) @@ -95,6 +101,10 @@ endif() # Install library and header files install(TARGETS mastodon-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +if(WITH_STATIC) + install(TARGETS mastodon-cpp_static LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR}) +endif() install(FILES src/mastodon-cpp.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp) if(NOT WITHOUT_EASY) diff --git a/packages/gentoo/mastodon-cpp-0.0.0.ebuild b/packages/gentoo/mastodon-cpp-0.0.0.ebuild index bb2694d..d452c53 100644 --- a/packages/gentoo/mastodon-cpp-0.0.0.ebuild +++ b/packages/gentoo/mastodon-cpp-0.0.0.ebuild @@ -10,7 +10,7 @@ SRC_URI="https://schlomp.space/tastytea/mastodon-cpp/archive/${PV}.tar.gz -> ${P LICENSE="GPL-3" SLOT="0" KEYWORDS="~amd64" -IUSE="doc debug examples" +IUSE="doc debug examples static-libs" RDEPEND=">=dev-cpp/curlpp-0.8.1 >=dev-libs/jsoncpp-1.8.4" DEPEND=">=dev-util/cmake-3.9.6 @@ -34,6 +34,9 @@ src_configure() { else mycmakeargs+=(-DCMAKE_BUILD_TYPE=Release) fi + if use static-libs; then + mycmakeargs+=(-DWITH_STATIC=YES) + fi cmake-utils_src_configure } diff --git a/packages/gentoo/mastodon-cpp-9999.ebuild b/packages/gentoo/mastodon-cpp-9999.ebuild index 4e52dba..75dcd0d 100644 --- a/packages/gentoo/mastodon-cpp-9999.ebuild +++ b/packages/gentoo/mastodon-cpp-9999.ebuild @@ -10,7 +10,7 @@ EGIT_REPO_URI="https://schlomp.space/tastytea/mastodon-cpp.git" LICENSE="GPL-3" SLOT="0" KEYWORDS="" -IUSE="doc debug examples" +IUSE="doc debug examples static-libs" RDEPEND=">=dev-cpp/curlpp-0.8.1 >=dev-libs/jsoncpp-1.8.1" DEPEND=">=dev-util/cmake-3.9.6 @@ -33,6 +33,10 @@ src_configure() { mycmakeargs+=(-DCMAKE_BUILD_TYPE=Release) fi + if use static-libs; then + mycmakeargs+=(-DWITH_STATIC=YES) + fi + cmake-utils_src_configure }