mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 20:04:27 +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.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():
|
||||||
@@ -59,22 +60,17 @@ 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 _configure_cmake(self):
|
def build(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)
|
||||||
cmake = self._configure_cmake()
|
self.copy(pattern="*", dst="include", src=os.path.join("src", "include"))
|
||||||
cmake.install()
|
|
||||||
|
|
||||||
def package_info(self):
|
def package_info(self):
|
||||||
self.cpp_info.includedirs = ['include']
|
self.cpp_info.includedirs = ['include']
|
||||||
|
@@ -28,13 +28,7 @@ set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
|||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
conan_basic_setup(TARGETS)
|
conan_basic_setup(TARGETS)
|
||||||
|
|
||||||
find_package(units CONFIG REQUIRED)
|
|
||||||
|
|
||||||
# test conan-generated target
|
# test conan-generated target
|
||||||
add_executable(${PROJECT_NAME}_conan test_package.cpp)
|
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||||
target_compile_features(${PROJECT_NAME}_conan PRIVATE cxx_std_20) # conan is not able to propagate that yet :-(
|
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) # conan is not able to propagate that yet :-(
|
||||||
target_link_libraries(${PROJECT_NAME}_conan PRIVATE CONAN_PKG::mp-units)
|
target_link_libraries(${PROJECT_NAME} 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)
|
|
||||||
|
Reference in New Issue
Block a user