Use cmake to compile latex files.
- Gentoo Linux (with noto-cjk installed for CJK fonts)
- TeXLive 2017
- cmake 2.8+
Put CMakeLists.txt and UseLATEX.cmake together with your latex files, modify CMakeLists.txt to match your project, and run the following commands:
#!/bin/sh
mkdir out
cd out
cmake .. -DPDFLATEX_COMPILER=$(which xelatex)
make VERBOSE=1 # VERBOSE mode for indicating what may go wrong.
cd -
The directory "out" contains all intermediate files, including the final pdf, that are generated by latex.