spajak / cef-pdf

cef-pdf HTML to PDF utility
MIT License
79 stars 32 forks source link

How do I build this again? #25

Open anko opened 6 years ago

anko commented 6 years ago

I can recall having managed it in the past.

Following the current building instructions, I downloaded the correct CEF distribution files for my system, cd'd into a temp directory, then ran this command I constructed based on the instructions:

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release \
    -DCEF_ROOT=~/dl/cef_binary_3.3282.1726.gc8368c8_linux64/Release \
    ~/src/cef-pdf

It failed for me with this:

CMake Error at CMakeLists.txt:192 (find_package):
  By not providing "FindCEF.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "CEF", but
  CMake did not find one.

  Could not find a package configuration file provided by "CEF" with any of
  the following names:

    CEFConfig.cmake
    cef-config.cmake

  Add the installation prefix of "CEF" to CMAKE_PREFIX_PATH or set "CEF_DIR"
  to a directory containing one of the above files.  If "CEF" provides a
  separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!
See also "/home/anko/src/cef-pdf/build/CMakeFiles/CMakeOutput.log".

This is the first time I touch cmake, so I'm probably just dumb. What did I do wrong?

Relatedly, could the build be adapted to only 1 step? It would help automate testing and packaging.

beckyconning commented 6 years ago

nice to see you again : ) i'll have a look at this on monday morning and get back to you!

ststeiger commented 5 years ago

@anko: I get this error message if I use spotify "CEF source" instead of "Minimal Distribution" as /path/to/cef/release.

as the readme says:

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCEF_ROOT=/path/to/cef/release /path/to/cef-pdf
ninja 

/path/to/cef/release is the extracted "Minimal Distribution", /path/to/cef-pdf is the local path to the git repository.

Here an example command-line that worked for me:

cmake -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release -DCEF_ROOT="C:/Users/MyUser/Documents/Visual Studio 2017/CEF/cef_binary_3.3626.1895.g7001d56_windows32_minimal" "C:/Users/MyUser/Documents/Visual Studio 2017/Projects/cef-pdf"

Note: You need to use forward-slash as directory-separator on Windows, otherwise you get something like

Invalid escape sequence \U Invalid escape sequence \S

On Linux, you can use

cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCEF_ROOT=/path/to/cef/release /path/to/cef-pdf
ninja

and actually, you don't need "Ninja", you can just use plain old unix makefiles: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCEF_ROOT=/home/username/Desktop/src/cef_binary_3.3626.1895.g7001d56_linux64_minimal /home/username/Desktop/src/cef-pdf

Cmake on Linux is a bit of a bitch. When you run cmake --version, you might get

cmake: /usr/local/lib/libcurl.so.4: no version information available (required by cmake)

If you get that, you need to delete the symlink to libcurl.so.4, and create a new one

sudo rm /usr/local/lib/libcurl.so.4
sudo ln -s /usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4

You might then get

CMake Error at CMakeLists.txt:49 (list): list does not recognize sub-command FILTER

Which is to be expected, as list(FILTER) was introduced in CMake 3.6, and if you have a cmake version < 3.6, such as 3.5.1 on ubuntu 16.04, then using filter can't work.

You then need to apt-get --purge cmake, and subsequently install the latest version from cmake.org

wget https://cmake.org/files/v3.14/cmake-3.14.0-rc4-Linux-x86_64.sh
sudo sh cmake-3.14.0-rc4-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir

Also, make might then treat warnings as erros. So in the makefiles created by cmake, search for all files named flags.make, and remove -Werr, which treats warnings as errors (and because since some methods aren't being used, this creates a warning, and the with the -Werr option on, warnings will cause the build to build to fail (-Werr: treat warnings as errors).

The way cmake works, is you open a command prompt in the directory where you want to build in. Then you issue the cmake command, cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCEF_ROOT=/path/to/cef/release /path/to/cef-pdf, which generates the build files you need to compile the application. -G specifies the build target, can be Ninja, unix-makefiles, Visual-Studio solutions. Enter a bogus-name there, and cmake will list you the possible options for your machine.

You then use the makefiles or the Visual Studio solution to compile the project. Note: Visual Studio on a 64-Bit processor wants to link against the 32-Bit dlls BY DEFAULT, so use the CEF minimal distribution for Win32 when you create the visual-studio solution with cmake...

You also need to switch the build to "Release", because in "Debug", the build will fail because of missing CEF files.

Enjoy the sources updated for the latest version of Chromium per March 11, 2019 CET here: https://github.com/ststeiger/cef-pdf