Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CMAKE_PROJECT_VERSION for URLs #3831

Merged
merged 3 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,10 @@ endif()

get_target_property(BUILD_FLAGS mixxx-lib COMPILE_OPTIONS)

# uses CMAKE_PROJECT_VERSION MIXXX_VERSION_PRERELEASE GIT_BRANCH GIT_DESCRIBE GIT_COMMIT_DATE BUILD_FLAGS
# uses CMAKE_PROJECT_VERSION MIXXX_VERSION_PRERELEASE
configure_file(src/version.h.in src/version.h @ONLY)
# uses GIT_BRANCH GIT_DESCRIBE GIT_COMMIT_DATE BUILD_FLAGS
configure_file(src/versiondetails.h.in src/versiondetails.h @ONLY)

# Windows-only resource file
if(WIN32)
Expand Down
14 changes: 13 additions & 1 deletion src/defs_urls.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#pragma once
#include "version.h"

// Two-level macro to stringize the numeric version definitions to a version
// string. See https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html for details.
#define TO_STR(x) #x
#define TO_VERSION_STR(major, minor) \
TO_STR(major) \
"." TO_STR(minor)

#define MIXXX_WEBSITE_URL "https://www.mixxx.org"
#define MIXXX_WEBSITE_SHORT_URL "www.mixxx.org"
Expand All @@ -20,9 +28,13 @@
#define MIXXX_WIKI_MIDI_SCRIPTING_URL \
MIXXX_WIKI_URL "/Midi-Scripting"

#define MIXXX_MANUAL_URL "https://manual.mixxx.org/2.3"
#define MIXXX_MANUAL_URL \
"https://manual.mixxx.org/" TO_VERSION_STR( \
MIXXX_VERSION_MAJOR, MIXXX_VERSION_MINOR)
#define MIXXX_MANUAL_SHORTCUTS_URL \
MIXXX_MANUAL_URL "/chapters/controlling_mixxx.html#using-a-keyboard"
#define MIXXX_MANUAL_COMMANDLINEOPTIONS_URL \
MIXXX_MANUAL_URL "/chapters/appendix.html#command-line-options"
#define MIXXX_MANUAL_CONTROLLERS_URL \
MIXXX_MANUAL_URL "/chapters/controlling_mixxx.html#using-midi-hid-controllers"
#define MIXXX_MANUAL_CONTROLLERMANUAL_PREFIX \
Expand Down
6 changes: 2 additions & 4 deletions src/util/cmdlineargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <QStandardPaths>

#include "defs_urls.h"
#include "sources/soundsourceproxy.h"
#include "util/versionstore.h"

Expand Down Expand Up @@ -172,8 +173,5 @@ void CmdlineArgs::printUsage() {
"\
-h, --help Display this help message and exit", stdout);

fputs("\n\n(For more information, see "
"https://manual.mixxx.org/2.3/chapters/"
"appendix.html#command-line-options)\n",
stdout);
fputs("\n\n(For more information, see " MIXXX_MANUAL_COMMANDLINEOPTIONS_URL ")\n", stdout);
}
3 changes: 2 additions & 1 deletion src/util/versionstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#include <taglib/taglib.h>
#include <vorbis/codec.h>

#define VERSION_STORE
#include "version.h"
#define VERSION_STORE
#include "versiondetails.h"

namespace {

Expand Down
13 changes: 4 additions & 9 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#pragma once

#ifndef VERSION_STORE
#error "Include only from versionstore.cpp do avoid unnecessary recompile on every commit."
#endif

// This file contains the basic Mixxx version and prerelease name. This doesn't
// change very often, so this file can be included in other parts of the code
// where the version number needs to be known at the preprocessor stage and
// using the VersionInfo class is not an option.
#define MIXXX_VERSION_MAJOR @CMAKE_PROJECT_VERSION_MAJOR@
#define MIXXX_VERSION_MINOR @CMAKE_PROJECT_VERSION_MINOR@
#define MIXXX_VERSION_PATCH @CMAKE_PROJECT_VERSION_PATCH@
#define MIXXX_VERSION_SUFFIX "@MIXXX_VERSION_PRERELEASE@"
#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_DESCRIBE "@GIT_DESCRIBE@"
#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@"
#define BUILD_FLAGS "@BUILD_FLAGS@"
14 changes: 14 additions & 0 deletions src/versiondetails.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
// This file contains the exact Mixxx git version and commit date. Since this
// changes on every single commit (or even if just the dirty flag changes), all
// files that include this will be recompile very often. Therefore, this should
// only be included from versionstore.cpp.

#ifndef VERSION_STORE
#error "Include only from versionstore.cpp do avoid unnecessary recompile on every commit."
#endif

#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_DESCRIBE "@GIT_DESCRIBE@"
#define GIT_COMMIT_DATE "@GIT_COMMIT_DATE@"
#define BUILD_FLAGS "@BUILD_FLAGS@"