cmake不链接ncurses [英] cmake does non link ncurses

查看:232
本文介绍了cmake不链接ncurses的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对cmake完全陌生.我的CMakeLists确实很基本:

I am a total noob concerning cmake. My CMakeLists is really basic:

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)

当我使链接器找不到ncurses命令时,在make的详细模式下,我看到编译器未添加-Incurses.我必须添加什么到CMakeLists才能使其正常工作?

when I make the linker does not find the ncurses commands and in the verbose mode of make I see that the compiler did not add the -lncurses. What do I have to add to the CMakeLists to make it work?

推荐答案

对于超级菜鸟,请记住target_link_libraries()必须低于add_executable():

For the super noob, remember target_link_libraries() needs to be below add_executable():

cmake_minimum_required(VERSION 2.8) project(main)

find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIR})

add_executable(main main.cpp)
target_link_libraries(main ${CURSES_LIBRARIES})

这篇关于cmake不链接ncurses的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