Changeset acf0660 in nscp


Ignore:
Timestamp:
06/09/10 19:25:14 (3 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
5cd6bcf
Parents:
86632db
Message:

renamed to_string as it clashed with some boost classes, as well as refactoring of the cmake build scripts to work better..

Files:
13 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    r86632db racf0660  
    3232# Open SSL 
    3333SET(OPENSSL_INCLUDE_DIR "${INC_OPENSSL_INCLUDEDIR}" CACHE PATH "Path to openssl includes") 
     34SET(OPENSSL_LIBRARY_DIR "${NSCP_LIBRARYDIR}" CACHE PATH "Path to openssl libraries") 
    3435# ### ### ### ### 
    3536# Google Protocol buffer 
     
    3738IF(WIN32 AND MSVC) 
    3839  SET(PROTOBUF_INCLUDE_DIR "${PROTOBUF_DIR}/src" CACHE PATH "Path to google protocol buffer source") 
    39   SET(PROTOBUF_LIBRARYDIR "${PROTOBUF_DIR}/vsprojects/Debug") 
    40   SET(PROTOBUF_BINARYDIR "${PROTOBUF_DIR}/vsprojects/Debug") 
     40  SET(PROTOBUF_LIBRARYDIR "${PROTOBUF_DIR}/vsprojects/Release") 
     41  SET(PROTOBUF_BINARYDIR "${PROTOBUF_DIR}/vsprojects/Release") 
    4142ELSE(WIN32 AND MSVC) 
    4243# TODO 
     
    4647SET(CRYPTOPP_DIR "${INC_CRYPTOPP_DIR}" CACHE PATH "Path to crypto++ root folder") 
    4748# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### 
     49 
     50 
     51INCLUDE_DIRECTORIES(${NSCP_INCLUDEDIR}) 
     52SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${OPENSSL_LIBRARY_DIR};${NSCP_LIBRARYDIR};${BOOST_LIBRARYDIR}") 
     53 
    4854 
    4955IF(APPLE) 
     
    5157ELSEIF(UNIX AND NOT APPLE) 
    5258  IF (ARCH_X86_64 EQUAL 1) 
    53     MESSAGE(STATUS, "Adding FPIC") 
     59    MESSAGE(STATUS "Adding FPIC") 
    5460    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 
    5561  ELSE(ARCH_X86_64 EQUAL 1) 
    56     MESSAGE(STATUS, "Adding FPIC (noia64)") 
     62    MESSAGE(STATUS "Adding FPIC (noia64)") 
    5763    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 
    5864  ENDIF (ARCH_X86_64 EQUAL 1) 
     
    8288ENDIF(NOT MULTI_THREADED) 
    8389 
    84 INCLUDE_DIRECTORIES(${NSCP_INCLUDEDIR}) 
    85 SET(CMAKE_LIBRARY_PATH "${NSCP_LIBRARYDIR}" CACHE PATH "Path to generic libraries") 
    86 #SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} CACHE PATH "Look for libraries here") 
    8790 
    8891IF(WIN32) 
     
    106109FIND_PACKAGE(OpenSSL) 
    107110if(OPENSSL_FOUND) 
    108   if(WIN32) 
    109     FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32) 
    110     FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32) 
    111       IF(LIB_EAY_DEBUG AND LIB_EAY_RELEASE) 
    112          SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG}) 
    113       ELSE(LIB_EAY_DEBUG AND LIB_EAY_RELEASE) 
    114     SET(OPENSSL_FOUND FALSE) 
    115          SET(OPENSSL_LIBRARIES NOTFOUND) 
    116          MESSAGE(STATUS "Could not find the debug and release version of openssl") 
    117       ENDIF(LIB_EAY_DEBUG AND LIB_EAY_RELEASE) 
    118   endif(WIN32) 
    119 endif(OPENSSL_FOUND) 
    120  
    121 if(OPENSSL_FOUND) 
    122   message(STATUS, "Found openssl: ${OPENSSL_LIBRARIES}") 
     111  MESSAGE(STATUS "Found OpenSSL") 
    123112  SET(NSCP_GLOBAL_DEFINES ${NSCP_GLOBAL_DEFINES} -DUSE_SSL) 
    124113else(OPENSSL_FOUND) 
    125   message(STATUS, "openssl NOT found (no ssl support)") 
     114  MESSAGE(WARNING " OpenSSL NOT found (no ssl support, ${OPENSSL_INCLUDE_DIR})") 
    126115endif(OPENSSL_FOUND) 
    127116 
    128 FIND_PACKAGE(Boost COMPONENTS system filesystem thread REQUIRED) 
    129  
     117FIND_PACKAGE(Boost COMPONENTS system filesystem thread regex date_time program_options REQUIRED) 
    130118if(Boost_FOUND) 
    131   message(STATUS, "Found boost in: ${Boost_INCLUDE_DIRS}") 
     119  MESSAGE(STATUS "Found boost in: ${Boost_INCLUDE_DIRS} / ${Boost_LIBRARY_DIRS}") 
     120  # Boost is used nearly everywhere, so we can put these here 
     121  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) 
     122  #LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) 
     123  IF(WIN32) 
     124    IF(BOOST_DYNAMIC) 
     125    #ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) 
     126    ENDIF(BOOST_DYNAMIC) 
     127    SET(EXTRA_LIBS ${EXTRA_LIBS} Userenv ole32) 
     128  ENDIF(WIN32) 
     129 
    132130else(Boost_FOUND) 
    133   message(FATAL_ERROR, "boost NOT fround: ${Boost_ERROR_REASON}") 
     131  MESSAGE(FATAL_ERROR, "boost NOT fround: ${Boost_ERROR_REASON}") 
    134132endif(Boost_FOUND) 
    135133 
    136134INCLUDE(cmake/NSCPPBuffer.cmake) 
     135LINK_DIRECTORIES("${CMAKE_LIBRARY_PATH};${OPENSSL_LIBRARY_DIR};${NSCP_LIBRARYDIR};${BOOST_LIBRARYDIR}") 
    137136 
    138137if(PROTOBUF_FOUND) 
    139   message(STATUS, "Found proto in: ${PROTOBUF_LIBRARY}") 
     138  message(STATUS "Found proto in: ${PROTOBUF_LIBRARY} (${PROTOBUF_PROTOC_EXECUTABLE})") 
    140139  INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR}) 
    141140else(PROTOBUF_FOUND) 
     
    180179ENDIF() 
    181180 
    182 # Boost is used nearly everywhere, so we can put these here 
    183 INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIRS}) 
    184 LINK_DIRECTORIES(${BOOST_LIB_DIRS}) 
    185 IF(WIN32) 
    186   IF(BOOST_DYNAMIC) 
    187     ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) 
    188   ENDIF(BOOST_DYNAMIC) 
    189   set (EXTRA_LIBS ${EXTRA_LIBS} Userenv ole32) 
    190 ENDIF(WIN32) 
    191  
    192181IF(NOT CMAKE_BUILD_TYPE) 
    193182  SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING 
     
    224213  protobuf 
    225214) 
    226 message(STATUS, "NSCP PLUGIN LIB: ${NSCP_DEF_PLUGIN_LIB}") 
    227 message(STATUS, "NSCP PLUGIN CPP: ${NSCP_DEF_PLUGIN_CPP}") 
     215 
     216message(STATUS "NSCP PLUGIN LIB: ${NSCP_DEF_PLUGIN_LIB}") 
     217message(STATUS "NSCP PLUGIN CPP: ${NSCP_DEF_PLUGIN_CPP}") 
    228218 
    229219   
  • build.cmake

    r86632db racf0660  
    55set(Boost_USE_STATIC_LIBS   ON) 
    66set(BOOST_USE_MULTITHREADED ON) 
     7SET(NSCP_GLOBAL_DEFINES ${NSCP_GLOBAL_DEFINES} -DBOOST_ALL_NO_LIB)  # THis is used to disable "automatic linking on windows which seems to break since I dont know how to set link dir 
    78#SET(BOOST_LIB_SUFFIX vc80-mt) 
    89#SET(Boost_VERSION 1.40) 
    910 
    10 SET(INC_BOOST_INCLUDEDIR C:/source/include) 
    11 SET(INC_BOOST_LIBRARYDIR C:/source/lib/x64) 
     11SET(INC_NSCP_LIBRARYDIR C:/source/lib/x86) 
     12SET(INC_NSCP_INCLUDEDIR C:/source/include) 
     13 
     14SET(INC_BOOST_INCLUDEDIR "${INC_NSCP_INCLUDEDIR}") 
     15SET(INC_BOOST_LIBRARYDIR "${INC_NSCP_LIBRARYDIR}") 
    1216 
    1317 
    14 SET(INC_OPENSSL_INCLUDEDIR C:/source/include) 
    15 SET(INC_NSCP_LIBRARYDIR C:/source/lib/x64) 
     18SET(INC_OPENSSL_INCLUDEDIR "${INC_NSCP_INCLUDEDIR}") 
    1619 
    1720SET(INC_PROTOBUF_DIR "c:/source/libraries/protobuf-2.3.0") 
  • cmake/NSCPPBuffer.cmake

    r60375ed racf0660  
    2626  # in cache already 
    2727  SET(PROTOBUF_FOUND TRUE) 
    28   MESSAGE(STATUS, "CACHED Protocol buffers was found!") 
     28  MESSAGE(STATUS "CACHED Protocol buffers was found!") 
    2929ELSE (PROTOBUF_LIBRARY AND PROTOBUF_INCLUDE_DIR AND PROTOBUF_PROTOC_EXECUTABLE) 
    3030 
     
    5252  SET(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE} CACHE INTERNAL "The protocol buffers compiler") 
    5353 
    54   MESSAGE(STATUS, "PROTOBUF_INCLUDE_DIR: ${PROTOBUF_INCLUDE_DIR}, PROTOBUF_LIBRARY: ${PROTOBUF_LIBRARY}, PROTOBUF_PROTOC_EXECUTABLE: ${PROTOBUF_PROTOC_EXECUTABLE}") 
     54  MESSAGE(STATUS "PROTOBUF_INCLUDE_DIR: ${PROTOBUF_INCLUDE_DIR}, PROTOBUF_LIBRARY: ${PROTOBUF_LIBRARY}, PROTOBUF_PROTOC_EXECUTABLE: ${PROTOBUF_PROTOC_EXECUTABLE}") 
    5555 
    5656ENDIF (PROTOBUF_LIBRARY AND PROTOBUF_INCLUDE_DIR AND PROTOBUF_PROTOC_EXECUTABLE) 
    5757 
    5858IF (PROTOBUF_FOUND) 
    59   MESSAGE(STATUS, "Good: Protocol buffers was found (${PROTOBUF_INCLUDE_DIR})") 
     59  MESSAGE(STATUS "Good: Protocol buffers was found (${PROTOBUF_INCLUDE_DIR})") 
    6060  # Define the WRAP_PROTO function 
    6161  SET(PROTOBUF_FOUND TRUE PARENT_SCOPE) 
     
    9191  ENDFUNCTION(WRAP_PROTO) 
    9292ELSE(PROTOBUF_FOUND) 
    93   MESSAGE(STATUS, "Error: Protocol buffers was not found!") 
     93  MESSAGE(WARNING "Error: Protocol buffers was not found!") 
    9494ENDIF(PROTOBUF_FOUND) 
  • include/nrpe/nrpe_packet.hpp

    r40970de racf0660  
    2626#include <boost/asio/buffer.hpp> 
    2727#include <swap_bytes.hpp> 
     28#include <strEx.h> 
     29 
     30 
     31using namespace nscp::helpers; 
    2832 
    2933namespace nrpe { 
  • include/nscapi/nscapi_core_wrapper.cpp

    r86632db racf0660  
    2929 
    3030#include "../libs/protobuf/plugin.proto.h" 
     31 
     32using namespace nscp::helpers; 
    3133 
    3234#define CORE_LOG_ERROR_STD(msg) CORE_LOG_ERROR(((std::wstring)msg).c_str()) 
  • include/nscapi/nscapi_plugin_wrapper.hpp

    rb0e7ecf racf0660  
    3434 
    3535#include "../libs/protobuf/plugin.proto.h" 
     36 
     37using namespace nscp::helpers; 
    3638 
    3739#ifdef WIN32 
  • include/socket_helpers.hpp

    r40970de racf0660  
    22#include <boost/asio.hpp> 
    33#include <boost/foreach.hpp> 
     4#include <boost/bind.hpp> 
    45 
    56namespace socketHelpers { 
  • include/strEx.h

    r60375ed racf0660  
    822822} 
    823823 
    824 template <typename T> std::string to_string(const T& arg) { 
    825   try { 
    826     return boost::lexical_cast<std::string>(arg) ; 
    827   } 
    828   catch(...) { 
    829     return ""; 
     824namespace nscp { 
     825  namespace helpers { 
     826    template <typename T> std::string to_string(const T& arg) { 
     827      try { 
     828        return boost::lexical_cast<std::string>(arg) ; 
     829      } 
     830      catch(...) { 
     831        return ""; 
     832      } 
     833    } 
     834    template <typename T> std::wstring to_wstring(const T& arg) { 
     835      try { 
     836        return boost::lexical_cast<std::wstring>(arg) ; 
     837      } 
     838      catch(...) { 
     839        return _T(""); 
     840      } 
     841    } 
    830842  } 
    831843} 
    832 template <typename T> std::wstring to_wstring(const T& arg) { 
    833   try { 
    834     return boost::lexical_cast<std::wstring>(arg) ; 
    835   } 
    836   catch(...) { 
    837     return _T(""); 
    838   } 
    839 } 
     844 
     845 
  • modules/NRPEServer/NRPEServer.cpp

    rcad08fb racf0660  
    4444 
    4545bool NRPEListener::loadModule(NSCAPI::moduleLoadMode mode) { 
    46 #ifndef USE_SSL 
    47   if (NSCModuleHelper::getSettingsInt(NRPE_SECTION_TITLE, NRPE_SETTINGS_USE_SSL ,NRPE_SETTINGS_USE_SSL_DEFAULT)==1) { 
    48     NSC_LOG_ERROR_STD(_T("SSL not avalible! (not compiled with openssl support)")); 
    49   } 
    50 #endif 
    5146  SETTINGS_REG_KEY_I(nrpe::PORT); 
    5247  SETTINGS_REG_KEY_S(nrpe::BINDADDR); 
     
    6560 
    6661  bUseSSL_ = SETTINGS_GET_BOOL(nrpe::KEYUSE_SSL)==1; 
     62 
     63#ifndef USE_SSL 
     64  if (bUseSSL_) { 
     65    NSC_LOG_ERROR_STD(_T("SSL not avalible! (not compiled with openssl support)")); 
     66  } 
     67#endif 
     68 
    6769  noPerfData_ = SETTINGS_GET_INT(nrpe::ALLOW_PERFDATA)==0; 
    6870  timeout = SETTINGS_GET_INT(nrpe::READ_TIMEOUT); 
  • modules/Scheduler/simple_scheduler.cpp

    rc0d7e82 racf0660  
    44#include <strEx.h> 
    55#include <unicode_char.hpp> 
     6 
     7using namespace nscp::helpers; 
    68 
    79namespace scheduler { 
  • service/channels.hpp

    r40970de racf0660  
    88#include "NSCPlugin.h" 
    99#include "logger.hpp" 
     10 
     11using namespace nscp::helpers; 
    1012 
    1113namespace nsclient { 
  • service/commands.hpp

    rcad08fb racf0660  
    66#include "logger.hpp" 
    77#include <strEx.h> 
     8 
     9using namespace nscp::helpers; 
    810 
    911namespace nsclient { 
  • service/core_api.cpp

    rcad08fb racf0660  
    3333#include <ServiceCmd.h> 
    3434#endif 
     35 
     36using namespace nscp::helpers; 
    3537 
    3638#define LOG_ERROR_STD(msg) LOG_ERROR(((std::wstring)msg).c_str()) 
Note: See TracChangeset for help on using the changeset viewer.