Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake and Latex

Tags:

latex

cmake

I am using the UseLATEX.cmake to compile my project documentation folder.

My project is organized as follows --

.
├── CMakeLists.txt
├── bin
├── build
├── cmake
│   ├── CMakeCompilerFlags.cmake
│   ├── CMakeDefaults.cmake
│   ├── MacroEnsureOutOfSourceBuilds.cmake
│   └── UseLATEX.cmake
├── doc
│   ├── Doc.tex
│   ├── CMakeLists.txt
│   └── images
│       ├── img1.png
│       ├── img2.png
│       ├── img3.png
│       └── img4.jpeg
............
└── src
    ├── CMakeLists.txt
    ├── file1.cpp
    ├── file2.cpp
    └── file3.cpp

My root level cmake file is like this ...

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

# Set path for CMake
set(CMAKE_MODULE_PATH
    "${CMAKE_SOURCE_DIR}/cmake"
    ${CMAKE_MODULE_PATH}
)

# Define project settings
project(proj)
set(APPLICATION_NAME ${PROJECT_NAME})
include(CMakeDefaults)

# Compile Program and Docs
include_directories(inc)
add_subdirectory(src)
add_subdirectory(doc)

And the CMakeList file in the document file is --

include(UseLATEX)

ADD_LATEX_DOCUMENT(Doc.tex
    #BIBFILES mybib.bib
    IMAGE_DIRS images
    DEFAULT_PDF
)

Now I compile my project in the build folder. Is there any way I can copy back the Doc.pdf file created in the build/doc folder back to my original build folder?

like image 388
ssb Avatar asked Jan 09 '13 13:01

ssb


People also ask

What exactly does CMake do?

CMake can generate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitrary combinations. CMake supports in-place and out-of-place builds, and can therefore support multiple builds from a single source tree.

Is CMake better than make?

So, what is the real difference? CMake is much more high-level. It's tailored to compile C++, for which you write much less build code, but can be also used for general purpose build. make has some built-in C/C++ rules as well, but they are useless at best.

Is CMake used for C++?

CMake is a very handy tool when you code in C++. It is more convivial than GNU make. For comparison purposes, the CMakeLists. txt file of our C++ library is only 14 lines long while the GNU makefile is made of 938 lines...


1 Answers

Since ADD_LATEX_DOCUMENT adds a CMake target named pdf here, you should be able to make use of add_custom_command. Try adding the following to your /doc/CMakeLists.txt after the ADD_LATEX_DOCUMENT call:

add_custom_command(TARGET pdf POST_BUILD
                   COMMAND ${CMAKE_COMMAND} -E copy
                       ${CMAKE_CURRENT_BINARY_DIR}/Doc.pdf
                       ${CMAKE_BINARY_DIR}/Doc.pdf)

This custom command invokes the cmake executable (held in the variable ${CMAKE_COMMAND}) along with the -E copy arguments every time the pdf target is built.

like image 145
Fraser Avatar answered Sep 21 '22 15:09

Fraser