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 <[email protected]> On Behalf Of Quaquaraquà
Sent: 08 July 2018 22:35
To: Cmake Mailing List <[email protected]>
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
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake