Hi, I want to use some required Qt component while others are optional. Apparently if you specify REQUIRED in find_package OPTIONAL_COMPONENTS is ignored. Here is a minimal CMakeLists.txt: project(test) cmake_minimum_required(VERSION 3.5)
find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui OPTIONAL_COMPONENTS Invalid) /home/alex/repo/cmake/build/bin/cmake --version cmake version 3.5.20160303-gf37f cmake fails with: CMake Error at /home/alex/repo/cmake/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find Qt4 (missing: QT_INVALID_INCLUDE_DIR QT_INVALID_LIBRARY) (found version "4.8.7") Call Stack (most recent call first): /home/alex/repo/cmake/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) /home/alex/repo/cmake/Modules/FindQt4.cmake:1333 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:4 (find_package) I expected that if required components are missing cmake bails out while continuing when OPTIONAL_COMPONENTS are missing. My current workaround is: find_package(Qt4 OPTIONAL_COMPONENTS Invalid) find_package(Qt4 REQUIRED COMPONENTS QtCore QtGui) But I would rather use a single line. Am I missing something here? Best regards, Alexander -- 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: http://public.kitware.com/mailman/listinfo/cmake