pcsx2/cmake/CheckLib.cmake

41 lines
1.1 KiB
CMake
Raw Normal View History

2014-08-04 16:05:13 +00:00
include(FindPkgConfig OPTIONAL)
macro(_internal_message msg)
message("${msg}")
endmacro()
macro(check_lib var lib)
set(_arg_list ${ARGN})
Avoid PKG_CONFIG_PATH issues. Even before this pull request it was required to set PKG_CONFIG_PATH when cross compiling since pkg-config always searches for native libraries. This would require to backup an already existing ENV variable if present, detect the distro specific place the pkgconfig folder is, and restore the original ENV variable if it was present. Cmake as shown in: . http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3df51470 . added support for this but requires CMAKE_MINIMUM_REQUIRED_VERSION as 3.1 which is kind of strict since it was released 10 days ago. . To avoid the ugliness let just avoid pkg-config when cross compiling. This means only EGL, SDL2 and GTK3 have to be updated since the rest work w/o pkg-config. - EGL is fixed with PR #409 - SDL2 is fixed here and it's trivial. - GTK3 is non-trivial. For this one use pkg-config for native builds since the .pc file is kept up to date automatically. For cross compilation use the provided FindGTK3 which I made by using the sed documented inside the file and updating the dependencies for GTK3. Since I checked each and every single .pc file to make sure they are up to date this should have the same behaviour as pkg-config. Prefer the .pc files for native builds since it does not need to be manually updated and when the native 64bit port gets finished all the cross compile options should be removed which is quite easy since most of the code got moved to the CMAKE_TOOLCHAIN_FILE. Note: Cmake Modules are BSD-3-clause therefore GPL compatible.
2014-12-28 03:15:08 +00:00
if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND AND NOT CMAKE_CROSSCOMPILING)
2014-08-04 16:05:13 +00:00
string(TOLOWER ${lib} lower_lib)
pkg_search_module(${var} QUIET ${lower_lib})
endif()
if(${var}_FOUND)
include_directories(${${var}_INCLUDE_DIRS})
# Make sure include directories for headers found using find_path below
# are re-added when reconfiguring
include_directories(${${var}_INCLUDE})
_internal_message("-- ${lib} found")
2014-08-04 16:05:13 +00:00
else()
find_library(${var}_LIBRARIES ${lib})
2014-08-04 16:05:13 +00:00
if(_arg_list)
find_path(${var}_INCLUDE ${_arg_list})
else()
set(${var}_INCLUDE FALSE)
endif()
if(${var}_LIBRARIES AND ${var}_INCLUDE)
2014-08-04 16:05:13 +00:00
include_directories(${${var}_INCLUDE})
_internal_message("-- ${lib} found")
2014-08-04 16:05:13 +00:00
set(${var}_FOUND 1 CACHE INTERNAL "")
elseif(${var}_LIBRARIES)
_internal_message("-- ${lib} not found (miss include)")
elseif(${var}_INCLUDE)
_internal_message("-- ${lib} not found (miss lib)")
else()
_internal_message("-- ${lib} not found")
2014-08-04 16:05:13 +00:00
endif()
endif()
endmacro()