build: Library renamed to mp::units

This commit is contained in:
Mateusz Pusz
2020-12-17 23:06:37 +01:00
parent 6a23718969
commit 206712f046
21 changed files with 166 additions and 115 deletions

View File

@ -0,0 +1,108 @@
# 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.
name: mp-units CMake Test Package CI
on:
push:
paths-ignore:
- 'docs/**'
- 'example/**'
- 'test/**'
pull_request:
paths-ignore:
- 'docs/**'
- 'example/**'
- 'test/**'
env:
CC: gcc-10
CXX: g++-10
jobs:
setup:
name: Environment setup
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Cache Conan data
uses: actions/cache@v2
env:
cache-name: cache-conan-data
with:
path: ~/.conan/data
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/metadata.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install Conan
run: |
pip install -U conan
- name: Configure Conan
run: |
conan config init
conan remote add upload ${{ secrets.CONAN_UPLOAD }}
install:
name: mp-units installation
needs: setup
runs-on: ubuntu-20.04
steps:
- name: Install Conan dependencies
run: |
mkdir build && cd build
conan install .. -s compiler.cppstd=20 -s compiler.libcxx=libstdc++11 -s build_type=Release -b outdated -u
conan install .. -s compiler.cppstd=20 -s compiler.libcxx=libstdc++11 -s build_type=Debug -b outdated -u
- name: Configure CMake
run: |
cd build
cmake ../src -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE=conan_paths.cmake
- name: Install
run: |
cd build
cmake --install . --prefix test_package --config Release
cmake --install . --prefix test_package --config Debug
test_package:
name: Testing CMake package
needs: install
runs-on: ubuntu-20.04
steps:
- name: Configure CMake
run: |
mkdir test_package/build && cd test_package/build
cmake .. -G "Ninja Multi-Config" -DCMAKE_INSTALL_PREFIX=../../build/test_package -DCMAKE_TOOLCHAIN_FILE=../../build/conan_paths.cmake
- name: Build and run Release
run: |
cd test_package/build
cmake --build . --config Release
./Release/test_package
- name: Build and run Debug
run: |
cd test_package/build
cmake --build . --config Debug
./Debug/test_package

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
project(mp-units
LANGUAGES CXX)

View File

@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.14)
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)

View File

@ -1,81 +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.
# A path to scripts directory
set(CMAKE_SCRIPTS_ROOT ${CMAKE_CURRENT_LIST_DIR})
# Install provided targets
function(install_targets)
if(NOT CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR "bin")
endif()
if(NOT CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
if(NOT CMAKE_INSTALL_INCLUDEDIR)
set(CMAKE_INSTALL_INCLUDEDIR "include")
endif()
install(TARGETS ${ARGN}
EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # TODO Remove when CMAKE 3.14
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # TODO Remove when CMAKE 3.14
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # TODO Remove when CMAKE 3.14
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endfunction()
# Generate configuration files and install the package
function(configure_and_install configure_in_file_path namespace version_compare_rules)
if(NOT APPLE)
set(CMAKE_INSTALL_RPATH ${ORIGIN})
endif()
# prepare installation files
include(CMakePackageConfigHelpers)
set(ConfigPackageSource ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME})
set(ConfigPackageDestination lib/cmake/${PROJECT_NAME})
write_basic_package_version_file(
${ConfigPackageSource}/${PROJECT_NAME}-config-version.cmake
COMPATIBILITY ${version_compare_rules})
configure_package_config_file(${configure_in_file_path}
${ConfigPackageSource}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${ConfigPackageDestination})
# install library
install(EXPORT ${PROJECT_NAME}Targets
DESTINATION ${ConfigPackageDestination}
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${namespace}::
COMPONENT Devel)
install(FILES
"${ConfigPackageSource}/${PROJECT_NAME}-config.cmake"
"${ConfigPackageSource}/${PROJECT_NAME}-config-version.cmake"
DESTINATION ${ConfigPackageDestination}
COMPONENT Devel)
# local package
export(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${namespace}::
FILE ${ConfigPackageSource}/${PROJECT_NAME}-targets.cmake)
endfunction()

View File

@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.14)
macro(enable_clang_tidy)
find_program(clang_tidy_cmd NAMES "clang-tidy")

View File

@ -22,6 +22,8 @@
# Based on https://github.com/lefticus/cpp_starter_project/blob/master/cmake/CompilerWarnings.cmake
cmake_minimum_required(VERSION 3.14)
# Configure compiler warning level
function(set_warnings target)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE)

View File

