Git Product home page Git Product logo

Comments (3)

martinus avatar martinus commented on May 20, 2024

Hi @nyronium , thanks for the detailed description! I've tried to add a library definition as you've described, but I'm not really experienced with cmake so I'm not sure if it works as it should. Can you give it a try? It's only in master for now.

from robin-hood-hashing.

oddlama avatar oddlama commented on May 20, 2024

@martinus Thanks for implementing this, I really appreciate it! Your changes are mostly fine, though there are just two small things that kind of prevent using your library properly. Both of them are easily fixed though.

Wrong compile option

target_compile_features(robin_hood INTERFACE ${RH_cxx_standard})

This line breaks compilation, as it requests a feature called "14", which is not a thing.
To do this properly, use cxx_std_14 instead of ${RH_cxx_standard}. Usually you don't have to store the required standard in a variable, as it can be deduced from the dependencies of a target and its compile options.

-target_compile_features(robin_hood INTERFACE ${RH_cxx_standard})
+target_compile_features(robin_hood INTERFACE cxx_std_14)

cxx_std_14 is a compile_feature offered by cmake to require c++14 for your target.
This is where it would come in handy if you had used the target in your local tests.
Then you could completely delete the RH_cxx_standard variable, and CMake would figure it out automatically.

Global CMAKE state

set(CMAKE_CXX_STANDARD ${RH_cxx_standard})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Setting global cmake variables is generally not a good practice, as it alters the global state for the whole project, not just for your definitions. In this case it will change the default standard for newly created targets, disable fallback to older standards and disable the use of any c++ extensions (such as gnu++14, ...).

Either way you can (and should) completely delete these lines, and instead either use the exported target as a dependency in your test target, or alternatively you can simply replace ${RH_cxx_standard} with cxx_std_14 in your test CMake files.

FYI (CMake intro)

I can understand that CMake does not seem very intuitive in the beginning, so
as you have said that you are not really experienced in CMake, I really want to recommend you to read through this short Introduction to modern CMake.

Especially the paragraphs "Dos and Don'ts", and "How to structure your project" might provide some useful insights.

I think adhering to some of those rules could both greatly simplify your setup and make it intuitive for other CMake users to use your project.

Even in case you don't want to change your structure, it will certainly give you a good understanding of basic CMake and why things are usually done a certain way. I hope you'll find useful!

from robin-hood-hashing.

martinus avatar martinus commented on May 20, 2024

Ok I think I got it now. I've got a minimal example in src/external_cmake that makes use of the library, and it seems to work for me. Thanks again!

from robin-hood-hashing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.