我对CMake完全是个菜鸟。我的CMakeLists.txt
非常基础:
cmake_minimum_required(VERSION 2.4.6)
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#For the Curses library to load:
SET(CURSES_USE_NCURSES TRUE)
include_directories(
"src/"
)
add_subdirectory(src)
当我make时,链接器找不到ncurses命令,在make的详细模式下,我看到编译器没有添加-lncurses
。我必须向CMakeLists添加什么才能使其工作?
2条答案
按热度按时间zwghvu4y1#
对于超级菜鸟,记住
target_link_libraries()
需要低于add_executable()
:20jt8wwn2#
在使用一些第三方库之前,你应该找到它!在
ncurses
的情况下,你需要添加find_package(Curses REQUIRED)
,然后在调用target_link_libraries()
和target_include_directories(... ${CURSES_INCLUDE_DIR})
时使用${CURSES_LIBRARIES}
。