Skip to content

Commit

Permalink
(#16044) lodepng: modernize more for conan v2
Browse files Browse the repository at this point in the history
* modernize more

* add libm to system libs
  • Loading branch information
SpaceIm authored Mar 10, 2023
1 parent 01ae136 commit 90e2487
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 9 additions & 7 deletions recipes/lodepng/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
import os

required_conan_version = ">=1.47.0"
required_conan_version = ">=1.53.0"


class LodepngConan(ConanFile):
Expand All @@ -16,6 +16,7 @@ class LodepngConan(ConanFile):
homepage = "https://github.com/lvandeve/lodepng"
url = "https://github.com/conan-io/conan-center-index"

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -34,18 +35,17 @@ def config_options(self):

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

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

def validate(self):
if self.options.shared and is_msvc(self) and is_msvc_static_runtime(self):
raise ConanInvalidConfiguration("lodepng shared doesn't support Visual Studio with static runtime")

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

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

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -64,3 +64,5 @@ def package(self):

def package_info(self):
self.cpp_info.libs = ["lodepng"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
11 changes: 6 additions & 5 deletions recipes/lodepng/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"

def requirements(self):
self.requires(self.tested_reference_str)
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 not cross_building(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
bees = os.path.join(self.source_folder, "bees.png")
self.run(f"{bin_path} {bees}", env="conanrun")
9 changes: 3 additions & 6 deletions recipes/lodepng/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)
project(test_package)

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

find_package(lodepng REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE lodepng::lodepng)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)

0 comments on commit 90e2487

Please sign in to comment.