Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
tastytea | 9337964266 | |
tastytea | 49b2117f13 | |
tastytea | 3da87609f4 | |
tastytea | 32e0a46a7f | |
tastytea | 88751694a5 | |
tastytea | 9a5bad2335 | |
tastytea | 26ae664334 | |
tastytea | 83a01f2941 |
|
@ -1,12 +1,13 @@
|
|||
# Support version 3.1 and above, but use policy settings up to 3.14.
|
||||
cmake_minimum_required(VERSION 3.1...3.14)
|
||||
# Ranges are supported from 3.12, set policy to current for 3.1 - 3.11.
|
||||
# Support version 3.6 and above, but use policy settings up to 3.14.
|
||||
# 3.6 is needed because of IMPORTED_TARGET in pkg_check_modules().
|
||||
cmake_minimum_required(VERSION 3.6...3.14)
|
||||
# Ranges are supported from 3.12, set policy to current for < 3.12.
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.12)
|
||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||
endif()
|
||||
|
||||
project(xdgcfg
|
||||
VERSION 0.4.0
|
||||
VERSION 0.5.0
|
||||
LANGUAGES CXX
|
||||
)
|
||||
# DESCRIPTION was introduced in version 3.9.
|
||||
|
@ -18,9 +19,7 @@ endif()
|
|||
# All custom build switches.
|
||||
option(WITH_EXAMPLES "Compile examples." NO)
|
||||
option(WITH_TESTS "Compile tests." NO)
|
||||
|
||||
# Build shared libs by default but allow overriding.
|
||||
set(BUILD_SHARED_LIBS YES CACHE BOOL "Build shared libs.")
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries." YES)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||
|
@ -46,7 +45,6 @@ else()
|
|||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(pkg-config)
|
||||
add_subdirectory(cmake)
|
||||
|
||||
|
|
2
Doxyfile
2
Doxyfile
|
@ -1,7 +1,7 @@
|
|||
# -*- mode: conf-unix -*-
|
||||
PROJECT_NAME = "xdgcfg"
|
||||
PROJECT_NUMBER = 0.0.0
|
||||
INPUT = README.md src/
|
||||
INPUT = README.md include/ src/
|
||||
USE_MDFILE_AS_MAINPAGE = README.md
|
||||
EXAMPLE_PATH = examples/
|
||||
EXAMPLE_RECURSIVE = YES
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
Copyright (c) 2019 tastytea <tastytea@tastytea.de>. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -5,7 +5,7 @@ necessary.
|
|||
## Usage
|
||||
|
||||
`xdgcfg.hpp` has explanatory comments in it and there is an
|
||||
[example](src/example.cpp). The reference is also available at
|
||||
[example](examples/example.cpp). The reference is also available at
|
||||
[doc.schlomp.space/xdgcfg/](https://doc.schlomp.space/xdgcfg/classxdgcfg.html).
|
||||
|
||||
Use it in your CMake project like this:
|
||||
|
|
|
@ -3,4 +3,4 @@ include(CMakeFindDependencyMacro)
|
|||
find_dependency(PkgConfig REQUIRED)
|
||||
pkg_check_modules(libconfig++ REQUIRED IMPORTED_TARGET libconfig++)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* This file is part of xdgcfg. */
|
||||
|
||||
#include <iostream>
|
||||
#include <libconfig.h++>
|
||||
#include "xdgcfg.hpp"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
include(GNUInstallDirs)
|
||||
|
||||
install(FILES "xdgcfg.hpp" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
@ -1,5 +1,7 @@
|
|||
/* Public Domain / CC-0
|
||||
* Author: tastytea <tastytea@tastytea.de>
|
||||
/* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
#ifndef XDGCFG_HPP
|
||||
|
@ -21,7 +23,7 @@
|
|||
namespace fs = std::experimental::filesystem;
|
||||
#endif
|
||||
using std::string;
|
||||
using std::uint_fast8_t;
|
||||
using std::uint8_t;
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
|
||||
|
@ -46,7 +48,7 @@ public:
|
|||
*
|
||||
* @return 0 on success, 1 on I/O error, 2 on parse error.
|
||||
*/
|
||||
uint_fast8_t read();
|
||||
uint8_t read();
|
||||
|
||||
/*!
|
||||
* @brief Write the file
|
||||
|
|
|
@ -4,11 +4,13 @@ find_package(PkgConfig REQUIRED)
|
|||
pkg_check_modules(libxdg-basedir REQUIRED IMPORTED_TARGET libxdg-basedir)
|
||||
pkg_check_modules(libconfig++ REQUIRED IMPORTED_TARGET libconfig++)
|
||||
|
||||
add_library(${PROJECT_NAME} "xdgcfg.cpp" "../include/xdgcfg.hpp")
|
||||
set(${PROJECT_NAME}_public_headers "../include/xdgcfg.hpp")
|
||||
add_library(${PROJECT_NAME} "xdgcfg.cpp" "${${PROJECT_NAME}_public_headers}")
|
||||
|
||||
set_target_properties(xdgcfg PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR})
|
||||
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}
|
||||
PUBLIC_HEADER "${${PROJECT_NAME}_public_headers}")
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
|
@ -22,4 +24,5 @@ target_link_libraries(${PROJECT_NAME}
|
|||
install(TARGETS ${PROJECT_NAME}
|
||||
EXPORT "${PROJECT_NAME}Targets"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* Public Domain / CC-0
|
||||
* Author: tastytea <tastytea@tastytea.de>
|
||||
/* Copyright © 2019 tastytea <tastytea@tastytea.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
#include <basedir.h>
|
||||
|
@ -25,7 +27,7 @@ xdgcfg::xdgcfg(const string &filename, const string &subdir)
|
|||
_filepath /= filename;
|
||||
}
|
||||
|
||||
uint_fast8_t xdgcfg::read()
|
||||
uint8_t xdgcfg::read()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
Reference in New Issue