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 proxy package for libx11 #678

Closed
wants to merge 18 commits into from
56 changes: 56 additions & 0 deletions recipes/libx11/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import subprocess
import shlex

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

def remove_prefix(s, prefix):
return s[len(prefix):] if s.startswith(prefix) else s


class LibX11Conan(ConanFile):
name = "libx11"
license = "X11"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.x.org/wiki/"
description = "Client interface to the X Window System, otherwise known as \'Xlib\'",
settings = "os", "compiler", "build_type", "arch"
_required_system_package = "libx11-dev"
Copy link
Contributor

Choose a reason for hiding this comment

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

would be much better to use pkg-config to check package availability, so it would be completely distro agnostic


def system_requirements(self):
installer = tools.SystemPackageTool()
if not installer.installed(self._required_system_package):
raise ConanInvalidConfiguration(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the plan to have libx11-dev installed in C3I build configurations ? Otherwise that would drastically reduce this package's usefulness, because it would not be possible to require it from any CCI recipe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they should be installed in CCI, if not all these kinds of recipes would be useless as you say.

"{0} system library missing. Install {0} in your system with something like: "\
"sudo apt-get install {0}"
.format(self._required_system_package))

def configure(self):
if self.settings.os != "Linux":
raise ConanInvalidConfiguration(
"This library is only compatible with Linux")
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def package(self):
tools.download("https://gitlab.freedesktop.org/xorg/lib/libx11/raw/master/COPYING", filename="COPYING")
czoido marked this conversation as resolved.
Show resolved Hide resolved
self.copy("COPYING", dst="licenses")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really useful to have a license file when you don't distribute anything ?

Copy link
Contributor

Choose a reason for hiding this comment

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

agree, it's pointless



def package_info(self):
if tools.which("pkg-config"):
pkg = tools.PkgConfig("x11")
self.cpp_info.includedirs = [remove_prefix(x,'-I') for x in pkg.cflags_only_I]
self.cpp_info.libdirs = [remove_prefix(x,'-L') for x in pkg.libs_only_L]
self.cpp_info.libs = [remove_prefix(x,'-l') for x in pkg.libs_only_l]
self.cpp_info.defines = [remove_prefix(x,'-D') for x in pkg.cflags_only_other if x.startswith('-D')]
self.cpp_info.cflags = [x for x in pkg.cflags_only_other if not x.startswith('-D')]
self.cpp_info.cppflags = [x for x in pkg.cflags_only_other if not x.startswith('-D')]
self.cpp_info.sharedlinkflags = pkg.libs_only_other
self.cpp_info.exelinkflags = pkg.libs_only_other
else:
self.cpp_info.libs.append("X11")

def package_id(self):
self.info.header_only()
9 changes: 9 additions & 0 deletions recipes/libx11/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 2.8.11)

project(test_package)

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

add_executable(${CMAKE_PROJECT_NAME} example.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/libx11/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os.path

from conans import ConanFile, CMake


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

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

def test(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
10 changes: 10 additions & 0 deletions recipes/libx11/all/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main()
{
Display *mydisplay;
mydisplay = XOpenDisplay("");
XCloseDisplay(mydisplay);
return 0;
}
3 changes: 3 additions & 0 deletions recipes/libx11/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"system":
folder: all