Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oatpp: add version 1.3.0-latest #23696

Merged
merged 9 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions recipes/oatpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
38 changes: 28 additions & 10 deletions recipes/oatpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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)

Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also probably want to set OATPP_LINK_TEST_LIBRARY to false in the CMakeToolchain here

Copy link
Contributor Author

@toge toge Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RubenRBS
Thanks a lot!
I add with_test_library option and use it's value for OATPP_LINK_TEST_LIBRARY.

venv.generate(scope="build")

def build(self):
cmake = CMake(self)
Expand All @@ -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"
Expand All @@ -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")
10 changes: 2 additions & 8 deletions recipes/oatpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 0 additions & 18 deletions recipes/oatpp/all/test_package/DeserializerTest.hpp

This file was deleted.

51 changes: 0 additions & 51 deletions recipes/oatpp/all/test_package/DeserializerTest_1_0_0.cpp

This file was deleted.

49 changes: 0 additions & 49 deletions recipes/oatpp/all/test_package/DeserializerTest_1_1_0.cpp

This file was deleted.

49 changes: 0 additions & 49 deletions recipes/oatpp/all/test_package/DeserializerTest_1_3_0.cpp

This file was deleted.

19 changes: 4 additions & 15 deletions recipes/oatpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
#include "DeserializerTest.hpp"
#include <iostream>

#include "oatpp/core/concurrency/SpinLock.hpp"
#include "oatpp/core/base/Environment.hpp"

#include <iostream>
#include <atomic>


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;
}
2 changes: 2 additions & 0 deletions recipes/oatpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.3.0.latest":
folder: all
"1.3.0":
folder: all
"1.2.5":
Expand Down