- Changed CMake file to use C++ instead of C and also to use the project name as the target name.

- Changed the macro-constants to constexpr constants and removed void as the parameter to main.
This commit is contained in:
Luca Sas 2021-03-31 19:00:44 +01:00
parent 310e32006f
commit bdab2b8a6e
2 changed files with 9 additions and 9 deletions

View file

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.0)
project(raylib_template C)
project(raylib_template CXX)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
# Setting parameters for raylib
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
@ -9,7 +9,7 @@ set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
add_subdirectory(libs/raylib)
add_executable(raylib_template src/main.c)
target_link_libraries(raylib_template PRIVATE raylib)
target_compile_definitions(raylib_template PUBLIC ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/") # Set the asset path macro to the absolute path on the dev machine
#target_compile_definitions(raylib_template PUBLIC ASSETS_PATH="relative-path-to-assets-in-the-game-package") # Set the asset path macro in release more
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE raylib)
target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/") # Set the asset path macro to the absolute path on the dev machine
#target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="relative-path-to-assets-in-the-game-package") # Set the asset path macro in release more

View file

@ -1,9 +1,9 @@
#include "raylib.h"
#define SCREEN_WIDTH (800)
#define SCREEN_HEIGHT (450)
constexpr auto SCREEN_WIDTH = 800;
constexpr auto SCREEN_HEIGHT = 450;
int main(void)
int main()
{
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Window title");
SetTargetFPS(60);