fast-cpp-csv-parser 및 date 라이브러리를 사용하는 프로젝트에서 작업 중이며 zmq (0mq)를 추가하려고하지만 CMakeList를 작동시키지 못합니다. 여러 라이브러리를 사용할 때 CMakeList에서 target_link_libraries를 구성하는 올바른 방법은 무엇입니까? 연결 라이브러리 오류를 지정할 수 없습니다.
다음
는 작업CMakeList.txt
경우 :
CMakeLists.txt
에 추가되어야하는 다음
cmake_minimum_required(VERSION 3.7)
project(sample_project)
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES source/main.cpp include/csv.h include/date.h)
find_package (Threads)
add_executable(sample_project ${SOURCE_FILES})
target_link_libraries (sample_project ${CMAKE_THREAD_LIBS_INIT})
zmq instructions 같이 당 (ZMQ 및 CPPZMQ 이미 설치된). 내가 CMakeLists.txt
에 위의 코드를 추가 할 때
find_package(cppzmq)
if(cppzmq_FOUND)
include_directories(${cppzmq_INCLUDE_DIR})
target_link_libraries(sample_project ${cppzmq_LIBRARY})
endif()
, 그것은 다음과 같습니다
cmake_minimum_required(VERSION 3.7)
project(sample_project)
set(CMAKE_CXX_STANDARD 14)
set(SOURCE_FILES source/main.cpp include/csv.h include/date.h)
find_package(cppzmq)
if(cppzmq_FOUND)
include_directories(${cppzmq_INCLUDE_DIR})
target_link_libraries(sample_project ${cppzmq_LIBRARY})
endif()
find_package (Threads)
add_executable(sample_project ${SOURCE_FILES})
target_link_libraries (sample_project ${CMAKE_THREAD_LIBS_INIT})
그리고 다음과 같은 오류가 발생합니다 :
CMake Warning at /usr/local/share/cmake/cppzmq/cppzmqConfig.cmake:44 (find_package):
By not providing "FindZeroMQ.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "ZeroMQ", but
CMake did not find one.
Could not find a package configuration file provided by "ZeroMQ" with any
of the following names:
ZeroMQConfig.cmake
zeromq-config.cmake
Add the installation prefix of "ZeroMQ" to CMAKE_PREFIX_PATH or set
"ZeroMQ_DIR" to a directory containing one of the above files. If "ZeroMQ"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:7 (find_package)
CMake Error at CMakeLists.txt:10 (target_link_libraries):
Cannot specify link libraries for target "sample_project" which is not
built by this project.
-- Configuring incomplete, errors occurred!
See also "/home/greg/CLionProjects/sample_project/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/home/greg/CLionProjects/sample_project/cmake-build-debug/CMakeFiles/CMakeError.log".
[Finished]
어떻게 제대로 CMakeLists.txt
를 사용하여 추가 라이브러리를 추가 ?
문제는 cppzmq가 libzmq를 찾을 수 없다는 것입니다. 아마도 [여기] (https://github.com/zeromq/cppzmq/issues/127)의 제안 중 일부가 도움이 될 수 있습니다. – Mark