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 update || brew update
|
||||||
brew outdated pyenv || brew upgrade pyenv
|
brew outdated pyenv || brew upgrade pyenv
|
||||||
brew install pyenv-virtualenv
|
brew install pyenv-virtualenv
|
||||||
brew install cmake || true
|
brew upgrade cmake || true
|
||||||
|
|
||||||
if which pyenv > /dev/null; then
|
if which pyenv > /dev/null; then
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init -)"
|
||||||
@@ -19,6 +19,6 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
|
|||||||
pyenv activate conan
|
pyenv activate conan
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install conan_package_tools
|
pip install -U conan_package_tools
|
||||||
pip install conan --upgrade
|
pip install -U conan
|
||||||
conan user
|
conan user
|
||||||
|
@@ -32,7 +32,7 @@ include(tools)
|
|||||||
# use Conan configuration if available
|
# use Conan configuration if available
|
||||||
conan_init(cmake)
|
conan_init(cmake)
|
||||||
|
|
||||||
# project-specific compilation flags
|
# compilation options and flags used in a project development process
|
||||||
include(compile_flags)
|
include(compile_flags)
|
||||||
|
|
||||||
# add project code
|
# add project code
|
||||||
|
13
README.md
13
README.md
@@ -1,5 +1,5 @@
|
|||||||
[](https://raw.githubusercontent.com/mpusz/units/master/LICENSE)
|
[](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://ci.appveyor.com/project/mpusz/units)
|
||||||
[](https://bintray.com/mpusz/conan-mpusz/units%3Ampusz/_latestVersion)
|
[](https://bintray.com/mpusz/conan-mpusz/units%3Ampusz/_latestVersion)
|
||||||
|
|
||||||
@@ -34,18 +34,19 @@ static_assert(10_km / 5_km == 2);
|
|||||||
|
|
||||||
## Repository structure
|
## 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`
|
- `./src` - header-only project for `units`
|
||||||
- `.` - project used for development needs that wraps `./src` project together with
|
- `.` - project used for development needs that wraps `./src` project together with
|
||||||
usage examples and unit tests
|
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).
|
[doc/INSTALL.md](doc/INSTALL.md).
|
||||||
|
|
||||||
|
|
||||||
|
18
build.py
18
build.py
@@ -1,14 +1,24 @@
|
|||||||
from cpt.packager import ConanMultiPackager
|
from cpt.packager import ConanMultiPackager
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
builder = ConanMultiPackager(username = "mpusz",
|
builder = ConanMultiPackager(
|
||||||
|
# package id
|
||||||
|
username = "mpusz",
|
||||||
channel = "testing",
|
channel = "testing",
|
||||||
login_username = "mpusz",
|
|
||||||
upload = "https://api.bintray.com/conan/mpusz/conan-mpusz",
|
|
||||||
stable_branch_pattern = r"v\d+\.\d+\.\d+.*",
|
stable_branch_pattern = r"v\d+\.\d+\.\d+.*",
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
remotes = None,
|
||||||
build_policy = "outdated",
|
build_policy = "outdated",
|
||||||
upload_dependencies="all",
|
upload_dependencies="all",
|
||||||
remotes = "https://api.bintray.com/conan/martinmoene/nonstd-lite")
|
|
||||||
|
# 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)
|
builder.add_common_builds(pure_c=False)
|
||||||
for settings, options, env_vars, build_requires, reference in builder.items:
|
for settings, options, env_vars, build_requires, reference in builder.items:
|
||||||
settings["cppstd"] = "20"
|
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.tools import load
|
||||||
from conans.errors import ConanInvalidConfiguration
|
from conans.errors import ConanInvalidConfiguration
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
@@ -63,17 +62,22 @@ class UnitsConan(ConanFile):
|
|||||||
if self.settings.cppstd not in ["20", "gnu20"]:
|
if self.settings.cppstd not in ["20", "gnu20"]:
|
||||||
raise ConanInvalidConfiguration("Library units requires at least C++20 support")
|
raise ConanInvalidConfiguration("Library units requires at least C++20 support")
|
||||||
|
|
||||||
def build(self):
|
def _configure_cmake(self):
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
if tools.get_env("CONAN_RUN_TESTS", False):
|
if tools.get_env("CONAN_RUN_TESTS", False):
|
||||||
cmake.configure()
|
cmake.configure()
|
||||||
else:
|
else:
|
||||||
cmake.configure(source_dir="%s/src" % self.source_folder)
|
cmake.configure(source_dir="%s/src" % self.source_folder)
|
||||||
|
return cmake
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
cmake = self._configure_cmake()
|
||||||
cmake.build()
|
cmake.build()
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
self.copy(pattern="*license*", dst="licenses", excludes="cmake/common/*", ignore_case=True, keep_path=False)
|
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):
|
def package_info(self):
|
||||||
self.cpp_info.includedirs = ['include']
|
self.cpp_info.includedirs = ['include']
|
||||||
|
@@ -29,6 +29,11 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|||||||
conan_basic_setup(TARGETS)
|
conan_basic_setup(TARGETS)
|
||||||
|
|
||||||
# test conan-generated target
|
# test conan-generated target
|
||||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
add_executable(${PROJECT_NAME}_conan test_package.cpp)
|
||||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) # conan is not able to propagate that yet :-(
|
target_compile_features(${PROJECT_NAME}_conan PRIVATE cxx_std_20) # Conan is not able to propagate that yet :-(
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE CONAN_PKG::mp-units)
|
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
|
import os
|
||||||
|
|
||||||
class TestPackageConan(ConanFile):
|
class TestPackageConan(ConanFile):
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
settings = "cppstd", "os", "compiler", "build_type", "arch"
|
||||||
generators = "cmake"
|
generators = "cmake"
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
@@ -32,20 +32,7 @@ class TestPackageConan(ConanFile):
|
|||||||
cmake.configure()
|
cmake.configure()
|
||||||
cmake.build()
|
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):
|
def test(self):
|
||||||
if not tools.cross_building(self.settings):
|
if not tools.cross_building(self.settings):
|
||||||
with tools.environment_append(RunEnvironment(self).vars):
|
self.run(os.path.join("bin", "test_package_conan"), run_environment=True)
|
||||||
self._test_run(os.path.join("bin", "test_package"))
|
self.run(os.path.join("bin", "test_package_cmake"), run_environment=True)
|
||||||
|
Reference in New Issue
Block a user