diff --git a/CMakeLists.txt b/CMakeLists.txt index 814201d..5040760 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ list(APPEND cmkr_SOURCES "include/literals.hpp" "include/project_parser.hpp" "cmake/cmkr.cmake" + "cmake/version.hpp.in" ) list(APPEND cmkr_SOURCES diff --git a/cmake.toml b/cmake.toml index f7520fa..88abb69 100644 --- a/cmake.toml +++ b/cmake.toml @@ -25,6 +25,7 @@ sources = [ "src/*.cpp", "include/*.hpp", "cmake/cmkr.cmake", + "cmake/version.hpp.in", ] include-directories = [ "include", diff --git a/cmake/generate_resources.cmake b/cmake/generate_resources.cmake index 57533c3..20c7d98 100644 --- a/cmake/generate_resources.cmake +++ b/cmake/generate_resources.cmake @@ -5,15 +5,19 @@ function(generate_resources target) PROPERTY SOURCES ) foreach(SOURCE ${TARGET_SOURCES}) + get_filename_component(RESOURCE_NAME "${SOURCE}" NAME_WE) + set(RESOURCE_HEADER "include/resources/${RESOURCE_NAME}.hpp") + if(SOURCE MATCHES ".cmake$") - get_filename_component(RESOURCE_NAME "${SOURCE}" NAME_WE) - set(RESOURCE_HEADER "include/resources/${RESOURCE_NAME}.hpp") # Add configure-time dependency on the source file configure_file("${SOURCE}" "${RESOURCE_HEADER}" COPYONLY) # Generate the actual resource into the header file(READ "${SOURCE}" RESOURCE_CONTENTS) configure_file("${PROJECT_SOURCE_DIR}/cmake/resource.hpp.in" "${RESOURCE_HEADER}" @ONLY) message(STATUS "[cmkr] Generated ${RESOURCE_HEADER}") + elseif(SOURCE MATCHES ".in$") + configure_file("${SOURCE}" "${RESOURCE_HEADER}" @ONLY) + message(STATUS "[cmkr] Generated ${RESOURCE_HEADER}") endif() endforeach() target_include_directories(${target} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include") diff --git a/cmake/version.hpp.in b/cmake/version.hpp.in new file mode 100644 index 0000000..87a5f7b --- /dev/null +++ b/cmake/version.hpp.in @@ -0,0 +1,3 @@ +#pragma once + +#define CMKR_VERSION "@PROJECT_VERSION@" \ No newline at end of file diff --git a/src/help.cpp b/src/help.cpp index 5d93f57..84b4af6 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -1,9 +1,10 @@ #include "help.hpp" +#include namespace cmkr { namespace help { -const char *version() noexcept { return "cmkr version 0.1.3"; } +const char *version() noexcept { return "cmkr version " CMKR_VERSION; } const char *message() noexcept { return R"lit(