[conan] Fix the Conan package for multiple static library use

This commit is contained in:
Alexandr Timofeev
2020-01-25 20:48:59 +03:00
committed by Martin Hořeňovský
parent 2e1ce37faa
commit 49e000b505
4 changed files with 26 additions and 10 deletions

View File

@@ -49,7 +49,7 @@ class BuilderSettings(object):
def reference(self):
""" Read project version from branch create Conan reference
"""
return os.getenv("CONAN_REFERENCE", "Catch2/{}".format(self._version))
return os.getenv("CONAN_REFERENCE", "catch2/{}".format(self._version))
@property
def channel(self):

View File

@@ -1,11 +1,19 @@
cmake_minimum_required(VERSION 3.2.0)
project(test_package CXX)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
# We set it only for the convenience of calling the executable
# in the package test function
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
find_package(Catch2 REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} CONAN_PKG::Catch2Main)
# Note: Conan 1.21 doesn't support granular target generation yet.
# The Main library would be included into the unified target.
# It's controlled by the `with_main` option in the recipe.
target_link_libraries(${PROJECT_NAME} Catch2::Catch2)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)

View File

@@ -6,7 +6,7 @@ import os
class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
generators = "cmake_find_package_multi"
def build(self):
cmake = CMake(self)
@@ -14,6 +14,6 @@ class TestPackageConan(ConanFile):
cmake.build()
def test(self):
assert os.path.isfile(os.path.join(self.deps_cpp_info["Catch2"].rootpath, "licenses", "LICENSE.txt"))
assert os.path.isfile(os.path.join(self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt"))
bin_path = os.path.join("bin", "test_package")
self.run("%s -s" % bin_path, run_environment=True)