bugfix: some examples didn't compile with -DWITHOUT_EASY

This commit is contained in:
tastytea 2018-07-19 11:06:16 +02:00
parent e18c9b1c35
commit 63fd9f581c
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
6 changed files with 32 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project (mastodon-cpp project (mastodon-cpp
VERSION 0.18.2 VERSION 0.18.3
LANGUAGES CXX LANGUAGES CXX
) )
@ -8,7 +8,9 @@ include(GNUInstallDirs)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(CURLPP REQUIRED curlpp) 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 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -62,6 +64,7 @@ set_target_properties(mastodon-cpp PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
SOVERSION ${mastodon-cpp_VERSION_MAJOR} SOVERSION ${mastodon-cpp_VERSION_MAJOR}
) )
if(WITHOUT_EASY) if(WITHOUT_EASY)
target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES}) target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES})
else() else()

View File

@ -120,6 +120,7 @@ int main(int argc, char *argv[])
} }
#else #else
#include <cstdio>
int main() int main()
{ {
printf("mastodon-cpp was compiled without Easy support.\n"); printf("mastodon-cpp was compiled without Easy support.\n");

View File

@ -102,6 +102,7 @@ int main(int argc, char *argv[])
} }
#else #else
#include <cstdio>
int main() int main()
{ {
printf("mastodon-cpp was compiled without Easy support.\n"); printf("mastodon-cpp was compiled without Easy support.\n");

View File

@ -121,6 +121,7 @@ int main(int argc, char *argv[])
} }
#else #else
#include <cstdio>
int main() int main()
{ {
printf("mastodon-cpp was compiled without Easy support.\n"); printf("mastodon-cpp was compiled without Easy support.\n");

View File

@ -2,6 +2,9 @@
* Get fields from own account. * Get fields from own account.
*/ */
// Don't compile this if the Easy-interface is turned off
#ifndef WITHOUT_EASY
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <string> #include <string>
@ -43,3 +46,12 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
#else
#include <cstdio>
int main()
{
printf("mastodon-cpp was compiled without Easy support.\n");
return 255;
}
#endif // WITHOUT_EASY

View File

@ -1,6 +1,9 @@
/* This file is part of mastodon-cpp. /* This file is part of mastodon-cpp.
*/ */
// Don't compile this if the Easy-interface is turned off
#ifndef WITHOUT_EASY
#include <iostream> #include <iostream>
#include <cstdint> #include <cstdint>
#include "mastodon-cpp.hpp" #include "mastodon-cpp.hpp"
@ -25,3 +28,12 @@ int main(int argc, char *argv[])
std::cout << ret << ": " << answer << '\n'; std::cout << ret << ": " << answer << '\n';
return 1; return 1;
} }
#else
#include <cstdio>
int main()
{
printf("mastodon-cpp was compiled without Easy support.\n");
return 0;
}
#endif // WITHOUT_EASY