Can I command CMake to not generate a Build system, but compile/link only?

I am working on a small-ish scale project.

Engine/
├── CMakeLists.txt
├── game/
│   └── CMakeLists.txt
└── lib/
    ├── zlib/
    │   └── CMakeLists.txt
    ├── DirectXTK/
    │   └── CMakeLists.txt
    └── libpng/
        └── CMakeLists.txt

Is it possible to not generate build systems for everything whats under lib/ and instead compile and link the library directly into the Engine project?

My CMakeLists.txt looks like this:

project(Engine VERSION 0.1)

add_subdirectory("./Game")
add_subdirectory("./Libraries/directxtk" "lib/directxtk")
add_subdirectory("./Libraries/zlib" "lib/zlib")
add_subdirectory("./Libraries/libzip" "lib/libzip")
target_include_directories(Game PUBLIC "${CMAKE_BINARY_DIR}/lib")

Visual Studio atleast generates a solution that contains several projects for every library; I would like to have only Game within that solution and Game having all libraries linked instead.


Is it possible to not generate build systems for everything whats under lib/ and instead compile and link the library directly into the Engine project?

This sounds like an XY problem. What do you really want to do?

  1. Are you trying to avoid CMake spending time configuring those projects? If they're really optional, then add option()s to disable them.
  2. Are you spending a lot of time rebuilding everything when you only want some parts? Let me point you to the cmake --build ... --config <Release|Debug|...> --target Game command. That will build only what is needed for target Game.
  3. Something else?

But this question of not "generat[ing] build systems" is ill-formed. CMake is a build system generator. How do you make a C++ compiler not compile C++?