Why set STRINGS property for a CACHE variable?

Viewed 258

Well I always had troubles understanding the cmake doc, but concerning the set_property I cant get it, especially in this example, taken from the CMakeLists of Openpose.

# Select the DL Framework
set(DL_FRAMEWORK CAFFE CACHE STRING "Select Deep Learning Framework.")
if (WIN32)
  set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE)
else (WIN32)
  set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE NV_CAFFE)
  # set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE NV_CAFFE PYTORCH TENSORFLOW)
endif (WIN32)

# Suboptions for Caffe DL Framework
include(CMakeDependentOption)
if (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")
  CMAKE_DEPENDENT_OPTION(BUILD_CAFFE "Build Caffe as part of OpenPose." ON
    "DL_FRAMEWORK" ON)
  # OpenPose flags
  add_definitions(-DUSE_CAFFE)
  # Nvidia NVCaffe
  if (${DL_FRAMEWORK} MATCHES "NV_CAFFE")
      MESSAGE(STATUS "Using NVIDIA NVCaffe")
      add_definitions(-DNV_CAFFE)
  endif (${DL_FRAMEWORK} MATCHES "NV_CAFFE")
endif (${DL_FRAMEWORK} MATCHES "CAFFE" OR ${DL_FRAMEWORK} MATCHES "NV_CAFFE")

I do understand the CACHE variable, but what is the effect of the two set_property, as the variable ${DL_FRAMEWORK} seems to be checked to plain text like "CAFFE" or "NV_CAFFE".

Here is the complete CMakeLists.txt: https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/CMakeLists.txt

I may also misunderstand how properties are working then.

Thanks for your time!

1 Answers

The command

  set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE NV_CAFFE)

Sets STRINGS property for the CACHE variable DL_FRAMEWORK.

If one configures the project with CMake GUI, then the first configuration is usually performed without any setting of the variables.

After that first configuration one could desire to set(change) the variable DL_FRAMEWORK. And STRING provides a list of values which will be suggested. So one doesn't need to type e.g. "NV_CAFFE" but could select it from the list.

Related