CMake: fix fltk-config generation for MacOS.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12687 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2018-02-24 13:44:06 +00:00
parent 7d1488507d
commit c9d4df288c
2 changed files with 51 additions and 19 deletions

View File

@ -25,10 +25,18 @@ if (DEBUG_OPTIONS_CMAKE)
endif (DEBUG_OPTIONS_CMAKE)
#######################################################################
# *temporary* option to modify header searches
# *Temporary* option to modify header file searches
#######################################################################
# Note: The old, deprecated behavior (ON) was to use find_file() for
# header searches, the new behavior (ON) is to use check_include_files()
# which seems to be more reliable but more difficult to set up and
# slower because it uses a compilation test. Default is "new" (OFF).
# This option should be removed as soon as the new search strategy
# is considered stable.
# Currently used only in resources.cmake.
#######################################################################
option(USE_FIND_FILE
"Deprecated: use find_file() for header searches"
"Deprecated: use find_file() for header searches. Should be OFF."
OFF
)
mark_as_advanced(USE_FIND_FILE)
@ -59,14 +67,9 @@ set(FL_ABI_VERSION ${OPTION_ABI_VERSION})
#######################################################################
#######################################################################
if (UNIX)
option(OPTION_CREATE_LINKS "create backwards compatibility links" OFF)
list(APPEND FLTK_LDLIBS -lm)
option(OPTION_CREATE_LINKS "create backwards compatibility links" OFF)
endif (UNIX)
if (WIN32)
list(APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32)
endif (WIN32)
#######################################################################
## Add a TEMPORARY OPTION to enable high-DPI support under Windows.
## May be removed once high-DPI support under Windows is complete.
@ -195,21 +198,26 @@ if(OPTION_USE_GL)
set(HAVE_GL_GLU_H ${HAVE_OPENGL_GLU_H})
endif(APPLE)
endif(OPTION_APPLE_X11)
else ()
set(OPENGL_FOUND FALSE)
endif(OPTION_USE_GL)
if (DEBUG_OPTIONS_CMAKE)
fl_debug_var(OPENGL_FOUND)
fl_debug_var(OPENGL_INCLUDE_DIR)
fl_debug_var(OPENGL_LIBRARIES)
endif (DEBUG_OPTIONS_CMAKE)
if (OPENGL_FOUND)
set (CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL)
# Set GLLIBS (used in fltk-config).
# We should probably deduct this from OPENGL_LIBRARIES but it turned
# out to be difficult since FindOpenGL seems to return different
# syntax depending on the platform (and maybe also CMake version).
# Hence we use the following code...
if (WIN32)
set (GLLIBS "-lglu32 -lopengl32")
elseif (APPLE AND NOT OPTION_APPLE_X11)
set (GLLIBS "-framework OpenGL")
else ()
set (GLLIBS "-lGLU -lGL")
endif ()
endif (WIN32)
# check if function glXGetProcAddressARB exists
set (TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@ -221,6 +229,7 @@ if (OPENGL_FOUND)
set (FLTK_GL_FOUND TRUE)
else ()
set (FLTK_GL_FOUND FALSE)
set (GLLIBS)
endif (OPENGL_FOUND)
#######################################################################
@ -541,11 +550,15 @@ endif(NOT CMAKE_VERSION VERSION_LESS 3.0.0)
# Debugging ...
if (DEBUG_OPTIONS_CMAKE)
message (STATUS "") # empty line
fl_debug_var (WIN32)
fl_debug_var (LIBS)
fl_debug_var (GLLIBS)
fl_debug_var (FLTK_LDLIBS)
fl_debug_var (USE_FIND_FILE)
fl_debug_var (OPENGL_FOUND)
fl_debug_var (OPENGL_INCLUDE_DIR)
fl_debug_var (OPENGL_LIBRARIES)
message (STATUS "[** end of options.cmake **]")
endif (DEBUG_OPTIONS_CMAKE)
unset (DEBUG_OPTIONS_CMAKE)

View File

@ -25,6 +25,8 @@ set (FL_PATCH_VERSION ${FLTK_VERSION_PATCH})
set (DEBUG_VARIABLES_CMAKE 0)
if (DEBUG_VARIABLES_CMAKE)
message (STATUS "[** variables.cmake **]")
fl_debug_var (HAVE_DLSYM)
fl_debug_var (CMAKE_DL_LIBS)
fl_debug_var (CMAKE_EXE_LINKER_FLAGS)
fl_debug_var (LDFLAGS)
fl_debug_var (LIBS)
@ -40,14 +42,28 @@ endif (DEBUG_VARIABLES_CMAKE)
#######################################################################
# add several libraries
# FIXME: libraries may need reordering.
# FIXME: check fontconfig conditions (only if Xft is used or ...)
if (WIN32)
list (APPEND FLTK_LDLIBS -lole32 -luuid -lcomctl32)
elseif (APPLE AND OPTION_APPLE_SDL)
# FIXME: do nothing?
elseif (APPLE AND NOT OPTION_APPLE_X11)
list (APPEND FLTK_LDLIBS "-framework Cocoa")
else ()
list (APPEND FLTK_LDLIBS -lm)
endif (WIN32)
if (LIB_fontconfig)
list(APPEND FLTK_LDLIBS -lfontconfig)
endif (LIB_fontconfig)
if (HAVE_DLSYM AND NOT WIN32)
list(APPEND FLTK_LDLIBS -ldl)
endif (HAVE_DLSYM AND NOT WIN32)
# add "-ldl" or whatever is necessary according to CMake (CMAKE_DL_LIBS)
if (HAVE_DLSYM)
foreach (LIB ${CMAKE_DL_LIBS})
list (APPEND FLTK_LDLIBS "-l${LIB}")
endforeach ()
endif (HAVE_DLSYM)
#######################################################################
# Set variables for fltk-config (generated from fltk-config.in)
@ -123,7 +139,7 @@ foreach(arg ${FLTK_LDLIBS})
set(LINK_LIBS "${LINK_LIBS} ${arg}")
endforeach(arg ${FLTK_LDLIBS})
set(LIBS ${LINK_LIBS})
set(LIBS "${LINK_LIBS}")
if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
set(SHAREDSUFFIX "_s")
@ -132,6 +148,9 @@ else ()
endif (${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
if (DEBUG_VARIABLES_CMAKE)
message (STATUS "") # empty line
fl_debug_var (HAVE_DLSYM)
fl_debug_var (CMAKE_DL_LIBS)
fl_debug_var (CMAKE_EXE_LINKER_FLAGS)
fl_debug_var (LDFLAGS)
fl_debug_var (LIBS)