diff --git a/CMakeLists.txt b/CMakeLists.txt index cff10b6f..affc35c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,14 @@ endif() # # Version # -execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_REV ERROR_QUIET) -file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/VERSION CONTENT "${GIT_REV}") +execute_process(COMMAND git describe --tags + OUTPUT_VARIABLE GIT_DESCRIBE_RESULT + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +message(STATUS "Version: ${GIT_DESCRIBE_RESULT}") +string(STRIP "${GIT_DESCRIBE_RESULT}" ION_KIT_VERSION_S) +add_definitions("-DION_KIT_VERSION=\"${ION_KIT_VERSION_S}\"") +string(REPLACE "v" "" ION_KIT_VERSION ${ION_KIT_VERSION_S}) +file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/VERSION CONTENT "${ION_KIT_VERSION_S}") # # ion utilities @@ -185,11 +191,5 @@ if (UNIX) else () set(CPACK_GENERATOR "ZIP") endif () -execute_process(COMMAND git describe --tags - OUTPUT_VARIABLE GIT_DESCRIBE_RESULT - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -message(STATUS "Version: ${GIT_DESCRIBE_RESULT}") -string(STRIP "${GIT_DESCRIBE_RESULT}" ION_KIT_VERSION_S) -string(REPLACE "v" "" ION_KIT_VERSION ${ION_KIT_VERSION_S}) set(CPACK_PACKAGE_VERSION ${ION_KIT_VERSION}) -include(CPack) \ No newline at end of file +include(CPack) diff --git a/src/log.cc b/src/log.cc index fc1efc47..8ccde7a4 100644 --- a/src/log.cc +++ b/src/log.cc @@ -24,6 +24,8 @@ struct Logger { auto logger = std::make_shared("ion", spdlog::sinks_init_list{console_sink, file_sink}); logger->set_level(spdlog::level::trace); + logger->debug("ion-kit version is {}", ION_KIT_VERSION); + spdlog::register_logger(logger); } } logger;