-
Notifications
You must be signed in to change notification settings - Fork 1
Build on any OS with CLion
Marcus Hudritsch edited this page Jul 1, 2024
·
2 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, you must also install 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.
- Go to File > Settings... > Build, Execution, Deployment > Toolchains and check what kind of toolchain is active. Under Windows, Visual Studio must be on top.
-
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
-
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.
- 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
-
To run the demo application set the app-demo | Release as the startup project.
- Press the Run button to start the app.
- After closing the welcome dialogue you can open with the menu File > Load Demo Scenes many different scenes that demonstrate the features of SLProject.
- 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