-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
88 lines (77 loc) · 3.19 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 3.15)
project(sigfox_ep_addon_rfp)
#Check if Project configure by himself or by a parent project (like sigfox-ep-lib)
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} )
if (NOT DEFINED SIGFOX_EP_LIB_DIR)
message(FATAL_ERROR "${PROJECT_NAME} cannot be configured without -DSIGFOX_EP_LIB_DIR=<sigfox-ep-lib directory>")
endif()
set(ADDON_RFP OFF)
add_subdirectory(${SIGFOX_EP_LIB_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${SIGFOX_EP_LIB_DIR}")
else()
set(SIGFOX_EP_LIB_DIR ${CMAKE_SOURCE_DIR})
message("${PROJECT_NAME} is Fetched by a parent project")
endif()
set(ADDON_RFP_SOURCES
src/sigfox_ep_addon_rfp_api.c
src/test_modes_rfp/sigfox_rfp_test_mode_a.c
src/test_modes_rfp/sigfox_rfp_test_mode_b.c
src/test_modes_rfp/sigfox_rfp_test_mode_c.c
src/test_modes_rfp/sigfox_rfp_test_mode_d.c
src/test_modes_rfp/sigfox_rfp_test_mode_e.c
src/test_modes_rfp/sigfox_rfp_test_mode_f.c
src/test_modes_rfp/sigfox_rfp_test_mode_g.c
src/test_modes_rfp/sigfox_rfp_test_mode_j.c
src/test_modes_rfp/sigfox_rfp_test_mode_k.c
src/test_modes_rfp/sigfox_rfp_test_mode_l.c
)
set(ADDON_RFP_HEADERS
inc/sigfox_ep_addon_rfp_api.h
inc/sigfox_ep_addon_rfp_version.h
inc/test_modes_rfp/sigfox_rfp_test_mode_types.h
)
set(ADDON_RFP_PUBLIC_HEADERS
inc/sigfox_ep_addon_rfp_api.h
inc/sigfox_ep_addon_rfp_version.h
inc/test_modes_rfp/sigfox_rfp_test_mode_types.h
)
#When sigfox_ep_flag.h is don't used
if(${USE_SIGFOX_EP_FLAGS_H} STREQUAL "ON")
else()
if(${CERTIFICATION} STREQUAL "OFF")
message(FATAL_ERROR "CERTIFICATION Flag must be activated for this addon")
endif()
if((${RC3C_ZONE} STREQUAL OFF) AND (${RC5_ZONE} STREQUAL OFF))
list(REMOVE_ITEM ADDON_RFP_SOURCES "src/test_modes_rfp/sigfox_rfp_test_mode_g.c")
endif()
if((${PUBLIC_KEY_CAPABLE} STREQUAL OFF) )
list(REMOVE_ITEM ADDON_RFP_SOURCES "src/test_modes_rfp/sigfox_rfp_test_mode_k.c")
endif()
if(${BIDIRECTIONAL} STREQUAL OFF)
list(REMOVE_ITEM ADDON_RFP_SOURCES "src/test_modes_rfp/sigfox_rfp_test_mode_f.c")
endif()
endif()
#Add Cmake module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
#Precompile module
include(precompile_addon_rfp)
add_library(${PROJECT_NAME}_obj OBJECT EXCLUDE_FROM_ALL ${ADDON_RFP_SOURCES})
target_include_directories( ${PROJECT_NAME}_obj PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc
${SIGFOX_EP_LIB_DIR}/inc
)
target_compile_definitions(${PROJECT_NAME}_obj PUBLIC ${DEF_FLAG_LIST})
add_library(${PROJECT_NAME} STATIC ${PRECOMPIL_ADDON_RFP_SOURCES})
add_dependencies(${PROJECT_NAME} precompil_${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC ${PRECOMPIL_DIR}/inc)
target_compile_definitions(${PROJECT_NAME} PUBLIC ${DEF_FLAG_LIST})
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PRECOMPIL_ADDON_RFP_PUBLIC_HEADERS}")
set_target_properties(${PROJECT_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${LIB_LOCATION}
LIBRARY_OUTPUT_DIRECTORY ${LIB_LOCATION}
)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${LIB_LOCATION}
PUBLIC_HEADER DESTINATION ${API_LOCATION}
)