Skip to content

Commit

Permalink
Merge pull request conan-io#1 from uilianries/freealut
Browse files Browse the repository at this point in the history
[freealut] Code review for PR 20851 at ConanCenterIndex
  • Loading branch information
lucaskdc authored Nov 20, 2023
2 parents 3423ee0 + 382545c commit b671bfb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 222 deletions.
8 changes: 0 additions & 8 deletions recipes/freealut/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,3 @@ sources:
"1.1.0":
url: "http://ftp.debian.org/debian/pool/main/f/freealut/freealut_1.1.0.orig.tar.gz"
sha256: "60d1ea8779471bb851b89b49ce44eecb78e46265be1a6e9320a28b100c8df44f"
patches:
"1.1.0":
- patch_file: "patches/get-openal-from-conan-and-cmake-adaptations.patch"
patch_description: "Get OpenAL from conan and use GNUInstallDirs in cmake"
patch_type: "conan"
- patch_file: "patches/harmonize-static-lib-build.patch"
patch_description: "Remove dllexport/dllimport when build as static library"
patch_type: "portability"
38 changes: 21 additions & 17 deletions recipes/freealut/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get
from conan.tools.files import copy, get, rm, rmdir
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.61"
required_conan_version = ">=1.54"

class FreeAlutConan(ConanFile):
name = "freealut"
description = "freealut is a free implementation of OpenAL's ALUT standard."
topics = ("freealut", "openal", "audio", "api")
topics = ("openal", "audio", "api")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://directory.fsf.org/wiki/Freealut"
homepage = "https://openal.org"
license = "LGPL-2.0-or-later"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -24,9 +23,6 @@ class FreeAlutConan(ConanFile):
"fPIC": True
}

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
Expand All @@ -37,12 +33,12 @@ def configure(self):
self.options["openal-soft"].shared = True
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def validate(self):
if self.options.shared and \
(not self.dependencies["openal-soft"].options.shared):
not self.dependencies["openal-soft"].options.shared:
raise ConanInvalidConfiguration(
"If built as shared openal-soft must be shared as well. "
"If built as shared openal-soft must be shared as well. "
"Please, use `openal-soft/*:shared=True`.",
)

Expand All @@ -54,15 +50,19 @@ def requirements(self):

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
apply_conandata_patches(self)

def generate(self):
tc = CMakeDeps(self)
tc.generate()
tc = CMakeToolchain(self)
# Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840)
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0003"] = "NEW"
tc.variables["BUILD_STATIC"] = not self.options.shared
# INFO: CMakeDeps generates CamelCase variables
tc.variables["OPENAL_LIB_DIR"] = os.path.join(self.dependencies["openal-soft"].package_folder, "lib")
tc.variables["OPENAL_INCLUDE_DIR"] = os.path.join(self.dependencies["openal-soft"].package_folder, "include")
tc.generate()
CMakeDeps(self).generate()

def build(self):
cmake = CMake(self)
Expand All @@ -73,9 +73,13 @@ def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
if not self.options.shared:
rm(self, "*.so*", os.path.join(self.package_folder, "lib"))

def package_info(self):
self.cpp_info.libs = ['alut']
self.cpp_info.includedirs.append(os.path.join("include", "AL"))
if(not self.options.shared):
self.cpp_info.defines.append("ALUT_LIBTYPE_STATIC")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs = ["m", "pthread"]
if self.options.shared:
self.cpp_info.defines.append("ALUT_BUILD_LIBRARY")

This file was deleted.

98 changes: 0 additions & 98 deletions recipes/freealut/all/patches/harmonize-static-lib-build.patch

This file was deleted.

2 changes: 1 addition & 1 deletion recipes/freealut/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES C)

find_package(FreeAlut REQUIRED)
find_package(freealut REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE freealut::freealut)

0 comments on commit b671bfb

Please sign in to comment.