Line 0
Link Here
|
|
|
1 |
Sent upstream: https://github.com/hydrogen-music/hydrogen/pull/290 |
2 |
|
3 |
cmake: Call find_path and find_library even if pkg-config calls work. |
4 |
|
5 |
Instead of calling pkg_check_modules() with the same prefix as the calls |
6 |
to find_library() and find_path(), pass PC_${prefix} to the former. |
7 |
|
8 |
This way, we are able to use the paths that might have been found by |
9 |
pkg-config as hints to the find_library and find_path calls. Doing so |
10 |
helps systems where the dependent libraries (libarchive, libsndfile etc) |
11 |
are not in the default linker path, as the linker is now called with the |
12 |
libraries' absolute path: |
13 |
|
14 |
c++ file1.o file2.o [...] -o hydrogen /usr/lib/libsndfile.so ... |
15 |
|
16 |
instead of |
17 |
|
18 |
c++ file1.o file2.o [...] -o hydrogen -lsndfile ... |
19 |
|
20 |
as the latter requires one to manually pass "-L/usr/local/lib" to CMake |
21 |
when configuring Hydrogen. |
22 |
|
23 |
While here, use HINTS instead of PATHS when calling the find_*() |
24 |
functions, as CMake's documentation says that "paths computed by system |
25 |
introspection" should use HINTS, not PATHS, which is for hardcoded |
26 |
paths. |
27 |
--- cmake/FindHelper.cmake |
28 |
+++ cmake/FindHelper.cmake |
29 |
@@ -23,7 +23,7 @@ macro(FIND_HELPER prefix pkg_name header lib) |
30 |
FIND_PACKAGE(PkgConfig) |
31 |
endif() |
32 |
if(PKG_CONFIG_FOUND) |
33 |
- pkg_check_modules(${prefix} ${pkg_name}) |
34 |
+ pkg_check_modules(PC_${prefix} ${pkg_name}) |
35 |
#MESSAGE(STATUS " LDFLAGS ${${prefix}_LDFLAGS}" ) |
36 |
#MESSAGE(STATUS " CFLAGS ${${prefix}_CFLAGS}" ) |
37 |
#MESSAGE(STATUS " INCLUDEDIRS ${${prefix}_INCLUDE_DIRS}" ) |
38 |
@@ -36,12 +36,14 @@ macro(FIND_HELPER prefix pkg_name header lib) |
39 |
|
40 |
find_path(${prefix}_INCLUDE_DIR |
41 |
NAMES ${header} |
42 |
- PATHS ${${prefix}_INCLUDE_DIRS} ${${prefix}_INCLUDEDIR} ${${prefix}_INCLUDE_PATHS} ENV ${prefix}_INCLUDE |
43 |
+ HINTS ${PC_${prefix}_INCLUDE_DIRS} ${PC_${prefix}_INCLUDEDIR} ${PC_${prefix}_INCLUDE_PATHS} |
44 |
+ ENV ${prefix}_INCLUDE |
45 |
) |
46 |
|
47 |
find_library(${prefix}_LIBRARIES |
48 |
NAMES ${lib} |
49 |
- PATHS ${${prefix}_LIBDIR} ${${prefix}_LIBRARY_DIRS} ${${prefix}_LIB_PATHS} ENV ${prefix}_PATH |
50 |
+ HINTS ${PC_${prefix}_LIBDIR} ${PC_${prefix}_LIBRARY_DIRS} ${PC_${prefix}_LIB_PATHS} |
51 |
+ ENV ${prefix}_PATH |
52 |
) |
53 |
endif() |
54 |
|