mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
db5c053057
CMake already provides variables to handle the version major/minor/patch if we give it the dotted version in the `project()` command. Using it significantly reduces the amount of macro stuff we have to do in version.cpp.in, and it seems a little nicer to have it defined in the project top level rather than buried in a needs-to-beprocessed .cpp file. This moves the release codename there, too, so that it stays being defined in essentially the same place as the version. This change here requires some minor tweaking of the version generation code to do it in two steps (when we have git): the first (`src/version.cpp.in` -> `build/version.cpp.in`) replaces all the main version variables during cmake configuration, the second (`build/version.cpp.in` -> `build/version.cpp`) then replaces the VERSIONTAG at build time. (Before this commit, there was only version tag replacement that only happened at build time). Also bumps up the version here (since I'm moving it anyway) to match master's 7.1.8.
52 lines
2.5 KiB
CMake
52 lines
2.5 KiB
CMake
# Copyright (c) 2014-2018, The Monero Project
|
|
#
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without modification, are
|
|
# permitted provided that the following conditions are met:
|
|
#
|
|
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
# conditions and the following disclaimer.
|
|
#
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
# of conditions and the following disclaimer in the documentation and/or other
|
|
# materials provided with the distribution.
|
|
#
|
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
# used to endorse or promote products derived from this software without specific
|
|
# prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
function (write_static_version_header hash)
|
|
set(VERSIONTAG "${hash}")
|
|
configure_file("${CMAKE_SOURCE_DIR}/src/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
|
|
endfunction ()
|
|
|
|
find_package(Git QUIET)
|
|
if (GIT_FOUND OR Git_FOUND)
|
|
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
|
set(VERSIONTAG "@VERSIONTAG@") # Will be replaced again by GenVersion.cmake, below.
|
|
configure_file("${CMAKE_SOURCE_DIR}/src/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp.in")
|
|
add_custom_command(
|
|
OUTPUT "${CMAKE_BINARY_DIR}/version.cpp"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
"-D" "GIT=${GIT_EXECUTABLE}"
|
|
"-P" "${CMAKE_SOURCE_DIR}/cmake/GenVersion.cmake"
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
|
DEPENDS "${CMAKE_BINARY_DIR}/version.cpp.in")
|
|
else()
|
|
message(WARNING "Git was not found; setting release tag to 'unknown'")
|
|
write_static_version_header("unknown")
|
|
endif ()
|
|
add_custom_target(genversion ALL
|
|
DEPENDS "${CMAKE_BINARY_DIR}/version.cpp")
|