diff --git a/CMakeLists.txt b/CMakeLists.txt index ca25fd05ff..acec38fad0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ set(OPENMW_VERSION_COMMITDATE "") set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") -set(OPENMW_DOC_BASEURL "https://openmw.readthedocs.io/en/stable/") +set(OPENMW_DOC_BASEURL "https://openmw.readthedocs.io/en/") set(GIT_CHECKOUT FALSE) if(EXISTS ${PROJECT_SOURCE_DIR}/.git) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 01efcd7c05..8bdead1357 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -29,6 +29,7 @@ if (GIT_CHECKOUT) -DOPENMW_LUA_API_REVISION=${OPENMW_LUA_API_REVISION} -DOPENMW_POSTPROCESSING_API_REVISION=${OPENMW_POSTPROCESSING_API_REVISION} -DOPENMW_VERSION=${OPENMW_VERSION} + -DOPENMW_DOC_BASEURL=${OPENMW_DOC_BASEURL} -DMACROSFILE=${CMAKE_SOURCE_DIR}/cmake/OpenMWMacros.cmake "-DCMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}" -Dgenerator_is_multi_config_var=${multi_config} @@ -617,7 +618,6 @@ endif() if (USE_QT) add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR}) target_link_libraries(components_qt components Qt::Widgets Qt::Core) - target_compile_definitions(components_qt PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}") if (BUILD_LAUNCHER OR BUILD_WIZARD) add_dependencies(components_qt qm-files) @@ -657,6 +657,7 @@ endif() set(COMPONENT_FILES ${COMPONENT_FILES} PARENT_SCOPE) target_compile_definitions(components PUBLIC BT_USE_DOUBLE_PRECISION) +target_compile_definitions(components PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}") if(OSG_STATIC) unset(_osg_plugins_static_files) diff --git a/components/misc/helpviewer.cpp b/components/misc/helpviewer.cpp index 0ff4abb9d3..ebfca9ad14 100644 --- a/components/misc/helpviewer.cpp +++ b/components/misc/helpviewer.cpp @@ -4,9 +4,12 @@ #include #include +#include + void Misc::HelpViewer::openHelp(const char* url) { - QString link{ OPENMW_DOC_BASEURL }; + std::string_view docsUrl = Version::getDocumentationUrl(); + QString link = QString::fromUtf8(docsUrl.data(), docsUrl.size()); link.append(url); QDesktopServices::openUrl(QUrl(link)); } diff --git a/components/version/version.cpp.in b/components/version/version.cpp.in index 312520acbb..12192785b7 100644 --- a/components/version/version.cpp.in +++ b/components/version/version.cpp.in @@ -52,4 +52,11 @@ namespace Version return getVersion() == version && getCommitHash() == commitHash && getTagHash() == tagHash; } + std::string_view getDocumentationUrl() + { + if constexpr (std::string_view("@OPENMW_VERSION_COMMITHASH@") == "@OPENMW_VERSION_TAGHASH@") + return OPENMW_DOC_BASEURL "openmw-@OPENMW_VERSION_MAJOR@.@OPENMW_VERSION_MINOR@.@OPENMW_VERSION_RELEASE@/"; + else + return OPENMW_DOC_BASEURL "latest/"; + } } diff --git a/components/version/version.hpp b/components/version/version.hpp index c05cf8a594..a8a8117dee 100644 --- a/components/version/version.hpp +++ b/components/version/version.hpp @@ -17,6 +17,8 @@ namespace Version std::string getOpenmwVersionDescription(); bool checkResourcesVersion(const std::filesystem::path& resourcePath); + + std::string_view getDocumentationUrl(); } #endif // VERSION_HPP