From 816c86a81a4a22fef7390bd04dc1572c8c73941f Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 10 Apr 2019 18:17:21 +0100 Subject: [PATCH] cmake install and find_package removed from conanfile find_package() does not really work well for header only libraries --- conanfile.py | 10 +++------- test_package/CMakeLists.txt | 12 +++--------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/conanfile.py b/conanfile.py index 25d8501c..789ca29e 100644 --- a/conanfile.py +++ b/conanfile.py @@ -24,6 +24,7 @@ from conans import ConanFile, CMake, tools from conans.tools import load from conans.errors import ConanInvalidConfiguration import re +import os def get_version(): @@ -59,22 +60,17 @@ class UnitsConan(ConanFile): if self.settings.cppstd not in ["20", "gnu20"]: raise ConanInvalidConfiguration("Library units requires at least C++20 support") - def _configure_cmake(self): + def build(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) - cmake = self._configure_cmake() - cmake.install() + self.copy(pattern="*", dst="include", src=os.path.join("src", "include")) def package_info(self): self.cpp_info.includedirs = ['include'] diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index ef48c6af..82829b0f 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -28,13 +28,7 @@ set(CMAKE_VERBOSE_MAKEFILE TRUE) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -find_package(units CONFIG REQUIRED) - # test conan-generated target -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 target -add_executable(${PROJECT_NAME}_cmake test_package.cpp) -target_link_libraries(${PROJECT_NAME}_cmake PRIVATE mp::units) +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)