Add xxx_DEFINITIONS macro
Find package should include a DEFINITION macro even empty to forward -D options.
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Contributor
If I have a very simple Cmake project:
cmake_minimum_required(VERSION 2.8) project(example1) find_package(PkgConfig REQUIRED) pkg_check_modules(PC_STARPU libstarpu REQUIRED) message(STATUS "${PC_STARPU_CFLAGS_OTHER}")
And if I trace the call made by cmake to pkg-config I have the following:
[tmijieux@tontonbox: build]$ strace -e execve -f cmake .. |& grep pkg-config [pid 23156] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--version"], 0x2677d10 /* 52 vars */) = 0 -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") [pid 23157] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--exists", "--print-errors", "--short-errors", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23158] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--modversion", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23159] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--variable=prefix", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23160] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--variable=includedir", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23161] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--variable=libdir", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23162] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--libs-only-l", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23163] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--libs-only-l", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23164] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--libs-only-L", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23165] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--libs-only-L", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23166] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--libs", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23167] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--libs", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23168] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--libs-only-other", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23169] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--libs-only-other", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23170] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--cflags-only-I", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23171] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--cflags-only-I", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23172] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--cflags", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23173] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--cflags", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23174] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--cflags-only-other", "libstarpu"], 0x2677d10 /* 52 vars */) = 0 [pid 23175] execve("/usr/bin/pkg-config", ["/usr/bin/pkg-config", "--static", "--cflags-only-other", "libstarpu"], 0x2677d10 /* 52 vars */) = 0
The one that give the DEFINITION is actually
pkg-config --cflags-only-other libstarpu
You can also see from cmake documentation that cmake set the <XPREFIX>_CFLAGS_OTHER variable is this the one that contains the DEFINITIONS
- Contributor
As they are named "other", one could think, that they could contain something else that a definition (everything else but Includes), but I think the compilation flags that are meant to be passed to a dependent package are only include directories and definitions (I can't think of anything else).
(for instance DEFINITIONS could be useful when using FindLAPACKE from a C++ project, we could think of implementing this kind of functionality:
find_package(LAPACKE COMPONENT cpp REQUIRED)
and the DEFINITIONS would actually contains the -DHAVE_LAPACK_CONFIG_H and -DLAPACK_COMPLEX_CPP
to replace the C complex types with the binary compatible C++ complex types )
Edited by MIJIEUX Thomas - Contributor
For the cases where the source code doesn't provide a pkg-config (or even a standalone Cmake module), I think that for most of cases, it means that the code does not require to setup definitions for dependent packages. For other cases where it does matter (if they are any), we probably have to look up about the definitions flags on the source documentation and set them directly in the Find module.
- MIJIEUX Thomas mentioned in commit fpruvost/chameleon@02a28fb9
mentioned in commit fpruvost/chameleon@02a28fb9
- MIJIEUX Thomas mentioned in commit d19125f8
mentioned in commit d19125f8