gpt4 book ai didi

c++ - 如何防止 CMake 在生成的项目的根目录下添加 CMakeLists.txt?

转载 作者:行者123 更新时间:2023-11-28 01:14:58 30 4
gpt4 key购买 nike

我有以下 CMakeLists.txt:

cmake_minimum_required(VERSION 3.15.5)

project(REminiscence VERSION 0.4.5)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

configure_file(REminiscenceConfig.h.in REminiscenceConfig.h)

add_definitions(-DUSE_MODPLUG -DUSE_STATIC_SCALER -DUSE_TREMOR -DUSE_ZLIB)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(RE_SRC
"collision.cpp"
"cpc_player.cpp"
"cutscene.cpp"
"decode_mac.cpp"
"dynlib.cpp"
"file.cpp"
"fs.cpp"
"game.cpp"
"graphics.cpp"
"main.cpp"
"menu.cpp"
"mixer.cpp"
"mod_player.cpp"
"ogg_player.cpp"
"piege.cpp"
"protection.cpp"
"resource.cpp"
"resource_aba.cpp"
"resource_mac.cpp"
"scaler.cpp"
"screenshot.cpp"
"seq_player.cpp"
"sfx_player.cpp"
"staticres.cpp"
"systemstub_sdl.cpp"
"unpack.cpp"
"util.cpp"
"video.cpp"
)

source_group("Sources" FILES ${RE_SRC})

set(RE_INC
"cpc_player.h"
"cutscene.h"
"decode_mac.h"
"dynlib.h"
"file.h"
"fs.h"
"game.h"
"graphics.h"
"intern.h"
"menu.h"
"mixer.h"
"mod_player.h"
"ogg_player.h"
"resource.h"
"resource_aba.h"
"resource_mac.h"
"scaler.h"
"screenshot.h"
"seq_player.h"
"sfx_player.h"
"systemstub.h"
"unpack.h"
"util.h"
"video.h"
)

source_group("Headers" FILES ${RE_INC})

add_executable(REminiscence ${RE_SRC} ${RE_INC})

find_package(SDL2 CONFIG REQUIRED)
target_link_libraries(REminiscence PRIVATE SDL2::SDL2 SDL2::SDL2main)

find_package(ZLIB REQUIRED)
target_link_libraries(REminiscence PRIVATE ZLIB::ZLIB)

target_include_directories(REminiscence PUBLIC
"${PROJECT_BINARY_DIR}"
)

当我生成 Visual Studio 解决方案时,它还会将 CMakeLists.txt 放在根目录中:

enter image description here

问题

如果可能的话,如何防止 CMake 在根目录添加 CMakeLists.txt

最佳答案

您不能从项目中删除 CMakeLists.txt,这是设计使然。

cmakeCMakeLists.txt 作为依赖添加到项目中。即使您在外部编辑器中修改它,MSBuild 也会运行 cmake . 来更新项目。您不需要手动运行 cmake .cmake --build,当您选择 Build Solution 时,Visual Studio 会为您完成。

此外,如果 CMakeLists.txt 在项目中,您可以直接在 Visual Studio 中轻松编辑它。

关于c++ - 如何防止 CMake 在生成的项目的根目录下添加 CMakeLists.txt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58988289/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com