Search code examples
c++eigenprecompile

Ensure define is processed when recompiling


I am working on a c++ project using Eigen. Recently I added a function to Eigen MatrixBase using the recommended way described here:

https://eigen.tuxfamily.org/dox/TopicCustomizingEigen.html

This web page explains how to add a new eigen function in a new file called MatrixBaseAddons.h. Then it asks to define EIGEN_MATRIXBASE_PLUGIN

Then one can add the following declaration in the config.h or whatever prerequisites header file of his project:

#define EIGEN_MATRIXBASE_PLUGIN "MatrixBaseAddons.h"

This is the part that bothers me... I didn't create the project I am working on and am new to CMake. I don't see a config.h file in our project and don't know where to add the definition above to ensure that EIGEN_MATRIXBASE_PLUGIN is always defined.

In a c++ project using CMake, how can we see / change the order in which the files are compiled? Where should I put this line

#define EIGEN_MATRIXBASE_PLUGIN "MatrixBaseAddons.h"

to ensure that it is always defined?


Solution

  • try adding the following line in your CMakeLists :

    add_definitions(-DEIGEN_MATRIXBASE_PLUGIN="MatrixBaseAddons.h")
    

    this will add your definitions to your compiler command line. More info in CMake add_definitions page