Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake Error: Command add_definitions() is not scriptable

Tags:

cmake

Has anyone ever come across this error? If so how do I fix it or what is an equivalent approach.

I am running Ubuntu and the code creates a list of compiler defines and then I am just looping through the list and adding each define.

set(COMPILER_DEF_LIST)
list(APPEND COMPILER_DEF_LIST_COMMON
 NUMBER_FAMILY_RESERVED_FIXED_OIDS=5
 CHILD_LIST_ELEMENTS_PER_BLOCK=10
 ...

FOREACH(compilerDefine ${COMPILER_DEF_LIST_COMMON})
add_definitions(-D${compilerDefine})
ENDFOREACH(compilerDefine)
like image 324
Adam Avatar asked Dec 17 '25 22:12

Adam


1 Answers

This error message is specific to CMake being run in "script mode" with cmake -P ....

Mainly all commands handling targets and target settings/options/properties are not "scriptable" (not usable when running CMake in "script mode").

See also CMake/Language Syntax: cmake -P:

... except that all commands related to Makefile generation or the CMake cache will fail

like image 138
Florian Avatar answered Dec 21 '25 22:12

Florian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!