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?
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.
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.
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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With