Use pkg-config where possible instead of hard-coding or library-specific programs
Accepted by: Itms, wraitii Previously tested by: andy5995 Fixes: #5157 Refs: D1582 Differential Revision: https://code.wildfiregames.com/D1611 This was SVN commit r22302.
This commit is contained in:
parent
220449ea9a
commit
9ea68317ad
@ -262,39 +262,31 @@ extern_lib_defs = {
|
||||
compile_settings = function()
|
||||
if os.istarget("windows") then
|
||||
add_default_include_paths("gloox")
|
||||
elseif os.istarget("macosx") then
|
||||
-- Support GLOOX_CONFIG for overriding the default PATH-based gloox-config
|
||||
gloox_config_path = os.getenv("GLOOX_CONFIG")
|
||||
if not gloox_config_path then
|
||||
gloox_config_path = "gloox-config"
|
||||
end
|
||||
pkgconfig.add_includes(nil, gloox_config_path.." --cflags")
|
||||
else
|
||||
-- Support GLOOX_CONFIG for overriding the default (pkg-config --cflags gloox)
|
||||
-- i.e. on OSX where it gets set in update-workspaces.sh
|
||||
pkgconfig.add_includes("gloox", os.getenv("GLOOX_CONFIG"))
|
||||
end
|
||||
end,
|
||||
link_settings = function()
|
||||
if os.istarget("windows") then
|
||||
add_default_lib_paths("gloox")
|
||||
end
|
||||
if os.istarget("macosx") then
|
||||
gloox_config_path = os.getenv("GLOOX_CONFIG")
|
||||
if not gloox_config_path then
|
||||
gloox_config_path = "gloox-config"
|
||||
end
|
||||
pkgconfig.add_links(nil, gloox_config_path.." --libs")
|
||||
|
||||
-- Manually add gnutls dependencies, those are not present in gloox's pkg-config
|
||||
add_default_lib_paths("nettle")
|
||||
add_default_lib_paths("gmp")
|
||||
add_default_links({
|
||||
osx_names = { "nettle", "hogweed", "gmp" },
|
||||
})
|
||||
else
|
||||
-- TODO: consider using pkg-config on non-Windows (for compile_settings too)
|
||||
add_default_links({
|
||||
win_names = { "gloox-1.0" },
|
||||
unix_names = { "gloox" },
|
||||
no_delayload = 1,
|
||||
})
|
||||
else
|
||||
pkgconfig.add_links("gloox", os.getenv("GLOOX_CONFIG"))
|
||||
|
||||
if os.istarget("macosx") then
|
||||
-- Manually add gnutls dependencies, those are not present in gloox's pkg-config
|
||||
add_default_lib_paths("nettle")
|
||||
add_default_lib_paths("gmp")
|
||||
add_default_links({
|
||||
osx_names = { "nettle", "hogweed", "gmp" },
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -338,32 +330,22 @@ extern_lib_defs = {
|
||||
compile_settings = function()
|
||||
if os.istarget("windows") then
|
||||
add_default_include_paths("icu")
|
||||
elseif os.istarget("macosx") then
|
||||
-- Support ICU_CONFIG for overriding the default PATH-based icu-config
|
||||
icu_config_path = os.getenv("ICU_CONFIG")
|
||||
if not icu_config_path then
|
||||
icu_config_path = "icu-config"
|
||||
end
|
||||
pkgconfig.add_includes(nil, icu_config_path.." --cppflags")
|
||||
else
|
||||
-- Support ICU_CONFIG for overriding the default (pkg-config --cflags icu-i18n)
|
||||
-- i.e. on OSX where it gets set in update-workspaces.sh
|
||||
pkgconfig.add_includes("icu-i18n", os.getenv("ICU_CONFIG"), "--cppflags")
|
||||
end
|
||||
end,
|
||||
link_settings = function()
|
||||
if os.istarget("windows") then
|
||||
add_default_lib_paths("icu")
|
||||
end
|
||||
if os.istarget("macosx") then
|
||||
icu_config_path = os.getenv("ICU_CONFIG")
|
||||
if not icu_config_path then
|
||||
icu_config_path = "gloox-config"
|
||||
end
|
||||
pkgconfig.add_links(nil, icu_config_path.." --ldflags-searchpath --ldflags-libsonly --ldflags-system")
|
||||
else
|
||||
add_default_links({
|
||||
win_names = { "icuuc", "icuin" },
|
||||
unix_names = { "icui18n", "icuuc" },
|
||||
dbg_suffix = "",
|
||||
no_delayload = 1,
|
||||
})
|
||||
else
|
||||
pkgconfig.add_links("icu-i18n", os.getenv("ICU_CONFIG"), "--ldflags-searchpath --ldflags-libsonly --ldflags-system")
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -427,20 +409,15 @@ extern_lib_defs = {
|
||||
compile_settings = function()
|
||||
if os.istarget("windows") then
|
||||
add_default_include_paths("libxml2")
|
||||
elseif os.istarget("macosx") then
|
||||
-- Support XML2_CONFIG for overriding for the default PATH-based xml2-config
|
||||
xml2_config_path = os.getenv("XML2_CONFIG")
|
||||
if not xml2_config_path then
|
||||
xml2_config_path = "xml2-config"
|
||||
end
|
||||
|
||||
-- use xml2-config instead of pkg-config on OS X
|
||||
pkgconfig.add_includes(nil, xml2_config_path.." --cflags")
|
||||
else
|
||||
-- Support XML2_CONFIG for overriding the default (pkg-config --cflags libxml-2.0)
|
||||
-- i.e. on OSX where it gets set in update-workspaces.sh
|
||||
pkgconfig.add_includes("libxml-2.0", os.getenv("XML2_CONFIG"))
|
||||
end
|
||||
if os.istarget("macosx") then
|
||||
-- libxml2 needs _REENTRANT or __MT__ for thread support;
|
||||
-- OS X doesn't get either set by default, so do it manually
|
||||
defines { "_REENTRANT" }
|
||||
else
|
||||
pkgconfig.add_includes("libxml-2.0")
|
||||
end
|
||||
end,
|
||||
link_settings = function()
|
||||
@ -451,14 +428,8 @@ extern_lib_defs = {
|
||||
filter "Release"
|
||||
links { "libxml2" }
|
||||
filter { }
|
||||
elseif os.istarget("macosx") then
|
||||
xml2_config_path = os.getenv("XML2_CONFIG")
|
||||
if not xml2_config_path then
|
||||
xml2_config_path = "xml2-config"
|
||||
end
|
||||
pkgconfig.add_links(nil, xml2_config_path.." --libs")
|
||||
else
|
||||
pkgconfig.add_links("libxml-2.0")
|
||||
pkgconfig.add_links("libxml-2.0", os.getenv("XML2_CONFIG"))
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -549,24 +520,14 @@ extern_lib_defs = {
|
||||
elseif not _OPTIONS["android"] then
|
||||
-- Support SDL2_CONFIG for overriding the default (pkg-config sdl2)
|
||||
-- i.e. on OSX where it gets set in update-workspaces.sh
|
||||
sdl_config_path = os.getenv("SDL2_CONFIG")
|
||||
if sdl_config_path then
|
||||
pkgconfig.add_includes(nil, sdl_config_path.." --cflags")
|
||||
else
|
||||
pkgconfig.add_includes("sdl2")
|
||||
end
|
||||
pkgconfig.add_includes("sdl2", os.getenv("SDL2_CONFIG"))
|
||||
end
|
||||
end,
|
||||
link_settings = function()
|
||||
if os.istarget("windows") then
|
||||
add_default_lib_paths("sdl2")
|
||||
elseif not _OPTIONS["android"] then
|
||||
sdl_config_path = os.getenv("SDL2_CONFIG")
|
||||
if sdl_config_path then
|
||||
pkgconfig.add_links(nil, sdl_config_path.." --libs")
|
||||
else
|
||||
pkgconfig.add_links("sdl2")
|
||||
end
|
||||
pkgconfig.add_links("sdl2", os.getenv("SDL2_CONFIG"))
|
||||
end
|
||||
end,
|
||||
},
|
||||
@ -670,34 +631,31 @@ extern_lib_defs = {
|
||||
includedirs { libraries_dir.."wxwidgets/include/msvc" }
|
||||
add_default_include_paths("wxwidgets")
|
||||
else
|
||||
|
||||
-- Support WX_CONFIG for overriding for the default PATH-based wx-config
|
||||
wx_config_path = os.getenv("WX_CONFIG")
|
||||
if not wx_config_path then
|
||||
wx_config_path = "wx-config"
|
||||
end
|
||||
|
||||
pkgconfig.add_includes(nil, wx_config_path.." --unicode=yes --cxxflags")
|
||||
-- wxwidgets does not come with a definition file for pkg-config,
|
||||
-- so we have to use wxwidgets' own config tool
|
||||
wx_config_path = os.getenv("WX_CONFIG") or "wx-config"
|
||||
pkgconfig.add_includes(nil, wx_config_path, "--unicode=yes --cxxflags")
|
||||
end
|
||||
end,
|
||||
link_settings = function()
|
||||
if os.istarget("windows") then
|
||||
libdirs { libraries_dir.."wxwidgets/lib/vc_lib" }
|
||||
else
|
||||
wx_config_path = os.getenv("WX_CONFIG")
|
||||
if not wx_config_path then
|
||||
wx_config_path = "wx-config"
|
||||
end
|
||||
pkgconfig.add_links(nil, wx_config_path.." --unicode=yes --libs std,gl")
|
||||
wx_config_path = os.getenv("WX_CONFIG") or "wx-config"
|
||||
pkgconfig.add_links(nil, wx_config_path, "--unicode=yes --libs std,gl")
|
||||
end
|
||||
end,
|
||||
},
|
||||
x11 = {
|
||||
compile_settings = function()
|
||||
if not os.istarget("windows") and not os.istarget("macosx") then
|
||||
pkgconfig.add_includes("x11")
|
||||
end
|
||||
end,
|
||||
link_settings = function()
|
||||
add_default_links({
|
||||
win_names = { },
|
||||
unix_names = { "X11" },
|
||||
})
|
||||
if not os.istarget("windows") and not os.istarget("macosx") then
|
||||
pkgconfig.add_links("x11")
|
||||
end
|
||||
end,
|
||||
},
|
||||
xcursor = {
|
||||
|
@ -1,16 +1,20 @@
|
||||
local m = {}
|
||||
m._VERSION = "1.0.0-dev"
|
||||
m._VERSION = "1.1.0-dev"
|
||||
|
||||
local function os_capture(cmd)
|
||||
return io.popen(cmd, 'r'):read('*a'):gsub("\n", " ")
|
||||
end
|
||||
|
||||
function m.add_includes(lib, alternative_cmd)
|
||||
function m.add_includes(lib, alternative_cmd, alternative_flags)
|
||||
local result
|
||||
if not alternative_cmd then
|
||||
result = os_capture("pkg-config --cflags "..lib)
|
||||
else
|
||||
result = os_capture(alternative_cmd)
|
||||
if not alternative_flags then
|
||||
result = os_capture(alternative_cmd.." --cflags")
|
||||
else
|
||||
result = os_capture(alternative_cmd.." "..alternative_flags)
|
||||
end
|
||||
end
|
||||
|
||||
-- Small trick: delete the space after -include so that we can detect
|
||||
@ -35,12 +39,16 @@ function m.add_includes(lib, alternative_cmd)
|
||||
buildoptions(options)
|
||||
end
|
||||
|
||||
function m.add_links(lib, alternative_cmd)
|
||||
function m.add_links(lib, alternative_cmd, alternative_flags)
|
||||
local result
|
||||
if not alternative_cmd then
|
||||
result = os_capture("pkg-config --libs "..lib)
|
||||
else
|
||||
result = os_capture(alternative_cmd)
|
||||
if not alternative_flags then
|
||||
result = os_capture(alternative_cmd.." --libs")
|
||||
else
|
||||
result = os_capture(alternative_cmd.." "..alternative_flags)
|
||||
end
|
||||
end
|
||||
|
||||
-- On OSX, wx-config outputs "-framework foo" instead of "-Wl,-framework,foo"
|
||||
|
@ -367,23 +367,6 @@ function project_set_build_flags()
|
||||
end
|
||||
end
|
||||
|
||||
-- add X11 includes paths after all the others so they don't conflict with
|
||||
-- bundled libs
|
||||
function project_add_x11_dirs()
|
||||
if not os.istarget("windows") and not os.istarget("macosx") then
|
||||
-- X11 includes may be installed in one of a gadzillion of five places
|
||||
-- Famous last words: "You can't include too much! ;-)"
|
||||
sysincludedirs {
|
||||
"/usr/X11R6/include/X11",
|
||||
"/usr/X11R6/include",
|
||||
"/usr/local/include/X11",
|
||||
"/usr/local/include",
|
||||
"/usr/include/X11"
|
||||
}
|
||||
libdirs { "/usr/X11R6/lib" }
|
||||
end
|
||||
end
|
||||
|
||||
-- create a project and set the attributes that are common to all projects.
|
||||
function project_create(project_name, target_type)
|
||||
|
||||
@ -528,7 +511,6 @@ function setup_static_lib_project (project_name, rel_source_dirs, extern_libs, e
|
||||
project_create(project_name, target_type)
|
||||
project_add_contents(source_root, rel_source_dirs, {}, extra_params)
|
||||
project_add_extern_libs(extern_libs, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
if not extra_params["no_default_link"] then
|
||||
table.insert(static_lib_names, project_name)
|
||||
@ -553,7 +535,6 @@ function setup_shared_lib_project (project_name, rel_source_dirs, extern_libs, e
|
||||
project_create(project_name, target_type)
|
||||
project_add_contents(source_root, rel_source_dirs, {}, extra_params)
|
||||
project_add_extern_libs(extern_libs, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
if not extra_params["no_default_link"] then
|
||||
table.insert(static_lib_names, project_name)
|
||||
@ -965,7 +946,6 @@ function setup_main_exe ()
|
||||
}
|
||||
project_add_contents(source_root, {}, {}, extra_params)
|
||||
project_add_extern_libs(used_extern_libs, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
dependson { "Collada" }
|
||||
|
||||
@ -1063,7 +1043,6 @@ function setup_atlas_project(project_name, target_type, rel_source_dirs, rel_inc
|
||||
|
||||
project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params)
|
||||
project_add_extern_libs(extern_libs, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
-- Platform Specifics
|
||||
if os.istarget("windows") then
|
||||
@ -1186,7 +1165,6 @@ function setup_atlas_frontend_project (project_name)
|
||||
|
||||
local target_type = get_main_project_target_type()
|
||||
project_create(project_name, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
local source_root = rootdir.."/source/tools/atlas/AtlasFrontends/"
|
||||
files { source_root..project_name..".cpp" }
|
||||
@ -1226,7 +1204,6 @@ function setup_collada_project(project_name, target_type, rel_source_dirs, rel_i
|
||||
extra_params["pch_dir"] = source_root
|
||||
project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params)
|
||||
project_add_extern_libs(extern_libs, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
-- Platform Specifics
|
||||
if os.istarget("windows") then
|
||||
@ -1370,7 +1347,6 @@ function setup_tests()
|
||||
|
||||
project_add_contents(source_root, {}, {}, extra_params)
|
||||
project_add_extern_libs(used_extern_libs, target_type)
|
||||
project_add_x11_dirs()
|
||||
|
||||
dependson { "Collada" }
|
||||
|
||||
|
@ -41,10 +41,10 @@
|
||||
|
||||
#define Cursor X__Cursor
|
||||
|
||||
#include <Xlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <Xatom.h>
|
||||
#include <Xcursor/Xcursor.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
Loading…
Reference in New Issue
Block a user