Define version number and project name with cmake

This commit is contained in:
Epicalert 2021-01-27 00:21:06 +08:00
parent 82edd492c0
commit 5cdd1808ad
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD
6 changed files with 17 additions and 4 deletions

2
.gitignore vendored
View file

@ -33,3 +33,5 @@
fc2d
build/
src/config.hpp

View file

@ -1,5 +1,5 @@
cmake_minimum_required( VERSION 3.0 )
project( FaceCam2D VERSION 0.1.0 )
project( Facecam2D VERSION 0.1.0 )
find_package( OpenCV REQUIRED )
message (STATUS "Found OpenCV at: " ${OpenCV_INCLUDE_DIRS} )
find_package( OpenGL REQUIRED )
@ -16,6 +16,7 @@ include_directories( ${GLEW_INCLUDE_DIRS} )
include_directories( ${GLM_INCLUDE_DIRS} )
include_directories( ${GLUT_INCLUDE_DIR} )
include_directories( ${PROJECT_SOURCE_DIR}/src )
configure_file( ${PROJECT_SOURCE_DIR}/src/config.hpp.in ${PROJECT_SOURCE_DIR}/src/config.hpp @ONLY )
file(
COPY
${PROJECT_SOURCE_DIR}/models

View file

@ -1,7 +1,8 @@
#include <args.hpp>
#include <config.hpp>
const char* argp_program_version =
"Facecam2D 0.1.0\n"
PROJECT_NAME " " VERSION_CODE "\n"
"License: GPLv3 <https://www.gnu.org/licenses/gpl-3.0.html>\n"
"If you did not receive a copy of the source code, it is\n"
"available at <https://gitlab.com/epicalert/facecam2d.git>.";

8
src/config.hpp.in Normal file
View file

@ -0,0 +1,8 @@
#ifndef CONFIG_HPP
#define CONFIG_HPP
#define PROJECT_NAME "@PROJECT_NAME@"
#define VERSION_CODE "@PROJECT_VERSION@"
#endif

View file

@ -13,6 +13,7 @@
#include <graphics.hpp>
#include <modelpart.hpp>
#include <paths.hpp>
#include <config.hpp>
GLuint shader; //standard shader program used for all elements
GLuint transUniform; //location of the "transMatrix" transformation matrix uniform in the shader
@ -73,7 +74,7 @@ void initGraphics () {
char *argv[1] = {(char*)"fc2d"};
glutInit(&argc, argv);
glutCreateWindow("FaceCam2D");
glutCreateWindow(PROJECT_NAME);
glutInitWindowSize(512, 512);
glewExperimental = GL_TRUE;

View file

@ -9,7 +9,7 @@
int main (int argc, char** argv) {
argp_parse(&argp, argc, argv, 0, 0, 0);
std::cout << "Facecam2D is starting..." << std::endl;
std::cout << PROJECT_NAME " is starting..." << std::endl;
initPrefixes();
std::cout << "Custom asset prefix: " << prefixCustom << std::endl;