CPU specific compiler flags

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CPU specific compiler flags

Ciccio Pasticcio
Hi all,

I'm refactoring some libraries cmake files to be compliant to the use of targets instead of tons of variables. Since these libraries are cross-compiled I'm facing some problem finding how to properly set some specific flags like: -march -marm -mfloat-abi etc. For now I set the CMAKE_CXX_FLAGS:

set(CMAKE_CXX_FLAGS -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -Wno-psabi)

Is this the only way to do this? With targets I do something like this:

add_library(MyLib)
# add sources
...
# Comiler features
TARGET_COMPILE_FEATURES(MyLib PUBLIC cxx_lambdas)

Thanks,
Gabriele

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: CPU specific compiler flags

Eric Noulard


Le lun. 26 nov. 2018 à 09:36, Ciccio Pasticcio <[hidden email]> a écrit :
Hi all,

I'm refactoring some libraries cmake files to be compliant to the use of targets instead of tons of variables. Since these libraries are cross-compiled I'm facing some problem finding how to properly set some specific flags like: -march -marm -mfloat-abi etc. For now I set the CMAKE_CXX_FLAGS:

set(CMAKE_CXX_FLAGS -march=armv7-a -marm -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a8 -Wno-psabi)

Is this the only way to do this?

I'm not sure to understand, you can perfectly setup flags on a target specific way using 'target_compile_option'

If all your libraries are in a common directory you can use, COMPILE_OPTIONS property on the directory
to avoid repetition for each lib.

All that said, if you are cross-compiling those I bet you are using a toolchain file (https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling)
so if those "target-specific" compile options are global to your target then you may set
in the toolchain.

--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake