Skip to content

Instantly share code, notes, and snippets.

@luciopaiva
Last active March 5, 2022 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luciopaiva/6a1f870f932a5f54011cc869c4d558a8 to your computer and use it in GitHub Desktop.
Save luciopaiva/6a1f870f932a5f54011cc869c4d558a8 to your computer and use it in GitHub Desktop.
How to build aseprite via CLion on Windows

ase128 clion_logo_300x300a

The aseprite docs help with building it from the command line. Here I show how to build it via CLion. It is surprinsingly simple!

First, follow the instrucions in INSTALLATION.md. I will summarize here what I had to follow when building tag v1.3-beta11:

  1. Clone the repo with its submodules;

  2. Either stay in the main branch or switch to the desired tag. For example, this is how I switched to v1.3-beta11:

    git checkout tags/v1.3-beta11 -b v1.3-beta11
    
  3. Installing CMake is probably not necessary as I was able to build it just fine via the CMake bundled with CLion, so I think you can safely skip this;

  4. About Ninja, I'm not sure if it's necessary to download it either. I did install it before trying CLion, but it's possible that CLion is using its own, bundled Ninja - I suggest you download it just in case. It's just an EXE file. Move it to some folder and make sure it's in the system PATH variable;

  5. Download a pre-compiled version of the Skia library as instructed by the docs. The docs suggest putting it under C:\deps, but you can put it anywhere as long as you change the CMake options accordingly (see below);

  6. You need to download VS Community 2019 even if you're not using VS as an IDE, because the build task will need VS's SDK and etc. Make sure you also use the Visual Studio Installer to download the VS add-ons indicated in the docs.

After you go through the setup phase above, you can just skip the Compilation section for now and just follow the instructions below:

  1. Open CLion and point it to the project root folder;

  2. File -> Settings, select Build, Execution, Deployment -> CMake;

  3. There should already exist a Debug profile. In the CMake options field, paste the options described the in Compilation section. They should be something like this:

    -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLAF_BACKEND=skia -DSKIA_DIR=C:\deps\skia -DSKIA_LIBRARY_DIR=C:\deps\skia\out\Release-x64 -DSKIA_LIBRARY=C:\deps\skia\out\Release-x64\skia.lib -G Ninja ..
    

    Mind that you may need to replace C:\deps\skia with the correct folder where you placed the Skia library;

    image

  4. Now create a second profile. CLion should automatically name it Release and that's exactly what we want. Set CMake options just like instructed above;

  5. Now select Build, Execution, Deployment -> Toolchains. There should be a Visual Studio toolchain already configured. Make sure it's poiting to the correct VS version (2019 Community).

  6. In the Architecture field, change it from x86 to x64. This is important because the Skia pre-compiled library is built for x64 and the linker will break if you don't match it accordingly.

    image

And that should be it! CLion should have detected that CMake's options were changing and it should be running the recipe right now, both for Debug and Release (check the CMake window, you should see the two tabs there). You will probably see some warnings, but don't worry - that's expected. It should end with something like this:

-- Build files have been written to: C:/path/to/aseprite/cmake-build-release

[Finished]

After that is done, you should finally be able to invoke Ninja to do the linking and start the final executable. For that, select aseprite in the configurations combo box at the top right corner of CLion. Selecting either Debug or Release should work just fine. Click the play button and, if everything goes well, you should see Aseprite starting!

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment