Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STLab] upgrade version to 1.7.1 #13048

Merged
merged 85 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
21467c9
[STLab] upgrade to 1.7.0
fpelliccioni Sep 20, 2022
3ab6af6
fix
fpelliccioni Sep 20, 2022
e35356e
fix
fpelliccioni Sep 21, 2022
4dce302
fix
fpelliccioni Sep 21, 2022
bc5e68f
fix
fpelliccioni Sep 21, 2022
5952797
fix
fpelliccioni Sep 21, 2022
26cf513
fix
fpelliccioni Sep 21, 2022
dd411e5
fix
fpelliccioni Sep 21, 2022
4ca7637
version 1.7.1
fpelliccioni Sep 26, 2022
48e1ec8
fixes
fpelliccioni Sep 26, 2022
b3e3495
fix test recipe
fpelliccioni Sep 26, 2022
be16a32
fix test recipe
fpelliccioni Sep 26, 2022
83d5278
uses cmake v23
fpelliccioni Sep 26, 2022
e4051c4
fixes
fpelliccioni Sep 26, 2022
2d37212
adds short_paths = True
fpelliccioni Sep 27, 2022
6cc5b14
remove share folder
fpelliccioni Sep 27, 2022
34e3779
temp removal of old files
fpelliccioni Sep 27, 2022
aeddbc3
fix text package
fpelliccioni Sep 28, 2022
dc9a196
fix
fpelliccioni Sep 28, 2022
ed524d8
skip coying systems libs
fpelliccioni Sep 28, 2022
649e2f9
NOMINMAX
fpelliccioni Sep 28, 2022
fe0377c
fix
fpelliccioni Sep 28, 2022
30719d1
fix
fpelliccioni Sep 28, 2022
324f505
define NOMINMAX on conan recipe
fpelliccioni Sep 28, 2022
9484323
now try all the versions
fpelliccioni Sep 28, 2022
e1a10ba
fix
fpelliccioni Sep 28, 2022
11506bf
remove old versions (temp)
fpelliccioni Sep 28, 2022
a9762a8
remove old versions (temp)
fpelliccioni Sep 28, 2022
7bcef41
rollback
fpelliccioni Sep 28, 2022
427151a
fixes
fpelliccioni Sep 28, 2022
4715413
fix
fpelliccioni Sep 28, 2022
a1fcf66
fix
fpelliccioni Sep 28, 2022
cf81d57
fix
fpelliccioni Sep 28, 2022
f7ae5dc
fix
fpelliccioni Sep 28, 2022
241028a
Update recipes/absent/all/conanfile.py
fpelliccioni Sep 28, 2022
a4f8d58
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
cca2888
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
2f8385a
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
92276e7
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
804809c
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
d3c9d17
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
915695b
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Sep 30, 2022
738e865
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Oct 3, 2022
d042566
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Oct 3, 2022
43c8f2d
Update recipes/stlab/1.7.0_and_above/conanfile.py
fpelliccioni Oct 3, 2022
03b4fc0
with_boost
fpelliccioni Oct 3, 2022
5b07f24
Merge branch 'feat/upgrade-stlab' of github.com:fpelliccioni/conan-ce…
fpelliccioni Oct 3, 2022
2148dff
no test option
fpelliccioni Oct 3, 2022
ba5ecf8
fix
fpelliccioni Oct 3, 2022
00eafe6
Trigger notification
fpelliccioni Nov 8, 2022
384802f
fix
fpelliccioni Nov 24, 2022
5fe8d4a
Merge branch 'master' into feat/upgrade-stlab
fpelliccioni Nov 25, 2022
eba3a47
fixes
fpelliccioni Nov 25, 2022
92e3915
fixes 2
fpelliccioni Nov 25, 2022
111a3b3
Update recipes/bertrand/all/conanfile.py
fpelliccioni Nov 25, 2022
bdf7347
fixes 3
fpelliccioni Nov 25, 2022
f3e1082
Merge branch 'feat/upgrade-stlab' of github.com:fpelliccioni/conan-ce…
fpelliccioni Nov 25, 2022
c3dd0ff
Trigger notification
fpelliccioni Nov 29, 2022
c68bf7d
fix linting
fpelliccioni Nov 30, 2022
b08669e
fix linting
fpelliccioni Nov 30, 2022
c6ad438
remove dead code
fpelliccioni Dec 1, 2022
e69043b
Update recipes/stlab/old/conandata.yml
fpelliccioni Dec 2, 2022
7bb7d41
Update recipes/stlab/old/conandata.yml
fpelliccioni Dec 10, 2022
fb27191
Update recipes/stlab/old/conanfile.py
fpelliccioni Dec 10, 2022
20829d0
remove dead code
fpelliccioni Dec 10, 2022
f61f261
fix linter warnings
fpelliccioni Dec 14, 2022
27f1840
Update recipes/stlab/all/conanfile.py
fpelliccioni Dec 14, 2022
0eb14ad
reduce nesting
fpelliccioni Dec 14, 2022
c1ca053
Update recipes/stlab/old/conanfile.py
fpelliccioni Dec 15, 2022
d53741e
Update recipes/stlab/old/conanfile.py
fpelliccioni Dec 15, 2022
fc464ae
review suggestions
fpelliccioni Dec 15, 2022
2badd60
set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP
fpelliccioni Dec 15, 2022
9e7af4a
test things
fpelliccioni Dec 15, 2022
d877434
remove Windows runtime libs
fpelliccioni Jan 4, 2023
92bfa4e
Update conanfile.py
fpelliccioni Mar 29, 2023
ec898c0
Refactoring and fixing errors
franramirez688 Jun 22, 2023
729f173
putting self.ref instead of self.name
franramirez688 Jun 22, 2023
0796e5e
suggestions
franramirez688 Jun 22, 2023
1026f67
Removed old versions
franramirez688 Jun 22, 2023
d1d77e4
Merge branch 'master' into feat/upgrade-stlab
franramirez688 Jun 23, 2023
6e3d4f7
Added new CMake var
franramirez688 Jun 23, 2023
47daf9a
Merge branch 'master' into feat/upgrade-stlab
franramirez688 Jun 25, 2023
a4e1c17
Merge branch 'master' into feat/upgrade-stlab
franramirez688 Jun 26, 2023
ff737fe
Update recipes/stlab/all/conanfile.py
AbrilRBS Jun 26, 2023
58ba859
Update conanfile.py
fpelliccioni Jun 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions recipes/stlab/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
sources:
"1.6.2":
url: "https://github.com/stlab/libraries/archive/v1.6.2.tar.gz"
sha256: "d0369d889c7bf78068d0c4f4b5125d7e9fe9abb0ad7a3be35bf13b6e2c271676"
"1.5.6":
url: "https://github.com/stlab/libraries/archive/refs/tags/v1.5.6.tar.gz"
sha256: "a6b788848be637b6d6c471de76c38486789e708997648e9b9731fdb5a631030c"
"1.5.5":
url: "https://github.com/stlab/libraries/archive/v1.5.5.tar.gz"
sha256: "30ec5a36b4c074feac72a1b9a744f0b279010e18c7bb04bbdc5d44fe9eaf5ad8"
"1.5.4":
url: "https://github.com/stlab/libraries/archive/v1.5.4.tar.gz"
sha256: "87306f58f6614f4a1ca54dda52fedff7e610d3b3dae035829657bac77bc33640"
"1.5.2":
url: https://github.com/stlab/libraries/archive/v1.5.2.tar.gz
sha256: a82eb013e51d0bb3ee2050f0eda31e11997cb4ca74d2abfdc2c8249c5c67c9fb
"1.7.1":
url: "https://github.com/stlab/libraries/archive/refs/tags/v1.7.1.tar.gz"
sha256: "0160b5f7be7d423100a9a8b205a99285b106dd438f806978028a82b9f01c6b64"
263 changes: 131 additions & 132 deletions recipes/stlab/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,180 +1,179 @@
from conans import ConanFile, tools
from conans.tools import Version
from conans.errors import ConanInvalidConfiguration
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd, cross_building
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rm, rmdir
from conan.tools.microsoft import check_min_vs, is_msvc
from conan.tools.scm import Version

required_conan_version = ">=1.52.0"


class Stlab(ConanFile):
name = 'stlab'
description = 'The Software Technology Lab libraries.'
url = 'https://github.com/conan-io/conan-center-index'
homepage = 'https://github.com/stlab/libraries'
license = 'BSL-1.0'
topics = 'conan', 'c++', 'concurrency', 'futures', 'channels'

settings = "arch", "os", "compiler", "build_type",

topics = 'concurrency', 'futures', 'channels'
settings = "arch", "os", "compiler", "build_type",
options = {
"boost_optional": [True, False],
"boost_variant": [True, False],
"coroutines": [True, False],
"task_system": ["portable", "libdispatch", "emscripten", "pnacl", "windows", "auto"],
"with_boost": [True, False],
"no_std_coroutines": [True, False],
"future_coroutines": [True, False],
franramirez688 marked this conversation as resolved.
Show resolved Hide resolved
"task_system": ["portable", "libdispatch", "emscripten", "pnacl", "windows"],
"thread_system": ["win32", "pthread", "pthread-emscripten", "pthread-apple", "none"],
}

default_options = {
"boost_optional": False,
"boost_variant": False,
"coroutines": False,
"task_system": "auto",
"with_boost": False,
"no_std_coroutines": True,
"future_coroutines": False
# Handle default value for `thread_system` in `config_options` method
# Handle default value for `task_system` in `config_options` method
}
package_type = "header-library"
short_paths = True

no_copy_source = True
_source_subfolder = 'source_subfolder'
def config_options(self):
self.options.thread_system = {"Macos": "pthread-apple",
"Linux": "pthread",
"Windows": "win32",
"Emscripten": "pthread-emscripten"}.get(str(self.settings.os), "none")
self.options.task_system = {"Macos": "libdispatch",
"Windows": "windows"}.get(str(self.settings.os), "portable")

def _use_boost(self):
return self.options.boost_optional or self.options.boost_variant
@property
def _minimum_cpp_standard(self):
return 17

def _requires_libdispatch(self):
# On macOS it is not necessary to use the libdispatch conan package, because the library is
# included in the OS.
return self.options.task_system == "libdispatch" and self.settings.os != "Macos"
@property
def _compilers_minimum_version(self):
return {"gcc": "9",
"clang": "8",
"apple-clang": "13"}

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

def build_requirements(self):
self.tool_requires("cmake/[>=3.23.3]")

def requirements(self):
if self._use_boost():
self.requires("boost/1.75.0")
if self.options.with_boost:
self.requires("boost/1.82.0")

if self._requires_libdispatch():
# On macOS, it is not necessary to use the libdispatch conan package, because the library is
# included in the OS.
if self.options.task_system == "libdispatch" and self.settings.os != "Macos":
self.requires("libdispatch/5.3.2")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "libraries-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _fix_boost_components(self):
if self.settings.os != "Macos": return
if self.settings.compiler != "apple-clang": return
if Version(self.settings.compiler.version) >= "12": return

#
# On Apple we have to force the usage of boost.variant, because Apple's implementation of C++17 is not complete.
#
self.output.info("Apple-Clang versions less than 12 do not correctly support std::optional or std::variant, so we will use boost::optional and boost::variant instead.")
self.options.boost_optional = True
self.options.boost_variant = True

def _default_task_system(self):
if self.settings.os == "Macos":
return "libdispatch"

if self.settings.os == "Windows":
return "windows"

if self.settings.os == "Emscripten":
return "emscripten"
prince-chrismc marked this conversation as resolved.
Show resolved Hide resolved

return "portable"

def _validate_task_system_libdispatch(self):
if self.settings.os == "Linux":
if self.settings.compiler != "clang":
raise ConanInvalidConfiguration("{}/{} task_system=libdispatch needs Clang compiler when using OS: {}. Use Clang compiler or switch to task_system=portable or task_system=auto".format(self.name, self.version, self.settings.os))
elif self.settings.os != "Macos":
raise ConanInvalidConfiguration("{}/{} task_system=libdispatch is not supported on {}. Try using task_system=auto".format(self.name, self.version, self.settings.os))

def _validate_task_system_windows(self):
if self.settings.os != "Windows":
self.output.info("Libdispatch is not supported on {}. The task system is changed to {}.".format(self.settings.os, self.options.task_system))
raise ConanInvalidConfiguration("{}/{} task_system=windows is not supported on {}. Try using task_system=auto".format(self.name, self.version, self.settings.os))

def _validate_task_system_emscripten(self):
if self.settings.os != "Emscripten":
raise ConanInvalidConfiguration("{}/{} task_system=emscripten is not supported on {}. Try using task_system=auto".format(self.name, self.version, self.settings.os))
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)

def _validate_task_system(self):
if self.options.task_system == "libdispatch":
self._validate_task_system_libdispatch()
elif self.options.task_system == "windows":
self._validate_task_system_windows()
elif self.options.task_system == "emscripten":
self._validate_task_system_emscripten()
if self.settings.os == "Linux" and self.settings.compiler != "clang":
raise ConanInvalidConfiguration(f"{self.ref} task_system=libdispatch needs Clang compiler when using OS: {self.settings.os}."
f" Use Clang compiler or switch to task_system=portable")
elif self.settings.os != "Macos":
raise ConanInvalidConfiguration(f"{self.ref} task_system=libdispatch is not supported on {self.settings.os}")
elif self.options.task_system == "windows" and self.settings.os != "Windows":
raise ConanInvalidConfiguration(f"{self.ref} task_system=windows is not supported on {self.settings.os}")

def _validate_thread_system(self):
if any([self.options.thread_system == "pthread-apple" and self.settings.os != "Macos",
self.options.thread_system == "pthread" and self.settings.os != "Linux",
self.options.thread_system == "win32" and self.settings.os != "Windows",
self.options.thread_system == "pthread-emscripten" and self.settings.os != "Emscripten"]):
raise ConanInvalidConfiguration(f"{self.ref} thread_system={self.options.thread_system} is not supported on {self.settings.os}")

def _validate_boost_components(self):
if self.settings.os != "Macos": return
if self.settings.compiler != "apple-clang": return
if Version(self.settings.compiler.version) >= "12": return
if self.options.boost_optional and self.options.boost_variant: return
#
# On Apple we have to force the usage of boost.variant, because Apple's implementation of C++17
# is not complete.
#
msg = "Apple-Clang versions less than 12 do not correctly support std::optional or std::variant, so we will use boost::optional and boost::variant instead. "
if not self.options.boost_optional and not self.options.boost_variant:
msg += "Try -o boost_optional=True -o boost_variant=True"
elif not self.options.boost_optional:
msg += "Try -o boost_optional=True."
if not any([self.settings.os != "Macos", self.settings.compiler != "apple-clang",
Version(str(self.settings.compiler.version)) >= "12", self.options.with_boost]):
# On Apple we have to force the usage of boost.variant and boost.optional, because Apple's implementation of C++17
# is not complete.
raise ConanInvalidConfiguration(
f"Compiler Apple-Clang < 12 versions do not correctly support std::optional or std::variant, "
f"so we will use boost::optional and boost::variant instead. Try -o {self.ref}:with_boost=True.")

def _validate_min_compiler_version(self):
if is_msvc(self):
check_min_vs(self, "192")
else:
msg += "Try -o boost_variant=True."

raise ConanInvalidConfiguration(msg)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if not minimum_version:
self.output.warn(f"{self.ref} requires C++{self._minimum_cpp_standard}. "
f"Your compiler is unknown. Assuming it supports C++{self._minimum_cpp_standard}.")
elif Version(str(self.settings.compiler.version)) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._minimum_cpp_standard}, "
f"which your compiler does not support.")
if self.settings.compiler == "clang" and str(self.settings.compiler.version) in ("13", "14"):
raise ConanInvalidConfiguration(
f"{self.ref} currently does not work with Clang {self.settings.compiler.version} on CCI, it enters "
f"in an infinite build loop (smells like a compiler bug). Contributions are welcomed!")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, '17')

if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "9":
raise ConanInvalidConfiguration("Need GCC >= 9")

if self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "8":
raise ConanInvalidConfiguration("Need Clang >= 8")

if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) < "15.8":
raise ConanInvalidConfiguration("Need Visual Studio >= 2017 15.8 (MSVC 19.15)")

# Actually, we want *at least* 15.8 (MSVC 19.15), but we cannot check this for now with Conan.
if self.settings.compiler == "msvc" and Version(self.settings.compiler.version) < "19.15":
raise ConanInvalidConfiguration("Need msvc >= 19.15")
check_min_cppstd(self, self._minimum_cpp_standard)

self._validate_min_compiler_version()
self._validate_task_system()
self._validate_thread_system()
self._validate_boost_components()

def configure(self):
if self.options.task_system == "auto":
self.options.task_system = self._default_task_system()
self.output.info("Stlab Task System: {}.".format(self.options.task_system))
self.output.info("STLab With Boost: {}.".format(self.options.with_boost))
self.output.info("STLab Future Coroutines: {}.".format(self.options.future_coroutines))
self.output.info("STLab No Standard Coroutines: {}.".format(self.options.no_std_coroutines))
self.output.info("STLab Task System: {}.".format(self.options.task_system))
self.output.info("STLab Thread System: {}.".format(self.options.thread_system))
Comment on lines 126 to +131
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to remove these messages? It's quite weird to see these messages under ======== Computing dependency graph ======== in conan v2, and from my point of view it's the job of upstream build system to display these informations at build time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be done in another PR. This one is already merged


