Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Jun 30, 2020
0 parents commit 71c9f86
Show file tree
Hide file tree
Showing 46 changed files with 3,379 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Files and folders to ignore

# 1. intermediate files
*.o
*.d


# 2. Build files

**/Build/*
!**/Build/CMakeLists.txt
!**/Build/CMAKE_README.txt

3 changes: 3 additions & 0 deletions Build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore

21 changes: 21 additions & 0 deletions CMAKE_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
To generate build files for your platform run in a command terminal:
cd Build
cmake -G GENERATOR ..

Valid generators are:
Windows:
"Visual Studio 12 2013 Win64"
"Visual Studio 14 2015 Win64"
"Visual Studio 15 2017 Win64"
Mac:
"Xcode"
Linux: (see note below)
"Unix Makefiles"

Example: cmake -G "Visual Studio 12 2013 Win64" ..

For Linux Only:
On linux, Debug and Release options are generated by cmake and must be specified like so:
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
or
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..
108 changes: 108 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
cmake_minimum_required(VERSION 3.5.0)
if (NOT DEFINED GUI_BASE_DIR)
if (DEFINED ENV{GUI_BASE_DIR})
set(GUI_BASE_DIR $ENV{GUI_BASE_DIR})
else()
set(GUI_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../plugin-GUI)
endif()
endif()

get_filename_component(PROJECT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
get_filename_component(PLUGIN_NAME ${PROJECT_FOLDER} NAME)

project(OE_PLUGIN_${PLUGIN_NAME})
set(CMAKE_SHARED_LIBRARY_PREFIX "")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX 1)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
endif()

set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
OEPLUGIN
"$<$<PLATFORM_ID:Windows>:JUCE_API=__declspec(dllimport)>"
$<$<PLATFORM_ID:Windows>:_CRT_SECURE_NO_WARNINGS>
$<$<PLATFORM_ID:Linux>:JUCE_DISABLE_NATIVE_FILECHOOSERS=1>
$<$<CONFIG:Debug>:DEBUG=1>
$<$<CONFIG:Debug>:_DEBUG=1>
$<$<CONFIG:Release>:NDEBUG=1>
)


set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Source)
file(GLOB_RECURSE SRC_FILES LIST_DIRECTORIES false "${SOURCE_PATH}/*.cpp" "${SOURCE_PATH}/*.h")
set(GUI_COMMONLIB_DIR ${GUI_BASE_DIR}/installed_libs)

set(CONFIGURATION_FOLDER $<$<CONFIG:Debug>:Debug>$<$<NOT:$<CONFIG:Debug>>:Release>)

list(APPEND CMAKE_PREFIX_PATH ${GUI_COMMONLIB_DIR} ${GUI_COMMONLIB_DIR}/${CONFIGURATION_FOLDER})

if (APPLE)
add_library(${PLUGIN_NAME} MODULE ${SRC_FILES})
else()
add_library(${PLUGIN_NAME} SHARED ${SRC_FILES})
endif()

target_compile_features(${PLUGIN_NAME} PUBLIC cxx_auto_type cxx_generalized_initializers)
target_include_directories(${PLUGIN_NAME} PUBLIC ${GUI_BASE_DIR}/JuceLibraryCode ${GUI_BASE_DIR}/JuceLibraryCode/modules ${GUI_BASE_DIR}/Plugins/Headers ${GUI_COMMONLIB_DIR}/include)

set(GUI_BIN_DIR ${GUI_BASE_DIR}/Build/${CONFIGURATION_FOLDER})

if (NOT CMAKE_LIBRARY_ARCHITECTURE)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_LIBRARY_ARCHITECTURE "x64")
else()
set(CMAKE_LIBRARY_ARCHITECTURE "x86")
endif()
endif()

#Libraries and compiler options
if(MSVC)
target_link_libraries(${PLUGIN_NAME} ${GUI_BIN_DIR}/open-ephys.lib)
target_compile_options(${PLUGIN_NAME} PRIVATE /sdl-)

install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION ${GUI_BIN_DIR}/plugins CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})

set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/windows)
elseif(LINUX)
target_link_libraries(${PLUGIN_NAME} GL X11 Xext Xinerama asound dl freetype pthread rt)
set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS
"-fvisibility=hidden -fPIC -rdynamic -Wl,-rpath,'$ORIGIN/../shared'")
target_compile_options(${PLUGIN_NAME} PRIVATE -fPIC -rdynamic)
target_compile_options(${PLUGIN_NAME} PRIVATE -O3) #enable optimization for linux debug

install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${GUI_BIN_DIR}/plugins)
set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/linux)
elseif(APPLE)
set_target_properties(${PLUGIN_NAME} PROPERTIES BUNDLE TRUE)
set_property(TARGET ${PLUGIN_NAME} APPEND_STRING PROPERTY LINK_FLAGS
"-undefined dynamic_lookup -rpath @loader_path/../../../../shared")

install(TARGETS ${PLUGIN_NAME} DESTINATION $ENV{HOME}/Library/Application\ Support/open-ephys/PlugIns)
set(CMAKE_PREFIX_PATH /opt/local)
endif()

#create filters for vs and xcode

foreach( src_file IN ITEMS ${SRC_FILES})
get_filename_component(src_path "${src_file}" PATH)
file(RELATIVE_PATH src_path_rel "${SOURCE_PATH}" "${src_path}")
string(REPLACE "/" "\\" group_name "${src_path_rel}")
source_group("${group_name}" FILES "${src_file}")
endforeach()

#on windows, copy the dlls when installing
if (MSVC)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs/windows/bin/${CMAKE_LIBRARY_ARCHITECTURE}/ DESTINATION ${GUI_BIN_DIR}/shared CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
elseif(LINUX)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs/linux/bin/ DESTINATION ${GUI_BIN_DIR}/shared)
endif()

#additional libraries, if needed
find_library(ZMQ_LIBRARIES NAMES libzmq-v120-mt-4_0_4 zmq zmq-v120-mt-4_0_4)
find_path(ZMQ_INCLUDE_DIRS zmq.h)

target_include_directories(${PLUGIN_NAME} PUBLIC ${ZMQ_INCLUDE_DIRS})
target_link_libraries(${PLUGIN_NAME} ${ZMQ_LIBRARIES})
target_compile_definitions(${PLUGIN_NAME} PRIVATE ZEROMQ $<$<PLATFORM_ID:Windows>:_SCL_SECURE_NO_WARNINGS>)
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# NetworkEvents plugin
This reposiory contains the following first party plugins developed by Open Ephys that make use of the [0MQ library](http:https://zeromq.org/):

**NetworkEvents**: A plugin that allows controlling basic functions of the GUI such as recording toggle, as well as sending custom events via network using 0MQ. For more information, go to our [wiki](https://open-ephys.atlassian.net/wiki/spaces/OEW/pages/23265310/Network+Events) and find out how to use this plugin.

## Installation
### Installing the 0MQ library
For windows and linux, the required files are already included for the plugin
We have detailed instructions on our wiki on how to install the 0MQ for [macOS](https://open-ephys.atlassian.net/wiki/spaces/OEW/pages/491555/macOS).

### Building the plugins
Building the plugins requires [CMake](https://cmake.org/). Detailed instructions on how to build open ephys plugins with CMake can be found in [our wiki](https://open-ephys.atlassian.net/wiki/spaces/OEW/pages/1259110401/Plugin+CMake+Builds).

Loading

0 comments on commit 71c9f86

Please sign in to comment.