Fix cairo build (autoconf + CMake) + README's

- rewrite to use pkg-config with both autoconf + CMake
- remove hardcoded library names
- fix build dependencies and search directories
- remove or replace old and unused variables
- update README files

To be done:
- implement fallback for autoconf/configure if pkg-config is missing
- fix pango build (uses cairo internally)
This commit is contained in:
Albrecht Schlosser 2021-02-28 14:56:19 +01:00
parent 266b5e7cdd
commit 49a78bc482
11 changed files with 238 additions and 105 deletions

View File

@ -115,6 +115,10 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME}) set_target_properties (${TARGET_NAME} PROPERTIES OUTPUT_NAME ${NAME})
target_link_libraries (${TARGET_NAME} ${LIBRARIES}) target_link_libraries (${TARGET_NAME} ${LIBRARIES})
if (FLTK_HAVE_CAIRO)
target_link_directories (${TARGET_NAME} PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
endif (FLTK_HAVE_CAIRO)
if (ICON_PATH) if (ICON_PATH)
set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties (${TARGET_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH}) set_target_properties (${TARGET_NAME} PROPERTIES RESOURCE ${ICON_PATH})

View File

@ -21,7 +21,7 @@
# #
# This macro displays the name and value of a CMake variable. # This macro displays the name and value of a CMake variable.
# The variable name is expanded with spaces to be (at least) # The variable name is expanded with spaces to be (at least)
# <min_len> (currently 24) characters wide for better readability. # <min_len> (currently 30) characters wide for better readability.
# VARNAME must be a string literal, e.g. WIN32 or "WIN32". # VARNAME must be a string literal, e.g. WIN32 or "WIN32".
# #
# Syntax: # Syntax:
@ -34,7 +34,7 @@
####################################################################### #######################################################################
macro (fl_debug_var name) macro (fl_debug_var name)
set (min_len 24) set (min_len 30)
set (var "${name}") set (var "${name}")
string(LENGTH "${var}" len) string(LENGTH "${var}" len)
while (len LESS min_len) while (len LESS min_len)

View File

@ -145,37 +145,63 @@ if (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION)
endif (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION) endif (OPTION_BUILD_HTML_DOCUMENTATION OR OPTION_BUILD_PDF_DOCUMENTATION)
####################################################################### #######################################################################
include (FindPkgConfig) # Include optional Cairo support
#######################################################################
option (OPTION_CAIRO "use lib Cairo" OFF) option (OPTION_CAIRO "use lib Cairo" OFF)
option (OPTION_CAIROEXT option (OPTION_CAIROEXT
"use FLTK code instrumentation for Cairo extended use" OFF "use FLTK code instrumentation for Cairo extended use" OFF
) )
if ((OPTION_CAIRO OR OPTION_CAIROEXT) AND LIB_CAIRO) set (FLTK_HAVE_CAIRO 0)
pkg_search_module (PKG_CAIRO cairo) set (FLTK_USE_CAIRO 0)
endif ((OPTION_CAIRO OR OPTION_CAIROEXT) AND LIB_CAIRO)
if (PKG_CAIRO_FOUND) if (OPTION_CAIRO OR OPTION_CAIROEXT)
pkg_search_module (PKG_CAIRO cairo)
# fl_debug_var (PKG_CAIRO_FOUND)
if (PKG_CAIRO_FOUND)
set (FLTK_HAVE_CAIRO 1) set (FLTK_HAVE_CAIRO 1)
if (OPTION_CAIROEXT)
set (FLTK_USE_CAIRO 1)
endif (OPTION_CAIROEXT)
add_subdirectory (cairo) add_subdirectory (cairo)
list (APPEND FLTK_LDLIBS -lcairo -lpixman-1)
# fl_debug_var (PKG_CAIRO_INCLUDE_DIRS)
# fl_debug_var (PKG_CAIRO_CFLAGS)
# fl_debug_var (PKG_CAIRO_STATIC_CFLAGS)
# fl_debug_var (PKG_CAIRO_LIBRARIES)
# fl_debug_var (PKG_CAIRO_STATIC_LIBRARIES)
include_directories (${PKG_CAIRO_INCLUDE_DIRS}) include_directories (${PKG_CAIRO_INCLUDE_DIRS})
# Cairo libs and flags for fltk-config
# Hint: use either PKG_CAIRO_* or PKG_CAIRO_STATIC_* variables to
# create the list of libraries used to link programs with cairo
# by running fltk-config --use-cairo --compile ...
# Currently we're using the non-STATIC variables to link cairo shared.
set (CAIROLIBS)
foreach (lib ${PKG_CAIRO_LIBRARIES})
list (APPEND CAIROLIBS "-l${lib}")
endforeach()
string (REPLACE ";" " " CAIROLIBS "${CAIROLIBS}")
string (REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}") string (REPLACE ";" " " CAIROFLAGS "${PKG_CAIRO_CFLAGS}")
if (LIB_CAIRO AND OPTION_CAIROEXT) # fl_debug_var (FLTK_LDLIBS)
set (FLTK_USE_CAIRO 1) # fl_debug_var (CAIROFLAGS)
set (FLTK_CAIRO_FOUND TRUE) # fl_debug_var (CAIROLIBS)
else () else ()
set (FLTK_CAIRO_FOUND FALSE)
endif (LIB_CAIRO AND OPTION_CAIROEXT)
else ()
if (OPTION_CAIRO OR OPTION_CAIROEXT)
message (STATUS "*** Cairo was requested but not found - please check your cairo installation") message (STATUS "*** Cairo was requested but not found - please check your cairo installation")
message (STATUS "*** or disable options OPTION_CAIRO and OPTION_CAIRO_EXT.") message (STATUS "*** or disable options OPTION_CAIRO and OPTION_CAIRO_EXT.")
message (FATAL_ERROR "*** Terminating: missing Cairo libs or headers.") message (FATAL_ERROR "*** Terminating: missing Cairo libs or headers.")
endif (OPTION_CAIRO OR OPTION_CAIROEXT) endif (PKG_CAIRO_FOUND)
endif (PKG_CAIRO_FOUND)
endif (OPTION_CAIRO OR OPTION_CAIROEXT)
####################################################################### #######################################################################
option (OPTION_USE_SVG "read/write SVG files" ON) option (OPTION_USE_SVG "read/write SVG files" ON)

View File

@ -2,7 +2,7 @@
# Resource definitions to build the FLTK project using CMake (www.cmake.org) # Resource definitions to build the FLTK project using CMake (www.cmake.org)
# Written by Michael Surette # Written by Michael Surette
# #
# Copyright 1998-2020 by Bill Spitzak and others. # Copyright 1998-2021 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -35,7 +35,19 @@ macro (fl_find_header VAR HEADER)
endif (NOT CMAKE_REQUIRED_QUIET) endif (NOT CMAKE_REQUIRED_QUIET)
endmacro (fl_find_header) endmacro (fl_find_header)
#######################################################################
# Include FindPkgConfig for later use of pkg-config
#######################################################################
include (FindPkgConfig)
# fl_debug_var (PKG_CONFIG_FOUND)
# fl_debug_var (PKG_CONFIG_EXECUTABLE)
# fl_debug_var (PKG_CONFIG_VERSION_STRING)
#######################################################################
# Find header files... # Find header files...
#######################################################################
fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h) fl_find_header (HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h)
fl_find_header (HAVE_DLFCN_H dlfcn.h) fl_find_header (HAVE_DLFCN_H dlfcn.h)
@ -150,7 +162,6 @@ mark_as_advanced (FREETYPE_PATH)
####################################################################### #######################################################################
# libraries # libraries
find_library (LIB_CAIRO cairo)
find_library (LIB_dl dl) find_library (LIB_dl dl)
if ((NOT APPLE) OR OPTION_APPLE_X11) if ((NOT APPLE) OR OPTION_APPLE_X11)
find_library (LIB_fontconfig fontconfig) find_library (LIB_fontconfig fontconfig)
@ -163,7 +174,7 @@ find_library (LIB_jpeg jpeg)
find_library (LIB_png png) find_library (LIB_png png)
find_library (LIB_zlib z) find_library (LIB_zlib z)
mark_as_advanced (LIB_CAIRO LIB_dl LIB_fontconfig LIB_freetype) mark_as_advanced (LIB_dl LIB_fontconfig LIB_freetype)
mark_as_advanced (LIB_GL LIB_MesaGL LIB_GLEW) mark_as_advanced (LIB_GL LIB_MesaGL LIB_GLEW)
mark_as_advanced (LIB_jpeg LIB_png LIB_zlib) mark_as_advanced (LIB_jpeg LIB_png LIB_zlib)

