forked from mpusz/mp-units
Conan packaging refactored
This commit is contained in:
@@ -7,7 +7,7 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
brew update || brew update
|
||||
brew outdated pyenv || brew upgrade pyenv
|
||||
brew install pyenv-virtualenv
|
||||
brew install cmake || true
|
||||
brew upgrade cmake || true
|
||||
|
||||
if which pyenv > /dev/null; then
|
||||
eval "$(pyenv init -)"
|
||||
@@ -19,6 +19,6 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
pyenv activate conan
|
||||
fi
|
||||
|
||||
pip install conan_package_tools
|
||||
pip install conan --upgrade
|
||||
pip install -U conan_package_tools
|
||||
pip install -U conan
|
||||
conan user
|
||||
|
@@ -32,7 +32,7 @@ include(tools)
|
||||
# use Conan configuration if available
|
||||
conan_init(cmake)
|
||||
|
||||
# project-specific compilation flags
|
||||
# compilation options and flags used in a project development process
|
||||
include(compile_flags)
|
||||
|
||||
# add project code
|
||||
|
13
README.md
13
README.md
@@ -1,5 +1,5 @@
|
||||
[](https://raw.githubusercontent.com/mpusz/units/master/LICENSE)
|
||||
[](https://travis-ci.org/mpusz/units)
|
||||
[](https://travis-ci.com/mpusz/units)
|
||||
[](https://ci.appveyor.com/project/mpusz/units)
|
||||
[](https://bintray.com/mpusz/conan-mpusz/units%3Ampusz/_latestVersion)
|
||||
|
||||
@@ -34,18 +34,19 @@ static_assert(10_km / 5_km == 2);
|
||||
|
||||
## Repository structure
|
||||
|
||||
That repository contains the following `cmake`-based projects:
|
||||
That repository contains the following independent `cmake`-based projects:
|
||||
- `./src` - header-only project for `units`
|
||||
- `.` - project used for development needs that wraps `./src` project together with
|
||||
usage examples and unit tests
|
||||
- `./test_package` - library installation and conan package verification
|
||||
- `./test_package` - library installation and Conan package verification
|
||||
|
||||
Please note that all projects depend on some `cmake` modules in `./cmake` directory.
|
||||
Please note that the projects depend on `cmake` git submodule in the `./cmake/common`
|
||||
subdirectory.
|
||||
|
||||
|
||||
## Building, testing and installation
|
||||
## Building, testing, and installation
|
||||
|
||||
For detailed information on project compilation, testing and reuse please refer to
|
||||
For a detailed information on project compilation, testing and reuse please refer to
|
||||
[doc/INSTALL.md](doc/INSTALL.md).
|
||||
|
||||
|
||||
|
26
build.py
26
build.py
@@ -1,14 +1,24 @@
|
||||
from cpt.packager import ConanMultiPackager
|
||||
|
||||
if __name__ == "__main__":
|
||||
builder = ConanMultiPackager(username = "mpusz",
|
||||
channel = "testing",
|
||||
login_username = "mpusz",
|
||||
upload = "https://api.bintray.com/conan/mpusz/conan-mpusz",
|
||||
stable_branch_pattern = r"v\d+\.\d+\.\d+.*",
|
||||
build_policy = "outdated",
|
||||
upload_dependencies="all",
|
||||
remotes = "https://api.bintray.com/conan/martinmoene/nonstd-lite")
|
||||
builder = ConanMultiPackager(
|
||||
# package id
|
||||
username = "mpusz",
|
||||
channel = "testing",
|
||||
stable_branch_pattern = r"v\d+\.\d+\.\d+.*",
|
||||
|
||||
# dependencies
|
||||
remotes = None,
|
||||
build_policy = "outdated",
|
||||
upload_dependencies="all",
|
||||
|
||||
# build configurations
|
||||
archs = ["x86_64"], # limit to 64-bit only
|
||||
|
||||
# package upload (REMEMBER to set CONAN_PASSWORD environment variable in Travis CI and AppVeyor)
|
||||
login_username = "mpusz",
|
||||
upload = "https://api.bintray.com/conan/mpusz/conan-mpusz"
|
||||
)
|
||||
builder.add_common_builds(pure_c=False)
|
||||
for settings, options, env_vars, build_requires, reference in builder.items:
|
||||
settings["cppstd"] = "20"
|
||||
|
10
conanfile.py
10
conanfile.py
@@ -24,7 +24,6 @@ from conans import ConanFile, CMake, tools
|
||||
from conans.tools import load
|
||||
from conans.errors import ConanInvalidConfiguration
|
||||
import re
|
||||
import os
|
||||
|
||||
|
||||
def get_version():
|
||||
@@ -63,17 +62,22 @@ class UnitsConan(ConanFile):
|
||||
if self.settings.cppstd not in ["20", "gnu20"]:
|
||||
raise ConanInvalidConfiguration("Library units requires at least C++20 support")
|
||||
|
||||
def build(self):
|
||||
def _configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
if tools.get_env("CONAN_RUN_TESTS", False):
|
||||
cmake.configure()
|
||||
else:
|
||||
cmake.configure(source_dir="%s/src" % self.source_folder)
|
||||
return cmake
|
||||
|
||||
def build(self):
|
||||
cmake = self._configure_cmake()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
self.copy(pattern="*license*", dst="licenses", excludes="cmake/common/*", ignore_case=True, keep_path=False)
|
||||
self.copy(pattern="*", dst="include", src=os.path.join("src", "include"))
|
||||
cmake = self._configure_cmake()
|
||||
cmake.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.includedirs = ['include']
|
||||
|
@@ -29,6 +29,11 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
|
||||
# test conan-generated target
|
||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) # conan is not able to propagate that yet :-(
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::mp-units)
|
||||
add_executable(${PROJECT_NAME}_conan test_package.cpp)
|
||||
target_compile_features(${PROJECT_NAME}_conan PRIVATE cxx_std_20) # Conan is not able to propagate that yet :-(
|
||||
target_link_libraries(${PROJECT_NAME}_conan PRIVATE CONAN_PKG::mp-units)
|
||||
|
||||
# test cmake-generated target
|
||||
find_package(units CONFIG REQUIRED)
|
||||
add_executable(${PROJECT_NAME}_cmake test_package.cpp)
|
||||
target_link_libraries(${PROJECT_NAME}_cmake PRIVATE mp::units)
|
||||
|
@@ -24,7 +24,7 @@ from conans import ConanFile, CMake, tools, RunEnvironment
|
||||
import os
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
settings = "cppstd", "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
||||
def build(self):
|
||||
@@ -32,20 +32,7 @@ class TestPackageConan(ConanFile):
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def imports(self):
|
||||
self.copy("*.dll", dst="bin", src="bin")
|
||||
self.copy("*.dylib*", dst="bin", src="lib")
|
||||
self.copy('*.so*', dst='bin', src='lib')
|
||||
|
||||
def _test_run(self, bin_path):
|
||||
if self.settings.os == "Windows":
|
||||
self.run(bin_path)
|
||||
elif self.settings.os == "Macos":
|
||||
self.run("DYLD_LIBRARY_PATH=%s %s" % (os.environ.get('DYLD_LIBRARY_PATH', ''), bin_path))
|
||||
else:
|
||||
self.run("LD_LIBRARY_PATH=%s %s" % (os.environ.get('LD_LIBRARY_PATH', ''), bin_path))
|
||||
|
||||
def test(self):
|
||||
if not tools.cross_building(self.settings):
|
||||
with tools.environment_append(RunEnvironment(self).vars):
|
||||
self._test_run(os.path.join("bin", "test_package"))
|
||||
self.run(os.path.join("bin", "test_package_conan"), run_environment=True)
|
||||
self.run(os.path.join("bin", "test_package_cmake"), run_environment=True)
|
||||
|
Reference in New Issue
Block a user