Git Product home page Git Product logo

llanillo / clion-cmake-sdl2-template Goto Github PK

View Code? Open in Web Editor NEW
59.0 2.0 4.0 14.44 MB

Template for Clion/Cmake and SDL2 Setup

CMake 0.85% Shell 0.06% C 97.63% Objective-C 0.39% M4 0.57% Makefile 0.19% JavaScript 0.29% HTML 0.01% C++ 0.02%
clion clion-cmake cmake cmake-template sdl2 sdl2-application sld2-image clionsdl2 jetbrains c cpp development videogames template game-development game-dev gamedev sdl cmake-modules cmakelists

clion-cmake-sdl2-template's Introduction

Clion and SDL2 Setup

It's been so hard to find a decent guide about how to set up Clion and SDL2, so I made one for my future self and for some random person on internet who find this. I hope it helps you.

We are going to use the bundled MinGw 64 bits version that comes with Clion, if you use 32 bits version you should replace the CMakeLists.txt file with the proper directories paths.

Note: This project was tested on Windows 64 bits.

Fast setup

All the files needed to make it work are already uploaded. You just need to open with it Clion and start coding.

  • Download or clone the repository
git clone https://github.com/llanillo/clion-cmake-sdl2-template
  • Open it with Clion and click Ok to the Project Wizard.
  • (Optional) Rename the project. To do it you must change PROJECT_NAME ONLY in line 2 of CMaLists.txt.
  • Compile and run it. Everything went well if you see a purple window with exit code '0'.

Manual setup

  • Download the latest SDL Development Libraries (MinGW version)

  • Download the SDL2 Cmake Scripts

  • Create a cmake/modules directory in your project root and unzip all cmake scripts there.

  • Unzip the SDL Development libraries in your project root, rename the folder to 'SDL2'

  • Mark the SDL2 folder as excluded in Clion (Optional)

  • Download the CMakeLists.txt from this repository and copy it to your project.

  • (Optional) Rename the project editing line 2 (PROJECT_NAME) in line 2.

  • Copy the SDL2.dll from the SDL2 folder into your cmake-build-debug folder:

    • For 64 bits version it's located at x86_64-w65-mingw32/bin/SDL2.dll
    • For 32 bits version it's located at i686-w64-mingw32/bin/SDL2.dll
  • Modify the main.cpp signature to look like:

int main (int argc, char* args[])

If your exit code is 0 and Clion detects your SDL2 headers then you are good to go.

Important READ

  • The paths should be exactly as told otherwise change the folder's paths inside the CMakeLists.txt.
  • MingGw should be the default toolchains for Clion.
  • Add SDL2 and cmake folders to the gitignore.

Project tree example

example

Setup SDL2 Image

  1. Download the SDL Image Development Release

  2. Inside your SDL2 Image folder (downloaded from step 1), select the version you are using for SDL2 and copy it to your SDL2 folder in your project (It won't override anything)

  3. Put the SDL2_image.dll from the SDL2 Image folder into your cmake-build-debug folder.

  4. Add to the CMakeList:

set(SDL2_IMAGE_PATH "SDL2/x86_64-w64-mingw32")
find_package(SDL2_image REQUIRED) 

Modify the SDL2_IMAGE_PATH if you are using the 32 bit version

clion-cmake-sdl2-template's People

Contributors

cesare077 avatar llanillo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clion-cmake-sdl2-template's Issues

SDL2_IMAGE setup issue

I followed your instruction ,but the image library still not working. After google it up I find that the I need add ${SDL2_IMAGE_LIBRARIES} to target_link_libraries in the cmakefile.txt. For reference only.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.