[CMake] installation paths and generated source files

Magnus Hagdorn magnus.hagdorn at ed.ac.uk
Mon Aug 19 12:23:14 EDT 2013


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.



More information about the CMake mailing list