Skip to content

Commit

Permalink
(conan-io#13120) nlohmann_json: small improvements
Browse files Browse the repository at this point in the history
* tiny improvements

* Update recipes/nlohmann_json/all/conanfile.py
  • Loading branch information
SpaceIm authored and kayoub5 committed Sep 29, 2022
1 parent 182ad8d commit df01efb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
23 changes: 15 additions & 8 deletions recipes/nlohmann_json/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.50.0"

Expand All @@ -23,17 +23,24 @@ def layout(self):
def package_id(self):
self.info.clear()

def generate(self):
pass
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def build(self):
pass

def package(self):
copy(self, "LICENSE*", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include"))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "nlohmann_json"
self.cpp_info.names["cmake_find_package_multi"] = "nlohmann_json"
self.cpp_info.names["pkg_config"] = "nlohmann_json"
self.cpp_info.set_property("cmake_file_name", "nlohmann_json")
self.cpp_info.set_property("cmake_target_name", "nlohmann_json::nlohmann_json")
self.cpp_info.set_property("pkg_config_name", "nlohmann_json")
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
8 changes: 4 additions & 4 deletions recipes/nlohmann_json/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(nlohmann_json REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} nlohmann_json::nlohmann_json)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} PRIVATE nlohmann_json::nlohmann_json)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
1 change: 1 addition & 0 deletions recipes/nlohmann_json/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)
Expand Down
8 changes: 4 additions & 4 deletions recipes/nlohmann_json/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.1.2)
project(test_package)
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(nlohmann_json REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} nlohmann_json::nlohmann_json)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} PRIVATE nlohmann_json::nlohmann_json)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

0 comments on commit df01efb

Please sign in to comment.