[CMake] 1 tricky question, 1 bug report

Eric Noulard eric.noulard at gmail.com
Fri Mar 13 13:31:24 EDT 2009


2009/3/13 Denis Scherbakov <denis_scherbakov at yahoo.com>:
>
> Eric,
>
> Your solution requires a developer to know too much about the project, which is not always true and basically to answer a full-scale questionnaire before compilation. What if it is a new developer?

If it is not a developer there is a simpler solution, try to find all
what you can
in the main CMakeLists.txt and throw a "STATUS" message instead of FATAL
as told by Bill.

As regarding the OPTION solution, you may build your CMakeLists.txt to
automatically (and silently) put to ON all "buildable" parts (after trying
to find all dependencies).

Note that the drawback of the totally automatic thing is that you may search
for unwanted user things. Which may be a waste of time for him.

>  What if it is not a developer, but a user who expects everything to compile automatically?

Then each "Not Found" message shuold tell him how to install dependencies.

>
> My question is simple:
>
> What is the way to get some code executed not during cmake-compilation, but when a user types "gmake something" and it becomes clear which dependencies are needed.

You ask to run CMake from make somehow. This should be doable with
add_custom_command / add_custom_target,
and a 2 steps make,  but I don't think  CMake  was meant for kind of
re-entrant usage, i.e. the build system (make, Visual Studio etc...)
calling the build generator (cmake). As far as I know this is currently done
only for checking if a CMakeLists.txt changed and it bothers some build system
like Visual Studio when they discover that the file they are using have been
changed during their own build.


Note however,
that here you expect your user to actually know that he wants
"something" to be build,
thus it is not "very" different (beside the syntactic sugar)
from requiring him to do:

cmake -DSOMETHING:BOOL=ON

when running cmake, it doesn't require much more knowledge but the name
the sub-projects he wants to build.


-- 
Erk


More information about the CMake mailing list