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

add proposal/7.5.1 and update recipe for conan2 #16851

Merged
merged 17 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
75 changes: 39 additions & 36 deletions recipes/proposal/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
sources:
"7.0.2":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.2.tar.gz"
sha256: "8166ffca150abce77cc4254343bb89d3476e17910e96fa4936b87dafcc72d592"
"7.0.4":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.4.tar.gz"
sha256: "1442b9f5d8824e7794e97a2eca3f5f109e33c423a37714ada9ad98435b4d4b01"
"7.0.5":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.5.tar.gz"
sha256: "232f84e410f439e6bc1b721fc65280906e9f6ad5b39490561870d42a1ee1af17"
"7.0.7":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.7.tar.gz"
sha256: "e366e9280fbe99e68bc5b31a74f51610e27ca8a646dff28e883573893572ab75"
"7.1.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.1.0.tar.gz"
sha256: "98faba7cd9d743dae2a8bec70b1c4a382339b9fa40b71fda2936c9d7054d7a85"
"7.1.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.1.1.tar.gz"
sha256: "090e885d6f241b87a98234571cc1bd2ff935933365717e327602ea37f4d3548a"
"7.2.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.2.1.tar.gz"
sha256: "279c1b897c8ae426a493ca77e01c8cfd47e8cd313f3e35ed3ddf098dcccdeeda"
"7.3.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.3.0.tar.gz"
sha256: "fa3763fee656164e5f3a7d6a11f08771dd70700adb93de9db4625ad981e0defb"
"7.3.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.3.1.tar.gz"
sha256: "260426f71226c888832a6da47c55c05dab31b8240dbbc67b4b2466af24d962d3"
"7.4.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.4.0.tar.gz"
sha256: "34865a84052c670fbc4554361acef716655906f65f5bba88e3fd73dff92989de"
"7.4.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.4.1.tar.gz"
sha256: "e6ff9749f402dd77f320a2a28b77a45636cbe186f926d9b5a7b54ea6ee631ada"
"7.4.2":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.4.2.tar.gz"
sha256: "f0db44c96a80a6ce3dda02c598574f5f0209376bd2c6c176797710da8eb3e108"
"7.5.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.5.1.tar.gz"
sha256: "2a283bfc335c4b6b01d2acc1eea1a5e4c456bd3dd11e41ef24ca3d955c9655a3"
"7.5.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.5.0.tar.gz"
sha256: "ba31bd0a2337f3717a1ad88a3b3f7fefa3f1e4dae4fc922e72144cfecffe5e94"
"7.4.2":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.4.2.tar.gz"
sha256: "f0db44c96a80a6ce3dda02c598574f5f0209376bd2c6c176797710da8eb3e108"
"7.4.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.4.1.tar.gz"
sha256: "e6ff9749f402dd77f320a2a28b77a45636cbe186f926d9b5a7b54ea6ee631ada"
"7.4.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.4.0.tar.gz"
sha256: "34865a84052c670fbc4554361acef716655906f65f5bba88e3fd73dff92989de"
"7.3.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.3.1.tar.gz"
sha256: "260426f71226c888832a6da47c55c05dab31b8240dbbc67b4b2466af24d962d3"
"7.3.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.3.0.tar.gz"
sha256: "fa3763fee656164e5f3a7d6a11f08771dd70700adb93de9db4625ad981e0defb"
"7.2.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.2.1.tar.gz"
sha256: "279c1b897c8ae426a493ca77e01c8cfd47e8cd313f3e35ed3ddf098dcccdeeda"
"7.1.1":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.1.1.tar.gz"
sha256: "090e885d6f241b87a98234571cc1bd2ff935933365717e327602ea37f4d3548a"
"7.1.0":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.1.0.tar.gz"
sha256: "98faba7cd9d743dae2a8bec70b1c4a382339b9fa40b71fda2936c9d7054d7a85"
"7.0.7":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.7.tar.gz"
sha256: "e366e9280fbe99e68bc5b31a74f51610e27ca8a646dff28e883573893572ab75"
"7.0.5":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.5.tar.gz"
sha256: "232f84e410f439e6bc1b721fc65280906e9f6ad5b39490561870d42a1ee1af17"
"7.0.4":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.4.tar.gz"
sha256: "1442b9f5d8824e7794e97a2eca3f5f109e33c423a37714ada9ad98435b4d4b01"
"7.0.2":
url: "https://github.com/tudo-astroparticlephysics/PROPOSAL/archive/refs/tags/7.0.2.tar.gz"
sha256: "8166ffca150abce77cc4254343bb89d3476e17910e96fa4936b87dafcc72d592"
44 changes: 22 additions & 22 deletions recipes/proposal/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import get, rmdir, copy
from conan.tools.cmake import CMake, CMakeToolchain
from conan.errors import ConanInvalidConfiguration
from conan.tools.scm import Version

