diff options
Diffstat (limited to 'cmake/ModulePackage.cmake')
-rw-r--r-- | cmake/ModulePackage.cmake | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index 9cc21863..04dbf16d 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake | |||
@@ -21,21 +21,39 @@ endif() | |||
21 | 21 | ||
22 | find_package(PkgConfig) | 22 | find_package(PkgConfig) |
23 | 23 | ||
24 | function(pkg_use_module mod pkg) | 24 | function(pkg_use_module mod pkgs) |
25 | if(PKG_CONFIG_FOUND) | 25 | foreach(pkg IN ITEMS ${pkgs}) |
26 | pkg_search_module(${mod} ${pkg}) | 26 | if(PKG_CONFIG_FOUND) |
27 | endif() | 27 | pkg_search_module(${mod} ${pkg}) |
28 | if(${mod}_FOUND) | 28 | endif() |
29 | link_directories(${${mod}_LIBRARY_DIRS}) | 29 | if(NOT ${mod}_FOUND) |
30 | include_directories(${${mod}_INCLUDE_DIRS}) | 30 | find_package(${pkg} QUIET) |
31 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | 31 | # This is very very ugly, but the variables are sometimes used in this scope |
32 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | 32 | # and sometimes in the parent scope, so we have to set them to both places. |
33 | 33 | set(${mod}_FOUND ${${pkg}_FOUND}) | |
34 | foreach(dir ${${mod}_INCLUDE_DIRS}) | 34 | set(${mod}_FOUND ${${pkg}_FOUND} PARENT_SCOPE) |
35 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE) | 35 | set(${mod}_LIBRARIES ${${pkg}_LIBS}) |
36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE) | 36 | set(${mod}_LIBRARIES ${${pkg}_LIBS} PARENT_SCOPE) |
37 | endforeach() | 37 | set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS}) |
38 | endif() | 38 | set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS} PARENT_SCOPE) |
39 | set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS}) | ||
40 | set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS} PARENT_SCOPE) | ||
41 | endif() | ||
42 | if(${mod}_FOUND) | ||
43 | link_directories(${${mod}_LIBRARY_DIRS}) | ||
44 | include_directories(${${mod}_INCLUDE_DIRS}) | ||
45 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | ||
46 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | ||
47 | |||
48 | if(NOT MSVC) | ||
49 | foreach(dir ${${mod}_INCLUDE_DIRS}) | ||
50 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE) | ||
51 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE) | ||
52 | endforeach() | ||
53 | endif() | ||
54 | break() | ||
55 | endif() | ||
56 | endforeach() | ||
39 | endfunction() | 57 | endfunction() |
40 | 58 | ||
41 | function(add_module lib) | 59 | function(add_module lib) |