feat: add version header
This commit is contained in:
parent
6260ce47dc
commit
0d43936a61
@ -2,21 +2,20 @@ cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(
|
||||
hello
|
||||
VERSION 0.1
|
||||
VERSION 0.1.0
|
||||
LANGUAGES CXX)
|
||||
|
||||
set(SOURCES src/main.cpp)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS
|
||||
ON
|
||||
CACHE INTERNAL "")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if(CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
|
||||
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
|
||||
endif()
|
||||
|
||||
add_executable(hello ${SOURCES})
|
||||
configure_file("${PROJECT_SOURCE_DIR}/include/version.h.in"
|
||||
"${PROJECT_BINARY_DIR}/include/version.h")
|
||||
|
||||
add_executable(hello src/main.cpp)
|
||||
target_compile_features(hello PUBLIC cxx_std_20)
|
||||
|
||||
target_include_directories(hello PRIVATE "${PROJECT_BINARY_DIR}/include")
|
||||
|
8
include/version.h.in
Normal file
8
include/version.h.in
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
||||
#define VERSION_MINOR @PROJECT_VERSION_MINOR@
|
||||
#define VERSION_PATCH @PROJECT_VERSION_PATCH@
|
||||
#define VERSION_TWEAK @PROJECT_VERSION_TWEAK@
|
||||
|
||||
#define VERSION "@PROJECT_VERSION@"
|
@ -1,6 +1,10 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::cout << "Hello" << std::endl;
|
||||
return 0;
|
||||
std::cout << "Hello, world! Version " << VERSION << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Reference in New Issue
Block a user