this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Making CMake produce version header.

authored by

Jonathan Dearborn and committed by
Alice
d88f0273 72247d32

+26 -11
+15 -6
CMakeLists.txt
··· 1 - cmake_minimum_required(VERSION 2.6) 1 + cmake_minimum_required(VERSION 3.0) 2 2 3 3 project(SDL_gpu) 4 4 5 - file(READ version.txt SDL_GPU_VERSION) 5 + file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.txt VERSION_FILE_CONTENTS) 6 6 7 - if((NOT DEFINED VERSION_MAJOR OR NOT DEFINED VERSION_MINOR OR NOT DEFINED VERSION_BUGFIX) AND SDL_GPU_VERSION STREQUAL "") 7 + if((NOT DEFINED VERSION_MAJOR OR NOT DEFINED VERSION_MINOR OR NOT DEFINED VERSION_BUGFIX) AND VERSION_FILE_CONTENTS STREQUAL "") 8 8 message(ERROR "Missing version.txt, VERSION_MAJOR, VERSION_MINOR, and VERSION_BUGFIX.") 9 9 message(FATAL_ERROR "Failed to read version.txt and cannot proceed without a version number for SDL_gpu.") 10 10 endif() 11 11 12 12 if(NOT DEFINED VERSION_MAJOR) 13 - string(REGEX MATCH "^[0-9]*" VERSION_MAJOR ${SDL_GPU_VERSION}) 13 + string(REGEX MATCH "^[0-9]*" VERSION_MAJOR ${VERSION_FILE_CONTENTS}) 14 14 endif() 15 15 if(NOT DEFINED VERSION_MINOR) 16 - string(REGEX MATCH "[.][0-9]*[.]" VERSION_MINOR ${SDL_GPU_VERSION}) 16 + string(REGEX MATCH "[.][0-9]*[.]" VERSION_MINOR ${VERSION_FILE_CONTENTS}) 17 17 # Chop off the dots 18 18 string(LENGTH ${VERSION_MINOR} VERSION_MINOR_LENGTH) 19 19 string(SUBSTRING ${VERSION_MINOR} 1 ${VERSION_MINOR_LENGTH}-2 VERSION_MINOR) 20 20 endif() 21 21 if(NOT DEFINED VERSION_BUGFIX) 22 - string(REGEX MATCH "[0-9]*$" VERSION_MAJOR ${SDL_GPU_VERSION}) 22 + string(REGEX MATCH "[0-9]*$" VERSION_MAJOR ${VERSION_FILE_CONTENTS}) 23 23 endif() 24 24 25 25 set(SDL_gpu_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUGFIX}) 26 + 27 + message("Writing version header for v${SDL_gpu_VERSION}") 28 + string(CONCAT VERSION_HEADER_CONTENTS "#ifndef _SDL_GPU_VERSION_H__" 29 + "#define _SDL_GPU_VERSION_H__" 30 + "#define SDL_GPU_VERSION_MAJOR ${VERSION_MAJOR}" 31 + "#define SDL_GPU_VERSION_MINOR ${VERSION_MINOR}" 32 + "#define SDL_GPU_VERSION_PATCH ${VERSION_BUGFIX}" 33 + "#endif") 34 + file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/include/SDL_gpu_version.h ${VERSION_HEADER_CONTENTS}) 26 35 27 36 set(SDL_gpu_INSTALL_BY_DEFAULT ON) 28 37 set(SDL_gpu_DEFAULT_BUILD_SHARED ON)
+2 -4
include/SDL_gpu.h
··· 12 12 extern "C" { 13 13 #endif 14 14 15 - // Compile-time versions 16 - #define SDL_GPU_VERSION_MAJOR 0 17 - #define SDL_GPU_VERSION_MINOR 11 18 - #define SDL_GPU_VERSION_PATCH 0 15 + // Compile-time version info 16 + #include "SDL_gpu_version.h" 19 17 20 18 /* Auto-detect if we're using the SDL2 API by the headers available. */ 21 19 #if SDL_VERSION_ATLEAST(2,0,0)
+8
include/SDL_gpu_version.h
··· 1 + #ifndef _SDL_GPU_VERSION_H__ 2 + #define _SDL_GPU_VERSION_H__ 3 + 4 + #define SDL_GPU_VERSION_MAJOR 0 5 + #define SDL_GPU_VERSION_MINOR 11 6 + #define SDL_GPU_VERSION_PATCH 0 7 + 8 + #endif
+1 -1
version.txt
··· 1 - 0.11.0 1 + 0.12.0