-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conanfile, build and test_package
- Loading branch information
Vincent Thiery
committed
Jun 14, 2017
1 parent
fd4a0ec
commit b6b1c44
Showing
7 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test_package/build | ||
*.pyc | ||
conanbuildinfo.cmake | ||
conaninfo.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from conans import ConanFile | ||
from conans.tools import download | ||
|
||
class StatsdClient(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build/ | ||
conanfile.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 RxcppTestConan(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |