Finally I have build a CMakeList.txt file to easy compile my plugin out of tree.
First, you must create a folder where compile VLC and create a script with this content: (configure-env-osx.sh in my case)
Code: Select all
#!/bin/sh
function log () { echo $'\e[1;32m'$1$'\e[00m' ; }
function errorLog () { echo $'\e[1;31m'$1$'\e[00m' ; }
# MacPorts creates conflits when compile VLC, inform to the user
if [ -d "/opt" ]; then
errorLog 'It is not possible to compile VLC with MacPorts installed'
errorLog 'Please, rename your "/opt" folder to "/_opt" and execute this script again'
exit 1
fi
# Clone the VLC source code
log 'Cloning VLC source code'
git clone git://git.videolan.org/vlc.git
# Compile VLC <http://wiki.videolan.org/OSXCompile>
log 'Compiling VLC. Consider take a cup of coffe...'
export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
export CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
export OBJC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
cd vlc
mkdir build
cd build
../extras/package/macosx/build.sh && \
make VLC-dev.app && \
log 'VLC devel environment correctly configured. Remember to restore your MacPorts folder if necessary'
This script clones and compiles the VLC source code in OS X Lion and Mountain Lion without problems.
Now create a "src" folder where you can put your source code, for testing you can try this:
viewtopic.php?f=32&t=109526#p371601
In the "src" folder create a "CMakeLists.txt" file with this content:
Code: Select all
project(TestPlugin)
cmake_minimum_required(VERSION 2.6)
SET(CMAKE_SYSTEM_NAME Darwin)
SET(CMAKE_OSX_ARCHITECTURES x86_64) # To build as universal binary: SET(CMAKE_OSX_ARCHITECTURES i386;x86_64)
# Target
ADD_LIBRARY(stream_filter_proton_plugin SHARED VLCPlugin.cpp) # Add here your source code
# Link with libvlccore using pkg-config
SET(ENV{PKG_CONFIG_PATH} ${CMAKE_SOURCE_DIR}/../vlc/build/src)
EXECUTE_PROCESS(COMMAND pkg-config --cflags vlc-plugin OUTPUT_VARIABLE VLC_PLUGIN_CFLAGS ERROR_VARIABLE VLC_PLUGIN_CFLAGS_STATUS)
EXECUTE_PROCESS(COMMAND pkg-config --libs vlc-plugin OUTPUT_VARIABLE VLC_PLUGIN_LIBS ERROR_VARIABLE VLC_PLUGIN_LIBS_STATUS)
IF(NOT ${VLC_PLUGIN_CFLAGS_STATUS} MATCHES 0)
MESSAGE(FATAL_ERROR "pkg-config --cflags error: ${VLC_PLUGIN_CFLAGS_STATUS}")
ENDIF(NOT ${VLC_PLUGIN_CFLAGS_STATUS} MATCHES 0)
IF(NOT ${VLC_PLUGIN_LIBS_STATUS} MATCHES 0)
MESSAGE(FATAL_ERROR "pkg-config --cflags error: ${VLC_PLUGIN_LIBS_STATUS}")
ENDIF(NOT ${VLC_PLUGIN_LIBS_STATUS} MATCHES 0)
STRING(REGEX REPLACE "\n" "" VLC_PLUGIN_CFLAGS "${VLC_PLUGIN_CFLAGS}")
STRING(REGEX REPLACE "\n" "" VLC_PLUGIN_LIBS "${VLC_PLUGIN_LIBS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VLC_PLUGIN_CFLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VLC_PLUGIN_CFLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} ${VLC_PLUGIN_LIBS})
# Installation
ADD_CUSTOM_COMMAND(TARGET stream_filter_proton_plugin COMMAND install_name_tool ARGS -change @loader_path/lib/libvlccore.5.dylib @loader_path/../lib/libvlccore.5.dylib libstream_filter_proton_plugin.dylib)
INSTALL(TARGETS stream_filter_proton_plugin DESTINATION ${CMAKE_SOURCE_DIR}/../vlc/build/VLC.app/Contents/MacOS/plugins)
And now cd to src/build and execute:
Code: Select all
$ cmake .. && make && make install && ../../vlc/build/VLC.app/Contents/MacOS/VLC
To test your plugin. Thats all.