summaryrefslogtreecommitdiff
path: root/glib/CMakeLists.txt
blob: ca5021f75184a0d68526b5d3e74e7054c3e890b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
)

include_directories(
  SYSTEM
  ${GLIB2_INCLUDE_DIRS}
  ${CAIRO_INCLUDE_DIRS}
)
add_definitions(
  -DG_LOG_DOMAIN=\"Poppler\"
  ${GLIB2_CFLAGS_OTHER}
  ${CAIRO_CFLAGS}
  ${POPPLER_GLIB_DISABLE_DEPRECATED}
  ${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES}
)

configure_file(poppler-features.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/poppler-features.h @ONLY)

if (GTK_FOUND AND BUILD_GTK_TESTS)
  add_subdirectory(demo)
endif ()

set(poppler_glib_public_headers
  poppler-action.h
  poppler-date.h
  poppler-document.h
  poppler-page.h
  poppler-attachment.h
  poppler-form-field.h
  poppler-annot.h
  poppler-layer.h
  poppler-macros.h
  poppler-movie.h
  poppler-media.h
  poppler.h
  poppler-structure-element.h
)

find_program(GLIB2_MKENUMS glib-mkenums)

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
  COMMAND ${GLIB2_MKENUMS}
  ARGS
    --template poppler-enums.h.template
    ${poppler_glib_public_headers} > ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${poppler_glib_public_headers}
          ${CMAKE_CURRENT_SOURCE_DIR}/poppler-enums.h.template
)

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
  COMMAND ${GLIB2_MKENUMS}
  ARGS
    --template poppler-enums.c.template
    ${poppler_glib_public_headers} > ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${poppler_glib_public_headers} ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
          ${CMAKE_CURRENT_SOURCE_DIR}/poppler-enums.c.template
)


set(poppler_glib_SRCS
  poppler-action.cc
  poppler-date.cc
  poppler-document.cc
  poppler-page.cc
  poppler-attachment.cc
  poppler-form-field.cc
  poppler-annot.cc
  poppler-layer.cc
  poppler-movie.cc
  poppler-media.cc
  poppler.cc
  poppler-cached-file-loader.cc
  poppler-input-stream.cc
  poppler-structure-element.cc
)
set(poppler_glib_generated_SRCS
  ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
  ${CMAKE_SOURCE_DIR}/poppler/CairoFontEngine.cc
  ${CMAKE_SOURCE_DIR}/poppler/CairoOutputDev.cc
  ${CMAKE_SOURCE_DIR}/poppler/CairoRescaleBox.cc
)
add_library(poppler-glib ${poppler_glib_SRCS} ${poppler_glib_generated_SRCS})
set_target_properties(poppler-glib PROPERTIES VERSION 8.12.0 SOVERSION 8)
set_target_properties(poppler-glib PROPERTIES C_VISIBILITY_PRESET hidden)
set_target_properties(poppler-glib PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(poppler-glib PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
if(MINGW AND BUILD_SHARED_LIBS)
    get_target_property(POPPLER_GLIB_SOVERSION poppler-glib SOVERSION)
    set_target_properties(poppler-glib PROPERTIES SUFFIX "-${POPPLER_GLIB_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.6.0")
    target_link_libraries(poppler-glib poppler ${GLIB2_LIBRARIES} ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES})
else()
    target_link_libraries(poppler-glib poppler PkgConfig::GLIB2 ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES})
endif()
if(CMAKE_USE_PTHREADS_INIT)
   target_link_libraries(poppler-glib Threads::Threads)
endif()
install(TARGETS poppler-glib RUNTIME DESTINATION bin LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES
  ${poppler_glib_public_headers}
  ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
  ${CMAKE_CURRENT_BINARY_DIR}/poppler-features.h
  DESTINATION include/poppler/glib)

set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
  "${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c"
)


macro(_list_prefix _outvar _listvar _prefix)
  set(${_outvar})
  foreach(_item IN LISTS ${_listvar})
    list(APPEND ${_outvar} ${_prefix}${_item})
  endforeach()
endmacro(_list_prefix)

# GObject Introspection
if (HAVE_INTROSPECTION AND BUILD_SHARED_LIBS)
  include(GObjectIntrospectionMacros)
  set(INTROSPECTION_GIRS)
  set(INTROSPECTION_SCANNER_ARGS "--add-include-path=${CMAKE_CURRENT_SOURCE_DIR} --warn-all")
  set(INTROSPECTION_COMPILER_ARGS "--includedir=${CMAKE_CURRENT_SOURCE_DIR}")

  set(introspection_files ${poppler_glib_SRCS} ${poppler_glib_public_headers})
  set(Poppler_0_18_gir "poppler-glib")
  set(Poppler_0_18_gir_INCLUDES GObject-2.0 Gio-2.0 cairo-1.0)
  get_directory_property(_tmp_includes INCLUDE_DIRECTORIES)
  _list_prefix(_includes _tmp_includes "-I")
  set(Poppler_0_18_gir_CFLAGS ${_includes} -L${CMAKE_BINARY_DIR} -L${CMAKE_CURRENT_BINARY_DIR})
  set(Poppler_0_18_gir_LIBS poppler-glib poppler)
  _list_prefix(_abs_introspection_files introspection_files "${CMAKE_CURRENT_SOURCE_DIR}/")
  list(APPEND _abs_introspection_files
    ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
    ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
    ${CMAKE_CURRENT_BINARY_DIR}/poppler-features.h
  )
  set(Poppler_0_18_gir_FILES ${_abs_introspection_files})
  set(Poppler_0_18_gir_SCANNERFLAGS --c-include poppler.h)
  set(Poppler_0_18_gir_EXPORT_PACKAGES poppler-glib)

  list(APPEND INTROSPECTION_GIRS Poppler-0.18.gir)

  gir_add_introspections(INTROSPECTION_GIRS)
endif ()

if(ENABLE_GTK_DOC)
  add_subdirectory(reference)
endif()