[CMake] Conditional subdirectory build

Marcel Loose loose at astron.nl
Mon Nov 30 03:23:06 EST 2009


Hi David,

Why not use OPTION(...) for this, or if you really want to the
equivalent: set(MYVAR ON CACHE BOOL "My variable"). Don't use FORCE, or
you will overwrite any changes the user made.

Best regards,
Marcel Loose.

On Sun, 2009-11-29 at 10:12 -0500, David Cole wrote:
> if(BUILD_PARAVIEW_PLUGIN==ON)
>   should just be
> if(BUILD_PARAVIEW_PLUGIN)
> 
> 
> cmake --help-command IF
> will explain...
> 
> 
> There is no "==" but there are EQUAL and STREQUAL operators. In the
> case of a boolean option variable, the syntax "if(variable)" if
> preferred.
> 
> 
> 
> 
> HTH,
> David
> 
> 
> 
> On Sun, Nov 29, 2009 at 9:10 AM, David Doria <daviddoria at gmail.com>
> wrote:
>         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
>         _______________________________________________
>         Powered by www.kitware.com
>         
>         Visit other Kitware open-source projects at
>         http://www.kitware.com/opensource/opensource.html
>         
>         Please keep messages on-topic and check the CMake FAQ at:
>         http://www.cmake.org/Wiki/CMake_FAQ
>         
>         Follow this link to subscribe/unsubscribe:
>         http://www.cmake.org/mailman/listinfo/cmake
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list