OSDN Git Service

binding with libharu.
[putex/putex.git] / src / texsourc / lib / libhpdf / CMakeLists.txt
1 # CMakeLists.txt
2 #
3 # Copyright (C) 2008  Werner Smekal
4 #
5 # Process this file with cmake to produce Makefiles or project files
6 # for your specific compiler tool set
7 #
8 # TODO:
9 # - shared and static library
10 # - packaging
11 # - devpackage
12 # =======================================================================
13 # libharu project
14 # =======================================================================
15 project(libharu C)
16
17 # determine compiler name
18 set(COMPILER_LABEL "unknown")
19 if(CMAKE_COMPILER_IS_GNUCC)
20   set(COMPILER_LABEL "gcc")
21 endif(CMAKE_COMPILER_IS_GNUCC)
22 if(MSVC)
23   set(COMPILER_LABEL "vc")
24 endif(MSVC)
25
26 # information about libharu
27 set(LIBHARU_MAJOR 2)
28 set(LIBHARU_MINOR 2)
29 set(LIBHARU_PATCH 0)
30 set(LIBHARU_VERSION ${LIBHARU_MAJOR}.${LIBHARU_MINOR}.${LIBHARU_PATCH})
31 set(LIBHARU_DESCRIPTION "libHaru is a free, cross platform, open source library for generating PDF files.")
32 set(LIBHARU_PACKAGE_NAME "libHaru-${LIBHARU_VERSION}-${COMPILER_LABEL}")
33
34 # we want cmake version 2.4.8 at least
35 cmake_minimum_required(VERSION 2.4.8 FATAL_ERROR)
36
37 # Location where the haru cmake build system first looks for cmake modules
38 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
39
40 # set library name, msvc does not append 'lib' automatically
41 if(MSVC)
42  set(LIBHARU_NAME lib)
43  set(CMAKE_DEBUG_POSTFIX "d")
44 endif(MSVC)
45 set(LIBHARU_NAME ${LIBHARU_NAME}hpdf)
46 set(LIBHARU_NAME_STATIC ${LIBHARU_NAME}s)
47
48 # =======================================================================
49 # command line options
50 # =======================================================================
51 option(LIBHARU_SHARED "Build shared lib" YES)
52 option(LIBHARU_STATIC "Build static lib" YES)
53 option(LIBHARU_EXAMPLES "Build libharu examples" NO)
54 option(DEVPAK "Create DevPackage" NO)
55
56 if(DEVPAK AND NOT WIN32)
57   message( STATUS "DevPackage only available for Win32. Set DEVPAK to OFF." )
58   set(DEVPAK OFF)
59 endif(DEVPAK AND NOT WIN32)
60 if(DEVPAK AND LIBHARU_EXAMPLES)
61   message( STATUS "Examples are not build for DevPackage. Set LIBHARU_EXAMPLES to OFF." )
62   set(LIBHARU_EXAMPLES OFF)
63 endif(DEVPAK AND LIBHARU_EXAMPLES)
64
65 if(BUILD_SHARED_LIBS)
66   set(LIBHARU_SHARED ON)
67 endif(BUILD_SHARED_LIBS)
68
69 # =======================================================================
70 # look for headers and libraries
71 # =======================================================================
72 include(haru)
73 include(summary)
74
75 # check zlib availibility
76 find_package(ZLIB)
77 if(ZLIB_FOUND)
78   set(HAVE_LIBZ ON)
79   include_directories(${ZLIB_INCLUDE_DIR})
80   set(ADDITIONAL_LIBRARIES ${ZLIB_LIBRARIES})
81 else(ZLIB_FOUND)
82   set(HPDF_NOZLIB ON)  
83 endif(ZLIB_FOUND)
84   
85 # check png availibility
86 find_package(PNG)
87 if(PNG_FOUND)
88   set(HAVE_LIBPNG ON)
89   include_directories(${PNG_INCLUDE_DIR})
90   add_definitions(${PNG_DEFINITIONS})
91   set(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${PNG_LIBRARIES})
92 else(PNG_FOUND)
93   set(HPDF_NOPNGLIB ON)  
94 endif(PNG_FOUND)
95
96 # =======================================================================
97 # configure header files, add compiler flags
98 # =======================================================================
99 # add definitions and directories to include
100 #if(CMAKE_COMPILER_IS_GNUCC)
101 #  add_definitions("-Wall")
102 #endif(CMAKE_COMPILER_IS_GNUCC)
103 if(MSVC_VERSION GREATER 1399)
104   add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
105 endif(MSVC_VERSION GREATER 1399)
106 include_directories(${CMAKE_SOURCE_DIR}/include)
107
108 # create hpdf_config.h
109 configure_file(
110   ${CMAKE_SOURCE_DIR}/include/hpdf_config.h.cmake
111   ${CMAKE_BINARY_DIR}/include/hpdf_config.h
112 )
113 include_directories(${CMAKE_BINARY_DIR}/include)
114
115 # create DevPackage file
116 if(DEVPAK)
117   configure_file(
118     ${CMAKE_SOURCE_DIR}/libharu.DevPackage.cmake
119     ${CMAKE_BINARY_DIR}/libharu.DevPackage
120   )
121 endif(DEVPAK)
122 # =======================================================================
123 # create library and demos
124 # =======================================================================
125 add_subdirectory(src)
126 add_subdirectory(demo)
127
128 # =======================================================================
129 # installation configuration
130 # =======================================================================
131 set(
132   haru_HDRS
133     include/hpdf.h
134     include/hpdf_types.h
135     include/hpdf_consts.h 
136     include/hpdf_version.h
137     include/hpdf_annotation.h
138     include/hpdf_catalog.h
139     include/hpdf_conf.h
140     include/hpdf_destination.h
141     include/hpdf_doc.h
142     include/hpdf_encoder.h
143     include/hpdf_encrypt.h
144     include/hpdf_encryptdict.h
145     include/hpdf_error.h
146     include/hpdf_ext_gstate.h
147     include/hpdf_font.h
148     include/hpdf_fontdef.h
149     include/hpdf_gstate.h
150     include/hpdf_image.h
151     include/hpdf_info.h
152     include/hpdf_list.h
153     include/hpdf_mmgr.h
154     include/hpdf_objects.h
155     include/hpdf_outline.h
156     include/hpdf_pages.h
157     include/hpdf_page_label.h
158     include/hpdf_streams.h
159     include/hpdf_u3d.h
160     include/hpdf_utils.h
161     include/hpdf_pdfa.h
162     include/hpdf_3dmeasure.h
163     include/hpdf_exdata.h
164     ${CMAKE_BINARY_DIR}/include/hpdf_config.h
165 )
166
167 # install header files
168 install(FILES ${haru_HDRS} DESTINATION include)
169
170 # install various files
171 install(FILES README CHANGES INSTALL DESTINATION .)
172 install(DIRECTORY doc DESTINATION .)
173 if(NOT DEVPAK)
174   install(DIRECTORY if DESTINATION .)
175 endif(NOT DEVPAK)
176 if(DEVPAK)
177   install(FILES ${CMAKE_BINARY_DIR}/libharu.DevPackage DESTINATION .)
178 endif(DEVPAK)
179 # =======================================================================
180 # print out some information
181 # =======================================================================
182 summary()
183
184 # =======================================================================
185 # packing stuff
186 # =======================================================================
187 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${LIBHARU_DESCRIPTION})
188 set(CPACK_PACKAGE_VENDOR "Werner Smekal")
189 set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
190 set(CPACK_PACKAGE_VERSION_MAJOR "${LIBHARU_MAJOR}")
191 set(CPACK_PACKAGE_VERSION_MINOR "${LIBHARU_MINOR}")
192 set(CPACK_PACKAGE_VERSION_PATCH "${LIBHARU_PATCH}")
193 set(CPACK_PACKAGE_FILE_NAME "libHaru-${LIBHARU_VERSION}-${COMPILER_LABEL}")
194
195 set(CPACK_STRIP_FILES ON)
196
197 if(WIN32)
198   set(CPACK_GENERATOR ZIP)
199 else(WIN32)
200   set(CPACK_GENERATOR TGZ)
201 endif(WIN32)
202
203 INCLUDE( CPack )