Can I run an arbitrary CMake function from the command line? -


i want this:

$ cmake -e "find_package(boost)" 

to see if succeeds or fails? (ie. can dependancy checking on project , try install of them before cmake runs cmakelists.txt.

i know cmake has -e flag when run small list of available commands:

usage: cmake -e [command] [arguments ...] available commands:   chdir dir cmd [args]...   - run command in given directory   compare_files file1 file2 - check if file1 same file2   copy file destination     - copy file destination (either file or directory)   copy_directory source destination   - copy directory 'source' content directory 'destination'   copy_if_different in-file out-file  - copy file if input has changed   echo [string]...          - displays arguments text   echo_append [string]...   - displays arguments text no new line   environment               - display current environment   make_directory dir        - create directory   md5sum file1 [...]        - compute md5sum of files   remove [-f] file1 file2 ... - remove file(s), use -f force   remove_directory dir      - remove directory , contents   rename oldname newname    - rename file or directory (on 1 volume)   tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]                             - create or extract tar or zip archive   time command [args] ...   - run command , return elapsed time   touch file                - touch file.   touch_nocreate file       - touch file not create it. available on unix only:   create_symlink old new    - create symbolic link new -> old 

there -p <source.cmake> flag, puts cmake script processing mode. can execute arbitrary cmake code using

execute_process(command ${cmake_program} -p yourscript.cmake) 

but there nothing wrong calling find_package(boost) cmakelists.txt, because if boost wasn't found doesn't fail right away, provide means check , else.

all dependence cheking should done somewhere inside cmakelists.txt , not external scripts.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -