I am creating a C++ class which has a constructor like this:
MyClass(const std::string& config_file);
I.e. a configuration file should be passed to the constructor when instantiating an object. As part of the project I create a default configuration file which will probably be used in ~90% of the cases, and I would like people to be able use my class as:
MyClass myInstance(DEFAULT_CONFIG_FILE);
i.e. I want the symbol 'DEFAULT_CONFIG_FILE' to point to the path of configuration file I have created as part of the project. But the problem is that I have no clue where people actually install the library. Is there (CMake ??) trick/best practices here?
I guess could do something like
set( DEFAULT_CONFIG_FILE ${CMAKE_INSTALL_PREFIX}/share/app/default_config.json)
But then things will not work in the build directory?!
Joakim