Commit 7a2b8b5
committed
cmake: fix shared lib build with NAG Fortran on macOS
On Apple, the shared library link rule for Fortran used GCC-specific flags:
-x f95-cpp-input (GCC preprocessing flag; NAG does not support it)
-Wl,-shared (Linux linker flag; macOS needs -dynamiclib)
The fix is NAG-specific — other non-GNU compilers (Intel, flang, Cray,
etc.) are left alone since they may handle the existing code paths fine.
Fix in two places (both already inside if(APPLE) / if(APPLE AND BUILD_STATIC_LIBS)):
1. Before add_library() (affects the main CMake Fortran shared lib rule):
For NAG Fortran, substitute CMAKE_C_CREATE_SHARED_LIBRARY so the
C compiler link rule is used instead.
2. Inside the APPLE AND BUILD_STATIC_LIBS block (the static->shared
conversion trick for long argument lists): add an elseif(NAG) branch
that uses the C compiler with -dynamiclib and auto-detects the NAG
Fortran runtime (libf72rts) from the compiler's directory so that
NAGf90_* symbols resolve.
Tested with NAG 7.2.7243 on macOS/arm64.1 parent 1bd74ad commit 7a2b8b5
1 file changed
Lines changed: 34 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
| |||
360 | 368 | | |
361 | 369 | | |
362 | 370 | | |
363 | | - | |
364 | | - | |
365 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
366 | 397 | | |
367 | 398 | | |
368 | 399 | | |
| |||
0 commit comments