So joined (via /) with the relative path in #include directive will give absolute path to the header file. Of course, it’s all in the CMake documentation, but mentioned implicitly at best.
# This directory will be used as include directory. My installation looks like this: install(ĭESTINATION $/mylib However, upon installation, the header file(s) listed in the PUBLIC section of target_sources() are never installed. On Linux, you can also install the packages from the distributions package manager. On Windows double click the binary to install. This allows me to successfully build the library. Head over to CMake download page and get a binary for your operating system, e.g. You can add more configurations by choosing the green plus sign. Visual Studio provides one 圆4-Debug configuration by default. vcpkg install sdl2 git clone https://gith. Environment OS: Ubuntu 20.04.1 LTS Compiler: CMake 3.16.3/Ninja To Reproduce Steps to reproduce the behavior. Now you see the Settings Editor with the installed configurations on the left. Describe the bug SDL2 target was not found. A CMakeLists.txt in one of the many subdirectories of my C++ library project looks like this: target_sources(mylib To open the CMake settings editor, select the Configuration drop-down in the main toolbar and choose Manage Configurations. It appears that target_sources() is somewhat of a mystery for anything other than adding private sources to an executable.Īfter reading a lot of material, where especially this blog entry was helpful, I managed to understand & bypass the issue with target_sources() and PUBLIC files.
#Cmake target how to#
I am having a hard time figuring out how to install PUBLIC headers specified in target_sources().