我正在制作一个程序,它基本上是几台不同机器的最大压力,我必须将测试结果写成一个have格式。
因为我不想在我决定在CMakeLists文件中使用Fetchcontent的每台机器上手动安装jsoncpp:
cmake_minimum_required(VERSION 3.15)
project(Programma)
include(FetchContent)
FetchContent_Declare(
jsoncpp
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp.git
GIT_TAG master
)
FetchContent_GetProperties(jsoncpp)
if (NOT jsoncpp_POPULATED)
FetchContent_Populate(jsoncpp)
add_subdirectory(${jsoncpp_SOURCE_DIR} ${jsoncpp_BINARY_DIR})
message(${jsoncpp_SOURCE_DIR})
message(${jsoncpp_BINARY_DIR})
endif ()
#FetchContent_MakeAvailable(jsoncpp)
set(CMAKE_CXX_STANDARD 17)
add_executable(Programma main.cpp)
add_library(TestSubjects.cpp TransformTests.cpp FoldTests.cpp
TestResults.h SortTests.cpp FindTests.cpp)
target_link_libraries(Programma Tests jsoncpp)但是我尝试了几个标题,比如<json.h>,<jsoncpp/json.h>,json/json.h>,但是没有一个能工作。我做错了什么?
发布于 2020-09-04 07:42:40
在构建过程中,项目jsoncpp没有提供jsoncpp 。相反,它为不同类型的库提供了单独的目标:
jsoncpp_static用于静态库,jsoncpp_lib用于共享库,jsoncpp_object用于对象库.默认情况下,所有3种库都是构建的,因此您可以选择任意来链接:
target_link_libraries(Programma jsoncpp_lib)另外,正确的包含指令是
#include <json/json.h>https://stackoverflow.com/questions/63721872
复制相似问题