Bug 102230 - Unable to build Poppler (with CMake) as a subproject
Summary: Unable to build Poppler (with CMake) as a subproject
Status: RESOLVED WONTFIX
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-15 09:02 UTC by Aki Koskinen
Modified: 2017-08-17 20:58 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Aki Koskinen 2017-08-15 09:02:18 UTC
Poppler fails to build when used as a subproject. Say I have a project at directory ${CWD} where I have a CMakeLists.txt file for my project. Poppler sources are in ${CWD}/poppler. In my CMakeLists.txt I have a line:

add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/poppler" "${CMAKE_CURRENT_BINARY_DIR}/poppler")

When configuring my project with CMake, it fails because it can't find the needed CMake modules within Poppler sources. These modules are included in Poppler's CMakeLists.txt starting from line 7.

The root cause of this is that on line 5 in Poppler's CMakeLists.txt there is this:

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)

That works fine when Poppler is built by itself. But when Poppler sources are in a subdirectory under another project, then ${CMAKE_SOURCE_DIR} points to the main project's source directory.

I suggest changing the line 5 in CMakeLists.txt to this:

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/modules)
Comment 1 Albert Astals Cid 2017-08-15 09:07:36 UTC
I honestly don't see a reason why we should support that.
Comment 2 Aki Koskinen 2017-08-17 06:46:04 UTC
(In reply to Albert Astals Cid from comment #1)
> I honestly don't see a reason why we should support that.

Right. Using git submodules and CMake subprojects is a handy way to combine many projects together (which I tried to describe in the original report), but if that's not reason enough then what can I say.
Comment 3 Albert Astals Cid 2017-08-17 20:58:24 UTC
The problem is, no one is ever going to think about using ${CMAKE_CURRENT_LIST_DIR} instead of ${CMAKE_SOURCE_DIR} because when you're writing the code, you're not thinking about "people that abuse cmake to make my code be a subfolder of their code".

We might fix this, but it'd break again at some point because i'm never going to remember to use a weird variable instead of the variable that i'm used to using.

I'm sorry if this causes you trouble, but i'm going to close this as WONTFIX.

Maybe what you want is https://cmake.org/cmake/help/latest/module/ExternalProject.html ?


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.