Fl_Menu: Work better with scheme background image.
[ntk.git] / CMakeLists.txt
bloba604fb6a4d1bd6acf4809e6a5cc985351830391b
2 # "$Id: CMakeLists.txt 8198 2011-01-06 10:24:58Z manolo $"
4 # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
5 # Written by Andy Cedilnik and Julien Jomier
7 # Copyright 1998-2010 by Bill Spitzak and others.
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Library General Public
11 # License as published by the Free Software Foundation; either
12 # version 2 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Library General Public License for more details.
19 # You should have received a copy of the GNU Library General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 # USA.
24 # Please report all bugs and problems on the following page:
26 #     http:#www.fltk.org/str.php
29 #######################################################################
30 # basic setup
31 #######################################################################
32 project(FLTK)
33 cmake_minimum_required(VERSION 2.6)
35 # The FLTK version
36 set(FLTK_VERSION_MAJOR "1")
37 set(FLTK_VERSION_MINOR "3")
38 set(FLTK_VERSION_PATCH "0")
39 set(FLTK_VERSION "${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}")
40 set(FLTK_VERSION_FULL "${FLTK_VERSION}.${FLTK_VERSION_PATCH}")
42 set(EXECUTABLE_OUTPUT_PATH ${FLTK_BINARY_DIR}/bin)
43 set(LIBRARY_OUTPUT_PATH ${FLTK_BINARY_DIR}/lib)
44 set(ARCHIVE_OUTPUT_PATH ${FLTK_BINARY_DIR}/lib)
46 # Search for modules in the FLTK source dir first
47 set(CMAKE_MODULE_PATH "${FLTK_SOURCE_DIR}/CMake")
49 include_directories(${FLTK_BINARY_DIR} ${FLTK_SOURCE_DIR})
51 #######################################################################
52 # platform dependent information
53 #######################################################################
55 include(TestBigEndian)
56 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
58 if(APPLE)
59    set(__APPLE_QUARTZ__ 1)
60    set(HAVE_STRTOLL 1)
61    set(HAVE_STRCASECMP 1)
62    set(HAVE_DIRENT_H 1)
63    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
64 endif(APPLE)
66 if(WIN32)
67    if(MSVC)
68       add_definitions(-DWIN32_LEAN_AND_MEAN)
69       add_definitions(-D_CRT_SECURE_NO_WARNINGS)
70    endif(MSVC)
71    if(CMAKE_C_COMPILER_ID STREQUAL GNU)
72       set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-subsystem,windows")
73    endif(CMAKE_C_COMPILER_ID STREQUAL GNU)
74    if(MINGW AND EXISTS /mingw)
75       list(APPEND CMAKE_PREFIX_PATH /mingw)
76         endif(MINGW AND EXISTS /mingw)
77 endif(WIN32)
79 #######################################################################
80 # size of ints
81 include(CheckTypeSize)
83 CHECK_TYPE_SIZE(short SIZEOF_SHORT)
84 CHECK_TYPE_SIZE(int   SIZEOF_INT)
85 CHECK_TYPE_SIZE(long  SIZEOF_LONG)
86 CHECK_TYPE_SIZE("long long"  HAVE_LONG_LONG)
88 if(${SIZEOF_SHORT} MATCHES "^2$")
89    set(U16 "unsigned short")
90 endif(${SIZEOF_SHORT} MATCHES "^2$")
92 if(${SIZEOF_INT} MATCHES "^4$")
93    set(U32 "unsigned")
94 else()
95    if(${SIZEOF_LONG} MATCHES "^4$")
96       set(U32 "unsigned long")
97    endif(${SIZEOF_LONG} MATCHES "^4$")
98 endif(${SIZEOF_INT} MATCHES "^4$")
100 if(${SIZEOF_INT} MATCHES "^8$")
101    set(U64 "unsigned")
102 else()
103    if(${SIZEOF_LONG} MATCHES "^8$")
104       set(U64 "unsigned long")
105    endif(${SIZEOF_LONG} MATCHES "^8$")
106 endif(${SIZEOF_INT} MATCHES "^8$")
108 #######################################################################
109 # check for headers, libraries and functions
110 #######################################################################
111 # headers
112 find_file(HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h)
113 find_file(HAVE_DIRENT_H dirent.h)
114 find_file(HAVE_DLFCN_H dlfcn.h)
115 find_file(HAVE_FREETYPE_H freetype.h PATH_SUFFIXES freetype2)
116 find_file(HAVE_GL_GL_H GL/gl.h)
117 find_file(HAVE_GL_GLU_H GL/glu.h)
118 find_file(HAVE_LIBPNG_PNG_H libpng/png.h)
119 find_file(HAVE_LOCALE_H locale.h)
120 find_file(HAVE_NDIR_H ndir.h)
121 find_file(HAVE_OPENGL_GLU_H OpenGL/glu.h)
122 find_file(HAVE_PNG_H png.h)
123 find_file(HAVE_PTHREAD_H pthread.h)
124 find_file(HAVE_STDIO_H stdio.h)
125 find_file(HAVE_STRINGS_H strings.h)
126 find_file(HAVE_SYS_DIR_H sys/dir.h)
127 find_file(HAVE_SYS_NDIR_H sys/ndir.h)
128 find_file(HAVE_SYS_SELECT_H sys/select.h)
129 find_file(HAVE_SYS_STDTYPES_H sys/stdtypes.h)
131 mark_as_advanced(HAVE_ALSA_ASOUNDLIB_H HAVE_DIRENT_H HAVE_DLFCN_H)
132 mark_as_advanced(HAVE_FREETYPE_H HAVE_GL_GL_H HAVE_GL_GLU_H)
133 mark_as_advanced(HAVE_LIBPNG_PNG_H HAVE_LOCALE_H HAVE_NDIR_H)
134 mark_as_advanced(HAVE_OPENGL_GLU_H HAVE_PNG_H HAVE_PTHREAD_H)
135 mark_as_advanced(HAVE_STDIO_H HAVE_STRINGS_H HAVE_SYS_DIR_H)
136 mark_as_advanced(HAVE_SYS_NDIR_H HAVE_SYS_SELECT_H)
137 mark_as_advanced(HAVE_SYS_STDTYPES_H)
139 # where to find freetype headers
140 find_path(FREETYPE_PATH freetype/config/ftheader.h PATH_SUFFIXES freetype2)
141 if(FREETYPE_PATH)
142    include_directories(${FREETYPE_PATH})
143 endif(FREETYPE_PATH)
144 mark_as_advanced(FREETYPE_PATH)
146 #######################################################################
147 # libraries
148 find_library(LIB_CAIRO cairo)
149 find_library(LIB_fontconfig fontconfig)
150 find_library(LIB_freetype freetype)
151 find_library(LIB_GL GL)
152 find_library(LIB_MesaGL MesaGL)
153 find_library(LIB_jpeg jpeg)
154 find_library(LIB_png png)
155 find_library(LIB_zlib z)
157 mark_as_advanced(LIB_CAIRO LIB_fontconfig LIB_freetype)
158 mark_as_advanced(LIB_GL LIB_MesaGL)
159 mark_as_advanced(LIB_jpeg LIB_png LIB_zlib)
161 #######################################################################
162 # functions
163 include(CheckFunctionExists)
165 if(HAVE_DLFCN_H)
166    set(CMAKE_REQUIRED_LIBRARIES dl)
167 endif(HAVE_DLFCN_H)
168 CHECK_FUNCTION_EXISTS(dlsym                  HAVE_DLSYM)
170 CHECK_FUNCTION_EXISTS(localeconv             HAVE_LOCALECONV)
172 if(LIB_png)
173    set(CMAKE_REQUIRED_LIBRARIES png)
174 endif(LIB_png)
175 CHECK_FUNCTION_EXISTS(png_get_valid          HAVE_PNG_GET_VALID)
176 CHECK_FUNCTION_EXISTS(png_set_tRNS_to_alpha  HAVE_PNG_SET_TRNS_TO_ALPHA)
178 CHECK_FUNCTION_EXISTS(scandir                HAVE_SCANDIR)
179 CHECK_FUNCTION_EXISTS(snprintf               HAVE_SNPRINTF)
181 # not really true but we convert strcasecmp calls to _stricmp calls in flstring.h
182 if(MSVC)
183    set(HAVE_STRCASECMP 1)
184 endif(MSVC)
185 CHECK_FUNCTION_EXISTS(strcasecmp             HAVE_STRCASECMP)
187 CHECK_FUNCTION_EXISTS(strlcat                HAVE_STRLCAT)
188 CHECK_FUNCTION_EXISTS(strlcpy                HAVE_STRLCPY)
189 CHECK_FUNCTION_EXISTS(strtoll                HAVE_STRTOLL)
190 CHECK_FUNCTION_EXISTS(vsnprintf              HAVE_VSNPRINTF)
192 set(CMAKE_REQUIRED_LIBRARIES)
194 if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
195    set(MSG "POSIX compatible scandir")
196    message(STATUS "Looking for ${MSG}")
197    try_compile(V
198       ${FLTK_BINARY_DIR}
199       ${FLTK_SOURCE_DIR}/CMake/posixScandir.cxx
200       )
201    if(V)
202       message(STATUS "${MSG} - found")
203       set(HAVE_SCANDIR_POSIX 1 CACHE INTERNAL "")
204    else()
205       message(STATUS "${MSG} - not found")
206       set(HAVE_SCANDIR_POSIX HAVE_SCANDIR_POSIX-NOTFOUND)
207    endif(V)
208 endif(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
209 mark_as_advanced(HAVE_SCANDIR_POSIX)
211 #######################################################################
212 # options
213 #######################################################################
214 set(OPTION_OPTIM ""
215    CACHE STRING
216    "custom optimization flags"
217    )
218 add_definitions(${OPTION_OPTIM})
220 #######################################################################
221 set(OPTION_ARCHFLAGS ""
222    CACHE STRING
223    "custom architecture flags"
224    )
225 add_definitions(${OPTION_ARCHFLAGS})
227 #######################################################################
228 set(OPTION_PREFIX_BIN ""
229    CACHE STRING
230    "where to install executables - leave empty to use {CMAKE_INSTALL_PREFIX}/bin"
231    )
233 if(OPTION_PREFIX_BIN)
234    set(PREFIX_BIN ${OPTION_PREFIX_BIN} CACHE INTERNAL "" FORCE)
235 else()
236    set(PREFIX_BIN ${CMAKE_INSTALL_PREFIX}/bin CACHE INTERNAL "" FORCE)
237 endif(OPTION_PREFIX_BIN)
239 #######################################################################
240 set(OPTION_PREFIX_LIB ""
241    CACHE STRING
242    "where to install libraries - leave empty to use {CMAKE_INSTALL_PREFIX}/lib"
243    )
245 if(OPTION_PREFIX_LIB)
246    set(PREFIX_LIB ${OPTION_PREFIX_LIB} CACHE INTERNAL "" FORCE)
247 else()
248    set(PREFIX_LIB ${CMAKE_INSTALL_PREFIX}/lib CACHE INTERNAL "" FORCE)
249 endif(OPTION_PREFIX_LIB)
251 #######################################################################
252 set(OPTION_PREFIX_INCLUDE ""
253    CACHE STRING
254    "where to install include files - leave empty to use {CMAKE_INSTALL_PREFIX}/include"
255    )
257 if(OPTION_PREFIX_INCLUDE)
258    set(PREFIX_INCLUDE ${OPTION_PREFIX_INCLUDE} CACHE INTERNAL "" FORCE)
259 else()
260    set(PREFIX_INCLUDE ${CMAKE_INSTALL_PREFIX}/include CACHE INTERNAL "" FORCE)
261 endif(OPTION_PREFIX_INCLUDE)
263 #######################################################################
264 set(OPTION_PREFIX_DATA ""
265    CACHE STRING
266    "where to install data files - leave empty to use {CMAKE_INSTALL_PREFIX}/share/FLTK"
267    )
269 if(OPTION_PREFIX_DATA)
270    set(PREFIX_DATA ${OPTION_PREFIX_DATA} CACHE INTERNAL "" FORCE)
271 else()
272    set(PREFIX_DATA ${CMAKE_INSTALL_PREFIX}/share/FLTK CACHE INTERNAL "" FORCE)
273 endif(OPTION_PREFIX_DATA)
275 #######################################################################
276 set(OPTION_PREFIX_DOC ""
277    CACHE STRING
278    "where to install doc files - leave empty to use {CMAKE_INSTALL_PREFIX}/share/doc/FLTK"
279    )
281 if(OPTION_PREFIX_DOC)
282    set(PREFIX_DOC ${OPTION_PREFIX_DOC} CACHE INTERNAL "" FORCE)
283 else()
284    set(PREFIX_DOC ${CMAKE_INSTALL_PREFIX}/share/doc/FLTK CACHE INTERNAL "" FORCE)
285 endif(OPTION_PREFIX_DOC)
287 #######################################################################
288 if(WIN32)
289    set(DEFAULT_CONFIG "${CMAKE_INSTALL_PREFIX}/CMake")
290 elseif(APPLE)
291    set(DEFAULT_CONFIG "${CMAKE_INSTALL_PREFIX}/FLTK/.framework/Resources/CMake")
292 else()
293    set(DEFAULT_CONFIG "${CMAKE_INSTALL_PREFIX}/lib/FLTK-${FLTK_VERSION}")
294 endif(WIN32)
296 set(OPTION_PREFIX_CONFIG ""
297    CACHE STRING
298    "where to install CMake config files - leave empty to use ${DEFAULT_CONFIG}"
299    )
301 if(OPTION_PREFIX_CONFIG)
302    set(PREFIX_CONFIG "${OPTION_PREFIX_CONFIG}" CACHE INTERNAL "" FORCE)
303 else()
304    set(PREFIX_CONFIG "${DEFAULT_CONFIG}" CACHE INTERNAL "" FORCE)
305 endif(OPTION_PREFIX_CONFIG)
307 #######################################################################
308 if(CMAKE_HOST_UNIX)
309    set(OPTION_PREFIX_MAN ""
310       CACHE STRING
311       "where to install man files - leave empty to use {CMAKE_INSTALL_PREFIX}/man"
312       )
314    if(OPTION_PREFIX_MAN)
315       set(PREFIX_MAN ${OPTION_PREFIX_MAN} CACHE INTERNAL "" FORCE)
316    else()
317       set(PREFIX_MAN ${CMAKE_INSTALL_PREFIX}/man CACHE INTERNAL "" FORCE)
318    endif(OPTION_PREFIX_MAN)
320    option(OPTION_CREATE_LINKS "create backwards compatibility links" OFF)
321 endif(CMAKE_HOST_UNIX)
323 #######################################################################
324 if(APPLE)
325    option(OPTION_APPLE_X11 "use X11" OFF)
326 endif(APPLE)
328 if(NOT APPLE OR OPTION_APPLE_X11)
329    include(FindX11)
330    if(X11_FOUND)
331       set(USE_X11 1)
332       list(APPEND FLTK_CFLAGS -DUSE_X11)
333       list(APPEND FLTK_LDLIBS -lX11)
334    endif(X11_FOUND)
335 endif(NOT APPLE OR OPTION_APPLE_X11)
337 #######################################################################
338 option(OPTION_USE_POLL "use poll if available" OFF)
340 if(OPTION_USE_POLL)
341    CHECK_FUNCTION_EXISTS(poll USE_POLL)
342 endif(OPTION_USE_POLL)
344 #######################################################################
345 option(OPTION_BUILD_SHARED_LIBS "Build shared libraries" OFF)
347 #######################################################################
348 option(OPTION_BUILD_EXAMPLES "build example programs" ON)
350 #######################################################################
351 include(FindPkgConfig)
353 option(OPTION_CAIRO "use lib Cairo" OFF)
354 option(OPTION_CAIROEXT
355    "use fltk code instrumentation for cairo extended use" OFF
356    )
358 if(OPTION_CAIRO OR OPTION_CAIROEXT AND LIB_CAIRO)
359    pkg_search_module(PKG_CAIRO cairo)
360 endif(OPTION_CAIRO OR OPTION_CAIROEXT AND LIB_CAIRO)
362 if(PKG_CAIRO_FOUND)
363    set(FLTK_HAVE_CAIRO 1)
364   # add_subdirectory(cairo)
365    list(APPEND FLTK_LDLIBS -lcairo -lpixman-1)
366    include_directories(${PKG_CAIRO_INCLUDE_DIRS})
367    string(REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}")
368 endif(PKG_CAIRO_FOUND)
370 if(LIB_CAIRO AND OPTION_CAIROEXT AND PKG_CAIRO_FOUND)
371    set(FLTK_USE_CAIRO 1)
372    set(FLTK_CAIRO_FOUND TRUE)
373 else()
374    set(FLTK_CAIRO_FOUND FALSE)
375 endif(LIB_CAIRO AND OPTION_CAIROEXT AND PKG_CAIRO_FOUND)
377 #######################################################################
378 set(HAVE_GL LIB_GL OR LIB_MesaGL)
380 if(HAVE_GL)
381    option(OPTION_USE_GL "use OpenGL" ON)
382 endif(HAVE_GL)
384 if(OPTION_USE_GL)
385    include(FindOpenGL)
386 endif(OPTION_USE_GL)
388 if(OPENGL_FOUND)
389    set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL)
390    set(CMAKE_REQUIRED_LIBRARIES -lGLU -lGL)
391    CHECK_FUNCTION_EXISTS(glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB)
392    set(FLTK_GL_FOUND TRUE)
393 else()
394    set(FLTK_GL_FOUND FALSE)
395 endif(OPENGL_FOUND)
397 #######################################################################
398 option(OPTION_USE_THREADS "use multi-threading" ON)
400 if(OPTION_USE_THREADS)
401    include(FindThreads)
402 endif(OPTION_USE_THREADS)
404 if(OPTION_USE_THREADS AND CMAKE_HAVE_THREADS_LIBRARY)
405    add_definitions("-D_THREAD_SAFE -D_REENTRANT")
406    set(USE_THREADS 1)
407    set(FLTK_THREADS_FOUND TRUE)
408 else()
409    set(FLTK_THREADS_FOUND FALSE)
410 endif(OPTION_USE_THREADS AND CMAKE_HAVE_THREADS_LIBRARY)
412 if(OPTION_USE_THREADS AND CMAKE_USE_PTHREADS_INIT)
413    set(HAVE_PTHREAD 1)
414    list(APPEND FLTK_LDLIBS -lpthread)
415    list(APPEND FLTK_CFLAGS -D_THREAD_SAFE -D_REENTRANT)
416    set(FLTK_PTHREADS_FOUND TRUE)
417 else()
418    set(HAVE_PTHREAD 0)
419    set(HAVE_PTHREAD_H 0)
420    set(FLTK_PTHREADS_FOUND FALSE)
421 endif(OPTION_USE_THREADS AND CMAKE_USE_PTHREADS_INIT)
423 #######################################################################
424 option(OPTION_LARGE_FILE "enable large file support" ON)
426 if(OPTION_LARGE_FILE)
427    if(NOT MSVC)
428       add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
429       list(APPEND FLTK_CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE)
430    endif(NOT MSVC)
431 endif(OPTION_LARGE_FILE)
433 #######################################################################
434 option(OPTION_USE_SYSTEM_LIBJPEG "Use's system libjpeg" ON)
436 if(OPTION_USE_SYSTEM_LIBJPEG AND LIB_jpeg)
437    include(FindJPEG)
438 endif(OPTION_USE_SYSTEM_LIBJPEG AND LIB_jpeg)
440 if(OPTION_USE_SYSTEM_LIBJPEG AND JPEG_FOUND)
441    set(FLTK_JPEG_LIBRARIES ${JPEG_LIBRARIES})
442    include_directories(${JPEG_INCLUDE_DIR})
443    set(FLTK_BUILTIN_JPEG_FOUND FALSE)
444 else()
445    add_subdirectory(jpeg)
446    set(FLTK_JPEG_LIBRARIES fltk_jpeg)
447    include_directories(${FLTK_SOURCE_DIR}/jpeg)
448    set(FLTK_BUILTIN_JPEG_FOUND TRUE)
449 endif(OPTION_USE_SYSTEM_LIBJPEG AND JPEG_FOUND)
451 if(OPTION_USE_SYSTEM_LIBJPEG AND NOT JPEG_FOUND)
452    message(STATUS "\ncannot find system jpeg library - using built-in\n")
453 endif(OPTION_USE_SYSTEM_LIBJPEG AND NOT JPEG_FOUND)
455 set(HAVE_LIBJPEG 1)
457 #######################################################################
458 option(OPTION_USE_SYSTEM_ZLIB "Use's system zlib" ON)
460 if(OPTION_USE_SYSTEM_ZLIB AND LIB_zlib)
461    include(FindZLIB)
462 endif(OPTION_USE_SYSTEM_ZLIB AND LIB_zlib)
464 if(OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)
465    set(FLTK_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
466    include_directories(${ZLIB_INCLUDE_DIRS})
467    set(FLTK_BUILTIN_ZLIB_FOUND FALSE)
468 else()
469    add_subdirectory(zlib)
470    set(FLTK_ZLIB_LIBRARIES fltk_z)
471    set(ZLIB_INCLUDE_DIR ${FLTK_SOURCE_DIR}/zlib)
472    include_directories(${FLTK_SOURCE_DIR}/zlib)
473    set(FLTK_BUILTIN_ZLIB_FOUND TRUE)
474 endif(OPTION_USE_SYSTEM_ZLIB AND ZLIB_FOUND)
476 if(OPTION_USE_SYSTEM_ZLIB AND NOT ZLIB_FOUND)
477    message(STATUS "\ncannot find system zlib library - using built-in\n")
478 endif(OPTION_USE_SYSTEM_ZLIB AND NOT ZLIB_FOUND)
480 set(HAVE_LIBZ 1)
482 #######################################################################
483 option(OPTION_USE_SYSTEM_LIBPNG "Use's system libpng" ON)
485 if(OPTION_USE_SYSTEM_LIBPNG AND LIB_png)
486    include(FindPNG)
487 endif(OPTION_USE_SYSTEM_LIBPNG AND LIB_png)
489 if(OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)
490    set(FLTK_PNG_LIBRARIES ${PNG_LIBRARIES})
491    include_directories(${PNG_INCLUDE_DIR})
492    add_definitions(${PNG_DEFINITIONS})
493    set(FLTK_BUILTIN_PNG_FOUND FALSE)
494 else()
495    add_subdirectory(png)
496    set(FLTK_PNG_LIBRARIES fltk_png)
497    set(HAVE_PNG_H 1)
498    set(HAVE_PNG_GET_VALID 1)
499    set(HAVE_PNG_SET_TRNS_TO_ALPHA 1)
500    include_directories(${FLTK_SOURCE_DIR}/png)
501    set(FLTK_BUILTIN_PNG_FOUND TRUE)
502 endif(OPTION_USE_SYSTEM_LIBPNG AND PNG_FOUND)
504 if(OPTION_USE_SYSTEM_LIBPNG AND NOT PNG_FOUND)
505    message(STATUS "\ncannot find system png library - using built-in\n")
506 endif(OPTION_USE_SYSTEM_LIBPNG AND NOT PNG_FOUND)
508 set(HAVE_LIBPNG 1)
510 #######################################################################
511 if(X11_Xinerama_FOUND)
512    option(OPTION_USE_XINERAMA "use lib Xinerama" ON)
513 endif(X11_Xinerama_FOUND)
515 if(OPTION_USE_XINERAMA)
516    set(HAVE_XINERAMA ${X11_Xinerama_FOUND})
517    include_directories(${X11_Xinerama_INCLUDE_PATH})
518    list(APPEND FLTK_LDLIBS -lXinerama)
519    set(FLTK_XINERAMA_FOUND TRUE)
520 else()
521    set(FLTK_XINERAMA_FOUND FALSE)
522 endif(OPTION_USE_XINERAMA)
524 #######################################################################
525 if(X11_Xft_FOUND)
526    option(OPTION_USE_XFT "use lib Xft" ON)
527 endif(X11_Xft_FOUND)
529 if(OPTION_USE_XFT)
530    set(USE_XFT X11_Xft_FOUND)
531    list(APPEND FLTK_LDLIBS -lXft)
532    set(FLTK_XFT_FOUND TRUE)
533 else()
534    set(FLTK_XFT_FOUND FALSE)
535 endif(OPTION_USE_XFT)
537 #######################################################################
538 # final setup and config
539 #######################################################################
540 # Set the fluid executable path
541 if(CMAKE_CROSSCOMPILING)
542    find_file(FLUID_PATH
543       NAMES fluid fluid.exe
544       PATHS ENV PATH
545       NO_CMAKE_FIND_ROOT_PATH
546    )
547    add_executable(fluid IMPORTED)
548    set(FLTK_FLUID_EXECUTABLE ${FLUID_PATH})
549    set(FLTK_FLUID_PATH ${FLUID_PATH})
550    set_target_properties(fluid
551       PROPERTIES IMPORTED_LOCATION ${FLUID_PATH}
552    )
553 else()
554    add_subdirectory(fluid)
555    set(FLTK_FLUID_EXECUTABLE fluid)
556    set(FLTK_FLUID_PATH ${PREFIX_BIN}/fluid)
557 endif(CMAKE_CROSSCOMPILING)
559 add_subdirectory(src)
561 # generate FLTKConfig.cmake
562 string(REPLACE ";" " " EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
563 configure_file(
564    ${FLTK_SOURCE_DIR}/CMake/FLTKConfig.cmake.in
565    ${EXECUTABLE_OUTPUT_PATH}/FLTKConfig.cmake
566    @ONLY
569 # generate UseFLTK.cmake
570 configure_file(
571    ${FLTK_SOURCE_DIR}/CMake/UseFLTK.cmake.in
572    ${EXECUTABLE_OUTPUT_PATH}/UseFLTK.cmake
573    @ONLY
576 # generate config.h
577 configure_file(
578    "${FLTK_SOURCE_DIR}/configh.cmake.in"
579    "${FLTK_BINARY_DIR}/config.h"
580    @ONLY
583 # generate fltk-config
584 get_filename_component(CC ${CMAKE_C_COMPILER} NAME)
585 get_filename_component(CXX ${CMAKE_CXX_COMPILER} NAME)
587 string(REPLACE ";" " " C_FLAGS "${FLTK_CFLAGS}")
589 if(X11_Xext_FOUND)
590    list(APPEND FLTK_LDLIBS -lXext)
591 endif(X11_Xext_FOUND)
592 string(REPLACE ";" " " LD_LIBS "${FLTK_LDLIBS}")
594 configure_file(
595    "${FLTK_SOURCE_DIR}/fltk-config.cmake.in"
596    "${FLTK_BINARY_DIR}/fltk-config"
597    @ONLY
599 if(UNIX)
600    execute_process(COMMAND chmod 755 fltk-config
601       WORKING_DIRECTORY "${FLTK_BINARY_DIR}"
602    )
603 endif(UNIX)
605 if(OPTION_CREATE_LINKS)
606    configure_file(
607       "${FLTK_SOURCE_DIR}/CMake/install-symlinks.cmake.in"
608       "${FLTK_BINARY_DIR}/install-symlinks.cmake"
609       @ONLY
610    )
611 endif(OPTION_CREATE_LINKS)
613 # generate uninstall target
614 configure_file(
615   "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in"
616   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
617   @ONLY
619 add_custom_target(uninstall
620   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
623 #######################################################################
624 # build examples - these have to be after fluid is built/imported
625 #######################################################################
626 if(OPTION_BUILD_EXAMPLES)
627    add_subdirectory(test)
628 endif(OPTION_BUILD_EXAMPLES)
630 #######################################################################
631 # installation
632 #######################################################################
634 install(DIRECTORY ${FLTK_SOURCE_DIR}/FL
635    DESTINATION ${PREFIX_INCLUDE} USE_SOURCE_PERMISSIONS
636    PATTERN ".svn" EXCLUDE
639 if(OPTION_CREATE_LINKS)
640    install(SCRIPT ${FLTK_BINARY_DIR}/install-symlinks.cmake)
641 endif(OPTION_CREATE_LINKS)
643 install(PROGRAMS ${FLTK_BINARY_DIR}/fltk-config
644    DESTINATION ${PREFIX_BIN}
645    OPTIONAL
648 install(EXPORT fltk-install
649    DESTINATION ${PREFIX_CONFIG}
650    FILE FLTKLibraries.cmake
653 install(FILES ${EXECUTABLE_OUTPUT_PATH}/FLTKConfig.cmake
654    DESTINATION ${PREFIX_CONFIG}
657 install(FILES ${EXECUTABLE_OUTPUT_PATH}/UseFLTK.cmake
658    DESTINATION ${PREFIX_CONFIG}
661 if(CMAKE_HOST_UNIX)
662    macro(INSTALL_MAN FILE LEVEL)
663    install(FILES
664       ${FLTK_SOURCE_DIR}/documentation/src/${FILE}.man
665       DESTINATION ${PREFIX_MAN}/man${LEVEL}
666       RENAME ${FILE}.${LEVEL}
667    )
668    endmacro(INSTALL_MAN FILE LEVEL)
670    INSTALL_MAN(fluid 1)
671    INSTALL_MAN(fltk-config 1)
672    INSTALL_MAN(fltk 3)
673    INSTALL_MAN(blocks 6)
674    INSTALL_MAN(checkers 6)
675    INSTALL_MAN(sudoku 6)
677 endif(CMAKE_HOST_UNIX)