@ -129,13 +129,20 @@ class UnitsConan(ConanFile):
self.info.header_only()
def package_info(self):
self.cpp_info.filenames["cmake_find_package"] = "mp-units"
self.cpp_info.filenames["cmake_find_package_multi"] = "mp-units"
self.cpp_info.names["cmake_find_package"] = "mp"
self.cpp_info.names["cmake_find_package_multi"] = "mp"
self.cpp_info.components["units"].name = "units"
self.cpp_info.components["units"].requires = ["fmt::fmt", "ms-gsl::ms-gsl"]
compiler = self.settings.compiler
version = Version(self.settings.compiler.version)
if compiler == "gcc":
self.cpp_info.cxxflags = [
self.cpp_info.components["units"].cxxflags = [
"-Wno-non-template-friend"
]
elif compiler == "Visual Studio":
self.cpp_info.cxxflags = [
self.cpp_info.components["units"].cxxflags = [
"/utf-8"
]

View File

@ -20,7 +20,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
option(BUILD_DOCS "Generate project documentation" ON)
if(NOT BUILD_DOCS)
return()
endif()
# Find all the public headers
file(GLOB_RECURSE unitsPublicHeaders "${PROJECT_SOURCE_DIR}/src/*.h")
@ -221,9 +226,10 @@ set(unitsSphinxDocs
include(documentation)
include(GNUInstallDirs)
add_documentation(documentation
add_documentation(documentation ALL
BREATHE_PROJECT mp-units
CODE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src"
INSTALL_DIR ${CMAKE_INSTALL_DOCDIR}
CODE_DEPENDS ${unitsPublicHeaders}
DOCS_DEPENDS ${unitsSphinxDocs}
)

View File

@ -183,7 +183,7 @@ defined by the library. To do so you should use *CMakeLists.txt* file from the *
add_subdirectory(<path_to_units_folder>/src)
# ...
target_link_libraries(<your_target> PUBLIC|PRIVATE|INTERFACE mp-units::mp-units)
target_link_libraries(<your_target> PUBLIC|PRIVATE|INTERFACE mp::units)
.. important::
@ -228,7 +228,7 @@ library release the following steps may be performed:
.. code-block:: cmake
target_link_libraries(<your_target> PUBLIC|PRIVATE|INTERFACE mp-units::mp-units)
target_link_libraries(<your_target> PUBLIC|PRIVATE|INTERFACE mp::units)
target_compile_features(<your_target> PUBLIC|PRIVATE|INTERFACE cxx_std_20)
.. important::

View File

@ -20,11 +20,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
function(add_example target)
add_executable(${target} ${target}.cpp)
target_link_libraries(${target} PRIVATE mp-units::mp-units)
target_link_libraries(${target} PRIVATE mp::units)
endfunction()
add_example(box_example)

View File

@ -20,11 +20,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
function(add_example target)
add_executable(${target}_alt ${target}.cpp)
target_link_libraries(${target}_alt PRIVATE mp-units::mp-units)
target_link_libraries(${target}_alt PRIVATE mp::units)
endfunction()
add_example(box_example)

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
project(mp-units
VERSION 0.7.0
@ -78,16 +78,22 @@ else()
target_compile_definitions(mp-units INTERFACE UNITS_DOWNCAST_MODE=0)
endif()
add_library(mp-units::mp-units ALIAS mp-units)
include(install)
add_library(mp::units ALIAS mp-units)
set_target_properties(mp-units PROPERTIES EXPORT_NAME units)
# installation info
install_targets(mp-units)
install(DIRECTORY include/units
DESTINATION include
COMPONENT Devel
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(mp-unitsConfigVersion.cmake COMPATIBILITY SameMajorVersion)
# generate configuration files and install the package
configure_and_install(../cmake/mp-units-config.cmake.in mp-units SameMajorVersion)
include(GNUInstallDirs)
install(TARGETS mp-units EXPORT mp-unitsTargets)
install(EXPORT mp-unitsTargets
NAMESPACE mp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units
)
install(FILES mp-unitsConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/mp-unitsConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mp-units
)
install(DIRECTORY include/units
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

View File

@ -23,4 +23,5 @@
include(CMakeFindDependencyMacro)
find_dependency(fmt)
find_dependency(Microsoft.GSL)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/mp-unitsTargets.cmake")

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
add_subdirectory(unit_test/runtime)
add_subdirectory(unit_test/static)

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
function(add_metabench_test target name erb_path range)
metabench_add_dataset(${target} "${erb_path}" "${range}" NAME "${name}")

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
add_metabench_test(metabench.data.list.type_list.concepts_all "all concepts" type_list_concepts_all.cpp.erb "[3, 6, 9, 12, 15]")
add_metabench_test(metabench.data.list.type_list.concepts_iface "concepts in interface" type_list_concepts_iface.cpp.erb "[3, 6, 9, 12, 15]")

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
add_metabench_test(metabench.data.make_dimension.no_concepts "no concepts" no_concepts.cpp.erb "[1, 2, 3, 4, 6, 8, 10]")
add_metabench_test(metabench.data.make_dimension.concepts_iface "concepts iface" concepts_iface.cpp.erb "[1, 2, 3, 4, 6, 8, 10]")

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
add_metabench_test(metabench.data.ratio.create.std_ratio "std::ratio" create_std_ratio.cpp.erb "[1000, 2500, 5000, 7500, 10000]")
add_metabench_test(metabench.data.ratio.create.ratio_type_constexpr "ratio with constexpr" create_ratio_type_constexpr.cpp.erb "[1000, 2500, 5000, 7500, 10000]")

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
find_package(Catch2 CONFIG REQUIRED)
@ -34,7 +34,7 @@ add_executable(unit_tests_runtime
)
target_link_libraries(unit_tests_runtime
PRIVATE
mp-units::mp-units
mp::units
Catch2::Catch2
)

View File

@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.14)
add_library(unit_tests_static
cgs_test.cpp
@ -48,5 +48,5 @@ add_library(unit_tests_static
)
target_link_libraries(unit_tests_static
PRIVATE
mp-units::mp-units
mp::units
)

View File

@ -26,8 +26,8 @@ project(test_package)
# enable package discovery based on the local configuration files
list(PREPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
# test cmake-generated target
find_package(mp-units CONFIG REQUIRED)
add_executable(test_package test_package.cpp)
target_link_libraries(test_package PRIVATE mp-units::mp-units)
target_link_libraries(test_package PRIVATE mp::units)
target_compile_features(test_package PRIVATE cxx_std_20)