On 10/09/2013 10:44 AM, Stephen Kelly wrote:
> if(NOT needs17 EQUAL -1)
> set(standard 17)
> elseif(NOT needs14 EQUAL -1)
> set(standard 14)
> elseif(NOT needs11 EQUAL -1)
> set(standard 11)
> endif()
>
> # ...
> set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD ${standard})
This assumes a linear ordering among standards, which is true for the
actual standards, but may not be true for the compiler feature levels.
For example, the GNU compiler has a "gnu" variant branching off from
each standard level.
> This is where I have an open question in the branch:
>
> # TODO: Gnu extensions supported by -std=gnu++98 ?
> # And others.
> http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/C-Dialect-Options.html#C-Dialect-Options
Perhaps each feature can map to the minimum standard spec flag
it needs:
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_CXX_FEATURE_FLAG_final -std=c++11)
set(CMAKE_CXX_FEATURE_FLAG_override -std=c++11)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
set(CMAKE_CXX_FEATURE_FLAG_generalized_lambda_capture -std=c++1y)
set(CMAKE_CXX_FEATURE_FLAG_return_type_deduction -std=c++1y)
endif()
Then have a graph of flags subsuming others:
set(CMAKE_CXX_STANDARD_SUBSUMES_-std=c++1y -std=c++11)
Then from the needed features, their corresponding flags,
and the "subsume" graph, compute the possible flags.
Then provide a way for the project and/or user to specify
their preferred flag and use it or error if it is not one
of those possible. If no preference is given, choose the
"oldest" flag.
-Brad
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers