From add719e6026848a57126222d6521e3b8bd937c6f Mon Sep 17 00:00:00 2001 From: otreblan Date: Wed, 15 Apr 2020 07:45:59 -0500 Subject: [PATCH] Add CMake to doc --- CMakeLists.txt | 2 +- Makefile.am | 1 - configure.ac | 40 ---------------------------------------- doc/CMakeLists.txt | 45 +++++++++++++++++++++++++++++++++++++++++---- doc/Makefile.am | 6 ------ pkg/PKGBUILD | 1 + src/Makefile.am | 2 -- src/main.cpp | 2 +- 8 files changed, 44 insertions(+), 55 deletions(-) delete mode 100644 Makefile.am delete mode 100644 configure.ac delete mode 100644 doc/Makefile.am delete mode 100644 src/Makefile.am diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a80e1d..c8a2c3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ target_include_directories(${PROJECT_NAME} # Sources list add_subdirectory(src) -#add_subdirectory(doc) +add_subdirectory(doc) ## Libraries #pkg_check_modules(RAPIDJSON REQUIRED RapidJSON) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 3920780..0000000 --- a/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = src doc diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 3a4debc..0000000 --- a/configure.ac +++ /dev/null @@ -1,40 +0,0 @@ -# New macro definitions {{{ - -# This macro checks for a program and exits if not found {{{ - -# AC_CHECK_CHECK_PROG([variable], [program-name]) -AC_DEFUN(AC_CHECK_CHECK_PROG,[ - AC_CHECK_PROG([$1], [$2], [$2], []) - if test -z $$1 - then - AC_MSG_ERROR([$2 not found.]) - fi -]) - -#}}} - -#}}} - -AC_INIT([hello], [0.0.1]) -AC_CONFIG_AUX_DIR([aux]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) - -# Language -AC_LANG([C++]) - -# Checking if some programs are installed{{{ -AC_PROG_CXX -AC_PROG_INSTALL -AC_PROG_LIBTOOL -AC_CHECK_CHECK_PROG([ASCII], [asciidoctor]) - -# }}} - -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([ - Makefile - src/Makefile - doc/Makefile -]) - -AC_OUTPUT diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 597dcfd..be99fb9 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -14,7 +14,44 @@ # You should have received a copy of the GNU General Public License # along with hello. If not, see . -#target_sources(doc -#PRIVATE -#hello.adoc -#) +find_program(ASCIIDOCTOR asciidoctor) + +if(NOT ASCIIDOCTOR) + message(SEND_ERROR "asciidoctor not found in $PATH") +endif() + + +add_custom_target(doc + DEPENDS + man1 +) + +# Man pages that end in *.1 +set(MAN1_SOURCES + hello.adoc +) + +add_custom_target(man1 + SOURCES + ${MAN1_SOURCES} +) + +foreach(MAN IN LISTS MAN1_SOURCES) + + # Deleting the extension + get_filename_component(MAN ${MAN} NAME_WE) + + add_custom_command( + TARGET doc + COMMAND asciidoctor --backend manpage --out-file ${MAN}.1 + ${CMAKE_CURRENT_SOURCE_DIR}/${MAN}.adoc + + OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${MAN}.1 + ) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${MAN}.1 + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/man/man1/ + ) + +endforeach() diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index a23c1bc..0000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -man1_MANS = hello.man -EXTRA_DIST = hello.adoc - -# This thing converts .adoc to .man -.adoc.man: - $(ASCII) --backend manpage --out-file $@ $< diff --git a/pkg/PKGBUILD b/pkg/PKGBUILD index 5393e14..1f43be1 100644 --- a/pkg/PKGBUILD +++ b/pkg/PKGBUILD @@ -42,6 +42,7 @@ build() { .. make + make doc } package() { diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 8de1f95..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -bin_PROGRAMS = hello -hello_SOURCES = main.cpp diff --git a/src/main.cpp b/src/main.cpp index 71cd652..b15400a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ // Display help void help(char**); -int main(int argc, char *argv[]) +int main() { std::cout << "Hello\n"; return 0;