diff --git a/features/environment/buildrunenv/conanfile.py b/features/environment/buildrunenv/conanfile.py new file mode 100644 index 00000000..b5496ac1 --- /dev/null +++ b/features/environment/buildrunenv/conanfile.py @@ -0,0 +1,57 @@ +from conans import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake + + +class HelloConan(ConanFile): + name = "hello" + version = "0.1" + + # Optional metadata + license = "" + author = " " + url = "" + description = "" + topics = ("", "", "") + + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "src/*" + + requires = "openssl/1.1.1k" + build_requires = "cmake/3.19.8" + + def build_requirements(self): + self.build_requires("gtest/1.11.0", force_host_context=True) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + self.folders.source = "src" + self.folders.build = "build/{}".format(self.settings.build_type) + self.folders.generators = "build/generators" + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + self.copy("*.h", dst="include") + self.copy("*.lib", dst="lib", keep_path=False) + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.dylib*", dst="lib", keep_path=False) + self.copy("*.so", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["hello"] diff --git a/features/environment/buildrunenv/src/CMakeLists.txt b/features/environment/buildrunenv/src/CMakeLists.txt new file mode 100644 index 00000000..cc1a157c --- /dev/null +++ b/features/environment/buildrunenv/src/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.15) +project(hello CXX) + +message(STATUS "CMAKE VERSION = ${CMAKE_VERSION}!!!") + +add_library(hello hello.cpp) diff --git a/features/environment/buildrunenv/src/hello.cpp b/features/environment/buildrunenv/src/hello.cpp new file mode 100644 index 00000000..84bebe06 --- /dev/null +++ b/features/environment/buildrunenv/src/hello.cpp @@ -0,0 +1,14 @@ +#include +#include "hello.h" + +void hello(){ + std::cout << hello_str(); +} + +std::string hello_str(){ + #ifdef NDEBUG + return "hello/0.1: Hello World Release!\n"; + #else + return "hello/0.1: Hello World Debug!\n"; + #endif +} \ No newline at end of file diff --git a/features/environment/buildrunenv/src/hello.h b/features/environment/buildrunenv/src/hello.h new file mode 100644 index 00000000..f77ecf53 --- /dev/null +++ b/features/environment/buildrunenv/src/hello.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +#ifdef WIN32 + #define hello_EXPORT __declspec(dllexport) +#else + #define hello_EXPORT +#endif + +hello_EXPORT void hello(); +hello_EXPORT std::string hello_str(); diff --git a/features/environment/buildrunenv/src/test.cpp b/features/environment/buildrunenv/src/test.cpp new file mode 100644 index 00000000..fe762a53 --- /dev/null +++ b/features/environment/buildrunenv/src/test.cpp @@ -0,0 +1,10 @@ +#include +#include "hello.h" + +void hello(){ + #ifdef NDEBUG + std::cout << "hello/0.1: Hello World Release!" <