-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conan v2 #14
Conan v2 #14
Changes from 6 commits
e8b01e8
f7da8b8
b678af3
fab3608
663da5d
7ab93a1
95929da
a2051b0
171d648
f95626e
9f74fd5
1ce507f
087c472
6057d49
4b13199
7d16be8
d196694
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 |
---|---|---|
|
@@ -19,21 +19,22 @@ jobs: | |
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-18.04] | ||
os: [ubuntu-latest] | ||
build_type: [Debug, Release] | ||
compiler_version: [7, 8, 9] | ||
compiler_version: [9] | ||
compiler_libcxx: [libstdc++11] | ||
option_shared: ['True', 'False'] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
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. Should be |
||
- name: Install prerequisites | ||
run: | | ||
sudo apt-get install -y --no-install-recommends g++-8 | ||
sudo apt-get install -y --no-install-recommends g++-11 | ||
sudo pip3 install --upgrade setuptools pip | ||
sudo pip3 install conan | ||
- run: conan profile detect | ||
- run: conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force | ||
- run: conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -o fmilibrary:shared=${{ matrix.option_shared }} . _/_ | ||
- run: conan upload --all -c -r osp 'fmilibrary*' | ||
- run: conan create -s build_type=${{ matrix.build_type }} -s compiler.version=${{ matrix.compiler_version }} -s compiler.libcxx=${{ matrix.compiler_libcxx }} -o fmilibrary/*:shared=${{ matrix.option_shared }} . | ||
- run: conan upload -c -r osp 'fmilibrary*' | ||
|
||
conan-on-windows: | ||
name: Conan | ||
|
@@ -53,6 +54,7 @@ jobs: | |
run: | | ||
pip3 install --upgrade setuptools pip | ||
pip3 install conan | ||
- run: conan profile detect | ||
- run: conan remote add osp https://osp.jfrog.io/artifactory/api/conan/conan-local --force | ||
- run: conan create -s build_type=${{ matrix.build_type }} -o fmilibrary:shared=${{ matrix.option_shared }} . _/_ | ||
- run: conan upload --all -c -r osp 'fmilibrary*' | ||
- run: conan create -s build_type=${{ matrix.build_type }} -o fmilibrary/*:shared=${{ matrix.option_shared }} . | ||
- run: conan upload -c -r osp 'fmilibrary*' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,51 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os, pathlib | ||
|
||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout | ||
from conan.tools.files import patch, copy | ||
from conan.tools.scm import Git | ||
|
||
|
||
class FMILibraryConan(ConanFile): | ||
name = "fmilibrary" | ||
version = "2.3" | ||
license = "https://github.com/modelon-community/fmi-library/blob/master/LICENSE.md" | ||
url = "https://github.com/kyllingstad/conan-FMILibrary" | ||
url = "https://github.com/open-simulation-platform/conan-fmilibrary" | ||
description = "An implementation of the FMI standard which enables FMU import in applications" | ||
scm = { | ||
"type": "git", | ||
"url": "https://github.com/modelon-community/fmi-library.git", | ||
"revision": version, | ||
"subfolder": "src" | ||
} | ||
|
||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False]} | ||
default_options = "shared=False" | ||
generators = "cmake" | ||
exports_sources = [ "build-static-c99snprintf.patch" ] | ||
default_options = {"shared": False} | ||
|
||
generators = "CMakeDeps" | ||
|
||
exports_sources = "build-static-c99snprintf.patch" | ||
|
||
def source(self): | ||
tools.patch(base_path="src", patch_file="build-static-c99snprintf.patch") | ||
tools.replace_in_file("src/CMakeLists.txt", "project (FMILibrary)", | ||
'''project (FMILibrary) | ||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup()''') | ||
git = Git(self) | ||
git.clone(url="https://github.com/modelon-community/fmi-library.git", target="src", args=["--branch=2.3"]) | ||
patch(self, base_path="src", patch_file="build-static-c99snprintf.patch") | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.cache_variables["FMILIB_BUILD_STATIC_LIB"] = False if self.options.shared else True | ||
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. I believe these should be 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. Are you sure? According to the
|
||
tc.cache_variables["FMILIB_BUILD_SHARED_LIB"] = True if self.options.shared else False | ||
tc.cache_variables["FMILIB_BUILD_TESTS"] = False | ||
tc.cache_variables["FMILIB_INSTALL_PREFIX"] = pathlib.Path(os.path.join(self.build_folder, "install")).as_posix() | ||
tc.generate() | ||
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. Suggest adding 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. Agreed. |
||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure( | ||
source_folder="src", | ||
defs={ | ||
"FMILIB_BUILD_STATIC_LIB": "OFF" if self.options.shared else "ON", | ||
"FMILIB_BUILD_SHARED_LIB": "ON" if self.options.shared else "OFF", | ||
"FMILIB_BUILD_TESTS": "OFF", | ||
"FMILIB_INSTALL_PREFIX": self.build_folder + "/install", | ||
}) | ||
cmake.configure(build_script_folder="src") | ||
cmake.build() | ||
cmake.install() | ||
|
||
def package(self): | ||
fmilib_install_dir = self.build_folder + "/install" | ||
self.copy("*.h", dst="include", src=fmilib_install_dir+"/include") | ||
self.copy("*.dll", dst="bin", src=fmilib_install_dir, keep_path=False) | ||
self.copy("*.so", dst="lib", src=fmilib_install_dir, keep_path=False) | ||
self.copy("*.dylib",dst="lib", src=fmilib_install_dir, keep_path=False) | ||
self.copy("*.lib", dst="lib", src=fmilib_install_dir, keep_path=False) | ||
self.copy("*.a", dst="lib", src=fmilib_install_dir, keep_path=False) | ||
self.copy("LICENSE.md", src="src", dst="licenses", keep_path=False) | ||
self.copy("FMILIB_Acknowledgements.txt", src="src", dst="licenses", keep_path=False) | ||
cmake = CMake(self) | ||
cmake.install() | ||
copy(self, "*.dll", os.path.join(self.build_folder, str(self.settings.build_type)), os.path.join(self.package_folder, "bin")) | ||
|
||
def package_info(self): | ||
if self.options.shared: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
project(PackageTest CXX) | ||
cmake_minimum_required(VERSION 2.8.12) | ||
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. Minimum required version when using |
||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
find_package(fmilibrary CONFIG REQUIRED) | ||
|
||
add_executable(test test.cpp) | ||
target_link_libraries(test ${CONAN_LIBS} ${CMAKE_DL_LIBS}) | ||
target_link_libraries(test fmilibrary::fmilibrary) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, cmake_layout | ||
from conan.tools.files import copy | ||
from conan.tools.build import can_run | ||
|
||
|
||
class FmilibraryTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
generators = "CMakeDeps", "CMakeToolchain" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is | ||
# in "test_package" | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def imports(self): | ||
self.copy("*.dll", dst="bin", src="bin") | ||
self.copy("*.dylib*", dst="bin", src="lib") | ||
self.copy('*.so*', dst='bin', src='lib') | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
os.chdir("bin") | ||
self.run(".%stest" % os.sep) | ||
if can_run(self): | ||
cmd = os.path.join(self.cpp.build.bindir, "test") | ||
self.run(cmd, env="conanrun") |
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 suggest using containers when building. This configuration (gcc 9 and ubuntu 22) is unfortunate, since distributions using gcc 9 have an older glibc version than ubuntu 22 and pesky glibc issues are likely.
conanio have (almost) ready-made containers for various compiler versions.
You would need to upgrade conan and either use
conan config install
orconan profile detect
to setup.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.
Also note that many conan environment variables, e.g.
CONAN_NON_INTERACTIVE
are ignored with conan 2 and should be configured withcore:non_interactive = False
inglobal.conf
. I think in this case it does not make a difference.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 agree, and we actually do use containers in our main repo, libcosim. But since this is going to be just a stop-gap solution until you get fmilibrary into conan-center, let's just leave it as-is for now.