# 
# OSS-7 - An opensource implementation of the DASH7 Alliance Protocol for ultra
# lowpower wireless sensor communication
#
# Copyright 2015 University of Antwerp
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#This file contains helper MACRO's that are only available to code from the framework itself

# Override a specific component of the framework with alternative sources. 
# This MACRO is mainly intended to be used by individual platforms but can also be used by specific chip 
# implementations (useful for MCU's).
#
#
# Usage:
#    OVERRIDE_COMPONENT(component <source_file> <source_file> ...)
#
MACRO(OVERRIDE_COMPONENT component)
    SET_GLOBAL(FRAMEWORK_OVERRIDE_LIBS "${FRAMEWORK_OVERRIDE_LIBS};FRAMEWORK_COMPONENT_${component}")
    ADD_LIBRARY(FRAMEWORK_COMPONENT_${component} OBJECT ${ARGN})
    ADD_DEPENDENCIES(FRAMEWORK_COMPONENT_${component} PLATFORM)
    GET_PROPERTY(__global_include_dirs GLOBAL PROPERTY GLOBAL_INCLUDE_DIRECTORIES)
    TARGET_INCLUDE_DIRECTORIES(FRAMEWORK_COMPONENT_${component} PUBLIC	${__global_include_dirs})
ENDMACRO()

# Add one or more CMAKE variables as '#define' statements to the "framework_defs.h"
# generated by the FRAMEWORK_BUILD_SETTINGS_FILE MACRO. This MACRO adopts the same
# variable types used by the GEN_SETTINGS_HEADER MACRO. See the explanation of that macro
# in utils.cmake for more explanation.
#
# Usage:
#    FRAMEWORK_HEADER_DEFINE([STRING <string_var> <string_var> ...] [ID <id_var> <id_var> ...] [BOOL <bool_var> <bool_var> ...] [NUMBER <number_var> <number_var> ...])
#
MACRO(FRAMEWORK_HEADER_DEFINE)
    PARSE_HEADER_VARS("FRAMEWORK_EXTRA_DEFS" ${ARGN})
ENDMACRO()

# Construct a "framework_defs.h" header file in the binary 'framework' directory containing 
# The various (cmake) settings for the framework. By default an 'empty' header file is generated.
# Settings can be added to this file by calling the FRAMEWORK_HEADER_DEFINES macro.
#
# Usage:
#    FRAMEWORK_BUILD_SETTINGS_FILE()
#
MACRO(FRAMEWORK_BUILD_SETTINGS_FILE)
    GEN_SETTINGS_HEADER("${CMAKE_CURRENT_BINARY_DIR}/framework_defs.h" 
			STRING "${FRAMEWORK_EXTRA_DEFS_STRING}" 
			BOOL "${FRAMEWORK_EXTRA_DEFS_BOOL}" 
			ID "${FRAMEWORK_EXTRA_DEFS_ID}"
			NUMBER "${FRAMEWORK_EXTRA_DEFS_NUMBER}" 
			)			
    SET_GLOBAL(FRAMEWORK_EXTRA_DEFS_STRING "")
    SET_GLOBAL(FRAMEWORK_EXTRA_DEFS_BOOL "")
    SET_GLOBAL(FRAMEWORK_EXTRA_DEFS_ID "")
    SET_GLOBAL(FRAMEWORK_EXTRA_DEFS_NUMBER "")
ENDMACRO()
