-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Working with CMake
lesleyrs edited this page Jan 25, 2024
·
11 revisions
If you installed raylib with a package manager, or used make install
, a simple CMakeLists.txt
could look like this:
cmake_minimum_required(VERSION 3.15)
project(my_project)
find_package(raylib 3.0 REQUIRED) # Requires at least version 3.0
set(CMAKE_C_STANDARD 11) # Requires C11 standard
add_executable(${PROJECT_NAME} main.c)
target_link_libraries(${PROJECT_NAME} raylib)
# Checks if OSX and links appropriate frameworks (only required on MacOS)
if (APPLE)
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
endif()
To generate build files in separate directory and build the project, use these commands:
cmake -B build && cmake --build build
If you want someone who builds your project to be able to download and build raylib with it, the CMakeLists.txt at projects/CMake will help you.
CMake supports a range of generators, which can be used to generate project files for IDEs/Build-Tools such as Visual Studio, Ninja or Sublime Text 2. e.g. for Xcode you can run cmake -G 'Xcode' ..
to have it generate project files for import into Xcode.
www.raylib.com | itch.io | GitHub | Discord | YouTube
- Architecture
- Syntax analysis
- Data structures
- Enumerated types
- External dependencies
- GLFW dependency
- libc dependency
- Platforms and graphics
- Input system
- Default shader
- Custom shaders
- Coding conventions
- Integration with other libs
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on Chrome OS
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working on exaequOS Web Computer
- Creating Discord Activities
- Working anywhere with CMake
- CMake Build Options
- raylib templates: Get started easily
- How To: Quick C/C++ Setup in Visual Studio 2022, GCC or MinGW
- How To: C# Visual Studio Setup
- How To: VSCode
- How To: Eclipse
- How To: Sublime Text
- How To: Code::Blocks