-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add au recipe #25447
Open
ericriff
wants to merge
6
commits into
conan-io:master
Choose a base branch
from
ericriff:eriff/au
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−0
Open
Add au recipe #25447
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f6c1381
Add au recipe
ericriff 9a74d91
Require CMake 3.24+
ericriff 88371b0
Clean package id, this is headers only
ericriff da4243d
Remove self.cpp_info.libs
ericriff 0c92661
This package requires C++14
ericriff 3bc2095
Fix typo
ericriff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,9 @@ | ||
sources: | ||
"0.3.5": | ||
url: "https://github.com/aurora-opensource/au/archive/refs/tags/0.3.5.tar.gz" | ||
sha256: "7ec826dc42968dc1633de56e4f9d06e70de73e820d2ac4788e8453343a622c9b" | ||
patches: | ||
"0.3.5": | ||
- patch_file: "patches/0001-v0.3.5-disable-gtest.patch" | ||
patch_description: "Remove GTest dependency and disable tests build" | ||
patch_type: "conan" |
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,86 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout | ||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class PackageConan(ConanFile): | ||
name = "au" | ||
description = "A C++14-compatible physical units library" | ||
license = "Apache-2.0" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/aurora-opensource/au" | ||
topics = ("units", "C++14") | ||
package_type = "header-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 14 | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"apple-clang": "10", | ||
"clang": "7", | ||
"gcc": "7", | ||
"msvc": "191", | ||
"Visual Studio": "15", | ||
} | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
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) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["package_lib"] | ||
|
||
self.cpp_info.set_property("cmake_file_name", "Au") | ||
self.cpp_info.set_property("cmake_target_name", "Au::au") | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("m") | ||
self.cpp_info.system_libs.append("pthread") | ||
self.cpp_info.system_libs.append("dl") | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.filenames["cmake_find_package"] = "Au" | ||
self.cpp_info.filenames["cmake_find_package_multi"] = "Au" | ||
self.cpp_info.names["cmake_find_package"] = "Au::au" | ||
self.cpp_info.names["cmake_find_package_multi"] = "Au::au" |
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,58 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index b18407f..dbd35af 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -37,23 +37,23 @@ set(AU_EXPORT_SET_NAME AuHeaders) | ||
|
||
enable_testing() | ||
|
||
-# Bring in GoogleTest so we can build and run the tests. | ||
-include(FetchContent) | ||
-FetchContent_Declare( | ||
- googletest | ||
- GIT_REPOSITORY https://github.com/google/googletest.git | ||
- GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # Release 1.12.1 | ||
- FIND_PACKAGE_ARGS | ||
- 1.12.1 | ||
- NAMES GTest | ||
-) | ||
- | ||
-# https://google.github.io/googletest/quickstart-cmake.html | ||
-# For Windows: Prevent overriding the parent project's compiler/linker settings | ||
-set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
- | ||
-FetchContent_MakeAvailable(googletest) | ||
-include(GoogleTest) | ||
+## Bring in GoogleTest so we can build and run the tests. | ||
+#include(FetchContent) | ||
+#FetchContent_Declare( | ||
+# googletest | ||
+# GIT_REPOSITORY https://github.com/google/googletest.git | ||
+# GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # Release 1.12.1 | ||
+# FIND_PACKAGE_ARGS | ||
+# 1.12.1 | ||
+# NAMES GTest | ||
+#) | ||
+# | ||
+## https://google.github.io/googletest/quickstart-cmake.html | ||
+## For Windows: Prevent overriding the parent project's compiler/linker settings | ||
+#set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
+# | ||
+#FetchContent_MakeAvailable(googletest) | ||
+#include(GoogleTest) | ||
|
||
add_subdirectory(au) | ||
|
||
diff --git a/cmake/HeaderOnlyLibrary.cmake b/cmake/HeaderOnlyLibrary.cmake | ||
index 28daf00..fbf0fab 100644 | ||
--- a/cmake/HeaderOnlyLibrary.cmake | ||
+++ b/cmake/HeaderOnlyLibrary.cmake | ||
@@ -75,7 +75,7 @@ function(header_only_library) | ||
) | ||
|
||
# Add the test, if requested. | ||
- if (DEFINED ARG_GTEST_SRCS) | ||
+ if (OFF) | ||
add_executable("${ARG_NAME}_test") | ||
target_sources("${ARG_NAME}_test" PRIVATE ${ARG_GTEST_SRCS}) | ||
target_link_libraries( |
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,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(Au REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE Au::au) |
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,27 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
# It will become the standard on Conan 2.x | ||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
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,15 @@ | ||
#include <iostream> | ||
|
||
#include "au/au.hh" | ||
#include "au/io.hh" | ||
#include "au/units/meters.hh" | ||
|
||
using namespace au; | ||
|
||
int main(void) { | ||
constexpr auto lenght = meters(100.0); | ||
ericriff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
std::cout << lenght << " == " << lenght.in(kilo(meters)) <<" km" << std::endl; | ||
|
||
return EXIT_SUCCESS; | ||
} |
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,3 @@ | ||
versions: | ||
"0.3.5": | ||
folder: all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proposed a solution upstram, but their CMake is a bit odd so some feedback there is welcome ;)
aurora-opensource/au#297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for posting it to the upstream first!