From aa7c021962f529f3ed2f482fd6f02e5497532a8a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 7 Jun 2023 16:41:32 +0200 Subject: project: begin restructuring --- .gitignore | 5 +- .travis.yml | 42 - .vscode/settings.json | 6 +- CMakeLists.txt | 281 ------- cmake/Modules/Conan.cmake | 554 ------------- cmake/Modules/DiscoverTests.cmake | 55 -- cmake/Modules/DiscoverTestsImpl.cmake | 39 - cmake/config.cmake.in | 4 - conanfile.py | 92 ++- examples/src/basic_usage.cpp | 39 - examples/src/basic_usage_with_read.cpp | 39 - examples/src/basic_usage_with_show.cpp | 41 - include/newtype/derivable.hpp | 32 - include/newtype/derivation_clause.hpp | 70 -- include/newtype/deriving.hpp | 21 - include/newtype/impl/new_type_iterator_types.hpp | 66 -- include/newtype/impl/new_type_storage.hpp | 139 ---- include/newtype/impl/type_traits_extensions.hpp | 853 --------------------- include/newtype/newtype.hpp | 550 ------------- include/newtype/version.hpp | 23 - source/CMakeLists.txt | 88 +++ source/examples/src/basic_usage.cpp | 39 + source/examples/src/basic_usage_with_read.cpp | 39 + source/examples/src/basic_usage_with_show.cpp | 41 + source/include/newtype/derivable.hpp | 32 + source/include/newtype/derivation_clause.hpp | 70 ++ source/include/newtype/deriving.hpp | 21 + .../newtype/impl/new_type_iterator_types.hpp | 66 ++ source/include/newtype/impl/new_type_storage.hpp | 139 ++++ .../newtype/impl/type_traits_extensions.hpp | 853 +++++++++++++++++++++ source/include/newtype/newtype.hpp | 550 +++++++++++++ source/include/newtype/version.hpp | 23 + source/test/src/arithmetic.cpp | 300 ++++++++ source/test/src/conversion_suite.cpp | 201 +++++ source/test/src/derivation_clause_suite.cpp | 312 ++++++++ source/test/src/equality_comparison_suite.cpp | 188 +++++ source/test/src/hash_suite.cpp | 69 ++ source/test/src/io_operators_suite.cpp | 121 +++ source/test/src/iterable_suite.cpp | 719 +++++++++++++++++ source/test/src/new_type_constructor_suite.cpp | 91 +++ source/test/src/relational_operators_suite.cpp | 321 ++++++++ test/include/arithmetic_suite.hpp | 11 - test/include/conversion_suite.hpp | 11 - test/include/derivation_clause_suite.hpp | 11 - test/include/equality_comparison_suite.hpp | 11 - test/include/hash_suite.hpp | 11 - test/include/io_operators_suite.hpp | 11 - test/include/iterable_suite.hpp | 11 - test/include/kawaii.hpp | 143 ---- test/include/new_type_constructor_suite.hpp | 11 - test/include/relational_operators_suite.hpp | 11 - test/src/arithmetic_suite.cpp | 330 -------- test/src/conversion_suite.cpp | 201 ----- test/src/derivation_clause_suite.cpp | 312 -------- test/src/driver.cpp | 101 --- test/src/equality_comparison_suite.cpp | 188 ----- test/src/hash_suite.cpp | 69 -- test/src/io_operators_suite.cpp | 121 --- test/src/iterable_suite.cpp | 719 ----------------- test/src/new_type_constructor_suite.cpp | 91 --- test/src/relational_operators_suite.cpp | 321 -------- test_package/CMakeLists.txt | 13 +- test_package/conanfile.py | 16 +- test_package/main.cpp | 2 +- 64 files changed, 4368 insertions(+), 5592 deletions(-) delete mode 100644 .travis.yml delete mode 100644 CMakeLists.txt delete mode 100644 cmake/Modules/Conan.cmake delete mode 100644 cmake/Modules/DiscoverTests.cmake delete mode 100644 cmake/Modules/DiscoverTestsImpl.cmake delete mode 100644 cmake/config.cmake.in delete mode 100644 examples/src/basic_usage.cpp delete mode 100644 examples/src/basic_usage_with_read.cpp delete mode 100644 examples/src/basic_usage_with_show.cpp delete mode 100644 include/newtype/derivable.hpp delete mode 100644 include/newtype/derivation_clause.hpp delete mode 100644 include/newtype/deriving.hpp delete mode 100644 include/newtype/impl/new_type_iterator_types.hpp delete mode 100644 include/newtype/impl/new_type_storage.hpp delete mode 100644 include/newtype/impl/type_traits_extensions.hpp delete mode 100644 include/newtype/newtype.hpp delete mode 100644 include/newtype/version.hpp create mode 100644 source/CMakeLists.txt create mode 100644 source/examples/src/basic_usage.cpp create mode 100644 source/examples/src/basic_usage_with_read.cpp create mode 100644 source/examples/src/basic_usage_with_show.cpp create mode 100644 source/include/newtype/derivable.hpp create mode 100644 source/include/newtype/derivation_clause.hpp create mode 100644 source/include/newtype/deriving.hpp create mode 100644 source/include/newtype/impl/new_type_iterator_types.hpp create mode 100644 source/include/newtype/impl/new_type_storage.hpp create mode 100644 source/include/newtype/impl/type_traits_extensions.hpp create mode 100644 source/include/newtype/newtype.hpp create mode 100644 source/include/newtype/version.hpp create mode 100644 source/test/src/arithmetic.cpp create mode 100644 source/test/src/conversion_suite.cpp create mode 100644 source/test/src/derivation_clause_suite.cpp create mode 100644 source/test/src/equality_comparison_suite.cpp create mode 100644 source/test/src/hash_suite.cpp create mode 100644 source/test/src/io_operators_suite.cpp create mode 100644 source/test/src/iterable_suite.cpp create mode 100644 source/test/src/new_type_constructor_suite.cpp create mode 100644 source/test/src/relational_operators_suite.cpp delete mode 100644 test/include/arithmetic_suite.hpp delete mode 100644 test/include/conversion_suite.hpp delete mode 100644 test/include/derivation_clause_suite.hpp delete mode 100644 test/include/equality_comparison_suite.hpp delete mode 100644 test/include/hash_suite.hpp delete mode 100644 test/include/io_operators_suite.hpp delete mode 100644 test/include/iterable_suite.hpp delete mode 100644 test/include/kawaii.hpp delete mode 100644 test/include/new_type_constructor_suite.hpp delete mode 100644 test/include/relational_operators_suite.hpp delete mode 100644 test/src/arithmetic_suite.cpp delete mode 100644 test/src/conversion_suite.cpp delete mode 100644 test/src/derivation_clause_suite.cpp delete mode 100644 test/src/driver.cpp delete mode 100644 test/src/equality_comparison_suite.cpp delete mode 100644 test/src/hash_suite.cpp delete mode 100644 test/src/io_operators_suite.cpp delete mode 100644 test/src/iterable_suite.cpp delete mode 100644 test/src/new_type_constructor_suite.cpp delete mode 100644 test/src/relational_operators_suite.cpp diff --git a/.gitignore b/.gitignore index 42afabf..cebfa4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -/build \ No newline at end of file +/.cache +/build +/source/CMakeUserPresets.json +/test_package/CMakeUserPresets.json diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f523e70..0000000 --- a/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -os: linux -language: python -python: "3.7" -dist: bionic - -addons: - apt: - sources: - - sourceline: 'ppa:ubuntu-toolchain-r/test' - - sourceline: 'deb https://apt.kitware.com/ubuntu/ bionic main' - key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc' - packages: - - g++-9 - - cmake - - libperlio-gzip-perl - - libjson-perl - -compiler: - - gcc - -cache: - directories: - - $HOME/.conan/data - -before_install: - - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 20 - - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 20 - - sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-9 20 - - sudo update-alternatives --config gcc - - sudo update-alternatives --config g++ - - sudo update-alternatives --config gcov - -install: - - pip install conan - - conan user - - git clone git://github.com/linux-test-project/lcov.git - - cd lcov && sudo make install - - cd .. - -script: - - /usr/bin/cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=YES -DRUN_TESTS_AFTER_BUILD=YES -DENABLE_CODE_COVERAGE=YES -DPRINT_COVERAGE_REPORT=YES - - /usr/bin/cmake --build build --target all --parallel $(nproc) diff --git a/.vscode/settings.json b/.vscode/settings.json index d237db4..24f5d88 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,9 @@ "C_Cpp.autoAddFileAssociations": false, // RST Configuration - "restructuredtext.confPath": "${workspaceFolder}/doc/src" + "restructuredtext.confPath": "${workspaceFolder}/doc/src", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "python.formatting.provider": "none" } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 3c29a76..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,281 +0,0 @@ -cmake_minimum_required(VERSION "3.9.0") - -project("newtype" - VERSION "1.1.0" - LANGUAGES CXX - DESCRIPTION "A library of types and functions to create strong type aliases" -) - -include("CMakePackageConfigHelpers") - -# Project Options - -option(RUN_TESTS_AFTER_BUILD "Automatically run the unit tests after building" ON) -option(BUILD_TESTING "Build the unit tests" ON) -option(ENABLE_CODE_COVERAGE "Enable building support for code coverage report generation" ON) -option(PRINT_COVERAGE_REPORT "Print a coverage report after running the unit tests" ON) -option(GENERATE_COVERAGE_REPORT "Generate an HTML coverage report after running the unit tests" OFF) - -# 'newtype' library - -add_library("${PROJECT_NAME}" INTERFACE) - -target_include_directories("${PROJECT_NAME}" INTERFACE - $ - $ -) - -target_compile_features("${PROJECT_NAME}" INTERFACE - "cxx_std_20" -) - -install(TARGETS "${PROJECT_NAME}" - EXPORT "${PROJECT_NAME}Targets" - PUBLIC_HEADER DESTINATION "include" -) - -install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" - DESTINATION "include" -) - -# 'newtype' tests - -if(BUILD_TESTING) - enable_testing() - - if(PRINT_COVERAGE_REPORT) - find_program(LCOV_EXE NAMES "lcov") - mark_as_advanced(LCOV_EXE) - if(NOT LCOV_EXE) - message(FATAL_ERROR "lcov is required to generate code coverage reports") - endif() - endif() - - if(GENERATE_COVERAGE_REPORT) - find_program(GENHTML_EXE NAMES "genhtml") - mark_as_advanced(GENHTML_EXE) - if(NOT GENHTML_EXE) - message(FATAL_ERROR "genhtml is required to generate code coverage reports") - endif() - endif() - - include("${PROJECT_SOURCE_DIR}/cmake/Modules/DiscoverTests.cmake") - include("${PROJECT_SOURCE_DIR}/cmake/Modules/Conan.cmake") - - conan_check(REQUIRED) - conan_add_remote(NAME "fmorgner-public" URL "https://api.bintray.com/conan/fmorgner/conan-public") - conan_cmake_run(CONANFILE "conanfile.py" - OUTPUT_QUIET - BASIC_SETUP - CMAKE_TARGETS - BUILD "missing" - NO_OUTPUT_DIRS - ) - - add_executable("${PROJECT_NAME}_tests" - "${PROJECT_SOURCE_DIR}/test/src/driver.cpp" - - "${PROJECT_SOURCE_DIR}/test/src/arithmetic_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/conversion_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/derivation_clause_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/equality_comparison_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/hash_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/io_operators_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/iterable_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/new_type_constructor_suite.cpp" - "${PROJECT_SOURCE_DIR}/test/src/relational_operators_suite.cpp" - ) - - target_include_directories("${PROJECT_NAME}_tests" PRIVATE - "${PROJECT_SOURCE_DIR}/test/include" - ) - - target_link_libraries("${PROJECT_NAME}_tests" - "newtype" - "CONAN_PKG::CUTE" - "CONAN_PKG::lyra" - ) - - target_compile_options("${PROJECT_NAME}_tests" PRIVATE - "-Wall" - "-Wextra" - "-Werror" - "-pedantic-errors" - $<$:--coverage> - ) - - target_link_options("${PROJECT_NAME}_tests" PRIVATE - $<$:--coverage> - ) - - set_target_properties("${PROJECT_NAME}_tests" PROPERTIES - CXX_EXTENSIONS OFF - ) - - discover_tests(TARGET "${PROJECT_NAME}_tests") - - if(RUN_TESTS_AFTER_BUILD) - add_custom_command(TARGET "${PROJECT_NAME}_tests" - POST_BUILD - DEPENDS "${PROJECT_NAME}_tests" - COMMAND "${CMAKE_CTEST_COMMAND}" - ARGS - "--output-on-failure" - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" - COMMENT "Running unit tests" - ) - endif() - - if(ENABLE_CODE_COVERAGE AND RUN_TESTS_AFTER_BUILD) - add_custom_command(TARGET "${PROJECT_NAME}_tests" - POST_BUILD - BYPRODUCTS "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.coverage.info" - COMMAND "${LCOV_EXE}" - ARGS - "--capture" - "--base-directory" "${PROJECT_SOURCE_DIR}" - "--directory" "${PROJECT_BINARY_DIR}" - "--output-file" "${PROJECT_NAME}.coverage.info" - "--no-external" - "--exclude" "${PROJECT_SOURCE_DIR}/test/\\*" - ">/dev/null" - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" - COMMENT "Capturing code coverage data" - ) - - if(PRINT_COVERAGE_REPORT) - add_custom_command(TARGET "${PROJECT_NAME}_tests" - POST_BUILD - COMMAND "${LCOV_EXE}" - ARGS - "--list" - "${PROJECT_NAME}.coverage.info" - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" - COMMENT "Printing code coverage report" - ) - endif() - - if(GENERATE_COVERAGE_REPORT) - add_custom_command(TARGET "${PROJECT_NAME}_tests" - POST_BUILD - BYPRODUCTS "${PROJECT_BINARY_DIR}/coverage-report/index.html" - COMMAND "${GENHTML_EXE}" - ARGS - "--demangle-cpp" - "--highlight" - "--missed" - "--show-details" - "--output" "coverage-report" - "${PROJECT_NAME}.coverage.info" - ">/dev/null" - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" - COMMENT "Generating code coverage report" - ) - endif() - endif() -endif() - -# 'newtype' docs - -option(BUILD_DOCS "Build the library documentation" OFF) - -if(BUILD_DOCS) - find_program(PIPENV_EXE NAMES "pipenv3" "pipenv") - mark_as_advanced(PIPENV_EXE) - if(NOT PIPENV_EXE) - message(FATAL_ERROR "Could not find pipenv") - endif() - - message(STATUS "Installing documentation dependencies via pipenv") - execute_process(COMMAND "${PIPENV_EXE}" "install" "-r" "requirements.txt" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/doc" - OUTPUT_QUIET - ERROR_QUIET - ) - - set(DOC_SOURCES - "${PROJECT_SOURCE_DIR}/doc/src/index.rst" - "${PROJECT_SOURCE_DIR}/doc/src/conf.py" - "${PROJECT_SOURCE_DIR}/examples/src/basic_usage.cpp" - "${PROJECT_SOURCE_DIR}/examples/src/basic_usage_with_show.cpp" - "${PROJECT_SOURCE_DIR}/examples/src/basic_usage_with_read.cpp" - ) - - add_custom_target("docs" - DEPENDS "${PROJECT_BINARY_DIR}/doc/html/index.html" "${PROJECT_BINARY_DIR}/doc/man/newtype.3" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/doc" - COMMENT "Building documentation" - ) - - add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/doc/html/index.html" - COMMAND "${PIPENV_EXE}" "run" "sphinx-build" "-b" "singlehtml" "${PROJECT_SOURCE_DIR}/doc/src" "${PROJECT_BINARY_DIR}/doc/html" ">/dev/null" - DEPENDS ${DOC_SOURCES} - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/doc" - COMMENT "Compiling HTML documentation" - ) - - add_custom_command(OUTPUT "${PROJECT_BINARY_DIR}/doc/man/newtype.3" - COMMAND "${PIPENV_EXE}" "run" "sphinx-build" "-b" "man" "${PROJECT_SOURCE_DIR}/doc/src" "${PROJECT_BINARY_DIR}/doc/man" ">/dev/null" - DEPENDS ${DOC_SOURCES} - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/doc" - COMMENT "Compiling man pages" - ) - - add_dependencies("${PROJECT_NAME}" "docs") - - install(DIRECTORY "${PROJECT_BINARY_DIR}/doc/html" - DESTINATION "share/doc/${PROJECT_NAME}" - PATTERN ".nojekyll" EXCLUDE - PATTERN ".buildinfo" EXCLUDE - PATTERN ".doctrees" EXCLUDE - PATTERN "objects.inv" EXCLUDE - ) - - install(FILES "${PROJECT_BINARY_DIR}/doc/man/${PROJECT_NAME}.3" - DESTINATION "share/man/man3" - ) -endif() - -# 'newtype' examples - -option(BUILD_EXAMPLES "Build the library examples" OFF) - -if(BUILD_EXAMPLES) - function(add_example NAME) - add_executable("ex_${NAME}" - "examples/src/${NAME}.cpp" - ) - target_link_libraries("ex_${NAME}" "${PROJECT_NAME}") - endfunction() - - add_example("basic_usage") - add_example("basic_usage_with_show") - add_example("basic_usage_with_read") -endif() - -# CMake support files - -write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - COMPATIBILITY "AnyNewerVersion" -) - -configure_package_config_file( - "${PROJECT_SOURCE_DIR}/cmake/config.cmake.in" - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION "lib/cmake/${PROJECT_NAME}" -) - -install(FILES - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - DESTINATION "lib/cmake/${PROJECT_NAME}" -) - -install(DIRECTORY "${PROJECT_SOURCE_DIR}/doc/src/" - DESTINATION "share/doc/newtype" -) - -install(EXPORT "${PROJECT_NAME}Targets" - DESTINATION "lib/cmake/${PROJECT_NAME}" -) diff --git a/cmake/Modules/Conan.cmake b/cmake/Modules/Conan.cmake deleted file mode 100644 index aac3b9c..0000000 --- a/cmake/Modules/Conan.cmake +++ /dev/null @@ -1,554 +0,0 @@ -# The MIT License (MIT) - -# Copyright (c) 2018 JFrog - -# 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. - - - -# This file comes from: https://github.com/conan-io/cmake-conan. Please refer -# to this repository for issues and documentation. - -# Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called. -# It will take CMake current settings (os, compiler, compiler version, architecture) -# and translate them to conan settings for installing and retrieving dependencies. - -# It is intended to facilitate developers building projects that have conan dependencies, -# but it is only necessary on the end-user side. It is not necessary to create conan -# packages, in fact it shouldn't be use for that. Check the project documentation. - - -include(CMakeParseArguments) - -function(_get_msvc_ide_version result) - set(${result} "" PARENT_SCOPE) - if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500) - set(${result} 8 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600) - set(${result} 9 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700) - set(${result} 10 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800) - set(${result} 11 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) - set(${result} 12 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910) - set(${result} 14 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920) - set(${result} 15 PARENT_SCOPE) - elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) - set(${result} 16 PARENT_SCOPE) - else() - message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") - endif() -endfunction() - -function(conan_cmake_settings result) - #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER}) - #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID}) - #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION}) - #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS}) - #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE}) - #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE}) - #message(STATUS "GENERATOR " ${CMAKE_GENERATOR}) - #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64}) - - message(STATUS "Conan: Automatic detection of conan settings from cmake") - - parse_arguments(${ARGV}) - - if(ARGUMENTS_BUILD_TYPE) - set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE}) - elseif(CMAKE_BUILD_TYPE) - set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE}) - else() - message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") - endif() - - string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER) - if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG") - set(_CONAN_SETTING_BUILD_TYPE "Debug") - elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE") - set(_CONAN_SETTING_BUILD_TYPE "Release") - elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO") - set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo") - elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL") - set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel") - endif() - - if(ARGUMENTS_ARCH) - set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH}) - endif() - #handle -s os setting - if(CMAKE_SYSTEM_NAME) - #use default conan os setting if CMAKE_SYSTEM_NAME is not defined - set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) - if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(CONAN_SYSTEM_NAME Macos) - endif() - set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore) - list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index) - if (${_index} GREATER -1) - #check if the cmake system is a conan supported one - set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME}) - else() - message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}") - endif() - endif() - - get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) - if (";${_languages};" MATCHES ";CXX;") - set(LANGUAGE CXX) - set(USING_CXX 1) - elseif (";${_languages};" MATCHES ";C;") - set(LANGUAGE C) - set(USING_CXX 0) - else () - message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.") - endif() - - if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) - # using GCC - # TODO: Handle other params - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - set(COMPILER_VERSION ${MAJOR}.${MINOR}) - if(${MAJOR} GREATER 4) - set(COMPILER_VERSION ${MAJOR}) - endif() - set(_CONAN_SETTING_COMPILER gcc) - set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang) - # using AppleClang - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - set(_CONAN_SETTING_COMPILER apple-clang) - set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang) - string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) - list(GET VERSION_LIST 0 MAJOR) - list(GET VERSION_LIST 1 MINOR) - set(_CONAN_SETTING_COMPILER clang) - set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) - if(APPLE) - cmake_policy(GET CMP0025 APPLE_CLANG_POLICY_ENABLED) - if(NOT APPLE_CLANG_POLICY_ENABLED) - message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it") - set(_CONAN_SETTING_COMPILER apple-clang) - endif() - endif() - if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7) - set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}) - endif() - if (USING_CXX) - conan_cmake_detect_unix_libcxx(_LIBCXX) - set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) - endif () - elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC) - set(_VISUAL "Visual Studio") - _get_msvc_ide_version(_VISUAL_VERSION) - if("${_VISUAL_VERSION}" STREQUAL "") - message(FATAL_ERROR "Conan: Visual Studio not recognized") - else() - set(_CONAN_SETTING_COMPILER ${_VISUAL}) - set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION}) - endif() - - if(NOT _CONAN_SETTING_ARCH) - if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64") - set(_CONAN_SETTING_ARCH x86_64) - elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM") - message(STATUS "Conan: Using default ARM architecture from MSVC") - set(_CONAN_SETTING_ARCH armv6) - elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86") - set(_CONAN_SETTING_ARCH x86) - else () - message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]") - endif() - endif() - - conan_cmake_detect_vs_runtime(_vs_runtime) - message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}") - set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime}) - - if (CMAKE_GENERATOR_TOOLSET) - set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) - elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja")) - set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) - endif() - else() - message(FATAL_ERROR "Conan: compiler setup not recognized") - endif() - - # If profile is defined it is used - if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE}) - elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE}) - elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE}) - elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE}) - elseif(ARGUMENTS_PROFILE) - set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE}) - endif() - - foreach(ARG ${_APPLIED_PROFILES}) - set(_SETTINGS ${_SETTINGS} -pr ${ARG}) - endforeach() - - if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL") - set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version - compiler.runtime compiler.libcxx compiler.toolset) - endif() - - # Automatic from CMake - foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) - string(TOUPPER ${ARG} _arg_name) - string(REPLACE "." "_" _arg_name ${_arg_name}) - if(_CONAN_SETTING_${_arg_name}) - set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}}) - endif() - endforeach() - - foreach(ARG ${ARGUMENTS_SETTINGS}) - set(_SETTINGS ${_SETTINGS} -s ${ARG}) - endforeach() - - message(STATUS "Conan: Settings= ${_SETTINGS}") - - set(${result} ${_SETTINGS} PARENT_SCOPE) -endfunction() - - -function(conan_cmake_detect_unix_libcxx result) - # Take into account any -stdlib in compile options - get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) - - # Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions - get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) - foreach(define ${defines}) - if(define MATCHES "_GLIBCXX_USE_CXX11_ABI") - if(define MATCHES "^-D") - set(compile_options ${compile_options} "${define}") - else() - set(compile_options ${compile_options} "-D${define}") - endif() - endif() - endforeach() - - execute_process( - COMMAND ${CMAKE_COMMAND} -E echo "#include " - COMMAND ${CMAKE_CXX_COMPILER} -x c++ ${compile_options} -E -dM - - OUTPUT_VARIABLE string_defines - ) - - if(string_defines MATCHES "#define __GLIBCXX__") - # Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake - if(DEFINED _GLIBCXX_USE_CXX11_ABI) - if(_GLIBCXX_USE_CXX11_ABI) - set(${result} libstdc++11 PARENT_SCOPE) - return() - else() - set(${result} libstdc++ PARENT_SCOPE) - return() - endif() - endif() - - if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n") - set(${result} libstdc++11 PARENT_SCOPE) - else() - # Either the compiler is missing the define because it is old, and so - # it can't use the new abi, or the compiler was configured to use the - # old abi by the user or distro (e.g. devtoolset on RHEL/CentOS) - set(${result} libstdc++ PARENT_SCOPE) - endif() - else() - set(${result} libc++ PARENT_SCOPE) - endif() -endfunction() - -function(conan_cmake_detect_vs_runtime result) - string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) - set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) - foreach(variable ${variables}) - string(REPLACE " " ";" flags ${${variable}}) - foreach (flag ${flags}) - if(${flag} STREQUAL "/MD" OR ${flag} STREQUAL "/MDd" OR ${flag} STREQUAL "/MT" OR ${flag} STREQUAL "/MTd") - string(SUBSTRING ${flag} 1 -1 runtime) - set(${result} ${runtime} PARENT_SCOPE) - return() - endif() - endforeach() - endforeach() - if(${build_type} STREQUAL "DEBUG") - set(${result} "MDd" PARENT_SCOPE) - else() - set(${result} "MD" PARENT_SCOPE) - endif() -endfunction() - - -macro(parse_arguments) - set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS) - set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER CONAN_COMMAND) - set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE - PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO - INSTALL_ARGS) - cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) -endmacro() - -function(conan_cmake_install) - # Calls "conan install" - # Argument BUILD is equivalant to --build={missing, PkgName,...} or - # --build when argument is 'BUILD all' (which builds all packages from source) - # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source - # cmake does not identify conan as command, even if it is +x and it is in the path - parse_arguments(${ARGV}) - - if(CONAN_CMAKE_MULTI) - set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi) - else() - set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake) - endif() - - set(CONAN_BUILD_POLICY "") - foreach(ARG ${ARGUMENTS_BUILD}) - if(${ARG} STREQUAL "all") - set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build) - break() - else() - set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG}) - endif() - endforeach() - if(ARGUMENTS_CONAN_COMMAND) - set(conan_command ${ARGUMENTS_CONAN_COMMAND}) - else() - set(conan_command conan) - endif() - set(CONAN_OPTIONS "") - if(ARGUMENTS_CONANFILE) - set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE}) - # A conan file has been specified - apply specified options as well if provided - foreach(ARG ${ARGUMENTS_OPTIONS}) - set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG}) - endforeach() - else() - set(CONANFILE ".") - endif() - if(ARGUMENTS_UPDATE) - set(CONAN_INSTALL_UPDATE --update) - endif() - if(ARGUMENTS_NO_IMPORTS) - set(CONAN_INSTALL_NO_IMPORTS --no-imports) - endif() - set(CONAN_INSTALL_FOLDER "") - if(ARGUMENTS_INSTALL_FOLDER) - set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER}) - endif() - foreach(ARG ${ARGUMENTS_GENERATORS}) - set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG}) - endforeach() - foreach(ARG ${ARGUMENTS_ENV}) - set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG}) - endforeach() - set(conan_args install ${CONANFILE} ${settings} ${CONAN_ENV_VARS} ${CONAN_GENERATORS} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_INSTALL_NO_IMPORTS} ${CONAN_OPTIONS} ${CONAN_INSTALL_FOLDER} ${ARGUMENTS_INSTALL_ARGS}) - - string (REPLACE ";" " " _conan_args "${conan_args}") - message(STATUS "Conan executing: ${conan_command} ${_conan_args}") - - if(ARGUMENTS_OUTPUT_QUIET) - execute_process(COMMAND ${conan_command} ${conan_args} - RESULT_VARIABLE return_code - OUTPUT_VARIABLE conan_output - ERROR_VARIABLE conan_output - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - else() - execute_process(COMMAND ${conan_command} ${conan_args} - RESULT_VARIABLE return_code - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - endif() - - if(NOT "${return_code}" STREQUAL "0") - message(FATAL_ERROR "Conan install failed='${return_code}'") - endif() - -endfunction() - - -function(conan_cmake_setup_conanfile) - parse_arguments(${ARGV}) - if(ARGUMENTS_CONANFILE) - get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME) - # configure_file will make sure cmake re-runs when conanfile is updated - configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) - else() - conan_cmake_generate_conanfile(${ARGV}) - endif() -endfunction() - -function(conan_cmake_generate_conanfile) - # Generate, writing in disk a conanfile.txt with the requires, options, and imports - # specified as arguments - # This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR) - parse_arguments(${ARGV}) - set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt") - - file(WRITE ${_FN} "[generators]\ncmake\n\n[requires]\n") - foreach(ARG ${ARGUMENTS_REQUIRES}) - file(APPEND ${_FN} ${ARG} "\n") - endforeach() - - file(APPEND ${_FN} ${ARG} "\n[options]\n") - foreach(ARG ${ARGUMENTS_OPTIONS}) - file(APPEND ${_FN} ${ARG} "\n") - endforeach() - - file(APPEND ${_FN} ${ARG} "\n[imports]\n") - foreach(ARG ${ARGUMENTS_IMPORTS}) - file(APPEND ${_FN} ${ARG} "\n") - endforeach() -endfunction() - - -macro(conan_load_buildinfo) - if(CONAN_CMAKE_MULTI) - set(_CONANBUILDINFO conanbuildinfo_multi.cmake) - else() - set(_CONANBUILDINFO conanbuildinfo.cmake) - endif() - if(ARGUMENTS_INSTALL_FOLDER) - set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER}) - else() - set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR}) - endif() - # Checks for the existence of conanbuildinfo.cmake, and loads it - # important that it is macro, so variables defined at parent scope - if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}") - message(STATUS "Conan: Loading ${_CONANBUILDINFO}") - include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}) - else() - message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}") - endif() -endmacro() - - -macro(conan_cmake_run) - parse_arguments(${ARGV}) - - if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED - AND NOT ARGUMENTS_BUILD_TYPE) - set(CONAN_CMAKE_MULTI ON) - message(STATUS "Conan: Using cmake-multi generator") - else() - set(CONAN_CMAKE_MULTI OFF) - endif() - - if(NOT CONAN_EXPORTED) - conan_cmake_setup_conanfile(${ARGV}) - if(CONAN_CMAKE_MULTI) - foreach(CMAKE_BUILD_TYPE "Release" "Debug") - set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE}) - conan_cmake_settings(settings ${ARGV}) - conan_cmake_install(SETTINGS ${settings} ${ARGV}) - endforeach() - set(CMAKE_BUILD_TYPE) - else() - conan_cmake_settings(settings ${ARGV}) - conan_cmake_install(SETTINGS ${settings} ${ARGV}) - endif() - endif() - - if (NOT ARGUMENTS_NO_LOAD) - conan_load_buildinfo() - endif() - - if(ARGUMENTS_BASIC_SETUP) - foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS) - if(ARGUMENTS_${_option}) - if(${_option} STREQUAL "CMAKE_TARGETS") - list(APPEND _setup_options "TARGETS") - else() - list(APPEND _setup_options ${_option}) - endif() - endif() - endforeach() - conan_basic_setup(${_setup_options}) - endif() -endmacro() - -macro(conan_check) - # Checks conan availability in PATH - # Arguments REQUIRED and VERSION are optional - # Example usage: - # conan_check(VERSION 1.0.0 REQUIRED) - message(STATUS "Conan: checking conan executable in path") - set(options REQUIRED) - set(oneValueArgs VERSION) - cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN}) - - find_program(CONAN_CMD conan) - if(NOT CONAN_CMD AND CONAN_REQUIRED) - message(FATAL_ERROR "Conan executable not found!") - endif() - message(STATUS "Conan: Found program ${CONAN_CMD}") - execute_process(COMMAND ${CONAN_CMD} --version - OUTPUT_VARIABLE CONAN_VERSION_OUTPUT - ERROR_VARIABLE CONAN_VERSION_OUTPUT) - message(STATUS "Conan: Version found ${CONAN_VERSION_OUTPUT}") - - if(DEFINED CONAN_VERSION) - string(REGEX MATCH ".*Conan version ([0-9]+\.[0-9]+\.[0-9]+)" FOO - "${CONAN_VERSION_OUTPUT}") - if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION}) - message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \ - required: ${CONAN_VERSION}. Consider updating via 'pip \ - install conan==${CONAN_VERSION}'.") - endif() - endif() -endmacro() - -macro(conan_add_remote) - # Adds a remote - # Arguments URL and NAME are required, INDEX is optional - # Example usage: - # conan_add_remote(NAME bincrafters INDEX 1 - # URL https://api.bintray.com/conan/bincrafters/public-conan) - set(oneValueArgs URL NAME INDEX) - cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN}) - - if(DEFINED CONAN_INDEX) - set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}") - endif() - - message(STATUS "Conan: Adding ${CONAN_NAME} remote repositoy (${CONAN_URL})") - execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_URL} - ${CONAN_INDEX_ARG} -f) -endmacro() diff --git a/cmake/Modules/DiscoverTests.cmake b/cmake/Modules/DiscoverTests.cmake deleted file mode 100644 index 882fbf8..0000000 --- a/cmake/Modules/DiscoverTests.cmake +++ /dev/null @@ -1,55 +0,0 @@ -#[=[ -Discover all tests in our test suites. - -This implementation is adapted vom GoogleTest.cmake -#]=] - -function(discover_tests) - set(OPTIONS "") - set(SINGLE_VALUE_KEYWORDS "TARGET") - set(MULTI_VALUE_KEYWORDS "") - - cmake_parse_arguments(DISCOVER_TESTS - "${OPTIONS}" - "${SINGLE_VALUE_KEYWORDS}" - "${MULTI_VALUE_KEYWORDS}" - ${ARGN} - ) - - if(NOT DISCOVER_TESTS_TARGET) - message(FATAL_ERROR "Missing argument TARGET") - endif() - - if(NOT TARGET "${DISCOVER_TESTS_TARGET}") - message(FATAL_ERROR "${DISCOVER_TESTS_TARGET} does not name a target known to CMake") - endif() - - set(CTEST_FILE_BASE "${CMAKE_CURRENT_BINARY_DIR}/${DISCOVER_TESTS_TARGET}") - set(CTEST_INCLUDE_FILE "${CTEST_FILE_BASE}_include.cmake") - set(CTEST_TESTS_FILE "${CTEST_FILE_BASE}_tests.cmake") - - add_custom_command(TARGET "${DISCOVER_TESTS_TARGET}" - POST_BUILD - BYPRODUCTS "${CTEST_TESTS_FILE}" - COMMAND "${CMAKE_COMMAND}" - "-D" "TEST_TARGET=${DISCOVER_TESTS_TARGET}" - "-D" "TEST_EXECUTABLE=$" - "-D" "TEST_WORKING_DIR=${CMAKE_CURRENT_BINARY_DIR}" - "-D" "CTEST_FILE=${CTEST_TESTS_FILE}" - "-P" "${PROJECT_SOURCE_DIR}/cmake/Modules/DiscoverTestsImpl.cmake" - VERBATIM - ) - - file(WRITE "${CTEST_INCLUDE_FILE}" - "if(EXISTS \"${CTEST_TESTS_FILE}\")\n" - " include(\"${CTEST_TESTS_FILE}\")\n" - "else()\n" - " add_test(${TARGET}_NOT_BUILT ${TARGET}_NOT_BUILT)\n" - "endif()\n" - ) - - set_property(DIRECTORY - APPEND - PROPERTY TEST_INCLUDE_FILES "${CTEST_INCLUDE_FILE}" - ) -endfunction() \ No newline at end of file diff --git a/cmake/Modules/DiscoverTestsImpl.cmake b/cmake/Modules/DiscoverTestsImpl.cmake deleted file mode 100644 index 893d998..0000000 --- a/cmake/Modules/DiscoverTestsImpl.cmake +++ /dev/null @@ -1,39 +0,0 @@ -#[=[ -Discover all tests in our test suites. - -This implementation is adapted vom GoogleTestAddTests.cmake -#]=] - -set(SCRIPT) - -function(add_command CMD EXE TEST) -endfunction() - -if(NOT EXISTS "${TEST_EXECUTABLE}") - message(FATAL_ERROR "The test driver ${TEST_EXECUTABLE} does not exist.") -endif() - -execute_process(COMMAND ${TEST_EXECUTABLE} "--tests" - WORKING_DIRECTORY "${TEST_WORKING_DIR}" - TIMEOUT "5" - OUTPUT_VARIABLE "TEST_LIST_OUTPUT" - RESULT_VARIABLE "TEST_LIST_RESULT" -) - -if(NOT ${TEST_LIST_RESULT} EQUAL 0) - message(FATAL_ERROR "Error while discovering tests:\n" - "Executable: ${TEST_EXECUTABLE}\n" - "Result: ${TEST_LIST_RESULT}\n" - "Output:\n" - " ${TEST_LIST_OUTPUT}\n" - ) -endif() - -string(REPLACE "\n" ";" TEST_LIST_OUTPUT "${TEST_LIST_OUTPUT}") - -foreach(LINE ${TEST_LIST_OUTPUT}) - string(REPLACE "#" ": " TEST_NAME "${LINE}") - set(SCRIPT "${SCRIPT}add_test(\"${TEST_NAME}\" \"${TEST_EXECUTABLE}\" \"${LINE}\")\n") -endforeach() - -file(WRITE "${CTEST_FILE}" "${SCRIPT}") \ No newline at end of file diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in deleted file mode 100644 index f07fcfd..0000000 --- a/cmake/config.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/newtypeTargets.cmake") -check_required_components("@PROJECT_NAME@") \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 000831e..990b8ac 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,50 +1,72 @@ -import re - -from conans import ConanFile, CMake -from conans.tools import load - - -def read_project_property(property): - try: - cmake_lists = load("CMakeLists.txt") - value = re.search(r"project\(.*{} \"(.*?)\"".format(property), cmake_lists, re.S).group(1) - return value.strip() - except: - return None +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.build import check_min_cppstd class NewtypeConan(ConanFile): name = "newtype" + version = "2.0.0" + license = "BSD-3-Clause" + description = "A library of types and functions to create strong type aliases" + url = "https://github.com/fmorgner/newtype" + + settings = ("os", "arch", "compiler", "build_type") + scm = { "type": "git", - "url": "https://github.com/fmorgner/newtype.git", - "revision": "auto", + "url": "auto", + "revision": "auto" + } + + options = { + "enable_docs": [False, True], } - settings = None - version = read_project_property("VERSION") - license = "BSD-3-Clause" - url = "https://github.com/fmorgner/newtype" - description = read_project_property("DESCRIPTION") - generators = "cmake" - build_requires = ( - "CUTE/2.2.6@fmorgner/stable", - "lyra/1.2.0" - ) - - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["BUILD_TESTING"] = True - cmake.definitions["RUN_TESTS_AFTER_BUILD"] = True - cmake.configure() - return cmake + + default_options = { + "enable_docs": False, + } + + generators = [ + "CMakeDeps" + ] + + exports_sources = [ + "source/*", + "test_package/*", + "LICENSE", + ] def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() + cmake.test() + + def build_requirements(self): + self.tool_requires("cmake/[~3.25]") + self.tool_requires("ninja/[~1.11]") + self.test_requires("catch2/[~3.3]") + + def generate(self): + toolchain = CMakeToolchain(self) + toolchain.variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True + toolchain.variables["PROJECT_VERSION"] = self.version + toolchain.variables["PROJECT_DESCRIPTION"] = self.description + toolchain.generate() + + def layout(self): + cmake_layout(self, generator="Ninja Multi-Config", src_folder="source") def package(self): - cmake = self._configure_cmake() + cmake = CMake(self) cmake.install() def package_id(self): - self.info.header_only() \ No newline at end of file + self.info.clear() + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] + + def validate(self): + check_min_cppstd(self, 20) diff --git a/examples/src/basic_usage.cpp b/examples/src/basic_usage.cpp deleted file mode 100644 index 35d1d2c..0000000 --- a/examples/src/basic_usage.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include - -#include - -using Width = nt::new_type; -using Height = nt::new_type; -using Area = nt::new_type; - -struct Rectangle -{ - constexpr Rectangle(Width w, Height h) - : width{w} - , height{h} - { - } - - auto constexpr area() const noexcept -> Area - { - return {width.decay() * height.decay()}; - } - -private: - Width width; - Height height; -}; - -int main() -{ - auto w{0u}, h{0u}; - - std::cin >> w >> h; - - auto width = Width{w}; - auto height = Height{h}; - - auto rect = Rectangle{width, height}; - - std::cout << rect.area().decay() << '\n'; -} \ No newline at end of file diff --git a/examples/src/basic_usage_with_read.cpp b/examples/src/basic_usage_with_read.cpp deleted file mode 100644 index 2dabe2e..0000000 --- a/examples/src/basic_usage_with_read.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -#include - -using Width = nt::new_type; -using Height = nt::new_type; -using Area = nt::new_type; - -struct Rectangle -{ - constexpr Rectangle(Width w, Height h) - : width{w} - , height{h} - { - } - - auto constexpr area() const noexcept -> Area - { - return {width.decay() * height.decay()}; - } - -private: - Width width; - Height height; -}; - -int main() -{ - auto width = Width{}; - auto height = Height{}; - - std::cin >> width >> height; - - auto rect = Rectangle{width, height}; - - std::cout << rect.area() << '\n'; -} \ No newline at end of file diff --git a/examples/src/basic_usage_with_show.cpp b/examples/src/basic_usage_with_show.cpp deleted file mode 100644 index 4bb68f6..0000000 --- a/examples/src/basic_usage_with_show.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include - -#include - -using Width = nt::new_type; -using Height = nt::new_type; -using Area = nt::new_type; - -struct Rectangle -{ - constexpr Rectangle(Width w, Height h) - : width{w} - , height{h} - { - } - - auto constexpr area() const noexcept -> Area - { - return {width.decay() * height.decay()}; - } - -private: - Width width; - Height height; -}; - -int main() -{ - auto w{0u}, h{0u}; - - std::cin >> w >> h; - - auto width = Width{w}; - auto height = Height{h}; - - auto rect = Rectangle{width, height}; - - std::cout << rect.area() << '\n'; -} \ No newline at end of file diff --git a/include/newtype/derivable.hpp b/include/newtype/derivable.hpp deleted file mode 100644 index c798c59..0000000 --- a/include/newtype/derivable.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef NEWTYPE_DERIVABLE_HPP -#define NEWTYPE_DERIVABLE_HPP - -#include "newtype/version.hpp" - -namespace nt -{ - - template - struct derivable final - { - using tag_type = DerivableTag; - }; - - inline namespace derivables - { - - auto constexpr Arithmetic = derivable{}; - auto constexpr EqBase = derivable{}; - auto constexpr Hash = derivable{}; - auto constexpr ImplicitConversion = derivable{}; - auto constexpr Indirection = derivable{}; - auto constexpr Iterable = derivable{}; - auto constexpr Read = derivable{}; - auto constexpr Relational = derivable{}; - auto constexpr Show = derivable{}; - - } // namespace derivables - -} // namespace nt - -#endif \ No newline at end of file diff --git a/include/newtype/derivation_clause.hpp b/include/newtype/derivation_clause.hpp deleted file mode 100644 index 6de70e1..0000000 --- a/include/newtype/derivation_clause.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef NEWTYPE_DERIVATION_CLAUSE_HPP -#define NEWTYPE_DERIVATION_CLAUSE_HPP - -#include "newtype/derivable.hpp" -#include "newtype/version.hpp" - -#include - -namespace nt -{ - - template - struct derivation_clause - { - constexpr derivation_clause(derivable...) noexcept - { - } - - template - auto constexpr operator()(derivable) const noexcept -> bool - { - return (std::is_same_v || ...); - } - - template - auto constexpr operator()(derivable, derivable...) const noexcept -> bool - { - return (*this)(derivable{}) && (*this)(derivable{}...); - } - - template - auto constexpr operator<(derivation_clause other) const noexcept -> bool - { - return (sizeof...(DerivableTags) < sizeof...(OtherDerivableTags)) && other(derivable{}...); - } - - template - auto constexpr operator>(derivation_clause other) const noexcept -> bool - { - return other < *this; - } - - template - auto constexpr operator==(derivation_clause other) const noexcept -> bool - { - return sizeof...(DerivableTags) == sizeof...(OtherDerivableTags) && other(derivable{}...); - } - - template - auto constexpr operator!=(derivation_clause other) const noexcept -> bool - { - return !(*this == other); - } - - template - auto constexpr operator<=(derivation_clause other) const noexcept -> bool - { - return *this < other || *this == other; - } - - template - auto constexpr operator>=(derivation_clause other) const noexcept -> bool - { - return *this > other || *this == other; - } - }; - -} // namespace nt - -#endif \ No newline at end of file diff --git a/include/newtype/deriving.hpp b/include/newtype/deriving.hpp deleted file mode 100644 index ae10bab..0000000 --- a/include/newtype/deriving.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef NEWTYPE_DERIVING_HPP -#define NEWTYPE_DERIVING_HPP - -#include "newtype/derivable.hpp" -#include "newtype/derivation_clause.hpp" -#include "newtype/version.hpp" - -#include - -namespace nt -{ - - template - auto constexpr deriving(derivable... features) noexcept -> derivation_clause - { - return {features...}; - } - -} // namespace nt - -#endif \ No newline at end of file diff --git a/include/newtype/impl/new_type_iterator_types.hpp b/include/newtype/impl/new_type_iterator_types.hpp deleted file mode 100644 index 2ea8274..0000000 --- a/include/newtype/impl/new_type_iterator_types.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef NEWTYPE_IMPL_NEW_TYPE_ITERATOR_TYPES_HPP -#define NEWTYPE_IMPL_NEW_TYPE_ITERATOR_TYPES_HPP - -#include "newtype/version.hpp" - -#include - -namespace nt::impl -{ - - template> - struct new_type_iterator - { - }; - - template - struct new_type_iterator> - { - using iterator = typename T::iterator; - }; - - template> - struct new_type_const_iterator - { - }; - - template - struct new_type_const_iterator> - { - using const_iterator = typename T::const_iterator; - }; - - template> - struct new_type_reverse_iterator - { - }; - - template - struct new_type_reverse_iterator> - { - using reverse_iterator = typename T::reverse_iterator; - }; - - template> - struct new_type_const_reverse_iterator - { - }; - - template - struct new_type_const_reverse_iterator> - { - using const_reverse_iterator = typename T::const_reverse_iterator; - }; - - template - struct new_type_iterator_types - : new_type_iterator - , new_type_const_iterator - , new_type_reverse_iterator - , new_type_const_reverse_iterator - { - }; - -} // namespace nt::impl - -#endif \ No newline at end of file diff --git a/include/newtype/impl/new_type_storage.hpp b/include/newtype/impl/new_type_storage.hpp deleted file mode 100644 index f7842af..0000000 --- a/include/newtype/impl/new_type_storage.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef NEWTYPE_IMPL_NEW_TYPE_STORAGE_HPP -#define NEWTYPE_IMPL_NEW_TYPE_STORAGE_HPP - -#include "newtype/version.hpp" - -#include -#include - -namespace nt::impl -{ - - template - struct new_type_storage - { - constexpr new_type_storage() noexcept(std::is_nothrow_default_constructible_v) - : m_value{} - { - } - - constexpr new_type_storage(BaseType const & value) - : m_value{value} - { - } - - constexpr new_type_storage(BaseType && value) - : m_value{std::move(value)} - { - } - - BaseType m_value; - }; - - template> - struct new_type_constructor : new_type_storage - { - using new_type_storage::new_type_storage; - }; - - template - struct new_type_constructor : new_type_storage - { - using new_type_storage::new_type_storage; - - constexpr new_type_constructor() = delete; - }; - - template> - struct new_type_copy_constructor : new_type_constructor - { - using new_type_constructor::new_type_constructor; - - constexpr new_type_copy_constructor(new_type_copy_constructor const &) = default; - constexpr new_type_copy_constructor(new_type_copy_constructor &&) = default; - auto constexpr operator=(new_type_copy_constructor &) -> new_type_copy_constructor & = default; - auto constexpr operator=(new_type_copy_constructor &&) -> new_type_copy_constructor & = default; - }; - - template - struct new_type_copy_constructor : new_type_constructor - { - using new_type_constructor::new_type_constructor; - - constexpr new_type_copy_constructor(new_type_copy_constructor const &) = delete; - constexpr new_type_copy_constructor(new_type_copy_constructor &&) = default; - constexpr new_type_copy_constructor(BaseType const &) = delete; - auto constexpr operator=(new_type_copy_constructor &) -> new_type_copy_constructor & = default; - auto constexpr operator=(new_type_copy_constructor &&) -> new_type_copy_constructor & = default; - }; - - template> - struct new_type_move_constructor : new_type_copy_constructor - { - using new_type_copy_constructor::new_type_copy_constructor; - - constexpr new_type_move_constructor(new_type_move_constructor const &) = default; - constexpr new_type_move_constructor(new_type_move_constructor &&) = default; - auto constexpr operator=(new_type_move_constructor &) -> new_type_move_constructor & = default; - auto constexpr operator=(new_type_move_constructor &&) -> new_type_move_constructor & = default; - }; - - template - struct new_type_move_constructor : new_type_copy_constructor - { - using new_type_copy_constructor::new_type_copy_constructor; - - constexpr new_type_move_constructor(new_type_move_constructor const &) = default; - constexpr new_type_move_constructor(new_type_move_constructor &&) = delete; - constexpr new_type_move_constructor(BaseType &&) = delete; - auto constexpr operator=(new_type_move_constructor &) -> new_type_move_constructor & = default; - auto constexpr operator=(new_type_move_constructor &&) -> new_type_move_constructor & = default; - }; - - template> - struct new_type_copy_assignment : new_type_move_constructor - { - using new_type_move_constructor::new_type_move_constructor; - - constexpr new_type_copy_assignment(new_type_copy_assignment const &) = default; - constexpr new_type_copy_assignment(new_type_copy_assignment &&) = default; - auto constexpr operator=(new_type_copy_assignment &) -> new_type_copy_assignment & = default; - auto constexpr operator=(new_type_copy_assignment &&) -> new_type_copy_assignment & = default; - }; - - template - struct new_type_copy_assignment : new_type_move_constructor - { - using new_type_move_constructor::new_type_move_constructor; - - constexpr new_type_copy_assignment(new_type_copy_assignment const &) = default; - constexpr new_type_copy_assignment(new_type_copy_assignment &&) = default; - auto constexpr operator=(new_type_copy_assignment &) -> new_type_copy_assignment & = default; - auto constexpr operator=(new_type_copy_assignment &&) -> new_type_copy_assignment & = delete; - }; - - template> - struct new_type_move_assignment : new_type_copy_assignment - { - using new_type_copy_assignment::new_type_copy_assignment; - - constexpr new_type_move_assignment(new_type_move_assignment const &) = default; - constexpr new_type_move_assignment(new_type_move_assignment &&) = default; - auto constexpr operator=(new_type_move_assignment &) -> new_type_move_assignment & = default; - auto constexpr operator=(new_type_move_assignment &&) -> new_type_move_assignment & = default; - }; - - template - struct new_type_move_assignment : new_type_copy_assignment - { - using new_type_copy_assignment::new_type_copy_assignment; - - constexpr new_type_move_assignment(new_type_move_assignment const &) = default; - constexpr new_type_move_assignment(new_type_move_assignment &&) = default; - auto constexpr operator=(new_type_move_assignment &) -> new_type_move_assignment & = default; - auto constexpr operator=(new_type_move_assignment &&) -> new_type_move_assignment & = delete; - }; - -} // namespace nt::impl - -#endif diff --git a/include/newtype/impl/type_traits_extensions.hpp b/include/newtype/impl/type_traits_extensions.hpp deleted file mode 100644 index dc41649..0000000 --- a/include/newtype/impl/type_traits_extensions.hpp +++ /dev/null @@ -1,853 +0,0 @@ -#ifndef NEWTYPE_IMPL_TYPE_TRAITS_EXTENSIONS_HPP -#define NEWTYPE_IMPL_TYPE_TRAITS_EXTENSIONS_HPP - -#include "newtype/version.hpp" - -#include -#include -#include -#include - -namespace nt::impl -{ - - inline namespace equality_comparable - { - - template - struct is_equality_comparable : std::false_type - { - }; - - template - struct is_equality_comparable() == std::declval())>> : std::true_type - { - }; - - template - auto constexpr is_equality_comparable_v = is_equality_comparable::value; - - template - struct is_nothrow_equality_comparable : std::false_type - { - }; - - template - struct is_nothrow_equality_comparable