CMake找不到cpp-netlib库 [英] CMake can't find cpp-netlib libraries

查看:237
本文介绍了CMake找不到cpp-netlib库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始学习CMake,并决定将其用于我正在从事的一个旧项目.该项目具有cpp-netlib,boost和Openssl作为依赖项. 这是我想出的有效的CMakeLists.txt文件.

I recently started learning CMake and have decided to use it with an old project I was working on. The project has cpp-netlib, boost and Openssl as dependencies. Here is the working CMakeLists.txt file I came up with.

CMAKE_MINIMUM_REQUIRED(VERSION 3.4.1)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
PROJECT(MangaMe)
INCLUDE_DIRECTORIES(includes)
ADD_EXECUTABLE(mangaMe src/mangaMe.cpp)

set(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE(Boost 1.59.0 REQUIRED COMPONENTS system thread filesystem)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(mangaMe ${Boost_LIBRARIES})

SET(OPENSSL_LIB_DIR /usr/local/Cellar/openssl/1.0.2e/lib)
INCLUDE_DIRECTORIES(/usr/local/Cellar/openssl/1.0.2e/include)
TARGET_LINK_LIBRARIES(mangaMe ${OPENSSL_LIB_DIR}/libcrypto.dylib ${OPENSSL_LIB_DIR}/libssl.dylib)

#WHY DOESNT THIS WORK!?!??!!?
#FIND_PACKAGE(cppnetlib 0.11 REQUIRED COMPONENTS client-connections server-parsers uri)
#INCLUDE_DIRECTORIES(${cppnetlib_INCLUDE_DIRS})
#TARGET_LINK_LIBRARIES(mangaMe ${cppnetlib_LIBRARIES})

SET(CPPNETLIB_LIB_DIR /usr/local/Cellar/cpp-netlib/0.11.2/lib)
INCLUDE_DIRECTORIES(/usr/local/Cellar/cpp-netlib/0.11.2/include)
TARGET_LINK_LIBRARIES(mangaMe ${CPPNETLIB_LIB_DIR}/libcppnetlib-client-connections.a ${CPPNETLIB_LIB_DIR}/libcppnetlib-server-parsers.a ${CPPNETLIB_LIB_DIR}/libcppnetlib-uri.a)

我想知道是否有人知道为什么使用FIND_PACKAGE查找cppnetlib的注释部分不起作用?我使用自制软件安装了cpp-netlib,当我运行if(cppnetlib_FOUND)时,我知道它找到了软件包,但似乎找不到库,因此当我尝试创建项目时,错误地指出它缺少cpp-库netlib.我还注意到,当我在FIND_PACKAGE中将版本设置为0.11.2(当前安装的版本)时,会收到一条消息,提示

I was wondering if anyone has any idea why the commented out section using FIND_PACKAGE to find cppnetlib doesn't work? I used homebrew to install cpp-netlib and when I run an if(cppnetlib_FOUND) I know that it finds the package but it seems to not find the libraries so when I try to make my project it errors saying its missing the libraries from cpp-netlib. I also noticed that when I set the version to 0.11.2 (the currently installed version) in the FIND_PACKAGE I get a message saying

-- Boost version: 1.59.0
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
CMake Error at CMakeLists.txt:16 (FIND_PACKAGE):
  Could not find a configuration file for package "cppnetlib" that is
  compatible with requested version "0.11.2".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/cppnetlib/cppnetlibConfig.cmake, version: 0.11.1
    /usr/local/lib/cmake/cppnetlib/cppnetlibConfig.cmake, version: 0.11.1



-- Configuring incomplete, errors occurred!
See also "/Users/LittleNewt/gitness/mangaMe/build/CMakeFiles/CMakeOutput.log".

没什么大不了的,因为当我明确指定目录时它可以工作,但仍然想知道为什么我不能只使用FIND_PACKAGE.

Not a huge deal since it works when I explicitly specify the directories but would still like to know why I can't just use FIND_PACKAGE.

推荐答案

尝试将cppnetlib_INCLUDE_DIRS更改为CPPNETLIB_INCLUDE_DIRS,将cppnetlib_LIBRARIES更改为CPPNETLIB_LIBRARIES.

Try changing cppnetlib_INCLUDE_DIRS to CPPNETLIB_INCLUDE_DIRS and cppnetlib_LIBRARIES to CPPNETLIB_LIBRARIES.

前缀不是按软件包名称命名,而是按软件包CMake文件中导出的内容命名.这是使用大写字母的源代码: https://github.com com/cpp-netlib/cpp-netlib/blob/master/cppnetlibConfig.cmake.in

The prefix doesn't go by the package name, but rather by what is exported in the package's CMake file. Here's the source that uses uppercase: https://github.com/cpp-netlib/cpp-netlib/blob/master/cppnetlibConfig.cmake.in

这篇关于CMake找不到cpp-netlib库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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