Ask Your Question
0

What better way of passing extra parameters to compile?

asked 2016-10-15 23:15:01 -0600

updated 2016-10-16 00:09:48 -0600

I am compiling OpenCV in order to make it more optimized possible to run on Cortex-A53 processor in a NanoPI M3 produced by FriendlyARM.

I have used in my projects the following keys:

-mtune=cortex-a53 -mcpu=cortex-a53 -mfloat-abi=hard -march=armv8-a+crc

Enabling the CMake with the following option besides "ENABLE_NEON = ON:

 -D EXTRA_C_FLAGS_RELEASE="-mtune=cortex-a53 -mcpu=cortex-a53 -mfloat-abi=hard -march=armv8-a+crc"

I did not succeed because the OpenCV settings do not use it.

What better way of passing those extra parameters to compile?

I do this:

mkdir CortexA53Release
cd CortexA53Release
cmake -G "Unix Makefiles" \
 -D CMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabihf-g++ \
 -D CMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabihf-gcc \
 -D CMAKE_BUILD_TYPE=RELEASE-NANOPI \
 -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D WITH_TBB=ON \
 -D WITH_V4L=ON \
 -D WITH_QT=ON \
 -D WITH_OPENGL=ON \
 -D WITH_IMAGEIO=ON \
 -D WITH_GSTREAMER=ON \
 -D ENABLE_NEON=ON \
 -D ENABLE_FAST_MATH=ON \
 -D BUILD_SHARED_LIBS=OFF \
 -D BUILD_NEW_PYTHON_SUPPORT=OFF \
 -D BUILD_EXAMPLES=ON \
 -D BUILD_FAT_JAVA_LIB=OFF \
 -D BUILD_TBB=ON \
 -D INSTALL_C_EXAMPLES=ON \
 -D INSTALL_PYTHON_EXAMPLES=OFF \
 -D INSTALL_TO_MANGLED_PATHS=ON \
 -D INSTALL_CREATE_DISTRIB=ON \
 -D INSTALL_TESTS=ON \
 -D EXTRA_C_FLAGS_RELEASE="-mtune=cortex-a53 -mcpu=cortex-a53 -mfloat-abi=hard -march=armv8-a+crc" \
 -D EXTRA_CXX_FLAGS_RELEASE="-mtune=cortex-a53 -mcpu=cortex-a53 -mfloat-abi=hard -march=armv8-a+crc" \
 ..

And get:

...

-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    EXTRA_CXX_FLAGS_RELEASE
    EXTRA_C_FLAGS_RELEASE


-- Build files have been written to: /home/fa/Workspace/opencv/CortexA53Release
edit retag flag offensive close merge delete

Comments

1

isn't it CMAKE_CXX_FLAGS_RELEASE or CMAKE_C_FLAGS_RELEASE ?

berak gravatar imageberak ( 2016-10-15 23:58:58 -0600 )edit

@berak either both to the C as C ++..

CarlosDelfino gravatar imageCarlosDelfino ( 2016-10-16 00:03:42 -0600 )edit

yea, i think you need both CXX and C version

berak gravatar imageberak ( 2016-10-16 00:06:51 -0600 )edit
1

new update for make clear

CarlosDelfino gravatar imageCarlosDelfino ( 2016-10-16 00:10:05 -0600 )edit

hummmm, CMAKE.....

CarlosDelfino gravatar imageCarlosDelfino ( 2016-10-16 00:10:41 -0600 )edit
1

i still think, you need tp replace EXTRA with CMAKE , to make it happy

berak gravatar imageberak ( 2016-10-16 00:17:28 -0600 )edit

And I need tool extra flags for LD.

CarlosDelfino gravatar imageCarlosDelfino ( 2016-10-16 00:40:14 -0600 )edit

^^ mind, if i convert your comment to an answer, then ?

berak gravatar imageberak ( 2016-10-16 01:18:39 -0600 )edit
1

@berak I'll do it tomorrow or on Monday without fail.

I'm finishing the build and will do some tests to see if everything is ok.

not appear the parameters for the Linker, I need to make sure that the result was positive.

Thank you for guidance.

CarlosDelfino gravatar imageCarlosDelfino ( 2016-10-16 01:21:00 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-10-18 12:37:05 -0600

The solution to this question is quite simple as suggested in the comments, be resolved by reading the CMake manual follows the summary of what I learned on the subject:

Just replace "EXTRA_" to "CMAKE_" in the name of the variable that parameterize the cmake command:

CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE

He does not use these post-fixed variables "_Release" or even "_DEBUG" the joint compilation, unless the variable CMAKE_BUILD_TYPE is used to determine the type of compilation to be done, selecting the appropriate setting for each use.

So the solution to pass extra parameters to compile OpenCV is using the variables:

CMAKE_CXX_FLAGS

    CMAKE_C_FLAGS

In addition it may be required for additional parameters to the linking process to use that variable:

CMAKE_EXE_LINKER_FLAGS

More information can be found at:

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-10-15 23:15:01 -0600

Seen: 1,173 times

Last updated: Oct 18 '16