Add cmake native/cross build flag (#83)
author박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 20 Mar 2018 00:44:29 +0000 (09:44 +0900)
committer서상민/동작제어Lab(SR)/Senior Engineer/삼성전자 <sangmin7.seo@samsung.com>
Tue, 20 Mar 2018 00:44:29 +0000 (09:44 +0900)
This will add a flag to determine native or cross build
And with this flag this patch will fix build for protobuf and graphdef

CMakeLists.txt
externals/CMakeLists.txt

index 69d2c20..e8b534a 100644 (file)
@@ -34,6 +34,13 @@ else()
   message(FATAL_ERROR "'${TARGET_ARCH}' architecture is not supported")
 endif()
 
+# Determine native or cross build
+if("${HOST_ARCH}" STREQUAL "${TARGET_ARCH}")
+  set(BUILD_IS_NATIVE True)
+else()
+  set(BUILD_IS_NATIVE False)
+endif()
+
 # TODO add Tizen
 # We don't allow cross-os build now
 set(HOST_OS "linux")
index adacdce..a7ef719 100644 (file)
@@ -29,7 +29,7 @@ target_include_directories(eigen3 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/eigen")
 # Protocol Buffer (>= 3.5.1)
 #
 # TODO add protobuf for arm cross build
-if(ROOTFS_ARM STREQUAL "")
+if(BUILD_IS_NATIVE AND NOT HOST_ARCH_BASE STREQUAL "arm")
   set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build tests" FORCE)
 
   add_subdirectory(protobuf/cmake)