Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown CMake command "CMAKE_DEPENDENT_OPTION"

Tags:

cmake

I faced with an issue that my installed on Ubuntu cmake

cmake --version
cmake version 3.17.2

doesn't recognize CMAKE_DEPENDENT_OPTION command.

So, my CMakeLists.txt with dependent option example from cmake.org/v3.16:

cmake_minimum_required(VERSION 3.4.1)

project(myexe)

CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON
                       "USE_BAR;NOT USE_ZOT" OFF)

file(GLOB SRC_FILES "src/*.cpp")

add_executable(${PROJECT_NAME} ${SRC_FILES})

The following error is displayed when running cmake:

CMake Error at CMakeLists.txt:5 (CMAKE_DEPENDENT_OPTION):
  Unknown CMake command "CMAKE_DEPENDENT_OPTION".

Why does it happen because the spec says it is supported? Thanks for any help!

like image 976
Mykola Khyliuk Avatar asked Jan 24 '23 11:01

Mykola Khyliuk


1 Answers

You need to add

include(CMakeDependentOption)

before accessing this function.

like image 137
vre Avatar answered Jan 31 '23 18:01

vre