[CMake] find_package REQUIRED
Alexander Bubnov
alexander.bubnov at gmail.com
Fri Jul 4 10:17:18 EDT 2008
Hello!
I am exploring cmake features. Now I have stopped at find_package,
REQUIRED parameter. As I can see from manual:
"The REQUIRED option stops processing with an
error message if the package cannot be found."
(cmake 2.6-patch 0)
My CMakeLists.txt looks like:
cmake_minimum_required(VERSION 2.6)
project (TRIAL)
FIND_PACKAGE(XMLRPC REQUIRED)
if ( NOT XMLRPC_FOUND )
message("The process is not interrupted!")
endif ( NOT XMLRPC_FOUND )
the output:
cmake/CMakeExample> rm CMakeCache.txt ; cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- XMLRPC was not found. Make sure the entries XMLRPC_* are set.
The process is not interrupted!
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alek/trial/cmake/CMakeExample
/usr/local/share/cmake-2.6/Modules/FindXMLRPC.cmake looks like:
...
# Report the results.
IF(NOT XMLRPC_FOUND)
SET(XMLRPC_DIR_MESSAGE
"XMLRPC was not found. Make sure the entries XMLRPC_* are set.")
IF(NOT XMLRPC_FIND_QUIETLY)
MESSAGE(STATUS "${XMLRPC_DIR_MESSAGE}")
ELSE(NOT XMLRPC_FIND_QUIETLY)
IF(XMLRPC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${XMLRPC_DIR_MESSAGE}")
ENDIF(XMLRPC_FIND_REQUIRED)
ENDIF(NOT XMLRPC_FIND_QUIETLY)
ENDIF(NOT XMLRPC_FOUND)
...
in order to interrupt the process XMLRPC_FIND_QUIETLY should be set by
hand at my CMakeLists.txt.
I guess it is not a bug because almost all (or all) Find*.cmak files,
which I sow, do not interrupt the process. So, can you please find an
answer how I should use find_package to stop script in case of a
component is not found?
Thanks for you greate works under cmake tool.
--
/BR, Alexander
More information about the CMake
mailing list