From 169259059ba57c97dfaf5d67e0022f379d95ba6a Mon Sep 17 00:00:00 2001
From: Mark Charlebois <charlebm@gmail.com>
Date: Fri, 15 Apr 2016 14:42:47 -0700
Subject: [PATCH] Updated cmake_hexagon and all the associated files that use
 it

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 cmake/configs/posix_eagle_default.cmake        |  3 ++-
 cmake/configs/posix_eagle_hil.cmake            |  2 ++
 cmake/configs/posix_eagle_muorb.cmake          |  4 +++-
 cmake/configs/posix_eagle_release.cmake        |  2 +-
 cmake/configs/qurt_eagle_default.cmake         | 17 +++++++----------
 cmake/configs/qurt_eagle_hello.cmake           |  8 +++++++-
 cmake/configs/qurt_eagle_hil.cmake             |  9 ++++++++-
 cmake/configs/qurt_eagle_muorb.cmake           |  8 +++++++-
 cmake/configs/qurt_eagle_release.cmake         |  2 +-
 cmake/configs/qurt_eagle_test.cmake            |  8 +++++++-
 cmake/configs/qurt_eagle_travis.cmake          |  3 ++-
 .../Toolchain-arm-linux-gnueabihf.cmake        |  2 +-
 src/firmware/posix/CMakeLists.txt              |  6 +++++-
 src/firmware/qurt/CMakeLists.txt               | 18 +++++++++++-------
 src/platforms/qurt/stubs/stubs_posix.c         |  4 ++++
 15 files changed, 68 insertions(+), 28 deletions(-)

diff --git a/cmake/configs/posix_eagle_default.cmake b/cmake/configs/posix_eagle_default.cmake
index 17cc9be561..d58b80d4a8 100644
--- a/cmake/configs/posix_eagle_default.cmake
+++ b/cmake/configs/posix_eagle_default.cmake
@@ -1,7 +1,8 @@
 include(posix/px4_impl_posix)
 
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(CONFIG_SHMEM "1")
 
diff --git a/cmake/configs/posix_eagle_hil.cmake b/cmake/configs/posix_eagle_hil.cmake
index cae322edb9..b856088b3f 100644
--- a/cmake/configs/posix_eagle_hil.cmake
+++ b/cmake/configs/posix_eagle_hil.cmake
@@ -1,5 +1,7 @@
 include(posix/px4_impl_posix)
 
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
+
 # Use build stubs unless explicitly set not to
 if("${DSPAL_STUBS_ENABLE}" STREQUAL "")
 	set(DSPAL_STUBS_ENABLE "1")
diff --git a/cmake/configs/posix_eagle_muorb.cmake b/cmake/configs/posix_eagle_muorb.cmake
index 813fbbfecb..576ddd3193 100644
--- a/cmake/configs/posix_eagle_muorb.cmake
+++ b/cmake/configs/posix_eagle_muorb.cmake
@@ -1,6 +1,8 @@
 include(posix/px4_impl_posix)
 
-set(CMAKE_TOOLCHAIN_FILE cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake)
+set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	drivers/device
diff --git a/cmake/configs/posix_eagle_release.cmake b/cmake/configs/posix_eagle_release.cmake
index ebe0593685..998c960f2b 100644
--- a/cmake/configs/posix_eagle_release.cmake
+++ b/cmake/configs/posix_eagle_release.cmake
@@ -4,7 +4,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linu
 
 set(CONFIG_SHMEM "1")
 
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	drivers/device
diff --git a/cmake/configs/qurt_eagle_default.cmake b/cmake/configs/qurt_eagle_default.cmake
index 07cae1573f..822d672038 100644
--- a/cmake/configs/qurt_eagle_default.cmake
+++ b/cmake/configs/qurt_eagle_default.cmake
@@ -1,19 +1,16 @@
 include(qurt/px4_impl_qurt)
 
-#if ("${HEXAGON_DRIVERS_ROOT}" #STREQUAL "")
-#	message(FATAL_ERROR "HEXAGON_DRIVERS_ROOT is not set")
-#endif()
-
-#if ("${EAGLE_DRIVERS_SRC}" STREQUAL "")
-#	message(FATAL_ERROR "EAGLE_DRIVERS_SRC is not set")
-#endif()
-
-#include_directories(${HEXAGON_DRIVERS_ROOT}/inc)
+if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
+	message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
+else()
+	set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
+endif()
 
 set(CONFIG_SHMEM "1")
 
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	#
diff --git a/cmake/configs/qurt_eagle_hello.cmake b/cmake/configs/qurt_eagle_hello.cmake
index 3427746a1d..972eeb294e 100644
--- a/cmake/configs/qurt_eagle_hello.cmake
+++ b/cmake/configs/qurt_eagle_hello.cmake
@@ -1,8 +1,14 @@
 include(qurt/px4_impl_qurt)
 
+if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
+	message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
+else()
+	set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
+endif()
+
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
 
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	drivers/device
diff --git a/cmake/configs/qurt_eagle_hil.cmake b/cmake/configs/qurt_eagle_hil.cmake
index a3759fc97d..0770c767c0 100644
--- a/cmake/configs/qurt_eagle_hil.cmake
+++ b/cmake/configs/qurt_eagle_hil.cmake
@@ -1,7 +1,14 @@
 include(qurt/px4_impl_qurt)
 
