aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2023-06-07 16:41:32 +0200
committerFelix Morgner <felix.morgner@gmail.com>2023-06-07 16:41:32 +0200
commitaa7c021962f529f3ed2f482fd6f02e5497532a8a (patch)
treec8a3eff796c94f757cc8ae7d3b2324f53038e0c3
parent741b6d177865f20908b1b290c5170025964d3d9a (diff)
downloadnewtype-aa7c021962f529f3ed2f482fd6f02e5497532a8a.tar.xz
newtype-aa7c021962f529f3ed2f482fd6f02e5497532a8a.zip
project: begin restructuring
-rw-r--r--.gitignore5
-rw-r--r--.travis.yml42
-rw-r--r--.vscode/settings.json6
-rw-r--r--CMakeLists.txt281
-rw-r--r--cmake/Modules/Conan.cmake554
-rw-r--r--cmake/Modules/DiscoverTests.cmake55
-rw-r--r--cmake/Modules/DiscoverTestsImpl.cmake39
-rw-r--r--cmake/config.cmake.in4
-rw-r--r--conanfile.py92
-rw-r--r--source/CMakeLists.txt88
-rw-r--r--source/examples/src/basic_usage.cpp (renamed from examples/src/basic_usage.cpp)0
-rw-r--r--source/examples/src/basic_usage_with_read.cpp (renamed from examples/src/basic_usage_with_read.cpp)0
-rw-r--r--source/examples/src/basic_usage_with_show.cpp (renamed from examples/src/basic_usage_with_show.cpp)0
-rw-r--r--source/include/newtype/derivable.hpp (renamed from include/newtype/derivable.hpp)0
-rw-r--r--source/include/newtype/derivation_clause.hpp (renamed from include/newtype/derivation_clause.hpp)0
-rw-r--r--source/include/newtype/deriving.hpp (renamed from include/newtype/deriving.hpp)0
-rw-r--r--source/include/newtype/impl/new_type_iterator_types.hpp (renamed from include/newtype/impl/new_type_iterator_types.hpp)0
-rw-r--r--source/include/newtype/impl/new_type_storage.hpp (renamed from include/newtype/impl/new_type_storage.hpp)0
-rw-r--r--source/include/newtype/impl/type_traits_extensions.hpp (renamed from include/newtype/impl/type_traits_extensions.hpp)0
-rw-r--r--source/include/newtype/newtype.hpp (renamed from include/newtype/newtype.hpp)0
-rw-r--r--source/include/newtype/version.hpp (renamed from include/newtype/version.hpp)0
-rw-r--r--source/test/src/arithmetic.cpp300
-rw-r--r--source/test/src/conversion_suite.cpp (renamed from test/src/conversion_suite.cpp)0
-rw-r--r--source/test/src/derivation_clause_suite.cpp (renamed from test/src/derivation_clause_suite.cpp)0
-rw-r--r--source/test/src/equality_comparison_suite.cpp (renamed from test/src/equality_comparison_suite.cpp)0
-rw-r--r--source/test/src/hash_suite.cpp (renamed from test/src/hash_suite.cpp)0
-rw-r--r--source/test/src/io_operators_suite.cpp (renamed from test/src/io_operators_suite.cpp)0
-rw-r--r--source/test/src/iterable_suite.cpp (renamed from test/src/iterable_suite.cpp)0
-rw-r--r--source/test/src/new_type_constructor_suite.cpp (renamed from test/src/new_type_constructor_suite.cpp)0
-rw-r--r--source/test/src/relational_operators_suite.cpp (renamed from test/src/relational_operators_suite.cpp)0
-rw-r--r--test/include/arithmetic_suite.hpp11
-rw-r--r--test/include/conversion_suite.hpp11
-rw-r--r--test/include/derivation_clause_suite.hpp11
-rw-r--r--test/include/equality_comparison_suite.hpp11
-rw-r--r--test/include/hash_suite.hpp11
-rw-r--r--test/include/io_operators_suite.hpp11
-rw-r--r--test/include/iterable_suite.hpp11
-rw-r--r--test/include/kawaii.hpp143
-rw-r--r--test/include/new_type_constructor_suite.hpp11
-rw-r--r--test/include/relational_operators_suite.hpp11
-rw-r--r--test/src/arithmetic_suite.cpp330
-rw-r--r--test/src/driver.cpp101
-rw-r--r--test_package/CMakeLists.txt13
-rw-r--r--test_package/conanfile.py16
-rw-r--r--test_package/main.cpp2
45 files changed, 473 insertions, 1697 deletions
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
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:include>
-)
-
-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"
- $<$<BOOL:${ENABLE_CODE_COVERAGE}>:--coverage>
- )
-
- target_link_options("${PROJECT_NAME}_tests" PRIVATE
- $<$<BOOL:${ENABLE_CODE_COVERAGE}>:--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 <string>"
- 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 missi