[CMake] target_compile_features() uses incorrect C++ version

Deniz Bahadir deniz.bahadir at benocs.com
Wed Dec 5 08:49:15 EST 2018


Am 05.12.18 um 14:37 schrieb Kim Walisch:
> OK thanks, I have created a new issue at:
> https://gitlab.kitware.com/cmake/cmake/issues/18686
> 
> Greetings,
> Kim

Thanks, great.

Best regards,
Deniz

PS: Next time better answer to the mailing-list. ;-) This is probably 
interesting for others that read your first email on the list, too.


> 
> On Wed, Dec 5, 2018 at 2:26 PM Deniz Bahadir <dbahadir at benocs.com 
> <mailto:dbahadir at benocs.com>> wrote:
> 
>     Am 05.12.18 um 13:40 schrieb Kim Walisch:
>      > Hi,
>      >
>      > I have realized that my C++ primesieve project
>      > (https://github.com/kimwalisch/primesieve) is
>      > compiled using -std=gnu++11 with GCC 7.3 and CMake 3.10 (on
>     Ubuntu 18.10
>      > x64) even
>      > though the default C++ version used by GCC 7.3 is C++14 as
>     checked below:
>      >
>      > $ g++ -dM -E -x c++  /dev/null | grep -F __cplusplus
>      > #define __cplusplus 201402L
>      >
>      > Note that I have not set CXX_STANDARD manually in my
>     CMakeLists.txt so I
>      > was expecting
>      > that my project would be compiled either with -std=gnu++14 or
>     without
>      > any C++ version flag.
>      > I spent some time investigating where the -std=gnu++11 flag comes
>     from
>      > and I found that it is
>      > related to the use of target_compile_features():
>      >
>      > target_compile_features(primesieve PRIVATE cxx_auto_type)
>      >
>      > This code tells the compiler that my program uses features from
>     C++11
>      > and that the compiler
>      > should enable C++11 if the default C++ version of the compiler is
>     e.g.
>      > C++98. I would
>      > however expect that if the default C++ version of the compiler is >
>      > C++11 CMake would not
>      > add -std=gnu++11 to the compiler flags.
>      >
>      > For me this is a CMake bug.
>      >
>      > Thanks,
>      > Kim Walisch
>      >
> 
>     Hi Kim,
> 
>     this does indeed sound like some unwanted behavior.
> 
>     I recommend you open an issue in CMake's issue-tracker
>     (https://gitlab.kitware.com/cmake/cmake/issues) and copy your
>     email-content there.
> 
>     Best regards,
>     Deniz Bahadir
> 
>     -- 
> 
>     Powered by www.kitware.com <http://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
> 

-- 
BENOCS GmbH
Dipl.-Inform. Deniz Bahadir
Reuchlinstr. 10 D
10553 Berlin
Germany
Phone: +49 - 30 / 577 0004-22
Email: deniz.bahadir at benocs.com
www.benocs.com

Board of Management: Stephan Schröder, Dr.-Ing. Ingmar Poese
Commercial Register: Amtsgericht Bonn HRB 19378


More information about the CMake mailing list