Unfortunately, the standard values for CMAKE_BUILD_TYPE only have their first letter capitalized, i.e. for a release build CMAKE_BUILD_TYPE will normally be "Release". To use it like you want to, it would need to be "RELEASE". To get around this problem, we define an all upper-case BUILD_TYPE in our projects, i.e.:

string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
message(STATUS "CXX compiler ${CMAKE_BUILD_TYPE} build options: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")

If you do this, keep in mind what fdk17 said - CMAKE_BUILD_TYPE may not be set depending on the generator you use.

Am 27.09.19 um 22:18 schrieb Zdenko Podobny:
Hello,

I try to print CMAKE_CXX_FLAGS_DEBUG/CMAKE_CXX_FLAGS_RELEASE as one line statement but is does not work for me:

message( STATUS "CXX compiler ${CMAKE_BUILD_TYPE} build options: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")

Produce empy result, but
message( STATUS "CXX compiler  Release build options: ${CMAKE_CXX_FLAGS_RELEASE}")
works as expected.
Is it possible to do it in one line or I have to use if/elseif ?

Zdenko

--

*Dr. Eric Dönges*
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
[email protected] <mailto:[email protected]> | Tel: +49 89 457 695-0 | www.mvtec.com <http://www.mvtec.com>

Find our privacy policy here <https://www.mvtec.com/imprint>.

Sign up <https://www.mvtec.com/newsletter> for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

MVTec Software GmbH Logo
-- 

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 via email to