diff --git a/recipes/oatpp/all/conandata.yml b/recipes/oatpp/all/conandata.yml index d78e0b1d715f8..afae435ea8dae 100644 --- a/recipes/oatpp/all/conandata.yml +++ b/recipes/oatpp/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.3.0.latest": + url: "https://github.com/oatpp/oatpp/archive/1.3.0-latest.tar.gz" + sha256: "adc3b88076532838cd0fb8155872d6a9467ac0cb5df319735a2396ce6945d064" "1.3.0": url: "https://github.com/oatpp/oatpp/archive/1.3.0.tar.gz" sha256: "e1f80fa8fd7a74da6737e7fee1a4db68b4d7085a3f40e7d550752d6ff5714583" diff --git a/recipes/oatpp/all/conanfile.py b/recipes/oatpp/all/conanfile.py index cae12177c9d72..ac27a054d2bc3 100644 --- a/recipes/oatpp/all/conanfile.py +++ b/recipes/oatpp/all/conanfile.py @@ -5,6 +5,7 @@ from conan.tools.files import copy, get, rmdir from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version +from conan.tools.env import VirtualBuildEnv import os required_conan_version = ">=1.54.0" @@ -23,12 +24,21 @@ class OatppConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "with_test_library": [True, False], } default_options = { "shared": False, "fPIC": True, + "with_test_library": False, } + @property + def _version(self): + version = str(self.version) + if version.endswith(".latest"): + version = version[:-len(".latest")] + return version + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -49,6 +59,10 @@ def validate(self): if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "5": raise ConanInvalidConfiguration("oatpp requires GCC >=5") + def build_requirements(self): + if Version(self._version) >= "1.3.0": + self.tool_requires("cmake/[>=3.20 <4]") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -58,7 +72,10 @@ def generate(self): tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True if is_msvc(self) and Version(self.version) >= "1.3.0": tc.variables["OATPP_MSVC_LINK_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.variables["OATPP_LINK_TEST_LIBRARY"] = self.options.with_test_library tc.generate() + venv = VirtualBuildEnv(self) + venv.generate(scope="build") def build(self): cmake = CMake(self) @@ -74,8 +91,8 @@ def package(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "oatpp") - include_dir = os.path.join("include", f"oatpp-{self.version}", "oatpp") - lib_dir = os.path.join("lib", f"oatpp-{self.version}") + include_dir = os.path.join("include", f"oatpp-{self._version}", "oatpp") + lib_dir = os.path.join("lib", f"oatpp-{self._version}") # oatpp self.cpp_info.components["_oatpp"].names["cmake_find_package"] = "oatpp" @@ -85,18 +102,19 @@ def package_info(self): self.cpp_info.components["_oatpp"].libdirs = [lib_dir] self.cpp_info.components["_oatpp"].libs = ["oatpp"] if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["_oatpp"].system_libs = ["pthread"] + self.cpp_info.components["_oatpp"].system_libs = ["pthread", "m"] elif self.settings.os == "Windows": self.cpp_info.components["_oatpp"].system_libs = ["ws2_32", "wsock32"] # oatpp-test - self.cpp_info.components["oatpp-test"].names["cmake_find_package"] = "oatpp-test" - self.cpp_info.components["oatpp-test"].names["cmake_find_package_multi"] = "oatpp-test" - self.cpp_info.components["oatpp-test"].set_property("cmake_target_name", "oatpp-test::oatpp-test") - self.cpp_info.components["oatpp-test"].includedirs = [include_dir] - self.cpp_info.components["oatpp-test"].libdirs = [lib_dir] - self.cpp_info.components["oatpp-test"].libs = ["oatpp-test"] - self.cpp_info.components["oatpp-test"].requires = ["_oatpp"] + if self.options.with_test_library: + self.cpp_info.components["oatpp-test"].names["cmake_find_package"] = "oatpp-test" + self.cpp_info.components["oatpp-test"].names["cmake_find_package_multi"] = "oatpp-test" + self.cpp_info.components["oatpp-test"].set_property("cmake_target_name", "oatpp-test::oatpp-test") + self.cpp_info.components["oatpp-test"].includedirs = [include_dir] + self.cpp_info.components["oatpp-test"].libdirs = [lib_dir] + self.cpp_info.components["oatpp-test"].libs = ["oatpp-test"] + self.cpp_info.components["oatpp-test"].requires = ["_oatpp"] # workaround to have all components in the global target self.cpp_info.set_property("cmake_target_name", "oatpp::oatpp-test") diff --git a/recipes/oatpp/all/test_package/CMakeLists.txt b/recipes/oatpp/all/test_package/CMakeLists.txt index cffae2f965d2e..9c8af92835a8c 100644 --- a/recipes/oatpp/all/test_package/CMakeLists.txt +++ b/recipes/oatpp/all/test_package/CMakeLists.txt @@ -3,12 +3,6 @@ project(test_package LANGUAGES CXX) find_package(oatpp REQUIRED CONFIG) -if ("${oatpp_VERSION}" VERSION_GREATER_EQUAL "1.3.0") - add_executable(${PROJECT_NAME} test_package.cpp DeserializerTest_1_3_0.cpp) -elseif("${oatpp_VERSION}" VERSION_GREATER_EQUAL "1.1.0") - add_executable(${PROJECT_NAME} test_package.cpp DeserializerTest_1_1_0.cpp) -else() - add_executable(${PROJECT_NAME} test_package.cpp DeserializerTest_1_0_0.cpp) -endif() -target_link_libraries(${PROJECT_NAME} PRIVATE oatpp::oatpp oatpp::oatpp-test) +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE oatpp::oatpp) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/oatpp/all/test_package/DeserializerTest.hpp b/recipes/oatpp/all/test_package/DeserializerTest.hpp deleted file mode 100644 index 6c1c0ec06209e..0000000000000 --- a/recipes/oatpp/all/test_package/DeserializerTest.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef oatpp_test_parser_json_mapping_DeserializerTest_hpp -#define oatpp_test_parser_json_mapping_DeserializerTest_hpp - -#include "oatpp-test/UnitTest.hpp" - -namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping { - -class DeserializerTest : public UnitTest{ -public: - - DeserializerTest():UnitTest("TEST[parser::json::mapping::DeserializerTest]"){} - void onRun() override; - -}; - -}}}}} - -#endif /* oatpp_test_parser_json_mapping_DeserializerTest_hpp */ diff --git a/recipes/oatpp/all/test_package/DeserializerTest_1_0_0.cpp b/recipes/oatpp/all/test_package/DeserializerTest_1_0_0.cpp deleted file mode 100644 index e4cd44ea34920..0000000000000 --- a/recipes/oatpp/all/test_package/DeserializerTest_1_0_0.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "DeserializerTest.hpp" - -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" -#include "oatpp/core/macro/codegen.hpp" - -namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping { - -namespace { - -#include OATPP_CODEGEN_BEGIN(DTO) - -typedef oatpp::data::mapping::type::Object DTO; - -class EmptyDto : public DTO { - - DTO_INIT(EmptyDto, DTO) - -}; - -class SampleDto : public DTO { - - DTO_INIT(SampleDto, DTO); - - DTO_FIELD(String, strF); - DTO_FIELD(Int32, int32F); - DTO_FIELD(Float32, float32F); - DTO_FIELD(EmptyDto::ObjectWrapper, object); - DTO_FIELD(List::ObjectWrapper, list); - -}; - -#include OATPP_CODEGEN_END(DTO) - -} - -void DeserializerTest::onRun(){ - - auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared(); - - auto obj = mapper->readFromString("{ \"strF\": \"value1\", \"int32F\": 30, \"float32F\": 32.4, \"object\": {}\"list\": [] }"); - - OATPP_ASSERT(obj); - OATPP_ASSERT(obj->strF->equals("value1")); - OATPP_ASSERT(obj->int32F->getValue() == 30); - OATPP_ASSERT(obj->float32F); - OATPP_ASSERT(obj->object); - OATPP_ASSERT(obj->list->count() == 0); - -} - -}}}}} diff --git a/recipes/oatpp/all/test_package/DeserializerTest_1_1_0.cpp b/recipes/oatpp/all/test_package/DeserializerTest_1_1_0.cpp deleted file mode 100644 index 93aedbe56f4c3..0000000000000 --- a/recipes/oatpp/all/test_package/DeserializerTest_1_1_0.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "DeserializerTest.hpp" - -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" -#include "oatpp/core/macro/codegen.hpp" - -namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping { - -namespace { - -#include OATPP_CODEGEN_BEGIN(DTO) - -class EmptyDto : public oatpp::DTO { - - DTO_INIT(EmptyDto, DTO) - -}; - -class SampleDto : public DTO { - - DTO_INIT(SampleDto, DTO); - - DTO_FIELD(String, strF); - DTO_FIELD(Int32, int32F); - DTO_FIELD(Float32, float32F); - DTO_FIELD(Object, object); - DTO_FIELD(List>, list); - -}; - -#include OATPP_CODEGEN_END(DTO) - -} - -void DeserializerTest::onRun(){ - - auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared(); - - auto obj = mapper->readFromString>("{ \"strF\": \"value1\", \"int32F\": 30, \"float32F\": 32.4, \"object\": {}\"list\": [] }"); - - OATPP_ASSERT(obj); - OATPP_ASSERT(obj->strF->equals("value1")); - OATPP_ASSERT(obj->int32F == 30); - OATPP_ASSERT(obj->float32F); - OATPP_ASSERT(obj->object); - OATPP_ASSERT(obj->list->size() == 0); - -} - -}}}}} diff --git a/recipes/oatpp/all/test_package/DeserializerTest_1_3_0.cpp b/recipes/oatpp/all/test_package/DeserializerTest_1_3_0.cpp deleted file mode 100644 index 331bb2d27749f..0000000000000 --- a/recipes/oatpp/all/test_package/DeserializerTest_1_3_0.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "DeserializerTest.hpp" - -#include "oatpp/parser/json/mapping/ObjectMapper.hpp" -#include "oatpp/core/macro/codegen.hpp" - -namespace oatpp { namespace test { namespace parser { namespace json { namespace mapping { - -namespace { - -#include OATPP_CODEGEN_BEGIN(DTO) - -class EmptyDto : public oatpp::DTO { - - DTO_INIT(EmptyDto, DTO) - -}; - -class SampleDto : public DTO { - - DTO_INIT(SampleDto, DTO); - - DTO_FIELD(String, strF); - DTO_FIELD(Int32, int32F); - DTO_FIELD(Float32, float32F); - DTO_FIELD(Object, object); - DTO_FIELD(List>, list); - -}; - -#include OATPP_CODEGEN_END(DTO) - -} - -void DeserializerTest::onRun(){ - - auto mapper = oatpp::parser::json::mapping::ObjectMapper::createShared(); - - auto obj = mapper->readFromString>("{ \"strF\": \"value1\", \"int32F\": 30, \"float32F\": 32.4, \"object\": {}\"list\": [] }"); - - OATPP_ASSERT(obj); - OATPP_ASSERT(*(obj->strF) == "value1"); - OATPP_ASSERT(obj->int32F == 30); - OATPP_ASSERT(obj->float32F); - OATPP_ASSERT(obj->object); - OATPP_ASSERT(obj->list->size() == 0); - -} - -}}}}} diff --git a/recipes/oatpp/all/test_package/test_package.cpp b/recipes/oatpp/all/test_package/test_package.cpp index b0d824cdfda32..c3c071f43b8a4 100644 --- a/recipes/oatpp/all/test_package/test_package.cpp +++ b/recipes/oatpp/all/test_package/test_package.cpp @@ -1,31 +1,20 @@ -#include "DeserializerTest.hpp" +#include #include "oatpp/core/concurrency/SpinLock.hpp" #include "oatpp/core/base/Environment.hpp" -#include -#include - - -void runTests() { - OATPP_RUN_TEST(oatpp::test::parser::json::mapping::DeserializerTest); -} - int main() { oatpp::base::Environment::init(); - - runTests(); - + /* Print how much objects were created during app running, and what have left-probably leaked */ /* Disable object counting for release builds using '-D OATPP_DISABLE_ENV_OBJECT_COUNTERS' flag for better performance */ std::cout << "\nEnvironment:\n"; std::cout << "objectsCount = " << oatpp::base::Environment::getObjectsCount() << "\n"; std::cout << "objectsCreated = " << oatpp::base::Environment::getObjectsCreated() << "\n\n"; - + OATPP_ASSERT(oatpp::base::Environment::getObjectsCount() == 0); - - oatpp::base::Environment::destroy(); + oatpp::base::Environment::destroy(); return 0; } diff --git a/recipes/oatpp/config.yml b/recipes/oatpp/config.yml index 4fdf83fae05c2..64022fc52f7b5 100644 --- a/recipes/oatpp/config.yml +++ b/recipes/oatpp/config.yml @@ -1,4 +1,6 @@ versions: + "1.3.0.latest": + folder: all "1.3.0": folder: all "1.2.5":