Commit 72844ac
committed
cmake: align check_symbol_exists with build flags
check_symbol_exists() runs an independent try_compile with no
knowledge of target properties. With GCC 15 defaulting to C23,
strndup was found during the check but then hidden at build time by
__STRICT_ANSI__ (set by -std=c99 / C_STANDARD 99), causing an
implicit-declaration error.
Fix this by setting CMAKE_REQUIRED_FLAGS and
CMAKE_REQUIRED_DEFINITIONS to match the flags the iio target
actually compiles with, saving and restoring their previous values
around the check block.
Introduce IIO_C_STANDARD and IIO_POSIX_C_SOURCE as the single source
of truth so that set_target_properties, target_compile_definitions
and the check block all stay in sync from one place.
Signed-off-by: Dan Nechita <dan.nechita@analog.com>1 parent 930f30c commit 72844ac
1 file changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
123 | 125 | | |
124 | 126 | | |
125 | | - | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
149 | | - | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
262 | 273 | | |
263 | 274 | | |
264 | 275 | | |
265 | 276 | | |
266 | 277 | | |
267 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
268 | 283 | | |
269 | 284 | | |
270 | 285 | | |
| |||
0 commit comments