-
Notifications
You must be signed in to change notification settings - Fork 186
Add pkg-config support to cmake #121
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
base: main
Are you sure you want to change the base?
Conversation
pkg-config pc file is essential for distributions. It was provided by autotools based builds but never supported properly by cmake builds.
| # Set compilation and linking flags for SystemC | ||
| set(PKGCONFIG_CFLAGS "") | ||
| set(PKGCONFIG_DEFINES "") | ||
| set(PKGCONFIG_LDPRIV "") | ||
|
|
||
| if(ENABLE_PTHREADS) | ||
| get_target_property(pthread_cflags Threads::Threads INTERFACE_COMPILE_OPTIONS) | ||
| if(pthread_cflags) | ||
| set(PKGCONFIG_CFLAGS ${PKGCONFIG_CFLAGS} ${pthread_cflags}) | ||
| endif() | ||
| get_target_property(pthread_lib Threads::Threads INTERFACE_LINK_LIBRARIES) | ||
| if(pthread_lib) | ||
| set(PKGCONFIG_LDPRIV ${PKGCONFIG_LDPRIV} ${pthread_lib}) | ||
| endif() | ||
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to query the target properties directly on the SystemC::systemc library to set PKGCONFIG_CFLAGS, PKGCONFIG_DEFINES, and PKGCONFIG_LDPRIV. This should ensure consistency in all cases. It should also take care on the potential transitive dependency on Pthreads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I attempted to implement that and found it is not possible as SystemC::systemc contains expressions that are only evaluated at GENERATE phase while configuration is done at an earlier phase.
I checked other projects, and it seems like they are all hard-coding flags.
|
Could you please give more context on your need for distribution, and indicate if pkg-config could be substituted by another package more inline with the CMake ecosystem? |
pkg-config pc file is essential for distributions. It was provided by autotools based builds but never supported properly by cmake builds.