Reputation: 10868
I need to compile OpenCV for i486 architecture. I would like to set optimization flags to O3. The problem is that can't find a way to set compiler flags in cmake file or with configuration script.
Upvotes: 1
Views: 6437
Reputation: 871
./opencv/cmake/OpenCVCompilerOptions.cmake
Line 29:
set(OPENCV_EXTRA_FLAGS_RELEASE "-O3")
Note the overrides at the top though.
Upvotes: 1
Reputation: 32923
CMake allows you to set your compiler flags on a configuration basis. By default, if you choose the Release configuration, the optimization flags will probably be enabled. If you want to turn them on yourself, use:
set(CMAKE_C_FLAGS_RELEASE "-O3")
and choose the Release configuration (you could also do this using the Cache or the GUI):
set(CMAKE_BUILD_TYPE Release)
NB: replace C by CXX if you use C++
Upvotes: 6
Reputation: 14021
I believe you can either set the CFLAGS
or CXXFLAGS
as environment variables before you run cmake
. Alternatively, have a look at using the CMAKE_C_FLAGS inside the relevant CMakeLists.txt files.
Hope that helps!
Upvotes: 1