Skip to content

Instantly share code, notes, and snippets.

@haxfn
Created May 15, 2024 17:41
Show Gist options
  • Select an option

  • Save haxfn/4b0e0ad238cef6184d4840287ce71d1c to your computer and use it in GitHub Desktop.

Select an option

Save haxfn/4b0e0ad238cef6184d4840287ce71d1c to your computer and use it in GitHub Desktop.
Raylib CMakeLists Template (Linting, LSP works)
cmake_minimum_required(VERSION 3.0)
project(fourier_series C)
set(CMAKE_C_STANDARD 11)
# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Adding Raylib
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games
FetchContent_Declare(
raylib
GIT_REPOSITORY "https://github.com/raysan5/raylib.git"
GIT_TAG "master"
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(raylib)
# Adding our source files
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.c") # Define PROJECT_SOURCES as a list of all source files
set(PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/include/") # Define PROJECT_INCLUDE to be the path to the include directory of the project
# Declaring our executable
add_executable(
${PROJECT_NAME}
src/cycloid.c
src/fourier.c
src/readPoints.c
src/sketch.c
test/drawSVGFourier.c
)
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE})
target_link_libraries(${PROJECT_NAME} PRIVATE raylib)
# Setting ASSETS_PATH
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="./assets") # Set the asset path macro in release mode to a relative path that assumes the assets folder is in the same directory as the game executable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment