Skip to content

Commit

Permalink
(#17505) Add seadex-genesis library recipe - Conan 2 ready
Browse files Browse the repository at this point in the history
* Add seadex-genesis library recipe

* Update recipes/seadex-genesis/all/test_package/CMakeLists.txt

* Make seadex-essentials transitive

* Removed header only requirement flag for fmt, spdlog

* Use fmt 10.0.0 because of PR #17976

---------

Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
  • Loading branch information
Seadex-GmbH and czoido authored Jul 6, 2023
1 parent 10e8014 commit 6b6f154
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 0 deletions.
5 changes: 5 additions & 0 deletions recipes/seadex-genesis/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sources:
"2.0.0":
url:
- "https://github.com/SeadexGmbH/genesis/archive/refs/tags/2.0.0.tar.gz"
sha256: "22bd4e438c1475d7b023d6f8f7d541f49f55784c89e8607acc68a73157bb4ea4"
92 changes: 92 additions & 0 deletions recipes/seadex-genesis/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.microsoft import check_min_vs, is_msvc
from conan.tools.files import get, copy
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os

required_conan_version = ">=1.53.0"

class SeadexGenesisConan(ConanFile):
name = "seadex-genesis"
description = "genesis is a generator library developed by Seadex (written in C++11)."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://genesis.seadex.de/"
topics = ("generator", "c++")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": True
}

@property
def _min_cppstd(self):
return 17

@property
def _compilers_minimum_version(self):
return {
"gcc": "8.3",
"clang": "12",
"Visual Studio": "16",
"msvc": "192",
"apple-clang": "10"
}

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 requirements(self):
# Exposes headers and symbols: https://github.com/SeadexGmbH/genesis/blob/master/genesis/source/version.cpp
self.requires("fmt/10.0.0", transitive_headers=True, transitive_libs=True)
self.requires("seadex-essentials/2.1.3", transitive_headers=True, transitive_libs=True)

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

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

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
check_min_vs(self, 192)
if not is_msvc(self):
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
if is_msvc(self) and self.options.shared:
raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.")

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["GEN_BUILD_EXAMPLES"] = False
tc.generate()

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

def package(self):
copy(self, "LICENSE.md", self.source_folder, os.path.join(self.package_folder, "licenses") )
cmake = CMake(self)
cmake.configure()
cmake.install()

def package_info(self):
self.cpp_info.libs = ["genesis"]
7 changes: 7 additions & 0 deletions recipes/seadex-genesis/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(seadex-genesis REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC seadex-genesis::seadex-genesis)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
31 changes: 31 additions & 0 deletions recipes/seadex-genesis/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

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

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

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
11 changes: 11 additions & 0 deletions recipes/seadex-genesis/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>

#include "genesis/grammar.hpp"


int main() {

std::cout<< sx::genesis::LOOP_START_COMMAND << " test " << sx::genesis::LOOP_END_COMMAND << std::endl;

return EXIT_SUCCESS;
}
8 changes: 8 additions & 0 deletions recipes/seadex-genesis/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)

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

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
19 changes: 19 additions & 0 deletions recipes/seadex-genesis/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os


# legacy validation with Conan 1.x
class TestPackageV1Conan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

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

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
3 changes: 3 additions & 0 deletions recipes/seadex-genesis/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.0.0":
folder: all

0 comments on commit 6b6f154

Please sign in to comment.