shithub: tinygl

Download patch

ref: e50ca7681754f98085e41c7f0f5701749151a819
parent: b833e3a78434e4956e434a9e86781b879c2d6f96
author: Cameron Cawley <ccawley2011@gmail.com>
date: Mon Sep 6 17:02:16 EDT 2021

Avoid building with -march=native when cross-compiling

--- a/SDL_Examples/CMakeLists.txt
+++ b/SDL_Examples/CMakeLists.txt
@@ -17,7 +17,10 @@
       target_link_libraries(${DEMO_NAME} ${TINYGL_LIB} ${M_LIBRARY} ${SDL_LIBRARY})
       target_include_directories(${DEMO_NAME} PUBLIC ${SDL_INCLUDE_DIR})
       if(NOT MSVC)
-	target_compile_options(${DEMO_NAME} PRIVATE -O3 -DNDEBUG -pedantic -march=native -Wall)
+        target_compile_options(${DEMO_NAME} PRIVATE -O3 -DNDEBUG -pedantic -Wall)
+        if(NOT CMAKE_CROSSCOMPILING)
+          target_compile_options(tinygl PRIVATE -march=native)
+        endif(NOT CMAKE_CROSSCOMPILING)
       endif(NOT MSVC)
     endforeach()
 
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,7 +36,10 @@
     LIBRARY DESTINATION ${LIB_DIR}
     ARCHIVE DESTINATION ${LIB_DIR})
   if(NOT MSVC)
-    target_compile_options(tinygl PRIVATE -O3 -DNDEBUG -pedantic -march=native -Wall -Wno-unused-function)
+    target_compile_options(tinygl PRIVATE -O3 -DNDEBUG -pedantic -Wall -Wno-unused-function)
+    if(NOT CMAKE_CROSSCOMPILING)
+      target_compile_options(tinygl PRIVATE -march=native)
+    endif(NOT CMAKE_CROSSCOMPILING)
   endif(NOT MSVC)
 endif(TINYGL_BUILD_SHARED)
 
@@ -48,7 +51,10 @@
     LIBRARY DESTINATION ${LIB_DIR}
     ARCHIVE DESTINATION ${LIB_DIR})
   if(NOT MSVC)
-    target_compile_options(tinygl-static PRIVATE -O3 -DNDEBUG -pedantic -march=native -Wall -Wno-unused-function)
+    target_compile_options(tinygl-static PRIVATE -O3 -DNDEBUG -pedantic -Wall -Wno-unused-function)
+    if(NOT CMAKE_CROSSCOMPILING)
+      target_compile_options(tinygl-static PRIVATE -march=native)
+    endif(NOT CMAKE_CROSSCOMPILING)
   endif(NOT MSVC)
 endif(TINYGL_BUILD_STATIC)