I want to do something like this:
$ cmake -E "find_package(Boost)"
To see if it succeeds or fails? (ie. so I can do some dependancy checking on a project and try to install all of them before cmake actually runs the CMakeLists.txt.
I know cmake already has that -E flag but when I run it I only get a small list of available commands:
Usage: cmake -E [command] [arguments ...]
Available commands:
chdir dir cmd [args]... - run command in a given directory
compare_files file1 file2 - check if file1 is same as file2
copy file destination - copy file to destination (either file or directory)
copy_directory source destination - copy directory 'source' content to directory 'destination'
copy_if_different in-file out-file - copy file if input has changed
echo [string]... - displays arguments as text
echo_append [string]... - displays arguments as text but no new line
environment - display the current environment
make_directory dir - create a directory
md5sum file1 [...] - compute md5sum of files
remove [-f] file1 file2 ... - remove the file(s), use -f to force it
remove_directory dir - remove a directory and its contents
rename oldname newname - rename a file or directory (on one volume)
tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]
- create or extract a tar or zip archive
time command [args] ... - run command and return elapsed time
touch file - touch a file.
touch_nocreate file - touch a file but do not create it.
Available on UNIX only:
create_symlink old new - create a symbolic link new -> old
There is -P <source.cmake>
flag, that puts CMake into script processing mode. You can execute arbitrary CMake code with it using
execute_process(COMMAND ${CMAKE_PROGRAM} -P yourscript.cmake)
But there is nothing wrong with calling find_package(Boost)
from your CMakeLists.txt
, because if Boost wasn't found it doesn't fail right away, but provide you means to check for this and do something else.
All dependence checking should be done somewhere inside your CMakeLists.txt
and not external scripts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With