diff --git a/CMakeLists.txt b/CMakeLists.txt index 8131449..598568c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(FindPkgConfig) pkg_check_modules(OGG REQUIRED ogg) +configure_file(config.h.in config.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_executable(opustags opustags.cc) target_compile_options(opustags PUBLIC ${OGG_CFLAGS}) target_link_libraries(opustags PUBLIC ${OGG_LIBRARIES}) diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..a447c65 --- /dev/null +++ b/config.h.in @@ -0,0 +1,2 @@ +#cmakedefine PROJECT_NAME "@PROJECT_NAME@" +#cmakedefine PROJECT_VERSION "@PROJECT_VERSION@" diff --git a/opustags.cc b/opustags.cc index af9af50..1427508 100644 --- a/opustags.cc +++ b/opustags.cc @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -165,7 +167,7 @@ int write_page(ogg_page *og, FILE *stream){ return 0; } -const char *version = "opustags version 1.1.1\n"; +const char *version = PROJECT_NAME " version " PROJECT_VERSION "\n"; const char *usage = "Usage: opustags --help\n" diff --git a/t/meta.t b/t/meta.t index 80e8574..97391e5 100644 --- a/t/meta.t +++ b/t/meta.t @@ -4,22 +4,23 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 7; my $opustags = './opustags'; -chomp(my $version = `git describe --tags --abbrev=0`); - BAIL_OUT("$opustags does not exist or is not executable") if (! -x $opustags); +chomp(my $version = `$opustags --help | head -n 1`); +like($version, qr/^opustags version \d+\.\d+\.\d+$/, 'get the version string'); + is(`$opustags`, <<"EOF", 'no options show the usage'); -opustags version $version +$version Usage: opustags --help opustags [OPTIONS] FILE opustags OPTIONS FILE -o FILE EOF my $help = <<"EOF"; -opustags version $version +$version Usage: opustags --help opustags [OPTIONS] FILE