-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ofeli: migrate to Conan v2, add v5.1.0 #18952
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a658a2
ofeli: migrate to Conan v2
valgur d076f84
ofeli: shared builds are not supported
valgur 9be097a
ofeli: remove incorrect shared/fPIC
valgur 0dfe69e
ofeli: add v5.1.0 with CMake support
valgur 57164ab
ofeli: shared build does not work
valgur 67ebb13
ofeli: install materials under res/
valgur 5658394
ofeli: fix license copying
valgur 0fd809e
ofeli: add cmake/3.16 dependency
valgur ebe9955
ofeli: improve validation logic, enable MSVC
valgur 4344a2d
ofeli: disable MSVC on 5.x
valgur 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
File renamed without changes.
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 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.files import chdir, copy, get | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain | ||
from conan.tools.layout import basic_layout | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class OfeliConan(ConanFile): | ||
name = "ofeli" | ||
description = "An Object Finite Element Library" | ||
license = "LGPL-3.0-or-later" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "http://ofeli.org/index.html" | ||
topics = ("finite-element", "finite-element-library", "finite-element-analysis", "finite-element-solver") | ||
|
||
package_type = "static-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"fPIC": True, | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.os not in ["Linux", "FreeBSD"]: | ||
raise ConanInvalidConfiguration("Ofeli only supports Linux") | ||
if self.settings.compiler != "gcc": | ||
raise ConanInvalidConfiguration("Ofeli only supports GCC") | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, 11) | ||
if self.settings.compiler.libcxx != "libstdc++11": | ||
raise ConanInvalidConfiguration("Ofeli only supports libstdc++'s new ABI") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = AutotoolsToolchain(self) | ||
config = 'release' if self.settings.build_type == 'Release' else 'debug' | ||
tc.configure_args.append(f"--enable-{config}") | ||
tc.generate() | ||
|
||
def build(self): | ||
with chdir(self, self.source_folder): | ||
autotools = Autotools(self) | ||
autotools.configure() | ||
autotools.make() | ||
|
||
def package(self): | ||
copy(self, "*.h", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=os.path.join(self.source_folder, "include")) | ||
copy(self, "*libofeli.a", | ||
dst=os.path.join(self.package_folder, "lib"), | ||
src=os.path.join(self.source_folder, "src")) | ||
copy(self, "*.md", | ||
dst=os.path.join(self.package_folder, "res"), | ||
src=os.path.join(self.source_folder, "material")) | ||
copy(self, "COPYING", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=os.path.join(self.source_folder, "doc")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["ofeli"] | ||
res_path = os.path.join(self.package_folder, "res") | ||
self.runenv_info.define("OFELI_PATH_MATERIAL", res_path) | ||
|
||
# TODO: Legacy, to be removed on Conan 2.0 | ||
self.env_info.OFELI_PATH_MATERIAL.append(res_path) |
7 changes: 2 additions & 5 deletions
7
...pes/ofeli/all/test_package/CMakeLists.txt → ...pes/ofeli/4.x/test_package/CMakeLists.txt
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,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
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
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) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
File renamed without changes.
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: | ||
"5.1.0": | ||
url: "https://github.com/rtouzani/ofeli/archive/0e66d0e5a38b209ee79eab0daf7686562b753536.tar.gz" | ||
sha256: "a2e4e62d912d05e55001a9be7c5c4741a7b8773a399acbbe558bdca0d60d430b" |
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,88 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.files import copy, get, rmdir, replace_in_file, rename | ||
from conan.tools.microsoft import is_msvc | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class OfeliConan(ConanFile): | ||
name = "ofeli" | ||
description = "An Object Finite Element Library" | ||
license = "LGPL-3.0-or-later" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "http://ofeli.org/index.html" | ||
topics = ("finite-element", "finite-element-library", "finite-element-analysis", "finite-element-solver") | ||
|
||
package_type = "static-library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"fPIC": True, | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, 11) | ||
if self.settings.compiler in ["clang", "apple-clang"] or is_msvc(self): | ||
# Clang fails with | ||
# include/linear_algebra/LocalVect_impl.h:251:42: error: cannot initialize return object of type 'OFELI::Element *' with an lvalue of type 'const OFELI::Element *' | ||
# MSVC fails with a lot of errors | ||
# https://c3i.jfrog.io/c3i/misc/summary.html?json=https://c3i.jfrog.io/c3i/misc/logs/pr/18952/12-windows-visual_studio/ofeli/5.1.0/summary.json | ||
raise ConanInvalidConfiguration(f"{self.settings.compiler} is not supported due to compilation errors") | ||
|
||
def build_requirements(self): | ||
self.tool_requires("cmake/[>=3.16 <4]") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
env = VirtualBuildEnv(self) | ||
env.generate() | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
|
||
def _patch_sources(self): | ||
cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") | ||
replace_in_file(self, cmakelists, "add_subdirectory (demos)", "") | ||
replace_in_file(self, cmakelists, "add_subdirectory (util)", "") | ||
# Fix incorrect use of add_definitions() for build flags | ||
replace_in_file(self, cmakelists, "add_definitions", "add_compile_options") | ||
# Fix -fPIC support | ||
replace_in_file(self, cmakelists, " -fPIE", "") | ||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
rename(self, os.path.join(self.package_folder, "share", "ofeli", "material"), | ||
os.path.join(self.package_folder, "res")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["ofeli"] | ||
self.cpp_info.includedirs = [os.path.join("include", "ofeli")] | ||
res_path = os.path.join(self.package_folder, "res") | ||
self.runenv_info.define_path("OFELI_PATH_MATERIAL", res_path) |
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(ofeli REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ofeli::ofeli) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) |
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,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
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,76 @@ | ||
/*============================================================================== | ||
|
||
O F E L I | ||
|
||
Object Finite Element Library | ||
|
||
============================================================================== | ||
|
||
Copyright (C) 1998 - 2015 Rachid Touzani | ||
|
||
This file is part of OFELI. | ||
|
||
OFELI is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
OFELI is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with OFELI. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
============================================================================== | ||
|
||
An example of a Finite Element Code using OFELI | ||
|
||
Solution of a 1-D Elliptic problem using P1 Finite elements | ||
|
||
==============================================================================*/ | ||
|
||
#include "OFELI.h" | ||
using namespace OFELI; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
double L=1; | ||
int N=10; | ||
|
||
/// Read and output mesh data | ||
banner(); | ||
if (argc>1) | ||
N = atoi(argv[1]); | ||
Mesh ms(L,N); | ||
int NbN = N+1; | ||
|
||
// Declare problem data (matrix, rhs, boundary conditions, body forces) | ||
TrMatrix<double> A(NbN); | ||
Vect<double> b(ms); | ||
b.set("16*pi*pi*sin(4*pi*x)"); | ||
|
||
// Build matrix and R.H.S. | ||
double h = L/double(N); | ||
b *= h; | ||
for (int i=2; i<NbN; i++) { | ||
A(i,i ) = 2./h; | ||
A(i,i+1) = -1./h; | ||
A(i,i-1) = -1./h; | ||
} | ||
|
||
// Impose boundary conditions | ||
A(1,1) = 1.; A(1,2) = 0.; b(1) = 0; | ||
A(NbN,NbN) = 1.; A(NbN-1,NbN) = 0.; b(NbN) = 0; | ||
|
||
// Solve the linear system of equations | ||
A.solve(b); | ||
|
||
// Output solution and error | ||
cout << "\nSolution:\n" << b; | ||
Vect<double> sol(ms); | ||
sol.set("sin(4*pi*x)"); | ||
cout << "Error = " << (b-sol).getNormMax() << endl; | ||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.
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.
I did not find a reference offering only static library: https://github.com/rtouzani/ofeli/blob/master/src/CMakeLists.txt
Please, point where you found it.
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.
A shared build fails with:
on GCC.