mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 18:37:15 +02:00
build: Conan generator changed to provide more transparent dependency handling
This commit is contained in:
@ -23,15 +23,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
project(mp-units)
|
project(mp-units)
|
||||||
|
|
||||||
# set path to custom cmake modules
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
# set paths to Conan packages
|
||||||
|
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
|
||||||
|
|
||||||
# include common tools and workarounds
|
# include common tools and workarounds
|
||||||
include(common/scripts)
|
include(common/scripts)
|
||||||
|
|
||||||
# use Conan configuration if available
|
|
||||||
conan_init(cmake)
|
|
||||||
|
|
||||||
# enable static analysis
|
# enable static analysis
|
||||||
#enable_clang_tidy()
|
#enable_clang_tidy()
|
||||||
#enable_iwyu()
|
#enable_iwyu()
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
# The MIT License (MIT)
|
|
||||||
#
|
|
||||||
# Copyright (c) 2017 Mateusz Pusz
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
|
||||||
# copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
# SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
# Helper to use conan generated configuration if provided
|
|
||||||
macro(conan_init generator)
|
|
||||||
if(${generator} STREQUAL "cmake_paths")
|
|
||||||
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
|
|
||||||
elseif(${generator} STREQUAL "cmake")
|
|
||||||
if(NOT DEFINED CONAN_PACKAGE_NAME)
|
|
||||||
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
||||||
conan_basic_setup(TARGETS)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unknown Conan generator: ${generator}")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
|
|
||||||
# Checks if conan installed testing dependencies
|
|
||||||
macro(conan_check_testing test_framework)
|
|
||||||
if(NOT TARGET CONAN_PKG::${test_framework})
|
|
||||||
message(FATAL_ERROR "CONAN_PKG::${test_framework} not found!\nPlease run `conan install` with `-e CONAN_RUN_TESTS=True`.")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
@ -43,7 +43,7 @@ class UnitsConan(ConanFile):
|
|||||||
topics = ("units", "dimensions", "quantities", "dimensional-analysis", "physical-quantities", "physical-units", "system-of-units", "cpp23", "cpp20", "library", "quantity-manipulation")
|
topics = ("units", "dimensions", "quantities", "dimensional-analysis", "physical-quantities", "physical-units", "system-of-units", "cpp23", "cpp20", "library", "quantity-manipulation")
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
url = "https://github.com/mpusz/units"
|
url = "https://github.com/mpusz/units"
|
||||||
settings = "compiler"
|
settings = "compiler", "build_type"
|
||||||
requires = (
|
requires = (
|
||||||
"fmt/7.0.3",
|
"fmt/7.0.3",
|
||||||
"ms-gsl/3.1.0"
|
"ms-gsl/3.1.0"
|
||||||
@ -64,7 +64,7 @@ class UnitsConan(ConanFile):
|
|||||||
# "revision": "auto",
|
# "revision": "auto",
|
||||||
# "submodule": "recursive"
|
# "submodule": "recursive"
|
||||||
# }
|
# }
|
||||||
generators = "cmake"
|
generators = "cmake_find_package_multi", "cmake_paths"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _run_tests(self):
|
def _run_tests(self):
|
||||||
|
@ -36,11 +36,11 @@ add_example(experimental_angle)
|
|||||||
add_example(foot_pound_second)
|
add_example(foot_pound_second)
|
||||||
add_example(kalman_filter-alpha_beta_filter_example2)
|
add_example(kalman_filter-alpha_beta_filter_example2)
|
||||||
|
|
||||||
conan_check_testing(linear_algebra)
|
find_package(linear_algebra CONFIG REQUIRED)
|
||||||
add_example(linear_algebra)
|
add_example(linear_algebra)
|
||||||
target_link_libraries(linear_algebra
|
target_link_libraries(linear_algebra
|
||||||
PRIVATE
|
PRIVATE
|
||||||
$<IF:$<TARGET_EXISTS:CONAN_PKG::linear_algebra>,CONAN_PKG::linear_algebra,linear_algebra::linear_algebra>
|
linear_algebra::linear_algebra
|
||||||
)
|
)
|
||||||
|
|
||||||
add_example(measurement)
|
add_example(measurement)
|
||||||
|
@ -36,8 +36,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
|||||||
# include common tools and workarounds
|
# include common tools and workarounds
|
||||||
include(common/scripts)
|
include(common/scripts)
|
||||||
|
|
||||||
# use Conan configuration if available
|
find_package(fmt CONFIG REQUIRED)
|
||||||
conan_init(cmake)
|
find_package(Microsoft.GSL CONFIG REQUIRED)
|
||||||
|
|
||||||
# library definition
|
# library definition
|
||||||
add_library(mp-units INTERFACE)
|
add_library(mp-units INTERFACE)
|
||||||
@ -58,8 +58,8 @@ add_library(mp-units INTERFACE)
|
|||||||
target_compile_features(mp-units INTERFACE cxx_std_20)
|
target_compile_features(mp-units INTERFACE cxx_std_20)
|
||||||
target_link_libraries(mp-units
|
target_link_libraries(mp-units
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<IF:$<TARGET_EXISTS:CONAN_PKG::fmt>,CONAN_PKG::fmt,fmt::fmt>
|
fmt::fmt
|
||||||
$<IF:$<TARGET_EXISTS:CONAN_PKG::ms-gsl>,CONAN_PKG::ms-gsl,Microsoft.GSL::GSL>
|
Microsoft.GSL::GSL
|
||||||
)
|
)
|
||||||
target_include_directories(mp-units
|
target_include_directories(mp-units
|
||||||
INTERFACE
|
INTERFACE
|
||||||
@ -70,7 +70,7 @@ target_include_directories(mp-units
|
|||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
target_link_libraries(mp-units
|
target_link_libraries(mp-units
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<IF:$<TARGET_EXISTS:CONAN_PKG::range-v3>,CONAN_PKG::range-v3,range-v3::range-v3>
|
range-v3::range-v3
|
||||||
)
|
)
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
target_compile_options(mp-units
|
target_compile_options(mp-units
|
||||||
|
@ -27,7 +27,7 @@ function(add_metabench_test target name erb_path range)
|
|||||||
target_compile_features(${target} PUBLIC cxx_std_20)
|
target_compile_features(${target} PUBLIC cxx_std_20)
|
||||||
target_link_libraries(${target}
|
target_link_libraries(${target}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<IF:$<TARGET_EXISTS:CONAN_PKG::range-v3>,CONAN_PKG::range-v3,range-v3::range-v3>
|
range-v3::range-v3>
|
||||||
)
|
)
|
||||||
target_compile_options(${target}
|
target_compile_options(${target}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
# check if conan installed a test framework
|
find_package(Catch2 CONFIG REQUIRED)
|
||||||
conan_check_testing(catch2)
|
|
||||||
|
|
||||||
add_executable(unit_tests_runtime
|
add_executable(unit_tests_runtime
|
||||||
catch_main.cpp
|
catch_main.cpp
|
||||||
@ -36,7 +35,7 @@ add_executable(unit_tests_runtime
|
|||||||
target_link_libraries(unit_tests_runtime
|
target_link_libraries(unit_tests_runtime
|
||||||
PRIVATE
|
PRIVATE
|
||||||
mp-units::mp-units
|
mp-units::mp-units
|
||||||
$<IF:$<TARGET_EXISTS:CONAN_PKG::catch2>,CONAN_PKG::catch2,Catch2::Catch2>
|
Catch2::Catch2
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
Reference in New Issue
Block a user