summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: bbf3df8971b999504f2433dfc804b97e1a18f5eb (plain)
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
project(wifi-settings)

cmake_minimum_required(VERSION 3.3)

include(GNUInstallDirs)

set(PROJECT_VERSION "0.1")
set(PROJECT_ICON "icon_wifi_128.png")
set(PROJECT_LIBDIR "lib")
set(PROJECT_QML "qml")
set(PROJECT_IMPORT "imports")
set(PROJECT_DOC "doc")

set(CMAKE_BUILD_TYPE Debug)

###########################################################################
add_compile_options(-Wall -Wextra -Wconversion)
add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care?
add_compile_options(-Werror=maybe-uninitialized)
add_compile_options(-Werror=implicit-function-declaration)
add_compile_options(-ffunction-sections -fdata-sections)
add_compile_options(-Wl,--as-needed -Wl,--gc-sections)
add_compile_options(-fPIC)

set(CMAKE_C_FLAGS_PROFILING    "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE")
set(CMAKE_C_FLAGS_DEBUG        "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")

###########################################################################

include(FindPkgConfig)

pkg_check_modules(EXTRAS REQUIRED json-c afb-daemon glib-2.0 gio-2.0 gobject-2.0 zlib)
add_compile_options(${EXTRAS_CFLAGS})
include_directories(${EXTRAS_INCLUDE_DIRS})
link_libraries(${EXTRAS_LIBRARIES})

###########################################################################
# the binding for afb

message(STATUS "Creation of ${PROJECT_NAME} for AFB-DAEMON")

###############################################################
add_library(${PROJECT_NAME} MODULE wifi-api.c wifi-connman.c agent.c)
 
set_target_properties(${PROJECT_NAME} PROPERTIES
        PREFIX ""
        LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export.map"
)

configure_file(config.xml.in config.xml)

add_custom_command(
        OUTPUT ${PROJECT_NAME}.wgt
        DEPENDS ${PROJECT_NAME}
        COMMAND rm -rf package
        COMMAND mkdir -p package/${PROJECT_LIBDIR} package/htdocs
        COMMAND cp config.xml package/
        COMMAND cp -rf ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_ICON} package/icon.png
        COMMAND cp -rf ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_QML} package/${PROJECT_QML}
        COMMAND cp -rf ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_IMPORT} package/${PROJECT_IMPORT}
        COMMAND cp -rf ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_DOC} package/${PROJECT_DOC}
        COMMAND cp ${PROJECT_NAME}.so package/${PROJECT_LIBDIR}
        COMMAND wgtpkg-pack -f -o ${PROJECT_NAME}.wgt package 
        COMMAND rm -rf package
)
add_custom_target(widget ALL DEPENDS ${PROJECT_NAME}.wgt)