-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
123 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
sources: | ||
"0.3.6": | ||
sha256: ea9847005d0a680264986ddab5b1c077b04b80f02a2529cc38e8191b64ea97c7 | ||
url: https://github.com/abbyssoul/libsolace/archive/v0.3.6.zip | ||
"0.3.7": | ||
sha256: 7f9790f850a0d7209f95be03e1c58e67f91faeec2e12709893cf32e5f09aa6d0 | ||
url: https://github.com/abbyssoul/libsolace/archive/v0.3.7.zip | ||
"0.3.9": | ||
sha256: 5a91cc000d0ef5c51fb58197a8e3ef003fa191926f4f2511b7e8940648f007ce | ||
url: https://github.com/abbyssoul/libsolace/archive/v0.3.9.zip | ||
|
||
sha256: "5a91cc000d0ef5c51fb58197a8e3ef003fa191926f4f2511b7e8940648f007ce" | ||
url: "https://github.com/abbyssoul/libsolace/archive/v0.3.9.zip" | ||
"0.3.7": | ||
sha256: "7f9790f850a0d7209f95be03e1c58e67f91faeec2e12709893cf32e5f09aa6d0" | ||
url: "https://github.com/abbyssoul/libsolace/archive/v0.3.7.zip" | ||
"0.3.6": | ||
sha256: "ea9847005d0a680264986ddab5b1c077b04b80f02a2529cc38e8191b64ea97c7" | ||
url: "https://github.com/abbyssoul/libsolace/archive/v0.3.6.zip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,98 @@ | ||
import os | ||
|
||
from conans import CMake, ConanFile, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
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 copy, get, replace_in_file | ||
from conan.tools.scm import Version | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class LibsolaceConan(ConanFile): | ||
name = "libsolace" | ||
description = "High performance components for mission critical applications" | ||
topics = ("HPC", "High reliability", "P10", "solace", "performance", "c++", "conan") | ||
description = "High-performance components for mission-critical applications" | ||
license = "Apache-2.0" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/abbyssoul/libsolace" | ||
license = "Apache-2.0" | ||
settings = "os", "compiler", "build_type", "arch" | ||
topics = ("HPC", "High reliability", "P10", "solace", "performance", "c++") | ||
|
||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False] | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
default_options = {"shared": False, "fPIC": True} | ||
generators = "cmake" | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _supported_cppstd(self): | ||
return ["17", "gnu17", "20", "gnu20"] | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "7", | ||
"clang": "5", | ||
"apple-clang": "9", | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
compiler_version = tools.Version(str(self.settings.compiler.version)) | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if self.settings.os == "Windows": | ||
raise ConanInvalidConfiguration("This library is not yet compatible with Windows") | ||
# Exclude compilers that claims to support C++17 but do not in practice | ||
if (self.settings.compiler == "gcc" and compiler_version < "7") or \ | ||
(self.settings.compiler == "clang" and compiler_version < "5") or \ | ||
(self.settings.compiler == "apple-clang" and compiler_version < "9"): | ||
raise ConanInvalidConfiguration("This library requires C++17 or higher support standard. {} {} is not supported".format(self.settings.compiler, self.settings.compiler.version)) | ||
if self.settings.compiler.cppstd and not self.settings.compiler.cppstd in self._supported_cppstd: | ||
raise ConanInvalidConfiguration("This library requires c++17 standard or higher. {} required".format(self.settings.compiler.cppstd)) | ||
raise ConanInvalidConfiguration("This library is not yet compatible with Windows") | ||
|
||
if self.settings.compiler.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 does not support." | ||
) | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
extracted_dir = self.name + "-" + self.version | ||
os.rename(extracted_dir, self._source_subfolder) | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.cache_variables["PKG_CONFIG"] = False | ||
tc.cache_variables["SOLACE_GTEST_SUPPORT"] = False | ||
tc.generate() | ||
|
||
def _configure_cmake(self): | ||
cmake = CMake(self, parallel=True) | ||
cmake.definitions["PKG_CONFIG"] = "OFF" | ||
cmake.definitions["SOLACE_GTEST_SUPPORT"] = "OFF" | ||
cmake.configure(source_folder=self._source_subfolder) | ||
return cmake | ||
def _patch_sources(self): | ||
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), | ||
"include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)\nconan_basic_setup()", | ||
"") | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
self._patch_sources() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake = CMake(self) | ||
cmake.install() | ||
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) | ||
copy(self, "LICENSE", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["solace"] | ||
if self.settings.os == "Linux": | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("m") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.3) | ||
cmake_minimum_required(VERSION 3.15) | ||
project(PackageTest CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
find_package(libsolace REQUIRED CONFIG) | ||
|
||
set(CMAKE_CXX_STANDARD_REQUIRED on) | ||
|
||
add_executable(example example.cpp) | ||
|
||
# libsolace requires at least C++17 | ||
set_target_properties(example PROPERTIES CXX_STANDARD 17) | ||
target_link_libraries(example ${CONAN_LIBS}) | ||
target_link_libraries(example libsolace::libsolace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class SolaceTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is | ||
# in "test_package" | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
with tools.chdir("bin"): | ||
self.run(".%sexample" % os.sep, run_environment=True) | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "example") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class SolaceTestConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is | ||
# in "test_package" | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
with tools.chdir("bin"): | ||
self.run(".%sexample" % os.sep, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
versions: | ||
0.3.6: | ||
0.3.9: | ||
folder: all | ||
0.3.7: | ||
folder: all | ||
0.3.9: | ||
0.3.6: | ||
folder: all |