View File

@ -1,22 +1,28 @@
README.Cairo.txt - 2011-12-10 - Cairo rendering support for FLTK README.Cairo.txt - Cairo rendering support for FLTK
---------------------------------------------------------------- ----------------------------------------------------
CONTENTS CONTENTS
========== ==========
1 INTRODUCTION 1 INTRODUCTION
2 CAIRO SUPPORT FOR FLTK 1.3
2 CAIRO SUPPORT FOR FLTK
2.1 Configuration 2.1 Configuration
2.2 Currently supported features 2.2 Currently supported features
2.3 Future considerations 2.3 Future considerations
3 PLATFORM SPECIFIC NOTES 3 PLATFORM SPECIFIC NOTES
3.1 Linux 3.1 Linux
3.1.1 Debian and Derivatives (like Ubuntu)
3.1.2 CentOS from Greg (erco@seriss.com)
3.2 Windows 3.2 Windows
3.3 Mac OSX 3.3 macOS
4 DOCUMENT HISTORY 3.3.1 Install Xcode Commandline Tools
3.3.2 Install Homebrew for Cairo and other Library Support
3.3.3 Install CMake and Build with CMake
4 DOCUMENT HISTORY
INTRODUCTION INTRODUCTION
@ -28,14 +34,13 @@ primitives for 2-dimensional drawing across a number of different
backends. Cairo is designed to use hardware acceleration when available. backends. Cairo is designed to use hardware acceleration when available.
CAIRO SUPPORT FOR FLTK 1.3 CAIRO SUPPORT FOR FLTK
============================ ========================
It is now possible to integrate cairo rendering in your FLTK application It is now possible to integrate Cairo rendering in your FLTK application
more easily and transparently. more easily and transparently.
In 1.3, we provide minimum support for Cairo, Since FLTK 1.3 we provide minimum support for Cairo; no "total" Cairo
in particular, no "total" cairo rendering layer support is achieved, rendering layer support is achieved.
as in fltk2.
Configuration Configuration
@ -53,25 +58,25 @@ variable OPTION_CAIRO:BOOL=ON is set.
integration of a Cairo draw callback without the need to subclass Fl_Window. integration of a Cairo draw callback without the need to subclass Fl_Window.
(2) Adding a Fl::cairo_make_current(Fl_Window*) function only providing (2) Adding a Fl::cairo_make_current(Fl_Window*) function only providing
transparently a cairo context to your custom Fl_Window derived class. transparently a Cairo context to your custom Fl_Window derived class.
This function is intended to be used in your overloaded draw() method. This function is intended to be used in your overloaded draw() method.
(3) Adding an optional cairo autolink context mode support which permits (3) Adding an optional Cairo autolink context mode support which permits
complete and automatic synchronization of OS dependent graphical context complete and automatic synchronization of OS dependent graphical context
and cairo contexts, thus furthering a valid cairo context anytime, and Cairo contexts, thus furthering a valid Cairo context anytime,
in any current window. in any current window.
This feature should be only necessary in the following cases: This feature should be only necessary in the following cases:
- Intensive and almost systematic use of cairo in an FLTK application - Intensive and almost systematic use of Cairo in an FLTK application
- Creation of a new cairo based scheme for FLTK - Creation of a new Cairo based scheme for FLTK
- Other uses of cairo necessitating the FLTK internal instrumentation - Other uses of Cairo necessitating the FLTK internal instrumentation
to automatically making possible the use of a cairo context to automatically making possible the use of a Cairo context
in any FLTK window. in any FLTK window.
This feature must be enabled with 'configure --enable-cairoext' or the This feature must be enabled with 'configure --enable-cairoext' or the
CMake variable OPTION_CAIROEXT:BOOL=ON (Default: OFF). CMake variable OPTION_CAIROEXT:BOOL=ON (Default: OFF).
(4) A new cairo demo that is available in the test subdirectory and has (4) A new Cairo demo that is available in the test subdirectory and has
been used as a testcase during the multiplatform tests. been used as a testcase during the multiplatform tests.
For more details, please have a look to the doxygen documentation, For more details, please have a look to the doxygen documentation,
@ -83,16 +88,16 @@ in the Modules section.
From Bill: From Bill:
First there is the FLTK_HAVE_CAIRO configuration option. This indicates that First there is the FLTK_HAVE_CAIRO configuration option. This indicates that
any cairo calls are available. In this case you get something like this: any Cairo calls are available. In this case you get something like this:
// static variable holding the last cairo context FLTK set: // static variable holding the last Cairo context FLTK set:
cairo_t* Fl::cr; cairo_t* Fl::cr;
// Make cr draw in this window. This hides the ugly platform-dependent // Make cr draw in this window. This hides the ugly platform-dependent
// part of getting cairo going: // part of getting Cairo going:
void Fl::cairo_make_current(Fl_Window*) void Fl::cairo_make_current(Fl_Window*)
*** POST 1.3 potential cairo use: *** POST 1.3 potential Cairo use:
// Set cr to something you made yourself. This lets you reuse functions // Set cr to something you made yourself. This lets you reuse functions
// that use cr, and also tells FLTK that cr is not one of its own and // that use cr, and also tells FLTK that cr is not one of its own and
// thus cannot be destroyed or reused for a different window: // thus cannot be destroyed or reused for a different window:
@ -117,19 +122,19 @@ on the various supported operating systems.
3.1 Linux 3.1 Linux
--------- ---------
3.1.1 Debian and derivatives (like Ubuntu) 3.1.1 Debian and Derivatives (like Ubuntu)
----------------------------------------------------- -------------------------------------------
Run from a terminal command line: Run from a terminal command line:
sudo apt install libcairo2-dev sudo apt install libcairo2-dev
Then build fltk using the cairo additional option using: Then build fltk using the Cairo support option using:
cmake -G"Unix Makefiles" -DOPTION_CAIRO:BOOL=ON -S <fltk_dir> -B <your_build_dir> cmake -G"Unix Makefiles" -DOPTION_CAIRO:BOOL=ON -S <fltk_dir> -B <your_build_dir>
cd <your_build_dir> cd <your_build_dir>
make make
3.1.2 CentOS from Greg (erco@seriss.com) 3.1.2 CentOS from Greg (erco@seriss.com)
--------------------------------------------------- -----------------------------------------
To get FLTK 1.3.x (r9204) to build on Centos 5.5, I found that To get FLTK 1.3.x (r9204) to build on Centos 5.5, I found that
I only needed to install the "cairo-devel" package, ie: I only needed to install the "cairo-devel" package, ie:
@ -158,7 +163,7 @@ on the various supported operating systems.
..then another 'make' should finish the build without errors. ..then another 'make' should finish the build without errors.
You should be able to then run the test/cairo_test program. You should be able to then run the test/cairo_test program.
According to the cairo site, "For Debian and Debian derivatives including According to the Cairo site, "For Debian and Debian derivatives including
Ubuntu" you need to install libcairo2-dev, i.e. Ubuntu" you need to install libcairo2-dev, i.e.
sudo apt-get install libcairo2-dev sudo apt-get install libcairo2-dev
@ -167,16 +172,101 @@ on the various supported operating systems.
installs libpixman-1-dev, so that dependencies on this should be resolved installs libpixman-1-dev, so that dependencies on this should be resolved
as well. as well.
As of Feb 2021 (FLTK 1.4.0) dependencies like pixman-1 will be detected by
configure or CMake automatically using pkg-config.
Note 1: CMake builds *require* the use of pkg-config.
Note 2: As of Feb 2021 autoconf/configure/make builds require pkg-config
as well but there are plans to implement a fallback mechanism so you can
build FLTK w/o having to install and use pkg-config. This will be done if
possible (but not guaranteed).
3.2 Windows 3.2 Windows
----------- ------------
TBD TBD
3.3 Mac OSX 3.3 macOS
----------- ----------
TBD As under Linux you can use both build options, i.e. autoconf/make or CMake
to build FLTK with Cairo support. One option is to install Homebrew and
add the required libraries with `brew install ...'. It is always required
to install the "Xcode commandline tools" but a full installation of Xcode
is not necessary. If you choose to use Xcode you can generate the Xcode
IDE files with CMake.
The following instructions are intentionally terse. More detailed
information can be found in README.macOS.md and README.CMake.txt.
3.3.1 Install Xcode Commandline Tools
--------------------------------------
Launch a "Terminal" and execute `xcode-select --install', then select to
install the Xcode commandline tools. This installs the required compilers
and build tools, for instance `git' (commandline only) and `clang'.
With these tools installed it is already possible to download and build
a current FLTK tarball or snapshot. All you need to do is unpack the
tarball and run `make' in the root directory. This will run `configure',
generate the necessary files, and build FLTK in its standard configuration.
Note 1: this requires an existing `configure' file which is included in
FLTK releases and snapshots but not in the FLTK Git repository.
Note 2: to build current FLTK downloaded from Git using configure + make
you need to run `autoconf' to generate 'configure'. If autoconf is not
available on your system you can download a FLTK snapshot, unpack it,
and copy the 'configure' file from the snapshot to your Git worktree.
3.3.2 Install Homebrew for Cairo and other Library Support
-----------------------------------------------------------
There are several options to install additional library support under
macOS. macOS does not provide a package manager to install such software.
This README is about installing and using Homebrew as a package manager
to build FLTK with Cairo, everything else (for instance "Fink") is beyond
the scope of this README.
This was tested on a MacBook Air 2020 (M1) with the new Apple Silicon M1
(ARM) processor.
Go to https://brew.sh/ and follow the instructions under "Install Homebrew".
Before you do this, read about the security implications - the FLTK team
is not responsible for your system security. Read their docs on how to
install and use Homebrew.
If you installed Homebrew correctly you can use `brew search cairo' or any
other software (package) name to see if it can be installed. If yes, run
`brew install cairo' (or other name) to install it.
Other helpful packages are 'autoconf' and other Unix (Linux) tools, for
instance 'git-gui' (installs 'gitk' and 'git gui' commands). The Xcode
commandline tools mentioned above install only the git commandline tool.
3.3.3 Install CMake and Build with CMake
-----------------------------------------
Either use `brew install cmake' or go to https://cmake.org/download/
and download the latest stable CMake release for macOS, for instance
'cmake-3.19.6-macos-universal.dmg' (at the time of this writing). Open
(mount) this .dmg file in the Finder. In the shown window you can either
run CMake directly or drag the CMake application to the "Applications"
folder to install it (recommended). Then you can run CMake from your
Applications folder or using "launchpad". See README.macOS.md for
instructions to install the downloaded CMake GUI tool for use with the
commandline.
Once you start the CMake GUI version you can select your source folder
(where you downloaded FLTK) and the build folder (either a subdirectory,
e.g. 'build' or another folder anywhere else) and click "configure".
Follow the instructions and select either "native compilers" or Xcode or
whatever you like to build your FLTK library. In the CMake GUI you need
to select OPTION_CAIRO (ON) to build with basic Cairo support. Finally
click "generate" to create the build files.
For more information on using CMake to build FLTK see README.CMake.txt.
DOCUMENT HISTORY DOCUMENT HISTORY
@ -186,3 +276,4 @@ Dec 20 2010 - matt: restructured document
Dec 09 2011 - greg: Updates for Centos 5.5 builds Dec 09 2011 - greg: Updates for Centos 5.5 builds
Dec 10 2011 - Albrecht: Updates for Ubuntu and Debian, fixed typos. Dec 10 2011 - Albrecht: Updates for Ubuntu and Debian, fixed typos.
Jul 05 2017 - Albrecht: Added CMake config info, fixed typos. Jul 05 2017 - Albrecht: Added CMake config info, fixed typos.
Feb 28 2021 - Albrecht: Update for FLTK 1.4, add macOS instructions.

View File

@ -44,6 +44,9 @@ _README.macOS.md - Building FLTK under Apple macOS_
FLTK supports macOS version 10.3 Panther and above. At the time of writing (Jan. 2019), FLTK supports macOS version 10.3 Panther and above. At the time of writing (Jan. 2019),
FLTK compiles and runs fine on the most recent macOS 10.14 Mojave. FLTK compiles and runs fine on the most recent macOS 10.14 Mojave.
Update (March 2021): FLTK builds and runs fine on macOS 11 (Big Sur) on Intel and
the new M1 Apple Silicon (Arm) processors.
FLTK 1.4 supports the following build environments on the macOS FLTK 1.4 supports the following build environments on the macOS
platform: platform:
@ -76,7 +79,7 @@ user input, but will likely take well over an hour.
compiler independent configuration files, and generate native makefiles and workspaces compiler independent configuration files, and generate native makefiles and workspaces
that can be used in the compiler environment of your choice." that can be used in the compiler environment of your choice."
Please download and install the Mac OS X version of _CMake_ from Please download and install the macOS version of _CMake_ from
[www.cmake.org](https://cmake.org/download/). Download the .dmg file, click it, and when [www.cmake.org](https://cmake.org/download/). Download the .dmg file, click it, and when
the Finder window opens, drag the _CMake_ icon into the Applications folder. the Finder window opens, drag the _CMake_ icon into the Applications folder.
@ -91,17 +94,17 @@ _pull_ the newest release.
If you want to use _Xcode_ to clone the FLTK GitHub repository, you will have to give _Xcode_ If you want to use _Xcode_ to clone the FLTK GitHub repository, you will have to give _Xcode_
access to your GitHub Account in the _Xcode_ preferences. If you don't have a GitHub access to your GitHub Account in the _Xcode_ preferences. If you don't have a GitHub
account, or don't want to share your credentials with _Xcode_, you can use still the command account, or don't want to share your credentials with _Xcode_, you can use still the command
line `git clone https://github.com/fltk/fltk.git fltk-1.4.git` line `git clone https://github.com/fltk/fltk.git fltk-1.4`
to ceck out the repo. to check out the repo.
Start _Xcode_. Select `Source Control >> Clone...` in the main menu. Start _Xcode_. Select `Source Control >> Clone...` in the main menu.
A dialog box will open with a search field and a list of repositories. Enter `fltk/fltk` in A dialog box will open with a search field and a list of repositories. Enter `fltk/fltk` in
the search field. A list of matchin repositories appears. The first one should be named `fltk` the search field. A list of matching repositories appears. The first one should be named `fltk`
and be owned by `fltk`. Select it and click _Clone_. and be owned by `fltk`. Select it and click _Clone_.
A file chooser appears. Navigate to your home directory. The create a new folder named A file chooser appears. Navigate to your home directory. Create a new folder named
`dev`. Enter `fltk-1.4.git` in the _Save As:_ field and click _Clone_, then _Done_ in the `dev`. Enter `fltk-1.4` in the _Save As:_ field and click _Clone_, then _Done_ in the
previous dialog. previous dialog.
The local copy of your repository can be updated by loading it into _Xcode_ and selecting The local copy of your repository can be updated by loading it into _Xcode_ and selecting
@ -110,23 +113,23 @@ The local copy of your repository can be updated by loading it into _Xcode_ and
<a name="bcx_config"></a> <a name="bcx_config"></a>
### Configuring FLTK (CMake, Xcode) ### Configuring FLTK (CMake, Xcode)
Launch _CMake_ by pressing Command+Spacebar, the type _CMake_ and press return. Launch _CMake_ by pressing Command+Spacebar, then type _CMake_ and press return.
_CMake_ should open with a large dialog box. _CMake_ should open with a large dialog box.
The first input field is labeled with _Where is the source code:_ . Click on _Browse Source..._ The first input field is labeled with _Where is the source code:_ . Click on _Browse Source..._
and navigate to your home folder, then `dev`, then `fltk-1.4.git`. Click _Open_. and navigate to your home folder, then `dev`, then `fltk-1.4`. Click _Open_.
The next input field is marked _Where to build the binaries:_. Click _Browse Build..._ The next input field is marked _Where to build the binaries:_. Click _Browse Build..._
and navigate to your home folder, then `dev`, then `fltk-1.4.git`, then use _New Folder_ and navigate to your home folder, then `dev`, then `fltk-1.4`, then use _New Folder_
to create a folder named `build`, and inside that, create a folder named `Xcode`. Click _Open_. to create a folder named `build`, and inside that, create a folder named `Xcode`. Click _Open_.
The top two input fields should read The top two input fields should read
``` ```
/Users/your_name/dev/fltk-1.4.git /Users/your_name/dev/fltk-1.4
``` ```
and and
``` ```
/Users/your_name/dev/fltk-1.4.git/build/Xcode /Users/your_name/dev/fltk-1.4/build/Xcode
``` ```
Back in the _CMake_ main window, click _Configure_, select _Xcode_ as the generator and Back in the _CMake_ main window, click _Configure_, select _Xcode_ as the generator and
@ -150,7 +153,7 @@ _CMake_ will be smart enough to update the build files as well.
Now this is easy if all the previous steps were successful. If you are still in _CMake_, just click Now this is easy if all the previous steps were successful. If you are still in _CMake_, just click
_Open Project_ and _CMake_ will launch _XCode_ for you. If not, just launch _XCode_ and _Open Project_ and _CMake_ will launch _XCode_ for you. If not, just launch _XCode_ and
open `Macintosh HDUsers ▸ your_namedevfltk-1.4.gitbuildXcodeFLTK.xcodeproj`. open `Macintosh HDUsers ▸ your_namedevfltk-1.4buildXcodeFLTK.xcodeproj`.
_XCode_ may or may not ask to Autocreate Schemes. Click _Automatically Create Schemes_. _XCode_ may or may not ask to Autocreate Schemes. Click _Automatically Create Schemes_.
@ -176,8 +179,7 @@ permission.
<a name="bcx_new_projects"></a> <a name="bcx_new_projects"></a>
### Creating new Projects (CMake, Xcode) ### Creating new Projects (CMake, Xcode)
TODO: we still need to write a simple CMake file for creating a minimal cross platform app. See README.CMake.txt
<a name="build_cmake_make"></a> <a name="build_cmake_make"></a>
## How to Build FLTK Using _CMake_ and _make_ ## How to Build FLTK Using _CMake_ and _make_
@ -197,7 +199,7 @@ In order to build FLTK, you need to install _CMake_ and the _Xcode_ command line
compiler independent configuration files, and generate native makefiles and workspaces compiler independent configuration files, and generate native makefiles and workspaces
that can be used in the compiler environment of your choice." that can be used in the compiler environment of your choice."
Please download and install the Mac OS X version of _CMake_ from Please download and install the macOS version of _CMake_ from
[www.cmake.org](https://cmake.org/download/). Download the .dmg file, click it, and when [www.cmake.org](https://cmake.org/download/). Download the .dmg file, click it, and when
the Finder window opens, drag the _CMake_ icon into the Applications folder. the Finder window opens, drag the _CMake_ icon into the Applications folder.
@ -229,7 +231,7 @@ Downloading FLTK is explained [here](#bam_download).
<a name="bcm_config"></a> <a name="bcm_config"></a>
### Configuring FLTK (CMake, make) ### Configuring FLTK (CMake, make)
Using you shell in the terminal, make sure that you are in the root directory of your Using your shell in the terminal, make sure that you are in the root directory of your
FLTK source code tree. FLTK source code tree.
Create a directory where all FLTK binaries will be built: Create a directory where all FLTK binaries will be built:
@ -253,7 +255,7 @@ cmake -G "Unix Makefiles" \
_CMake_ runs a number of tests to find external headers, libraries, and tools. _CMake_ runs a number of tests to find external headers, libraries, and tools.
The configuration summary should not show any errors. You can now continue to build FLTK. The configuration summary should not show any errors. You can now continue to build FLTK.
For the advanced user, there are a few more optinons to the _CMake_ setup. Type For the advanced user there are a few more options to the _CMake_ setup. Type
`cmake -L ../..` to get a complete list of options. These should be pretty `cmake -L ../..` to get a complete list of options. These should be pretty
self-explanatory. Some more details can be found in self-explanatory. Some more details can be found in
[online documentation](https://www.fltk.org/doc-1.4/intro.html#intro_unix). [online documentation](https://www.fltk.org/doc-1.4/intro.html#intro_unix).
@ -278,7 +280,7 @@ symbols. This is normal and can safely be ignored.
After a successful build, you can test FLTK's capabilities by running After a successful build, you can test FLTK's capabilities by running
```bash ```bash
open bin/examples/demo.app open bin/test/demo.app
``` ```
<a name="bcm_install"></a> <a name="bcm_install"></a>
@ -380,8 +382,8 @@ cd dev
Now create a copy of the source code archive at Github on your local file system: Now create a copy of the source code archive at Github on your local file system:
```bash ```bash
git clone https://github.com/fltk/fltk.git fltk-1.4.git git clone https://github.com/fltk/fltk.git fltk-1.4
cd fltk-1.4.git cd fltk-1.4
``` ```
<a name="bam_config"></a> <a name="bam_config"></a>
@ -394,9 +396,9 @@ If you are configuring fltk for the first time, you need to instruct FLTK to cre
very basic configuration files. Type: very basic configuration files. Type:
```bash ```bash
NOCONFIGURE=1 ./autogen.sh autoconf
``` ```
This script may generate a few error messages which you can sefely ignore. This creates the configure script.
Now configure your FLTK installation. Stay in your FLTK source-code directory Now configure your FLTK installation. Stay in your FLTK source-code directory
and type and type
@ -408,7 +410,7 @@ and type
The configuration script runs a number of tests to find external headers, libraries, and tools. The configuration script runs a number of tests to find external headers, libraries, and tools.
The configuration summary should not show any errors. You can now continue to build FLTK. The configuration summary should not show any errors. You can now continue to build FLTK.
For the advanced user, there are a few more optinons to the _configure_ script. Type For the advanced user there are a few more optinons to the _configure_ script. Type
`./configure --help` to get a complete list of options. These should be pretty `./configure --help` to get a complete list of options. These should be pretty
self-explanatory. Some more details can be found in self-explanatory. Some more details can be found in
[online documentation](https://www.fltk.org/doc-1.4/intro.html#intro_unix). [online documentation](https://www.fltk.org/doc-1.4/intro.html#intro_unix).
@ -512,9 +514,9 @@ to the Info.plist file you have prepared.
- Feb 24 2011 - Manolo: architecture flags are not propagated to the fltk-config script. - Feb 24 2011 - Manolo: architecture flags are not propagated to the fltk-config script.
- Apr 17 2012 - matt: added Xcode4 documentation - Apr 17 2012 - matt: added Xcode4 documentation
- Nov 13 2012 - Manolo: added "MAKE AN APPLICATION LAUNCHABLE BY DROPPING FILES ON ITS ICON" - Nov 13 2012 - Manolo: added "MAKE AN APPLICATION LAUNCHABLE BY DROPPING FILES ON ITS ICON"
- Apr 28 2014 - Manolo: how to build programs that run on various Mac OS X versions - Apr 28 2014 - Manolo: how to build programs that run on various macOS versions
- Mar 18 2015 - Manolo: removed uses of the Xcode3 project - Mar 18 2015 - Manolo: removed uses of the Xcode3 project
- Apr 01 2016 - AlbrechtS: corrected typo, formatted most line breaks < 80 columns - Apr 01 2016 - Albrecht: corrected typo, formatted most line breaks < 80 columns
- Dec 04 2018 - AlbrechtS: fix typo (lowercase fluid.app) for case sensitive macOS - Dec 04 2018 - Albrecht: fix typo (lowercase fluid.app) for case sensitive macOS
- Dec 28 2018 - Matt: complete rework for FLTK 1.4 - Dec 28 2018 - Matt: complete rework for FLTK 1.4
- Mar 01 2021 - Albrecht: minor updates, macOS Big Sur and Apple Silicon M1 (ARM)

View File

@ -1,7 +1,7 @@
// //
// Main header file for the Fast Light Tool Kit (FLTK). // Main header file for the Fast Light Tool Kit (FLTK).
// //
// Copyright 1998-2018 by Bill Spitzak and others. // Copyright 1998-2021 by Bill Spitzak and others.
// //
// This library is free software. Distribution and use rights are outlined in // 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 // the file "COPYING" which should have been included with this file. If this
@ -124,9 +124,9 @@ static cairo_surface_t * cairo_create_surface(void * gc, int W, int H) {
cairo_t * Fl::cairo_make_current(void *gc) { cairo_t * Fl::cairo_make_current(void *gc) {
int W=0,H=0; int W=0,H=0;
#if defined(USE_X11) #if defined(USE_X11)
//FIXME X11 get W,H // FIXME X11 get W,H
// gc will be the window handle here // gc will be the window handle here
# warning FIXME get W,H for cairo_make_current(void*) // # warning FIXME get W,H for cairo_make_current(void*)
#elif defined(__APPLE_QUARTZ__) #elif defined(__APPLE_QUARTZ__)
if (fl_window) { if (fl_window) {
W = Fl_Window::current()->w(); W = Fl_Window::current()->w();

View File

@ -211,8 +211,7 @@ AS_IF([test x$enable_cairoext = xyes], [
AC_DEFINE([FLTK_HAVE_CAIRO]) AC_DEFINE([FLTK_HAVE_CAIRO])
CAIRODIR="cairo" CAIRODIR="cairo"
CAIROFLAGS="$($PKGCONFIG --cflags cairo)" CAIROFLAGS="$($PKGCONFIG --cflags cairo)"
# TODO: Use pkg-config to get cairo libraries CAIROLIBS="$($PKGCONFIG --libs cairo)"
CAIROLIBS="-lcairo -lpixman-1"
CXXFLAGS="$CAIROFLAGS $CXXFLAGS" CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
LINKFLTKCAIRO="../lib/libfltk_cairo.a" LINKFLTKCAIRO="../lib/libfltk_cairo.a"
FLTKCAIROOPTION="-L ../cairo -lfltk_cairo$SHAREDSUFFIX" FLTKCAIROOPTION="-L ../cairo -lfltk_cairo$SHAREDSUFFIX"
@ -226,8 +225,7 @@ AS_IF([test x$enable_cairoext = xyes], [
AC_DEFINE(FLTK_HAVE_CAIRO) AC_DEFINE(FLTK_HAVE_CAIRO)
CAIRODIR="cairo" CAIRODIR="cairo"
CAIROFLAGS="$($PKGCONFIG --cflags cairo)" CAIROFLAGS="$($PKGCONFIG --cflags cairo)"
# TODO: Use pkg-config to get cairo libraries CAIROLIBS="$($PKGCONFIG --libs cairo)"
CAIROLIBS="-lcairo -lpixman-1"
CXXFLAGS="$CAIROFLAGS $CXXFLAGS" CXXFLAGS="$CAIROFLAGS $CXXFLAGS"
LINKFLTKCAIRO="../lib/libfltk_cairo.a" LINKFLTKCAIRO="../lib/libfltk_cairo.a"
FLTKCAIROOPTION="-L ../cairo -lfltk_cairo$SHAREDSUFFIX" FLTKCAIROOPTION="-L ../cairo -lfltk_cairo$SHAREDSUFFIX"

View File

@ -1,7 +1,7 @@
# #
# CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org) # CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org)
# #
# Copyright 1998-2020 by Bill Spitzak and others. # Copyright 1998-2021 by Bill Spitzak and others.
# #
# This library is free software. Distribution and use rights are outlined in # 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 # the file "COPYING" which should have been included with this file. If this
@ -69,7 +69,10 @@ else ()
add_executable (fluid WIN32 ${CPPFILES}) add_executable (fluid WIN32 ${CPPFILES})
endif (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) endif (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
target_link_libraries(fluid fltk fltk_images fltk_forms) target_link_libraries (fluid fltk fltk_images fltk_forms)
if (FLTK_HAVE_CAIRO)
target_link_directories (fluid PUBLIC ${PKG_CAIRO_LIBRARY_DIRS})
endif (FLTK_HAVE_CAIRO)
# install fluid # install fluid

View File

@ -518,7 +518,7 @@ endif (WIN32)
if (FLTK_HAVE_CAIRO) if (FLTK_HAVE_CAIRO)
list (APPEND OPTIONAL_LIBS fltk_cairo ${PKG_CAIRO_LIBRARIES}) list (APPEND OPTIONAL_LIBS fltk_cairo ${PKG_CAIRO_LIBRARIES})
ENDif (FLTK_HAVE_CAIRO) endif (FLTK_HAVE_CAIRO)
if (HAVE_XINERAMA) if (HAVE_XINERAMA)
list (APPEND OPTIONAL_LIBS ${X11_Xinerama_LIB}) list (APPEND OPTIONAL_LIBS ${X11_Xinerama_LIB})
@ -537,10 +537,9 @@ if (HAVE_XRENDER)
endif (HAVE_XRENDER) endif (HAVE_XRENDER)
if (USE_PANGO) if (USE_PANGO)
list (APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOXFT} ${HAVE_LIB_PANGOCAIRO} ${HAVE_LIB_CAIRO} ${HAVE_LIB_GOBJECT}) ### FIXME ### This needs to use the PKG_* variables directly
#if (NOT APPLE) list (APPEND OPTIONAL_LIBS ${HAVE_LIB_PANGO} ${HAVE_LIB_PANGOXFT} ${HAVE_LIB_PANGOCAIRO})
# list (APPEND OPTIONAL_LIBS ${HAVE_LIB_GOBJECT} ) list (APPEND OPTIONAL_LIBS ${HAVE_LIB_CAIRO} ${HAVE_LIB_GOBJECT})
#endif (NOT APPLE)
endif (USE_PANGO) endif (USE_PANGO)
if (USE_XFT) if (USE_XFT)

View File

@ -181,7 +181,6 @@ ALL = \
tree$(EXEEXT) \ tree$(EXEEXT) \
twowin$(EXEEXT) \ twowin$(EXEEXT) \
valuators$(EXEEXT) \ valuators$(EXEEXT) \
cairotest$(EXEEXT) \
utf8$(EXEEXT) \ utf8$(EXEEXT) \
windowfocus$(EXEEXT) windowfocus$(EXEEXT)