Skip to content

Commit 6e4944e

Browse files
Move module to include/ directory, add compiling example program for modules
1 parent 121eb9b commit 6e4944e

File tree

6 files changed

+99
-1453
lines changed

6 files changed

+99
-1453
lines changed

CMakeLists.txt

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,36 @@ if (NOT WIN32)
162162
endif()
163163

164164
if (DPP_MODULES)
165-
add_subdirectory(src/modules)
166-
target_compile_definitions(dpp PUBLIC DPP_MODULES)
167165
message("-- C++20 Modules support: ${Green}ENABLED${ColourReset}")
166+
add_library(dpp_module)
167+
168+
target_sources(dpp_module
169+
PUBLIC
170+
FILE_SET CXX_MODULES
171+
FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/dpp/dpp.cppm"
172+
)
173+
174+
target_compile_features(dpp_module PUBLIC cxx_std_20)
175+
176+
target_include_directories(dpp_module PUBLIC
177+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
178+
$<INSTALL_INTERFACE:include>
179+
)
180+
181+
target_link_libraries(dpp_module PUBLIC dpp)
182+
183+
add_library(dpp::module ALIAS dpp_module)
184+
185+
# Installation
186+
install(TARGETS dpp_module
187+
EXPORT ${PROJECT_NAME}Targets
188+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
189+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
190+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
191+
FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dpp/include
192+
)
193+
194+
target_compile_definitions(dpp PUBLIC DPP_MODULES)
168195
else()
169196
message("-- C++20 Modules support: ${Red}DISABLED${ColourReset} (enable with -DDPP_MODULES=ON)")
170197
endif()

include/dpp/dpp.cppm

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/************************************************************************************
2+
*
3+
* D++, A Lightweight C++ library for Discord
4+
*
5+
* Copyright 2021 Craig Edwards and D++ contributors
6+
* (https://github.com/brainboxdotcc/DPP/graphs/contributors)
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*
20+
************************************************************************************/
21+
22+
module;
23+
24+
// Include the entire standard library so it doesn't cause issue in our headers
25+
#include <cstddef>
26+
#include <cstdint>
27+
#include <cstring>
28+
#include <ctime>
29+
30+
#include <algorithm>
31+
#include <charconv>
32+
#include <condition_variable>
33+
#include <cstddef>
34+
#include <ctime>
35+
#include <deque>
36+
#include <exception>
37+
#include <fstream>
38+
#include <functional>
39+
#include <iomanip>
40+
#include <iostream>
41+
#include <locale>
42+
#include <map>
43+
#include <memory>
44+
#include <mutex>
45+
#include <optional>
46+
#include <queue>
47+
#include <shared_mutex>
48+
#include <sstream>
49+
#include <string>
50+
#include <string_view>
51+
#include <thread>
52+
#include <type_traits>
53+
#include <unordered_map>
54+
#include <variant>
55+
#include <vector>
56+
57+
#include <dpp/export.h>
58+
#include <dpp/compat.h>
59+
60+
export module dpp;
61+
62+
export extern "C++" {
63+
#include <dpp/dpp.h>
64+
#include <dpp/dns.h>
65+
#include <dpp/restrequest.h>
66+
#include <dpp/unicode_emoji.h>
67+
}

include/dpp/nlohmann/json.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18033,8 +18033,8 @@ boundaries compute_boundaries(FloatType value)
1803318033
//
1803418034
// -e <= 60 or e >= -60 := alpha
1803518035

18036-
constexpr int kAlpha = -60;
18037-
constexpr int kGamma = -32;
18036+
inline constexpr int kAlpha = -60;
18037+
inline constexpr int kGamma = -32;
1803818038

1803918039
struct cached_power // c = f * 2^e ~= 10^k
1804018040
{

src/dpp/utility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ void exec(const std::string& cmd, std::vector<std::string> parameters, cmd_resul
465465
}
466466
/* Capture stderr */
467467
cmd_and_parameters << " 2>&1";
468-
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd_and_parameters.str().c_str(), "r"), pclose);
468+
std::unique_ptr<FILE, int(*)(FILE*)> pipe(popen(cmd_and_parameters.str().c_str(), "r"), pclose);
469469
if (!pipe) {
470470
return;
471471
}

src/modules/CMakeLists.txt

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)