Skip to content

Commit

Permalink
chore: version is 0.0.1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alandefreitas committed Dec 1, 2023
1 parent 866f727 commit 285ddcb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 27 deletions.
28 changes: 27 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif()
cmake_policy(SET CMP0111 OLD)
project(
MrDocs
VERSION 1.0.0
VERSION 0.0.1
DESCRIPTION "C++ Documentation Tool"
HOMEPAGE_URL "https://github.com/cppalliance/mrdocs"
LANGUAGES CXX C
Expand Down Expand Up @@ -115,19 +115,39 @@ unset(CMAKE_FOLDER)
# mrdocs-core
#
#-------------------------------------------------
# Create include/mrdocs/Version.hpp from Version.hpp.in
find_package(Git QUIET)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_VERSION_BUILD
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PROJECT_VERSION_BUILD "${PROJECT_VERSION_BUILD}")
else()
set(PROJECT_VERSION_BUILD "")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/mrdocs/Version.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/include/mrdocs/Version.hpp
@ONLY
)

file(
GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS
src/lib/*.cpp src/lib/*.hpp src/lib/*.ipp
src/lib/*.natvis
include/*.hpp include/*.ipp
${CMAKE_CURRENT_BINARY_DIR}/src/lib/*.hpp
include/*.natvis
SourceFileNames.cpp)
add_library(mrdocs-core ${LIB_SOURCES})
target_compile_features(mrdocs-core PUBLIC cxx_std_20)
target_include_directories(mrdocs-core
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"${PROJECT_SOURCE_DIR}/src"
Expand Down Expand Up @@ -407,6 +427,12 @@ if (MRDOCS_INSTALL)
FILES_MATCHING
PATTERN "*.[hi]pp")

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/mrdocs
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT development
FILES_MATCHING
PATTERN "*.[hi]pp")

#-------------------------------------------------
# share
#-------------------------------------------------
Expand Down
26 changes: 0 additions & 26 deletions include/mrdocs/Version.hpp

This file was deleted.

30 changes: 30 additions & 0 deletions include/mrdocs/Version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Copyright (c) 2023 Klemens D. Morgenstern
//
// Official repository: https://github.com/cppalliance/mrdocs
//

#ifndef MRDOCS_VERSION_HPP
#define MRDOCS_VERSION_HPP

#include <string_view>

namespace clang {
namespace mrdocs {

constexpr std::string_view project_version = "@PROJECT_VERSION@";
constexpr std::size_t project_version_major = @PROJECT_VERSION_MAJOR@;
constexpr std::size_t project_version_minor = @PROJECT_VERSION_MINOR@;
constexpr std::size_t project_version_patch = @PROJECT_VERSION_PATCH@;
constexpr std::string_view project_version_build = "@PROJECT_VERSION_BUILD@";
constexpr std::string_view project_name = "@PROJECT_NAME@";
constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";

} // mrdocs
} // clang

#endif

0 comments on commit 285ddcb

Please sign in to comment.