Skip to content

Build on any OS with CLion

Chnoblouch edited this page Feb 22, 2022 · 20 revisions
  • All C++ projects can also be built with the platform-independent IDE CLion from JetBrains. The advantage is that CLion uses cmake directly and does not create an additional project definition. For Windows without Visual Studio download the MinGW version with the GNU toolchain. For Windows, we recommend to build and work with Visual Studio.
  • Clone the SLProject GIT repository into a directory of your choice.
  • Open the CLion IDE.
    • Choose Import Project from Sources on the Welcome screen.
    • Select the top-level CMakeLists.txt file in the SLProject root folder.
    • Choose Open Existing Project
    • Wait for the configuration to complete.
  • Press the Hammer Button on the top toolbar to build all projects.
    • Note: CLion on Windows uses NMake as the default build system. NMake doesn't support parallel builds, which makes the compilation process incredibly slow. It's highly recommended that you switch to a better build system such as Ninja.
      • Go to File > Settings... > Build, Execution, Deployment > CMake
      • Add -G Ninja to the CMake options of the Debug configuration
  • Press the Run Button on the top toolbar to run the selected app|configuration.
  • The CLion defines by default only the Debug configuration. The Release configuration has to be added manually:
    • Go to File > Settings... > Build, Execution, Deployment > CMake
    • Press the + button to add a new configuration (CLion automatically chooses the Release configuration)
    • Add the CMake option -G Ninja if you use Windows and want to run parallel builds
    • Press OK

Building with Clang on Windows

  • SLProject can also be built using the Clang compiler
  • Download and run the latest installer from the LLVM project on GitHub (LLVM-x.x.x-win64.exe)
    • It's recommended that you add Clang to the system path during installation
  • In CLion, go to File > Settings... > Build Execution, Deployment > Toolchains
  • Press the + button
  • Select Visual Studio
  • Rename the toolchain to Clang
  • Change C Compiler and C++ Compiler to the location of clang-cl
    • clang-cl is a drop-in replacement for the Visual Studio compiler, which means it has the same frontend and uses the same ABIs
    • If CLion doesn't automatically find clang-cl, open a terminal, run where clang-cl and copy the resulting path (this only works if Clang was added to the system path during installation)
  • Move the toolchain to the top to make it the preferred one
  • Press OK
Clone this wiki locally