-
Notifications
You must be signed in to change notification settings - Fork 21
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
Update repository for conan2 #365
Changes from all commits
a465650
951a9d8
486b714
975b96b
930d7f4
52743c0
4e0add7
2d84853
440a33b
45df900
f8c2727
ea0c649
90c9cea
a6526f5
88ea906
34c18a7
ea62959
da351da
3e20cdd
a773327
1560cfc
83c90c1
f383b23
2dff1b2
0b19d02
ca215b7
3aff96b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,128 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
from conan.tools.files import copy, get, rmdir | ||
from conan.tools.microsoft import is_msvc | ||
from conan.tools.scm import Version | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class PROPOSALConan(ConanFile): | ||
name = "proposal" | ||
homepage = "https://github.com/tudo-astroparticlephysics/PROPOSAL" | ||
license = "GNU Lesser General Public License v3.0" | ||
description = "the very best lepton and photon propagator" | ||
license = "LGPL-3.0" | ||
package_type = "library" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
description = "monte Carlo based lepton and photon propagator" | ||
topics = ("propagator", "lepton", "photon", "stochastic") | ||
|
||
settings = "os", "compiler", "build_type", "arch" | ||
exports_sources = "*" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_testing": [True, False], | ||
"with_python": [True, False], | ||
"with_testing": [True, False], | ||
"with_documentation": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_python" : False, | ||
"with_testing": False, | ||
"with_python": False, | ||
"with_documentation": False, | ||
} | ||
generators = "cmake_find_package", "cmake_paths" | ||
_cmake = None | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return "14" | ||
|
||
@property | ||
def _minimum_compilers_version(self): | ||
return { | ||
"Visual Studio": "15", | ||
"msvc": "191", | ||
"gcc": "5", | ||
"clang": "5", | ||
"apple-clang": "5", | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
self.options.rm_safe("fPIC") | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
self.folders.generators = "build" | ||
|
||
def requirements(self): | ||
self.requires("cubicinterpolation/0.1.5") | ||
self.requires("spdlog/1.10.0") | ||
self.requires("nlohmann_json/3.9.1") | ||
# cubicinterpolation: headers are transitively included, and function calls are made | ||
# from implementation in headers (templates) | ||
self.requires("cubicinterpolation/0.1.5", transitive_headers=True, transitive_libs=True) | ||
# spdlog: requires transitive_libs due to direct calls to functionality from headers | ||
self.requires("spdlog/1.11.0", transitive_headers=True, transitive_libs=True) | ||
# nlohmann_json: public headers include json.hpp and json_fwd.hpp | ||
self.requires("nlohmann_json/3.11.2", transitive_headers=True) | ||
if self.options.with_python: | ||
self.requires("pybind11/2.10.1") | ||
if self.options.with_testing: | ||
self.requires("boost/1.78.0") | ||
self.requires("boost/1.75.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the downgrading from 1.78 to 1.75 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self.requires("gtest/1.11.0") | ||
if self.options.with_documentation: | ||
self.requires("doxygen/1.8.20") | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.definitions["BUILD_TESTING"] = self.options.with_testing | ||
self._cmake.definitions["BUILD_PYTHON"] = self.options.with_python | ||
self._cmake.definitions["BUILD_DOCUMENTATION"] = self.options.with_documentation | ||
self._cmake.configure() | ||
return self._cmake | ||
|
||
def validate(self): | ||
if is_msvc(self) and self.options.shared: | ||
raise ConanInvalidConfiguration( | ||
"Can not build shared library on Visual Studio." | ||
) | ||
if self.settings.compiler.get_safe("cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
minimum_version = self._minimum_compilers_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 build(self): | ||
cmake = self._configure_cmake() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
cmake.install() | ||
if self.options.with_testing: | ||
cmake.test() | ||
|
||
def package(self): | ||
self.copy("LICENSE", dst="licenses") | ||
cmake = self._configure_cmake() | ||
copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
cmake = CMake(self) | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.variables["BUILD_TESTING"] = self.options.with_testing | ||
tc.variables["BUILD_PYTHON"] = self.options.with_python | ||
tc.variables["BUILD_DOCUMENTATION"] = self.options.with_documentation | ||
tc.variables["CMAKE_BUILD_TYPE"] = "Release" # set as default | ||
tc.generate() | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
def package_info(self): | ||
self.cpp_info.names["cmake_find_package"] = "PROPOSAL" | ||
self.cpp_info.set_property("cmake_file_name", "PROPOSAL") | ||
self.cpp_info.set_property("cmake_target_name", "PROPOSAL::PROPOSAL") | ||
self.cpp_info.libs = ["PROPOSAL"] | ||
self.cpp_info.requires = [ | ||
"cubicinterpolation::CubicInterpolation", | ||
"spdlog::spdlog", | ||
"nlohmann_json::nlohmann_json", | ||
] | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.names["cmake_find_package"] = "PROPOSAL" | ||
self.cpp_info.names["cmake_find_package_multi"] = "PROPOSAL" |
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.
Just to be sure: this conanfile is still compatible with conan 1?
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.
Yes. At the moment, the conanfile is written in such a way that it is backwards-compatible with conan 1.x.