Skip to content

Commit 0505604

Browse files
committed
Adds deprecation warning and CMake support
1 parent 1e92f5b commit 0505604

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#----------------------- PROJECT CONFIGURATION -------------------------
2+
cmake_minimum_required(VERSION 3.10)
3+
project(cpp-dotenv VERSION 0.1.0)
4+
5+
set(CMAKE_CXX_STANDARD 14)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
#----------------------- LIBRARY CONFIGURATION -------------------------
9+
10+
set(CPP_DOTENV_LIB cpp_dotenv CACHE INTERNAL "")
11+
set(CPP_DOTENV_SRC
12+
dotenv.h
13+
)
14+
15+
add_library(${CPP_DOTENV_LIB} ${CPP_DOTENV_SRC})
16+
set_target_properties(${CPP_DOTENV_LIB} PROPERTIES
17+
LINKER_LANGUAGE CXX
18+
)
19+
20+
target_include_directories(${CPP_DOTENV_LIB} PUBLIC
21+
${CMAKE_CURRENT_SOURCE_DIR}
22+
)

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ C++ implementation of nodejs [dotenv](https://github.com/motdotla/dotenv) projec
66

77
**cpp-dotenv** is implemented as a single C++ header file, so there is no need to compile nor to add complex file dependencies to your project. Simply include the header file wherever you want to use it and ta-da!, you're done.
88

9+
## Table of contents
10+
11+
1. [Dependencies](#dependencies)
12+
2. [Usage](#usage)
13+
1. [CMake](#cmake)
14+
3. [Examples](#examples)
15+
4. [Grammar](#grammar)
16+
917
## Dependencies
1018

1119
**NONE**, for sure! :sunglasses: If it had, it wouldn't follow the basic dotenv principles.
@@ -32,6 +40,20 @@ Also for convenience, there is a namespace-global pre-loaded reference variable
3240
auto& dotenv = env; // 'auto' here is 'dotenv::dotenv'
3341
```
3442

43+
### CMake
44+
45+
`cpp-dotenv` also comes with support for `CMake` right out of the box. In order to use it, simply include this repository's directory and link the `CPP_DOTENV_LIB` library to your own targets where needed:
46+
47+
```cmake
48+
add_subdirectory(cpp-dotenv)
49+
50+
...
51+
52+
target_link_libraries(YOUR_TARGET PUBLIC ${CPP_DOTENV_LIB})
53+
```
54+
55+
After this, you might use the library as described in [usage](#usage).
56+
3557
## Examples
3658

3759
Assume the following `.env` file:

dotenv.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ namespace dotenv
366366

367367
private:
368368

369-
const bool overwrite = false;
369+
bool overwrite = false;
370370

371371
char token;
372372
uint row_count;
@@ -465,6 +465,12 @@ namespace dotenv
465465
return *this;
466466
}
467467

468+
[[deprecated("Replaced by load_dotenv()")]]
469+
inline dotenv& config(const std::string& full_path = env_filename)
470+
{
471+
return load_dotenv(full_path);
472+
}
473+
468474
inline const value_type operator[](const key_type& k) const
469475
{
470476
if (not _config) { throw std::logic_error(config_err); }

0 commit comments

Comments
 (0)