2016-09-27 22:01:08 +03:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindFLTK2
|
|
|
|
# ---------
|
|
|
|
#
|
|
|
|
# Find the native FLTK2 includes and library
|
|
|
|
#
|
2007-10-12 19:34:07 +04:00
|
|
|
# The following settings are defined
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# FLTK2_FLUID_EXECUTABLE, where to find the Fluid tool
|
|
|
|
# FLTK2_WRAP_UI, This enables the FLTK2_WRAP_UI command
|
|
|
|
# FLTK2_INCLUDE_DIR, where to find include files
|
|
|
|
# FLTK2_LIBRARIES, list of fltk2 libraries
|
|
|
|
# FLTK2_FOUND, Don't use FLTK2 if false.
|
|
|
|
#
|
2007-10-12 19:34:07 +04:00
|
|
|
# The following settings should not be used in general.
|
2013-10-15 19:17:36 +04:00
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# FLTK2_BASE_LIBRARY = the full path to fltk2.lib
|
|
|
|
# FLTK2_GL_LIBRARY = the full path to fltk2_gl.lib
|
|
|
|
# FLTK2_IMAGES_LIBRARY = the full path to fltk2_images.lib
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set (FLTK2_DIR $ENV{FLTK2_DIR} )
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Platform dependent libraries required by FLTK2
|
2012-08-13 21:47:32 +04:00
|
|
|
if(WIN32)
|
|
|
|
if(NOT CYGWIN)
|
|
|
|
if(BORLAND)
|
|
|
|
set( FLTK2_PLATFORM_DEPENDENT_LIBS import32 )
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set( FLTK2_PLATFORM_DEPENDENT_LIBS wsock32 comctl32 )
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
include(${CMAKE_ROOT}/Modules/FindX11.cmake)
|
|
|
|
set( FLTK2_PLATFORM_DEPENDENT_LIBS ${X11_LIBRARIES} -lm)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set( FLTK2_PLATFORM_DEPENDENT_LIBS "-framework Carbon -framework Cocoa -framework ApplicationServices -lz")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-11-07 20:13:09 +04:00
|
|
|
# If FLTK2_INCLUDE_DIR is already defined we assign its value to FLTK2_DIR
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLTK2_INCLUDE_DIR)
|
|
|
|
set(FLTK2_DIR ${FLTK2_INCLUDE_DIR})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_INCLUDE_DIR ${FLTK2_DIR})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
# If FLTK2 has been built using CMake we try to find everything directly
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_DIR_STRING "directory containing FLTK2Config.cmake. This is either the root of the build tree, or PREFIX/lib/fltk for an installation.")
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Search only if the location is not already known.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT FLTK2_DIR)
|
2007-10-12 19:34:07 +04:00
|
|
|
# Get the system search path as a list.
|
2012-08-13 21:47:32 +04:00
|
|
|
file(TO_CMAKE_PATH "$ENV{PATH}" FLTK2_DIR_SEARCH2)
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Construct a set of paths relative to the system search path.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_DIR_SEARCH "")
|
|
|
|
foreach(dir ${FLTK2_DIR_SEARCH2})
|
|
|
|
set(FLTK2_DIR_SEARCH ${FLTK2_DIR_SEARCH} "${dir}/../lib/fltk")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REPLACE "//" "/" FLTK2_DIR_SEARCH "${FLTK2_DIR_SEARCH}")
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Look for an installation or build tree.
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
find_path(FLTK2_DIR FLTK2Config.cmake
|
2007-10-12 19:34:07 +04:00
|
|
|
# Look for an environment variable FLTK2_DIR.
|
2012-03-29 02:00:54 +04:00
|
|
|
ENV FLTK2_DIR
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Look in places relative to the system executable search path.
|
|
|
|
${FLTK2_DIR_SEARCH}
|
|
|
|
|
|
|
|
# Look in standard UNIX install locations.
|
|
|
|
/usr/local/lib/fltk2
|
|
|
|
/usr/lib/fltk2
|
|
|
|
/usr/local/fltk2
|
|
|
|
/usr/X11R6/include
|
|
|
|
|
|
|
|
# Help the user find it if we cannot.
|
|
|
|
DOC "The ${FLTK2_DIR_STRING}"
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT FLTK2_DIR)
|
|
|
|
find_path(FLTK2_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
# If FLTK2 was found, load the configuration file to get the rest of the
|
|
|
|
# settings.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLTK2_DIR)
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Check if FLTK2 was built using CMake
|
2012-08-13 21:47:32 +04:00
|
|
|
if(EXISTS ${FLTK2_DIR}/FLTK2Config.cmake)
|
|
|
|
set(FLTK2_BUILT_WITH_CMAKE 1)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLTK2_BUILT_WITH_CMAKE)
|
|
|
|
set(FLTK2_FOUND 1)
|
|
|
|
include(${FLTK2_DIR}/FLTK2Config.cmake)
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Fluid
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLUID_COMMAND)
|
|
|
|
set(FLTK2_FLUID_EXECUTABLE ${FLUID_COMMAND} CACHE FILEPATH "Fluid executable")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
find_program(FLTK2_FLUID_EXECUTABLE fluid2 PATHS
|
2007-10-12 19:34:07 +04:00
|
|
|
${FLTK2_EXECUTABLE_DIRS}
|
|
|
|
${FLTK2_EXECUTABLE_DIRS}/RelWithDebInfo
|
|
|
|
${FLTK2_EXECUTABLE_DIRS}/Debug
|
|
|
|
${FLTK2_EXECUTABLE_DIRS}/Release
|
|
|
|
NO_SYSTEM_PATH)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(FLTK2_FLUID_EXECUTABLE)
|
|
|
|
set( FLTK_FLUID_EXECUTABLE ${FLTK2_FLUID_EXECUTABLE} )
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_INCLUDE_DIR ${FLTK2_DIR})
|
|
|
|
link_directories(${FLTK2_LIBRARY_DIRS})
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_BASE_LIBRARY fltk2)
|
|
|
|
set(FLTK2_GL_LIBRARY fltk2_gl)
|
|
|
|
set(FLTK2_IMAGES_LIBRARY fltk2_images)
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Add the extra libraries
|
2012-08-13 21:47:32 +04:00
|
|
|
load_cache(${FLTK2_DIR}
|
2007-10-12 19:34:07 +04:00
|
|
|
READ_WITH_PREFIX
|
|
|
|
FL FLTK2_USE_SYSTEM_JPEG
|
|
|
|
FL FLTK2_USE_SYSTEM_PNG
|
|
|
|
FL FLTK2_USE_SYSTEM_ZLIB
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_IMAGES_LIBS "")
|
|
|
|
if(FLFLTK2_USE_SYSTEM_JPEG)
|
|
|
|
set(FLTK2_IMAGES_LIBS ${FLTK2_IMAGES_LIBS} fltk2_jpeg)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLFLTK2_USE_SYSTEM_PNG)
|
|
|
|
set(FLTK2_IMAGES_LIBS ${FLTK2_IMAGES_LIBS} fltk2_png)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLFLTK2_USE_SYSTEM_ZLIB)
|
|
|
|
set(FLTK2_IMAGES_LIBS ${FLTK2_IMAGES_LIBS} fltk2_zlib)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL
|
2007-10-12 19:34:07 +04:00
|
|
|
"Extra libraries for fltk2_images library.")
|
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# if FLTK2 was not built using CMake
|
|
|
|
# Find fluid executable.
|
2012-08-13 21:47:32 +04:00
|
|
|
find_program(FLTK2_FLUID_EXECUTABLE fluid2 ${FLTK2_INCLUDE_DIR}/fluid)
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# Use location of fluid to help find everything else.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_INCLUDE_SEARCH_PATH "")
|
|
|
|
set(FLTK2_LIBRARY_SEARCH_PATH "")
|
|
|
|
if(FLTK2_FLUID_EXECUTABLE)
|
|
|
|
set( FLTK_FLUID_EXECUTABLE ${FLTK2_FLUID_EXECUTABLE} )
|
|
|
|
get_filename_component(FLTK2_BIN_DIR "${FLTK2_FLUID_EXECUTABLE}" PATH)
|
|
|
|
set(FLTK2_INCLUDE_SEARCH_PATH ${FLTK2_INCLUDE_SEARCH_PATH}
|
2007-10-12 19:34:07 +04:00
|
|
|
${FLTK2_BIN_DIR}/../include ${FLTK2_BIN_DIR}/..)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_LIBRARY_SEARCH_PATH}
|
2007-10-12 19:34:07 +04:00
|
|
|
${FLTK2_BIN_DIR}/../lib)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_WRAP_UI 1)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_INCLUDE_SEARCH_PATH ${FLTK2_INCLUDE_SEARCH_PATH}
|
2007-10-12 19:34:07 +04:00
|
|
|
/usr/local/fltk2
|
|
|
|
/usr/X11R6/include
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_path(FLTK2_INCLUDE_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH})
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_LIBRARY_SEARCH_PATH}
|
2007-10-12 19:34:07 +04:00
|
|
|
/usr/local/fltk2/lib
|
|
|
|
/usr/X11R6/lib
|
|
|
|
${FLTK2_INCLUDE_DIR}/lib
|
|
|
|
)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(FLTK2_BASE_LIBRARY NAMES fltk2
|
2007-10-12 19:34:07 +04:00
|
|
|
PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(FLTK2_GL_LIBRARY NAMES fltk2_gl
|
2007-10-12 19:34:07 +04:00
|
|
|
PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(FLTK2_IMAGES_LIBRARY NAMES fltk2_images
|
2007-10-12 19:34:07 +04:00
|
|
|
PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
|
|
|
|
|
|
|
|
# Find the extra libraries needed for the fltk_images library.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(UNIX)
|
|
|
|
find_program(FLTK2_CONFIG_SCRIPT fltk2-config PATHS ${FLTK2_BIN_DIR})
|
|
|
|
if(FLTK2_CONFIG_SCRIPT)
|
|
|
|
exec_program(${FLTK2_CONFIG_SCRIPT} ARGS --use-images --ldflags
|
2007-10-12 19:34:07 +04:00
|
|
|
OUTPUT_VARIABLE FLTK2_IMAGES_LDFLAGS)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_LIBS_EXTRACT_REGEX ".*-lfltk2_images (.*) -lfltk2.*")
|
|
|
|
if("${FLTK2_IMAGES_LDFLAGS}" MATCHES "${FLTK2_LIBS_EXTRACT_REGEX}")
|
2014-04-06 23:30:00 +04:00
|
|
|
string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${CMAKE_MATCH_1}")
|
2007-10-12 19:34:07 +04:00
|
|
|
# The EXEC_PROGRAM will not be inherited into subdirectories from
|
|
|
|
# the file that originally included this module. Save the answer.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL
|
2007-10-12 19:34:07 +04:00
|
|
|
"Extra libraries for fltk_images library.")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_FOUND 1)
|
|
|
|
foreach(var FLTK2_FLUID_EXECUTABLE FLTK2_INCLUDE_DIR
|
2007-10-12 19:34:07 +04:00
|
|
|
FLTK2_BASE_LIBRARY FLTK2_GL_LIBRARY
|
|
|
|
FLTK2_IMAGES_LIBRARY)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT ${var})
|
|
|
|
message( STATUS "${var} not found" )
|
|
|
|
set(FLTK2_FOUND 0)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(FLTK2_FOUND)
|
|
|
|
set(FLTK2_LIBRARIES ${FLTK2_IMAGES_LIBRARY} ${FLTK2_IMAGES_LIBS} ${FLTK2_BASE_LIBRARY} ${FLTK2_GL_LIBRARY} )
|
|
|
|
if(APPLE)
|
|
|
|
set(FLTK2_LIBRARIES ${FLTK2_PLATFORM_DEPENDENT_LIBS} ${FLTK2_LIBRARIES})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FLTK2_LIBRARIES ${FLTK2_LIBRARIES} ${FLTK2_PLATFORM_DEPENDENT_LIBS})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|
|
|
|
# The following deprecated settings are for compatibility with CMake 1.4
|
2012-08-13 21:47:32 +04:00
|
|
|
set (HAS_FLTK2 ${FLTK2_FOUND})
|
|
|
|
set (FLTK2_INCLUDE_PATH ${FLTK2_INCLUDE_DIR})
|
|
|
|
set (FLTK2_FLUID_EXE ${FLTK2_FLUID_EXECUTABLE})
|
|
|
|
set (FLTK2_LIBRARY ${FLTK2_LIBRARIES})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2007-10-12 19:34:07 +04:00
|
|
|
# make FIND_PACKAGE friendly
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT FLTK2_FIND_QUIETLY)
|
|
|
|
if(FLTK2_FIND_REQUIRED)
|
|
|
|
message(FATAL_ERROR
|
2007-10-12 19:34:07 +04:00
|
|
|
"FLTK2 required, please specify its location with FLTK2_DIR.")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "FLTK2 was not found.")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2007-10-12 19:34:07 +04:00
|
|
|
|