Added cmake versioning and removed hardcoded share dir path

This commit is contained in:
Christian Prather 2023-07-11 13:54:22 -06:00
parent 6c6ec00251
commit a49af31188
2 changed files with 36 additions and 4 deletions

View File

@ -1,6 +1,14 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(Tracy LANGUAGES CXX) # Run version helper script
include(version.cmake)
set(TRACY_VERSION_MAJOR ${major})
set(TRACY_VERSION_MINOR ${minor})
set(TRACY_VERSION_PATCH ${patch})
set(TRACY_VERSION_STRING "${TRACY_VERSION_MAJOR}.${TRACY_VERSION_MINOR}.${TRACY_VERSION_PATCH}")
project(Tracy LANGUAGES CXX VERSION ${TRACY_VERSION_STRING})
if(${BUILD_SHARED_LIBS}) if(${BUILD_SHARED_LIBS})
set(DEFAULT_STATIC OFF) set(DEFAULT_STATIC OFF)
@ -84,6 +92,8 @@ endif()
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(GNUInstallDirs) include(GNUInstallDirs)
set_target_properties(TracyClient PROPERTIES VERSION ${PROJECT_VERSION})
set(tracy_includes set(tracy_includes
${TRACY_PUBLIC_DIR}/tracy/TracyC.h ${TRACY_PUBLIC_DIR}/tracy/TracyC.h
${TRACY_PUBLIC_DIR}/tracy/Tracy.hpp ${TRACY_PUBLIC_DIR}/tracy/Tracy.hpp
@ -146,10 +156,10 @@ install(FILES ${common_includes}
install(EXPORT TracyConfig install(EXPORT TracyConfig
NAMESPACE Tracy:: NAMESPACE Tracy::
FILE TracyTargets.cmake FILE TracyTargets.cmake
DESTINATION share/Tracy) DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Tracy)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/TracyConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/TracyConfig.cmake"
INSTALL_DESTINATION share/Tracy) INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Tracy)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TracyConfig.cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TracyConfig.cmake
DESTINATION share/Tracy) DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/Tracy)

22
version.cmake Normal file
View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)
message("Parsing public/common/TracyVersion.hpp file")
file(READ "public/common/TracyVersion.hpp" version)
# Note: This looks for a specific pattern in TracyVersion.hpp, if it changes
# this needs updating.
string(REGEX MATCH "Major = ([0-9]+)" _ ${version})
# This works do to the above () subexpression selection. See
# https://cmake.org/cmake/help/latest/command/string.html#regex-match for more
# details
set(major ${CMAKE_MATCH_1})
string(REGEX MATCH "Minor = ([0-9]+)" _ ${version})
set(minor ${CMAKE_MATCH_1})
string(REGEX MATCH "Patch = ([0-9]+)" _ ${version})
set(patch ${CMAKE_MATCH_1})
message("VERSION ${major}.${minor}.${patch}")