How to compile a single source file from list of sources set in a static library

AFAIK CMake isn’t meant to do that. Build systems generally care about build targets (like a library or executable), not so much individual files.

If you really, really need to do that, you could always make a single library (e.g. object library) per cpp file, although 1) I’m not sure what build speed results you would get if you were to do that on a large project, 2) if two files anywhere in your project have the same name, even inside different libraries, you could easily fall into a case where you have two targets with the same name, and then CMake will complain, and 3) you will need to repeat target-specific properties like target_compile_features() for each of these libraries, which essentially means you’ll need a function to set them, which in turn will quickly make your CMake code hard to read.

# Untested, fix issues if any!
add_library(file1-lib OBJECT file1.cpp)
setup_tally_world_lib(file1-lib)
# ...
add_library(fileN-lib OBJECT fileN.cpp)
setup_tally_world_lib(fileN-lib)

add_library(tally-world-lib)
target_link_libraries(tally-world-lib
  PUBLIC
    file1-lib
    file2-lib
    # ...
    fileN-lib)

You could then run the appropriate target using the --target CLI option. As a final note, I remember reading somewhere in CMake’s doc that (for XCode only I think?) you can’t have a library with no sources as tally-world-lib does above.

Personally this seems like way too much badness for something you probably don’t need!