CUTE is an easy to use C++ unit testing framework that leverages modern C++ libraries and features. CLion is a cross-platform IDE for C and C++ made by JetBrains. CUTE has, currently, an Eclipse plugin that is easy to install and use. This simple project aims to help beginners run CUTE tests in CLion.
You can either clone this repository (using git clone
) or copy the structure represented below.
Be sure to check the .gitignore file in order to keep unwanted (and possibly conflituous) files from being pushed to a Git repository.
The following tutorial was made and test with the following software:
- CLion 2020.3.2 (Build 203.7148.70)
- CUTE Standalone v2.2.6 (14 Oct 2019)
Forked from https://github.com/NIAEFEUP/cute-clion (archive)
For this to work, we need to install the following programs:
- CLion
- CUTE Standalone, which has a link to the CUTE-Repo on GitHub
This step is not needed if you cloned the repository. Otherwise, you need to create the following structure in your project:
cute-clion
|-- CMakeLists.txt # compilation instructions
`-- src # source code directory/folder
`-- Test.cpp # example with tests
Now, from the downloaded CUTE Standalone, copy the cute
folder (which includes cute.h
and the other cute_...
header files) to the project alongside the src/
folder.
The structure of your project should look like this afterwards:
cute-clion
|-- CMakeLists.txt
|-- cute # added folder from CUTE-master download
| |-- cute.h
| |-- ... (omitted files)
`-- src
`-- Test.cpp
After having achieved the structure above, we need to tell CLion to use cute
to add CUTE functions to its suggestions system.
To do that, on 'Project' file explorer, right-click the cute
folder and mark the directory as 'Library Files', as seen below.
- More folders can be created inside the
src
directory since they are all included automatically. - The
Test.cpp
file can be deleted and changed, it is just an example. However, it is mandatory that there is a.cpp
file with amain
function. - If you have problems, marking
cute
as library in clion, delete the hidden.idea
folder and restart clion and retry it - If you have compilation errors regarding
boost
, make sure cmake is using a version never than c++11, by adding this lineset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
to theCMakeLists.txt
file. More info
CLion uses CMake to compile its programs. As you can probably guess, CMakeLists.txt
is the file that tells CMake how to compile the source code.
Let's take a closer look.
1 cmake_minimum_required(VERSION 3.8)
2 project(clion)
3 include_directories(cute)
4 file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")
5 add_executable(clion ${SOURCE_FILES})
Explanation:
- This instruction specifies the minimum version of CMake required;
- The
project
command names the project (to be used later); - This line includes the CUTE library in the compilation process, allowing us to use its functionality;
- The
file
instruction will get all filenames that match thesrc/*.cpp
pattern and join them all in theSOURCE_FILES
variable; - This function creates the executable from the project name provided in the second line and all the files in the
SOURCE_FILES
variable.
If this was not what you were looking for, check out this picture of a cute sea lion
I took. I hope this helps..