Skip to content
Snippets Groups Projects

Wolf macro cmake conftime

Merged Jeremie Deray requested to merge wolf_macro_cmake_conftime into master

This pr add a config.h file (template at src/internal/config.h.in) which is set at cmake configure time - before building.

This allows to define/set pre-processing macro before compilation.

A simple example is also available here.

For instance it allows enabling / disabling _WOLF_DEBUG token.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Developer

    @jsola The 'logging' macro added here are rather simple/naive tools while waiting for a proper logging solution.
    As mentioned in the PR the main interesting one is WOLF_DEBUG that will print only is compiled in debug.
    That will be neat for your

    constructed H
    constructed T
    constructed M
  • Jeremie Deray Added 2 commits:

    Added 2 commits:

    • 2fe8745d - add cmake option for building examples
    • 248e6694 - add _WOLF_ROOT_DIR that points to wolf root directory

    Compare with previous version

  • Author Developer

    @jsola I just added _WOLF_ROOT_DIR that point to the wolf root directory.
    Hopefully no more messing around with WOLF_ROOT environment variable.

  • set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR})

    I tried this long ago and could not make the variable available in the code. Can you?

  • Jeremie Deray Added 2 commits:

    Added 2 commits:

    • 48a0024e - fix _WOLF_ROOT_DIR
    • bc427908 - add test_wolf_root

    Compare with previous version

  • Author Developer

    Well it looks like it works on my machine at least.
    I have added a test test_wolf_rootto make sure.

  • Jeremie Deray Marked this merge request as a Work In Progress

    Marked this merge request as a Work In Progress

  • I have a compile error:

    [ 85%] Building CXX object src/examples/CMakeFiles/test_sort_keyframes.dir/test_sort_keyframes.cpp.o
    In file included from /Users/jsola/dev/wolf/src/examples/test_processor_imu.cpp:16:
    /Users/jsola/dev/wolf/src/./logging.h:22:37: error: no member named '_V2' in namespace 'std::__1::chrono'
    using wolf_clock_t   = std::chrono::_V2::high_resolution_clock;
                           ~~~~~~~~~~~~~^
  • Im on my Mac, FYI.

  • Author Developer

    I am removing this logging.h file right now as I am working on a proper logging solution.
    Just a minute.

  • Jeremie Deray Added 4 commits:

    Added 4 commits:

    • 83311060 - include config.h in wolf.h
    • a7ad4c53 - add cmake option for building examples
    • 3de044cf - add _WOLF_ROOT_DIR that points to wolf root directory
    • f614d59a - add test_wolf_root

    Compare with previous version

  • Usually, we execute from eclipse, which also allows debugging with the IDE. The env variables in IDEs are tricky. I got it to load env variables by re-defininig them within my eclipse configuration. This means that macro variables defined in the CMakeLists.txt are not visible from the IDE. This issue was pursued for a while, until I got it working with env-like variables.

    Well, I tried your solution and it works, even if launching from eclipse! I am surprised. What else is there apart from the line set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR})?

    Edited by Joan Solà Ortega
  • Author Developer

    Now it should goes smoothly.

  • Nnope, sorry:

    In file included from /Users/jsola/dev/wolf/src/examples/test_processor_imu.cpp:16:
    /Users/jsola/dev/wolf/src/./logging.h:22:37: error: no member named '_V2' in namespace 'std::__1::chrono'
    using wolf_clock_t   = std::chrono::_V2::high_resolution_clock;
                           ~~~~~~~~~~~~~^
  • What is _V2?

  • Author Developer

    Well, the short answer is cmake configure_file function (link).

    This function allows to configure (write) a file during cmake configuration time and so before building. The file in question is src/internal/config.h.in where the macro is defined.
    By including the configured version of this config.h file we can have such _WOLF_ROOT_DIR macro or _WOLF_DEBUG and so on.

  • Wait: my pull produced a merge of two parallel commit lines from your work Is that normal? Or shoul I have checkouted a new branch?

  • *   432fa70 - (8 minutes ago) Merge branch 'wolf_macro_cmake_conftime' of ssh://gitlab.iri.upc.edu:2202/mobile_robotics/wolf into wolf_macro_cmake_conftime - Joan Solà (HEAD -> wolf_macro_cmake_conftime)
    |\  
    | * f614d59 - (29 minutes ago) add test_wolf_root - Jeremie Deray (origin/wolf_macro_cmake_conftime)
    | * 3de044c - (24 hours ago) add _WOLF_ROOT_DIR that points to wolf root directory - Jeremie Deray
    | * a7ad4c5 - (24 hours ago) add cmake option for building examples - Jeremie Deray
    | * 8331106 - (18 minutes ago) include config.h in wolf.h - Jeremie Deray
    * | bc42790 - (29 minutes ago) add test_wolf_root - Jeremie Deray
    * | 48a0024 - (29 minutes ago) fix _WOLF_ROOT_DIR - Jeremie Deray
    * | 248e669 - (24 hours ago) add _WOLF_ROOT_DIR that points to wolf root directory - Jeremie Deray
    * | 2fe8745 - (24 hours ago) add cmake option for building examples - Jeremie Deray
    * | fe6cbe4 - (24 hours ago) include config.h in wolf.h & few logging macro - Jeremie Deray
    |/  
    * ff2fb16 - (24 hours ago) add conf.h that is set at cmake conf time - Jeremie Deray
  • Sorry I have to go now

  • Author Developer

    No it isn't normal. edit: actually it is. I broke the history.

    short solution:

    $ git checkout master
    $ git branch -D wolf_macro_cmake_conftime
    $ git fetch
    $ git checkout wolf_macro_cmake_conftime

    Np see you later.

    Edited by Jeremie Deray
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading