[CMake] find_package: keyword REQUIRED ignored
Mark De Wit
mark.dewit at iesve.com
Mon Jul 9 03:45:25 EDT 2018
I thought that the find script itself was responsible for checking the required flag?
Our own find scripts do something along the lines of (note that we named ours sqlite, not sqlite3!)
if(NOT sqlite_FIND_QUIETLY)
MESSAGE(STATUS "Looking for sqlite...")
endif()
… look for package here
… if not found and required, signal fatal error:
if(sqlite_FIND_REQUIRED)
message(FATAL_ERROR "Looking for sqlite... - Not found")
endif()
From the CMake documentation on find_package:
When loading a find module or package configuration file find_package defines variables to provide information about the call arguments (and restores their original state before returning):
…
<package>_FIND_REQUIRED
true if REQUIRED option was given
<package>_FIND_QUIETLY
true if QUIET option was given
In Module mode the loaded find module is responsible to honor the request detailed by these variables; see the find module for details. In Config mode find_package handles REQUIRED, QUIET, and [version] options automatically
Mark
From: CMake <cmake-bounces at cmake.org> On Behalf Of Quaquaraquà
Sent: 08 July 2018 22:35
To: Cmake Mailing List <cmake at cmake.org>
Subject: [CMake] find_package: keyword REQUIRED ignored
Hi there,
I'm using a custom script [1] to look for the library sqlite3. However, the keyword "REQUIRED" (as quietly) is ignored by find_package. That is even if the library is not found, the script continues is processing:
// CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(hello_world)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build-aux/")
find_package(SQLite3 REQUIRED)
// output:
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -G "CodeBlocks - Unix Makefiles" ../
-- Could NOT find SQLITE3 (missing: SQLITE3_LIBRARY)
-- Configuring done
-- Generating done
-- Build files have been written to: ...
Any idea what is wrong here?
[1] https://github.com/LuaDist/libsqlite3/blob/master/cmake/FindSQLite3.cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180709/b13f78c1/attachment.html>
More information about the CMake
mailing list