Laid out the project structure.

This commit is contained in:
tastytea 2019-05-11 02:52:33 +02:00
commit 5e41f19cd3
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
9 changed files with 278 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build/

57
CMakeLists.txt Normal file
View File

@ -0,0 +1,57 @@
cmake_minimum_required (VERSION 3.2)
project(remwharead
VERSION 0.0.0
LANGUAGES CXX
)
set(WITH_MAN "YES" CACHE STRING "WITH_MAN defaults to \"YES\"")
set(WITH_TESTS "NO" CACHE STRING "WITH_TESTS defaults to \"NO\"")
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CURLPP REQUIRED curlpp)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -ftrapv \
-fsanitize=undefined -g -Og -fno-omit-frame-pointer")
include_directories(${PROJECT_SOURCE_DIR}/src)
Include_directories(${PROJECT_BINARY_DIR})
include_directories(${CURLPP_INCLUDE_DIRS})
link_directories(${CURLPP_LIBRARY_DIRS})
# Write version in header
configure_file(
"${PROJECT_SOURCE_DIR}/src/version.hpp.in"
"${PROJECT_BINARY_DIR}/version.hpp"
)
file(GLOB sources src/*.cpp)
add_executable(${PROJECT_NAME} "${sources}")
target_link_libraries(${PROJECT_NAME} ${CURLPP_LIBRARIES})
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
if (WITH_MAN)
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.1"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
DEPENDS "${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.1.adoc"
COMMAND ${CMAKE_SOURCE_DIR}/build_manpage.sh
ARGS ${PROJECT_VERSION})
add_custom_target(run ALL DEPENDS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.1")
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
endif()
if(WITH_TESTS)
add_library(${PROJECT_NAME}_testlib SHARED ${sources})
target_link_libraries(${PROJECT_NAME}_testlib ${CURLPP_LIBRARIES})
include(tests.CMakeLists.txt)
endif()

93
README.adoc Normal file
View File

@ -0,0 +1,93 @@
= remwharead
*remwharead* helps you remembering what you read, and when.
== Usage
See https://schlomp.space/tastytea/remwharead/src/branch/master/remwharead.1.adoc[manpage].
== Install
////
=== Gentoo
Add my https://schlomp.space/tastytea/overlay[repository] and install it from
there.
[source,shellsession]
----
eselect repository enable tastytea
echo "www-misc/remwharead ~amd64" >> /etc/portage/package.accept_keywords/remwharead
emaint sync -r tastytea
emerge -a www-misc/remwharead
----
////
=== From source
////
==== Dependencies
* Tested OS: Linux
* C++ compiler (tested: https://gcc.gnu.org/[gcc] 5/6/7/8,
https://llvm.org/[clang] 3/5/6)
* https://cmake.org/[cmake] (at least: 3.6)
* https://pkgconfig.freedesktop.org/wiki/[pkgconfig] (tested: 0.29)
* http://www.curlpp.org/[curlpp] (tested: 0.8)
* Optional:
** Manpage: http://asciidoc.org/[asciidoc] (tested: 8.6)
===== Debian stretch
[source,shellsession]
----
echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
apt-get update
apt-get install build-essential cmake pkg-config libcurl4-openssl-dev asciidoc
apt-get install -t sid libcurlpp-dev
----
////
==== Get sourcecode
////
===== Releases
Download the current release at
https://schlomp.space/tastytea/remwharead/releases[schlomp.space].
////
===== Development version
[source,shellsession]
----
git clone https://schlomp.space/tastytea/remwharead.git
----
==== Compile
[source,shellsession]
----
mkdir build
cd build/
cmake ..
cmake --build .
----
.cmake options:
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build.
* `-DWITH_MAN=NO` to not compile the manpage.
* `WITH_TESTS=YES` to compile the tests.
You can run the tests with `ctest` inside the build directory. Install with
`make install`.
== Copyright
----
Copyright © 2019 tastytea <tastytea@tastytea.de>.
License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.
This program comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
----

13
build_manpage.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
name="remwharead"
if [ -n "${1}" ]; then
dir="$(dirname ${0})"
version=${1}
cp -vf "${dir}/${name}.1.adoc" .
sed -Ei "s/(Revision: +)[0-9]+\.[0-9]\.[0-9]/\1${version}/" "${name}.1.adoc"
a2x --doctype manpage --format manpage --no-xmllint "${name}.1.adoc"
else
echo "usage: ${0} VERSION" >&2
fi

42
remwharead.1.adoc Normal file
View File

@ -0,0 +1,42 @@
= remwharead(1)
:doctype: manpage
:Author: tastytea
:Email: tastytea@tastytea.de
:Date: 2019-05-11
:Revision: 0.0.0
:man source: remwharead
:man version: {revision}
:man manual: General Commands Manual
== NAME
remwharead - Remember what you read, and when
== SYNOPSIS
*remwharead* [_url_|_--version_] [_arguments_]
////
== DESCRIPTION
////
== OPTIONS
*--version*::
Print version, copyright and license.
////
== EXAMPLES
== FILES
* *Configuration file*: `${XDG_CONFIG_HOME}/remwharead.cfg`
`${XDG_CONFIG_HOME}` is usually `~/.config`.
////
== REPORTING BUGS
Bugtracker: https://schlomp.space/tastytea/remwharead/issues
E-mail: tastytea@tastytea.de

20
src/main.cpp Normal file
View File

@ -0,0 +1,20 @@
/* This file is part of remwharead.
* Copyright © 2019 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
int main()
{
return 0;
}

9
src/version.hpp.in Normal file
View File

@ -0,0 +1,9 @@
#ifndef VERSION_HPP
#define VERSION_HPP
namespace global
{
static constexpr char version[] = "@PROJECT_VERSION@";
}
#endif // VERSION_HPP

24
tests.CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
include(CTest)
file(GLOB sources_tests tests/test_*.cpp)
find_package(Catch2)
if(Catch2_FOUND) # Catch 2.x
include(Catch)
add_executable(all_tests tests/main.cpp ${sources_tests})
target_link_libraries(all_tests Catch2::Catch2 ${PROJECT_NAME}_testlib)
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}")
else() # Catch 1.x
if(EXISTS "/usr/include/catch.hpp")
message(STATUS "Catch 1.x found.")
foreach(src ${sources_tests})
get_filename_component(bin ${src} NAME_WE)
add_executable(${bin} tests/main.cpp ${src})
target_link_libraries(${bin} ${PROJECT_NAME}_testlib)
add_test(${bin} ${bin} "${EXTRA_TEST_ARGS}")
endforeach()
else()
message(FATAL_ERROR
"Neither Catch 2.x nor Catch 1.x could be found.")
endif()
endif()

19
tests/main.cpp Normal file
View File

@ -0,0 +1,19 @@
/* This file is part of remwharead.
* Copyright © 2019 tastytea <tastytea@tastytea.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define CATCH_CONFIG_MAIN
#include <catch.hpp>