find_package: keyword REQUIRED ignored

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

find_package: keyword REQUIRED ignored

Quaquaraquà

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
Reply | Threaded
Open this post in threaded view
|

Re: find_package: keyword REQUIRED ignored

Rolf Eike Beer
Am 2018-07-08 23:34, schrieb Quaquaraquà:

> 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

Try:

find_package_handle_standard_args(SQLite3 …

i.e. use the same case for the prefix as your file is called. And maybe
use the second function signature of FPHSA.

Greetings,

Eike
--
--

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
Reply | Threaded
Open this post in threaded view
|

Re: find_package: keyword REQUIRED ignored

Mark De Wit
In reply to this post by Quaquaraquà

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 REQUIREDQUIET, and [version] options automatically 

 

Mark

 

From: CMake <[hidden email]> On Behalf Of Quaquaraquà
Sent: 08 July 2018 22:35
To: Cmake Mailing List <[hidden email]>
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
Reply | Threaded
Open this post in threaded view
|

Re: find_package: keyword REQUIRED ignored

Rolf Eike Beer
Am Montag, 9. Juli 2018, 09:45:25 CEST schrieb Mark De Wit:
> I thought that the find script itself was responsible for checking the
> required flag?

That's what find_package_handle_standard_args() does.

Eike
--

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

signature.asc (201 bytes) Download Attachment