-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
47 lines (41 loc) · 1.39 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
cmake_minimum_required(VERSION 3.20.0 FATAL_ERROR)
# dependency manager
set(CPM_VERSION 0.40.2)
set(CPM_SOURCE_CACHE ${CMAKE_CURRENT_SOURCE_DIR}/_build/cache/cpm)
set(CPM_USE_NAMED_CACHE_DIRECTORIES false)
set(CPM_PATH "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_VERSION}.cmake")
if(NOT EXISTS ${CPM_PATH})
message(STATUS "Downloading CPM.cmake to ${CPM_PATH}")
set(CPM_GH_URL https://github.com/cpm-cmake/cpm.cmake/releases/download)
set(CPM_RELEASE_URL ${CPM_GH_URL}/v${CPM_VERSION}/CPM.cmake)
file(DOWNLOAD ${CPM_RELEASE_URL} ${CPM_PATH})
endif()
include(${CPM_PATH})
file(GLOB PATCH_FILES "${CMAKE_SOURCE_DIR}/patches/*.patch")
# dependencies
CPMFindPackage(
NAME bacnet
GITHUB_REPOSITORY bacnet-stack/bacnet-stack
GIT_TAG bacnet-stack-1.3.8
OPTIONS "BACNET_STACK_BUILD_APPS NO"
PATCHES ${PATCH_FILES})
# setup erlang
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} $ENV{ERL_EI_LIBDIR})
find_library(ERLANG_EI_LIB ei)
include_directories($ENV{ERL_EI_INCLUDE_DIR})
# sources
INCLUDE_DIRECTORIES(src/)
set(SOURCES
src/bacnet.c
src/log.c
src/main.c
src/port.c
src/protocol/decode_call.c
src/protocol/enum.c)
# build
project(bacnetd)
set(CMAKE_BUILD_TYPE Release)
add_executable(bacnetd ${SOURCES})
set_target_properties(bacnetd PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE $ENV{MIX_APP_PATH}/priv)
target_link_libraries(bacnetd PRIVATE bacnet-stack ${ERLANG_EI_LIB})