CMake and latex

I am using 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 cmake file at my root level 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 will compile my project in the build folder. Can I somehow copy the Doc.pdf file created in the build/doc folder back to the original build folder?

+8
cmake latex
source share
1 answer

Since ADD_LATEX_DOCUMENT adds a CMake target named pdf here, you can use add_custom_command . Try adding the following to /doc/CMakeLists.txt after calling ADD_LATEX_DOCUMENT :

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

This user command calls the cmake executable (stored in the variable ${CMAKE_COMMAND} ) along with the -E copy arguments each time the pdf target is created.

+7
source share

All Articles