installation paths and generated source files

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

installation paths and generated source files

Magnus Hagdorn
Hi there,
I have the following problem with cmake:

I would like to set the installation path for plugins to be
${LIB_INSTALL_DIR}/${PROJECT_NAME}. As I understand it, the
LIB_INSTALL_DIR is relative to CMAKE_INSTALL_PREFIX if it is not an
absolute path. Installation works fine for both cases when
LIB_INSTALL_DIR is absolute and when it is relative. So far so good.

Now, my problem is that I would like to generate a header file
containing the installation path for my plugins so the program can find
them.  My header input file contains

#define PLUGIN_DIR "${PLUGIN_INSTALL_DIR}"

which works if LIB_INSTALL_DIR is absolute but it doesn't work if it is
a relative path in which case I'd need

#define PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_DIR}"

which presumably won't work on windows systems anyway because of the
unix dir separator. what's the best way of solving this issue?

Cheers
magnus

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: installation paths and generated source files

Andreas Pakulat-2
Hi,

On Mon, Aug 19, 2013 at 6:23 PM, Magnus Hagdorn <[hidden email]> wrote:
Hi there,
I have the following problem with cmake:

I would like to set the installation path for plugins to be ${LIB_INSTALL_DIR}/${PROJECT_NAME}. As I understand it, the LIB_INSTALL_DIR is relative to CMAKE_INSTALL_PREFIX if it is not an absolute path. Installation works fine for both cases when LIB_INSTALL_DIR is absolute and when it is relative. So far so good.

Now, my problem is that I would like to generate a header file containing the installation path for my plugins so the program can find them.  My header input file contains

#define PLUGIN_DIR "${PLUGIN_INSTALL_DIR}"

which works if LIB_INSTALL_DIR is absolute but it doesn't work if it is a relative path in which case I'd need

#define PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_DIR}"

which presumably won't work on windows systems anyway because of the unix dir separator. what's the best way of solving this issue?

I'd solve this inside cmake and setup a custom cmake variable which is then used in the h.cmake-file for configure_file.

However note that doing this makes your application non-relocatable, i.e. its not possible to move it around anymore. So you may want to reconsider this and merely store a relative path as plugin-dir in the header and then absolutify this during the runtime of the program based on the location of the binary or something like that. Makes handling the plugin-install-dir-is-absolute case a bit more work since you need to determine the location.

Andreas
 

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake