[DO-987] catch recipe (!3)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/3 Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team> Co-authored-by: Aleksandr Vodyanov <aleksandr.vodyanov@avroid.team> Co-committed-by: Aleksandr Vodyanov <aleksandr.vodyanov@avroid.team>
This commit is contained in:
committed by
Denis Patrakeev
parent
bb6197bed7
commit
e3106d807c
68
recipes/catch2/3.x.x/conandata.yml
Normal file
68
recipes/catch2/3.x.x/conandata.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
sources:
|
||||
"3.7.1":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.7.1"
|
||||
"3.7.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.7.0"
|
||||
"3.6.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.6.0"
|
||||
"3.5.4":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.5.4"
|
||||
"3.5.3":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.5.3"
|
||||
"3.5.2":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.5.2"
|
||||
"3.5.1":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.5.1"
|
||||
"3.5.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.5.0"
|
||||
"3.4.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.4.0"
|
||||
"3.3.2":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.3.2"
|
||||
"3.3.1":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.3.1"
|
||||
"3.3.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.3.0"
|
||||
"3.2.1":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.2.1"
|
||||
"3.2.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.2.0"
|
||||
"3.1.0":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.1.0"
|
||||
"3.0.1":
|
||||
url: "ssh://git@git.avroid.tech:2222/Mirrors/Catch2"
|
||||
branch: "v3.0.1"
|
||||
patches:
|
||||
"3.1.0":
|
||||
- patch_file: "patches/3.1.0-0001-fix-dll-install.patch"
|
||||
patch_description: "Install dll in bin folder"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://github.com/catchorg/Catch2/pull/2485"
|
||||
- patch_file: "patches/3.1.0-0002-dllimport-global-symbols-msvc.patch"
|
||||
patch_description: "Fix import of global symbols for msvc shared"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://github.com/catchorg/Catch2/pull/2527"
|
||||
"3.0.1":
|
||||
- patch_file: "patches/3.0.1-0001-allow-shared.patch"
|
||||
patch_description: "Allow to build catch2 as a shared library"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://github.com/catchorg/Catch2/commit/bea58bf8bbfca887f871c3aa2d720ba62c01f855"
|
||||
- patch_file: "patches/3.0.1-0002-dllimport-global-symbols-msvc.patch"
|
||||
patch_description: "Fix import of global symbols for msvc shared"
|
||||
patch_type: "portability"
|
||||
patch_source: "https://github.com/catchorg/Catch2/pull/2527"
|
||||
194
recipes/catch2/3.x.x/conanfile.py
Normal file
194
recipes/catch2/3.x.x/conanfile.py
Normal file
@@ -0,0 +1,194 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.build import check_min_cppstd
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save
|
||||
from conan.tools.scm import Version, Git
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
required_conan_version = ">=1.54.0"
|
||||
|
||||
|
||||
class Catch2Conan(ConanFile):
|
||||
name = "catch2"
|
||||
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
|
||||
license = "BSL-1.0"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "https://github.com/catchorg/Catch2"
|
||||
topics = ("catch2", "unit-test", "tdd", "bdd")
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"with_prefix": [True, False],
|
||||
"default_reporter": [None, "ANY"],
|
||||
"console_width": [None, "ANY"],
|
||||
"no_posix_signals": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"with_prefix": False,
|
||||
"default_reporter": None,
|
||||
"console_width": "80",
|
||||
"no_posix_signals": False,
|
||||
}
|
||||
# disallow cppstd compatibility, as it affects the ABI in this library
|
||||
# see https://github.com/conan-io/conan-center-index/issues/19008
|
||||
extension_properties = {"compatibility_cppstd": False}
|
||||
|
||||
@property
|
||||
def _min_cppstd(self):
|
||||
return "14"
|
||||
|
||||
@property
|
||||
def _min_console_width(self):
|
||||
# Catch2 doesn't build if less than this value
|
||||
return 46
|
||||
|
||||
@property
|
||||
def _compilers_minimum_version(self):
|
||||
return {
|
||||
"gcc": "7",
|
||||
"Visual Studio": "15",
|
||||
"msvc": "191",
|
||||
"clang": "5",
|
||||
"apple-clang": "10",
|
||||
}
|
||||
|
||||
@property
|
||||
def _default_reporter_str(self):
|
||||
return str(self.options.default_reporter).strip('"')
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
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 layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def validate(self):
|
||||
if self.settings.compiler.get_safe("cppstd"):
|
||||
check_min_cppstd(self, self._min_cppstd)
|
||||
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 doesn't support",
|
||||
)
|
||||
|
||||
try:
|
||||
if int(self.options.console_width) < self._min_console_width:
|
||||
raise ConanInvalidConfiguration(
|
||||
f"option 'console_width' must be >= {self._min_console_width}, "
|
||||
f"got {self.options.console_width}. Contributions welcome if this should work!")
|
||||
except ValueError as e:
|
||||
raise ConanInvalidConfiguration(f"option 'console_width' must be an integer, "
|
||||
f"got '{self.options.console_width}'") from e
|
||||
|
||||
def source(self):
|
||||
#get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
git = Git(self)
|
||||
sources = self.conan_data["sources"][self.version]
|
||||
clone_args = ['--depth', '1', '--branch', sources["branch"]]
|
||||
git.clone(url=sources["url"], target=self.source_folder, args=clone_args)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["BUILD_TESTING"] = False
|
||||
tc.cache_variables["CATCH_INSTALL_DOCS"] = False
|
||||
tc.cache_variables["CATCH_INSTALL_EXTRAS"] = True
|
||||
tc.cache_variables["CATCH_DEVELOPMENT_BUILD"] = False
|
||||
tc.variables["CATCH_CONFIG_PREFIX_ALL"] = self.options.with_prefix
|
||||
tc.variables["CATCH_CONFIG_CONSOLE_WIDTH"] = self.options.console_width
|
||||
if self.options.default_reporter:
|
||||
tc.variables["CATCH_CONFIG_DEFAULT_REPORTER"] = self._default_reporter_str
|
||||
tc.variables["CATCH_CONFIG_NO_POSIX_SIGNALS"] = self.options.no_posix_signals
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "LICENSE.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
for cmake_file in ["ParseAndAddCatchTests.cmake", "Catch.cmake", "CatchAddTests.cmake"]:
|
||||
copy(
|
||||
self,
|
||||
cmake_file,
|
||||
src=os.path.join(self.source_folder, "extras"),
|
||||
dst=os.path.join(self.package_folder, "lib", "cmake", "Catch2"),
|
||||
)
|
||||
|
||||
# TODO: to remove in conan v2 once legacy generators removed
|
||||
self._create_cmake_module_alias_targets(
|
||||
os.path.join(self.package_folder, self._module_file_rel_path),
|
||||
{
|
||||
"Catch2::Catch2": "catch2::_catch2",
|
||||
"Catch2::Catch2WithMain": "catch2::catch2_with_main",
|
||||
}
|
||||
)
|
||||
|
||||
def _create_cmake_module_alias_targets(self, module_file, targets):
|
||||
content = ""
|
||||
for alias, aliased in targets.items():
|
||||
content += textwrap.dedent(f"""\
|
||||
if(TARGET {aliased} AND NOT TARGET {alias})
|
||||
add_library({alias} INTERFACE IMPORTED)
|
||||
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
|
||||
endif()
|
||||
""")
|
||||
save(self, module_file, content)
|
||||
|
||||
@property
|
||||
def _module_file_rel_path(self):
|
||||
return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake")
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "Catch2")
|
||||
self.cpp_info.set_property("cmake_target_name", "Catch2::Catch2WithMain")
|
||||
self.cpp_info.set_property("pkg_config_name", "catch2-with-main")
|
||||
|
||||
lib_suffix = "d" if self.settings.build_type == "Debug" else ""
|
||||
self.cpp_info.components["_catch2"].set_property("cmake_target_name", "Catch2::Catch2")
|
||||
self.cpp_info.components["_catch2"].set_property("pkg_config_name", "catch2")
|
||||
self.cpp_info.components["_catch2"].libs = ["Catch2" + lib_suffix]
|
||||
|
||||
self.cpp_info.components["catch2_with_main"].builddirs.append(os.path.join("lib", "cmake", "Catch2"))
|
||||
self.cpp_info.components["catch2_with_main"].libs = ["Catch2Main" + lib_suffix]
|
||||
self.cpp_info.components["catch2_with_main"].requires = ["_catch2"]
|
||||
self.cpp_info.components["catch2_with_main"].system_libs = ["log"] if self.settings.os == "Android" else []
|
||||
self.cpp_info.components["catch2_with_main"].set_property("cmake_target_name", "Catch2::Catch2WithMain")
|
||||
self.cpp_info.components["catch2_with_main"].set_property("pkg_config_name", "catch2-with-main")
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.components["catch2_with_main"].system_libs.append("m")
|
||||
defines = []
|
||||
if self.options.with_prefix:
|
||||
defines.append("CATCH_CONFIG_PREFIX_ALL")
|
||||
if self.options.default_reporter:
|
||||
defines.append(f"CATCH_CONFIG_DEFAULT_REPORTER={self._default_reporter_str}")
|
||||
self.cpp_info.components["catch2_with_main"].defines = defines
|
||||
|
||||
# TODO: to remove in conan v2 once legacy generators removed
|
||||
self.cpp_info.filenames["cmake_find_package"] = "Catch2"
|
||||
self.cpp_info.filenames["cmake_find_package_multi"] = "Catch2"
|
||||
self.cpp_info.names["cmake_find_package"] = "catch2"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "catch2"
|
||||
self.cpp_info.components["_catch2"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["_catch2"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["catch2_with_main"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
|
||||
self.cpp_info.components["catch2_with_main"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
|
||||
64
recipes/catch2/3.x.x/patches/3.0.1-0001-allow-shared.patch
Normal file
64
recipes/catch2/3.x.x/patches/3.0.1-0001-allow-shared.patch
Normal file
@@ -0,0 +1,64 @@
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -263,9 +263,7 @@ set(REPORTER_SOURCES
|
||||
)
|
||||
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
||||
|
||||
-# Fixme: STATIC because for dynamic, we would need to handle visibility
|
||||
-# and I don't want to do the annotations right now
|
||||
-add_library(Catch2 STATIC
|
||||
+add_library(Catch2
|
||||
${REPORTER_FILES}
|
||||
${INTERNAL_FILES}
|
||||
${BENCHMARK_HEADERS}
|
||||
@@ -318,7 +316,7 @@ target_include_directories(Catch2
|
||||
)
|
||||
|
||||
|
||||
-add_library(Catch2WithMain STATIC
|
||||
+add_library(Catch2WithMain
|
||||
${SOURCES_DIR}/internal/catch_main.cpp
|
||||
)
|
||||
add_build_reproducibility_settings(Catch2WithMain)
|
||||
@@ -338,8 +336,12 @@ if (NOT_SUBPROJECT)
|
||||
Catch2WithMain
|
||||
EXPORT
|
||||
Catch2Targets
|
||||
- DESTINATION
|
||||
+ LIBRARY DESTINATION
|
||||
+ ${CMAKE_INSTALL_LIBDIR}
|
||||
+ ARCHIVE DESTINATION
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
+ RUNTIME DESTINATION
|
||||
+ ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
@@ -409,3 +411,27 @@ endif()
|
||||
|
||||
list(APPEND CATCH_WARNING_TARGETS Catch2 Catch2WithMain)
|
||||
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|
||||
+
|
||||
+
|
||||
+# We still do not support building dynamic library with hidden visibility
|
||||
+# so we want to check & warn users if they do this. However, we won't abort
|
||||
+# the configuration step so that we don't have to also provide an override.
|
||||
+if (BUILD_SHARED_LIBS)
|
||||
+ if (MSVC)
|
||||
+ set_target_properties(Catch2 Catch2WithMain
|
||||
+ PROPERTIES
|
||||
+ WINDOWS_EXPORT_ALL_SYMBOLS ON
|
||||
+ )
|
||||
+ endif()
|
||||
+
|
||||
+ get_target_property(_VisPreset Catch2 CXX_VISIBILITY_PRESET)
|
||||
+ if (NOT MSVC AND _VisPreset STREQUAL "hidden")
|
||||
+ set_target_properties(Catch2 Catch2WithMain
|
||||
+ PROPERTIES
|
||||
+ CXX_VISIBILITY_PRESET "default"
|
||||
+ VISIBILITY_INLINES_HIDDEN OFF
|
||||
+ )
|
||||
+ message(WARNING "Setting Catch2's visibility to default."
|
||||
+ " Hidden visibility is not supported.")
|
||||
+ endif()
|
||||
+endif()
|
||||
@@ -0,0 +1,77 @@
|
||||
--- a/CMake/CatchConfigOptions.cmake
|
||||
+++ b/CMake/CatchConfigOptions.cmake
|
||||
@@ -45,6 +45,7 @@ set(_OverridableOptions
|
||||
foreach(OptionName ${_OverridableOptions})
|
||||
AddOverridableConfigOption(${OptionName})
|
||||
endforeach()
|
||||
+set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||
|
||||
set(_OtherConfigOptions
|
||||
"DISABLE_EXCEPTIONS"
|
||||
--- a/src/catch2/catch_tostring.hpp
|
||||
+++ b/src/catch2/catch_tostring.hpp
|
||||
@@ -296,13 +296,13 @@ namespace Catch {
|
||||
template<>
|
||||
struct StringMaker<float> {
|
||||
static std::string convert(float value);
|
||||
- static int precision;
|
||||
+ CATCH_EXPORT static int precision;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct StringMaker<double> {
|
||||
static std::string convert(double value);
|
||||
- static int precision;
|
||||
+ CATCH_EXPORT static int precision;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
--- a/src/catch2/catch_user_config.hpp.in
|
||||
+++ b/src/catch2/catch_user_config.hpp.in
|
||||
@@ -181,6 +181,8 @@
|
||||
#cmakedefine CATCH_CONFIG_PREFIX_ALL
|
||||
#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG
|
||||
|
||||
+#cmakedefine CATCH_CONFIG_SHARED_LIBRARY
|
||||
+
|
||||
|
||||
// ------
|
||||
// "Variable" defines, these have actual values
|
||||
--- a/src/catch2/internal/catch_compiler_capabilities.hpp
|
||||
+++ b/src/catch2/internal/catch_compiler_capabilities.hpp
|
||||
@@ -364,5 +364,15 @@
|
||||
# define CATCH_CONFIG_COLOUR_WIN32
|
||||
#endif
|
||||
|
||||
+#if defined( CATCH_CONFIG_SHARED_LIBRARY ) && defined( _MSC_VER ) && \
|
||||
+ !defined( CATCH_CONFIG_STATIC )
|
||||
+# ifdef Catch2_EXPORTS
|
||||
+# define CATCH_EXPORT //__declspec( dllexport ) // not needed
|
||||
+# else
|
||||
+# define CATCH_EXPORT __declspec( dllimport )
|
||||
+# endif
|
||||
+#else
|
||||
+# define CATCH_EXPORT
|
||||
+#endif
|
||||
|
||||
#endif // CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
||||
--- a/src/catch2/internal/catch_context.hpp
|
||||
+++ b/src/catch2/internal/catch_context.hpp
|
||||
@@ -8,6 +8,8 @@
|
||||
#ifndef CATCH_CONTEXT_HPP_INCLUDED
|
||||
#define CATCH_CONTEXT_HPP_INCLUDED
|
||||
|
||||
+#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
+
|
||||
namespace Catch {
|
||||
|
||||
class IResultCapture;
|
||||
@@ -28,7 +30,7 @@ namespace Catch {
|
||||
virtual void setConfig( IConfig const* config ) = 0;
|
||||
|
||||
private:
|
||||
- static IMutableContext *currentContext;
|
||||
+ CATCH_EXPORT static IMutableContext *currentContext;
|
||||
friend IMutableContext& getCurrentMutableContext();
|
||||
friend void cleanUpContext();
|
||||
static void createContext();
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -359,8 +359,12 @@ if (NOT_SUBPROJECT)
|
||||
Catch2WithMain
|
||||
EXPORT
|
||||
Catch2Targets
|
||||
- DESTINATION
|
||||
+ LIBRARY DESTINATION
|
||||
+ ${CMAKE_INSTALL_LIBDIR}
|
||||
+ ARCHIVE DESTINATION
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
+ RUNTIME DESTINATION
|
||||
+ ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
--- a/CMake/CatchConfigOptions.cmake
|
||||
+++ b/CMake/CatchConfigOptions.cmake
|
||||
@@ -45,6 +45,7 @@ set(_OverridableOptions
|
||||
foreach(OptionName ${_OverridableOptions})
|
||||
AddOverridableConfigOption(${OptionName})
|
||||
endforeach()
|
||||
+set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||
|
||||
set(_OtherConfigOptions
|
||||
"DISABLE_EXCEPTIONS"
|
||||
--- a/src/catch2/catch_tostring.hpp
|
||||
+++ b/src/catch2/catch_tostring.hpp
|
||||
@@ -296,13 +296,13 @@ namespace Catch {
|
||||
template<>
|
||||
struct StringMaker<float> {
|
||||
static std::string convert(float value);
|
||||
- static int precision;
|
||||
+ CATCH_EXPORT static int precision;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct StringMaker<double> {
|
||||
static std::string convert(double value);
|
||||
- static int precision;
|
||||
+ CATCH_EXPORT static int precision;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
--- a/src/catch2/catch_user_config.hpp.in
|
||||
+++ b/src/catch2/catch_user_config.hpp.in
|
||||
@@ -181,6 +181,8 @@
|
||||
#cmakedefine CATCH_CONFIG_PREFIX_ALL
|
||||
#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG
|
||||
|
||||
+#cmakedefine CATCH_CONFIG_SHARED_LIBRARY
|
||||
+
|
||||
|
||||
// ------
|
||||
// "Variable" defines, these have actual values
|
||||
--- a/src/catch2/internal/catch_compiler_capabilities.hpp
|
||||
+++ b/src/catch2/internal/catch_compiler_capabilities.hpp
|
||||
@@ -376,5 +376,15 @@
|
||||
# define CATCH_CONFIG_COLOUR_WIN32
|
||||
#endif
|
||||
|
||||
+#if defined( CATCH_CONFIG_SHARED_LIBRARY ) && defined( _MSC_VER ) && \
|
||||
+ !defined( CATCH_CONFIG_STATIC )
|
||||
+# ifdef Catch2_EXPORTS
|
||||
+# define CATCH_EXPORT //__declspec( dllexport ) // not needed
|
||||
+# else
|
||||
+# define CATCH_EXPORT __declspec( dllimport )
|
||||
+# endif
|
||||
+#else
|
||||
+# define CATCH_EXPORT
|
||||
+#endif
|
||||
|
||||
#endif // CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
||||
--- a/src/catch2/internal/catch_context.hpp
|
||||
+++ b/src/catch2/internal/catch_context.hpp
|
||||
@@ -8,6 +8,8 @@
|
||||
#ifndef CATCH_CONTEXT_HPP_INCLUDED
|
||||
#define CATCH_CONTEXT_HPP_INCLUDED
|
||||
|
||||
+#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
+
|
||||
namespace Catch {
|
||||
|
||||
class IResultCapture;
|
||||
@@ -28,7 +30,7 @@ namespace Catch {
|
||||
virtual void setConfig( IConfig const* config ) = 0;
|
||||
|
||||
private:
|
||||
- static IMutableContext *currentContext;
|
||||
+ CATCH_EXPORT static IMutableContext *currentContext;
|
||||
friend IMutableContext& getCurrentMutableContext();
|
||||
friend void cleanUpContext();
|
||||
static void createContext();
|
||||
5
recipes/catch2/3.x.x/test_package/100-standalone.cpp
Normal file
5
recipes/catch2/3.x.x/test_package/100-standalone.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
TEST_CASE( "compiles and runs" ) {
|
||||
REQUIRE( true == !false );
|
||||
}
|
||||
12
recipes/catch2/3.x.x/test_package/200-benchmark.cpp
Normal file
12
recipes/catch2/3.x.x/test_package/200-benchmark.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/benchmark/catch_benchmark.hpp>
|
||||
|
||||
unsigned int Factorial( unsigned int number ) {
|
||||
return number > 1 ? Factorial(number-1)*number : 1;
|
||||
}
|
||||
|
||||
TEST_CASE( "compiles and runs" ) {
|
||||
BENCHMARK("factorial 25"){
|
||||
return Factorial(25);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
CATCH_TEST_CASE( "compiles and runs" ) {
|
||||
CATCH_REQUIRE( true == !false );
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/benchmark/catch_benchmark.hpp>
|
||||
|
||||
unsigned int Factorial( unsigned int number ) {
|
||||
return number > 1 ? Factorial(number-1)*number : 1;
|
||||
}
|
||||
|
||||
CATCH_TEST_CASE( "compiles and runs" ) {
|
||||
CATCH_BENCHMARK("factorial 25"){
|
||||
return Factorial(25);
|
||||
};
|
||||
}
|
||||
16
recipes/catch2/3.x.x/test_package/CMakeLists.txt
Normal file
16
recipes/catch2/3.x.x/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(test_package LANGUAGES CXX)
|
||||
|
||||
find_package(Catch2 REQUIRED CONFIG)
|
||||
|
||||
if(WITH_PREFIX)
|
||||
add_executable(standalone 300-standalone-with-prefix.cpp)
|
||||
add_executable(benchmark 400-benchmark-with-prefix.cpp)
|
||||
else()
|
||||
add_executable(standalone 100-standalone.cpp)
|
||||
add_executable(benchmark 200-benchmark.cpp)
|
||||
endif()
|
||||
target_link_libraries(standalone PRIVATE Catch2::Catch2WithMain)
|
||||
target_compile_features(standalone PRIVATE cxx_std_14)
|
||||
target_link_libraries(benchmark PRIVATE Catch2::Catch2WithMain)
|
||||
target_compile_features(benchmark PRIVATE cxx_std_14)
|
||||
31
recipes/catch2/3.x.x/test_package/conanfile.py
Normal file
31
recipes/catch2/3.x.x/test_package/conanfile.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeDeps", "VirtualRunEnv"
|
||||
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.variables["WITH_PREFIX"] = self.dependencies[self.tested_reference_str].options.with_prefix
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
self.run(os.path.join(self.cpp.build.bindirs[0], "standalone"), env="conanrun")
|
||||
self.run(os.path.join(self.cpp.build.bindirs[0], "benchmark"), env="conanrun")
|
||||
8
recipes/catch2/3.x.x/test_v1_package/CMakeLists.txt
Normal file
8
recipes/catch2/3.x.x/test_v1_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
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)
|
||||
18
recipes/catch2/3.x.x/test_v1_package/conanfile.py
Normal file
18
recipes/catch2/3.x.x/test_v1_package/conanfile.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from conans import ConanFile, CMake, tools
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "cmake", "cmake_find_package_multi"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.definitions["WITH_PREFIX"] = self.options["catch2"].with_prefix
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self):
|
||||
self.run(os.path.join("bin", "standalone"), run_environment=True)
|
||||
self.run(os.path.join("bin", "benchmark"), run_environment=True)
|
||||
Reference in New Issue
Block a user