Commit caa9977d authored by ledig's avatar ledig

[FIX] dll and compile works for MSVC now

parent ade270b5
......@@ -145,12 +145,21 @@ ADD_SUBDIRECTORY( modules )
#-------------------------------------------------------------------------------------------------------------
# Writes information about the revision of the current code to the file version.h which then gets included by OpenWalnut.cpp
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template '\#define W_VERSION \"{node|short} {rev} {branches} {tags}\"' > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template '\#define W_VERSION \"{node|short} {rev} {branches} {tags}\"' > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
ELSE()
add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
COMMAND hg parents --template "\"#define W_VERSION \"\"{node|short} {rev} {branches} {tags}\"\"\"" > ${PROJECT_SOURCE_DIR}/version.h
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Creating version.h"
)
ENDIF()
# finally, build walnut
ADD_EXECUTABLE( walnut OpenWalnut.cpp version.h )
......
......@@ -7,14 +7,16 @@ ADD_SUBDIRECTORY( datastructures )
ADD_SUBDIRECTORY( constraints )
ADD_SUBDIRECTORY( math )
ADD_LIBRARY( OWcommon ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
ADD_LIBRARY( OWcommon SHARED ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
TARGET_LINK_LIBRARIES( OWcommon ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines.
add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
ENDIF()
# Unit tests
IF( OW_COMPILE_TESTS )
......
......@@ -28,6 +28,7 @@
#include <string>
#include "WException.h"
#include "WExport_CommonDLL.h"
/**
* Implements assertion logic.
......@@ -40,7 +41,7 @@
* \param line The line in the file.
* \param msg An optional message.
*/
void wAssertFailed( std::string const& expression, std::string const& file, std::size_t line, std::string const& msg );
void EXPORT_OWCOMMON_DLL wAssertFailed( std::string const& expression, std::string const& file, std::size_t line, std::string const& msg );
//! the actual assertion macro
#define WAssert( e, msg ) ( ( e ) ? ( ( void )0 ) : ( wAssertFailed( #e, __FILE__, __LINE__, msg ) ) )
......
......@@ -31,10 +31,12 @@
#include <string>
#include <vector>
#include "WExport_CommonDLL.h"
/**
* Represents a RGBA Color
*/
class WColor
class EXPORT_OWCOMMON_DLL WColor
{
public:
......
......@@ -29,11 +29,13 @@
#include <boost/signals2/signal.hpp>
#include <boost/thread.hpp>
#include "WExport_CommonDLL.h"
/**
* Class to encapsulate boost::condition_variable_any. You may use it to efficiently wait for events (a condition comes true). It
* is a very simple implementation. It might be extended easily. Timed wait functions and so on.
*/
class WCondition
class EXPORT_OWCOMMON_DLL WCondition // NOLINT
{
friend class WCondition_test;
public:
......
......@@ -28,6 +28,7 @@
#include <boost/thread.hpp>
#include "WCondition.h"
#include "WExport_CommonDLL.h"
/**
* Implements a WCondition, but can be fired only ONCE. This is useful if you want to have a thread waiting for a condition but
......@@ -36,7 +37,7 @@
* on a mutex. All waiting threads try to get a read lock which is not possible as long it is write-locked. The notify method
* releases the write lock and all waiting threads can continue.
*/
class WConditionOneShot: public WCondition
class EXPORT_OWCOMMON_DLL WConditionOneShot: public WCondition
{
friend class WConditionOneShot_test;
public:
......
......@@ -32,13 +32,14 @@
#include <boost/thread.hpp>
#include "WCondition.h"
#include "WExport_CommonDLL.h"
/**
* Class allowing multiple conditions to be used for one waiting cycle. Since wait() can not be used for waiting on multiple
* conditions, this class can encapsulate multiple conditions and offer a wait() command to wait for one of them to change its
* state. Please not that this class can also be used as condition.
*/
class WConditionSet: public WCondition
class EXPORT_OWCOMMON_DLL WConditionSet: public WCondition
{
friend class WConditionSetTest;
public:
......
......@@ -31,11 +31,12 @@
#include <sstream>
#include "WTerminalColor.h"
#include "WExport_CommonDLL.h"
/**
* Basic exception handler.
*/
class WException: public std::exception
class EXPORT_OWCOMMON_DLL WException: public std::exception
{
/**
* Only UnitTests are allowed to be a friend of this class.
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WEXPORT_COMMONDLL_H
#define WEXPORT_COMMONDLL_H
#ifdef _MSC_VER
#pragma warning( disable: 4251 )
#ifdef OWcommon_EXPORTS
#define EXPORT_OWCOMMON_DLL __declspec( dllexport )
#else
#define EXPORT_OWCOMMON_DLL __declspec( dllimport )
#endif
#else
#define EXPORT_OWCOMMON_DLL
#endif // _MSC_VER
#endif // WEXPORT_COMMONDLL_H
......@@ -29,6 +29,7 @@
#include <boost/signals2/signal.hpp>
#include "WFlag.h"
#include "WExport_CommonDLL.h"
/**
* This class helps especially container module programmers to easily synchronize the value of one flag with several other
......@@ -49,7 +50,7 @@
* \param T the encapsulated type inside the flag. I.e. for WFlag< int32_t > use T=int32_t
*/
template < typename T >
class WFlagForwarder
class EXPORT_OWCOMMON_DLL WFlagForwarder // NOLINT
{
public:
......
......@@ -27,11 +27,13 @@
#include <utility>
#include "WExport_CommonDLL.h"
/**
* Container which associate values with (uniform width) bins (aka intervals or buckets). This class implements the abstract interface and
* therefore builds the base class for all histogram classes. The interface also allows programming histogram of different bucket sizes.
*/
class WHistogram
class EXPORT_OWCOMMON_DLL WHistogram // NOLINT
{
public:
/**
......
......@@ -33,6 +33,8 @@
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "WExport_CommonDLL.h"
class WItemSelector;
/**
......@@ -42,7 +44,7 @@ class WItemSelector;
* not implement any function that might change the item list. The would cause odd behaviour of all the WItemSelector instances. Items can only
* be added until the first Selector instance is created.
*/
class WItemSelection: public boost::enable_shared_from_this< WItemSelection >
class EXPORT_OWCOMMON_DLL WItemSelection: public boost::enable_shared_from_this< WItemSelection >
{
public:
/**
......
......@@ -33,6 +33,7 @@
#include <boost/shared_ptr.hpp>
#include "WItemSelection.h"
#include "WExport_CommonDLL.h"
/**
* This class represents a subset of a WItemSelection. It is a class for managing selections. The class is kept very restrictive. The selection
......@@ -46,7 +47,7 @@
* \note the protected constructor avoids instance creation of classes not the WItemSelection. This is restrictive but needed. Nobody can create
* instances of it, changing the underlying WItemSelection and using it as selector for another ItemSelection instance.
*/
class WItemSelector
class EXPORT_OWCOMMON_DLL WItemSelector // NOLINT
{
friend class WItemSelection;
public:
......
......@@ -28,6 +28,7 @@
#include <string>
#include "WTerminalColor.h"
#include "WExport_CommonDLL.h"
/**
* Various log levels, to distinguish output on its level.
......@@ -44,7 +45,7 @@ LogLevel;
/**
* Represents a simple log message with some attributes.
*/
class WLogEntry
class EXPORT_OWCOMMON_DLL WLogEntry // NOLINT
{
public:
......
......@@ -33,6 +33,7 @@
/**
* Used for program wide access to the logger.
*/
WLogger* logger = NULL;
WLogger::WLogger( std::string fileName, LogLevel level ):
......
......@@ -38,11 +38,12 @@
#include "WLogEntry.h"
#include "WStringUtils.h"
#include "WThreadedRunner.h"
#include "WExport_CommonDLL.h"
/**
* Does actual logging of WLogEntries down to stdout or something similar.
*/
class WLogger: public WThreadedRunner
class EXPORT_OWCOMMON_DLL WLogger: public WThreadedRunner
{
public:
/**
......
......@@ -30,11 +30,12 @@
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
#include "WExport_CommonDLL.h"
/**
* Singleton class helping to find files and paths. It is a useful to to search for resources and the central place to "hardcode" relative paths.
* It contains global paths only. Modules have their OWN local paths.
*/
class WPathHelper
class EXPORT_OWCOMMON_DLL WPathHelper // NOLINT
{
public:
......
......@@ -36,10 +36,11 @@
#include "WProperties.h"
#include "WLogger.h"
#include "WExport_CommonDLL.h"
/**
* Fetches and caches preferences set in file.
*/
class WPreferences
class EXPORT_OWCOMMON_DLL WPreferences
{
public:
/**
......
......@@ -30,6 +30,7 @@
#include <boost/shared_ptr.hpp>
#include "WExport_CommonDLL.h"
/**
* Class managing progress inside of modules. It interacts with the abstract WGUI class to present those information to the user.
* At the same time, it also is a simple tree structure, allowing the programmer to arrange complex sub progress. This is
......@@ -37,7 +38,7 @@
*
* \see WGUI
*/
class WProgress
class EXPORT_OWCOMMON_DLL WProgress // NOLINT
{
friend class WProgressTest;
public:
......
......@@ -31,12 +31,13 @@
#include <boost/thread.hpp>
#include "WProgress.h"
#include "WExport_CommonDLL.h"
/**
* Base class for all kinds of progress combinations. You might want to derive from this class to implement some special progress
* combination.
*/
class WProgressCombiner: public WProgress
class EXPORT_OWCOMMON_DLL WProgressCombiner: public WProgress
{
friend class WProgressCombinerTest;
public:
......
......@@ -28,11 +28,12 @@
#include <ostream>
#include <string>
#include "WExport_CommonDLL.h"
/**
* A base class for all parts of OpenWalnut which can be serialized to a project file. It is used by WProjectFile to actually parse the file line
* by line. Derive from this class if you write your own parser and use it to fill your internal data structures.
*/
class WProjectFileIO
class EXPORT_OWCOMMON_DLL WProjectFileIO // NOLINT
{
public:
......
......@@ -38,6 +38,7 @@
#include "WPropertyBase.h"
#include "WPropertyTypes.h"
#include "WPropertyVariable.h"
#include "WExport_CommonDLL.h"
/**
* Class to manage properties of an object and to provide convenience methods for easy access and manipulation. It also allows
......@@ -46,7 +47,7 @@
* is the property with the name "property" in the group "you" which against is in the group "hello".
* \note The root group of each module does not have a name.
*/
class WProperties: public WPropertyBase
class EXPORT_OWCOMMON_DLL WProperties: public WPropertyBase
{
friend class WPropertiesTest;
public:
......
......@@ -36,11 +36,12 @@
#include "WPropertyTypes.h"
#include "WCondition.h"
#include "WConditionSet.h"
#include "WExport_CommonDLL.h"
/**
* Abstract base class for all properties. Simply provides name and type information.
*/
class WPropertyBase: public boost::enable_shared_from_this< WPropertyBase >
class EXPORT_OWCOMMON_DLL WPropertyBase: public boost::enable_shared_from_this< WPropertyBase >
{
public:
......
......@@ -33,6 +33,7 @@
#include "constraints/WPropertyConstraintPathExists.h"
#include "constraints/WPropertyConstraintIsDirectory.h"
#include "constraints/WPropertyConstraintSelectOnlyOne.h"
#include "WExport_CommonDLL.h"
/**
* This namespace contains several utility functions to handle properties. Especially constraint helper to easily create constraints.
......@@ -49,7 +50,7 @@ namespace WPropertyHelper
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropSelection prop );
void EXPORT_OWCOMMON_DLL addTo( WPropSelection prop );
}
/**
......@@ -62,21 +63,21 @@ namespace WPropertyHelper
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropSelection prop );
void EXPORT_OWCOMMON_DLL addTo( WPropSelection prop );
/**
* Add the PC_NOTEMPTY constraint to the property.
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropString prop );
void EXPORT_OWCOMMON_DLL addTo( WPropString prop );
/**
* Add the PC_NOTEMPTY constraint to the property.
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropFilename prop );
void EXPORT_OWCOMMON_DLL addTo( WPropFilename prop );
}
/**
......@@ -89,7 +90,7 @@ namespace WPropertyHelper
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropFilename prop );
void EXPORT_OWCOMMON_DLL addTo( WPropFilename prop );
}
/**
......@@ -102,7 +103,7 @@ namespace WPropertyHelper
*
* \param prop the property where to add the constraint.
*/
void addTo( WPropFilename prop );
void EXPORT_OWCOMMON_DLL addTo( WPropFilename prop );
}
}
......
......@@ -29,10 +29,12 @@
#include <boost/shared_ptr.hpp>
#include "WExport_CommonDLL.h"
/**
* Interface class for the concept "Prototype". The requirements are a zero-parameter constructor.
*/
class WPrototyped
class EXPORT_OWCOMMON_DLL WPrototyped // NOLINT
{
public:
......
......@@ -35,6 +35,7 @@
#include <boost/lexical_cast.hpp>
#include "WException.h"
#include "WExport_CommonDLL.h"
#ifdef __linux__
// This is highly platform dependent. Used for backtrace functionality.
......@@ -76,7 +77,7 @@ private:
* recoverable, which means it can NOT be catched!
* Also note that this will only work on Linux.
*/
class WSegmentationFault: public WException
class EXPORT_OWCOMMON_DLL WSegmentationFault: public WException
{
public:
......
......@@ -26,13 +26,17 @@
#include <cassert>
#include <string>
#ifdef _WIN32
#include <iostream>
#include <windows.h> // NOLINT
#endif
#include "exceptions/WLibraryFetchFailed.h"
#include "exceptions/WLibraryLoadFailed.h"
#include "WSharedLib.h"
#ifdef _WIN32
#include <windows.h> // NOLINT
/**
* Simple class holding an opened library.
......@@ -264,6 +268,19 @@ void* WSharedLib::findVariable( const std::string& name ) const
return m_data->findVariable( name );
}
#ifdef _MSC_VER
// easier this way because VC has problems with quote in command line
std::string WSharedLib::getSystemPrefix()
{
return "";
}
std::string WSharedLib::getSystemSuffix()
{
return ".dll";
}
#else
std::string WSharedLib::getSystemPrefix()
{
return W_LIB_PREFIX;
......@@ -273,6 +290,7 @@ std::string WSharedLib::getSystemSuffix()
{
return W_LIB_SUFFIX;
}
#endif
std::string WSharedLib::getSystemLibPath()
{
......
......@@ -30,6 +30,8 @@
#include <boost/filesystem.hpp>
#include "WExport_CommonDLL.h"
/**
* This class loads shared libraries and provides function pointers. This is especially useful for dynamic loading of shared libraries during
* runtime. This works on Windows, Linux and Mac OS and is based on the openbug shared_lib implementation by
......@@ -39,7 +41,7 @@
* \warning Because the POSIX standard does not enforce thread safety for the functions dlopen, dlclose, dlerror, and dlsym, these should not
* be used simultaneously with variables of this class.
*/
class WSharedLib
class EXPORT_OWCOMMON_DLL WSharedLib // NOLINT
{
public:
......
......@@ -37,6 +37,8 @@
#include <boost/lexical_cast.hpp>
#include "WExport_CommonDLL.h"
/**
* Some utilities for string manipulation and output operations. Please note
* that the overloaded ostream output operators aren't in a separate namespace
......@@ -63,7 +65,7 @@ namespace string_utils
* - <tt>\\t</tt> tab
* - <tt>' '</tt> space
*/
extern const std::string WHITESPACE;
extern EXPORT_OWCOMMON_DLL const std::string WHITESPACE;
/**
* Trims any occurence of each character given in parameter t from the end
......@@ -74,7 +76,7 @@ namespace string_utils
* \return A copy of the trimmed string
*/
std::string rTrim( const std::string& source, const std::string& t = WHITESPACE );
std::string EXPORT_OWCOMMON_DLL rTrim( const std::string& source, const std::string& t = WHITESPACE );
/**
* Trims any occurence of each character given in parameter t from the
......@@ -84,7 +86,7 @@ namespace string_utils
* \param t String representing a set containg all trimmable characters
* \return A copy of the trimmed string
*/
std::string lTrim( const std::string& source, const std::string& t =
std::string EXPORT_OWCOMMON_DLL lTrim( const std::string& source, const std::string& t =
WHITESPACE );
/**
......@@ -95,7 +97,7 @@ namespace string_utils
* \param t String representing a set containg all trimmable characters
* \return A copy of the trimmed string
*/
std::string trim( const std::string& source, const std::string& t = WHITESPACE );
std::string EXPORT_OWCOMMON_DLL trim( const std::string& source, const std::string& t = WHITESPACE );
/**
* Transforms all characters in the given string into upper case
......@@ -104,7 +106,7 @@ namespace string_utils
* \param source String to transpose.
* \return A copy of the upper case only string
*/
std::string toUpper( const std::string& source );
std::string EXPORT_OWCOMMON_DLL toUpper( const std::string& source );
/**
* Transforms all characters in the given string into lower case
......@@ -113,7 +115,7 @@ namespace string_utils
* \param source String to transpose.
* \return A copy of the lower case only string
*/
std::string toLower( const std::string& source );
std::string EXPORT_OWCOMMON_DLL toLower( const std::string& source );
/**