mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-29 18:07:16 +02:00
Compiler version specific configuration support added
This commit is contained in:
@ -25,16 +25,15 @@ project(units)
|
|||||||
|
|
||||||
# set path to custom cmake modules
|
# 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")
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/common/cmake")
|
|
||||||
|
|
||||||
# include common tools and workarounds
|
# include common tools and workarounds
|
||||||
include(tools)
|
include(common/cmake/tools)
|
||||||
|
|
||||||
# use Conan configuration if available
|
# use Conan configuration if available
|
||||||
conan_init(cmake)
|
conan_init(cmake)
|
||||||
|
|
||||||
# compilation options and flags used in a project development process
|
# compilation options and flags used in a project development process
|
||||||
include(compile_flags)
|
include(common/cmake/compile_flags)
|
||||||
|
|
||||||
# add project code
|
# add project code
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
30
cmake/check_features.cmake
Normal file
30
cmake/check_features.cmake
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2018 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.
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_FLAGS -std=c++2a)
|
||||||
|
|
||||||
|
include(CheckTypeSize)
|
||||||
|
|
||||||
|
set(CMAKE_EXTRA_INCLUDE_FILES type_traits)
|
||||||
|
check_type_size("std::type_identity<int>" UNITS_HAS_STD_TYPE_IDENTITY LANGUAGE CXX)
|
||||||
|
|
||||||
|
configure_file(../cmake/config.h.in include/units/bits/config.h)
|
25
cmake/config.h.in
Normal file
25
cmake/config.h.in
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// The MIT License (MIT)
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 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.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#cmakedefine UNITS_HAS_STD_TYPE_IDENTITY
|
@ -85,4 +85,6 @@ class UnitsConan(ConanFile):
|
|||||||
self.cpp_info.includedirs = ['include']
|
self.cpp_info.includedirs = ['include']
|
||||||
|
|
||||||
def package_id(self):
|
def package_id(self):
|
||||||
self.info.header_only()
|
self.info.settings.clear()
|
||||||
|
self.info.settings.compiler = self.settings.compiler
|
||||||
|
self.info.settings.compiler.version = self.settings.compiler.version
|
||||||
|
@ -29,10 +29,13 @@ project(units
|
|||||||
)
|
)
|
||||||
|
|
||||||
# set path to custom cmake modules
|
# set path to custom cmake modules
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/common/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
||||||
|
|
||||||
# include common tools and workarounds
|
# include common tools and workarounds
|
||||||
include(tools)
|
include(common/cmake/tools)
|
||||||
|
|
||||||
|
# check availability of C++20 features
|
||||||
|
include(check_features)
|
||||||
|
|
||||||
# library definition
|
# library definition
|
||||||
add_library(units INTERFACE)
|
add_library(units INTERFACE)
|
||||||
@ -59,7 +62,7 @@ target_link_libraries(units
|
|||||||
target_include_directories(units
|
target_include_directories(units
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
add_library(mp::units ALIAS units)
|
add_library(mp::units ALIAS units)
|
||||||
@ -75,6 +78,10 @@ install(DIRECTORY include/units
|
|||||||
DESTINATION include
|
DESTINATION include
|
||||||
COMPONENT Devel
|
COMPONENT Devel
|
||||||
)
|
)
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/units
|
||||||
|
DESTINATION include
|
||||||
|
COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
# generate configuration files and install the package
|
# generate configuration files and install the package
|
||||||
configure_and_install(../cmake/common/cmake/simple_package-config.cmake.in mp SameMajorVersion)
|
configure_and_install(../cmake/common/cmake/simple_package-config.cmake.in mp SameMajorVersion)
|
||||||
|
@ -22,10 +22,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <units/bits/config.h>
|
||||||
#include <experimental/ranges/concepts>
|
#include <experimental/ranges/concepts>
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
|
#ifndef UNITS_HAS_STD_TYPE_IDENTITY
|
||||||
|
|
||||||
// type_identity
|
// type_identity
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct type_identity { using type = T; };
|
struct type_identity { using type = T; };
|
||||||
@ -33,6 +36,8 @@ namespace std {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
using type_identity_t = typename type_identity<T>::type;
|
using type_identity_t = typename type_identity<T>::type;
|
||||||
|
|
||||||
|
#endif // UNITS_HAS_STD_TYPE_IDENTITY
|
||||||
|
|
||||||
// concepts
|
// concepts
|
||||||
using experimental::ranges::Same;
|
using experimental::ranges::Same;
|
||||||
using experimental::ranges::Integral;
|
using experimental::ranges::Integral;
|
||||||
|
Reference in New Issue
Block a user