[CMake] Conditional subdirectory build

David Doria daviddoria at gmail.com
Sun Nov 29 09:10:59 EST 2009


I am packaging a VTK filter. I am trying to give the user the option
of additionally compiling the Paraview plugin for the filter (in the
.../plugin directory). I wanted to make a BUILD_PARAVIEW_PLUGIN
variable that they could set to "ON" or "OFF". If it is set to "ON",
CMake should proceed with processing the plugin subdirectory. Else,
just ignore it. However, when I generate the makefiles in both cases,
they seem to be the same and neither includes the plugin subdirectory.

Can anyone see where I have gone wrong?

My main CMakeLists.txt file is:
------------------------------
cmake_minimum_required(VERSION 2.6)
    if(COMMAND cmake_policy)
      cmake_policy(SET CMP0003 NEW)
    endif(COMMAND cmake_policy)

PROJECT(vtkPointSetOutlierRemoval)

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

SET(BUILD_PARAVIEW_PLUGIN ON CACHE STRING "Build Paraview plugin?" FORCE)

if(BUILD_PARAVIEW_PLUGIN==ON)
 ADD_SUBDIRECTORY(plugin)
endif(BUILD_PARAVIEW_PLUGIN==ON)

ADD_EXECUTABLE(vtkPointSetOutlierRemoval Example.cxx
vtkPointSetOutlierRemoval.cxx)
TARGET_LINK_LIBRARIES(vtkPointSetOutlierRemoval vtkHybrid )

-------------------------------
And the plugin subdirectory CMakeLists.txt file is:

FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})

ADD_PARAVIEW_PLUGIN(PointSetOutlierRemoval "1.0"
  SERVER_MANAGER_XML PointSetOutlierRemoval.xml
SERVER_MANAGER_SOURCES ../vtkPointSetOutlierRemoval.cxx
)


Thanks,

David


More information about the CMake mailing list