Add pkg-config support to cmake#121
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.
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.
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.