[Cmake] Some problems

Bill Hoffman bill . hoffman at kitware . com
Wed, 18 Jun 2003 08:00:19 -0400


At 06:13 AM 6/18/2003, David Svoboda wrote:
>Hello,
>
>I'm sorry, but I'm begginer in using CMake package. Here are some
>questions, I'm not able to answer them:
>
>******
>1. Built in options and string variables in Cache file can be implicitly
>changed by setting something like the following code:
>
>  OPTION(CMAKE_VERBOSE_MAKEFILE "Tracing the compilation process" ON)
>
>but before typing the keyword PROJECT(<name of the project>). When setting
>this after PROJECT keyword, it doesn't work. Why?


The OPTION command should work before or after the PROJECT command, in fact
there should not be many commands at all before the project command.   However,
the OPTION command will only initialize a cache variable.   It will
not set it each time, for that you need SET.

>******
>2. I've been developing library. The root CMakeLists.txt file looks like:
>
>PROJECT(<name of project>)
>SET(LIBRARY_NAME i3d)
>SUBDIRS(src examples)
>
>In the src/CMakeLists.txt the shared library is built with using the
>keyword TARGET_LINK_LIBRARIES(${LIBRARY_NAME} <needed libs>) to link the
>neccesary libs to the result.
>
>In the examples/CMakeLists.txt the samples are build using the keywords
>
>LINK_LIBRARIES(${LIBRARY_NAME})
>ADD_EXECUTABLE(example1 example1.cc)
>ADD_EXECUTABLE(example2 example2.cc)
>
>When linking the examples, the libraries used for linking library
>${LIBRARY_NAME} are linked to these examples as well. Why? How to avoid
>this?
>

There is no way to stop this.   For static libraries it is required, and
as far as I know it should not cause any harm.   In fact, this is an important
feature of cmake.  CMake remembers all the library chaining rules and makes
sure that executables will link static or shared.   

-Bill


>-David
>
>_______________________________________________
>Cmake mailing list
>Cmake at public . kitware . com
>http://public . kitware . com/mailman/listinfo/cmake