Compiler Explorer with Cmake

Gajendra Gulgulia
6 min readOct 7, 2021
Compilere Explorer and Cmake

Introduction

Compiler explorer has been one of the most widely used online tool for compiling C++ code, doing experiment with C++ features, sharing code snippets with friends and colleagues and also (my favorite feature) to compare and prove with the help of assembly code why a certain way of coding might be good or bad compared to another way.

Recently compiler explorer added support for compiling multiple files with CMakeLists.txt . This opens up a new possibilities for developers around the world from testing complex pieces of code to testing the compilation behavior of the same.

In this issue, I would like to give a walk through on how to set up a simple layout of three files compiled with CMakelists.txt. Note that the focus is on setting up compiler explorer for multiple files and not on code efficiency. Also the article might at first glance look lengthy, but it may only be due to 19 images in the tutorial. So don’t get weighed down by the size of the article and lets start!

1. Compiler explorer default layout

If you’ve never visited the page of compiler explorer, then simply type in the url : www.godbolt.org and you’ll land on the compiler explorer page. The default layout shows a C++ source file having a function square compiled with the latest gcc…

--

--