From 63fd9f581c133213b6b10f6e9271873a76295446 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 19 Jul 2018 11:06:16 +0200 Subject: [PATCH] bugfix: some examples didn't compile with -DWITHOUT_EASY --- CMakeLists.txt | 7 +++++-- examples/example12_easy_laststatus.cpp | 1 + examples/example13_easy_stream.cpp | 1 + examples/example14_easy_treeview.cpp | 1 + examples/example16_account_fields.cpp | 12 ++++++++++++ tests/test_02_easy_get_public_timeline.cpp | 12 ++++++++++++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24aef43..b3486a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastodon-cpp - VERSION 0.18.2 + VERSION 0.18.3 LANGUAGES CXX ) @@ -8,7 +8,9 @@ include(GNUInstallDirs) find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(CURLPP REQUIRED curlpp) -pkg_check_modules(JSONCPP REQUIRED jsoncpp) +if(NOT WITHOUT_EASY) + pkg_check_modules(JSONCPP REQUIRED jsoncpp) +endif() set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -62,6 +64,7 @@ set_target_properties(mastodon-cpp PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${mastodon-cpp_VERSION_MAJOR} ) + if(WITHOUT_EASY) target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES}) else() diff --git a/examples/example12_easy_laststatus.cpp b/examples/example12_easy_laststatus.cpp index 737daf0..07f9842 100644 --- a/examples/example12_easy_laststatus.cpp +++ b/examples/example12_easy_laststatus.cpp @@ -120,6 +120,7 @@ int main(int argc, char *argv[]) } #else +#include int main() { printf("mastodon-cpp was compiled without Easy support.\n"); diff --git a/examples/example13_easy_stream.cpp b/examples/example13_easy_stream.cpp index ac74fe3..444ddfc 100644 --- a/examples/example13_easy_stream.cpp +++ b/examples/example13_easy_stream.cpp @@ -102,6 +102,7 @@ int main(int argc, char *argv[]) } #else +#include int main() { printf("mastodon-cpp was compiled without Easy support.\n"); diff --git a/examples/example14_easy_treeview.cpp b/examples/example14_easy_treeview.cpp index f130a1e..e5ff7ef 100644 --- a/examples/example14_easy_treeview.cpp +++ b/examples/example14_easy_treeview.cpp @@ -121,6 +121,7 @@ int main(int argc, char *argv[]) } #else +#include int main() { printf("mastodon-cpp was compiled without Easy support.\n"); diff --git a/examples/example16_account_fields.cpp b/examples/example16_account_fields.cpp index bc549f8..6a05a7e 100644 --- a/examples/example16_account_fields.cpp +++ b/examples/example16_account_fields.cpp @@ -2,6 +2,9 @@ * Get fields from own account. */ +// Don't compile this if the Easy-interface is turned off +#ifndef WITHOUT_EASY + #include #include #include @@ -43,3 +46,12 @@ int main(int argc, char *argv[]) return 0; } + +#else +#include +int main() +{ + printf("mastodon-cpp was compiled without Easy support.\n"); + return 255; +} +#endif // WITHOUT_EASY diff --git a/tests/test_02_easy_get_public_timeline.cpp b/tests/test_02_easy_get_public_timeline.cpp index 46112c8..4f3aaae 100644 --- a/tests/test_02_easy_get_public_timeline.cpp +++ b/tests/test_02_easy_get_public_timeline.cpp @@ -1,6 +1,9 @@ /* This file is part of mastodon-cpp. */ +// Don't compile this if the Easy-interface is turned off +#ifndef WITHOUT_EASY + #include #include #include "mastodon-cpp.hpp" @@ -25,3 +28,12 @@ int main(int argc, char *argv[]) std::cout << ret << ": " << answer << '\n'; return 1; } + +#else +#include +int main() +{ + printf("mastodon-cpp was compiled without Easy support.\n"); + return 0; +} +#endif // WITHOUT_EASY