I'm trying to add a CMakeLists.txt for this project: https://github.com/gdelugre/literal_ipaddr which is very simple.
This is what I did:
cmake_minimum_required(VERSION 3.5)
project(literal_ipaddr)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_library (literal_ipaddr ipaddr.cc)
set_property(TARGET literal_ipaddr PROPERTY CXX_STANDARD 17)
but I mainly get errors in constexpr
token:
/home/user/libopenvpn/literal_ipaddr/ipaddr.h:100:21: error: expected ‘(’ before ‘constexpr’
else if constexpr ( base == 16 )
^~~~~~~~~
/home/user/libopenvpn/literal_ipaddr/ipaddr.h: In lambda function:
/home/user/libopenvpn/literal_ipaddr/ipaddr.h:327:51: error: expected ‘{’ before ‘constexpr’
auto remaining_chars = [](size_t pos) constexpr { return N - 1 - pos; };
^~~~~~~~~
/home/user/libopenvpn/literal_ipaddr/ipaddr.h: In function ‘constexpr int IPAddr::details::inet6_aton(const char (&)[N], in6_addr&)’:
/home/user/libopenvpn/literal_ipaddr/ipaddr.h:327:51: error: expected ‘,’ or ‘;’ before ‘constexpr’
/home/user/libopenvpn/literal_ipaddr/ipaddr.h: In function ‘constexpr auto IPAddr::inet_pton(const char (&)[N])’:
/home/user/libopenvpn/literal_ipaddr/ipaddr.h:430:12: error: expected ‘(’ before ‘constexpr’
if constexpr (AddressF == AF_INET ) {
Take a look at the project's Makefile
: https://github.com/gdelugre/literal_ipaddr/blob/master/Makefile. The only thing missing is the -Wno-missing-field-initializers
. Is it necessary and if so, how to do it in cmake?