tags:

views:

49

answers:

1

I have a project structure like:

src/CMakeLists.txt
src/test/component1/CMakeLists.txt
src/test/component2/CMakeLists.txt

For the testing, I'm using Qt - however, I want to make sure that if Qt (or some other test-specific package is not found) I simply skip the package.

I tried

find_package(Qt4 QUIET COMPONENTS QtCore QtTestLib)
if (NOT QT4_FOUND)
    message(SEND_ERROR "Qt4 not found - skipping building tests")
endif (NOT QT4_FOUND)

but that doesn't work like I want to since that still prevents the generation of the Makefiles. The only way I can think is to put the entire body of the CMakeLists file into the body of the conditional.

Is there a way to say "skip processing the remainder of this CMakeLists"?

A: 

From the CMake documentation

  • return: Return from a directory or function.

    return()

Returns from a directory or function. When this command is encountered, it caused process of the current function or directory to stop and control is return to the caller of the function, or the parent directory if any. Note that a macro is not a function and does not handle return like a function does.

pkit