1 # - Find the native FLTK2 includes and library
2 # The following settings are defined
3 # FLTK2_FLUID_EXECUTABLE, where to find the Fluid tool
4 # FLTK2_WRAP_UI, This enables the FLTK2_WRAP_UI command
5 # FLTK2_INCLUDE_DIR, where to find include files
6 # FLTK2_LIBRARIES, list of fltk2 libraries
7 # FLTK2_FOUND, Don't use FLTK2 if false.
8 # The following settings should not be used in general.
9 # FLTK2_BASE_LIBRARY = the full path to fltk2.lib
10 # FLTK2_GL_LIBRARY = the full path to fltk2_gl.lib
11 # FLTK2_IMAGES_LIBRARY = the full path to fltk2_images.lib
13 SET (FLTK2_DIR $ENV{FLTK2_DIR} )
15 # Platform dependent libraries required by FLTK2
19 SET( FLTK2_PLATFORM_DEPENDENT_LIBS import32 )
21 SET( FLTK2_PLATFORM_DEPENDENT_LIBS wsock32 comctl32 )
27 INCLUDE(${CMAKE_ROOT}/Modules/FindX11.cmake)
28 SET( FLTK2_PLATFORM_DEPENDENT_LIBS ${X11_LIBRARIES} -lm)
32 SET( FLTK2_PLATFORM_DEPENDENT_LIBS "-framework Carbon -framework Cocoa -framework ApplicationServices -lz")
36 SET( FLTK2_PLATFORM_DEPENDENT_LIBS ole32 uuid comctl32 wsock32 supc++ -lm -lgdi32)
39 # If FLTK2_INCLUDE_DIR is already defined we assigne its value to FLTK2_DIR
41 SET(FLTK2_DIR ${FLTK2_INCLUDE_DIR})
42 ELSE(FLTK2_INCLUDE_DIR)
43 SET(FLTK2_INCLUDE_DIR ${FLTK2_DIR})
44 ENDIF(FLTK2_INCLUDE_DIR)
47 # If FLTK2 has been built using CMake we try to find everything directly
48 SET(FLTK2_DIR_STRING "directory containing FLTK2Config.cmake. This is either the root of the build tree, or PREFIX/lib/fltk for an installation.")
50 # Search only if the location is not already known.
52 # Get the system search path as a list.
54 STRING(REGEX MATCHALL "[^:]+" FLTK2_DIR_SEARCH1 "$ENV{PATH}")
56 STRING(REGEX REPLACE "\\\\" "/" FLTK2_DIR_SEARCH1 "$ENV{PATH}")
58 STRING(REGEX REPLACE "/;" ";" FLTK2_DIR_SEARCH2 ${FLTK2_DIR_SEARCH1})
60 # Construct a set of paths relative to the system search path.
61 SET(FLTK2_DIR_SEARCH "")
62 FOREACH(dir ${FLTK2_DIR_SEARCH2})
63 SET(FLTK2_DIR_SEARCH ${FLTK2_DIR_SEARCH} "${dir}/../lib/fltk")
67 # Look for an installation or build tree.
69 FIND_PATH(FLTK2_DIR FLTK2Config.cmake
70 # Look for an environment variable FLTK2_DIR.
73 # Look in places relative to the system executable search path.
76 # Look in standard UNIX install locations.
84 # Read from the CMakeSetup registry entries. It is likely that
85 # FLTK2 will have been recently built.
86 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
87 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
88 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
89 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
90 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
91 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
92 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
93 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
94 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
95 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
97 # Help the user find it if we cannot.
98 DOC "The ${FLTK2_DIR_STRING}"
102 FIND_PATH(FLTK2_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH})
108 # If FLTK2 was found, load the configuration file to get the rest of the
112 # Check if FLTK2 was built using CMake
113 IF(EXISTS ${FLTK2_DIR}/FLTK2Config.cmake)
114 SET(FLTK2_BUILT_WITH_CMAKE 1)
115 ENDIF(EXISTS ${FLTK2_DIR}/FLTK2Config.cmake)
117 IF(FLTK2_BUILT_WITH_CMAKE)
119 INCLUDE(${FLTK2_DIR}/FLTK2Config.cmake)
123 SET(FLTK2_FLUID_EXECUTABLE ${FLUID_COMMAND} CACHE FILEPATH "Fluid executable")
125 FIND_PROGRAM(FLTK2_FLUID_EXECUTABLE fluid2 PATHS
126 ${FLTK2_EXECUTABLE_DIRS}
127 ${FLTK2_EXECUTABLE_DIRS}/RelWithDebInfo
128 ${FLTK2_EXECUTABLE_DIRS}/Debug
129 ${FLTK2_EXECUTABLE_DIRS}/Release
133 MARK_AS_ADVANCED(FLTK2_FLUID_EXECUTABLE)
134 SET( FLTK_FLUID_EXECUTABLE ${FLTK2_FLUID_EXECUTABLE} )
139 SET(FLTK2_INCLUDE_DIR ${FLTK2_DIR})
140 LINK_DIRECTORIES(${FLTK2_LIBRARY_DIRS})
142 SET(FLTK2_BASE_LIBRARY fltk2)
143 SET(FLTK2_GL_LIBRARY fltk2_gl)
144 SET(FLTK2_IMAGES_LIBRARY fltk2_images)
146 # Add the extra libraries
147 LOAD_CACHE(${FLTK2_DIR}
149 FL FLTK2_USE_SYSTEM_JPEG
150 FL FLTK2_USE_SYSTEM_PNG
151 FL FLTK2_USE_SYSTEM_ZLIB
154 SET(FLTK2_IMAGES_LIBS "")
155 IF(FLFLTK2_USE_SYSTEM_JPEG)
156 SET(FLTK2_IMAGES_LIBS ${FLTK2_IMAGES_LIBS} fltk2_jpeg)
157 ENDIF(FLFLTK2_USE_SYSTEM_JPEG)
158 IF(FLFLTK2_USE_SYSTEM_PNG)
159 SET(FLTK2_IMAGES_LIBS ${FLTK2_IMAGES_LIBS} fltk2_png)
160 ENDIF(FLFLTK2_USE_SYSTEM_PNG)
161 IF(FLFLTK2_USE_SYSTEM_ZLIB)
162 SET(FLTK2_IMAGES_LIBS ${FLTK2_IMAGES_LIBS} fltk2_zlib)
163 ENDIF(FLFLTK2_USE_SYSTEM_ZLIB)
164 SET(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL
165 "Extra libraries for fltk2_images library.")
167 ELSE(FLTK2_BUILT_WITH_CMAKE)
169 # if FLTK2 was not built using CMake
170 # Find fluid executable.
171 FIND_PROGRAM(FLTK2_FLUID_EXECUTABLE fluid2 ${FLTK2_INCLUDE_DIR}/fluid)
173 # Use location of fluid to help find everything else.
174 SET(FLTK2_INCLUDE_SEARCH_PATH "")
175 SET(FLTK2_LIBRARY_SEARCH_PATH "")
176 IF(FLTK2_FLUID_EXECUTABLE)
177 SET( FLTK_FLUID_EXECUTABLE ${FLTK2_FLUID_EXECUTABLE} )
178 GET_FILENAME_COMPONENT(FLTK2_BIN_DIR "${FLTK2_FLUID_EXECUTABLE}" PATH)
179 SET(FLTK2_INCLUDE_SEARCH_PATH ${FLTK2_INCLUDE_SEARCH_PATH}
180 ${FLTK2_BIN_DIR}/../include ${FLTK2_BIN_DIR}/..)
181 SET(FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_LIBRARY_SEARCH_PATH}
182 ${FLTK2_BIN_DIR}/../lib)
184 ENDIF(FLTK2_FLUID_EXECUTABLE)
186 SET(FLTK2_INCLUDE_SEARCH_PATH ${FLTK2_INCLUDE_SEARCH_PATH}
193 FIND_PATH(FLTK2_INCLUDE_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH})
195 SET(FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_LIBRARY_SEARCH_PATH}
200 ${FLTK2_INCLUDE_DIR}/lib
203 FIND_LIBRARY(FLTK2_BASE_LIBRARY NAMES fltk2
204 PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
205 FIND_LIBRARY(FLTK2_GL_LIBRARY NAMES fltk2_gl
206 PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
207 FIND_LIBRARY(FLTK2_IMAGES_LIBRARY NAMES fltk2_images
208 PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
210 # Find the extra libraries needed for the fltk_images library.
212 FIND_PROGRAM(FLTK2_CONFIG_SCRIPT fltk2-config PATHS ${FLTK2_BIN_DIR})
213 IF(FLTK2_CONFIG_SCRIPT)
214 EXEC_PROGRAM(${FLTK2_CONFIG_SCRIPT} ARGS --use-images --ldflags
215 OUTPUT_VARIABLE FLTK2_IMAGES_LDFLAGS)
216 SET(FLTK2_LIBS_EXTRACT_REGEX ".*-lfltk2_images (.*) -lfltk2.*")
217 IF("${FLTK2_IMAGES_LDFLAGS}" MATCHES "${FLTK2_LIBS_EXTRACT_REGEX}")
218 STRING(REGEX REPLACE "${FLTK2_LIBS_EXTRACT_REGEX}" "\\1"
219 FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LDFLAGS}")
220 STRING(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}")
221 # The EXEC_PROGRAM will not be inherited into subdirectories from
222 # the file that originally included this module. Save the answer.
223 SET(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL
224 "Extra libraries for fltk_images library.")
225 ENDIF("${FLTK2_IMAGES_LDFLAGS}" MATCHES "${FLTK2_LIBS_EXTRACT_REGEX}")
226 ENDIF(FLTK2_CONFIG_SCRIPT)
229 ENDIF(FLTK2_BUILT_WITH_CMAKE)
234 FOREACH(var FLTK2_FLUID_EXECUTABLE FLTK2_INCLUDE_DIR
235 FLTK2_BASE_LIBRARY FLTK2_GL_LIBRARY
236 FLTK2_IMAGES_LIBRARY)
238 MESSAGE( STATUS "${var} not found" )
245 SET(FLTK2_LIBRARIES ${FLTK2_IMAGES_LIBRARY} ${FLTK2_IMAGES_LIBS} ${FLTK2_BASE_LIBRARY} ${FLTK2_GL_LIBRARY} )
247 SET(FLTK2_LIBRARIES ${FLTK2_PLATFORM_DEPENDENT_LIBS} ${FLTK2_LIBRARIES})
249 SET(FLTK2_LIBRARIES ${FLTK2_LIBRARIES} ${FLTK2_PLATFORM_DEPENDENT_LIBS})
252 # The following deprecated settings are for compatibility with CMake 1.4
253 SET (HAS_FLTK2 ${FLTK2_FOUND})
254 SET (FLTK2_INCLUDE_PATH ${FLTK2_INCLUDE_DIR})
255 SET (FLTK2_FLUID_EXE ${FLTK2_FLUID_EXECUTABLE})
256 SET (FLTK2_LIBRARY ${FLTK2_LIBRARIES})
258 # make FIND_PACKAGE friendly
259 IF(NOT FLTK2_FIND_QUIETLY)
260 IF(FLTK2_FIND_REQUIRED)
262 "FLTK2 required, please specify its location with FLTK2_DIR.")
263 ELSE(FLTK2_FIND_REQUIRED)
264 MESSAGE(STATUS "FLTK2 was not found.")
265 ENDIF(FLTK2_FIND_REQUIRED)
266 ENDIF(NOT FLTK2_FIND_QUIETLY)