From 64ebe5f323878158785bbe76c09c8ac4e83623a3 Mon Sep 17 00:00:00 2001
From: Romain Forlot <romain.forlot@iot.bzh>
Date: Fri, 18 Aug 2017 16:33:18 +0200
Subject: Change how to define compile options

Move specific compilation options to the target it is related
keep global compilation option in config.cmake then
variable can be correctly evaluated and use with the correct
values (CMAKE_INSTALL_PREFIX isn't the same before common.cmake
inclusion and after.)

Change-Id: Ia3c3fe6bc6fcdcb79858f233b108b9ee1e071131
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
---
 CMakeLists.txt | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1b430b..c128184 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,10 +16,24 @@
 # limitations under the License.
 ###########################################################################
 
-# Include LUA only when requested    
+ADD_COMPILE_OPTIONS(-DCONTROL_ONLOAD_DEFAULT="onload-default")
+
+ADD_COMPILE_OPTIONS(-DCONTROL_DOSCRIPT_PRE="doscript")
+ADD_COMPILE_OPTIONS(-DCONTROL_CONFIG_PRE="onload")
+ADD_COMPILE_OPTIONS(-DCONTROL_CONFIG_POST="control")
+ADD_COMPILE_OPTIONS(-DCONTROL_CONFIG_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/config.d:${CMAKE_INSTALL_PREFIX}/controller/config.d")
+ADD_COMPILE_OPTIONS(-DCTL_PLUGIN_MAGIC=2468013579)
+ADD_COMPILE_OPTIONS(-DCONTROL_PLUGIN_PATH="${CMAKE_BINARY_DIR}:${CMAKE_INSTALL_PREFIX}/controller/plugin:/usr/lib/afb/controller/ctlplug")
+
+# Include LUA only when requested
 if(CONTROL_SUPPORT_LUA)
    message(STATUS "Notice: LUA Controler Support Selected")
    set(CTL_LUA_SOURCE ctl-lua.c)
+   ADD_COMPILE_OPTIONS(-DCONTROL_SUPPORT_LUA)
+   ADD_COMPILE_OPTIONS(-DCONTROL_LUA_EVENT="luaevt")
+   ADD_COMPILE_OPTIONS(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/lua.d:${CMAKE_INSTALL_PREFIX}/controller/ctl-lua.d")
+else(CONTROL_SUPPORT_LUA)
+   message(STATUS "Warning: LUA Without Support ")
 endif(CONTROL_SUPPORT_LUA)
 
 # Add target to project dependency list
-- 
cgit