Notes |
|
(0023186)
|
Alex Neundorf
|
2010-11-11 15:43
|
|
I don't think that's a good idea.
pkg-config has problems, cmake can do better. pkg-config simply prints to stdout a set of command line options hardcoded in a text file which are hopefully correct for the compiler you are using.
An alternative could be to add something to cmake so it can be used similar to pkgconfig, something like
$ cmake --find-package=JPEG --print-include-dirs --compilerID=GNU
or so, which would basically run the
find_package(JPEG)
command and print the results to stdout for GNU compilers.
This can then be used the same way as pkg-config in non-cmake Makefiles.
Alex |
|
|
(0023250)
|
lesmana
|
2010-11-15 04:39
|
|
it is true that pkg-config just prints out some "hardcoded" strings from a text file, but that text file is (or would be) generated by CMake along with the Makefile. as far as i understand the compiler options and stuff are fixed once VTK has been installed on a system.
but i see your points. a cmake option --find-package will work just as well. |
|
|
(0023497)
|
Alex Neundorf
|
2010-11-22 15:47
|
|
I attached a cmake-config.cmake script as a very quick first try.
You can execute it with cmake in script-mode to search packages and print to stdout which flags are needed for compiling and which flags are needed for linking.
Example:
$ cmake -DMODE=COMPILE -DCOMPILER_ID=GNU -DPACKAGE=PNG -P cmake-config.cmake
-I/usr/include -I/usr/include
$ cmake -DMODE=LINK -DCOMPILER_ID=GNU -DPACKAGE=PNG -P cmake-config.cmake
/usr/lib/libpng.so /usr/lib/libz.so
So 3 variables/arguments are supported:
* MODE: this is either "COMPILE" (gives the include dirs and definitions) or "LINK" (gives the libraries) or "EXIST" (fails if the package has not been found)
* PACKAGE: the name of the package, i.e. the same as used for the find_package() call
* COMPILER_ID: the CMAKE_C_COMPILER_ID, i.e. "GNU" for gcc, "Intel" for icpc, etc.
I didn't actually try yet to use this in a Makefile, maybe the line breaks in the output make problems.
Also, it does not yet work with all Find-modules (i.e. not with those which are using e.g. try_compile()). So it needs a bit more work than half an hour to get fully working.
Alex |
|
|
(0023498)
|
Alex Neundorf
|
2010-11-22 16:16
|
|
Brad wrote:
Consider implementing the outer-most script in bash (or plain bourne shell).
Internally it can run "cmake" on a test project that prints information
during its configuration but never builds. Then you can use sed to parse
out the results. |
|
|
(0024495)
|
Bill Hoffman
|
2011-01-06 17:00
|
|
Unless there is a patch and buy in on the cmake-developers list for this issue, I can not see it happening, so I am closing the issue. |
|