+if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
+	message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
+else()
+	set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
+endif()
+
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	drivers/device
diff --git a/cmake/configs/qurt_eagle_muorb.cmake b/cmake/configs/qurt_eagle_muorb.cmake
index 0da1fdb1a7..285d804d70 100644
--- a/cmake/configs/qurt_eagle_muorb.cmake
+++ b/cmake/configs/qurt_eagle_muorb.cmake
@@ -1,8 +1,14 @@
 include(qurt/px4_impl_qurt)
 
+if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
+	message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
+else()
+	set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
+endif()
+
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
 
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	drivers/device
diff --git a/cmake/configs/qurt_eagle_release.cmake b/cmake/configs/qurt_eagle_release.cmake
index fd5a7838d9..62619a4b15 100644
--- a/cmake/configs/qurt_eagle_release.cmake
+++ b/cmake/configs/qurt_eagle_release.cmake
@@ -29,7 +29,7 @@ set(QURT_ENABLE_STUBS "0")
 set(CONFIG_SHMEM "1")
 
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	#
diff --git a/cmake/configs/qurt_eagle_test.cmake b/cmake/configs/qurt_eagle_test.cmake
index 3602056e01..1597d7f4f2 100644
--- a/cmake/configs/qurt_eagle_test.cmake
+++ b/cmake/configs/qurt_eagle_test.cmake
@@ -1,7 +1,13 @@
 include(qurt/px4_impl_qurt)
 
+if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
+	message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
+else()
+	set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
+endif()
+
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 set(config_module_list
 	drivers/device
diff --git a/cmake/configs/qurt_eagle_travis.cmake b/cmake/configs/qurt_eagle_travis.cmake
index 01956337e5..332fbcb1a4 100644
--- a/cmake/configs/qurt_eagle_travis.cmake
+++ b/cmake/configs/qurt_eagle_travis.cmake
@@ -6,7 +6,8 @@ set(CONFIG_SHMEM "1")
 set(QURT_ENABLE_STUBS "1")
 
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/toolchain/Toolchain-qurt.cmake)
-include(${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon/qurt_app.cmake)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
 
 if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
 	message(FATAL_ERROR "Enviroment variable HEXAGON_SDK_ROOT must be set")
diff --git a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake
index 3e331fe2fa..cfac028903 100644
--- a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake
+++ b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake
@@ -20,7 +20,7 @@ include(CMakeForceCompiler)
 if ("$ENV{HEXAGON_SDK_ROOT}" STREQUAL "")
         message(FATAL_ERROR "HEXAGON_SDK_ROOT not set")
 else()
-        set(HEXAGON_TOOLS_ROOT $ENV{HEXAGON_SDK_ROOT})
+        set(HEXAGON_SDK_ROOT $ENV{HEXAGON_SDK_ROOT})
 endif()
 
 if ("$ENV{HEXAGON_ARM_SYSROOT}" STREQUAL "")
diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt
index a87809d7bf..f1c87d14e6 100644
--- a/src/firmware/posix/CMakeLists.txt
+++ b/src/firmware/posix/CMakeLists.txt
@@ -5,10 +5,14 @@ px4_posix_generate_builtin_commands(
 	MODULE_LIST ${module_libraries})
 
 if ("${BOARD}" STREQUAL "eagle")
+
+	include(fastrpc)
+	include(linux_app)
+
 	FASTRPC_STUB_GEN(../qurt/px4muorb.idl)
 
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes -Wno-missing-declarations")
-	QURT_APP(
+	LINUX_APP(
 		APP_NAME mainapp
 		IDL_NAME px4muorb
 		APPS_DEST "/home/linaro"
diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt
index 2687a84e32..fe07f6e989 100644
--- a/src/firmware/qurt/CMakeLists.txt
+++ b/src/firmware/qurt/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/cmake_hexagon")
+include(fastrpc)
+include(qurt_lib)
+
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes")
@@ -33,16 +37,16 @@ else()
 	message("df_driver_libs = ${df_driver_libs}")
 	# Generate the DSP lib and stubs but not the apps side executable
 	# The Apps side executable is generated via the posix_eagle_xxxx target
-	QURT_LIB(APP_NAME mainapp
+	QURT_LIB(LIB_NAME mainapp
 		IDL_NAME px4muorb
 		SOURCES
-		${CMAKE_BINARY_DIR}/apps.h
+			${CMAKE_BINARY_DIR}/apps.h
 		LINK_LIBS
-		${module_libraries}
-		${target_libraries}
-		df_driver_framework
-		${df_driver_libs}
-		m
+			${module_libraries}
+			${target_libraries}
+			df_driver_framework
+			${df_driver_libs}
+			m
 		)
 
 	px4_add_adb_push(OUT upload
diff --git a/src/platforms/qurt/stubs/stubs_posix.c b/src/platforms/qurt/stubs/stubs_posix.c
index bc21907a93..16514aa72f 100644
--- a/src/platforms/qurt/stubs/stubs_posix.c
+++ b/src/platforms/qurt/stubs/stubs_posix.c
@@ -148,3 +148,7 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
 	return -1;
 }
 
+int fsync(int fd)
+{
+	return -1;
+}
-- 
GitLab