-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement the initial version of the recipe * Update license to MIT instead of direct link Co-authored-by: Chris Mc <[email protected]> * Update the test recipe Co-authored-by: Chris Mc <[email protected]> * Make improvements based on review comments * Remove the option to build samples * Set the C++ standard of the test package Co-authored-by: Chris Mc <[email protected]> * Rework the options * Make improvements based on the reviews * Make a certain version CMake a build requirement * Check compiler-eligibility the right way Co-authored-by: ZombieRaccoon <[email protected]> Co-authored-by: Chris Mc <[email protected]>
- Loading branch information
1 parent
8ce42d2
commit 99b933b
Showing
7 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(cmake_wrapper LANGUAGES CXX) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"3.3": | ||
sha256: "b58a8c4fc4128a880471d708ba5b0c7f4389645265c53803824b10d9a4255ec5" | ||
url: "https://github.com/mikke89/RmlUi/archive/3.3.zip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
|
||
class RmluiConan(ConanFile): | ||
name = "rmlui" | ||
description = "RmlUi - The HTML/CSS User Interface Library Evolved" | ||
homepage = "https://github.com/mikke89/RmlUi" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
license = "MIT" | ||
topics = ("conan", "css", "gui", "html", "lua", "rmlui") | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"enable_rtti_and_exceptions": [True, False], | ||
"font_interface": ["freetype", None], | ||
"fPIC": [True, False], | ||
"shared": [True, False], | ||
"with_lua_bindings": [True, False], | ||
"with_thirdparty_containers": [True, False] | ||
} | ||
default_options = { | ||
"enable_rtti_and_exceptions": True, | ||
"font_interface": "freetype", | ||
"fPIC": True, | ||
"shared": False, | ||
"with_lua_bindings": False, | ||
"with_thirdparty_containers": True | ||
} | ||
build_requires = ["cmake/3.20.0"] | ||
exports_sources = ["CMakeLists.txt"] | ||
generators = ["cmake", "cmake_find_package"] | ||
|
||
@property | ||
def _minimum_compilers_version(self): | ||
# Reference: https://en.cppreference.com/w/cpp/compiler_support/14 | ||
return { | ||
"apple-clang": "5.1", | ||
"clang": "3.4", | ||
"gcc": "5", | ||
"intel": "17", | ||
"sun-cc": "5.15", | ||
"Visual Studio": "15" | ||
} | ||
|
||
@property | ||
def _minimum_cpp_standard(self): | ||
return 14 | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, self._minimum_cpp_standard) | ||
min_version = self._minimum_compilers_version.get( | ||
str(self.settings.compiler)) | ||
if not min_version: | ||
self.output.warn("{} recipe lacks information about the {} compiler support.".format( | ||
self.name, self.settings.compiler)) | ||
else: | ||
if tools.Version(self.settings.compiler.version) < min_version: | ||
raise ConanInvalidConfiguration("{} requires C++{} support. The current compiler {} {} does not support it.".format( | ||
self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)) | ||
|
||
def requirements(self): | ||
if self.options.font_interface == "freetype": | ||
self.requires("freetype/2.10.1") | ||
|
||
if self.options.with_lua_bindings: | ||
self.requires("lua/5.3.5") | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], | ||
destination=self._source_subfolder, strip_root=True) | ||
|
||
def _configure_cmake(self): | ||
if not hasattr(self, "_cmake"): | ||
self._cmake = CMake(self) | ||
self._cmake.definitions["BUILD_LUA_BINDINGS"] = self.options.with_lua_bindings | ||
self._cmake.definitions["BUILD_SAMPLES"] = False | ||
self._cmake.definitions["DISABLE_RTTI_AND_EXCEPTIONS"] = not self.options.enable_rtti_and_exceptions | ||
self._cmake.definitions["ENABLE_PRECOMPILED_HEADERS"] = True | ||
self._cmake.definitions["ENABLE_TRACY_PROFILING"] = False | ||
self._cmake.definitions["NO_FONT_INTERFACE_DEFAULT"] = self.options.font_interface is None | ||
self._cmake.definitions["NO_THIRDPARTY_CONTAINERS"] = not self.options.with_thirdparty_containers | ||
|
||
self._cmake.configure() | ||
|
||
return self._cmake | ||
|
||
def _patch_sources(self): | ||
# The *.cmake files that conan generates using cmake_find_package for CMake's find_package to consume use | ||
# different variable naming than described in CMake's documentation, thus the need for most of the replacements. | ||
# References: | ||
# * https://cmake.org/cmake/help/latest/module/FindFreetype.html | ||
# * https://cmake.org/cmake/help/latest/module/FindLua.html | ||
replace_mapping = { | ||
"FREETYPE_FOUND": "Freetype_FOUND", | ||
"FREETYPE_INCLUDE_DIRS": "Freetype_INCLUDE_DIRS", | ||
"FREETYPE_LINK_DIRS": "Freetype_LINK_DIRS", | ||
"FREETYPE_LIBRARY": "Freetype_LIBRARIES", | ||
"LUA_FOUND": "lua_FOUND", | ||
"LUA_INCLUDE_DIR": "lua_INCLUDE_DIR", | ||
"LUA_LIBRARIES": "lua_LIBRARIES", | ||
# disables the built-in generation of package configuration files | ||
"if(PkgHelpers_AVAILABLE)": "if(FALSE)" | ||
} | ||
|
||
cmakelists_path = os.path.join( | ||
self._source_subfolder, "CMakeLists.txt") | ||
|
||
for key, value in replace_mapping.items(): | ||
tools.replace_in_file(cmakelists_path, key, value) | ||
|
||
def build(self): | ||
self._patch_sources() | ||
self._configure_cmake().build() | ||
|
||
def package(self): | ||
self._configure_cmake().install() | ||
self.copy("LICENSE", dst="licenses", src=self._source_subfolder) | ||
|
||
def package_info(self): | ||
if not self.options.enable_rtti_and_exceptions: | ||
self.cpp_info.defines.append("RMLUI_USE_CUSTOM_RTTI") | ||
|
||
if not self.options.shared: | ||
self.cpp_info.defines.append("RMLUI_STATIC_LIB") | ||
|
||
if not self.options.with_thirdparty_containers: | ||
self.cpp_info.defines.append("RMLUI_NO_THIRDPARTY_CONTAINERS") | ||
|
||
self.cpp_info.libs.append("RmlDebugger") | ||
|
||
if self.options.with_lua_bindings: | ||
self.cpp_info.libs.append("RmlControlsLua") | ||
self.cpp_info.libs.append("RmlControls") | ||
|
||
if self.options.with_lua_bindings: | ||
self.cpp_info.libs.append("RmlCoreLua") | ||
self.cpp_info.libs.append("RmlCore") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(example example.cpp) | ||
target_link_libraries(example ${CONAN_LIBS}) | ||
set_property(TARGET example PROPERTY CXX_STANDARD 14) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class ConanRmluiTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join("bin", "example") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <RmlUi/Core.h> | ||
|
||
int main() | ||
{ | ||
Rml::Core::Shutdown(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"3.3": | ||
folder: "3.3" |