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

add ms-gsl/3.0.0 #1388

Merged
merged 10 commits into from Apr 30, 2020
3 changes: 3 additions & 0 deletions recipes/ms-gsl/all/conandata.yml
Expand Up @@ -5,3 +5,6 @@ sources:
"2.1.0":
url: https://github.com/microsoft/GSL/archive/v2.1.0.tar.gz
sha256: "ef73814657b073e1be86c8f7353718771bf4149b482b6cb54f99e79b23ff899d"
"3.0.1":
url: "https://github.com/microsoft/GSL/archive/v3.0.1.tar.gz"
sha256: "7ceba191e046e5347357c6b605f53e6bed069c974aeda851254cb6962a233572"
25 changes: 19 additions & 6 deletions recipes/ms-gsl/all/conanfile.py
@@ -1,16 +1,23 @@
import os
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration


class GslMicrosoftConan(ConanFile):
class MicrosoftGslConan(ConanFile):
name = "ms-gsl"
description = "Microsoft implementation of the Guidelines Support Library"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/microsoft/GSL"
topics = ("gsl", "header-only")
license = "MIT"
topics = ("gsl", "guidelines", "core", "span")
no_copy_source = True
_source_subfolder = "source_subfolder"

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

# There are three configuration options for this GSL implementation's behavior
# when pre/post conditions on the GSL types are violated:
Expand Down Expand Up @@ -50,8 +57,14 @@ def package_id(self):
self.info.header_only()

def package_info(self):
if tools.Version(self.version) >= "3.0.0":
if self.options.on_contract_violation != 'terminate':
raise ConanInvalidConfiguration("Microsoft GSL only supports terminate on contract violation since version 3.0.0")

self.cpp_info.defines = [
self._contract_map[str(self.options.on_contract_violation)]
]
self.cpp_info.names["cmake_find_package"] = "Microsoft.GSL"
self.cpp_info.names["cmake_find_package_multi"] = "Microsoft.GSL"

if tools.Version(self.version) >= "3.0.0":
self.cpp_info.names["cmake_find_package"] = "Microsoft.GSL"
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
self.cpp_info.names["cmake_find_package_multi"] = "Microsoft.GSL"
gocarlos marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 3 additions & 7 deletions recipes/ms-gsl/all/test_package/CMakeLists.txt
@@ -1,13 +1,9 @@
cmake_minimum_required(VERSION 2.8.12)
project(test_package CXX)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

file(GLOB SOURCE_FILES *.cpp)

add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
9 changes: 5 additions & 4 deletions recipes/ms-gsl/all/test_package/conanfile.py
@@ -1,8 +1,8 @@
import os
from conans import ConanFile, CMake
from conans import ConanFile, CMake, tools


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

Expand All @@ -12,5 +12,6 @@ def build(self):
cmake.build()

def test(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/ms-gsl/config.yml
Expand Up @@ -3,3 +3,5 @@ versions:
folder: all
"2.1.0":
folder: all
"3.0.1":
folder: all