Skip to content

Commit 285ddcb

Browse files
committed
chore: version is 0.0.1
This PR sets the version for the initial 0.0.1 MrDocs release. To ensure the versions in header files are always consistent, version details like major, minor, patch, and build are dynamically populated during the build process from variables defined in the CMakeLists.txt file. Adjustments have been made to include paths to ensure the new dynamically generated Version.hpp file is correctly included during the building process and installed with other header files.
1 parent 866f727 commit 285ddcb

File tree

3 files changed

+57
-27
lines changed

3 files changed

+57
-27
lines changed

CMakeLists.txt

+27-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endif()
2424
cmake_policy(SET CMP0111 OLD)
2525
project(
2626
MrDocs
27-
VERSION 1.0.0
27+
VERSION 0.0.1
2828
DESCRIPTION "C++ Documentation Tool"
2929
HOMEPAGE_URL "https://github.com/cppalliance/mrdocs"
3030
LANGUAGES CXX C
@@ -115,19 +115,39 @@ unset(CMAKE_FOLDER)
115115
# mrdocs-core
116116
#
117117
#-------------------------------------------------
118+
# Create include/mrdocs/Version.hpp from Version.hpp.in
119+
find_package(Git QUIET)
120+
if (GIT_FOUND)
121+
execute_process(
122+
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
123+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
124+
OUTPUT_VARIABLE PROJECT_VERSION_BUILD
125+
OUTPUT_STRIP_TRAILING_WHITESPACE
126+
)
127+
set(PROJECT_VERSION_BUILD "${PROJECT_VERSION_BUILD}")
128+
else()
129+
set(PROJECT_VERSION_BUILD "")
130+
endif()
131+
configure_file(
132+
${CMAKE_CURRENT_SOURCE_DIR}/include/mrdocs/Version.hpp.in
133+
${CMAKE_CURRENT_BINARY_DIR}/include/mrdocs/Version.hpp
134+
@ONLY
135+
)
118136

119137
file(
120138
GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS
121139
src/lib/*.cpp src/lib/*.hpp src/lib/*.ipp
122140
src/lib/*.natvis
123141
include/*.hpp include/*.ipp
142+
${CMAKE_CURRENT_BINARY_DIR}/src/lib/*.hpp
124143
include/*.natvis
125144
SourceFileNames.cpp)
126145
add_library(mrdocs-core ${LIB_SOURCES})
127146
target_compile_features(mrdocs-core PUBLIC cxx_std_20)
128147
target_include_directories(mrdocs-core
129148
PUBLIC
130149
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
150+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/>"
131151
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
132152
PRIVATE
133153
"${PROJECT_SOURCE_DIR}/src"
@@ -407,6 +427,12 @@ if (MRDOCS_INSTALL)
407427
FILES_MATCHING
408428
PATTERN "*.[hi]pp")
409429

430+
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/mrdocs
431+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
432+
COMPONENT development
433+
FILES_MATCHING
434+
PATTERN "*.[hi]pp")
435+
410436
#-------------------------------------------------
411437
# share
412438
#-------------------------------------------------

include/mrdocs/Version.hpp

-26
This file was deleted.

include/mrdocs/Version.hpp.in

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Licensed under the Apache License v2.0 with LLVM Exceptions.
3+
// See https://llvm.org/LICENSE.txt for license information.
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
//
6+
// Copyright (c) 2023 Klemens D. Morgenstern
7+
//
8+
// Official repository: https://github.com/cppalliance/mrdocs
9+
//
10+
11+
#ifndef MRDOCS_VERSION_HPP
12+
#define MRDOCS_VERSION_HPP
13+
14+
#include <string_view>
15+
16+
namespace clang {
17+
namespace mrdocs {
18+
19+
constexpr std::string_view project_version = "@PROJECT_VERSION@";
20+
constexpr std::size_t project_version_major = @PROJECT_VERSION_MAJOR@;
21+
constexpr std::size_t project_version_minor = @PROJECT_VERSION_MINOR@;
22+
constexpr std::size_t project_version_patch = @PROJECT_VERSION_PATCH@;
23+
constexpr std::string_view project_version_build = "@PROJECT_VERSION_BUILD@";
24+
constexpr std::string_view project_name = "@PROJECT_NAME@";
25+
constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
26+
27+
} // mrdocs
28+
} // clang
29+
30+
#endif

0 commit comments

Comments
 (0)