[CMake] A few newbie "how to" questions
Simon Perreault
nomis80 at nomis80.org
Fri Mar 9 15:22:04 EST 2007
Hello,
I'm using CMake for building the source code of a research project where a few
people of diverse level of technicality will contribute. It will have to be
buildable in Visual Studio as well as under Linux.
I have a few simple questions on how to do stuff with CMake. Hopefully someone
can donate a few minutes and answer at least one of them. ;) Thanks in
advance. (I've done my homework: I read the documentation many times, as well
as the FAQ and the wiki.)
1. A few files require the Matlab libraries and include. This package is
installed in varied and unpredictable places, and therefore I chose to force
the user to specify the MATLABROOT variable manually. I used the following
code:
IF (NOT DEFINED MATLABROOT)
MESSAGE(FATAL_ERROR "Please define the MATLABROOT variable.")
ENDIF (NOT DEFINED MATLABROOT)
Then I run cmake with "cmake -DMATLABROOT=/path/to/matlab ." and it works.
However, if I do "touch CMakeLists.txt; make" it fails, requiring me to
specify MATLABROOT once again instead of fetching it from the cache. What is
the correct way to do this?
2. Is it possible to have per-sourcefile definitions? i.e. In one directory I
have a few .c files which require the MATLAB_MEX_FILE definition while others
are stand-alone programs that don't need it. ADD_DEFINITIONS seems to have a
global effect.
3. Same question as 2 but concerning INCLUDE_DIRECTORIES.
4 and 5. Same questions as 2 and 3, but this time I want per-library or
per-executable instead of per-sourcefile.
That's it for now. I'll probably have more as I continue writing this new
build system.
More information about the CMake
mailing list