Skip to content

Commit

Permalink
(#24893) magic_enum/0.9.6: create package using CMake install target
Browse files Browse the repository at this point in the history
  • Loading branch information
nine committed Aug 11, 2024
1 parent 7f77323 commit 48b5714
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 15 additions & 5 deletions recipes/magic_enum/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
from conan.tools.files import copy, get, rmdir
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.scm import Version
import os

Expand Down Expand Up @@ -39,7 +39,7 @@ def _compilers_minimum_version(self):
}

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

Check failure on line 42 in recipes/magic_enum/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

layout is missing `src_folder` argument which should be to `src`

def package_id(self):
self.info.clear()
Expand All @@ -56,12 +56,22 @@ def validate(self):
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()

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

def package(self):
copy(self, "*", src=os.path.join(self.source_folder, "include/magic_enum"), dst=os.path.join(self.package_folder, "include"))
cmake = CMake(self)
cmake.install()
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "magic_enum")
Expand Down
4 changes: 0 additions & 4 deletions recipes/magic_enum/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ find_package(magic_enum REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE magic_enum::magic_enum)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)

if(magic_enum_VERSION VERSION_EQUAL "0.9.4")
target_compile_definitions(${PROJECT_NAME} PRIVATE MAGIC_ENUM_INCLUDE_WITH_FOLDER)
endif()

0 comments on commit 48b5714

Please sign in to comment.