| 1 |
|
| 2 |
from conans import ConanFile, CMake, tools |
| 3 |
|
| 4 |
class CatchConan(ConanFile): |
| 5 |
name = "catch2" |
| 6 |
description = "A modern, C++-native, framework for unit-tests, TDD and BDD" |
| 7 |
topics = ("conan", "catch2", "unit-test", "tdd", "bdd") |
| 8 |
url = "https://github.com/catchorg/Catch2" |
| 9 |
homepage = url |
| 10 |
license = "BSL-1.0" |
| 11 |
|
| 12 |
exports = "LICENSE.txt" |
| 13 |
exports_sources = ("src/*", "CMakeLists.txt", "CMake/*", "extras/*") |
| 14 |
|
| 15 |
settings = "os", "compiler", "build_type", "arch" |
| 16 |
|
| 17 |
generators = "cmake" |
| 18 |
|
| 19 |
def _configure_cmake(self): |
| 20 |
cmake = CMake(self) |
| 21 |
cmake.definitions["BUILD_TESTING"] = "OFF" |
| 22 |
cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF" |
| 23 |
cmake.definitions["CATCH_INSTALL_EXTRAS"] = "ON" |
| 24 |
cmake.configure(build_folder="build") |
| 25 |
return cmake |
| 26 |
|
| 27 |
def build(self): |
| 28 |
|
| 29 |
|
| 30 |
line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")' |
| 31 |
tools.replace_in_file("CMakeLists.txt", line_to_replace, |
| 32 |
'''{} |
| 33 |
include("{}/conanbuildinfo.cmake") |
| 34 |
conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\", "/"))) |
| 35 |
|
| 36 |
cmake = self._configure_cmake() |
| 37 |
cmake.build() |
| 38 |
|
| 39 |
def package(self): |
| 40 |
self.copy(pattern="LICENSE.txt", dst="licenses") |
| 41 |
cmake = self._configure_cmake() |
| 42 |
cmake.install() |
| 43 |
|
| 44 |
def package_info(self): |
| 45 |
lib_suffix = "d" if self.settings.build_type == "Debug" else "" |
| 46 |
|
| 47 |
self.cpp_info.names["cmake_find_package"] = "Catch2" |
| 48 |
self.cpp_info.names["cmake_find_package_multi"] = "Catch2" |
| 49 |
|
| 50 |
self.cpp_info.components["catch2base"].names["cmake_find_package"] = "Catch2" |
| 51 |
self.cpp_info.components["catch2base"].names["cmake_find_package_multi"] = "Catch2" |
| 52 |
self.cpp_info.components["catch2base"].names["pkg_config"] = "Catch2" |
| 53 |
self.cpp_info.components["catch2base"].libs = ["Catch2" + lib_suffix] |
| 54 |
self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/Catch2") |
| 55 |
|
| 56 |
self.cpp_info.components["catch2main"].names["cmake_find_package"] = "Catch2WithMain" |
| 57 |
self.cpp_info.components["catch2main"].names["cmake_find_package_multi"] = "Catch2WithMain" |
| 58 |
self.cpp_info.components["catch2main"].names["pkg_config"] = "Catch2WithMain" |
| 59 |
self.cpp_info.components["catch2main"].libs = ["Catch2Main" + lib_suffix] |
| 60 |
self.cpp_info.components["catch2main"].requires = ["catch2base"] |