summaryrefslogtreecommitdiff
path: root/CMake/variables.cmake
blob: 9719435cf49a33eb4eb435575915b0a7dc7afaa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# "$Id$"
#
# This file sets variables for common use in export.cmake and install.cmake
# Written by Michael Surette
#
# 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
# file is missing or damaged, see the license at:
#
#     http://www.fltk.org/COPYING.php
#
# Please report all bugs and problems on the following page:
#
#     http://www.fltk.org/str.php
#

#######################################################################
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
# FIXME: libraries may need reordering.

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)

#######################################################################
# 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 ()

set (IMAGELIBS)
set (STATICIMAGELIBS)

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}")
string(REPLACE ";" " " STATICIMAGELIBS "${STATICIMAGELIBS}")

#######################################################################
set(CC ${CMAKE_C_COMPILER})
set(CXX ${CMAKE_CXX_COMPILER})

set(ARCHFLAGS ${OPTION_ARCHFLAGS})

string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_UPPER)
if (${BUILD_UPPER})
    set(CFLAGS "${CMAKE_C_FLAGS_${BUILD_UPPER}} ${CFLAGS}")
endif (${BUILD_UPPER})

set(CFLAGS "${OPTION_OPTIM} ${CMAKE_C_FLAGS} ${CFLAGS}")
foreach(arg ${FLTK_CFLAGS})
    set(CFLAGS "${CFLAGS} ${arg}")
endforeach(arg ${FLTK_CFLAGS})

set(CXXFLAGS ${CFLAGS})

foreach(arg ${FLTK_LDLIBS})
  set(LINK_LIBS "${LINK_LIBS} ${arg}")
endforeach(arg ${FLTK_LDLIBS})

set(LIBS ${LINK_LIBS})

if (${CMAKE_SYSTEM_NAME} STREQUAL "AIX")
    set(SHAREDSUFFIX "_s")
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)