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

fpng: add recipe #22823

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

fpng: add recipe #22823

wants to merge 9 commits into from

Conversation

toge
Copy link
Contributor

@toge toge commented Feb 19, 2024

Specify library name and version: fpng/*


@conan-center-bot

This comment has been minimized.

@AbrilRBS AbrilRBS self-assigned this Feb 20, 2024
#include "fpng.h"

int main() {
fpng::fpng_init();
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@valgur
Thanks a lot!
Fixed.

recipes/fpng/all/CMakeLists.txt Outdated Show resolved Hide resolved
recipes/fpng/all/conanfile.py Outdated Show resolved Hide resolved
toge and others added 3 commits March 20, 2024 20:59
Co-authored-by: Martin Valgur <[email protected]>
Co-authored-by: Martin Valgur <[email protected]>
@conan-center-bot

This comment has been minimized.


def generate(self):
tc = CMakeToolchain(self)
tc.variables["FPNG_SRC_DIR"] = self.source_folder.replace("\\", "/")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not worth changing it here, but I generally find it easier to

def export_sources(self):
    copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))

That way all of the CMakeLists.txt and source paths work without any prefixing.

The current approach is not wrong either, though, of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@valgur
Sorry for my late response.

I tried your comment, but I failed.
Are there any misunderstandings in my modification?

Error message is following.

fpng/1.0.6: Running CMake.configure()
fpng/1.0.6: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/toge/.conan2/p/b/fpng8db6eab8b7baf/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/toge/.conan2/p/b/fpng8db6eab8b7baf/b/src"
CMake Warning:
  Ignoring extra path from command line:

   "/home/toge/.conan2/p/b/fpng8db6eab8b7baf/b/src"


CMake Error: The source directory "/home/toge/.conan2/p/b/fpng8db6eab8b7baf/b/src" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

modified conanfile.py

``` from conan import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.files import get, save, load, copy, rm from conan.tools.build import check_min_cppstd import os

required_conan_version = ">=1.53.0"

class FpngConan(ConanFile):
name = "fpng"
description = "Super fast C++ .PNG writer/reader"
license = "Unlicense",
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/richgel999/fpng"
topics = ("png", "writer", "reader")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_sse": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_sse": True,
}

def export_sources(self):
    copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, "src"))

def config_options(self):
    if self.settings.os == "Windows":
        del self.options.fPIC

def configure(self):
    if self.options.shared:
        self.options.rm_safe("fPIC")

def layout(self):
    cmake_layout(self, src_folder="src")

def validate(self):
    check_min_cppstd(self, 11)

def source(self):
    get(self, **self.conan_data["sources"][self.version], strip_root=True)
    # remove original CMakeLists.txt (which builds a test program only)
    rm(self, "CMakeLists.txt", self.source_folder)

def generate(self):
    tc = CMakeToolchain(self)
    tc.variables["FPNG_WITH_SSE"] = self.options.with_sse
    tc.generate()

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

def package(self):
    filename = os.path.join(self.source_folder, "src", "fpng.cpp")
    file_content = load(self, filename)
    license_start = "	This is free and unencumbered software"
    license_end = "*/"
    license_contents = file_content[file_content.find(license_start):file_content.find(license_end)]
    save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), license_contents)
    cmake = CMake(self)
    cmake.install()

def package_info(self):
    self.cpp_info.libs = ["fpng"]
    if self.settings.os in ("FreeBSD", "Linux"):
        self.cpp_info.system_libs = ["m"]
</details>

@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

All green in build 4 (848de399f8c095159a1cb48fae9fc4e49ed22c07):

  • fpng/1.0.6:
    All packages built successfully! (All logs)

Conan v2 pipeline ✔️

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

All green in build 4 (848de399f8c095159a1cb48fae9fc4e49ed22c07):

  • fpng/1.0.6:
    All packages built successfully! (All logs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants