diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2018-02-23 19:41:52 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2018-02-23 19:41:52 +0000 |
| commit | 7d1488507d110e567f57610894e9ce5d0eaebf2b (patch) | |
| tree | 39ec070c7b17850b61f3a665f5190f5b9b55a4e2 /CMake/variables.cmake | |
| parent | a0863e393af4231c93f917c18ef6b3366153c21e (diff) | |
CMake: Fix fltk-config for Windows and Unix/Linux.
This update ought to work with
fltk-config [--use-images] [--use-gl] --compile <c source file>
on both Windows and Unix/Linux when built with CMake. It was tested
under Windows and Linux using fltk-config directly from the build tree,
but it should work as well after installation.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12686 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'CMake/variables.cmake')
| -rw-r--r-- | CMake/variables.cmake | 116 |
1 files changed, 91 insertions, 25 deletions
diff --git a/CMake/variables.cmake b/CMake/variables.cmake index d20964201..9719435cf 100644 --- a/CMake/variables.cmake +++ b/CMake/variables.cmake @@ -4,7 +4,7 @@ # This file sets variables for common use in export.cmake and install.cmake # Written by Michael Surette # -# Copyright 1998-2015 by Bill Spitzak and others. +# Copyright 1998-2018 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -18,37 +18,88 @@ # ####################################################################### -set(FL_MAJOR_VERSION ${FLTK_VERSION_MAJOR}) -set(FL_MINOR_VERSION ${FLTK_VERSION_MINOR}) -set(FL_PATCH_VERSION ${FLTK_VERSION_PATCH}) +set (FL_MAJOR_VERSION ${FLTK_VERSION_MAJOR}) +set (FL_MINOR_VERSION ${FLTK_VERSION_MINOR}) +set (FL_PATCH_VERSION ${FLTK_VERSION_PATCH}) + +set (DEBUG_VARIABLES_CMAKE 0) +if (DEBUG_VARIABLES_CMAKE) + message (STATUS "[** variables.cmake **]") + fl_debug_var (CMAKE_EXE_LINKER_FLAGS) + fl_debug_var (LDFLAGS) + fl_debug_var (LIBS) + fl_debug_var (GLLIBS) + fl_debug_var (IMAGELIBS) + fl_debug_var (STATICIMAGELIBS) + fl_debug_var (FLTK_LDLIBS) + fl_debug_var (LIB_jpeg) + fl_debug_var (LIB_png) + fl_debug_var (LIB_zlib) +endif (DEBUG_VARIABLES_CMAKE) ####################################################################### -# add several libraries (STR #3011) -# FIXME: libraries may need reordering, and this version does not yet -# correctly support static linking and local zlib, png, and jpeg libs. +# add several libraries +# FIXME: libraries may need reordering. -if(LIB_fontconfig) - list(APPEND FLTK_LDLIBS -lfontconfig) -endif(LIB_fontconfig) +if (LIB_fontconfig) + list(APPEND FLTK_LDLIBS -lfontconfig) +endif (LIB_fontconfig) -if(HAVE_DLSYM) - list(APPEND FLTK_LDLIBS -ldl) -endif(HAVE_DLSYM) +if (HAVE_DLSYM AND NOT WIN32) + list(APPEND FLTK_LDLIBS -ldl) +endif (HAVE_DLSYM AND NOT WIN32) -if(LIB_png) - list(APPEND IMAGELIBS -lpng) -endif(LIB_png) +####################################################################### +# Set variables for fltk-config (generated from fltk-config.in) +####################################################################### + +# Variables in fltk-config.in (@VAR@) are used in configure(.ac) +# and in CMake so their names and usage must be synchronized. +# CMake generates two instances of fltk-config, one that can be used +# directly in the build tree (see export.cmake) and one that is copied +# to the installation directory (see install.cmake). Common variables +# should be set here, whereas variables with different values should +# be set in install.cmake or export.cmake, respectively. + +if (WIN32) + set (LDFLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows") +endif () -if(LIB_zlib) - list(APPEND IMAGELIBS -lz) -endif(LIB_zlib) +set (IMAGELIBS) +set (STATICIMAGELIBS) -if(LIB_jpeg) - list(APPEND IMAGELIBS -ljpeg) -endif(LIB_jpeg) +if (FLTK_BUILTIN_JPEG_FOUND) + list(APPEND IMAGELIBS -lfltk_jpeg) + list(APPEND STATICIMAGELIBS \$libdir/libfltk_jpeg.a) +else () + if (LIB_jpeg) + list(APPEND IMAGELIBS -ljpeg) + list(APPEND STATICIMAGELIBS -ljpeg) + endif (LIB_jpeg) +endif (FLTK_BUILTIN_JPEG_FOUND) + +if (FLTK_BUILTIN_PNG_FOUND) + list(APPEND IMAGELIBS -lfltk_png) + list(APPEND STATICIMAGELIBS \$libdir/libfltk_png.a) +else () + if (LIB_png) + list(APPEND IMAGELIBS -lpng) + list(APPEND STATICIMAGELIBS -lpng) + endif (LIB_png) +endif (FLTK_BUILTIN_PNG_FOUND) + +if (FLTK_BUILTIN_ZLIB_FOUND) + list(APPEND IMAGELIBS -lfltk_z) + list(APPEND STATICIMAGELIBS \$libdir/libfltk_z.a) +else () + if (LIB_zlib) + list(APPEND IMAGELIBS -lz) + list(APPEND STATICIMAGELIBS -lz) + endif (LIB_zlib) +endif (FLTK_BUILTIN_ZLIB_FOUND) string(REPLACE ";" " " IMAGELIBS "${IMAGELIBS}") -set(STATICIMAGELIBS "${IMAGELIBS}") +string(REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}") ####################################################################### set(CC ${CMAKE_C_COMPILER}) @@ -57,9 +108,9 @@ set(CXX ${CMAKE_CXX_COMPILER}) set(ARCHFLAGS ${OPTION_ARCHFLAGS}) string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_UPPER) -if(${BUILD_UPPER}) +if (${BUILD_UPPER}) set(CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}") -endif(${BUILD_UPPER}) +endif (${BUILD_UPPER}) set(CFLAGS "${OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}") foreach(arg ${FLTK_CFLAGS}) @@ -79,3 +130,18 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX") else () set(SHAREDSUFFIX "") endif (${CMAKE_SYSTEM_NAME} STREQUAL "AIX") + +if (DEBUG_VARIABLES_CMAKE) + fl_debug_var (CMAKE_EXE_LINKER_FLAGS) + fl_debug_var (LDFLAGS) + fl_debug_var (LIBS) + fl_debug_var (GLLIBS) + fl_debug_var (IMAGELIBS) + fl_debug_var (STATICIMAGELIBS) + fl_debug_var (FLTK_LDLIBS) + fl_debug_var (LIB_jpeg) + fl_debug_var (LIB_png) + fl_debug_var (LIB_zlib) + message (STATUS "[** end of variables.cmake **]") +endif (DEBUG_VARIABLES_CMAKE) +unset (DEBUG_VARIABLES_CMAKE) |
