• Harris Hancock's avatar
    Use target_compile_features to request C++11 · 1d0d1c3b
    Harris Hancock authored
    Projects which use Cap'n Proto require C++11, because they must be able to
    compile our headers. Old gcc defaults to C++98, forcing users to manually
    specify the -std=gnu++11 flag in their CMake projects. CMake 3.1
    introduced the target_compile_features command which removes this
    necessity by automatically communicating the C++ standard level
    requirement to client projects.
    
    Specifically, if target `kj` requires a C++11 feature publicly, then all
    targets which link to `kj` will also require that C++11 feature, and get
    the -std=gnu++11 flag for free. If that target is a library, such as
    `kj-async`, and `kj-async` links publicly to `kj`, the requirement is also
    transitive to all targets which link to `kj-async`.
    
    Note that CMake's default behavior is to request compiler-specific
    extensions, such as those provided by the -std=gnu++11 flag. You must
    specifically opt out of these extensions. I'm not aware of any way to
    propagate this nuance in CMake, but added a check to at least prevent
    users from compiling Cap'n Proto without extensions.
    
    With this change, the c++/samples/CMakeLists.txt will build with MinGW
    with no change beyond requiring a later version of CMake.
    1d0d1c3b
CMakeLists.txt 4.57 KB