Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
manual additions for cmake cleanup
svn path=/trunk/yarp2/; revision=7845
  • Loading branch information
paulfitz committed May 5, 2010
1 parent 1079626 commit ea3403b
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 0 deletions.
23 changes: 23 additions & 0 deletions autogen.sh
@@ -0,0 +1,23 @@
#!/bin/sh

echo "Checking for CMake..."
which cmake || {
echo "CMake is required to configure this project."
echo "It is available at http://www.cmake.org"
echo "or a package \"cmake\" on most distributions."
exit 1
}

echo "Creating and entering build directory"
mkdir -p build || {
echo "Failed to create a build directory"
exit 1
}
cd build
cmake .. && {
echo " "
echo "Successful configuration! Compile with:"
echo " cd build"
echo " make"
echo "Report problems to robotcub-hackers@lists.sourceforge.net"
}
2 changes: 2 additions & 0 deletions conf/YarpDevice.cmake
@@ -0,0 +1,2 @@
#MESSAGE(FATAL_ERROR "YarpDevice.cmake has been replaced by YarpPlugin.cmake")
INCLUDE(YarpPlugin)
7 changes: 7 additions & 0 deletions conf/YarpDoc.cmake
@@ -0,0 +1,7 @@
find_program(DOXYGEN_EXE NAMES doxygen)
mark_as_advanced(DOXYGEN_EXE)
if (DOXYGEN_EXE)
configure_file(${CMAKE_SOURCE_DIR}/conf/doxygen/Doxyfile.part.template
${CMAKE_BINARY_DIR}/dox/Doxyfile.part IMMEDIATE)
add_custom_target(dox COMMAND ${DOXYGEN_EXE} ${CMAKE_BINARY_DIR}/dox/Doxyfile.part)
endif ()
21 changes: 21 additions & 0 deletions conf/template/yarp_plugin_carrier.cpp.in
@@ -0,0 +1,21 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
* Copyright: (C) 2009 RobotCub Consortium
* Author: Paul Fitzpatrick
* CopyPolicy: Released under the terms of the GNU GPL v2.0.
*/

#define ENABLE_@YARPDEV_NAME@ (@ENABLE_YARPDEV_NAME@)

#include <yarp/os/impl/Carriers.h>
using namespace yarp::os::impl;

#include <@YARPDEV_INCLUDE@>

void add_@YARPDEV_NAME@() {
#if ENABLE_@YARPDEV_NAME@
Carriers::addCarrierPrototype(new @YARPDEV_TYPE@);
#endif
}

28 changes: 28 additions & 0 deletions conf/template/yarp_plugin_device.cpp.in
@@ -0,0 +1,28 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
* Copyright: (C) 2009 RobotCub Consortium
* Author: Paul Fitzpatrick
* CopyPolicy: Released under the terms of the GNU GPL v2.0.
*/

#define ENABLE_@YARPDEV_NAME@ (@ENABLE_YARPDEV_NAME@)

#include <yarp/os/Network.h>
#include <yarp/dev/Drivers.h>

#include <@YARPDEV_INCLUDE@>

using namespace yarp::os;
using namespace yarp::dev;

void add_@YARPDEV_NAME@() {
#if ENABLE_@YARPDEV_NAME@
DriverCreator *factory =
new DriverCreatorOf<@YARPDEV_TYPE@>("@YARPDEV_NAME@",
"@YARPDEV_WRAPPER@",
"@YARPDEV_TYPE@");
Drivers::factory().add(factory); // hand factory over to YARP
#endif
}

3 changes: 3 additions & 0 deletions conf/template/yarpdev_compat_plugin.cmake
@@ -0,0 +1,3 @@
FIND_PACKAGE(YARP)
LINK_LIBRARIES(@libname@)
SET(@libname@_FOUND TRUE)
44 changes: 44 additions & 0 deletions conf/template/yarpdev_compat_plugin.h
@@ -0,0 +1,44 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include <yarp/os/ConstString.h>
#include <yarp/dev/Drivers.h>
#include <yarp/dev/PolyDriver.h>

namespace yarp {
namespace dev {
class DriverCollection;
}
}

YARP_DECLARE_DEVICES(@libname@);

/**
*
* This is an automatically generated class to initialize a collection
* of drivers.
*
* Instantiate it in your main() function as:
* yarp::dev::DeviceCollection dev;
*
* That's all! You can print the output of the dev.status() method just to
* make sure that all the devices you expect to be present actually are.
*
* To actually instantiate devices, use the yarp::dev::PolyDriver class.
*
*/
class yarp::dev::DriverCollection {
public:
/**
* Add devices from all imported libraries.
*/
DriverCollection() {
YARP_REGISTER_DEVICES(@libname@);
}

/**
* Return a string listing all devices, to allow sanity-checking.
*/
yarp::os::ConstString status() {
return yarp::dev::Drivers::factory().toString();
}
};
28 changes: 28 additions & 0 deletions src/libYARP_init/CMakeLists.txt
@@ -0,0 +1,28 @@
# Copyright: (C) 2009 RobotCub Consortium
# Authors: Paul Fitzpatrick, Giorgio Metta, Lorenzo Natale
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

project(YARP_init)

get_property(YARP_TREE_INCLUDE_DIRS GLOBAL PROPERTY YARP_TREE_INCLUDE_DIRS)
include_directories(${YARP_TREE_INCLUDE_DIRS})

