CMake Error In Linux: target "FILE_SET" does not exist

Hi everyone,

I’m a beginner to CMake, using 3.22.1, and attempting to build a project targeting both Windows and Linux (x86). I am using an example CMake project to learn how to make this work, specifically this shared library project below:

I have installed and enabled the WSL in VS2022 and created a CMake project. The code is all deployed and compiles fine for Windows, but if I try to build the project for Linux, I get this error:

“install TARGETS given target “FILE_SET” which does not exist.”

I can’t find any information on why this is happening. From what I understand, the CMakeLists.txt in the shape and square subdirectories gather their files into a file set called “HEADERS”, which I then reference in the install command so I don’t have to manually specify all the source files in the install command.

I don’t understand what this error means, and why it doesn’t happen for Windows. Why is “FILE_SET” being interpreted as the target name and not a keyword indicating that I want to target a file set called “HEADERS”?


Trying that example should give an error message about your old CMake version.
The cmake_minimum_required(VERSION 3.23) is there for a reason, FILE_SET was introduced in v3.23.

1 Like

D’Oh! I wasn’t paying attention and probably changed the version. Why did it build fine on Windows then? Both Windows and Linux were running 3.22.1 (I specifically made sure both versions were identical).

I’ve upgraded both to 3.26.0 and it builds fine. Thanks very much!