emp-tool icon indicating copy to clipboard operation
emp-tool copied to clipboard

Remove c++11 as compilers have beyond it by default

Open mdas7 opened this issue 3 years ago • 6 comments

Moving the -std=c++11 flag to build files for this project only. emp-base.cmake get imported by static libraries and flags for older version is difficult to override at times.

Projects consuming this library can limit to specific C++ standard version using:

set(CMAKE_CXX_STANDARD 11) # or 17 or 20, etc.

mdas7 avatar Jul 11 '22 17:07 mdas7

I'm a bit confused. If you add --std=c++14 in your code, would it use 14 or 11?

wangxiao1254 avatar Jul 15 '22 03:07 wangxiao1254

I'm a bit confused. If you add --std=c++14 in your code, would it use 14 or 11?

With current setup it will still end up as 11. After this fix, it would use 14. Ideally 'set(CMAKE_CXX_STANDARD ##)' is better way to setup cmake.

mdas7 avatar Jul 18 '22 05:07 mdas7

Would it work if I put set(CMAKE_CXX_STANDARD 11) in emp-base.cmake? I'm just trying to see if there is a way to enforce a minimum level of C++ standard. It appears that CMAKE_CXX_STANDARD sets the default level of standard and you can overwrite it later on?

wangxiao1254 avatar Jul 18 '22 19:07 wangxiao1254

I have tested on multiple platforms but I cannot reproduce it. In particular, with the current code, when I add -std=c++17, the code will be compiled with 17.

wangxiao1254 avatar Jul 20 '22 04:07 wangxiao1254

Where are you adding -std=c++17? Adding it here might work, but if this library is hard-coding c++11 then code which is building with this a static library runs into c++11 as this library's make file includes are hard-coding it.

Would it work if I put set(CMAKE_CXX_STANDARD 11) in emp-base.cmake? That would also make this library hard-code this requirement. Can you make it configurable instead then?

mdas7 avatar Jul 21 '22 16:07 mdas7

Please look at the latest version if that works. You can now specify the default standard by using, e.g., cmake -DCMAKE_CXX_STANDARD=14 ..

wangxiao1254 avatar Jul 21 '22 16:07 wangxiao1254