test_compile with compiler flags

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

test_compile with compiler flags

Dustyn Blasig
Hi All,

I'm sure there is a way to do this, but I'm not seeing it. I need to test a compiler flag to know whether to enable it for our entire build. So I had planned on using test_compile(), but I don't see a way to pass additional compiler flags to test_compile() through CMAKE_FLAGS and there's no option to pass environment variables like CXXFLAGS with test_compile().

Also, when do the variables like CMAKE_CXX_FLAGS get set? I enable the CXX language and specify a required support for C++11, but if I dump CMAKE_CXX_FLAGS right after that there are no options such as -std=c++11 in the variable. I thought I could do something like ..

try_compile(.. CMAKE_FLAGS -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} <extra args>" ..)

... but CMAKE_CXX_FLAGS is empty as described above so I get errors about the compiler not supported C++11 features since -std=c++11 wasn't set.

Is there an example of testing a compiler flag I could try?



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: