mirror of
https://github.com/nigels-com/glew.git
synced 2024-11-22 05:45:07 +00:00
Merge pull request #151 from dimi309/master
Adding conan packaging support
This commit is contained in:
commit
0ce7b8ee26
53
.travis.yml.conan
Normal file
53
.travis.yml.conan
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
env:
|
||||
global:
|
||||
- CONAN_USERNAME="nigels-com"
|
||||
- CONAN_REFERENCE="glew/master"
|
||||
- CONAN_CHANNEL="testing"
|
||||
|
||||
linux: &linux
|
||||
os: linux
|
||||
sudo: required
|
||||
language: python
|
||||
python: "2.7"
|
||||
services:
|
||||
- docker
|
||||
osx: &osx
|
||||
os: osx
|
||||
language: generic
|
||||
matrix:
|
||||
include:
|
||||
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=lasote/conangcc49
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=5.4 CONAN_DOCKER_IMAGE=lasote/conangcc54
|
||||
- <<: *linux
|
||||
env: CONAN_GCC_VERSIONS=6.3 CONAN_DOCKER_IMAGE=lasote/conangcc63
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=lasote/conanclang39
|
||||
- <<: *linux
|
||||
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=lasote/conanclang40
|
||||
- <<: *osx
|
||||
osx_image: xcode7.3
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=7.3
|
||||
- <<: *osx
|
||||
osx_image: xcode8.2
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=8.0
|
||||
- <<: *osx
|
||||
osx_image: xcode8.3
|
||||
env: CONAN_APPLE_CLANG_VERSIONS=8.1
|
||||
|
||||
install:
|
||||
- chmod +x ./build/conan/.travis/install.sh
|
||||
- ./build/conan/.travis/install.sh
|
||||
script:
|
||||
# Building master
|
||||
- cp -rf ./build/conan/* .
|
||||
- cp -rf ./build/conan/.travis .
|
||||
- chmod +x .travis/run.sh
|
||||
- .travis/run.sh
|
||||
|
||||
# Building released version
|
||||
#- chmod +x ./build/conan/.travis/run.sh
|
||||
#- cd ./build/conan && .travis/run.sh
|
17
build/conan/.gitignore
vendored
Normal file
17
build/conan/.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#Backup files
|
||||
*\~
|
||||
*swp
|
||||
|
||||
#OSX
|
||||
Thumbs.db
|
||||
.DS_Store
|
||||
|
||||
#Emacs buffers
|
||||
\#*\#
|
||||
\.#*
|
||||
|
||||
#Conan
|
||||
test_package/build
|
||||
conanfile.pyc
|
||||
conaninfo.txt
|
||||
conanbuildinfo.cmake
|
24
build/conan/.travis/install.sh
Normal file
24
build/conan/.travis/install.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
brew update || brew update
|
||||
brew outdated pyenv || brew upgrade pyenv
|
||||
brew install pyenv-virtualenv
|
||||
brew install cmake || true
|
||||
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
|
||||
pyenv install 2.7.10
|
||||
pyenv virtualenv 2.7.10 conan
|
||||
pyenv rehash
|
||||
pyenv activate conan
|
||||
|
||||
fi
|
||||
|
||||
pip install conan_package_tools
|
||||
conan user
|
13
build/conan/.travis/run.sh
Executable file
13
build/conan/.travis/run.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
python build.py
|
18
build/conan/FindGLEW.cmake
Normal file
18
build/conan/FindGLEW.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
find_path(
|
||||
GLEW_INCLUDE_DIR
|
||||
NAMES
|
||||
GL
|
||||
PATHS
|
||||
include)
|
||||
|
||||
find_library(
|
||||
GLEW_LIBRARY
|
||||
NAMES
|
||||
GLEW GLEWd glew32 glew32s glew32d glew32sd
|
||||
PATHS
|
||||
lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(GLEW REQUIRED_VARS GLEW_LIBRARY GLEW_INCLUDE_DIR)
|
||||
|
12
build/conan/build.py
Normal file
12
build/conan/build.py
Normal file
@ -0,0 +1,12 @@
|
||||
from conan.packager import ConanMultiPackager
|
||||
import os, platform
|
||||
|
||||
if __name__ == "__main__":
|
||||
builder = ConanMultiPackager(args="--build missing")
|
||||
builder.add_common_builds()
|
||||
filtered_builds = []
|
||||
for settings, options, env_vars, build_requires in builder.builds:
|
||||
if not (settings["arch"] == "x86"):
|
||||
filtered_builds.append([settings, options, env_vars, build_requires])
|
||||
builder.builds = filtered_builds
|
||||
builder.run()
|
143
build/conan/conanfile.py
Normal file
143
build/conan/conanfile.py
Normal file
@ -0,0 +1,143 @@
|
||||
import os
|
||||
from conans import ConanFile, CMake
|
||||
from conans.tools import os_info, SystemPackageTool, ConanException
|
||||
from conans import tools, VisualStudioBuildEnvironment
|
||||
from conans.tools import build_sln_command, vcvars_command, replace_in_file, download, unzip
|
||||
|
||||
class GlewConan(ConanFile):
|
||||
name = "glew"
|
||||
version = "master"
|
||||
source_directory = "%s-%s" % (name, version) if version != "master" else "."
|
||||
description = "The GLEW library"
|
||||
generators = "cmake", "txt"
|
||||
settings = "os", "arch", "build_type", "compiler"
|
||||
options = {"shared": [True, False]}
|
||||
default_options = "shared=False"
|
||||
url="http://github.com/nigels-com/glew"
|
||||
license="https://github.com/nigels-com/glew#copyright-and-licensing"
|
||||
if version == "master":
|
||||
if os.path.isfile("Makefile"):
|
||||
exports_sources = "*"
|
||||
else:
|
||||
exports_sources = os.sep.join(["..", "..", "*"])
|
||||
else:
|
||||
exports = "FindGLEW.cmake"
|
||||
|
||||
def system_requirements(self):
|
||||
if os_info.is_linux:
|
||||
if os_info.with_apt:
|
||||
installer = SystemPackageTool()
|
||||
if self.version == "master":
|
||||
installer.install("build-essential")
|
||||
installer.install("libxmu-dev")
|
||||
installer.install("libxi-dev")
|
||||
installer.install("libgl-dev")
|
||||
installer.install("libosmesa-dev")
|
||||
installer.install("libglu1-mesa-dev")
|
||||
elif os_info.with_yum:
|
||||
installer = SystemPackageTool()
|
||||
if self.version == "master":
|
||||
installer.install("libXmu-devel")
|
||||
installer.install("libXi-devel")
|
||||
installer.install("libGL-devel")
|
||||
installer.install("mesa-libGLU-devel")
|
||||
else:
|
||||
self.output.warn("Could not determine Linux package manager, skipping system requirements installation.")
|
||||
|
||||
def configure(self):
|
||||
del self.settings.compiler.libcxx
|
||||
|
||||
def source(self):
|
||||
if self.version != "master":
|
||||
zip_name = "%s.tgz" % self.source_directory
|
||||
download("https://sourceforge.net/projects/glew/files/glew/%s/%s/download" % (self.version, zip_name), zip_name)
|
||||
unzip(zip_name)
|
||||
os.unlink(zip_name)
|
||||
|
||||
def build(self):
|
||||
if self.settings.os == "Windows" and self.version == "master":
|
||||
raise ConanException("Trunk builds are not supported on Windows (cannot build directly from master git repository).")
|
||||
|
||||
if self.settings.compiler == "Visual Studio":
|
||||
env = VisualStudioBuildEnvironment(self)
|
||||
with tools.environment_append(env.vars):
|
||||
version = min(12, int(self.settings.compiler.version.value))
|
||||
version = 10 if version == 11 else version
|
||||
cd_build = "cd %s\\%s\\build\\vc%s" % (self.conanfile_directory, self.source_directory, version)
|
||||
build_command = build_sln_command(self.settings, "glew.sln")
|
||||
vcvars = vcvars_command(self.settings)
|
||||
self.run("%s && %s && %s" % (vcvars, cd_build, build_command.replace("x86", "Win32")))
|
||||
else:
|
||||
if self.settings.os == "Windows":
|
||||
replace_in_file("%s/build/cmake/CMakeLists.txt" % self.source_directory, \
|
||||
"if(WIN32 AND (NOT MSVC_VERSION LESS 1600)", \
|
||||
"if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600)")
|
||||
|
||||
if self.version == "master":
|
||||
self.run("make extensions")
|
||||
|
||||
cmake = CMake(self)
|
||||
cmake.configure(source_dir="%s/build/cmake" % self.source_directory, defs={"BUILD_UTILS": "OFF"})
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
find_glew_dir = "%s/build/conan" % self.conanfile_directory if self.version == "master" else "."
|
||||
self.copy("FindGLEW.cmake", ".", find_glew_dir, keep_path=False)
|
||||
self.copy("include/*", ".", "%s" % self.source_directory, keep_path=True)
|
||||
self.copy("%s/license*" % self.source_directory, dst="licenses", ignore_case=True, keep_path=False)
|
||||
|
||||
if self.settings.os == "Windows":
|
||||
if self.settings.compiler == "Visual Studio":
|
||||
self.copy(pattern="*.pdb", dst="bin", keep_path=False)
|
||||
if self.options.shared:
|
||||
self.copy(pattern="*32.lib", dst="lib", keep_path=False)
|
||||
self.copy(pattern="*32d.lib", dst="lib", keep_path=False)
|
||||
self.copy(pattern="*.dll", dst="bin", keep_path=False)
|
||||
else:
|
||||
self.copy(pattern="*32s.lib", dst="lib", keep_path=False)
|
||||
self.copy(pattern="*32sd.lib", dst="lib", keep_path=False)
|
||||
else:
|
||||
if self.options.shared:
|
||||
self.copy(pattern="*32.dll.a", dst="lib", keep_path=False)
|
||||
self.copy(pattern="*32d.dll.a", dst="lib", keep_path=False)
|
||||
self.copy(pattern="*.dll", dst="bin", keep_path=False)
|
||||
else:
|
||||
self.copy(pattern="*32.a", dst="lib", keep_path=False)
|
||||
self.copy(pattern="*32d.a", dst="lib", keep_path=False)
|
||||
elif self.settings.os == "Macos":
|
||||
if self.options.shared:
|
||||
self.copy(pattern="*.dylib", dst="lib", keep_path=False)
|
||||
else:
|
||||
self.copy(pattern="*.a", dst="lib", keep_path=False)
|
||||
else:
|
||||
if self.options.shared:
|
||||
self.copy(pattern="*.so", dst="lib", keep_path=False)
|
||||
else:
|
||||
self.copy(pattern="*.a", dst="lib", keep_path=False)
|
||||
|
||||
def package_info(self):
|
||||
if self.settings.os == "Windows":
|
||||
self.cpp_info.libs = ['glew32']
|
||||
|
||||
if not self.options.shared:
|
||||
self.cpp_info.defines.append("GLEW_STATIC")
|
||||
|
||||
if self.settings.compiler == "Visual Studio":
|
||||
if not self.options.shared:
|
||||
self.cpp_info.libs[0] += "s"
|
||||
self.cpp_info.libs.append("OpenGL32.lib")
|
||||
if self.settings.compiler.runtime != "MT":
|
||||
self.cpp_info.exelinkflags.append('-NODEFAULTLIB:LIBCMTD')
|
||||
self.cpp_info.exelinkflags.append('-NODEFAULTLIB:LIBCMT')
|
||||
else:
|
||||
self.cpp_info.libs.append("opengl32")
|
||||
|
||||
else:
|
||||
self.cpp_info.libs = ['GLEW']
|
||||
if self.settings.os == "Macos":
|
||||
self.cpp_info.exelinkflags.append("-framework OpenGL")
|
||||
elif not self.options.shared:
|
||||
self.cpp_info.libs.append("GL")
|
||||
|
||||
if self.settings.build_type == "Debug":
|
||||
self.cpp_info.libs[0] += "d"
|
9
build/conan/test_package/CMakeLists.txt
Normal file
9
build/conan/test_package/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
project(GlewTest)
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup()
|
||||
|
||||
add_executable(testGlew main.c)
|
||||
target_compile_definitions(testGlew PUBLIC "${CONAN_DEFINES}")
|
||||
target_link_libraries(testGlew PUBLIC "${CONAN_LIBS}")
|
||||
set_target_properties(testGlew PROPERTIES LINK_FLAGS "${CONAN_EXE_LINKER_FLAGS}")
|
21
build/conan/test_package/conanfile.py
Normal file
21
build/conan/test_package/conanfile.py
Normal file
@ -0,0 +1,21 @@
|
||||
from conans import ConanFile, CMake
|
||||
import os
|
||||
|
||||
class TestGlew(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
self.run('cmake "%s" %s' % (self.conanfile_directory, cmake.command_line))
|
||||
self.run("cmake --build . %s" % cmake.build_config)
|
||||
|
||||
def test(self):
|
||||
self.run(os.sep.join([".","bin", "testGlew"]))
|
||||
|
||||
def imports(self):
|
||||
if self.settings.os == "Windows":
|
||||
self.copy(pattern="*.dll", dst="bin", src="bin")
|
||||
self.copy(pattern="*.pdb", dst="bin", src="bin")
|
||||
if self.settings.os == "Macos":
|
||||
self.copy(pattern="*.dylib", dst="bin", src="lib")
|
6
build/conan/test_package/main.c
Normal file
6
build/conan/test_package/main.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "GL/glew.h"
|
||||
|
||||
int main (){
|
||||
glewGetString(GLEW_VERSION);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user