Set default values for all custom cmake-variables.
And changed WITHOUT_EASY to WITH_EASY.
This commit is contained in:
parent
beb6910085
commit
d7bec891dd
|
@ -4,11 +4,18 @@ project (mastodon-cpp
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(WITH_EASY "YES" CACHE STRING "WITH_EASY defaults to \"YES\"")
|
||||||
|
set(WITH_EXAMPLES "YES" CACHE STRING "WITH_EXAMPLES defaults to \"YES\"")
|
||||||
|
set(WITH_TESTS "NO" CACHE STRING "WITH_TESTS defaults to \"NO\"")
|
||||||
|
set(WITH_DOC "YES" CACHE STRING "WITH_DOC defaults to \"YES\"")
|
||||||
|
set(WITH_DEB "NO" CACHE STRING "WITH_DEB defaults to \"NO\"")
|
||||||
|
set(WITH_RPM "NO" CACHE STRING "WITH_RPM defaults to \"NO\"")
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
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)
|
||||||
if(NOT WITHOUT_EASY)
|
if(WITH_EASY)
|
||||||
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
|
pkg_check_modules(JSONCPP REQUIRED jsoncpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -49,16 +56,16 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-DDEBUG=1)
|
add_definitions(-DDEBUG=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITHOUT_EASY)
|
if(NOT WITH_EASY)
|
||||||
add_definitions(-DWITHOUT_EASY=1)
|
add_definitions(-DWITHOUT_EASY=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compile library
|
# Compile library
|
||||||
if(WITHOUT_EASY)
|
if(WITH_EASY)
|
||||||
file(GLOB sources src/*.cpp src/api/*.cpp)
|
|
||||||
else()
|
|
||||||
file(GLOB sources src/*.cpp src/api/*.cpp
|
file(GLOB sources src/*.cpp src/api/*.cpp
|
||||||
src/easy/*.cpp src/easy/entities/*.cpp)
|
src/easy/*.cpp src/easy/entities/*.cpp)
|
||||||
|
else()
|
||||||
|
file(GLOB sources src/*.cpp src/api/*.cpp)
|
||||||
endif()
|
endif()
|
||||||
add_library(mastodon-cpp SHARED ${sources})
|
add_library(mastodon-cpp SHARED ${sources})
|
||||||
set_target_properties(mastodon-cpp PROPERTIES
|
set_target_properties(mastodon-cpp PROPERTIES
|
||||||
|
@ -66,14 +73,13 @@ set_target_properties(mastodon-cpp PROPERTIES
|
||||||
SOVERSION ${mastodon-cpp_VERSION_MAJOR}
|
SOVERSION ${mastodon-cpp_VERSION_MAJOR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WITHOUT_EASY)
|
if(WITH_EASY)
|
||||||
target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES} ${JSONCPP_LIBRARIES})
|
target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES} ${JSONCPP_LIBRARIES})
|
||||||
|
else()
|
||||||
|
target_link_libraries(mastodon-cpp ${CURLPP_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compile examples
|
# Compile examples
|
||||||
set(WITH_EXAMPLES "YES" CACHE STRING "WITH_EXAMPLES defaults to \"YES\"")
|
|
||||||
if(WITH_EXAMPLES)
|
if(WITH_EXAMPLES)
|
||||||
file(GLOB sources_examples examples/*.cpp)
|
file(GLOB sources_examples examples/*.cpp)
|
||||||
foreach(src ${sources_examples})
|
foreach(src ${sources_examples})
|
||||||
|
@ -92,7 +98,7 @@ endif()
|
||||||
install(TARGETS mastodon-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(TARGETS mastodon-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
install(FILES src/mastodon-cpp.hpp src/return_types.hpp src/types.hpp
|
install(FILES src/mastodon-cpp.hpp src/return_types.hpp src/types.hpp
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp)
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp)
|
||||||
if(NOT WITHOUT_EASY)
|
if(WITH_EASY)
|
||||||
file(GLOB easy_header src/easy/*.hpp)
|
file(GLOB easy_header src/easy/*.hpp)
|
||||||
install(FILES ${easy_header}
|
install(FILES ${easy_header}
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp/easy)
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp/easy)
|
||||||
|
|
12
README.md
12
README.md
|
@ -160,13 +160,13 @@ make
|
||||||
cmake options:
|
cmake options:
|
||||||
|
|
||||||
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build
|
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build
|
||||||
* `-DWITHOUT_EASY=ON` to not build the Easy abstractions and to get rid of the jsoncpp-dependency (not recommended)
|
* `-DWITH_EASY=NO` to not build the Easy abstractions and to get rid of the jsoncpp-dependency (not recommended)
|
||||||
* `-DWITH_EXAMPLES=ON` if you want to compile the examples
|
* `-DWITH_EXAMPLES=YES` if you want to compile the examples
|
||||||
* `-DWITH_TESTS=ON` if you want to compile the tests
|
* `-DWITH_TESTS=YES` if you want to compile the tests
|
||||||
* `-DWITH_DOC=ON` if you want to compile the HTML reference
|
* `-DWITH_DOC=YES` if you want to compile the HTML reference
|
||||||
* One of:
|
* One of:
|
||||||
* `-DWITH_DEB=ON` if you want to be able to generate a deb-package
|
* `-DWITH_DEB=YES` if you want to be able to generate a deb-package
|
||||||
* `-DWITH_RPM=ON` if you want to be able to generate an rpm-package
|
* `-DWITH_RPM=YES` if you want to be able to generate an rpm-package
|
||||||
|
|
||||||
You can run the tests with `ctest ..` inside the build directory.
|
You can run the tests with `ctest ..` inside the build directory.
|
||||||
To install, run `make install`.
|
To install, run `make install`.
|
||||||
|
|
Reference in New Issue