Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do CMake placeholders work?

Tags:

cmake

Inside the support libraries for CMake, you'll see command definitions that look like this:

 set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")

(from /usr/share/cmake-3.5/Modules/CMakeASMInformation.cmake in my install for example)

The objects of interest here to me are the placeholders (phrase obtained here): <DEFINES> <INCLUDES> <FLAGS>; I'm trying to figure out how they interact with the rest of CMake.

Given that I was able to pass flags to my assembler by setting CMAKE_ASM-ATT_FLAGS, I had sort of thought that there might be some magic mapping a placeholder to a variable name... but setting CMAKE_ASM-ATT_INCLUDES didn't seem to do anything.

So how would <INCLUDES> be populated here? Can it be filled in a target-specific manner?

like image 236
Matthew G. Avatar asked Oct 17 '22 09:10

Matthew G.


1 Answers

There is a little magic in origin of placeholders:

  • <DEFINES> is filled by add_definitions, target_compile_definitions commands and corresponded properties,

  • <INCLUDES> is filled by include_directories, target_include_directories and so,

  • <FLAGS> is filled by add_compile_options, target_compile_options and so plus CMAKE_<LANG>_FLAGS variable and its configuration-specific pair,

  • <SOURCE> are source files and

  • <OBJECT> are corresponded objects.

That is, everything which affects building of C/C++ programs affects (after being language-adapted) on library/executables on other languages.

like image 196
Tsyvarev Avatar answered Oct 21 '22 05:10

Tsyvarev