Skip to content

Commit

Permalink
(#20369) pipes: move checks to validate() instead of configure()
Browse files Browse the repository at this point in the history
…and add msvc min version

* move checks to validate() and add msvc to min compiler version

* small improvement to test package

* Include optional to fix compilation error

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Include optional when supported

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Remove verbose cmake

Signed-off-by: Uilian Ries <uilianries@gmail.com>

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Co-authored-by: Abril Rincón Blanco <git@rinconblanco.es>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent d28f623 commit a9f61a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
28 changes: 13 additions & 15 deletions recipes/pipes/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from conan.tools.layout import basic_layout
from conan.tools.scm import Version

required_conan_version = ">=1.52.0"
required_conan_version = ">=1.50.0"


class PipesConan(ConanFile):
Expand All @@ -23,37 +23,35 @@ class PipesConan(ConanFile):
no_copy_source = True

@property
def _minimum_cpp_standard(self):
def _min_cppstd(self):
return 14

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "15",
"msvc": "191",
"gcc": "5",
"clang": "3.4",
"apple-clang": "5.1",
}

def configure(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if not min_version:
self.output.warning(f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support.")
else:
if Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
f"{self.name} requires C++{self._minimum_cpp_standard} support. The current compiler"
f" {self.settings.compiler} {self.settings.compiler.version} does not support it."
)

def layout(self):
basic_layout(self, src_folder="src")

def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if min_version and Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

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

Expand Down
6 changes: 3 additions & 3 deletions recipes/pipes/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 CXX)
project(test_package LANGUAGES CXX)

find_package(pipes REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} pipes::pipes)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
target_link_libraries(${PROJECT_NAME} PRIVATE pipes::pipes)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
12 changes: 7 additions & 5 deletions recipes/pipes/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// Workaround for pipes not finding size_t
#include <cstddef>
#include <cstdlib>
#include <vector>
// FIXME: https://github.com/joboccara/pipes/pull/73
#if __cplusplus >= 201703L
#include <optional>
#endif

#include <pipes/pipes.hpp>

#include <vector>

int main() {
auto source = std::vector<int>{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Expand All @@ -13,8 +18,5 @@ int main() {
>>= pipes::transform([](int i){ return i * 2; })
>>= pipes::push_back(destination);

auto expected = std::vector<int>{0, 4, 8, 12, 16};
bool success = destination == expected;

return success ? 0 : 1;
return EXIT_SUCCESS;
}

0 comments on commit a9f61a0

Please sign in to comment.