mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 10:57:16 +02:00
cmake install and find_package removed from conanfile
find_package() does not really work well for header only libraries
This commit is contained in:
10
conanfile.py
10
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']
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user