Skip to content

Commit 702f514

Browse files
committed
Silence libtool empty-object warnings for static Xcode builds
Platform and feature guards intentionally leave some bundled sources empty, and Apple's libtool warns about each when the Xcode generator archives them. Pass -no_warning_for_no_symbols through STATIC_LIBRARY_OPTIONS for the Xcode generator only; Ninja and Makefile generators may use ar, which rejects the flag. Document it for consumers that repack FreeImage.a.
1 parent f5bfc09 commit 702f514

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,14 @@ endif()
15481548
# Apple-specific settings
15491549
if (APPLE)
15501550
set_target_properties(${PROJECT_NAME} PROPERTIES XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO")
1551+
# Platform/feature guards intentionally leave some bundled sources empty.
1552+
# Silence only libtool's empty-object warning when Xcode archives them.
1553+
# Ninja/Makefile generators may use ar, which rejects this libtool flag.
1554+
# Consumers that repack FreeImage.a need the same option on their target.
1555+
if(FREEIMAGE_STATIC AND CMAKE_GENERATOR STREQUAL "Xcode")
1556+
set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY
1557+
STATIC_LIBRARY_OPTIONS -no_warning_for_no_symbols)
1558+
endif()
15511559
if(BUILD_PLATFORM_APPLE_IOS)
15521560
set_target_properties(${PROJECT_NAME} PROPERTIES XCODE_ATTRIBUTE_GCC_THUMB_SUPPORT "NO")
15531561
endif()

‎README.md‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ target_link_libraries(<your_target> PRIVATE FreeImage::FreeImage)
334334

335335
For `find_package` to work, simply set `CMAKE_PREFIX_PATH` to the directory where the compiled binaries are installed (the `install_dir` folder from above).
336336

337+
<<<<<<< HEAD
337338
## Windows linker troubleshooting
338339

339340
If a prebuilt `FreeImage.lib` or `FreeImageD.lib` fails to link with `LNK2019`
@@ -464,6 +465,40 @@ A v143-only distribution should report that requirement before compiling.
464465
Do not use `/FORCE` to work around missing runtime symbols: it cannot supply
465466
the implementations, and the resulting executable can be invalid. `LNK4075`
466467
about `/INCREMENTAL` is a separate warning caused by that flag combination.
468+
=======
469+
## Apple archive warnings about objects with no symbols
470+
471+
Apple's `libtool` can report `FreeImage.a(...o) has no symbols` when creating
472+
or combining static libraries. Some bundled source files intentionally
473+
compile to empty objects because their platform or optional feature is not
474+
enabled, such as a Windows semaphore implementation on iOS. This diagnostic
475+
alone does not indicate missing FreeImage functions.
476+
477+
The CMake Xcode build suppresses this specific warning on the static
478+
FreeImage target. If another target later repacks `FreeImage.a`, configure
479+
that target too; archive options are not stored in the `.a` file or inherited
480+
by consumers. For another CMake target:
481+
482+
```cmake
483+
if(APPLE AND CMAKE_GENERATOR STREQUAL "Xcode")
484+
set_property(TARGET MyStaticLibrary APPEND PROPERTY
485+
STATIC_LIBRARY_OPTIONS -no_warning_for_no_symbols)
486+
endif()
487+
```
488+
489+
For a native Xcode static-library target, set **Other Librarian Flags**
490+
(`OTHER_LIBTOOLFLAGS`) in its build settings or shared `.xcconfig`:
491+
492+
```text
493+
OTHER_LIBTOOLFLAGS = $(inherited) -no_warning_for_no_symbols
494+
```
495+
496+
In openFrameworks, apply this to the core static-library target that combines
497+
FreeImage, Cairo and oF objects. Setting it only on the application target
498+
will not affect a separate nested `xcodebuild` invocation for the core.
499+
This flag belongs to Apple's archive tool, not compiler flags or
500+
`OTHER_LDFLAGS`; do not pass it to `ar` in a Ninja/Makefile build. It suppresses
501+
only empty-object warnings and leaves other archive diagnostics enabled.
467502

468503
## Running tests
469504

0 commit comments

Comments
 (0)