forked from neka-nat/cupoch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To fix a ton of Eigen warnings when building with CUDA.
- Loading branch information
Showing
6 changed files
with
135 additions
and
1 deletion.
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
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,4 @@ | ||
sources: | ||
"3.4.90-pre": | ||
url: "https://gitlab.com/libeigen/eigen/-/archive/7d7576f3262fa15c34d5575637bd8d7ff4a83f16/eigen-7d7576f3262fa15c34d5575637bd8d7ff4a83f16.tar.bz2" | ||
sha256: "ee649bf6c173660e523712be6336122fa61e436cdc07a59ac5fa9be0c2e24df9" |
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,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")] |
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,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) |
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,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
16
third_party/conan-recipes/eigen/test_package/test_package.cpp
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 <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; | ||
} |