-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better and more intuitive settings for C++11 and C++14 with different variants #10
Comments
I like the option of putting it in the biicode.conf. I don't see the need to put
And it would pick the latest possible. This is very common in the libraries I write. I usually have this in my CMake files:
Wouldn't this be just an implementation detail? So in newer versions biicode, if the user is requesting C++11 in biicode.conf it would just wire to whichever implementation would get the job done(Perhaps its Either way, the biicode.conf should support more than just C++11 and C++03. |
Yes, I would say this is a nice approach, thanks! I like also the "latest", and including the check_compiler_flag. I thing that new CMake >3.1 compile_features can help with this, but have to check. The PUBLIC option was intended for the use case when your interface for consumers is <C++11, but the internals of it are >=C++11, for example. Then you want to activate C++11 only in your current library, but your consumers are OK without it. I think this is possible, but not fully sure about the ABI, have to check. Maybe, assume the default is PUBLIC, no need to define it, and could implement optional PRIVATE just for this case if it is in fact possible. |
Well I would prefer not to write out compiler features, although some users may want to do that. The user could list either compiler features:
or standards(or
Of course, if a language standard is specified, it should be used to enable the language on compilers that allow for it to be optionally enabled. So if I specify C++11 or C++03, the library should still compile on MSVC even though it is not a C++03 nor a C++11 compiler. |
Yes, I was exactly analyzing that just now, and thought about the same interface. But trying out CMake, there are two ways to do exactly that to which both options would translate nicely:
or
The first one can be defined PUBLIC/PRIVATE/INTERFACE, thus applied easily where you want. But does not account for general C++11. I dislike having to define individual features. Furthermore, it is failing in MinGW, tried both 4.8 and 4.9, it seems that still not has support for MinGW, Visual... http://stackoverflow.com/questions/28119552/no-known-features-for-cxx-compiler-when-compiling-with-msvc-2013 The second one is what we want, but has 2 problems: cannot be defined PUBLIC/PRIVATE and cannot be applied to INTERFACE targets, thus it is not suitable for header only libs. I have posted the question in SO: http://stackoverflow.com/questions/29687331/how-to-define-transitive-cxx-standard-c11-in-cmake |
I still think that solving cmake UX issues via a custom DSL on top of it is not a good idea. Having a Let's say a block with the following settings: if(BIICODE)
if((CMAKE_CXX_COMPILER_ID MATCHES "gcc") OR (CMAKE_CXX_COMPILER_ID MATCHES "clang"))
target_compile_options(${BII_BLOCK_TARGET} INTERFACE
-std=c++1y
$<$<CONFIG:Debug>:-g3 -O0 -fstack-protector>
$<$<CONFIG:Release>:-g0 -O2>)
else()
...
endif()
endif() I don't see the point of having |
Then, why Kitware and CMake is developing TARGET_COMPILE_FEATURES (new from cmake 3.1) and supporting the CXX_STANDARD variable? |
Because biicode can better propagate the setting. If library A uses
First, those settings are already added by default to cmake. Secondly, optimizations settings are optional, and are not need to compile the program. |
I agree with @pfultz2, optimizations and the standard requirement, they are completely different things, and setting C++ standards is still not a solved problem, thats why CMake is evolving to address this issue with compile_features, though still not reliable enough. So it makes sense to define a simple conf for it (in biicode.conf) and let the internal implementation do it. Now that implementation is open source, it is easier to fix in case of problems, and can more easily evolve and mature with the help of users. Lets keep with it @franramirez688 , in any case it is totally a opt-in feature, lets do it and check if users like it, if there are too many problems, etc. Thanks! |
@pfultz2: I've implemented this feature (you can see part of the total code on this PR) and it is based on your system to get the most appropriate flag. So, we've got doubts about the problem of how CMake performs transitive My block is
And my own:
Then, my std flag will be overridden by my dependent block
Comes to your mind another way more straightforward? Thanks a lot in advance! |
Well biicode should compile all blocks(and dependents) using the most modern flag requested by all blocks(it will be the most modern flag allowed by the user's compiler if one of the blocks requested
Then
Now
Well Diego mentioned |
Ok! I'll implement something like that ;) For now, I'm using Thanks a lot for reporting your opinion! |
Currently, configuring some library/block to use C++11/14 is a bit complex. There are several options:
1-. Native use of CMake. It can require some conditionals for MultiOS
2-. Use an existing CMake macro, possibly one existing in biicode and retrieved as dependency:
This one requires one bii find or [requirements] to be written.
PROPOSAL:
From my point of view, it is still a bit complex, so I propose a high level definition, in biicode.conf, something like:
That would be translated to a cmake variable, and biicode, checking that variable would automatically call something in the line of ACTIVATE_CPP11. Surely we have to check for CMake compile features as solution for this, instead of bare compile options.
Pros:
Cons:
The text was updated successfully, but these errors were encountered: