Created
September 14, 2018 14:47
-
-
Save AlecTaylor/2df914df77f2315c3868bcc7de1ef2a6 to your computer and use it in GitHub Desktop.
Handling version with CMake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.12) | |
project(c VERSION 0.0.1) | |
set(CMAKE_C_STANDARD 11) | |
configure_file(lib/version.h.in version.h @ONLY) | |
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | |
add_definitions(-Wno-implicit-function-declaration) | |
add_executable(foo foo.c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VERSION_H | |
#define VERSION_H | |
#cmakedefine PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ | |
#ifndef PROJECT_VERSION_MAJOR | |
#define PROJECT_VERSION_MAJOR 0 | |
#endif | |
#cmakedefine PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@ | |
#ifndef PROJECT_VERSION_MINOR | |
#define PROJECT_VERSION_MINOR 0 | |
#endif | |
#cmakedefine PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@ | |
#ifndef PROJECT_VERSION_PATCH | |
#define PROJECT_VERSION_PATCH 0 | |
#endif | |
#endif //VERSION_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment