Issue
I am trying to understand this package meant to be built with cmake. I am having trouble understanding how the CMakeLists.txt of the same package is finding the source code needed to create a shared library file. Specifically, in the line (Line13 of the same file):
add_library(HelloWorld SHARED HelloWorld)
the first HelloWorld
is the target's name & the 2nd HelloWorld
is supposed to be the source (code). But there is no source file called HelloWorld
in the same directory. There are only HelloWorld.hh
& HelloWorld.cc
files. And there is a class called HelloWorld
in the hello_world
namespace in the .cc
& .hh
files.
So, does the build tool automatically search for files of any extension starting with the name HelloWorld
? How does the above Line13 work? I'm using cmake 3.22.1
& the build is passing.
Thanks!
Solution
Refer to CMake policy CMP0115.
The OLD behavior for this policy is to implicitly append known extensions to source files if they can't be found.
In CMake 3.22, if the source extension isn't mentioned and the cmake_policy()
command is not sent, the OLD
behavior is used and a warning is shown encouraging developers to mention the extension explicitly.
Answered By - PhiloRobotist Answer Checked By - Katrina (WPSolving Volunteer)