gplugin/gplugin

merge in the osx homebrew fixes
develop
2016-08-21, Gary Kramlich
f36cec1b6b4a
merge in the osx homebrew fixes
--- a/CMakeLists.txt Sun May 15 23:22:42 2016 -0500
+++ b/CMakeLists.txt Sun Aug 21 23:23:29 2016 -0500
@@ -17,6 +17,9 @@
# don't force target names to match a pattern
cmake_policy(SET CMP0037 OLD)
+
+ # enable MACOSX_RPATH
+ cmake_policy(SET CMP0042 NEW)
endif(${CMAKE_VERSION} VERSION_GREATER "3.0.0")
###############################################################################
@@ -156,16 +159,16 @@
)
# check if we're using gcc
-if(CMAKE_COMPILER_IS_GNUCC)
+if(CMAKE_COMPILER_IS_GNUCC OR APPLE)
add_definitions(
-DGPLUGIN_UNUSED=__attribute__\(\(unused\)\)
-ggdb
)
-else(CMAKE_COMPILER_IS_GNUCC)
+else(CMAKE_COMPILER_IS_GNUCC OR APPLE)
add_definitions(
-DGPLUGIN_UNUSED=
)
-endif(CMAKE_COMPILER_IS_GNUCC)
+endif(CMAKE_COMPILER_IS_GNUCC OR APPLE)
include_directories(
${CMAKE_SOURCE_DIR}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/HACKING.OSX Sun Aug 21 23:23:29 2016 -0500
@@ -0,0 +1,28 @@
+There are a few notes about building on OSX.
+
+First off, building has *ONLY* been tested against homebrew. If you want to
+support fink or macports, please let me know and I will merge your pull
+request.
+
+Lua
+===
+
+For the Lua loader to work, you need to install lgi from luarocks either
+systemwide or to a virtual environment created by LuaDist, vert, or something
+along those lines.
+
+When you're building lgi against homebrew you'll have to set the
+PKG_CONFIG_PATH environment variable since homebrew does not install libffi
+systemwide. This is easily done via:
+
+ export PKG_CONFIG_PATH=$(brew --prefix libffi)/lib/pkgconfig
+
+and then running "luarocks install lgi"
+
+PYTHON
+======
+
+If you're using homebrew, you need to install pygobject3 with
+
+ brew install pygobject3 --with-python3
+
--- a/gplugin/CMakeLists.txt Sun May 15 23:22:42 2016 -0500
+++ b/gplugin/CMakeLists.txt Sun Aug 21 23:23:29 2016 -0500
@@ -222,30 +222,25 @@
# GObject Introspection
###############################################################################
if(BUILD_GIR)
- if(APPLE)
- message("The GObject Introspection build always fails on OS X, "
- "skipping")
- else(APPLE)
- include(GObjectIntrospection)
+ include(GObjectIntrospection)
- set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_BINARY_DIR}")
+ set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_BINARY_DIR}")
- gobject_introspection(
- FILENAME GPlugin-${GPLUGIN_MAJOR_VERSION}.0.gir
- PACKAGES glib-2.0 gmodule-2.0 gobject-2.0
- LIBRARY gplugin
- QUIET
- SCANNER_ARGS --add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
- --include=GModule-2.0 --include=GObject-2.0
- COMPILER_ARGS --includedir=${CMAKE_CURRENT_SOURCE_DIR}
- SYMBOL_PREFIXES gplugin
- SOURCES ${GPLUGIN_SOURCES} ${GPLUGIN_HEADERS}
- BUILT_SOURCES ${GPLUGIN_PUBLIC_BUILT_SOURCES}
- ${GPLUGIN_PUBLIC_BUILT_HEADERS}
- )
- # For loader plugin tests dependencies
- set(GPLUGIN_GIR_TARGETS ${GPLUGIN_GIR_TARGETS} PARENT_SCOPE)
- endif(APPLE)
+ gobject_introspection(
+ FILENAME GPlugin-${GPLUGIN_MAJOR_VERSION}.${GPLUGIN_MINOR_VERSION}.gir
+ PACKAGES glib-2.0 gmodule-2.0 gobject-2.0
+ LIBRARY gplugin
+ QUIET
+ SCANNER_ARGS --add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
+ --include=GModule-2.0 --include=GObject-2.0
+ COMPILER_ARGS --includedir=${CMAKE_CURRENT_SOURCE_DIR}
+ SYMBOL_PREFIXES gplugin
+ SOURCES ${GPLUGIN_SOURCES} ${GPLUGIN_HEADERS}
+ BUILT_SOURCES ${GPLUGIN_PUBLIC_BUILT_SOURCES}
+ ${GPLUGIN_PUBLIC_BUILT_HEADERS}
+ )
+ # For loader plugin tests dependencies
+ set(GPLUGIN_GIR_TARGETS ${GPLUGIN_GIR_TARGETS} PARENT_SCOPE)
endif(BUILD_GIR)
###############################################################################
--- a/gplugin/tests/CMakeLists.txt Sun May 15 23:22:42 2016 -0500
+++ b/gplugin/tests/CMakeLists.txt Sun Aug 21 23:23:29 2016 -0500
@@ -3,7 +3,15 @@
###############################################################################
macro(add_test_plugin plugin)
add_library(${plugin} MODULE ${plugin}.c)
- set_target_properties(${plugin} PROPERTIES PREFIX "")
+
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(LINK_FLAGS "-undefined dynamic_lookup")
+ endif(CMAKE_C_COMPILER_ID MATCHES "Clang")
+
+ set_target_properties(${plugin} PROPERTIES
+ PREFIX ""
+ LINK_FLAGS "${LINK_FLAGS}"
+ )
target_link_libraries(${plugin} ${GLIB_LIBRARIES} gplugin)
endmacro(add_test_plugin)
--- a/lua/CMakeLists.txt Sun May 15 23:22:42 2016 -0500
+++ b/lua/CMakeLists.txt Sun Aug 21 23:23:29 2016 -0500
@@ -33,6 +33,8 @@
include_directories(${LUA_INCLUDE_DIRS})
+ link_directories(${LUA_LIBRARY_DIRS})
+
message(STATUS "checking for lua module 'lgi'")
# compile our lua-lgi test program
@@ -42,6 +44,7 @@
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=${LUA_INCLUDE_DIRS}
-DLINK_LIBRARIES:STRING=${LUA_LIBRARIES}
+ -DLINK_DIRECTORIES:STRING=${LUA_LIBRARY_DIRS}
OUTPUT_VARIABLE OUTPUT
COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/gplugin-lua-test-lgi
)
--- a/lua/gplugin-lua-test-lgi.c Sun May 15 23:22:42 2016 -0500
+++ b/lua/gplugin-lua-test-lgi.c Sun Aug 21 23:23:29 2016 -0500
@@ -16,18 +16,46 @@
*/
#include <stdio.h>
+#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
+static void
+_add_require_path(lua_State *L, const char *path) {
+ const char *pkg_path = NULL;
+ char buff[255];
+
+ lua_getglobal(L, "package");
+ lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1)
+ pkg_path = lua_tostring(L, -1); // grab path string from top of stack
+
+ memset(buff, 0, sizeof(buff));
+ snprintf(buff, sizeof(buff), "%s;%s", pkg_path, path);
+
+ lua_pop(L, 1); // pop off the path field
+ lua_pushstring(L, buff); // push the new one
+ lua_setfield(L, -2, "path"); // set the field "path" in table at -2 with value at top of stack
+ lua_pop( L, 1 ); // get rid of package table from top of stack
+}
+
int
main(int argc, char *argv[]) {
- lua_State *L = luaL_newstate();
+ lua_State *L = NULL;
int ret = 0;
+ L = luaL_newstate();
+ if(L == NULL) {
+ return 134;
+ }
+
luaL_openlibs(L);
+ /* add some additional paths to package.path */
+ //_add_require_path(L, "/usr/local/lib/luarocks/rocks");
+
+ /* now try to do the require */
lua_getglobal(L, "require");
lua_pushstring(L, "lgi");
--- a/python/CMakeLists.txt Sun May 15 23:22:42 2016 -0500
+++ b/python/CMakeLists.txt Sun Aug 21 23:23:29 2016 -0500
@@ -32,6 +32,8 @@
${PYGOBJECT_INCLUDE_DIRS}
)
+ link_directories(${PYTHON3_LIBRARY_DIRS})
+
message(STATUS "checking if pygobject works with python3")
set(GPLUGIN_PYTHON_TEST_PYGOBJECT_INCLUDES)