update ci, cmake, conan
This commit is contained in:
parent
50ded04922
commit
e62d87432f
15 changed files with 15217 additions and 252 deletions
|
@ -1,37 +1,31 @@
|
||||||
version: "{branch} #{build}"
|
version: "{branch} #{build}"
|
||||||
|
|
||||||
build: false
|
image:
|
||||||
|
- Visual Studio 2017
|
||||||
|
|
||||||
|
platform:
|
||||||
|
- Win32
|
||||||
|
- x64
|
||||||
|
|
||||||
|
configuration:
|
||||||
|
- Debug
|
||||||
|
- Release
|
||||||
|
|
||||||
|
build:
|
||||||
|
parallel: true
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
PYTHON: "C:\\Python37"
|
matrix:
|
||||||
|
- GENERATOR: "Visual Studio 15 2017"
|
||||||
|
|
||||||
CONAN_UPLOAD: "https://api.bintray.com/conan/steakhal/maintained"
|
before_build:
|
||||||
CONAN_BUILD_POLICY: "missing"
|
- if exist build RMDIR /S /Q build
|
||||||
CONAN_USERNAME: "steakhal"
|
- if not exist build mkdir build
|
||||||
CONAN_CHANNEL: "stable"
|
- cd build
|
||||||
CONAN_UPLOAD_ONLY_WHEN_TAG: 1
|
- cmake -G "%GENERATOR%" -A %PLATFORM% ..
|
||||||
|
|
||||||
matrix:
|
build_script:
|
||||||
- MINGW_CONFIGURATIONS: '7@x86_64@seh@posix, 7@x86@dwarf2@posix, 8@x86_64@seh@posix, 8@x86@dwarf2@posix'
|
- cmake --build . --config %CONFIGURATION%
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
CONAN_VISUAL_VERSIONS: 15
|
|
||||||
CONAN_BUILD_TYPES: Release
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
CONAN_VISUAL_VERSIONS: 15
|
|
||||||
CONAN_BUILD_TYPES: Debug
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
|
||||||
CONAN_VISUAL_VERSIONS: 16
|
|
||||||
CONAN_BUILD_TYPES: Release
|
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
|
||||||
CONAN_VISUAL_VERSIONS: 16
|
|
||||||
CONAN_BUILD_TYPES: Debug
|
|
||||||
|
|
||||||
|
|
||||||
install:
|
|
||||||
- set PATH=%PATH%;%PYTHON%/Scripts/
|
|
||||||
- pip.exe install conan --upgrade
|
|
||||||
- pip.exe install conan_package_tools bincrafters_package_tools
|
|
||||||
- conan user
|
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- python .ci/build.py
|
- ctest --output-on-failure -C %CONFIGURATION%
|
||||||
|
|
13
.ci/build.py
13
.ci/build.py
|
@ -1,13 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from cpt.packager import ConanMultiPackager
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
options = { 'nameof:build_tests': True, 'nameof:build_examples': True }
|
|
||||||
always_true = lambda build: True
|
|
||||||
|
|
||||||
builder = ConanMultiPackager()
|
|
||||||
builder.add_common_builds()
|
|
||||||
builder.update_build_if(always_true, new_options = options)
|
|
||||||
builder.run()
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
|
||||||
brew update || brew update
|
|
||||||
brew outdated pyenv || brew upgrade pyenv
|
|
||||||
brew install pyenv-virtualenv
|
|
||||||
brew install cmake || brew upgrade cmake || true
|
|
||||||
|
|
||||||
if which pyenv > /dev/null; then
|
|
||||||
eval "$(pyenv init -)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pyenv install 3.7.1
|
|
||||||
pyenv virtualenv 3.7.1 conan
|
|
||||||
pyenv rehash
|
|
||||||
pyenv activate conan
|
|
||||||
fi
|
|
||||||
|
|
||||||
pip install conan --upgrade
|
|
||||||
pip install conan_package_tools bincrafters_package_tools
|
|
||||||
|
|
||||||
conan user
|
|
12
.ci/run.sh
12
.ci/run.sh
|
@ -1,12 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
|
||||||
if which pyenv > /dev/null; then
|
|
||||||
eval "$(pyenv init -)"
|
|
||||||
fi
|
|
||||||
pyenv activate conan
|
|
||||||
fi
|
|
||||||
|
|
||||||
python .ci/build.py
|
|
142
.travis.yml
142
.travis.yml
|
@ -1,74 +1,100 @@
|
||||||
env:
|
os: linux # Use linux unless specified otherwise.
|
||||||
global:
|
dist: xenial
|
||||||
- CONAN_UPLOAD: "https://api.bintray.com/conan/steakhal/maintained"
|
sudo: required
|
||||||
- CONAN_BUILD_POLICY: "missing"
|
|
||||||
- CONAN_USERNAME: "steakhal"
|
|
||||||
- CONAN_CHANNEL: "stable"
|
|
||||||
- CONAN_UPLOAD_ONLY_WHEN_TAG: 1
|
|
||||||
|
|
||||||
linux: &linux
|
language: cpp
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
sudo: required
|
|
||||||
language: python
|
|
||||||
python: "3.6"
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
osx: &osx
|
|
||||||
os: osx
|
|
||||||
language: generic
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- <<: *osx
|
- os: linux
|
||||||
osx_image: xcode9.2
|
compiler: g++
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=9.0
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-9
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=g++-9 CC_COMPILER=gcc-9
|
||||||
|
|
||||||
- <<: *osx
|
- os: linux
|
||||||
osx_image: xcode9.4
|
compiler: clang++
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=9.1
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-5.0
|
||||||
|
packages:
|
||||||
|
- clang-5.0
|
||||||
|
- g++-7
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=clang++-5.0 CC_COMPILER=clang-5.0
|
||||||
|
|
||||||
- <<: *osx
|
- os: linux
|
||||||
osx_image: xcode10.1
|
compiler: clang++
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-6.0
|
||||||
|
packages:
|
||||||
|
- clang-6.0
|
||||||
|
- g++-7
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=clang++-6.0 CC_COMPILER=clang-6.0
|
||||||
|
|
||||||
- <<: *osx
|
- os: linux
|
||||||
osx_image: xcode10.2
|
compiler: clang++
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=10.0
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-7
|
||||||
|
packages:
|
||||||
|
- clang-7
|
||||||
|
- g++-7
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=clang++-7 CC_COMPILER=clang-7
|
||||||
|
|
||||||
- <<: *osx
|
- os: linux
|
||||||
osx_image: xcode11
|
compiler: clang++
|
||||||
env: CONAN_APPLE_CLANG_VERSIONS=11.0
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-xenial-8
|
||||||
|
packages:
|
||||||
|
- clang-8
|
||||||
|
- g++-7
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=clang++-8 CC_COMPILER=clang-8
|
||||||
|
|
||||||
- <<: *linux
|
- os: osx
|
||||||
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=conanio/gcc7
|
compiler: clang++
|
||||||
|
osx_image: xcode10.3
|
||||||
|
env:
|
||||||
|
- CXX_COMPILER=clang++ CC_COMPILER=clang
|
||||||
|
|
||||||
- <<: *linux
|
- os: osx
|
||||||
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/gcc8
|
compiler: clang++
|
||||||
|
osx_image: xcode11
|
||||||
- <<: *linux
|
env:
|
||||||
env: CONAN_GCC_VERSIONS=9 CONAN_DOCKER_IMAGE=conanio/gcc9
|
- CXX_COMPILER=clang++ CC_COMPILER=clang
|
||||||
|
|
||||||
- <<: *linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=conanio/clang50
|
|
||||||
|
|
||||||
- <<: *linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=conanio/clang60
|
|
||||||
|
|
||||||
- <<: *linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=7.0 CONAN_DOCKER_IMAGE=conanio/clang7
|
|
||||||
|
|
||||||
- <<: *linux
|
|
||||||
env: CONAN_CLANG_VERSIONS=8 CONAN_DOCKER_IMAGE=conanio/clang8
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- chmod +x .ci/install.sh
|
- export CC=${CC_COMPILER}
|
||||||
- ./.ci/install.sh
|
- export CXX=${CXX_COMPILER}
|
||||||
|
- JOBS=2 # Travis machines have 2 cores.
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- rm -rf build
|
||||||
|
- mkdir -p build
|
||||||
|
- cd build
|
||||||
|
- cmake -G "Unix Makefiles" ..
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- chmod +x .ci/run.sh
|
- cmake --build . -- -j${JOBS}
|
||||||
- ./.ci/run.sh
|
- ctest --output-on-failure -j${JOBS}
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
|
@ -4,16 +4,22 @@ project(nameof VERSION "0.9.0" LANGUAGES CXX)
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
|
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
|
||||||
|
|
||||||
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" OFF)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" OFF)
|
set(IS_TOPLEVEL_PROJECT TRUE)
|
||||||
|
else()
|
||||||
|
set(IS_TOPLEVEL_PROJECT FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ${IS_TOPLEVEL_PROJECT})
|
||||||
|
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ${IS_TOPLEVEL_PROJECT})
|
||||||
|
|
||||||
if(NAMEOF_OPT_BUILD_EXAMPLES)
|
if(NAMEOF_OPT_BUILD_EXAMPLES)
|
||||||
add_subdirectory(example)
|
add_subdirectory(example)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NAMEOF_OPT_BUILD_TESTS)
|
if(NAMEOF_OPT_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
@ -22,23 +28,23 @@ add_library(${PROJECT_NAME} INTERFACE)
|
||||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||||
target_include_directories(${PROJECT_NAME}
|
target_include_directories(${PROJECT_NAME}
|
||||||
INTERFACE
|
INTERFACE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>)
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
|
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
COMPATIBILITY AnyNewerVersion)
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME}
|
install(TARGETS ${PROJECT_NAME}
|
||||||
EXPORT ${PROJECT_NAME}Config)
|
EXPORT ${PROJECT_NAME}Config)
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME})
|
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
install(EXPORT ${PROJECT_NAME}Config
|
install(EXPORT ${PROJECT_NAME}Config
|
||||||
NAMESPACE ${PROJECT_NAME}::
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME})
|
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
DESTINATION .)
|
DESTINATION .)
|
||||||
|
|
65
conanfile.py
65
conanfile.py
|
@ -1,9 +1,6 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from conans import ConanFile, tools, CMake
|
from conans import ConanFile
|
||||||
from conans.model.version import Version
|
|
||||||
from conans.errors import ConanInvalidConfiguration
|
|
||||||
|
|
||||||
class NameofConan(ConanFile):
|
class NameofConan(ConanFile):
|
||||||
name = 'nameof'
|
name = 'nameof'
|
||||||
|
@ -17,67 +14,19 @@ class NameofConan(ConanFile):
|
||||||
'serialization',
|
'serialization',
|
||||||
'reflection',
|
'reflection',
|
||||||
'header-only',
|
'header-only',
|
||||||
'introspection',
|
|
||||||
'compile-time'
|
'compile-time'
|
||||||
)
|
)
|
||||||
url = 'https://github.com/Neargye/nameof'
|
url = 'https://github.com/Neargye/nameof'
|
||||||
|
homepage = 'https://github.com/Neargye/nameof'
|
||||||
author = 'Daniil Goncharov <neargye@gmail.com>'
|
author = 'Daniil Goncharov <neargye@gmail.com>'
|
||||||
license = 'MIT'
|
license = 'MIT'
|
||||||
generators = 'cmake_find_package'
|
exports_sources = ["include/*", "LICENCE"]
|
||||||
exports_sources = ['example/*', 'include/*', 'test/*', 'CMakeLists.txt', 'LICENSE']
|
exports = ["LICENSE"]
|
||||||
exports = ['LICENSE.md']
|
no_copy_source = True
|
||||||
_build_subfolder = 'build_subfolder'
|
|
||||||
build_requires = []
|
|
||||||
settings = ('os', 'compiler', 'build_type', 'arch')
|
|
||||||
options = {
|
|
||||||
'build_tests': [True, False],
|
|
||||||
'build_examples': [True, False],
|
|
||||||
}
|
|
||||||
default_options = {
|
|
||||||
'build_tests': False,
|
|
||||||
'build_examples': False,
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
|
||||||
def supports_compiler(self):
|
|
||||||
compiler = str(self.settings.compiler)
|
|
||||||
version = Version(str(self.settings.compiler.version))
|
|
||||||
if compiler == 'Visual Studio' and version >= Version('15'):
|
|
||||||
return True
|
|
||||||
if compiler == 'gcc' and version >= Version('7'):
|
|
||||||
return True
|
|
||||||
if compiler == 'icc' and version >= Version('19'):
|
|
||||||
return True
|
|
||||||
if compiler == 'clang' and version >= Version('5'):
|
|
||||||
return True
|
|
||||||
if compiler == 'apple-clang' and version >= Version('9'):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def requirements(self):
|
|
||||||
if self.options.build_tests:
|
|
||||||
self.build_requires.append('Catch2/2.9.1@catchorg/stable')
|
|
||||||
|
|
||||||
def configure(self):
|
|
||||||
if not self.supports_compiler:
|
|
||||||
raise ConanInvalidConfiguration('The specified compiler must support C++17')
|
|
||||||
|
|
||||||
def configure_cmake(self):
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.definitions['NAMEOF_OPT_BUILD_TESTS'] = self.options.build_tests
|
|
||||||
cmake.definitions['NAMEOF_OPT_BUILD_EXAMPLES'] = self.options.build_examples
|
|
||||||
cmake.configure(build_folder=self._build_subfolder)
|
|
||||||
return cmake
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
cmake = self.configure_cmake()
|
|
||||||
cmake.build()
|
|
||||||
if self.options.build_tests and not tools.cross_building(self.settings):
|
|
||||||
cmake.test()
|
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
cmake = self.configure_cmake()
|
self.copy("include/*")
|
||||||
cmake.install()
|
self.copy("LICENSE", dst="licenses")
|
||||||
|
|
||||||
def package_id(self):
|
def package_id(self):
|
||||||
self.info.header_only()
|
self.info.header_only()
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
add_executable(example example.cpp)
|
include(CheckCXXCompilerFlag)
|
||||||
target_link_libraries(example PRIVATE nameof::nameof)
|
|
||||||
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
|
||||||
|
|
||||||
target_compile_options(example
|
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||||
PRIVATE
|
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror)
|
||||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
-Wall -Wextra -pedantic-errors -Werror>
|
set(OPTIONS /W4 /WX)
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:
|
if(HAS_PERMISSIVE_FLAG)
|
||||||
/W4 /WX>
|
set(OPTIONS ${OPTIONS} /permissive-)
|
||||||
)
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(example example.cpp)
|
||||||
|
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
|
target_compile_features(example PRIVATE cxx_std_17)
|
||||||
|
target_compile_options(example PRIVATE ${OPTIONS})
|
||||||
|
target_link_libraries(example PRIVATE ${CMAKE_PROJECT_NAME})
|
||||||
|
|
23
test/3rdparty/Catch2/LICENSE
vendored
Normal file
23
test/3rdparty/Catch2/LICENSE
vendored
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
15003
test/3rdparty/Catch2/catch.hpp
vendored
Normal file
15003
test/3rdparty/Catch2/catch.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,27 +1,45 @@
|
||||||
find_package(Catch2 REQUIRED)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
set(SOURCES test.cpp)
|
||||||
check_cxx_compiler_flag(-std=c++20 HAS_GNU_CPP20_FLAG)
|
|
||||||
check_cxx_compiler_flag(/std:c++20 HAS_MSVC_CPP20_FLAG)
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
set(HAS_CPP20 (HAS_GNU_CPP20_FLAG OR HAS_MSVC_CPP20_FLAG))
|
set(OPTIONS /W4 /WX)
|
||||||
|
check_cxx_compiler_flag(/permissive HAS_PERMISSIVE_FLAG)
|
||||||
|
if(HAS_PERMISSIVE_FLAG)
|
||||||
|
set(OPTIONS ${OPTIONS} /permissive-)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(/std:c++20 HAS_CPP20_FLAG)
|
||||||
|
check_cxx_compiler_flag(/std:c++latest HAS_CPPLATEST_FLAG)
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror)
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(-std=c++20 HAS_CPP20_FLAG)
|
||||||
|
endif()
|
||||||
|
|
||||||
function(make_test target std)
|
function(make_test target std)
|
||||||
add_executable(${target} test.cpp)
|
add_executable(${target} ${SOURCES})
|
||||||
target_link_libraries(${target} PRIVATE Catch2::Catch2 nameof::nameof)
|
target_compile_options(${target} PRIVATE ${OPTIONS})
|
||||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
target_include_directories(${target} PRIVATE 3rdparty/Catch2)
|
||||||
target_compile_features(${target} PRIVATE ${std})
|
target_link_libraries(${target} PRIVATE ${CMAKE_PROJECT_NAME})
|
||||||
|
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
target_compile_options(${target}
|
if(std)
|
||||||
PRIVATE
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
target_compile_options(${target} PRIVATE /std:${std})
|
||||||
-Wall -Wextra -pedantic-errors -Werror>
|
else()
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:
|
target_compile_options(${target} PRIVATE -std=${std})
|
||||||
/W4 /WX>
|
endif()
|
||||||
)
|
endif()
|
||||||
|
add_test(NAME ${target} COMMAND ${target})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
make_test(nameof-cpp17.t cxx_std_17)
|
make_test(${CMAKE_PROJECT_NAME}-cpp17.t c++17)
|
||||||
|
|
||||||
if(HAS_CPP20 AND (cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES))
|
if(HAS_CPP20_FLAG)
|
||||||
make_test(nameof-cpp20.t cxx_std_20)
|
make_test(${CMAKE_PROJECT_NAME}-cpp20.t c++20)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAS_CPPLATEST_FLAG)
|
||||||
|
make_test(${CMAKE_PROJECT_NAME}-cpplatest.t c++latest)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
// SOFTWARE.
|
// SOFTWARE.
|
||||||
|
|
||||||
#define CATCH_CONFIG_MAIN
|
#define CATCH_CONFIG_MAIN
|
||||||
#include <catch2/catch.hpp>
|
#include <catch.hpp>
|
||||||
|
|
||||||
#define NAMEOF_ENUM_RANGE_MIN -120
|
#define NAMEOF_ENUM_RANGE_MIN -120
|
||||||
#define NAMEOF_ENUM_RANGE_MAX 120
|
#define NAMEOF_ENUM_RANGE_MAX 120
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
cmake_minimum_required(VERSION 3.8)
|
cmake_minimum_required(VERSION 3.8)
|
||||||
project(test_package CXX)
|
project(test_package CXX)
|
||||||
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
conan_basic_setup(TARGETS)
|
conan_basic_setup(TARGETS)
|
||||||
|
|
||||||
add_executable(test_package test_package.cpp)
|
add_executable(test_package test_package.cpp)
|
||||||
target_link_libraries(test_package PRIVATE CONAN_PKG::nameof)
|
target_link_libraries(test_package PRIVATE CONAN_PKG::nameof)
|
||||||
|
set_target_properties(test_package PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
target_compile_features(test_package PRIVATE cxx_std_17)
|
target_compile_features(test_package PRIVATE cxx_std_17)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from conans import ConanFile, CMake, tools
|
from conans import ConanFile, CMake, tools
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
class TestPackageConan(ConanFile):
|
class TestPackageConan(ConanFile):
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
generators = "cmake"
|
generators = "cmake"
|
||||||
|
|
|
@ -1,27 +1,19 @@
|
||||||
#include <nameof.hpp>
|
#include <nameof.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
struct SomeStruct {};
|
struct SomeStruct {};
|
||||||
|
|
||||||
SomeStruct structvar;
|
SomeStruct structvar;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Compile-time.
|
|
||||||
constexpr auto name = NAMEOF(structvar);
|
constexpr auto name = NAMEOF(structvar);
|
||||||
static_assert("structvar" == name);
|
static_assert("structvar" == name);
|
||||||
|
|
||||||
// Nameof.
|
|
||||||
std::string_view res1 = NAMEOF(structvar);
|
std::string_view res1 = NAMEOF(structvar);
|
||||||
std::string_view res2 = NAMEOF(::structvar);
|
std::string_view res2 = NAMEOF(::structvar);
|
||||||
|
|
||||||
std::cout << res1 << '\n' << res2 << '\n';
|
bool success = (res1 == "structvar") && (res2 == "structvar");
|
||||||
|
|
||||||
using std::literals::string_view_literals::operator""sv;
|
|
||||||
|
|
||||||
bool success = (res1 == "structvar"sv) && (res2 == "structvar"sv);
|
|
||||||
|
|
||||||
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue