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

Bump timsort to 3.0.0 #22516

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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/timsort/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"3.0.0":
url: "https://github.com/timsort/cpp-TimSort/archive/v3.0.0.tar.gz"
sha256: "d61b92850996305e5248d1621c8ac437c31b474f74907e223019739e2e556b1f"
"2.1.0":
url: "https://github.com/timsort/cpp-TimSort/archive/v2.1.0.tar.gz"
sha256: "b16606f85316d9a3cfde638c02dd9ce23324b0a904bb020e4ad2497cb8cf9ebd"
Expand Down
32 changes: 29 additions & 3 deletions recipes/timsort/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.50.0"
Expand All @@ -11,14 +12,34 @@
class TimsortConan(ConanFile):
name = "timsort"
description = "A C++ implementation of timsort"
topics = ("sorting", "algorithms")
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/timsort/cpp-TimSort"
license = "MIT"
topics = ("sorting", "algorithms", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _min_cppstd(self):
if Version(self.version) < "2.0.0":
return "98"
if Version(self.version) < "3.0.0":
return "11"
return "20"

@property
def _compilers_minimum_version(self):
return {
"20": {
"gcc": "11",
"clang": "12",
"apple-clang": "14",
"Visual Studio": "16",
"msvc": "192",
}
}.get(self._min_cppstd, {})

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

Expand All @@ -28,7 +49,12 @@ def package_id(self):
def validate(self):
if self.settings.compiler.get_safe("cppstd"):
if Version(self.version) >= "2.0.0":
check_min_cppstd(self, 11)
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_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
9 changes: 8 additions & 1 deletion recipes/timsort/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ find_package(gfx-timsort REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE gfx::timsort)
Morwenn marked this conversation as resolved.
Show resolved Hide resolved
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

if(gfx-timsort_VERSION VERSION_LESS "2.0.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_98)
elseif(gfx-timsort_VERSION VERSION_LESS "3.0.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since cxx_std_20 requires 3.12, would you update cmake_minimum_required?

https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about it again maybe these lines aren't be useful: shouldn't the conan-generated targets assign the correct compile features for the standard version?

I introduced them on your suggestion to fix the previous problem, but maybe constraining the compiler versions was enough.

Copy link
Member

Choose a reason for hiding this comment

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

For Conan 2.x is all solved, the CMakeDeps, etc. will require 3.15. Plus, cppstd is defined by default there, so passing target_compile_features should no longer needed. I guess it's okay keeping the current, otherwise it would fail to build with Conan 2.x in case running an older version of cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By "the current", do you mean as it was before this MR, or the target_compile_features currently in the MR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get errors when removing target_compile_features apparently, guess I incorrectly interpreted your message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bump because it's been half a year and I'm still unsure what you meant.

endif()
2 changes: 2 additions & 0 deletions recipes/timsort/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"3.0.0":
folder: all
"2.1.0":
folder: all
"2.0.2":
Expand Down
Loading