cmakelist:错误:没有将目标设置为“all”的规则。停

cmakelist: error: No rule to make target 'all'. Stop

提问人:Mannat Aggarwal 提问时间:11/14/2023 最后编辑:Abderrahmene Rayene MihoubMannat Aggarwal 更新时间:11/14/2023 访问量:29

问:

我收到此错误:

No rule to make target 'all'.  Stop.

这是我的CMake文件,我在Qt上运行它。

cmake_minimum_required(VERSION 3.0)

project(sorting-visualizer)

set(SFML_DIR "C:\\SFML-2.5.1\\lib\\cmake\\SFML")

set(SFML_ROOT "C:/SFML-2.5.1")

list(APPEND CMAKE_MODULE_PATH "C:\\SFML-2.5.1\\lib\\cmake\\SFML")

find_package(SFML COMPONENTS graphics window REQUIRED)

# Add your source files
add_executable(sorting-visualizer src/main.cpp src/Sortable.cpp src/SortAlgorithms.cpp src/SortController.cpp src/Utils.cpp)

include_directories("C:/SFML/include")
link_directories("C:/SFML/lib")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/Modules")

target_link_libraries(sorting-visualizer sfml-graphics)

add_custom_command(TARGET sorting-visualizer POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory
    "${SFML_ROOT}/bin" $<TARGET_FILE_DIR:sorting-visualizer>)

如何解决这个错误?

C++ Qt CMake

评论

1赞 Alan Birtles 11/14/2023
请展示一个最小的可重复示例,您如何调用 CMake?想必这个错误不是来自 cmake 它来自 make?

答: 暂无答案