Skip to content

Conversation

@mdas7
Copy link

@mdas7 mdas7 commented Jul 11, 2022

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.

@wangxiao1254
Copy link
Member

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

@mdas7
Copy link
Author

mdas7 commented Jul 18, 2022

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.

@wangxiao1254
Copy link
Member

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
Copy link
Member

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.

@mdas7
Copy link
Author

mdas7 commented Jul 21, 2022

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?

@wangxiao1254
Copy link
Member

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 ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants