<repo_name>fr830/opcua-cmake<file_sep>/server/CMakeLists.txt


include_directories(${MAPPINGSDIR}/include )
include_directories(${COREDIR}/include )
include_directories(${CLIENTDIR}/include )
include_directories(${SERVERDIR})


include_directories(${SERVERDIR}/binary_protocol/include )
include_directories(${SERVERDIR}/endpoint_services/include )
include_directories(${SERVERDIR}/services_registry/include )
include_directories(${SERVERDIR}/address_space/include )
include_directories(${SERVERDIR}/tcp_server/include )
include_directories(${SERVERDIR}/builtin_server/include )
include_directories(${SERVERDIR}/xml_address_space_loader/include )
include_directories(${SERVERDIR}/standard_namespace/include )
include_directories(${SERVERDIR}/server/include)

get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)

set(TMPSRC ${SERVERDIR}/services_registry/src)
add_library(services_registry_addon SHARED 
    ${TMPSRC}/services_registry_impl.cpp
    ${TMPSRC}/services_registry_factory.cpp  
    ${TMPSRC}/services_registry_module.cpp
)
target_link_libraries(services_registry_addon  opcuabinary opcuacommon)



set(TMPSRC ${SERVERDIR}/endpoint_services/src)
add_library(endpoints_services_addon SHARED 
    ${TMPSRC}/endpoints_parameters.cpp      
    ${TMPSRC}/endpoints_services_addon.cpp  ${TMPSRC}/endpoints_services_module.cpp
)
target_link_libraries(endpoints_services_addon opcuabinary)


set(TMPSRC ${SERVERDIR}/binary_protocol/src)
add_library(opcua_protocol SHARED 
    ${TMPSRC}/opc_tcp_processor.cpp  
    ${TMPSRC}/opcua_protocol_addon.cpp  
    ${TMPSRC}/opcua_protocol_module.cpp
)
target_link_libraries(opcua_protocol opcuacommon endpoints_services_addon xml2)


set(TMPSRC ${SERVERDIR}/standard_namespace/src)
add_library(standard_ns_addon SHARED 
    ${TMPSRC}/standard_namespace_addon.cpp  
    ${TMPSRC}/standard_namespace.cpp        ${TMPSRC}/standard_namespace_module.cpp
)
target_link_libraries(standard_ns_addon opcuabinary)

set(TMPSRC ${SERVERDIR}/address_space/src)
add_library(address_space_addon SHARED 
    ${TMPSRC}/address_space_addon.cpp  ${TMPSRC}/address_space_internal.cpp  ${TMPSRC}/address_space_module.cpp
)
target_link_libraries(address_space_addon opcuabinary opcuacommon ${Boost_LIBRARIES})


set(TMPSRC ${SERVERDIR}/xml_address_space_loader/src)
add_library(xml_address_space_loader_addon SHARED 
${TMPSRC}/xml_address_space_addon.cpp  ${TMPSRC}/xml_address_space_loader.cpp ${TMPSRC}/xml_address_space_module.cpp 
)
target_link_libraries(xml_address_space_loader_addon opcuacommon opcuabinary xml2)


set(TMPSRC ${SERVERDIR}/tcp_server/src)
add_library(opcua_tcp_server SHARED 
    ${TMPSRC}/tcp_server_addon_impl.cpp  
    ${TMPSRC}/tcp_server_factory.cpp  
    ${TMPSRC}/tcp_server.cpp        
    ${TMPSRC}/tcp_server_module.cpp
)
target_link_libraries(opcua_tcp_server opcuacommon)

set(TMPSRC ${SERVERDIR}/server/src)
add_library(opcuaserver SHARED 
    ${TMPSRC}/opcuaserver.cpp
)
target_link_libraries(opcuaserver opcuabinary opcuacommon standard_ns_addon opcua_protocol address_space_addon services_registry_addon opcua_tcp_server endpoints_services_addon)



#command line server
set(TMPSRC ${SERVERDIR}/exe/src)
add_executable(server
    ${TMPSRC}/daemon.cpp   ${TMPSRC}/server_main.cpp  ${TMPSRC}/server_options.cpp
)
target_link_libraries(server opcuabinary opcuacommon ${Boost_LIBRARIES} )

#example server
add_executable(example 
    ${TMPSRC}/daemon.cpp  ${TMPSRC}/example.cpp
)
target_link_libraries(example opcuaserver opcuabinary opcuacommon  ${Boost_LIBRARIES} )






<file_sep>/mappings/CMakeLists.txt




include_directories(${MAPPINGSDIR}/include)
file(GLOB_RECURSE HEADERS ${MAPPINGSDIR}/include/*.h )

#the OPCUA lib
add_library(opcuabinary SHARED
    ${MAPPINGSDIR}/src/binary_attribute.cpp   
    ${MAPPINGSDIR}/src/binary_node_management.cpp   
    ${MAPPINGSDIR}/src/binary_endpoints.cpp  
    ${MAPPINGSDIR}/src/binary_raw_size.cpp     
    ${MAPPINGSDIR}/src/binary_session.cpp  
    ${MAPPINGSDIR}/src/binary_variant.cpp  
    ${MAPPINGSDIR}/src/monitored_items.cpp  
    ${MAPPINGSDIR}/src/subscriptions.cpp
    ${MAPPINGSDIR}/src/binary_data_value.cpp  
    ${MAPPINGSDIR}/src/binary_messages.cpp   
    ${MAPPINGSDIR}/src/binary_stream.cpp   
    ${MAPPINGSDIR}/src/binary_view.cpp     
    ${MAPPINGSDIR}/src/nodeid.cpp
    ${MAPPINGSDIR}/src/types.cpp
    ${MAPPINGSDIR}/src/input_from_buffer.cpp
    ${MAPPINGSDIR}/src/string_utils.cpp
    ${HEADERS}
)

if(BUILD_TESTS)
    set(MAPPINGSTESTDIR ${MAPPINGSDIR}/tests)
    include_directories(${MAPPINGSTESTDIR})

    add_executable(opcuabinary_tests EXCLUDE_FROM_ALL 
        ${MAPPINGSTESTDIR}/binary_deserialize.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_variant.cpp
        ${MAPPINGSTESTDIR}/binary_serialize.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_attribute.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_data_value.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_endpoints.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_monitored_items.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_session.cpp
        ${MAPPINGSTESTDIR}/binary_serialize_view.cpp
        ${MAPPINGSTESTDIR}/binary_subscriptions.cpp
        ${MAPPINGSTESTDIR}/binary_node_management.cpp
        ${MAPPINGSTESTDIR}/message_id.cpp
        ${MAPPINGSTESTDIR}/node_id.cpp
        ${MAPPINGSTESTDIR}/reference_id.cpp
        ${MAPPINGSTESTDIR}/test_input_from_buffer.cpp
        ${MAPPINGSTESTDIR}/utils.cpp

        ${MAPPINGSTESTDIR}/common.h
    )
    target_link_libraries(opcuabinary_tests ${GTEST_BOTH_LIBRARIES} opcuabinary pthread)


endif(BUILD_TESTS)

<file_sep>/start_server.sh
set +x
build/server/server --config server/config/ --log-file=server.log
<file_sep>/CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project (FreeOpcUa)

option(CLANG "Build using Clang++" ON)

option(BUILD_PYTHON "Build Python bindings" ON)
option(BUILD_MAPPINGS "Build Mappings" ON)
option(BUILD_CORE "Build Core" ON)
option(BUILD_CLIENT "Build Client" ON)
option(BUILD_SERVER "Build Server" ON)
option(BUILD_TESTS "Build Tests Target" ON)


set(MAPPINGSDIR ${CMAKE_SOURCE_DIR}/reps/opcua-mappings)
set(COREDIR ${CMAKE_SOURCE_DIR}/reps/opcua-core)
set(CLIENTDIR ${CMAKE_SOURCE_DIR}/reps/opcua-client)
set(SERVERDIR ${CMAKE_SOURCE_DIR}/reps/opcua-server)
set(PYTHONDIR ${CMAKE_SOURCE_DIR}/reps/opcua-python)


if(NOT WIN32)
    set(CMAKE_CXX_FLAGS "-std=c++0x -ggdb -Wall ${CMAKE_CXX_FLAGS_DEBUG} " ) 
    if(CLANG)
        set(CMAKE_CXX_COMPILER  "clang++")
        set(CMAKE_SHARED_LINKER_FLAGS "--no-undefined" )
    endif()
endif(NOT WIN32)


find_package( Boost  COMPONENTS system program_options filesystem thread REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )
message(STATUS "Boost INCLUDE DIR IS: " ${Boost_INCLUDE_DIR})

find_package(LibXml2 REQUIRED) 
message(STATUS "LibXML2 INCLUDE DIR IS: " ${LIBXML2_INCLUDE_DIR})
include_directories( ${LIBXML2_INCLUDE_DIR} )

if(BUILD_TESTS)
    find_package(GTest)
    if(GTEST_FOUND)
        MESSAGE(STATUS "GTest found, building tests")
        enable_testing()
        include_directories(${GTEST_INCLUDE_DIRS})
    else()
        MESSAGE(STATUS "GTest NOT found, Not building tests")
        set(BUILD_TESTS OFF)
    endif()
endif()


if(BUILD_MAPPINGS)
    message(STATUS "Building Mappings")
    add_subdirectory (mappings) 
    if(BUILD_TESTS)
        add_test("OPC-UAMappings" ${PROJECT_BINARY_DIR}/mappings/opcuabinary_tests )
        set(TEST_MAPPINGS_DEPEND opcuabinary_tests)
    endif(BUILD_TESTS)
endif(BUILD_MAPPINGS)
if(BUILD_CORE)
    message(STATUS "Building Core")
    add_subdirectory (core) 
    if(BUILD_TESTS)
        add_test("OPC-UACore" ${PROJECT_BINARY_DIR}/core/opcuacore_tests )
        set(TEST_CORE_DEPEND opcuacore_tests)
    endif(BUILD_TESTS)
endif(BUILD_CORE)
if(BUILD_CLIENT)
    message(STATUS "Building Client")
    add_subdirectory (client) 
    if(BUILD_TESTS)
    endif(BUILD_TESTS)
endif(BUILD_CLIENT)
if(BUILD_SERVER)
    message(STATUS "Building Server")
    add_subdirectory (server) 
    if(BUILD_TESTS)
    endif(BUILD_TESTS)
endif(BUILD_SERVER)
if(BUILD_PYTHON)
    message(STATUS "Building Python")
    add_subdirectory (python) 
    if(BUILD_TESTS)
        add_test("PythonTests" python3 ${PYTHONDIR}/tests/test_highlevel.py) 
        #find_package(PythonInterp REQUIRED ) #cmake only find python2 ?!?!?
        #add_test("PythonTests" ${PYTHON_EXECUTABLE} ${PYTHONDIR}/tests/test_highlevel.py) 
    endif(BUILD_TESTS)
endif(BUILD_PYTHON)

if(BUILD_TESTS)
    add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure DEPENDS ${TEST_MAPPINGS_DEPEND} ${OPCUA_CORE_DEPEND})
endif()

<file_sep>/core/CMakeLists.txt

include_directories(${MAPPINGSDIR}/include )
include_directories(${COREDIR}/include )
file(GLOB_RECURSE HEADERS ${COREDIR}/include/*.h )

set(TMPSRC ${COREDIR}/src/)
add_library(opcuacommon SHARED 
    ${TMPSRC}/socket_channel.cpp
    ${TMPSRC}/common/application.cpp  
    ${TMPSRC}/common/common_errors.cpp  
    ${TMPSRC}/common/exception.cpp  
    ${TMPSRC}/common/object_id.cpp  
    ${TMPSRC}/common/thread.cpp  
    ${TMPSRC}/common/value.cpp 
    ${TMPSRC}/node.cpp
    ${TMPSRC}/common/addons_core/addon_manager.cpp  
    ${TMPSRC}/common/addons_core/config_file.cpp  
    ${TMPSRC}/common/addons_core/dynamic_addon_factory.cpp  
    ${TMPSRC}/common/addons_core/dynamic_library.cpp  
    ${TMPSRC}/common/addons_core/errors_addon_manager.cpp
    ${TMPSRC}/opcua_errors.cpp
    ${HEADERS}
)
target_link_libraries(opcuacommon opcuabinary ${Boost_LIBRARIES} dl xml2)


if(BUILD_TESTS)
    set(CORETESTDIR ${COREDIR}/tests)
    include_directories(${CORETESTDIR})

    add_executable(opcuacore_tests EXCLUDE_FROM_ALL 
        ${CORETESTDIR}/common/error_test.cpp
        ${CORETESTDIR}/common/main.cpp
        ${CORETESTDIR}/common/value_test.cpp
    )
    target_link_libraries(opcuacore_tests ${GTEST_BOTH_LIBRARIES} opcuabinary opcuacommon pthread cppunit)
endif(BUILD_TESTS)











<file_sep>/python/CMakeLists.txt

SET(PYTHONFOUND FALSE)
FIND_PACKAGE( Boost COMPONENTS python-py34 )
IF(Boost_PYTHON-PY34_FOUND)
    SET(Python_ADDITIONAL_VERSIONS 3.4) #HACK UNTIL CORRENT CMAKE SUPPORT
    FIND_PACKAGE(PythonLibs 3.4)
    IF(PYTHONLIBS_FOUND)
        MESSAGE(STATUS "Compiling Python module with Python 3.4")
        SET(PYTHONFOUND TRUE)
    ENDIF()
ENDIF()
IF(NOT PYTHONFOUND)
    FIND_PACKAGE( Boost COMPONENTS python )
    IF(Boost_PYTHON_FOUND)
        FIND_PACKAGE(PythonLibs 2.7)
        IF(PYTHONLIBS_FOUND)
            MESSAGE("Compiling Python module")
            SET(PYTHONFOUND TRUE)
        ENDIF()
    ENDIF()
ENDIF()

IF(NOT PYTHONFOUND)
    MESSAGE(STATUS "Python boost or lib not found: Not building python module")
    RETURN()
ENDIF()

INCLUDE_DIRECTORIES( ${BOOST_INCLUDE_DIR} )
INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIR} )

include_directories(${CMAKE_SOURCE_DIR}/mappings/include )
include_directories(${CMAKE_SOURCE_DIR}/core/include )
include_directories(${CMAKE_SOURCE_DIR}/client/include )
include_directories(${CMAKE_SOURCE_DIR}/server )


include_directories(${CMAKE_SOURCE_DIR}/server/binary_protocol/include )
include_directories(${CMAKE_SOURCE_DIR}/server/endpoint_services/include )
include_directories(${CMAKE_SOURCE_DIR}/server/services_registry/include )
include_directories(${CMAKE_SOURCE_DIR}/server/address_space/include )
include_directories(${CMAKE_SOURCE_DIR}/server/tcp_server/include )
include_directories(${CMAKE_SOURCE_DIR}/server/builtin_server/include )
include_directories(${CMAKE_SOURCE_DIR}/server/server/include )
include_directories(${CMAKE_SOURCE_DIR}/server/xml_address_space_loader/include )


add_definitions(-DMODULE_NAME=opcua)
ADD_LIBRARY(opcua SHARED src/module.cpp)
set_target_properties(opcua PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(opcua opcuaserver opcuabinary opcuacommon opcua_client ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})




<file_sep>/example_server.sh
set +x
build/server/example_server --config server/config/ --log-file=server.log
<file_sep>/client/CMakeLists.txt



include_directories(${MAPPINGSDIR}/include )
include_directories(${COREDIR}/include )
include_directories(${CLIENTDIR}/include )


#the OPCUA lib
add_library(opc_tcp_client SHARED 
    ${CLIENTDIR}/src/binary_computer_addon.cpp  
    ${CLIENTDIR}/src/binary_connection.cpp     
    ${CLIENTDIR}/src/binary_computer.cpp        
    ${CLIENTDIR}/src/binary_secure_channel.cpp  
    ${CLIENTDIR}/src/computer.cpp  
    ${CLIENTDIR}/src/errors.cpp  
)
target_link_libraries(opc_tcp_client opcuacommon opcuabinary)

add_library(opcua_client SHARED ${CLIENTDIR}/src/client.cpp )
target_link_libraries(opcua_client opcuacommon opcuabinary opc_tcp_client)


add_executable(client ${CLIENTDIR}/src/opcua_main.cpp  ${CLIENTDIR}/src/opcua_options.cpp)
target_link_libraries(client opcuacommon opcuabinary)

add_executable(example_client ${CLIENTDIR}/src/example_main.cpp )
target_link_libraries(example_client opcua_client )
