Issue
I have the following 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}"
)
When I generate the Visual Studio solution, it also puts CMakeLists.txt
at the root:
Question
How, if possible, to prevent CMake adding that CMakeLists.txt
at root ?
Solution
You can't remove CMakeLists.txt
from a project, it's done by design.
cmake
adds CMakeLists.txt
to a project as a dependence. If you modify it even in an external editor, MSBuild
runs cmake .
to update a project. You don't need to run cmake .
and cmake --build
manually, the Visual Studio does it for you when you select Build Solution.
Also if CMakeLists.txt
is in a project, you can easy edit it in Visual Studio directly.
Answered By - S.M.