Skip to content

build: tidy up compiler definition for tests#17768

Closed
vszakats wants to merge 17 commits intocurl:masterfrom
vszakats:cm-compopt
Closed

build: tidy up compiler definition for tests#17768
vszakats wants to merge 17 commits intocurl:masterfrom
vszakats:cm-compopt

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Jun 28, 2025

  • tests: merge cmake commands.
  • tests: use target_compile_definitions().
  • tests/server: use generator expression for platform-specific macro.
  • tests/unit: sync Makefile.am comment with cmake.
  • tests/unit: merge two AM_CPPFLAGS lines to keep synced with cmake.
  • tests: move macro definitions to first.h headers from build level.
    CURL_NO_OLDIES, CURL_DISABLE_DEPRECATION, WITHOUT_LIBCURL,
    CURL_STATICLIB (for servers).
    To share more logic.
    Pass CURL_STATICLIB in server on all platforms for simplicity.
    (On non-Windows, it's a no-op. It's already done like this with curlu
    and libcurltool.)

Also for lib:

  • lib: merge commands.
  • lib: sync macro order with tests (also in Makefile.am).

  • perhaps leave CURL_NO_OLDIES, CURL_DISABLE_DEPRECATION
    on build level for better readability?
    No, this seems fine on a second before/after review.

@github-actions github-actions bot added the tests label Jun 28, 2025
@vszakats vszakats marked this pull request as draft June 28, 2025 00:20
@vszakats vszakats changed the title cmake: tidy up compiler definition commands build: tidy up compiler definition for tests Jun 28, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Jun 28, 2025
vszakats added a commit to vszakats/curl that referenced this pull request Jul 4, 2025
… option

Current build doesn't hit this case, but a pending PR does.

Fixing:
```
[...] -Ilib -Itests/client -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -D_definitions_t-NOTFOUND
```
error: ISO C99 requires whitespace after the macro name [clang-diagnostic-c99-extensions,-warnings-as-errors]

Ref: curl#17768
vszakats added a commit to vszakats/curl that referenced this pull request Jul 4, 2025
Fix `curl_add_clang_tidy_test_target` generating an invalid option for
`clang-tidy` if the tested target has no custom macro definition.

Current build doesn't hit this case, but a pending PR does.

Fixing:
```
[...] -Ilib -Itests/client -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -D_definitions_t-NOTFOUND
```
error: ISO C99 requires whitespace after the macro name [clang-diagnostic-c99-extensions,-warnings-as-errors]

Cherry-picked from curl#17768
Closes curl#17813
vszakats added a commit to vszakats/curl that referenced this pull request Jul 4, 2025
Factor out two local variables.

Cherry-picked from curl#17768

Closes curl#17814
vszakats added a commit to vszakats/curl that referenced this pull request Jul 4, 2025
Factor out two local variables.

Cherry-picked from curl#17768

Closes curl#17814
vszakats added a commit to vszakats/curl that referenced this pull request Jul 4, 2025
- simplify gathering header directories and compiler definitions
  recursively.

- handle the case when the cmake directory doesn't define header
  directories or compiler definitions.

- honor more corners cases:
  - `INTERFACE_INCLUDE_DIRECTORIES` of the initial target.
  - handle no header directory for initial target.

- de-duplicate header directories and compiler redefinitions to mimic
  CMake.

- drop unnecessary `unset()`s.

Note that the order of header directories remains different compared to
how CMake passes them to the compiler when building tests. The order is
already skewed in the test target `INCLUDE_DIRECTORIES` property,
preventing to reproduce the CMake order. The distinction between `-I`
and `-isystem` is also missing from target properties.

Cherry-picked from curl#17768

Closes curl#17814
vszakats added a commit to vszakats/curl that referenced this pull request Jul 4, 2025
- simplify gathering header directories and compiler definitions
  recursively.

- handle the case when the cmake directory doesn't define header
  directories or compiler definitions.

- honor more corners cases:
  - `INTERFACE_INCLUDE_DIRECTORIES` of the initial target.
  - handle no header directory for initial target.

- de-duplicate header directories and compiler redefinitions to mimic
  CMake.

- drop unnecessary `unset()`s.

Note that the order of header directories remains different compared to
how CMake passes them to the compiler when building tests. The order is
already skewed in the test target `INCLUDE_DIRECTORIES` property,
preventing to reproduce the CMake order. The distinction between `-I`
and `-isystem` is also missing from target properties.

Cherry-picked from curl#17768

Closes curl#17814
vszakats added a commit that referenced this pull request Jul 4, 2025
- simplify gathering header directories and compiler definitions
  recursively.

- handle the case when the cmake directory object doesn't define header
  directories or compiler definitions.

- honor more corners cases:
  - `INTERFACE_INCLUDE_DIRECTORIES` of the initial target.
  - handle no header directory for initial target.

- de-duplicate header directories and compiler redefinitions to mimic
  CMake.

- drop unnecessary `unset()`s.

Note that the order of header directories remains different compared to
how CMake passes them to the compiler when building tests. The order is
already different in the test target `INCLUDE_DIRECTORIES` property,
preventing to reproduce the exact CMake order. The distinction between
`-I` and `-isystem` is also missing from target properties.

Cherry-picked from #17768

Closes #17814
@vszakats vszakats added the feature-window A merge of this requires an open feature window label Jul 7, 2025
@vszakats vszakats marked this pull request as ready for review July 28, 2025 09:32
@vszakats vszakats closed this in 2c90c3a Jul 28, 2025
@vszakats vszakats deleted the cm-compopt branch July 28, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build cmake feature-window A merge of this requires an open feature window tests tidy-up

Development

Successfully merging this pull request may close these issues.

1 participant

Comments