Skip to content
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

Prevent superfluous warnings from ranlib about libcellml.a having no symbols on macOS #533

Closed
wants to merge 1 commit into from

Conversation

agarny
Copy link
Contributor

@agarny agarny commented Jan 29, 2020

Addresses issue #532.

# Prevent superfluous warnings from ranlib about libcellml.a having no symbols
# on macOS.
if(APPLE)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line required? Does it change anything from the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have no idea why, but if you don't set CMAKE_CXX_ARCHIVE_CREATE and CMAKE_CXX_ARCHIVE_FINISH then you get two warnings. If you only set one of them then you still get one warning. It's only when you set both that no warning is generated.

# on macOS.
if(APPLE)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to do this through a target property on STATIC_LIBRARY_OPTIONS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you have in mind exactly? Happy for you to suggest some code. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_property(
    TARGET cellml
    APPEND
    PROPERTY STATIC_LIBRARY_OPTIONS "-no_warning_for_no_symbols"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just given it a try, but to no avail:

FAILED: src/libcellml.a
: && /usr/local/Cellar/cmake/3.16.3/bin/cmake -E remove src/libcellml.a && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar qc src/libcellml.a -no_warning_for_no_symbols src/CMakeFiles/cellml.dir/component.cpp.o src/CMakeFiles/cellml.dir/componententity.cpp.o src/CMakeFiles/cellml.dir/debug.cpp.o src/CMakeFiles/cellml.dir/entity.cpp.o src/CMakeFiles/cellml.dir/error.cpp.o src/CMakeFiles/cellml.dir/generator.cpp.o src/CMakeFiles/cellml.dir/generatorprofile.cpp.o src/CMakeFiles/cellml.dir/importedentity.cpp.o src/CMakeFiles/cellml.dir/importsource.cpp.o src/CMakeFiles/cellml.dir/logger.cpp.o src/CMakeFiles/cellml.dir/model.cpp.o src/CMakeFiles/cellml.dir/namedentity.cpp.o src/CMakeFiles/cellml.dir/orderedentity.cpp.o src/CMakeFiles/cellml.dir/parser.cpp.o src/CMakeFiles/cellml.dir/printer.cpp.o src/CMakeFiles/cellml.dir/reset.cpp.o src/CMakeFiles/cellml.dir/units.cpp.o src/CMakeFiles/cellml.dir/utilities.cpp.o src/CMakeFiles/cellml.dir/validator.cpp.o src/CMakeFiles/cellml.dir/variable.cpp.o src/CMakeFiles/cellml.dir/version.cpp.o src/CMakeFiles/cellml.dir/xmlattribute.cpp.o src/CMakeFiles/cellml.dir/xmldoc.cpp.o src/CMakeFiles/cellml.dir/xmlnode.cpp.o src/CMakeFiles/cellml.dir/xmlutils.cpp.o && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib src/libcellml.a && /usr/local/Cellar/cmake/3.16.3/bin/cmake -E touch src/libcellml.a && :
ar: -no_warning_for_no_symbols: No such file or directory
ninja: build stopped: subcommand failed.

I then tried to replace STATIC_LIBRARY_OPTIONS with STATIC_LIBRARY_FLAGS, as suggested here, but still no luck. The same when replacing APPEND with APPEND_STRING with either STATIC_LIBRARY_OPTIONS or STATIC_LIBRARY_FLAGS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After consideration I think it would be better to exclude the debug.cpp file from the build instead. And then add in an option to the configuration to enable debug helper methods.

@kerimoyle
Copy link
Contributor

I don't think I'm really not qualified to comment/review/whatever this PR ... :( sorry ...

@hsorby
Copy link
Contributor

hsorby commented Jan 29, 2020

As an alternative see #536.

@agarny
Copy link
Contributor Author

agarny commented Jan 29, 2020

Agreed, not to have debug[.cpp|.h] is a better way forward.

@agarny agarny closed this Jan 29, 2020
@agarny agarny deleted the issue532 branch January 29, 2020 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants