[DO-981] qt package (!15)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
This commit is contained in:
68
recipes/opengl/all/conanfile.py
Normal file
68
recipes/opengl/all/conanfile.py
Normal file
@@ -0,0 +1,68 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.system import package_manager
|
||||
from conan.tools.gnu import PkgConfig
|
||||
|
||||
required_conan_version = ">=1.50.0"
|
||||
|
||||
|
||||
class SysConfigOpenGLConan(ConanFile):
|
||||
name = "opengl"
|
||||
version = "system"
|
||||
description = "cross-platform virtual conan package for the OpenGL support"
|
||||
topics = ("opengl", "gl")
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://www.opengl.org/"
|
||||
license = "MIT"
|
||||
package_type = "shared-library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
|
||||
def layout(self):
|
||||
pass
|
||||
|
||||
def package_id(self):
|
||||
self.info.clear()
|
||||
|
||||
def system_requirements(self):
|
||||
if self.settings.os not in ["Linux", "FreeBSD", "SunOS"]:
|
||||
return
|
||||
|
||||
dnf = package_manager.Dnf(self)
|
||||
dnf.install_substitutes(["libglvnd-devel"], ["mesa-libGL-devel"], update=True, check=True)
|
||||
|
||||
yum = package_manager.Yum(self)
|
||||
yum.install(["mesa-libGL-devel"], update=True, check=True)
|
||||
|
||||
apt = package_manager.Apt(self)
|
||||
apt.install_substitutes(["libgl-dev"], ["libgl1-mesa-dev"], update=True, check=True)
|
||||
|
||||
pacman = package_manager.PacMan(self)
|
||||
pacman.install(["libglvnd"], update=True, check=True)
|
||||
|
||||
zypper = package_manager.Zypper(self)
|
||||
zypper.install_substitutes(["Mesa-libGL-devel", "glproto-devel"],
|
||||
["Mesa-libGL-devel", "xorgproto-devel"], update=True, check=True)
|
||||
|
||||
pkg = package_manager.Pkg(self)
|
||||
pkg.install(["libglvnd"], update=True, check=True)
|
||||
|
||||
pkg_util = package_manager.PkgUtil(self)
|
||||
pkg_util.install(["mesalibs"], update=True, check=True)
|
||||
|
||||
def package_info(self):
|
||||
# TODO: Workaround for #2311 until a better solution can be found
|
||||
self.cpp_info.filenames["cmake_find_package"] = "opengl_system"
|
||||
self.cpp_info.filenames["cmake_find_package_multi"] = "opengl_system"
|
||||
|
||||
self.cpp_info.set_property("cmake_file_name", "opengl_system")
|
||||
|
||||
self.cpp_info.bindirs = []
|
||||
self.cpp_info.includedirs = []
|
||||
self.cpp_info.libdirs = []
|
||||
if self.settings.os == "Macos":
|
||||
self.cpp_info.defines.append("GL_SILENCE_DEPRECATION=1")
|
||||
self.cpp_info.frameworks.append("OpenGL")
|
||||
elif self.settings.os == "Windows":
|
||||
self.cpp_info.system_libs = ["opengl32"]
|
||||
elif self.settings.os in ["Linux", "FreeBSD", "SunOS"]:
|
||||
pkg_config = PkgConfig(self, 'gl')
|
||||
pkg_config.fill_cpp_info(self.cpp_info, is_system=self.settings.os != "FreeBSD")
|
||||
31
recipes/opengl/all/test_cmake_module_package/CMakeLists.txt
Normal file
31
recipes/opengl/all/test_cmake_module_package/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(test_package)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(SOURCES ../test_package/test_package.cpp)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SOURCES ../test_package/win.cpp)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND SOURCES ../test_package/osx.mm)
|
||||
set_source_files_properties(../test_package/osx.mm PROPERTIES COMPILE_FLAGS "-x objective-c++")
|
||||
|
||||
list(APPEND PLATFORM_LIBS "objc")
|
||||
|
||||
find_library(APPKIT_LIBRARY AppKit)
|
||||
find_library(FOUNDATION_LIBRARY Foundation)
|
||||
|
||||
if(APPKIT_LIBRARY)
|
||||
list(APPEND PLATFORM_LIBS ${APPKIT_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(FOUNDATION_LIBRARY)
|
||||
list(APPEND PLATFORM_LIBS ${FOUNDATION_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL ${PLATFORM_LIBS})
|
||||
26
recipes/opengl/all/test_cmake_module_package/conanfile.py
Normal file
26
recipes/opengl/all/test_cmake_module_package/conanfile.py
Normal file
@@ -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 layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
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")
|
||||
31
recipes/opengl/all/test_package/CMakeLists.txt
Normal file
31
recipes/opengl/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(test_package)
|
||||
|
||||
find_package(opengl_system REQUIRED CONFIG)
|
||||
|
||||
set(SOURCES test_package.cpp)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SOURCES win.cpp)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND SOURCES osx.mm)
|
||||
set_source_files_properties(osx.mm PROPERTIES COMPILE_FLAGS "-x objective-c++")
|
||||
|
||||
list(APPEND PLATFORM_LIBS "objc")
|
||||
|
||||
find_library(APPKIT_LIBRARY AppKit)
|
||||
find_library(FOUNDATION_LIBRARY Foundation)
|
||||
|
||||
if(APPKIT_LIBRARY)
|
||||
list(APPEND PLATFORM_LIBS ${APPKIT_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(FOUNDATION_LIBRARY)
|
||||
list(APPEND PLATFORM_LIBS ${FOUNDATION_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE opengl::opengl ${PLATFORM_LIBS})
|
||||
10
recipes/opengl/all/test_package/CMakeUserPresets.json
Normal file
10
recipes/opengl/all/test_package/CMakeUserPresets.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": 4,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/gcc-12-x86_64-gnu17-release/generators/CMakePresets.json",
|
||||
"build/gcc-11.5-x86_64-17-release/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
||||
26
recipes/opengl/all/test_package/conanfile.py
Normal file
26
recipes/opengl/all/test_package/conanfile.py
Normal file
@@ -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 layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
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")
|
||||
31
recipes/opengl/all/test_package/osx.mm
Normal file
31
recipes/opengl/all/test_package/osx.mm
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "TargetConditionals.h"
|
||||
|
||||
#if TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_IPHONE
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
bool init_context()
|
||||
{
|
||||
#if TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_IPHONE
|
||||
return true;
|
||||
#else
|
||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
|
||||
{
|
||||
NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
0
|
||||
};
|
||||
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
||||
if (!pixelFormat)
|
||||
return false;
|
||||
|
||||
NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
||||
if (!context)
|
||||
return false;
|
||||
[context makeCurrentContext];
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
47
recipes/opengl/all/test_package/test_package.cpp
Normal file
47
recipes/opengl/all/test_package/test_package.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include <OpenGL/gl.h>
|
||||
|
||||
#else
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) or defined(__FreeBSD__)
|
||||
|
||||
bool init_context() { return true; }
|
||||
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#endif
|
||||
|
||||
bool init_context();
|
||||
|
||||
int main()
|
||||
{
|
||||
if (!init_context())
|
||||
{
|
||||
// std::cerr << "failed to initialize OpenGL context!" << std::endl;
|
||||
// return -1;
|
||||
|
||||
// Don't fail if we can't init the context - won't work on a headless CI
|
||||
// Instead, if we made it this far, then we were able to #include and link,
|
||||
// count that as a success!
|
||||
std::cout << "Linked test, but failed to initialize OpenGL context (headless platform?)" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
const char * gl_vendor = (const char *) glGetString(GL_VENDOR);
|
||||
const char * gl_renderer = (const char *) glGetString(GL_RENDERER);
|
||||
const char * gl_version = (const char *) glGetString(GL_VERSION);
|
||||
const char * gl_extensions = (const char *) glGetString(GL_EXTENSIONS);
|
||||
std::cout << "GL_VENDOR: " << (gl_vendor ? gl_vendor : "(null)") << std::endl;
|
||||
std::cout << "GL_RENDERER: " << (gl_renderer ? gl_renderer : "(null)") << std::endl;
|
||||
std::cout << "GL_VERSION: " << (gl_version ? gl_version : "(null)") << std::endl;
|
||||
std::cout << "GL_EXTENSIONS: " << (gl_extensions ? gl_extensions : "(null)") << std::endl;
|
||||
return 0;
|
||||
}
|
||||
58
recipes/opengl/all/test_package/win.cpp
Normal file
58
recipes/opengl/all/test_package/win.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <windows.h>
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd,
|
||||
UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT res = 1;
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_DESTROY:
|
||||
::PostQuitMessage (0);
|
||||
break;
|
||||
default:
|
||||
res = ::DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool init_context()
|
||||
{
|
||||
static const wchar_t * class_name = L"ConanOpenGL";
|
||||
static const wchar_t * window_name = L"Conan OpenGL";
|
||||
WNDCLASSEXW wc = {0};
|
||||
wc.cbSize = sizeof(WNDCLASSEXW);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.hInstance = ::GetModuleHandle(NULL);
|
||||
wc.hIcon = ::LoadIcon(0, IDI_APPLICATION);
|
||||
wc.hCursor = ::LoadCursor(0, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) ::GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszClassName = class_name;
|
||||
if (!::RegisterClassExW(&wc))
|
||||
return false;
|
||||
HWND hWnd = ::CreateWindowExW(0, class_name, window_name,
|
||||
WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, wc.hInstance, NULL);
|
||||
if (!hWnd)
|
||||
return false;
|
||||
HDC hDC = ::GetDC(hWnd);
|
||||
if (!hDC)
|
||||
return false;
|
||||
PIXELFORMATDESCRIPTOR pfd = {0};
|
||||
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||
pfd.nVersion = 1;
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.dwLayerMask = PFD_MAIN_PLANE;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cDepthBits = 16;
|
||||
int pixel_format = ::ChoosePixelFormat(hDC, &pfd);
|
||||
if(0 == pixel_format)
|
||||
return false;
|
||||
if (!::SetPixelFormat(hDC, pixel_format, &pfd))
|
||||
return false;
|
||||
HGLRC hGLRC = ::wglCreateContext(hDC);
|
||||
if (!hGLRC)
|
||||
return false;
|
||||
::wglMakeCurrent(hDC, hGLRC);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_cmake_module_package
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_cmake_module_package)
|
||||
17
recipes/opengl/all/test_v1_cmake_module_package/conanfile.py
Normal file
17
recipes/opengl/all/test_v1_cmake_module_package/conanfile.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self):
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run(bin_path, run_environment=True)
|
||||
8
recipes/opengl/all/test_v1_package/CMakeLists.txt
Normal file
8
recipes/opengl/all/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
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)
|
||||
17
recipes/opengl/all/test_v1_package/conanfile.py
Normal file
17
recipes/opengl/all/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package_multi"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self):
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run(bin_path, run_environment=True)
|
||||
3
recipes/opengl/config.yml
Normal file
3
recipes/opengl/config.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
versions:
|
||||
"system":
|
||||
folder: all
|
||||
Reference in New Issue
Block a user