-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (52 loc) · 2.18 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 2.8)
project(wpcp2opcua)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_GENERATED_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/generated)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if (MSVC)
set(ADDITIONAL_COMPILER_FLAGS "/Wall /wd4820")
if (MSVC_VERSION LESS 1600)
set(ADDITIONAL_COMPILER_FLAGS "${ADDITIONAL_COMPILER_FLAGS} /wd4255")
include_directories(win32compat)
endif ()
if (NOT MSVC_VERSION LESS 1500)
set(ADDITIONAL_COMPILER_FLAGS "${ADDITIONAL_COMPILER_FLAGS} /MP")
endif ()
endif ()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADDITIONAL_COMPILER_FLAGS}")
include(ExternalProject)
ExternalProject_Add(
libwpcp
GIT_REPOSITORY https://github.com/WebProcessControl/libwpcp.git
GIT_TAG v0.1.0
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>" "-DWPCP_BUILD_LIBWEBSOCKETS=ON" "-DWPCP_BUILD_CHECK=ON"
)
ExternalProject_Get_Property(libwpcp INSTALL_DIR)
ExternalProject_Get_Property(libwpcp SOURCE_DIR)
add_library(wpcp STATIC IMPORTED)
add_library(wpcp-lws STATIC IMPORTED)
add_dependencies(wpcp libwpcp)
add_dependencies(wpcp-lws libwpcp)
set_property(TARGET wpcp PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}wpcp${CMAKE_STATIC_LIBRARY_SUFFIX})
set_property(TARGET wpcp-lws PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}wpcp-lws${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LIBWPCP_INCLUDE_DIRS ${SOURCE_DIR}/include)
set(LIBWPCP_LIBRARIES wpcp wpcp-lws)
include_directories(${LIBWPCP_INCLUDE_DIRS})
set(WPCP2OPCUA_SOURCES
channel.c
convert.c
main.c
main.h
pubsub.c
rw.c
)
set(ENVPROGRAMFILES "PROGRAMFILES(X86)")
set(UaSdkCppDir "$ENV{${ENVPROGRAMFILES}}/UnifiedAutomation/UaSdkCppBundleEval")
include_directories("${UaSdkCppDir}/include/uastack")
link_directories("${UaSdkCppDir}/lib")
set(UA_STACK_LIB uastack)
add_executable(wpcp2opcua ${WPCP2OPCUA_SOURCES})
set_property(TARGET wpcp2opcua PROPERTY COMPILE_DEFINITIONS _UA_STACK_USE_DLL)
target_link_libraries(wpcp2opcua ${LIBWPCP_LIBRARIES} ${UA_STACK_LIB})