-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
cmake: add libcurlu
/libcurltool
for unit tests
#11446
Conversation
Add a `libcurlu`/`libcurltool` static library that is compiled only for unit tests. We use `EXCLUDE_FROM_ALL` to make sure that they're not built by default, they're only built if unit tests are built. These libraries allow us to compile every unit test with CMake.
any cmake person around who wants to give this PR their thumbs up? I wouldn't be able to say if this is done the right way or not. |
I found two PRs that touched building unit tests in CMake, see:
|
I like how this gets rid of the hack I added to build unit tests with a static library, but my knowledge of CMake isn't enough to tell if there are any issues with how it's done. Having said that, it looks fine to me, although I wouldn't have expected there to be any changes necessary to src/CMakeLists.txt |
I've mainly placed it there to match the definition of Lines 75 to 83 in ebd83bf
(some of the unit tests test functions in the We could move the definition to |
I can't spot any objects from src/ in the libcurlu built by autoconf, and
there's no reference to it in the src/ directory. Are you sure this is needed?
|
Lines 63 to 67 in 2900c29
To be honest, most of the unit tests don't need Lines 48 to 50 in 2900c29
|
I see it now. No objections to merging this. |
|
Both the Line 70 in ed6ac11
Instead, they're built automatically whenever you build anything that depends on them. And since the unit tests are the only targets that depend on We could hide them behind an
Maybe it's worth adding a comment? I think most CMake people will know what
There is one other difference, it also defines Line 73 in ed6ac11
Defining Lines 46 to 51 in 2900c29
So, we could avoid compiling everything twice for --- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -116 +116 @@ libcurl_la_CFLAGS = $(AM_CFLAGS) $(libcurl_la_CFLAGS_EXTRA)
-libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
+libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB |
Damn, I totally missed the
After reading your analysis, I can agree with that. I feel like there could be some complicated way to re-use everything that does not rely on the additional macro, but I'm not sure if it's worth it. So it's thumbs up from me. |
Thank you everyone and @aloisklink in particular. I'm merging! |
Add a `libcurlu`/`libcurltool` static library that is compiled only for unit tests. We use `EXCLUDE_FROM_ALL` to make sure that they're not built by default, they're only built if unit tests are built. These libraries allow us to compile every unit test with CMake. Closes curl#11446
Before this patch, building unit tests (= the `testdeps` target) required `-DCURLDEBUG` be set either via `ENABLE_DEBUG=ON` or `ENABLE_CURLDEBUG=ON`. After fixing the build issues in curl#13694, the above requirement is no longer necessary as a workaround. This patch makes unit tests build unconditionally. Depends-on: curl#13694 (fix build issues) Depends-on: curl#13697 (fix unit test issue revealed by Old Linux CI job) Follow-up to 39e7c22 curl#11446 Closes curl#13698
Before this patch, the `testdeps` build target required `-DCURLDEBUG` be set either via `ENABLE_DEBUG=ON` or `ENABLE_CURLDEBUG=ON` to build the curl unit tests. After fixing build issues in #13694, we can drop this requirement and build unit tests unconditionally. Depends-on: #13694 Depends-on: #13697 (fix unit test issue revealed by Old Linux CI job) Follow-up to 39e7c22 #11446 Closes #13698
Add a
libcurlu
/libcurltool
static library to the CMake build that is compiled only for unit tests. We useEXCLUDE_FROM_ALL
to make sure that they're not built by default, they're only built if unit tests are built.These libraries allow us to compile every unit test with CMake, rather than skipping some of them.
To make reviewing easier:
libcurltool
is defined in theMakefile.am
at:curl/src/Makefile.am
Lines 77 to 82 in ebd83bf
libcurlu
is defined in theMakefile.am
at:curl/lib/Makefile.am
Lines 116 to 118 in ebd83bf
You can also easily configure, build, and test everything using: