Skip to content

Commit

Permalink
Use pre-release Eigen 3.4.90
Browse files Browse the repository at this point in the history
To fix a ton of Eigen warnings when building with CUDA.
  • Loading branch information
valgur committed Jun 7, 2023
1 parent ee678de commit a06b8a1
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def requirements(self):
self._export_local_recipes()

# Used by all modules via cupoch_utility
self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True)
self.requires("eigen/3.4.90-pre@cupoch", transitive_headers=True, transitive_libs=True)
self.requires("spdlog/1.11.0", transitive_headers=True, transitive_libs=True)
self.requires("thrust/1.16.0@cupoch", transitive_headers=True, transitive_libs=True,
force=True)
Expand Down
4 changes: 4 additions & 0 deletions third_party/conan-recipes/eigen/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.4.90-pre":
url: "https://gitlab.com/libeigen/eigen/-/archive/7d7576f3262fa15c34d5575637bd8d7ff4a83f16/eigen-7d7576f3262fa15c34d5575637bd8d7ff4a83f16.tar.bz2"
sha256: "ee649bf6c173660e523712be6336122fa61e436cdc07a59ac5fa9be0c2e24df9"
82 changes: 82 additions & 0 deletions third_party/conan-recipes/eigen/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rmdir
import os

required_conan_version = ">=1.52.0"


class EigenConan(ConanFile):
name = "eigen"
version = "3.4.90-pre"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://eigen.tuxfamily.org"
description = "Eigen is a C++ template library for linear algebra: matrices, vectors," \
" numerical solvers, and related algorithms."
topics = ("algebra", "linear-algebra", "matrix", "vector", "numerical", "header-only")
package_type = "header-library"
license = ("MPL-2.0", "LGPL-3.0-or-later") # Taking into account the default value of MPL2_only option

settings = "os", "arch", "compiler", "build_type"
options = {
"MPL2_only": [True, False],
}
default_options = {
"MPL2_only": False,
}

def export_sources(self):
export_conandata_patches(self)

def configure(self):
self.license = "MPL-2.0" if self.options.MPL2_only else ("MPL-2.0", "LGPL-3.0-or-later")

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

def package_id(self):
self.info.clear()

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

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["BUILD_TESTING"] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool)
tc.cache_variables["EIGEN_TEST_NOQT"] = True
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, "COPYING.*", self.source_folder, os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "Eigen3")
self.cpp_info.set_property("cmake_target_name", "Eigen3::Eigen")
self.cpp_info.set_property("pkg_config_name", "eigen3")
# TODO: back to global scope once cmake_find_package* generators removed
self.cpp_info.components["eigen3"].bindirs = []
self.cpp_info.components["eigen3"].libdirs = []
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["eigen3"].system_libs = ["m"]
if self.options.MPL2_only:
self.cpp_info.components["eigen3"].defines = ["EIGEN_MPL2_ONLY"]

# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
self.cpp_info.names["cmake_find_package"] = "Eigen3"
self.cpp_info.names["cmake_find_package_multi"] = "Eigen3"
self.cpp_info.names["pkg_config"] = "eigen3"
self.cpp_info.components["eigen3"].names["cmake_find_package"] = "Eigen"
self.cpp_info.components["eigen3"].names["cmake_find_package_multi"] = "Eigen"
self.cpp_info.components["eigen3"].set_property("cmake_target_name", "Eigen3::Eigen")
self.cpp_info.components["eigen3"].includedirs = [os.path.join("include", "eigen3")]
7 changes: 7 additions & 0 deletions third_party/conan-recipes/eigen/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)

find_package(Eigen3 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE Eigen3::Eigen)
25 changes: 25 additions & 0 deletions third_party/conan-recipes/eigen/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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 = "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):
self.run(os.path.join(self.cpp.build.bindirs[0], "test_package"), env="conanrun")
16 changes: 16 additions & 0 deletions third_party/conan-recipes/eigen/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
#include <Eigen/Core>
#include <unsupported/Eigen/MatrixFunctions>


int main(void)
{
int const N = 5;
Eigen::MatrixXi A(N, N);
A.setRandom();

std::cout << "A =\n" << A << "\n\n"
<< "A(2..3,:) =\n" << A.middleRows(2, 2) << "\n";

return 0;
}

0 comments on commit a06b8a1

Please sign in to comment.