I'm new to cmake, recently, my program cannot run on another device and I find that reason is compile flag -march=native
silently added (found PCL
library do it), I verify it by modifying value of -march
from native to x86-64 CXX_FLAGS
in flags.make (hacking this file because I cannot find a way to change it within cmake file by setting CMAKE_CXX_FLAGS or add_compile_options).
One word, that compile flag -march=native
is added by PCL
library by find_package.
QUESTION
I want change it to -march=x86-64
in cmake, How to do it?
Ps: Tried adding -march=x86-64
to CMAKE_CXX_FLAGS
or add_compile_options
, not working by inspecting flags.make in which CXX_FLAGS
is:
CXX_FLAGS = -march=x86-64 -O3 -DNDEBUG -fPIC -march-native -msse4.2 -mfpmath=sse -std=gnu++14
and the letter -march=native
wins.
First of all, thanks @Tsyvarev and @Lack for useful suggestions.
I solved that problem by recompile
PCL
from stretch by adding-DPCL_ENABLE_MARCHNATIVE=False -DPCL_ENABLE_SSE=False ..
as following command:This can eliminate
-march=native
from final flags, which will work on other devices and I test it.Besides, someone says only
-DPCL_ENABLE_SSE=False
is needed due to minePCL
version is1.10.1
andPCL_ENABLE_MARCHNATIVE
was not introduced yet. But I haven't tried this.