def generate(self):
tc = CMakeToolchain(self)
tc.variables['BUILD_TESTING'] = not self.conf.get("tools.build:skip_test", default=True, check_type=bool)
tc.variables["STLAB_USE_BOOST_CPP17_SHIMS"] = self.options.with_boost
tc.variables["STLAB_NO_STD_COROUTINES"] = self.options.no_std_coroutines
tc.variables["STLAB_THREAD_SYSTEM"] = self.options.thread_system
tc.variables["STLAB_TASK_SYSTEM"] = self.options.task_system
if cross_building(self):
tc.variables["STLAB_HAVE_FUNCTIONAL_VARIANT_OPTIONAL"] = True
Copy link
Contributor

@franramirez688 franramirez688 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fpelliccioni is this OK? I had to add it otherwise It was failing.

tc.generate()

tc = CMakeDeps(self)
tc.generate()

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

def package(self):
self.copy("*LICENSE", dst="licenses", keep_path=False)
self.copy("stlab/*", src=self._source_subfolder, dst='include/')
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()

rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "msvcp*.dll", os.path.join(self.package_folder, "bin"))
rm(self, "concrt*.dll", os.path.join(self.package_folder, "bin"))
rm(self, "vcruntime*.dll", os.path.join(self.package_folder, "bin"))

def package_id(self):
self.info.header_only()
self.info.options.boost_optional = "ANY"
self.info.options.boost_variant = "ANY"
# TODO: is header only but needs a header modified by cmake
# self.info.settings.clear()
# self.info.header_only()
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fpelliccioni Sorry, could you please give me more information about this one? why can't you put self.info.settings.clear()?


def package_info(self):
coroutines_value = 1 if self.options.coroutines else 0
future_coroutines_value = 1 if self.options.future_coroutines else 0

self.cpp_info.defines = [
'STLAB_FUTURE_COROUTINES={}'.format(coroutines_value)
'STLAB_FUTURE_COROUTINES={}'.format(future_coroutines_value)
]

if self.options.boost_optional:
self.cpp_info.defines.append("STLAB_FORCE_BOOST_OPTIONAL")

if self.options.boost_variant:
self.cpp_info.defines.append("STLAB_FORCE_BOOST_VARIANT")

if self.options.task_system == "portable":
self.cpp_info.defines.append("STLAB_FORCE_TASK_SYSTEM_PORTABLE")
elif self.options.task_system == "libdispatch":
self.cpp_info.defines.append("STLAB_FORCE_TASK_SYSTEM_LIBDISPATCH")
elif self.options.task_system == "emscripten":
self.cpp_info.defines.append("STLAB_FORCE_TASK_SYSTEM_EMSRIPTEN") #Note: there is a typo in Stlab Cmake.
self.cpp_info.defines.append("STLAB_FORCE_TASK_SYSTEM_EMSCRIPTEN") #Note: for typo fix in later versions
elif self.options.task_system == "pnacl":
self.cpp_info.defines.append("STLAB_FORCE_TASK_SYSTEM_PNACL")
elif self.options.task_system == "windows":
self.cpp_info.defines.append("STLAB_FORCE_TASK_SYSTEM_WINDOWS")
if self.settings.os == "Windows":
self.cpp_info.defines = ['NOMINMAX']
Comment on lines +175 to +176
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consumer should be settings this

Suggested change
if self.settings.os == "Windows":
self.cpp_info.defines = ['NOMINMAX']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove those lines I get the following error:

https://c3i.jfrog.io/c3i/misc/logs/pr/13048/67-configs/windows-visual_studio/stlab/1.7.1//02833e547ecc88a0495cb145970002b7a2796825-test.txt

I do not like the idea that the consumer recipe has to know about these internal things...


if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread"]
14 changes: 7 additions & 7 deletions recipes/stlab/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
cmake_minimum_required(VERSION 3.15)

set(CMAKE_CXX_STANDARD 17)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
project(test_package CXX) # if the project uses c++
find_package(stlab REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_compile_definitions( ${PROJECT_NAME} INTERFACE $<$<CXX_COMPILER_ID:MSVC>:NOMINMAX> )
target_link_libraries(${PROJECT_NAME} PRIVATE stlab::stlab)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)

19 changes: 14 additions & 5 deletions recipes/stlab/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from conans import ConanFile, CMake, tools
import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"

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

def layout(self):
cmake_layout(self)

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
2 changes: 2 additions & 0 deletions recipes/stlab/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ int main() {
while (!f.get_try()) { this_thread::sleep_for(chrono::milliseconds(1)); }

cout << "The answer is " << *f.get_try() << "\n";

stlab::pre_exit();
}

/*
Expand Down
Loading