-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#23286) libassert: refactor recipe into v1 and v2 folders
* Split recipe into v1 and v2 folders * Add libm * Update recipes/libassert/v2/conanfile.py Co-authored-by: Jordan Williams <[email protected]> * Guard libm on v1 recipe --------- Co-authored-by: Jordan Williams <[email protected]>
- Loading branch information
1 parent
976b1cd
commit d4f3987
Showing
25 changed files
with
273 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
versions: | ||
# Newer versions at the top | ||
"2.0.0": | ||
folder: all | ||
folder: v2 | ||
"1.2.2": | ||
folder: all | ||
folder: v1 | ||
"1.2.1": | ||
folder: all | ||
folder: v1 | ||
"1.1": | ||
folder: all | ||
folder: v1 | ||
"1.0": | ||
folder: all | ||
folder: v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(test_package CXX) | ||
|
||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
|
||
find_package(assert REQUIRED CONFIG) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE assert::assert) | ||
|
||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <cstdlib> | ||
#include <iostream> | ||
#include <assert/assert.hpp> | ||
|
||
int main(void) { | ||
std::cout << "Testing libassert\n"; | ||
|
||
try{ | ||
VERIFY(1 != 1); | ||
} | ||
catch (...){ | ||
return EXIT_SUCCESS; | ||
} | ||
|
||
return EXIT_FAILURE; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
sources: | ||
# Newer versions at the top | ||
"2.0.0": | ||
url: | ||
- "https://github.com/jeremy-rifkin/libassert/archive/refs/tags/v2.0.0.tar.gz" | ||
sha256: "d4b2da2179a94637b34d18813a814531a1eceb0ddc6dd6db6098050dd638f4a1" | ||
|
||
patches: | ||
"2.0.0": | ||
- patch_file: "patches/2.0.0/0001-fix-export-and-include.patch" | ||
patch_type: "bugfix" | ||
patch_source: https://github.com/jeremy-rifkin/libassert/commit/25c1f3e43737ab18490a0d9430cb1c70f976a662 | ||
patch_description: "Fix export header and an incorrect #include" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.microsoft import check_min_vs, is_msvc_static_runtime, is_msvc | ||
from conan.tools.apple import is_apple_os | ||
from conan.tools.files import get, copy, rm, rmdir | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.scm import Version | ||
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout | ||
from conan.tools.files import apply_conandata_patches, export_conandata_patches | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class LibassertConan(ConanFile): | ||
name = "libassert" | ||
description = "The most over-engineered C++ assertion library" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/jeremy-rifkin/libassert" | ||
package_type = "library" | ||
|
||
topics = ("assert", "library", "assertions", "stacktrace", "diagnostics", "defensive programming", "testing") | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "8", | ||
"clang": "9" | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("cpptrace/0.5.1", transitive_headers=True, transitive_libs=True) | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
check_min_vs(self, 192) | ||
if not is_msvc(self): | ||
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) | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
|
||
if is_msvc(self): | ||
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) | ||
|
||
tc.variables["LIBASSERT_USE_EXTERNAL_CPPTRACE"] = True | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
tc.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
|
||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
if self.settings.os == "Windows" and self.options.shared: | ||
copy( | ||
self, | ||
"*.dll", | ||
src=self.build_folder, | ||
dst=os.path.join(self.package_folder, "bin"), | ||
keep_path=False | ||
) | ||
|
||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
rm(self, "*.la", os.path.join(self.package_folder, "lib")) | ||
rm(self, "*.pdb", os.path.join(self.package_folder, "lib")) | ||
rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["assert"] | ||
|
||
self.cpp_info.set_property("cmake_file_name", "libassert") | ||
self.cpp_info.set_property("cmake_target_name", "libassert::assert") | ||
|
||
# the first version of this library used assert/assert as include folder | ||
# appending this one but not removing the default to not break consumers | ||
self.cpp_info.includedirs.append(os.path.join("include", "libassert")) | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.filenames["cmake_find_package"] = "libassert" | ||
self.cpp_info.filenames["cmake_find_package_multi"] = "libassert" | ||
self.cpp_info.names["cmake_find_package"] = "libassert" | ||
self.cpp_info.names["cmake_find_package_multi"] = "libassert" | ||
|
||
self.cpp_info.components["assert"].names["cmake_find_package"] = "assert" | ||
self.cpp_info.components["assert"].names["cmake_find_package_multi"] = "assert" | ||
self.cpp_info.components["assert"].requires = ["cpptrace::cpptrace"] | ||
self.cpp_info.components["assert"].libs = ["assert"] | ||
if not self.options.shared: | ||
self.cpp_info.components["assert"].defines.append("LIBASSERT_STATIC_DEFINE") | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("m") | ||
self.cpp_info.requires = ["cpptrace::cpptrace"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(test_package CXX) | ||
|
||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
|
||
find_package(libassert REQUIRED CONFIG) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE libassert::assert) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) |
Oops, something went wrong.