CMakeLists.txt 4.22 KB
Newer Older
1 2 3
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
4
  ${GLIB2_INCLUDE_DIRS}
5
  ${CAIRO_INCLUDE_DIRS}
6
)
7
add_definitions(
8
  -DG_LOG_DOMAIN=\"Poppler\"
9
  ${GLIB2_CFLAGS_OTHER}
10 11 12 13
  ${CAIRO_CFLAGS}
  ${POPPLER_GLIB_DISABLE_DEPRECATED}
  ${POPPLER_GLIB_DISABLE_SINGLE_INCLUDES}
)
14

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

17
if (GTK_FOUND AND BUILD_GTK_TESTS)
18
  add_subdirectory(demo)
19
endif (GTK_FOUND AND BUILD_GTK_TESTS)
20 21 22

set(poppler_glib_public_headers
  poppler-action.h
Pino Toscano's avatar
Pino Toscano committed
23
  poppler-date.h
24 25 26 27
  poppler-document.h
  poppler-page.h
  poppler-attachment.h
  poppler-form-field.h
28
  poppler-annot.h
29
  poppler-layer.h
30 31
  poppler-movie.h
  poppler-media.h
32 33 34 35 36 37 38 39 40
  poppler.h
)

find_program(GLIB2_MKENUMS glib-mkenums)

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
  COMMAND ${GLIB2_MKENUMS}
  ARGS
41
    --template poppler-enums.h.template
42 43 44
    ${poppler_glib_public_headers} > ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.h
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  DEPENDS ${poppler_glib_public_headers}
45
          ${CMAKE_CURRENT_SOURCE_DIR}/poppler-enums.h.template
46 47 48 49 50 51
)

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
  COMMAND ${GLIB2_MKENUMS}
  ARGS
52
    --template poppler-enums.c.template
53 54 55
    ${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
56
          ${CMAKE_CURRENT_SOURCE_DIR}/poppler-enums.c.template
57 58 59 60 61
)


set(poppler_glib_SRCS
  poppler-action.cc
Pino Toscano's avatar
Pino Toscano committed
62
  poppler-date.cc
63 64 65 66
  poppler-document.cc
  poppler-page.cc
  poppler-attachment.cc
  poppler-form-field.cc
67
  poppler-annot.cc
Albert Astals Cid's avatar
Albert Astals Cid committed
68
  poppler-layer.cc
69 70
  poppler-movie.cc
  poppler-media.cc
71
  poppler.cc
Albert Astals Cid's avatar
Albert Astals Cid committed
72 73
  poppler-cached-file-loader.cc
  poppler-input-stream.cc
74 75
)
set(poppler_glib_generated_SRCS
76
  ${CMAKE_CURRENT_BINARY_DIR}/poppler-enums.c
77 78 79
  ${CMAKE_SOURCE_DIR}/poppler/CairoFontEngine.cc
  ${CMAKE_SOURCE_DIR}/poppler/CairoOutputDev.cc
  ${CMAKE_SOURCE_DIR}/poppler/CairoRescaleBox.cc
80
)
81
add_library(poppler-glib SHARED ${poppler_glib_SRCS} ${poppler_glib_generated_SRCS})
82
set_target_properties(poppler-glib PROPERTIES VERSION 8.6.0 SOVERSION 8)
83
target_link_libraries(poppler-glib poppler ${GLIB2_LIBRARIES} ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES})
84 85 86
if(HAVE_PTHREAD)
   target_link_libraries(poppler-glib -lpthread)
endif()
87
install(TARGETS poppler-glib RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX})
88 89 90 91 92 93 94

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

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

99

100 101 102 103 104 105 106 107 108 109 110
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)
  include(GObjectIntrospectionMacros)
  set(INTROSPECTION_GIRS)
111
  set(INTROSPECTION_SCANNER_ARGS "--add-include-path=${CMAKE_CURRENT_SOURCE_DIR} --warn-all")
112 113
  set(INTROSPECTION_COMPILER_ARGS "--includedir=${CMAKE_CURRENT_SOURCE_DIR}")

114
  set(introspection_files ${poppler_glib_SRCS} ${poppler_glib_public_headers})
Albert Astals Cid's avatar
Albert Astals Cid committed
115
  set(Poppler_0_18_gir "poppler-glib")
116
  set(Poppler_0_18_gir_INCLUDES GObject-2.0 Gio-2.0 cairo-1.0)
117 118
  get_directory_property(_tmp_includes INCLUDE_DIRECTORIES)
  _list_prefix(_includes _tmp_includes "-I")
Albert Astals Cid's avatar
Albert Astals Cid committed
119 120
  set(Poppler_0_18_gir_CFLAGS ${_includes})
  set(Poppler_0_18_gir_LIBS poppler-glib)
121 122 123 124
  _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
125
    ${CMAKE_CURRENT_BINARY_DIR}/poppler-features.h
126
  )
Albert Astals Cid's avatar
Albert Astals Cid committed
127
  set(Poppler_0_18_gir_FILES ${_abs_introspection_files})
128 129
  set(Poppler_0_18_gir_SCANNERFLAGS --c-include poppler.h)
  set(Poppler_0_18_gir_EXPORT_PACKAGES poppler-glib)
130

Albert Astals Cid's avatar
Albert Astals Cid committed
131
  list(APPEND INTROSPECTION_GIRS Poppler-0.18.gir)
132 133 134

  gir_add_introspections(INTROSPECTION_GIRS)
endif ()