From 9e101cec430180ffd1005966182ae6c8d4c65cf2 Mon Sep 17 00:00:00 2001 From: Dalton Nell Date: Mon, 17 Nov 2014 11:44:17 -0700 Subject: [PATCH] Cleaned up CMakeLists.txt and improved README regeneration. --- CMakeLists.txt | 36 +++++++++++++----------------------- README.md | 7 +++---- generateReadme.sh | 13 +++++++++++++ 3 files changed, 29 insertions(+), 27 deletions(-) create mode 100755 generateReadme.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 098d9d4..6566e7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required( VERSION 2.8 ) project( "maim" ) set( maim_VERSION_MAJOR 2 ) set( maim_VERSION_MINOR 3 ) -set( maim_VERSION_PATCH 34 ) +set( maim_VERSION_PATCH 35 ) set( BIN_TARGET "${PROJECT_NAME}" ) set( CMAKE_INSTALL_PREFIX "/usr/bin" ) @@ -17,6 +17,8 @@ if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR # -Wall: Enable all warnings. # -Wextra: Enable some more warnings. # -Werror: Have errors on warnings. + # -Wno-unused-parameter: Don't error on unused parameters, required since we have function hooks + # that have unused parameters. else() message( FATAL_ERROR "Your operating system isn't supported yet! CMake will now exit." ) endif() @@ -34,17 +36,13 @@ endif() # so nobody has to go find and install gengetopt if they don't want to. find_program( GENGETOPT_EXECUTABLE gengetopt DOC "A tool to generate code to grab command line options." ) -find_program( COPY_EXECUTABLE cp ) -if ( GENGETOPT_EXECUTABLE AND COPY_EXECUTABLE ) - message( "Executing " "${GENGETOPT_EXECUTABLE}" " " "--input=options.ggo" ) - execute_process( COMMAND - "${GENGETOPT_EXECUTABLE}" "--input=options.ggo" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" ) - execute_process( COMMAND - "${COPY_EXECUTABLE}" "cmdline.h" "cmdline.in" +if ( GENGETOPT_EXECUTABLE ) + message( "-- Regenerating cmdline.in" ) + execute_process( COMMAND "${GENGETOPT_EXECUTABLE}" "--input=options.ggo" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" ) + file( RENAME "${CMAKE_SOURCE_DIR}/src/cmdline.h" "${CMAKE_SOURCE_DIR}/src/cmdline.in" ) else() - message( "Command gengetopt not found! Won't regenerate command line code." ) + message( "Warning: Command gengetopt not found! Won't regenerate command line code. (If you're just compiling this doesn't matter.)" ) endif() # By default our src/options.ggo has our cmake versions variables for @@ -52,19 +50,11 @@ endif() configure_file( "src/cmdline.in" "src/cmdline.h" ) -# Here we need to make sure our README has the correct version inside of it. -# We use a simple regex search and replace for it, but it seems really -# hard because cmake is silly. -# I think this is better than using configure_file since README.md needs -# to exist within github, rather than as an input file with a different -# name or extension. -message( "Replacing version in readme..." ) -set( SEARCH_REGEX "maim v([0-9]+)\\.([0-9]+)\\.([0-9]+)" ) -set( REPLACE_TEXT "maim v${maim_VERSION_MAJOR}.${maim_VERSION_MINOR}.${maim_VERSION_PATCH}" ) -file( READ "${CMAKE_CURRENT_SOURCE_DIR}/README.md" FILE_CONTENT ) -string( REGEX REPLACE "${SEARCH_REGEX}" "${REPLACE_TEXT}" - MODIFIED_FILE_CONTENT "${FILE_CONTENT}" ) -file( WRITE "${CMAKE_CURRENT_SOURCE_DIR}/README.md" "${MODIFIED_FILE_CONTENT}" ) +# This allows for "make README.md" to be ran to update the README's help +# section automatically. We don't add it to ALL because running arbitrary +# scripts is unsafe and I don't know if systems will actually have it +# be executbable. +add_custom_target( README.md "./generateReadme.sh" DEPENDS "maim" ) # Sources set( source diff --git a/README.md b/README.md index d2cf017..c96fec7 100644 --- a/README.md +++ b/README.md @@ -80,11 +80,11 @@ make && sudo make install Make sure to check out and install [slop](https://github.com/naelstrof/slop) too if you want selection capabilities! -## Need help? +help +---- Join us on irc at freenode in *#maim*. - ```text -maim v2.3.34 +maim v2.3.35 Copyright (C) 2014 Dalton Nell, Maim Contributors (https://github.com/naelstrof/maim/graphs/contributors) @@ -168,5 +168,4 @@ Examples $ # Save a dated screenshot. $ maim ~/$(date +%F-%T).png - ``` diff --git a/generateReadme.sh b/generateReadme.sh new file mode 100755 index 0000000..a1887a7 --- /dev/null +++ b/generateReadme.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# generateReadme.sh: Regenerates the help section of the README.md using output from ./maim --help. + +# Remove help section +sed -i '/^help$/,/^```$/d' README.md + +# Add the help section again. +echo 'help' >> README.md +echo '----' >> README.md +echo 'Join us on irc at freenode in *#maim*.' >> README.md +echo '```text' >> README.md +echo "$(./maim --help)" >> README.md +echo '```' >> README.md