Skip to content

Commit

Permalink
Use C++11 for test package if >=1.51
Browse files Browse the repository at this point in the history
  • Loading branch information
hdhauk committed Jan 19, 2021
1 parent 81df2f5 commit f6b2586
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
22 changes: 16 additions & 6 deletions recipes/geographiclib/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,30 @@ def config_options(self):
def _min_compiler_version_default_cxx11(self):
# Minimum compiler version having c++ standard >= 11
return {
"gcc": 6,
"clang": 6,
"Visual Studio": 14, # guess
}.get(str(self.settings.compiler))
"apple-clang": "3.3",
"gcc": "4.9",
"clang": "6",
"Visual Studio": "14", # guess
}.get(str(self.settings.compiler), False)

def configure(self):
if self.options.shared:
del self.options.fPIC
if tools.Version(self.version) >= "1.51":
if self.settings.compiler.cppstd:
tools.min_cppstd(self, 11)
elif tools.Version(self.settings.compiler.version) < self._min_compiler_version_default_cxx11:
raise ConanInvalidConfiguration("C++11 support needed for version >= 1.51")

def lazy_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")]
lv2 = [int(v) for v in v2.split(".")]
min_length = min(len(lv1), len(lv2))
return lv1[:min_length] < lv2[:min_length]

minimum_version = self._min_compiler_version_default_cxx11
if not minimum_version:
self.output.warn("geographiclib {} requires C++11 math functions. Your compiler is unknown. Assuming it supports this feature.".format(self.version))
elif lazy_lt_semver(str(self.settings.compiler.version), minimum_version):
raise ConanInvalidConfiguration("geographiclib {} requires C++11 math functions, which your compiler does not support.".format(self.version))

def source(self):
tools.get(**self.conan_data["sources"][self.version])
Expand Down
4 changes: 4 additions & 0 deletions recipes/geographiclib/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ find_package(geographiclib CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} GeographicLib::GeographicLib)

if(geographiclib_VERSION VERSION_GREATER_EQUAL "1.51")
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
endif()

0 comments on commit f6b2586

Please sign in to comment.