CMake不包括json-rpc-cpp,但所有路径变量均已设置并正确

时间:2018-10-25 08:19:25

标签: cmake

在我的cmake项目之一中,我正在静态链接一堆库。他们都被找到并包含好了,我测试了变量,但是当我检查生成的makefile时,与json-rpc-cpp相关的一切都被完全忽略了。我怀疑这是因为它包含3个不同的文件,例如libjsonrpccpp-common.a.dll,libjsonrpccpp-server.a.dll等。但是,无论我尝试了许多小时,cmake都只会忽略它不存在的lib,它永远不会包含在makefile中,并且永远不会给出任何错误。

有帮助吗?

cmake_minimum_required(VERSION 3.10.2)
project (myprojwrap LANGUAGES CXX VERSION 0.1)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (CMAKE_COMPILER_IS_GNUCXX)
 set(CMAKE_C_FLAGS_DEBUG "-g -ggdb -pg -fsanitize=undefined")
 set(CMAKE_C_FLAGS_RELEASE "-O2")
 set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
 set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
endif ()
set(CMAKE_BUILD_TYPE RELEASE)

set(BASE_DIR ./)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(myprojgame REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(jsonrpccpp-client REQUIRED)
find_package(jsonrpccpp-server REQUIRED)
find_package(glog REQUIRED)
find_package(gflags REQUIRED)
find_package(sqlite3 REQUIRED)
find_package(zmq REQUIRED)

include(FindProtobuf)
find_package(Protobuf REQUIRED)


get_filename_component(HEADERS src REALPATH)
include_directories(${HEADERS} ${myprojGAME_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIR} ${JSONCPP_INCLUDE_DIR} ${JSONRPCCPP_CLIENT_INCLUDE_DIR} ${JSONRPCCPP_SERVER_INCLUDE_DIR} ${GLOG_INCLUDE_DIR} ${GFLAGS_INCLUDE_DIR} ${SQLITE3_INCLUDE_DIR} ${ZEROMQ_INCLUDE_DIR})
set(SOURCE_FILES myprojwrap.cpp)


add_library(jsoncpp STATIC IMPORTED)
add_library(jsonrpccpp-client STATIC IMPORTED)
add_library(jsonrpccpp-server STATIC IMPORTED)
add_library(glog STATIC IMPORTED)
add_library(gflags STATIC IMPORTED)
add_library(sqlite3 STATIC IMPORTED)
add_library(zmq STATIC IMPORTED)
add_library(myprojgame STATIC IMPORTED)
add_library(myprojwrap SHARED ${SOURCE_FILES})


target_link_libraries(myprojwrap LINK_PUBLIC ${PROTOBUF_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${JSONCPP_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${JSONRPCCPP_CLIENT_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${JSONRPCCPP_SERVER_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${GLOG_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${GFLAGS_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${SQLITE3_LIBRARY})
target_link_libraries(myprojwrap LINK_PUBLIC ${ZMQ_LIBRARY})
target_include_directories (myprojwrap PUBLIC ${BASE_DIR})

install(TARGETS myprojwrap DESTINATION /mingw64/lib)

0 个答案:

没有答案