add_library(YARP_init src/CustomInit.cpp)
target_link_libraries(YARP_init YARP_OS)
install(TARGETS YARP_init EXPORT YARP COMPONENT runtime DESTINATION lib)

if (CREATE_OPTIONAL_CARRIERS)
set_property(SOURCE src/CustomInit.cpp APPEND PROPERTY COMPILE_DEFINITIONS
PLUGIN_INIT_FUNCTION=add_yarpcar_devices)
target_link_libraries(YARP_init yarpcar)
endif (CREATE_OPTIONAL_CARRIERS)

if (CREATE_DEVICE_LIBRARY_MODULES)
set_property(SOURCE src/CustomInit.cpp APPEND PROPERTY COMPILE_DEFINITIONS
PLUGIN_INIT_FUNCTION2=add_yarpmod_devices)
target_link_libraries(YARP_init yarpmod)
endif (CREATE_DEVICE_LIBRARY_MODULES)

set_property(GLOBAL APPEND PROPERTY YARP_LIBS YARP_init)

set_property(TARGET YARP_init PROPERTY INCLUDE_DIRS ${YARP_TREE_INCLUDE_DIRS})
54 changes: 54 additions & 0 deletions src/libYARP_init/src/CustomInit.cpp
@@ -0,0 +1,54 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
* Copyright (C) 2010 Paul Fitzpatrick
* CopyPolicy: Released under the terms of the GNU GPL v2.0.
*
*/

#include <stdio.h>
#include <yarp/os/Network.h>

// customizable initialization and shutdown functions

#ifdef PLUGIN_INIT_FUNCTION
extern "C" void PLUGIN_INIT_FUNCTION();
#endif

#ifdef PLUGIN_INIT_FUNCTION2
extern "C" void PLUGIN_INIT_FUNCTION2();
#endif

extern "C" void yarpCustomInit() {
#ifdef PLUGIN_INIT_FUNCTION
PLUGIN_INIT_FUNCTION();
#endif
#ifdef PLUGIN_INIT_FUNCTION2
PLUGIN_INIT_FUNCTION2();
#endif
}

extern "C" int __yarp_is_initialized;

extern "C" void yarpCustomFini() {
}



void yarp::os::Network::init() {
if (__yarp_is_initialized==0) {
initMinimum();
yarpCustomInit();
}
__yarp_is_initialized++;
}


void yarp::os::Network::fini() {
if (__yarp_is_initialized>0) {
yarpCustomFini();
finiMinimum();
__yarp_is_initialized--;
}
}

23 changes: 23 additions & 0 deletions src/tests/CMakeLists.txt
@@ -0,0 +1,23 @@

set(targets OS sig dev)
get_property(YARP_HAS_MATH_LIB GLOBAL PROPERTY YARP_HAS_MATH_LIB)
if (YARP_HAS_MATH_LIB)
set(targets ${targets} math)
endif (YARP_HAS_MATH_LIB)

foreach(test_family ${targets})
file(GLOB harness_code ../libYARP_${test_family}/harness/*.cpp)
GET_PROPERTY(YARP_TREE_INCLUDE_DIRS TARGET YARP_${test_family}
PROPERTY INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${YARP_TREE_INCLUDE_DIRS})
set(EXE harness_${test_family})
string(TOLOWER ${EXE} EXE)
add_executable(${EXE} ${harness_code})
target_link_libraries(${EXE} YARP_init YARP_${test_family})
GET_TARGET_PROPERTY(EXELOC ${EXE} LOCATION)
foreach(test ${harness_code})
get_filename_component(XN ${test} NAME_WE)
add_test("${test_family}::${XN}" ${EXELOC} regression ${XN})
endforeach()
endforeach()

13 changes: 13 additions & 0 deletions src/yarp/CMakeLists.txt
@@ -0,0 +1,13 @@
# Copyright: (C) 2010 RobotCub Consortium
# Authors: Paul Fitzpatrick
# CopyPolicy: Released under the terms of the GNU GPL v2.0.


GET_PROPERTY(YARP_TREE_INCLUDE_DIRS TARGET YARP_OS PROPERTY INCLUDE_DIRS)
INCLUDE_DIRECTORIES(${YARP_TREE_INCLUDE_DIRS})
ADD_EXECUTABLE(yarp yarp.cpp)
TARGET_LINK_LIBRARIES(yarp YARP_init)
ADD_EXECUTABLE(yarpserver yarpserver.cpp)
TARGET_LINK_LIBRARIES(yarpserver YARP_init)

INSTALL(TARGETS yarp yarpserver COMPONENT utilities DESTINATION bin)
13 changes: 13 additions & 0 deletions src/yarphear/CMakeLists.txt
@@ -0,0 +1,13 @@
# Copyright: (C) 2010 RobotCub Consortium
# Authors: Paul Fitzpatrick
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

if (CREATE_DEVICE_LIBRARY_MODULES)

get_property(YARP_TREE_INCLUDE_DIRS TARGET YARP_dev PROPERTY INCLUDE_DIRS)
include_directories(${YARP_TREE_INCLUDE_DIRS})
add_executable(yarphear yarphear.cpp)
target_link_libraries(yarphear yarpmod YARP_init)
install(TARGETS yarphear COMPONENT utilities DESTINATION bin)

endif(CREATE_DEVICE_LIBRARY_MODULES)

0 comments on commit ea3403b

Please sign in to comment.