I've looked at many different threads, but nothing seemed to work.
I'm trying to include the NLohmann JSON library using CMake. IntelliSense does autocomplete the filename sometimes, but you see a red or purple error line underneath the include and during compilation it can't find it. GTest does work though. Does someone know what's going on?
root: CMakeLists.txt
cmake_minimum_required (VERSION 3.10)
project(my_project LANGUAGES CXX VERSION 1.0.0)
enable_testing()
add_subdirectory("src")
add_subdirectory("test")
set_property(TARGET my_project PROPERTY CXX_STANDARD 20)
src: CMakeLists.txt
cmake_minimum_required (VERSION 3.10)
add_executable(my_project
...
"main.cpp"
)
set_property(TARGET my_project PROPERTY CXX_STANDARD 20)
add_subdirectory("C:/dev/libs/nlohmann_json/3.11.2" "build/nlohmann_json")
target_link_libraries(my_project PRIVATE nlohmann_json::nlohmann_json)
test: CMakeLists.txt
cmake_minimum_required (VERSION 3.10)
add_executable(my_project_test
"properties.cpp"
"main.cpp"
)
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set_property(TARGET my_project_test PROPERTY CXX_STANDARD 20)
add_subdirectory("C:/dev/libs/googletest/1.12.1" "build/google_test")
target_link_libraries(my_project_test PRIVATE gtest)