Merge 2648ce6516 into b27d2adcbe
This commit is contained in:
commit
ebb7d6dd1e
4
conan/.gitignore
vendored
Normal file
4
conan/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
test_package/build
|
||||
*.pyc
|
||||
conanbuildinfo.cmake
|
||||
conaninfo.txt
|
||||
7
conan/build.py
Normal file
7
conan/build.py
Normal file
@ -0,0 +1,7 @@
|
||||
from conan.packager import ConanMultiPackager
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
builder = ConanMultiPackager(username="nlohmann", channel="stable")
|
||||
builder.add_common_builds(pure_c=False)
|
||||
builder.run()
|
||||
21
conan/conanfile.py
Normal file
21
conan/conanfile.py
Normal file
@ -0,0 +1,21 @@
|
||||
from conans import ConanFile
|
||||
from conans.tools import download
|
||||
|
||||
class JsonForModernCppConan(ConanFile):
|
||||
name = "jsonformoderncpp"
|
||||
version = "2.1.1"
|
||||
license = "MIT"
|
||||
url = "https://github.com/nlohmann/json"
|
||||
author = "Niels Lohmann (mail@nlohmann.me)"
|
||||
settings = None
|
||||
options = {"path": "ANY"}
|
||||
default_options = "path="
|
||||
|
||||
def source(self):
|
||||
download("https://github.com/nlohmann/json/releases/download/v%s/json.hpp" % self.version, "json.hpp")
|
||||
|
||||
def package(self):
|
||||
header_dir = "include"
|
||||
if self.options.path != "":
|
||||
header_dir += "/" + str(self.options.path)
|
||||
self.copy("*.hpp", dst=header_dir)
|
||||
2
conan/test_package/.gitignore
vendored
Normal file
2
conan/test_package/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/
|
||||
conanfile.pyc
|
||||
9
conan/test_package/CMakeLists.txt
Normal file
9
conan/test_package/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
project(PackageTest CXX)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
add_compile_options(-std=c++11)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
add_executable(example example.cpp)
|
||||
target_link_libraries(example ${CONAN_LIBS})
|
||||
22
conan/test_package/conanfile.py
Normal file
22
conan/test_package/conanfile.py
Normal file
@ -0,0 +1,22 @@
|
||||
from conans import ConanFile, CMake
|
||||
import os
|
||||
|
||||
version = "2.1.1"
|
||||
channel = os.getenv("CONAN_CHANNEL", "stable")
|
||||
username = os.getenv("CONAN_USERNAME", "nlohmann")
|
||||
|
||||
|
||||
class JsonForModernCppTestConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
requires = "jsonformoderncpp/%s@%s/%s" % (version, username, channel)
|
||||
generators = "cmake"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self.settings)
|
||||
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is in "test_package"
|
||||
cmake.configure(self, source_dir=self.conanfile_directory, build_dir="./")
|
||||
cmake.build(self)
|
||||
|
||||
def test(self):
|
||||
os.chdir("bin")
|
||||
self.run(".%sexample" % os.sep)
|
||||
16
conan/test_package/example.cpp
Normal file
16
conan/test_package/example.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "json.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
const json myJson = {
|
||||
{ "Hello", "World" }
|
||||
};
|
||||
|
||||
for (auto it{ myJson.cbegin() }; it != myJson.cend(); ++it)
|
||||
{
|
||||
std::cout << it.key() << " " << it.value() << std::endl;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user