[CMake] Howto define build order

Matthias Fechner idefix at fechner.net
Wed Aug 22 04:40:12 EDT 2007


Hi,

I am writing my masterthesis with LaTeX and I use here cmake to do the
comilation for me.
Today I added gnuplot to my LaTeX document.

But I have now the problem that cmake first build the LaTeX document
and then the gnuplot file. How can I say cmake to first build my
gnuplot files?

The struture is
maindir (include the main latex file)
maindir/vorlage (includes some latex templates and libs)
maindir/gnuplot (includes the gnuplot files)
maindir/images (includes images)

I created now two CMakeLists.txt, one in maindir and one in gnuplot:

---cut---
PROJECT(MASTERTHESIS NONE)

# debug output
#CMAKE_VERBOSE_MAKEFILE(ON)

SET(LATEX_OUTPUT_PATH build)
INCLUDE(UseLATEX.cmake)
INCLUDE(FindGnuplot)
ADD_SUBDIRECTORY(gnuplot)

ADD_LATEX_DOCUMENT(masterthesis.tex
		   INPUTS vorlage/standard_eng.sty vorlage/standard.tex vorlage/trennhilfen.sty vorlage/owntitlepage.sty
		   erklaerung.tex
		   IMAGE_DIRS images/
		   DEFAULT_PDF) # MANGLE_TARGET_NAMES)
---cut---					      
					      
---cut---
# files to plot must have the extension .plot
# A pdf file is generated in the same directory
ADD_CUSTOM_TARGET(GNUPLOTs ALL)

IF(GNUPLOT)
  SET(files count)
  SET(results)
  FOREACH(file ${files})
   SET(src ${file}.plot)
   SET(dst ${file}.pdf)
   ADD_CUSTOM_COMMAND(
      SOURCE ${src}
      TARGET GNUPLOTs
      COMMAND ${GNUPLOT} ${src}
      OUTPUTS ${dst}
   )
   SET(results ${results} ${dst})
  ENDFOREACH(file)
    
  ADD_CUSTOM_COMMAND(SOURCE GNUPLOTs
    TARGET GNUPLOTs
    DEPENDS ${results}
  )
		  
ENDIF(GNUPLOT)
---cut---

Thx a lot for help,
Matthias

-- 

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook


More information about the CMake mailing list