2

I'm using UseLATEX.cmake with CMake and it works pretty well except for passing compiler flags.

For example, in the main directory I have a basic TeX file main.tex, the UseLATEX.cmake file, and this CMakeLists.txt

cmake_minimum_required(VERSION 2.8.4)

project(test NONE)

include(UseLATEX.cmake)

set(LATEX_COMPILER_FLAGS "-jobname=another_name")

set(PDFLATEX_COMPILER pdflatex)
set(LATEX_DEFAULT_BUILD pdf)

add_latex_document(main.tex)

I make a directory called ./build, cd into it, and run cmake ../ then make. The output pdf is still called main.pdf and not another_name.pdf. It won't accept any compiler flags that I give it. Any ideas?

3

This works for me:

cmake_minimum_required(VERSION 2.8.4)

project(test NONE)

set(LATEX_COMPILER_FLAGS "-jobname=another_name"
    CACHE STRING "Flags passed to latex.")

set(PDFLATEX_COMPILER pdflatex)
set(LATEX_DEFAULT_BUILD pdf)

include(UseLATEX.cmake)

add_latex_document(main.tex)

Note the CACHE STRING "Flags passed to latex." and the fact that UseLATEX.cmake is included after setting the variables. You can also use --jobname=another_name (i.e., with two dashes; tested on TeX Live 2019).

  • That, and, as I've just learned, apparently clearing the build directory is also necessary after a bad compilation. I should've known that. – fiziks May 21 at 21:23
  • This UseLATEX.cmake is picky! I've already worked with CMake on another project but was a bit surprised to find both conditions I cited as really necessary. Oh well... – frougon May 21 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.