-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++20 modules support #1162
Comments
@germandiagogomez thanks for your feature request! |
Hello @COM8. Maybe over some weekend I could try a couple of experiments at some point. But I do not know yet when that weekend will come. Too busy with work actually til at least May unless I find a slot somewhere. |
No hurry I know we all got other stuff to do and we are all doing this in our free time :) |
Here is one possible way to support C++20 module usage. diff --git a/cpr/CMakeLists.txt b/cpr/CMakeLists.txt
index db48358..ad8922d 100644
--- a/cpr/CMakeLists.txt
+++ b/cpr/CMakeLists.txt
@@ -29,6 +29,10 @@ add_library(cpr
curlmultiholder.cpp
multiperform.cpp)
+target_compile_features(cpr PUBLIC cxx_std_20)
+
+target_sources(cpr PUBLIC FILE_SET CXX_MODULES FILES module.cpp)
+
add_library(cpr::cpr ALIAS cpr)
target_link_libraries(cpr PUBLIC ${CURL_LIB}) # todo should be private, but first dependencies in ssl_options need to be removed
@@ -50,6 +54,7 @@ include(GNUInstallDirs)
install(TARGETS cpr
EXPORT cprTargets
+ FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/cpr/module.cpp b/cpr/module.cpp
new file mode 100644
index 0000000..74d86d8
--- /dev/null
+++ b/cpr/module.cpp
@@ -0,0 +1,16 @@
+module;
+
+#include "cpr/cpr.h"
+
+export module cpr;
+
+export namespace cpr {
+using cpr::Authentication;
+using cpr::AuthMode;
+
+using cpr::Parameters;
+using cpr::Response;
+using cpr::Url;
+
+using cpr::Get;
+} // namespace cpr Now the example in README.md can be switched between (Edited) We might need to first decide whether users can using It's a problem since that See also: |
Is your feature request related to a problem?
I would like to use cpr as a module.
Possible Solution
Being able to
import cpr
from my own code.Alternatives
Compile with
#include
Additional Context
I would like to start to use modules in the context of a bigger project.
The text was updated successfully, but these errors were encountered: