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 ignition-cmake #3268

Merged
merged 15 commits into from
Nov 24, 2020
4 changes: 4 additions & 0 deletions recipes/ignition-cmake/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.5.0":
url: "https://github.com/ignitionrobotics/ign-cmake/archive/ignition-cmake2_2.5.0.zip"
sha256: "6d35f015e259ec955f3abda64358a705ce5b3376c3df2ab5f0c17bea4b4e2f68"
81 changes: 81 additions & 0 deletions recipes/ignition-cmake/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import glob
import os

from conans import CMake, ConanFile, tools
from conans.errors import ConanInvalidConfiguration


class IgnitionCmakeConan(ConanFile):
name = "ignition-cmake"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/ignitionrobotics/ign-cmake"
description = "A set of CMake modules that are used by the C++-based Ignition projects."
topics = ("ignition", "robotics", "cmake")
settings = "os", "compiler", "build_type", "arch"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hard to see on mobile but I believe the settings are not used.. can they be removed in this case?

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 think so. Will remove.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the cmake script builds a test library.
I left it in to be certain it would select the correct toolchain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing settings results in error:

ignition-cmake/2.5.0: ERROR: Generator cmake_find_package_multi(file:None) failed
'settings.build_type' doesn't exist
'settings' possible configurations are none
ERROR: 'settings.build_type' doesn't exist
'settings' possible configurations are none

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can remove cmake_find_package from generators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's currently not part of generators. You mean line:

self.cpp_info.names["cmake_find_package"] = "ignition-cmake{}".format(version_major)

?

generators = "cmake", "cmake_find_package_multi"
joxoby marked this conversation as resolved.
Show resolved Hide resolved

_cmake = None

@property
def _minimum_cpp_standard(self):
return 17

@property
def _minimum_compilers_version(self):
return {
"Visual Studio": "16",
"gcc": "7",
"clang": "5",
"apple-clang": "10",
}

@property
def _source_subfolder(self):
return "source_subfolder"

def _configure_cmake(self):
if self._cmake is not None:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure(source_folder=self._source_subfolder)
return self._cmake

def configure(self):
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if not min_version:
self.output.warn(
"{} recipe lacks information about the {} compiler support.".format(
self.name, self.settings.compiler
)
)
else:
if tools.Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
"{} requires c++17 support. The current compiler {} {} does not support it.".format(
self.name,
self.settings.compiler,
self.settings.compiler.version,
)
)

def source(self):
joxoby marked this conversation as resolved.
Show resolved Hide resolved
tools.get(**self.conan_data["sources"][self.version])
os.rename(glob.glob("ign-cmake*")[0], self._source_subfolder)

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

def package_info(self):
version_major = tools.Version(self.version).major
self.cpp_info.names["cmake_find_package"] = "ignition-cmake{}".format(self.version_major)
self.cpp_info.names["cmake_find_package_multi"] = "ignition-cmake{}".format(self.version_major)
joxoby marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions recipes/ignition-cmake/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.10.2)
project(test_package)

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

find_package(ignition-cmake2)
joxoby marked this conversation as resolved.
Show resolved Hide resolved

include(IgnUtils)
joxoby marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions recipes/ignition-cmake/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os

from conans import CMake, ConanFile, tools


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

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

def test(self):
pass
joxoby marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions recipes/ignition-cmake/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.5.0":
folder: all