Typo in CMake Tutorial » Step 2: Adding a Library

In the tutorial it is said to

Lastly, replace sqrt with our library function mathfunctions::mysqrt.

However, the functionmysqrt is in namespace mathfunctions::detail not just mathfunctions. There is a wrapper mathfunctions::sqrt which I believe should be mentioned instead. It is also written that way in the solution.

Thanks for catching this! I created a MR with a fix for the typo along with some other minor tutorial issues here: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8779

This is a heads up for others if they encounter similar errors during Step 2 Exercise 1.

IDE: VSCodium 1.85.2
Extensions: clangd v0.1.26, CMake, CMake Tools, CodeLLDB
Compiler: GCC 13.2.0 x86_64-w64-mingw
CMake: cmake-3.28.0-windows-x86_64
Tutorial: cmake-3.28.1-tutorial-source.zip

I copied the solutions to TODO 1 through 4 to the relevant files.

Step 2 Exercise 1 TODO 5: Include MathFunctions.h

#include “MathFunctions.h”

Error: ‘MathFunctions.h’ file not found

Step 2 Exercise 1 TODO 6: Replace sqrt with mathfunctions::sqrt

const double outputValue = mathfunctions::sqrt(inputValue)

Error: Use of undeclared identifier ‘mathfunctions’

The cmake build works okay, but it’s confusing to see the errors from the clangd extension.