mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
fix installing via cmake (#374)
This commit is contained in:
parent
9675f2bc29
commit
a72a0536c7
25 changed files with 478 additions and 186 deletions
58
.cmake-format
Normal file
58
.cmake-format
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
format:
|
||||
tab_size: 2
|
||||
line_width: 100
|
||||
dangle_parens: true
|
||||
|
||||
parse:
|
||||
additional_commands:
|
||||
cpmaddpackage:
|
||||
pargs:
|
||||
nargs: '*'
|
||||
flags: []
|
||||
spelling: CPMAddPackage
|
||||
kwargs: &cpmaddpackagekwargs
|
||||
NAME: 1
|
||||
FORCE: 1
|
||||
VERSION: 1
|
||||
GIT_TAG: 1
|
||||
DOWNLOAD_ONLY: 1
|
||||
GITHUB_REPOSITORY: 1
|
||||
GITLAB_REPOSITORY: 1
|
||||
GIT_REPOSITORY: 1
|
||||
SVN_REPOSITORY: 1
|
||||
SVN_REVISION: 1
|
||||
SOURCE_DIR: 1
|
||||
DOWNLOAD_COMMAND: 1
|
||||
FIND_PACKAGE_ARGUMENTS: 1
|
||||
NO_CACHE: 1
|
||||
GIT_SHALLOW: 1
|
||||
URL: 1
|
||||
URL_HASH: 1
|
||||
URL_MD5: 1
|
||||
DOWNLOAD_NAME: 1
|
||||
DOWNLOAD_NO_EXTRACT: 1
|
||||
HTTP_USERNAME: 1
|
||||
HTTP_PASSWORD: 1
|
||||
OPTIONS: +
|
||||
cpmfindpackage:
|
||||
pargs:
|
||||
nargs: '*'
|
||||
flags: []
|
||||
spelling: CPMFindPackage
|
||||
kwargs: *cpmaddpackagekwargs
|
||||
packageproject:
|
||||
pargs:
|
||||
nargs: '*'
|
||||
flags: []
|
||||
spelling: packageProject
|
||||
kwargs:
|
||||
NAME: 1
|
||||
VERSION: 1
|
||||
NAMESPACE: 1
|
||||
INCLUDE_DIR: 1
|
||||
INCLUDE_DESTINATION: 1
|
||||
BINARY_DIR: 1
|
||||
COMPATIBILITY: 1
|
||||
VERSION_HEADER: 1
|
||||
DEPENDENCIES: +
|
||||
|
||||
9
.dockerignore
Normal file
9
.dockerignore
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
build*/
|
||||
.cache/
|
||||
.git/
|
||||
.github/
|
||||
compile_commands.json
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
install_dir/
|
||||
|
||||
60
.github/workflows/ubuntu_test_installed_version.yml
vendored
Normal file
60
.github/workflows/ubuntu_test_installed_version.yml
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
name: ubuntu_test_installed_version.yml
|
||||
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: "**/cpm_modules"
|
||||
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
||||
|
||||
- name: install library
|
||||
run: |
|
||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release --log-level=DEBUG -DCMAKE_INSTALL_PREFIX=./install_dir
|
||||
cmake --build ./build -j$(nproc)
|
||||
cmake --install ./build --prefix ./install_dir
|
||||
rm -rf build
|
||||
|
||||
- name: configure with installed version via cmake
|
||||
run: CMAKE_PREFIX_PATH="./install_dir" cmake -S. -Bbuild2 -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION=1 --log-level=DEBUG
|
||||
|
||||
- name: build with installed version via cmake
|
||||
run: cmake --build build2 --config Debug -j$(nproc) --verbose
|
||||
|
||||
- name: test
|
||||
run: |
|
||||
cd build2
|
||||
ctest --build-config Debug -j$(nproc)
|
||||
|
||||
- name: clear
|
||||
run: rm -rf build2
|
||||
|
||||
- name: configure with installed version via pkgconfig
|
||||
run: CMAKE_PREFIX_PATH="./install_dir" cmake -S. -Bbuild3 -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG=1 -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=1 --log-level=DEBUG
|
||||
|
||||
- name: build with installed version via pkgconfig
|
||||
run: cmake --build build3 --config Debug -j$(nproc) --verbose
|
||||
|
||||
- name: test
|
||||
run: |
|
||||
cd build3
|
||||
ctest --build-config Debug -j$(nproc)
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
|||
build/
|
||||
build*/
|
||||
cmake_build*/
|
||||
install_dir/
|
||||
.vscode/
|
||||
.vs/
|
||||
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ package(default_visibility = ["//visibility:public"])
|
|||
cc_library(
|
||||
name = "magic_enum",
|
||||
hdrs = glob(["include/magic_enum/*.hpp"]),
|
||||
includes = ["include/magic_enum"],
|
||||
includes = ["include"],
|
||||
)
|
||||
|
|
|
|||
111
CMakeLists.txt
111
CMakeLists.txt
|
|
@ -1,9 +1,11 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(magic_enum
|
||||
project(
|
||||
magic_enum
|
||||
VERSION "0.9.6"
|
||||
HOMEPAGE_URL "https://github.com/Neargye/magic_enum"
|
||||
DESCRIPTION "A library that provides static reflection for enums, work with any enum type without any macro or boilerplate code."
|
||||
DESCRIPTION
|
||||
"A library that provides static reflection for enums, work with any enum type without any macro or boilerplate code."
|
||||
LANGUAGES CXX
|
||||
)
|
||||
set(CPACK_PACKAGE_VENDOR "Daniil Goncharov")
|
||||
|
|
@ -22,7 +24,30 @@ endif()
|
|||
option(MAGIC_ENUM_OPT_BUILD_EXAMPLES "Build magic_enum examples" ${IS_TOPLEVEL_PROJECT})
|
||||
option(MAGIC_ENUM_OPT_BUILD_TESTS "Build and perform magic_enum tests" ${IS_TOPLEVEL_PROJECT})
|
||||
option(MAGIC_ENUM_OPT_INSTALL "Generate and install magic_enum target" ${IS_TOPLEVEL_PROJECT})
|
||||
option(MAGIC_ENUM_OPT_INSTALL_PACKAGE_XML "Include package.xml when installing" ${MAGIC_ENUM_OPT_INSTALL})
|
||||
option(MAGIC_ENUM_OPT_INSTALL_PACKAGE_XML "Include package.xml when installing"
|
||||
${MAGIC_ENUM_OPT_INSTALL}
|
||||
)
|
||||
option(MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION "When configuring tests, try use
|
||||
a local magic_enum." NO
|
||||
)
|
||||
option(MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG "When configuring tests, try use
|
||||
a local magic_enum via pkgconfig" NO
|
||||
)
|
||||
|
||||
if(${MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION} OR ${MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG})
|
||||
add_subdirectory(test)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include/magic_enum")
|
||||
set(EXPORT_NAMESPACE "${PROJECT_NAME}::")
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
add_library(${EXPORT_NAMESPACE}${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
if(MAGIC_ENUM_OPT_BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
|
|
@ -33,39 +58,33 @@ if(MAGIC_ENUM_OPT_BUILD_TESTS)
|
|||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
set(INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/include/magic_enum")
|
||||
set(EXPORT_NAMESPACE "${PROJECT_NAME}::")
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
add_library(${EXPORT_NAMESPACE}${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${INCLUDES}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
if(MAGIC_ENUM_OPT_INSTALL)
|
||||
list(APPEND CMAKE_MODULE_PATH "${ADDITIONAL_MODULES_DIR}/GenPkgConfig")
|
||||
include(GenPkgConfig)
|
||||
include(CPackComponent)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(TARGETS "${PROJECT_NAME}"
|
||||
install(
|
||||
TARGETS "${PROJECT_NAME}"
|
||||
EXPORT ${PROJECT_NAME}
|
||||
INCLUDES
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
# COMPONENT "${SDK_COMPONENT_NAME}" # component is not allowed for includes! Headers are installed separately! Includes only marks the headers for export
|
||||
# COMPONENT "${SDK_COMPONENT_NAME}" # component is not allowed for
|
||||
# includes!
|
||||
# Headers are installed separately! Includes only marks the headers for
|
||||
# export
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE HEADERS "${INCLUDES}/*.h" "${INCLUDES}/*.hxx" "${INCLUDES}/*.hpp")
|
||||
string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_LIBDIR}")
|
||||
foreach(headerFile ${HEADERS})
|
||||
get_filename_component(headerFileParentDir "${headerFile}" DIRECTORY)
|
||||
file(RELATIVE_PATH headerFileRelParentDir "${INCLUDES}" "${headerFileParentDir}")
|
||||
if(NOT DEFINED PROJECT_INCLUDE_HEADER_PATTERN)
|
||||
set(PROJECT_INCLUDE_HEADER_PATTERN "*")
|
||||
endif()
|
||||
|
||||
install(FILES "${headerFile}"
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${headerFileRelParentDir}"
|
||||
install(
|
||||
DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}
|
||||
DESTINATION include
|
||||
FILES_MATCHING
|
||||
PATTERN "${PROJECT_INCLUDE_HEADER_PATTERN}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}")
|
||||
|
|
@ -88,43 +107,55 @@ if(MAGIC_ENUM_OPT_INSTALL)
|
|||
set(CMAKE_CONFIG_FILE_BASENAME "${PROJECT_NAME}Config.cmake")
|
||||
set(CMAKE_EXPORT_FILE_BASENAME "${PROJECT_NAME}Export.cmake")
|
||||
set(CMAKE_CONFIG_VERSION_FILE_BASENAME "${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(CMAKE_CONFIG_VERSION_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CONFIG_VERSION_FILE_BASENAME}")
|
||||
set(CMAKE_CONFIG_VERSION_FILE_NAME
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CONFIG_VERSION_FILE_BASENAME}"
|
||||
)
|
||||
|
||||
export(TARGETS "${PROJECT_NAME}"
|
||||
export(
|
||||
TARGETS "${PROJECT_NAME}"
|
||||
NAMESPACE "${EXPORT_NAMESPACE}"
|
||||
FILE "${CMAKE_EXPORT_FILE_BASENAME}"
|
||||
EXPORT_LINK_INTERFACE_LIBRARIES
|
||||
)
|
||||
|
||||
install(EXPORT "${PROJECT_NAME}"
|
||||
install(
|
||||
EXPORT "${PROJECT_NAME}"
|
||||
FILE "${CMAKE_CONFIG_FILE_BASENAME}"
|
||||
NAMESPACE "${EXPORT_NAMESPACE}"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR_ARCHIND}/cmake/${PROJECT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CONFIG_VERSION_FILE_NAME}"
|
||||
#VERSION "100500.100500.100500" # any version of same bitness suits. CMake cannot compare to infinity, so use a large number we expect to be greater than any future version
|
||||
# VERSION "100500.100500.100500" # any version of same bitness suits. CMake cannot compare to
|
||||
# infinity, so use a large number we expect to be greater than any future version
|
||||
VERSION ${_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
ARCH_INDEPENDENT
|
||||
COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT
|
||||
)
|
||||
install(FILES "${CMAKE_CONFIG_VERSION_FILE_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR_ARCHIND}/cmake/${PROJECT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
configure_pkg_config_file("${PROJECT_NAME}"
|
||||
NAME "${PROJECT_NAME}"
|
||||
VERSION "${PROJECT_VERSION}"
|
||||
DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}"
|
||||
URL "${CPACK_PACKAGE_HOMEPAGE_URL}"
|
||||
INSTALL_LIB_DIR "${CMAKE_INSTALL_LIBDIR_ARCHIND}"
|
||||
INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
configure_pkg_config_file(
|
||||
"${PROJECT_NAME}"
|
||||
NAME
|
||||
"${PROJECT_NAME}"
|
||||
VERSION
|
||||
"${PROJECT_VERSION}"
|
||||
DESCRIPTION
|
||||
"${CPACK_PACKAGE_DESCRIPTION}"
|
||||
URL
|
||||
"${CPACK_PACKAGE_HOMEPAGE_URL}"
|
||||
INSTALL_LIB_DIR
|
||||
"${CMAKE_INSTALL_DATAROOTDIR}"
|
||||
INSTALL_INCLUDE_DIR
|
||||
"${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
if (MAGIC_ENUM_OPT_INSTALL_PACKAGE_XML)
|
||||
if(MAGIC_ENUM_OPT_INSTALL_PACKAGE_XML)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/package.xml
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
|
||||
)
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
|
|
|
|||
71
Dockerfile
Normal file
71
Dockerfile
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
FROM gentoo/stage3:latest
|
||||
|
||||
RUN echo "Updating Gentoo index registry..."
|
||||
RUN emerge-webrsync
|
||||
|
||||
|
||||
RUN echo "Setting up package manager"
|
||||
# Allow emerge newer versions of cmake. We need it because vcpkg wants it.
|
||||
RUN echo "dev-build/cmake ~amd64" >> /etc/portage/package.accept_keywords/unmask
|
||||
# # Get some packages as binaries and don't compile them. Actually, it allows to not compile only zip :(
|
||||
# RUN rm -rf /etc/portage/binrepos.conf/*
|
||||
# RUN echo -e "[binhost]\npriority = 9999\nsync-uri = https://gentoo.osuosl.org/experimental/amd64/binpkg/default/linux/17.1/x86-64/" >> /etc/portage/binrepos.conf/osuosl.conf
|
||||
# RUN cat /etc/portage/binrepos.conf/*
|
||||
# Arguments that going to be added automatically to `emerge` command. `man emerge` in help. Or read https://wiki.gentoo.org/wiki/Binary_package_guide/en#Installing_binary_packages .
|
||||
# RUN echo 'EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --binpkg-respect-use=y --getbinpkg=y --verbose --verbose-conflicts "' >> /etc/portage/make.conf
|
||||
|
||||
RUN echo "Installing dependencies..."
|
||||
|
||||
RUN emerge --quiet --verbose --tree --verbose-conflicts --jobs=2 dev-vcs/git dev-build/cmake zip
|
||||
|
||||
# RUN echo "Installing vcpkg..."
|
||||
# RUN git clone https://github.com/Microsoft/vcpkg.git && \
|
||||
# ./vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
||||
#
|
||||
# COPY ./vcpkg.json ./vcpkg.json
|
||||
#
|
||||
# RUN echo "Installing dependencies using vcpkg"
|
||||
# RUN ./vcpkg/vcpkg install
|
||||
|
||||
WORKDIR /backend
|
||||
|
||||
RUN echo "Copy sources of the project"
|
||||
COPY . .
|
||||
RUN ls -lah
|
||||
|
||||
# expected to be mounted at runtime as volume.
|
||||
# COPY resources/ ./resources/
|
||||
|
||||
|
||||
RUN echo "Configuring project..."
|
||||
RUN cmake -S ./ -B ./build --log-level DEBUG
|
||||
|
||||
|
||||
# RUN echo "Building project..."
|
||||
# RUN cmake --build ./build --parallel $(nproc) --verbose
|
||||
|
||||
RUN echo "really installing"
|
||||
RUN cmake --install ./build
|
||||
|
||||
RUN echo "checking cmake-cmake"
|
||||
RUN cmake -S. -B build2 -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION=1 --log-level=DEBUG
|
||||
RUN cmake --build build2 -j $(nproc) --verbose
|
||||
|
||||
RUN echo "checking pkgconfig-cmake"
|
||||
RUN cat "/usr/local/share/pkgconfig/magic_enum.pc"
|
||||
RUN cmake -S. -B build3 -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG=1 --log-level=DEBUG
|
||||
RUN cmake --build build3 -j $(nproc) --verbose
|
||||
|
||||
|
||||
|
||||
# RUN echo "what's with linking?"
|
||||
# RUN ls -lahR /usr/local/lib64
|
||||
# RUN lddtree /usr/local/lib64/libArby.so
|
||||
# RUN lddtree /usr/local/bin/Arby
|
||||
|
||||
# CMD ./build/Backend
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -23,8 +23,8 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
|
||||
enum class AnimalFlags : std::uint64_t { HasClaws = 1 << 10, CanFly = 1 << 20, EatsFish = 1 << 30, Endangered = std::uint64_t{1} << 40 };
|
||||
// Add specialization `is_flags` to define that enum are flags.
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
|
||||
enum class Color : int { RED = -10, BLUE = 0, GREEN = 10 };
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <magic_enum_containers.hpp>
|
||||
#include <magic_enum/magic_enum_containers.hpp>
|
||||
|
||||
enum class Color { RED = 1, GREEN = 2, BLUE = 4 };
|
||||
template <>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <magic_enum_containers.hpp>
|
||||
#include <magic_enum/magic_enum_containers.hpp>
|
||||
|
||||
enum class Color { RED = 1, GREEN = 2, BLUE = 4 };
|
||||
template <>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <magic_enum_containers.hpp>
|
||||
#include <magic_enum/magic_enum_containers.hpp>
|
||||
|
||||
enum class Color { RED = 1, GREEN = 2, BLUE = 4 };
|
||||
template <>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
|
||||
enum class Color : int { RED = -10, BLUE = 0, GREEN = 10 };
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
|
||||
enum class Language : int {
|
||||
日本語 = 10,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <iostream>
|
||||
|
||||
#define MAGIC_ENUM_ENABLE_HASH
|
||||
#include <magic_enum_switch.hpp>
|
||||
#include <magic_enum/magic_enum_switch.hpp>
|
||||
|
||||
enum class Color { RED, BLUE, GREEN };
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ project(
|
|||
version: '0.9.6',
|
||||
)
|
||||
|
||||
magic_enum_include = include_directories('include/magic_enum')
|
||||
magic_enum_include = include_directories('include')
|
||||
|
||||
magic_enum_args = []
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module;
|
|||
|
||||
#include <version>
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
#include <magic_enum_all.hpp>
|
||||
#include <magic_enum/magic_enum_all.hpp>
|
||||
#endif
|
||||
|
||||
export module magic_enum;
|
||||
|
|
@ -13,7 +13,7 @@ import std;
|
|||
extern "C++" {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#include <magic_enum_all.hpp>
|
||||
#include <magic_enum/magic_enum_all.hpp>
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,49 @@
|
|||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(${MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION})
|
||||
find_package(magic_enum REQUIRED magic_enum)
|
||||
endif()
|
||||
|
||||
if(${MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG})
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(magic_enum magic_enum)
|
||||
if(NOT magic_enum_FOUND)
|
||||
message(
|
||||
WARNING
|
||||
"magic_enum via pkgconfig is not found. \
|
||||
Next code will try check possible places for some platforms, \
|
||||
but there's no guarantee. \
|
||||
If you know where the magic_enum pkgconfig files (.pc) are, \
|
||||
then specify yourself variable \$\{CMAKE_PREFIX_PATH\} \
|
||||
with folder like /a/path/to/magic_enum (for POSIX-like pathes), \
|
||||
where in the folder exists share/pkgconfig/magic_enum.pc ."
|
||||
)
|
||||
if(UNIX AND EXISTS "/usr/local/share/pkgconfig/magic_enum.pc")
|
||||
message(DEBUG "\$\{CMAKE_PREFIX_PATH\} : ${CMAKE_PREFIX_PATH} ")
|
||||
set(CMAKE_PREFIX_PATH "/usr/local")
|
||||
message(DEBUG "\$\{CMAKE_PREFIX_PATH\} : ${CMAKE_PREFIX_PATH} ")
|
||||
pkg_check_modules(magic_enum magic_enum)
|
||||
endif()
|
||||
# code place for future workarounds for other platforms...
|
||||
if(NOT magic_enum_FOUND)
|
||||
message(FATAL_ERROR "Could not find magic_enum's config. Read a warning above.")
|
||||
endif()
|
||||
endif()
|
||||
message(DEBUG "magic_enum_FOUND : ${magic_enum_FOUND}")
|
||||
message(DEBUG "magic_enum_LIBRARIES: ${magic_enum_LIBRARIES}")
|
||||
message(DEBUG "magic_enum_LINK_LIBRARIES: ${magic_enum_LINK_LIBRARIES}")
|
||||
message(DEBUG "magic_enum_LIBRARY_DIRS: ${magic_enum_LIBRARY_DIRS}")
|
||||
message(DEBUG "magic_enum_INCLUDE_DIRS: ${magic_enum_INCLUDE_DIRS}")
|
||||
message(DEBUG "magic_enum_INCLUDE_DIR: ${magic_enum_INCLUDE_DIR}")
|
||||
message(DEBUG "magic_enum_LDFLAGS: ${magic_enum_LDFLAGS}")
|
||||
message(DEBUG "magic_enum_LDFLAGS_OTHER: ${magic_enum_LDFLAGS_OTHER}")
|
||||
message(DEBUG "magic_enum_CFLAGS: ${magic_enum_CFLAGS}")
|
||||
message(DEBUG "magic_enum_CFLAGS_OTHER: ${magic_enum_CFLAGS_OTHER}")
|
||||
message(DEBUG "magic_enum_INCLUDEDIR: ${magic_enum_INCLUDEDIR}")
|
||||
message(DEBUG "magic_enum_LIBDIR: ${magic_enum_LIBDIR}")
|
||||
message(DEBUG "magic_enum_PREFIX: ${magic_enum_PREFIX}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
set(OPTIONS /W4 /WX)
|
||||
check_cxx_compiler_flag(/permissive HAS_PERMISSIVE_FLAG)
|
||||
|
|
@ -22,7 +66,11 @@ function(make_test src target std)
|
|||
add_executable(${target} ${src})
|
||||
target_compile_options(${target} PRIVATE ${OPTIONS})
|
||||
target_include_directories(${target} PRIVATE 3rdparty/Catch2/include)
|
||||
target_link_libraries(${target} PRIVATE ${CMAKE_PROJECT_NAME})
|
||||
if(${MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG})
|
||||
target_include_directories(${target} PRIVATE ${magic_enum_INCLUDE_DIRS})
|
||||
else()
|
||||
target_link_libraries(${target} PRIVATE magic_enum::magic_enum)
|
||||
endif()
|
||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||
if(std)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@
|
|||
#define MAGIC_ENUM_NO_CHECK_REFLECTED_ENUM
|
||||
#define MAGIC_ENUM_RANGE_MIN -120
|
||||
#define MAGIC_ENUM_RANGE_MAX 120
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_fuse.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum_utility.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_fuse.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum_utility.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
|
|
@ -1176,7 +1176,7 @@ TEST_CASE("multdimensional-switch-case") {
|
|||
|
||||
#if defined(__cpp_lib_format)
|
||||
|
||||
#include <magic_enum_format.hpp>
|
||||
#include <magic_enum/magic_enum_format.hpp>
|
||||
|
||||
TEST_CASE("format-base") {
|
||||
REQUIRE(std::format("{}", Color::RED) == "red");
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ constexpr bool operator==(MyStringView lhs, MyStringView rhs) {
|
|||
#define MAGIC_ENUM_USING_ALIAS_STRING using string = MyString;
|
||||
#define MAGIC_ENUM_USING_ALIAS_STRING_VIEW using string_view = MyStringView;
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_flags.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_flags.hpp>
|
||||
using namespace magic_enum;
|
||||
using namespace magic_enum::bitwise_operators;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <magic_enum_containers.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum_containers.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_flags.hpp>
|
||||
#include <magic_enum_fuse.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum_utility.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_flags.hpp>
|
||||
#include <magic_enum/magic_enum_fuse.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum_utility.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
|
|
@ -91,8 +91,8 @@ struct magic_enum::customize::enum_range<number> {
|
|||
static constexpr bool is_flags = true;
|
||||
};
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_fuse.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_fuse.hpp>
|
||||
|
||||
using namespace magic_enum;
|
||||
using namespace magic_enum::bitwise_operators;
|
||||
|
|
@ -720,7 +720,7 @@ TEST_CASE("constexpr_for") {
|
|||
|
||||
#if defined(__cpp_lib_format)
|
||||
|
||||
#include <magic_enum_format.hpp>
|
||||
#include <magic_enum/magic_enum_format.hpp>
|
||||
|
||||
TEST_CASE("format-base") {
|
||||
REQUIRE(std::format("Test-{:~^11}.", Color::RED | Color::GREEN) == "Test-~RED|GREEN~.");
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@
|
|||
#define MAGIC_ENUM_RANGE_MIN -120
|
||||
#undef MAGIC_ENUM_RANGE_MAX
|
||||
#define MAGIC_ENUM_RANGE_MAX 120
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_fuse.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_fuse.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
#define MAGIC_ENUM_USING_ALIAS_STRING_VIEW using string_view = std::wstring_view;
|
||||
#define MAGIC_ENUM_USING_ALIAS_STRING using string = std::wstring;
|
||||
#include <magic_enum.hpp>
|
||||
#include <magic_enum_iostream.hpp>
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include <magic_enum/magic_enum_iostream.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
|
|
|
|||
13
test_installed_version.bash
Normal file
13
test_installed_version.bash
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
rm -rf ./build
|
||||
rm -rf ./build2
|
||||
rm -rf ./build3
|
||||
rm -rf ./install_dir/
|
||||
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release --log-level=DEBUG -DCMAKE_INSTALL_PREFIX=install_dir
|
||||
cmake --build ./build -j$(nproc)
|
||||
cmake --install ./build/ --prefix ./install_dir
|
||||
CMAKE_PREFIX_PATH="./install_dir" cmake -S. -Bbuild2 -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION=1 --log-level=DEBUG
|
||||
cmake --build build2 --config Debug -j$(nproc) --verbose
|
||||
CMAKE_PREFIX_PATH="./install_dir" cmake -S. -Bbuild3 -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG=1 --log-level=DEBUG
|
||||
cmake --build build3 --config Debug -j$(nproc) --verbose
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue