diff --git a/recipes/chaiscript/all/CMakeLists.txt b/recipes/chaiscript/all/CMakeLists.txt new file mode 100644 index 0000000000000..a7a84f24be646 --- /dev/null +++ b/recipes/chaiscript/all/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.4) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +if (WIN32 AND BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif(WIN32 AND BUILD_SHARED_LIBS) + +add_subdirectory("source_subfolder") diff --git a/recipes/chaiscript/all/conandata.yml b/recipes/chaiscript/all/conandata.yml new file mode 100644 index 0000000000000..f00f973637251 --- /dev/null +++ b/recipes/chaiscript/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "6.1.0": + sha256: 3ca9ba6434b4f0123b5ab56433e3383b01244d9666c85c06cc116d7c41e8f92a + url: https://github.com/ChaiScript/ChaiScript/archive/v6.1.0.tar.gz diff --git a/recipes/chaiscript/all/conanfile.py b/recipes/chaiscript/all/conanfile.py new file mode 100644 index 0000000000000..00f73ebe996c7 --- /dev/null +++ b/recipes/chaiscript/all/conanfile.py @@ -0,0 +1,80 @@ +from conans import ConanFile, CMake, tools +import os + + +class ChaiScriptConan(ConanFile): + name = "chaiscript" + homepage = "https://github.com/ChaiScript/ChaiScript" + description = "Embedded Scripting Language Designed for C++." + topics = ("conan", "embedded-scripting-language", "language") + url = "https://github.com/conan-io/conan-center-index" + license = "BSD-3-Clause" + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + settings = "os", "compiler", "build_type", "arch" + options = {"fPIC": [True, False], "dyn_load": [True, False], "use_std_make_shared": [True, False], + "multithread_support": [True, False], + "header_only": [True, False]} + default_options = {"fPIC": True, "dyn_load": True, + "use_std_make_shared": True, + "multithread_support": True, + "header_only": True} + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = "ChaiScript-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def _configure_cmake(self): + cmake = CMake(self) + cmake.definitions["BUILD_TESTING"] = False + cmake.definitions["BUILD_SAMPLES"] = False + cmake.definitions["BUILD_MODULES"] = True + cmake.definitions["USE_STD_MAKE_SHARED"] = self.options.use_std_make_shared + cmake.definitions["DYNLOAD_ENABLED"] = self.options.dyn_load + cmake.definitions["MULTITHREAD_SUPPORT_ENABLED"] = self.options.multithread_support + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + if not self.options.header_only: + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + if self.options.header_only: + self.copy(pattern="*.hpp", dst="include", + src=os.path.join(self._source_subfolder, 'include')) + else: + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_id(self): + if self.options.header_only: + self.info.header_only() + + def package_info(self): + if not self.options.header_only: + self.cpp_info.libs = tools.collect_libs(self) + if self.options.use_std_make_shared: + self.cpp_info.defines.append("CHAISCRIPT_USE_STD_MAKE_SHARED") + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["dl"] + if self.options.multithread_support: + self.cpp_info.system_libs.append("pthread") diff --git a/recipes/chaiscript/all/test_package/CMakeLists.txt b/recipes/chaiscript/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fdab2aae72151 --- /dev/null +++ b/recipes/chaiscript/all/test_package/CMakeLists.txt @@ -0,0 +1,15 @@ +project(test_package CXX) +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_VERBOSE_MAKEFILE ON) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(chaiscript REQUIRED CONFIG) + +# TEST_PACKAGE ################################################################# + +add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} CONAN_PKG::chaiscript) +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14) diff --git a/recipes/chaiscript/all/test_package/conanfile.py b/recipes/chaiscript/all/test_package/conanfile.py new file mode 100644 index 0000000000000..4d0099777a2a9 --- /dev/null +++ b/recipes/chaiscript/all/test_package/conanfile.py @@ -0,0 +1,15 @@ +import os +from conans import ConanFile, CMake + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake_find_package_multi", "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + self.run(os.path.join("bin", "test_package"), run_environment=True) diff --git a/recipes/chaiscript/all/test_package/test_package.cpp b/recipes/chaiscript/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..4dc5f93e03a5a --- /dev/null +++ b/recipes/chaiscript/all/test_package/test_package.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +double chai_add(double i, double j) +{ + return i + j; +} + +int main() +{ + chaiscript::ChaiScript chai; + chai.add(chaiscript::fun(&chai_add), "add"); + const auto answer = chai.eval("add(38.8, 3.2);"); + assert(static_cast(answer) == 42); + std::cout << "The answer is: " << answer << '\n'; +} diff --git a/recipes/chaiscript/config.yml b/recipes/chaiscript/config.yml new file mode 100644 index 0000000000000..6acad5b8e7fd8 --- /dev/null +++ b/recipes/chaiscript/config.yml @@ -0,0 +1,4 @@ +--- +versions: + "6.1.0": + folder: all