Discussion:
[cmake-developers] Using pkgconf
Paul Fultz II via cmake-developers
2018-06-12 16:11:40 UTC
Permalink
Hi All,

So from a previous threads, we were discussing pkgconfig and cmake interoperability. One issue with using pkgconfig currently, is that the results are completely flat. This is due to using the CLI to retrieve pkgconfig, which gives the user all the flags from every transitive package. This is great from a user perspective, but from cmake perspective not so because may already being using one of the transitive dependencies.

So instead of using the CLI, there is a library implementation of pkgconfig called pkgconf:

https://github.com/pkgconf/pkgconf <https://github.com/pkgconf/pkgconf>
http://pkgconf.readthedocs.io/en/latest/ <http://pkgconf.readthedocs.io/en/latest/>

CMake could use pkgconf internally, and then use functions like `pkgconf_pkg_traverse` to iterate over the transitive dependencies. We could use variable in the .pc files like `cmake_package` to know which cmake package the dependency belongs to or perhaps `cmake_target` to set the name of the cmake imported target.

Daniel Pfeiffer proposed supporting pkgconfig by extending `find_package`, like this:

find_package(zlib CONF)

And this would look up zlib using pkgconfig. The advantage of this, is that the transitive dependencies can be specified in the same manner as `find_dependency(zlib CONF)`.

Paul
Brad King
2018-06-13 12:54:01 UTC
Permalink
Post by Paul Fultz II via cmake-developers
https://github.com/pkgconf/pkgconf
CMake could use pkgconf internally
The license looks MIT-like.

Please confirm that it is at least BSD-3 compatible.
Post by Paul Fultz II via cmake-developers
find_package(zlib CONF)
And this would look up zlib using pkgconfig
An important distinction is that `find_package` is meant for whole
packages that may contain multiple libraries and components, while
IIUC a `.pc` file is equivalent to a single CMake target. We'll
need a way to reconcile that. Does pkgconfig have conventions for
meta-packages that cover multiple components?

Also, how should version matching work?

Thanks,
-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
Paul Fultz II via cmake-developers
2018-06-14 17:20:02 UTC
Permalink
Post by Brad King
Post by Paul Fultz II via cmake-developers
https://github.com/pkgconf/pkgconf
CMake could use pkgconf internally
The license looks MIT-like.
Please confirm that it is at least BSD-3 compatible.
I am not lawyer, but it seems to be compatible.
Post by Brad King
Post by Paul Fultz II via cmake-developers
find_package(zlib CONF)
And this would look up zlib using pkgconfig
An important distinction is that `find_package` is meant for whole
packages that may contain multiple libraries and components, while
IIUC a `.pc` file is equivalent to a single CMake target. We'll
need a way to reconcile that. Does pkgconfig have conventions for
meta-packages that cover multiple components?
You can just create a .pc file that adds each component in the requires. Since, we trace the dependencies, the user can use just one of the components targets, or use the package’s target which will include all components.

We could have the `find_package` component clause select one of the requirements:

find_package(foo CONF COMPONENTS bar)

But I dont think this really makes sense as the user could just do:

find_package(bar CONF)
Post by Brad King
Also, how should version matching work?
This is different than cmake’s. Since this is a different mode for `find_package` we should probably support the version constraints of pkgconfig:

find_package(zlib CONF VERSION > 1.0)

Although since pkgconfig has a more sophisticated mechanism to resolve packages(through the ‘replaces’ and ‘conflicts’ fields), we may want to have a way to query several packages at once, or even use previous found version as a constraint as well.
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http
Brad King
2018-06-14 18:54:25 UTC
Permalink
Post by Paul Fultz II via cmake-developers
Post by Brad King
meta-packages that cover multiple components?
You can just create a .pc file that adds each component in the requires.
That assumes that all components are wanted and are meant to be
all used together at once for linking. CMake's find_package
command is meant to find what's available. Project code then
links to some subset of the actual targets available. Maybe
we'd need a variable-only .pc file with a specific naming
convention for that.
Post by Paul Fultz II via cmake-developers
find_package(zlib CONF VERSION > 1.0)
find_package already has a "CONFIG" mode. The semantics of
pkgconf are different enough I don't think we should overload
the command. I'd rather have a separate find_pkgconf command.
Or maybe another name will be appropriate depending on the
semantics designed.

-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
APEKE, SENA (ext)
2018-06-15 09:19:26 UTC
Permalink
Hello,
We are beginners of cmake and currently we use it for porting mariadb. When we start manufacturing, we get a hang in the file CMakeDetermineCCompiler.cmake :

................................................
................................................
opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(38): if(NOT CMAKE_C_COMPILER_NAMES )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(39): set(CMAKE_C_COMPILER_NAMES cc )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(42): if(${CMAKE_GENERATOR} MATCHES Visual Studio )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(43): elseif(${CMAKE_GENERATOR} MATCHES Xcode )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(46): else()
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(47): if(NOT CMAKE_C_COMPILER )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(48): set(CMAKE_C_COMPILER_INIT NOTFOUND )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(51): if(NOT $ENV{CC} STREQUAL )
/opt/freeware/share/cmake/Modules/CMakeDetermineCCompiler.cmake(52): get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT )

Someone understand this problem? we need help please,

Thanks in advance !

Sena

-----Original Message-----
From: cmake-developers [mailto:cmake-developers-***@cmake.org] On Behalf Of Brad King
Sent: Thursday, June 14, 2018 8:54 PM
To: Paul Fultz II
Cc: cmake-***@cmake.org
Subject: Re: [cmake-developers] Using pkgconf
Post by Paul Fultz II via cmake-developers
Post by Brad King
meta-packages that cover multiple components?
You can just create a .pc file that adds each component in the requires.
That assumes that all components are wanted and are meant to be all used together at once for linking. CMake's find_package command is meant to find what's available. Project code then links to some subset of the actual targets available. Maybe we'd need a variable-only .pc file with a specific naming convention for that.
Post by Paul Fultz II via cmake-developers
find_package(zlib CONF VERSION > 1.0)
find_package already has a "CONFIG" mode. The semantics of pkgconf are different enough I don't think we should overload the command. I'd rather have a separate find_pkgconf command.
Or maybe another name will be appropriate depending on the semantics designed.

-Brad
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
Loading...