-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
53 lines (40 loc) · 1.66 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
cmake_minimum_required (VERSION 3.0)
project (dnp3hammer VERSION 1.0.0)
# other options off-by-default that you can enable
option(COVERAGE "Builds the libraries with coverage info for gcov" OFF)
# PkgConfig
FIND_PACKAGE(PkgConfig) # tell cmake to require pkg-config
PKG_CHECK_MODULES(GLIB2 REQUIRED glib-2.0>=2.36.0)
set(LIB_TYPE STATIC)
set(CMAKE_C_FLAGS "-Wall -std=c99 -D_POSIX_C_SOURCE=2")
set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
if(COVERAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage -fprofile-arcs -ftest-coverage")
endif()
# different release and debug flags
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
# include paths for all the local libraries
include_directories(include)
# for the tests
# TODO - only add these for the required test projects
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(test/catch)
# ---- parser library ----
file(GLOB_RECURSE dnp3hammer_SRC src/*.c)
add_library(dnp3hammer ${LIB_TYPE} ${dnp3hammer_SRC})
target_link_libraries(dnp3hammer hammer)
# ---- unit test suite ----
add_executable(dnp3-tests ./test/unit/main.c)
target_link_libraries(dnp3-tests dnp3hammer ${GLIB2_LIBRARIES})
# ---- plugin test suite ----
file(GLOB_RECURSE plugintests_SRC test/plugin/*.cpp)
add_executable(plugin-tests ${plugintests_SRC} test/plugin/fixtures/DNP3Helpers.h)
target_link_libraries(plugin-tests dnp3hammer)
# ---- crc example program -----
add_executable(crc crc.c)
target_link_libraries(crc dnp3hammer)
# ---- dissect example program -----
add_executable(dissect dissect.c)
target_link_libraries(dissect dnp3hammer)