MantisBT - CMake
View Issue Details
0012908CMakeCMakepublic2012-01-23 13:312012-09-03 16:01
Christopher Sean Morrison 
Brad King 
normalminoralways
closedfixed 
 
CMake 2.8.8CMake 2.8.8 
0012908: Emacs cmake mode indents incorrectly after multiline SET()
Summary says it all. If you define a macro that calls set, it will think the previous line indentation was at that unindented level. See the example in the Steps to Reproduce section.

Fortunately, it seems a fix was easy. See attached.
Indenting this region results in the lines after the DIRNAME_SRC set line all being at beginning of line.

MACRO(BRLCAD_CHECK_DIRNAME)
  SET(DIRNAME_SRC "
#include <libgen.h>
int main(int argc, char *argv[]) {
(void)dirname(argv[0]);
return 0;
}")
  CHECK_C_SOURCE_RUNS("${DIRNAME_SRC}" HAVE_DIRNAME)
  IF(HAVE_DIRNAME)
    FILE(APPEND ${CONFIG_H_FILE} "#define HAVE_DIRNAME 1\n")
  ENDIF(HAVE_DIRNAME)
ENDMACRO(BRLCAD_CHECK_DIRNAME var)
Conveniently, there was already a cmake-line-starts-inside-string() function we could key off of, so we keep walking backwards until we find an actual statement inside cmake-find-last-indented-line().
No tags attached.
patch cmake-mode-set-indent.patch (632) 2012-01-23 13:31
https://public.kitware.com/Bug/file/4197/cmake-mode-set-indent.patch
Issue History
2012-01-23 13:31Christopher Sean MorrisonNew Issue
2012-01-23 13:31Christopher Sean MorrisonFile Added: cmake-mode-set-indent.patch
2012-01-23 14:05Brad KingNote Added: 0028393
2012-01-23 14:05Brad KingStatusnew => resolved
2012-01-23 14:05Brad KingResolutionopen => fixed
2012-01-23 14:05Brad KingAssigned To => Brad King
2012-04-19 15:44David ColeFixed in Version => CMake 2.8.8
2012-04-19 15:44David ColeTarget Version => CMake 2.8.8
2012-09-03 16:01David ColeNote Added: 0030875
2012-09-03 16:01David ColeStatusresolved => closed

Notes
(0028393)
Brad King   
2012-01-23 14:05   
Thanks for the detailed report, analysis, and solution. I was able to simplify the patch to achieve the same result. Fixed:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7da35e65 [^]
(0030875)
David Cole   
2012-09-03 16:01   
Closing resolved issues that have not been updated in more than 4 months.