CLion and CMake: only building a library without an executable?

This is an old question. But I'll add the answer to your question as a help for other people. You need to replace your add_executable with add_library

add_library(target_name source_files)

Short answer: compile the library target and run any custom command as a placeholder to avoid the warning.

Long answer:

CLion lets you either build the whole project and run executables/configurations.

When running executables, you can choose a target to compile and the executable to run after compiling the target. For executable targets, they are usually the same thing. You compile the executable target and then run it.

It seems like this is not really designed for libraries, but there is a workaround. You usually set the target to be the library and the executable to be any executable that depends on this library. However, this is usually not very useful because if you wanted to run this executable you could just set this executable to be the target and the library would be built anyway.

So people probably want to just build the library (to check if everything is OK, etc) without compiling or running any extra executable targets. In this case, the workaround is to choose a custom executable to run after building the library, and the error message is gone.

You have nothing useful you need to run after building the library, just choose any cheap command as a placeholder. Something like "pwd" or "ls".

Setting up a configuration