required_conan_version = ">=1.43.0"

Expand All @@ -26,8 +30,7 @@ class PROPOSALConan(ConanFile):
"with_python": False,
}

generators = "cmake", "cmake_find_package"
_cmake = None
generators = "CMakeDeps"

@property
def _source_subfolder(self):
Expand Down Expand Up @@ -62,7 +65,7 @@ def validate(self):
"Can not build shared library on Visual Studio."
)
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, "14")
check_min_cppstd(self, "14")

minimum_version = self._minimum_compilers_version.get(
str(self.settings.compiler), False
Expand All @@ -71,34 +74,31 @@ def validate(self):
self.output.warn(
"PROPOSAL requires C++14. Your compiler is unknown. Assuming it supports C++14."
)
elif tools.Version(self.settings.compiler.version) < minimum_version:
elif Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
"PROPOSAL requires gcc >= 5, clang >= 5 or Visual Studio >= 15 as a compiler!"
)

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

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BUILD_TESTING"] = False
self._cmake.definitions["BUILD_PYTHON"] = self.options.with_python
self._cmake.definitions["BUILD_DOCUMENTATION"] = False
self._cmake.configure()
return self._cmake
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()

def package(self):
self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder)
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.cache_variables["BUILD_TESTING"] = False
tc.cache_variables["BUILD_PYTHON"] = self.options.with_python
tc.cache_variables["BUILD_DOCUMENTATION"] = False
tc.generate()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "PROPOSAL")
Expand Down
3 changes: 0 additions & 3 deletions recipes/proposal/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(PROPOSAL REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
Expand Down
20 changes: 14 additions & 6 deletions recipes/proposal/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from conans import ConanFile, CMake, tools
import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
requires = "spdlog/1.9.2" # TODO: not sure why this is explicitly necessary, but it fails without it
Copy link
Contributor

Choose a reason for hiding this comment

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

Conan 2.0 changes the graph model and deps are private by default to encourage good software practices.

you need to add a transitive_header=True with a link to the reason why it's need (ie a comment from the bot failing is perfect or a link to the source code)

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 am honestly note sure why I would need to put transitive_headers=True for spdlog, but not for any other libraries.
If I don't (and do not explicitly write requires = "spdlog/1.9.2" in the conanfile of the test_package), I get the error

/usr/local/include/spdlog/fmt/fmt.h:27:14: fatal error: fmt/core.h: No such file or directory
   27 | #    include <fmt/core.h>

which sounds related to the experience in #11981 and #15832...

I could do this, and this does fix the issue, but I would like to understand why this is necessary 😅


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 not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 11 additions & 0 deletions recipes/proposal/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(PROPOSAL REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PROPOSAL::PROPOSAL)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
17 changes: 17 additions & 0 deletions recipes/proposal/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
21 changes: 21 additions & 0 deletions recipes/proposal/all/test_v1_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "PROPOSAL/PROPOSAL.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This file can be delete with the improved CMakeLists.txt template :)

#include <iostream>
#include <memory>

int main()
{
auto particle = PROPOSAL::MuMinusDef();
auto target = PROPOSAL::Ice();
auto cut = std::make_shared<PROPOSAL::EnergyCutSettings>(500, 0.05, false);
auto cross = PROPOSAL::GetStdCrossSections(particle, target, cut, false);

auto energy = 1e4;
for (auto c : cross) {
auto type = c->GetInteractionType();
auto name = PROPOSAL::Type_Interaction_Name_Map.at(type);
auto dEdx = c->CalculatedEdx(energy);
std::cout << "The " << name << " average loss for a " << energy << " MeV "
<< particle.name << " in " << target.GetName()
<< " is: " << dEdx << " MeV * cm^2 / g" << std::endl;
}
}
26 changes: 14 additions & 12 deletions recipes/proposal/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
versions:
"7.0.2":
"7.5.1":
folder: all
"7.0.4":
"7.5.0":
folder: all
"7.0.5":
"7.4.2":
folder: all
"7.0.7":
"7.4.1":
folder: all
"7.1.0":
"7.4.0":
folder: all
"7.1.1":
"7.3.1":
folder: all
"7.3.0":
folder: all
"7.2.1":
folder: all
"7.3.0":
"7.1.1":
folder: all
"7.3.1":
"7.1.0":
folder: all
"7.4.0":
"7.0.7":
folder: all
"7.4.1":
"7.0.5":
folder: all
"7.4.2":
"7.0.4":
folder: all
"7.5.0":
"7.0.2":
folder: all