Skip to content

Commit

Permalink
build: 👷 remove dotenv dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Xminent committed Jan 23, 2024
1 parent eb416d9 commit 194005d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
30 changes: 3 additions & 27 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
cmake_minimum_required(VERSION 3.15)
project(${CMAKE_PROJECT_NAME}_examples LANGUAGES C CXX)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/_deps/dotenv-src/dotenv/dotenv.h")
file(
DOWNLOAD
"https://raw.githubusercontent.com/laserpants/dotenv-cpp/master/include/laserpants/dotenv/dotenv.h"
"${CMAKE_BINARY_DIR}/_deps/dotenv-src/dotenv/dotenv.h"
TLS_VERIFY ON
)
endif()

add_library(dotenv INTERFACE)
target_sources(
dotenv
INTERFACE
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/_deps/dotenv-src/dotenv/dotenv.h>
)
target_include_directories(
dotenv INTERFACE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/_deps/dotenv-src>
$<INSTALL_INTERFACE:include>
)

if(WIN32)
# Disable getenv() warning
target_compile_definitions(dotenv INTERFACE _CRT_SECURE_NO_WARNINGS)
endif()

cpmfindpackage(
NAME portaudio GITHUB_REPOSITORY "PortAudio/portaudio" GIT_TAG "v19.7.0"
)
Expand All @@ -47,8 +22,9 @@ foreach(example ${examples})
get_filename_component(example_name ${example} NAME_WE)
add_executable(${example_name} ${example})
target_link_libraries(
${example_name} PRIVATE ${CMAKE_PROJECT_NAME} dotenv portaudio_static spdlog::spdlog sodium
${example_name} PRIVATE ${CMAKE_PROJECT_NAME} portaudio_static
spdlog::spdlog sodium
)
endforeach()

file(COPY airhorn.dca DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY airhorn.dca DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
5 changes: 1 addition & 4 deletions examples/simple_with_logging.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <dotenv/dotenv.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>

Expand Down Expand Up @@ -33,9 +32,7 @@ Result<> handle_event(Snowflake &bot_id, const Event &ev,
const HttpClient &http, const asio::yield_context &yield);

async_main(const asio::yield_context &yield) {
dotenv::init();

const auto token = dotenv::getenv("DISCORD_TOKEN");
const std::string token{std::getenv("DISCORD_TOKEN")};

if (token.empty()) {
get_logger()->error("No token :(");
Expand Down

0 comments on commit 194005d

Please sign in to comment.