我可以命令 CMake 不生成构建系统,而只生成 compile/link 吗?
Can I command CMake to not generate a Build system, but compile/link only?
我正在做一个小型项目。
Engine/
├── CMakeLists.txt
├── game/
│ └── CMakeLists.txt
└── lib/
├── zlib/
│ └── CMakeLists.txt
├── DirectXTK/
│ └── CMakeLists.txt
└── libpng/
└── CMakeLists.txt
是否可以不为 lib/
下的所有内容生成构建系统,而是将 link 库直接编译到 Engine
项目中?
我的 CMakeLists.txt 看起来像这样:
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 至少为每个库生成一个包含多个项目的解决方案;
我想在该解决方案中只有 Game
,而 Game
拥有所有库 linked。
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?
这听起来像 XY problem。你真正想做什么?
- 您是否试图避免 CMake 花时间配置这些项目?如果它们真的是可选的,则添加
option()
以禁用它们。
- 当您只想要一些零件时,您是否花费大量时间重建所有东西?让我向您指出
cmake --build ... --config <Release|Debug|...> --target Game
命令。这将只构建目标 Game
. 所需的内容
- 还有别的吗?
但是这个不是“生成[ing]构建系统”的问题是ill-formed。 CMake 是一个 构建系统生成器 。如何让 C++ 编译器不编译 C++?
我正在做一个小型项目。
Engine/
├── CMakeLists.txt
├── game/
│ └── CMakeLists.txt
└── lib/
├── zlib/
│ └── CMakeLists.txt
├── DirectXTK/
│ └── CMakeLists.txt
└── libpng/
└── CMakeLists.txt
是否可以不为 lib/
下的所有内容生成构建系统,而是将 link 库直接编译到 Engine
项目中?
我的 CMakeLists.txt 看起来像这样:
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 至少为每个库生成一个包含多个项目的解决方案;
我想在该解决方案中只有 Game
,而 Game
拥有所有库 linked。
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?
这听起来像 XY problem。你真正想做什么?
- 您是否试图避免 CMake 花时间配置这些项目?如果它们真的是可选的,则添加
option()
以禁用它们。 - 当您只想要一些零件时,您是否花费大量时间重建所有东西?让我向您指出
cmake --build ... --config <Release|Debug|...> --target Game
命令。这将只构建目标Game
. 所需的内容
- 还有别的吗?
但是这个不是“生成[ing]构建系统”的问题是ill-formed。 CMake 是一个 构建系统生成器 。如何让 C++ 编译器不编译 C++?