2015-04-07 18:18:35 +03:00
|
|
|
README.CMake.txt - Building and using FLTK with CMake
|
|
|
|
-----------------------------------------------------
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
|
|
|
|
CONTENTS
|
|
|
|
==========
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
1 Introduction to CMake
|
|
|
|
2 Using CMake to Build FLTK
|
2010-12-20 23:00:44 +03:00
|
|
|
2.1 Prerequisites
|
|
|
|
2.2 Options
|
|
|
|
2.3 Building under Linux with Unix Makefiles
|
2017-03-30 04:52:39 +03:00
|
|
|
2.4 Building under Windows with Visual Studio [SUGGESTED DOCS -erco]
|
|
|
|
2.5 Building under Windows with MinGW using Makefiles
|
2017-07-05 18:02:43 +03:00
|
|
|
2.6 Building under MacOS with Xcode
|
|
|
|
2.7 Crosscompiling
|
2020-07-01 19:03:10 +03:00
|
|
|
3 Using CMake with FLTK
|
2016-11-01 18:18:31 +03:00
|
|
|
3.1 Library Names
|
|
|
|
3.2 Using Fluid Files
|
2020-07-01 19:03:10 +03:00
|
|
|
4 Document History
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
1. INTRODUCTION TO CMAKE
|
|
|
|
===========================
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
CMake was designed to let you create build files for a project once and
|
|
|
|
then compile the project on multiple platforms.
|
|
|
|
|
|
|
|
Using it on any platform consists of the same steps. Create the
|
|
|
|
CMakeLists.txt build file(s). Run one of the CMake executables, picking
|
|
|
|
your source directory, build directory, and build target. The "cmake"
|
|
|
|
executable is a one-step process with everything specified on the command
|
|
|
|
line. The others let you select options interactively, then configure
|
|
|
|
and generate your platform-specific target. You then run the resulting
|
|
|
|
Makefile / project file / solution file as you normally would.
|
|
|
|
|
|
|
|
CMake can be run in up to three ways, depending on your platform. "cmake"
|
|
|
|
is the basic command line tool. "ccmake" is the curses based interactive
|
|
|
|
tool. "cmake-gui" is the gui-based interactive tool. Each of these will
|
|
|
|
take command line options in the form of -DOPTION=VALUE. ccmake and
|
|
|
|
cmake-gui will also let you change options interactively.
|
|
|
|
|
|
|
|
CMake not only supports, but works best with out-of-tree builds. This means
|
|
|
|
that your build directory is not the same as your source directory or with a
|
|
|
|
complex project, not the same as your source root directory. Note that the
|
|
|
|
build directory is where, in this case, FLTK will be built, not its final
|
|
|
|
installation point. If you want to build for multiple targets, such as
|
|
|
|
VC++ and MinGW on Windows, or do some cross-compiling you must use out-of-tree
|
|
|
|
builds exclusively. In-tree builds will gum up the works by putting a
|
|
|
|
CMakeCache.txt file in the source root.
|
|
|
|
|
|
|
|
More information on CMake can be found on its web site http://www.cmake.org.
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
2. Using CMake to Build FLTK
|
|
|
|
===============================
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
2.1 Prerequisites
|
|
|
|
--------------------
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
The prerequisites for building FLTK with CMake are staightforward:
|
2021-02-15 21:45:20 +03:00
|
|
|
CMake 3.2.3 or later and a recent FLTK 1.3 release, snapshot, or Git
|
2015-04-07 18:18:35 +03:00
|
|
|
download (working copy). Installation of CMake is covered on its web site.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
This howto will cover building FLTK with the default options using CMake
|
|
|
|
under Linux and MinGW with Unix Makefiles. Chapter 2.5 shows how to use
|
|
|
|
a MinGW cross compiling toolchain to build a FLTK library for Windows
|
|
|
|
under Linux. Other platforms are just as easy to use.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
2.2 Options
|
|
|
|
--------------
|
2013-05-16 17:29:49 +04:00
|
|
|
Options can be specified to cmake with the -D flag:
|
|
|
|
|
|
|
|
cmake -D <OPTION_NAME>=<OPTION_VALUE>
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
cmake -D CMAKE_BUILD_TYPE=Debug
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
All options have sensible defaults so you won't usually need to touch these.
|
2013-05-16 17:29:49 +04:00
|
|
|
There are only two CMake options that you may want to specify:
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
CMAKE_BUILD_TYPE
|
2013-05-16 17:29:49 +04:00
|
|
|
This specifies what kind of build this is i.e. Release, Debug...
|
|
|
|
Platform specific compile/link flags/options are automatically selected
|
|
|
|
by CMake depending on this value.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
CMAKE_INSTALL_PREFIX
|
2016-08-01 15:50:15 +03:00
|
|
|
Where everything will go on install. Defaults are /usr/local for Unix
|
2013-05-16 17:29:49 +04:00
|
|
|
and C:\Program Files\FLTK for Windows.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2021-04-29 19:32:19 +03:00
|
|
|
CMAKE_OSX_ARCHITECTURES (macOS only, ignored on other platforms)
|
|
|
|
Set this to either "arm64", "x86_64", or a list of both "arm64;x86_64".
|
|
|
|
The latter will build "universal apps" on macOS, whereas the former
|
|
|
|
will either build Intel (x86_64) or Apple Silicon aka M1 (arm64) apps.
|
|
|
|
The default is to build for the host processor architecture.
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
The following are the FLTK specific options. Platform specific options
|
|
|
|
are ignored on other platforms.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2017-07-05 20:15:16 +03:00
|
|
|
OPTION_OPTIM - default EMPTY
|
|
|
|
Extra optimization flags for the C and C++ compilers, for instance
|
|
|
|
"-Wall -Wno-deprecated-declarations".
|
2013-05-16 17:29:49 +04:00
|
|
|
|
2017-07-05 20:15:16 +03:00
|
|
|
OPTION_ARCHFLAGS - default EMPTY
|
2010-12-20 23:00:44 +03:00
|
|
|
Extra architecture flags.
|
|
|
|
|
|
|
|
OPTION_APPLE_X11 - default OFF
|
2018-12-29 22:04:38 +03:00
|
|
|
In case you want to use X11 on macOS.
|
2015-12-31 09:19:59 +03:00
|
|
|
Use this only if you know what you do, and if you have installed X11.
|
2013-05-16 17:29:49 +04:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
OPTION_USE_POLL - default OFF
|
2021-02-15 21:45:20 +03:00
|
|
|
Don't use this one, it is deprecated.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
OPTION_BUILD_SHARED_LIBS - default OFF
|
|
|
|
Normally FLTK is built as static libraries which makes more portable
|
2013-05-16 17:29:49 +04:00
|
|
|
binaries. If you want to use shared libraries, this will build them too.
|
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
FLTK_BUILD_TEST - default ON
|
|
|
|
Builds the test and demo programs in the 'test' directory.
|
|
|
|
|
|
|
|
FLTK_BUILD_EXAMPLES - default OFF
|
|
|
|
Builds the example programs in the 'examples' directory.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
OPTION_CAIRO - default OFF
|
2018-12-29 22:04:38 +03:00
|
|
|
Enables libcairo support - see README.Cairo.txt.
|
2013-05-16 17:29:49 +04:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
OPTION_CAIROEXT - default OFF
|
2018-12-29 22:04:38 +03:00
|
|
|
Enables extended libcairo support - see README.Cairo.txt.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
OPTION_USE_GL - default ON
|
2017-07-05 20:15:16 +03:00
|
|
|
Enables OpenGL support.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
OPTION_USE_THREADS - default ON
|
2017-07-05 20:15:16 +03:00
|
|
|
Enables multithreaded support.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
OPTION_LARGE_FILE - default ON
|
2017-07-05 20:15:16 +03:00
|
|
|
Enables large file (>2G) support.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2021-04-29 19:32:19 +03:00
|
|
|
OPTION_USE_SYSTEM_LIBJPEG - default ON (macOS: OFF)
|
|
|
|
OPTION_USE_SYSTEM_LIBPNG - default ON (macOS: OFF)
|
|
|
|
OPTION_USE_SYSTEM_ZLIB - default ON
|
2017-07-05 20:15:16 +03:00
|
|
|
FLTK has built in jpeg, zlib, and png libraries. These options let you
|
|
|
|
use system libraries instead, unless CMake can't find them. If you set
|
2015-04-07 18:18:35 +03:00
|
|
|
any of these options to OFF, then the built in library will be used.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
OPTION_USE_SVG - default ON
|
|
|
|
FLTK has a built in SVG library and can create (write) SVG image files.
|
|
|
|
Turning this option off disables SVG (read and write) support.
|
2017-09-06 03:02:33 +03:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
OPTION_USE_XINERAMA - default ON
|
2020-08-13 21:32:56 +03:00
|
|
|
OPTION_USE_XFT - default ON
|
|
|
|
OPTION_USE_XDBE - default ON
|
|
|
|
OPTION_USE_XCURSOR - default ON
|
|
|
|
OPTION_USE_XRENDER - default ON
|
|
|
|
These are X11 extended libraries. These libs are used if found on the
|
|
|
|
build system unless the respective option is turned off.
|
2016-08-01 15:50:15 +03:00
|
|
|
|
2017-04-08 09:26:23 +03:00
|
|
|
OPTION_USE_PANGO - default OFF
|
2017-07-05 20:15:16 +03:00
|
|
|
Enables use of the Pango library for drawing text. Pango supports all
|
|
|
|
unicode-defined scripts with limited support of right-to-left scripts.
|
2017-04-08 09:26:23 +03:00
|
|
|
This option makes sense only under X11, and also requires Xft.
|
|
|
|
|
2016-08-01 15:50:15 +03:00
|
|
|
OPTION_ABI_VERSION - default EMPTY
|
|
|
|
Use a numeric value corresponding to the FLTK ABI version you want to
|
|
|
|
build in the form 1xxyy for FLTK 1.x.y (xx and yy with leading zeroes).
|
|
|
|
The default ABI version is 1xx00 (the stable ABI throughout all patch
|
|
|
|
releases of one minor FLTK version). The highest ABI version you may
|
|
|
|
choose is 1xxyy for FLTK 1.x.y (again with leading zeroes).
|
|
|
|
Please see README.abi-version.txt for more information about which
|
|
|
|
ABI version to select.
|
|
|
|
|
2016-02-05 20:13:17 +03:00
|
|
|
OPTION_PRINT_SUPPORT - default ON
|
2017-07-05 20:15:16 +03:00
|
|
|
When turned off, the Fl_Printer class does nothing and the
|
2016-02-05 20:13:17 +03:00
|
|
|
Fl_PostScript_File_Device class cannot be used, but the FLTK library
|
|
|
|
is somewhat smaller. This option makes sense only on the Unix/Linux
|
|
|
|
platform or when OPTION_APPLE_X11 is ON.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2018-12-29 22:04:38 +03:00
|
|
|
|
|
|
|
Documentation options: these options are only available if `doxygen' is
|
|
|
|
installed and found by CMake. PDF related options require also `latex'.
|
|
|
|
|
2020-08-13 21:32:56 +03:00
|
|
|
OPTION_BUILD_HTML_DOCUMENTATION - default ON
|
|
|
|
OPTION_BUILD_PDF_DOCUMENTATION - default ON
|
2018-12-29 22:04:38 +03:00
|
|
|
These options can be used to switch HTML documentation generation with
|
|
|
|
doxygen on. The build targets ('html', 'pdf', or 'docs') need still to
|
|
|
|
be executed explicitly.
|
|
|
|
|
|
|
|
OPTION_INCLUDE_DRIVER_DOCUMENTATION - default OFF
|
|
|
|
This option adds driver documentation to HTML and PDF docs (if ON). This
|
|
|
|
option is marked as "advanced" since it is only useful for FLTK developers
|
|
|
|
or advanced users.
|
|
|
|
|
|
|
|
OPTION_INSTALL_HTML_DOCUMENTATION - default OFF
|
2020-08-13 21:32:56 +03:00
|
|
|
OPTION_INSTALL_PDF_DOCUMENTATION - default OFF
|
2018-12-29 22:04:38 +03:00
|
|
|
If these options are ON then the HTML and/or PDF docs get installed
|
|
|
|
when the 'install' target is executed, e.g. with `make install'. You
|
|
|
|
need to select above options OPTION_BUILD_*_DOCUMENTATION as well.
|
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
2.3 Building under Linux with Unix Makefiles
|
|
|
|
-----------------------------------------------
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2017-07-05 20:15:16 +03:00
|
|
|
After unpacking the FLTK source, go to the root of the FLTK tree and type
|
2010-12-20 23:00:44 +03:00
|
|
|
the following.
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake ..
|
|
|
|
make
|
2016-08-01 15:50:15 +03:00
|
|
|
sudo make install (optional)
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2017-09-06 01:37:07 +03:00
|
|
|
IMPORTANT: The trailing ".." on the cmake command must be specified
|
2020-01-18 16:29:01 +03:00
|
|
|
(it is NOT an ellipsis). ^^^^^^^^^^^^^^^^^
|
2017-09-06 01:37:07 +03:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
This will build and install a default configuration FLTK.
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
Some flags can be changed during the 'make' command, such as:
|
|
|
|
|
|
|
|
make VERBOSE=on
|
|
|
|
|
|
|
|
..which builds in verbose mode, so you can see all the compile/link commands.
|
|
|
|
|
2016-08-01 15:50:15 +03:00
|
|
|
Hint: if you intend to build several different versions of FLTK, e.g. a Debug
|
2017-07-05 20:15:16 +03:00
|
|
|
and a Release version, or multiple libraries with different ABI versions or
|
|
|
|
options, then use subdirectories in the build directory, like this:
|
2016-08-01 15:50:15 +03:00
|
|
|
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
mkdir Debug
|
|
|
|
cd Debug
|
2017-07-05 20:15:16 +03:00
|
|
|
cmake -D 'CMAKE_BUILD_TYPE=Debug' ../..
|
2016-08-01 15:50:15 +03:00
|
|
|
make
|
|
|
|
sudo make install (optional)
|
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2017-03-30 04:52:39 +03:00
|
|
|
2.4 Building under Windows with Visual Studio
|
|
|
|
------------------------------------------------
|
|
|
|
|
2017-07-05 20:15:16 +03:00
|
|
|
Building with CMake under Visual Studio requires the CMake generator with
|
|
|
|
the -G command line switch, or the generator can be selected interactively
|
|
|
|
in the GUI (cmake-gui).
|
2017-03-30 04:52:39 +03:00
|
|
|
|
|
|
|
2.4.1 Visual Studio 7 / .NET
|
|
|
|
------------------------------
|
|
|
|
|
|
|
|
1) Open a "Visual Studio .NET command prompt" window, e.g.
|
|
|
|
|
|
|
|
Start > All Programs > Microsoft Visual Studio .NET >
|
|
|
|
Visual Studio .NET Tools > Command Prompt
|
|
|
|
|
|
|
|
2) In the DOS window created above, change the current directory
|
|
|
|
to where you've extracted an fltk distribution tar file (or
|
|
|
|
snapshot tar file), and run the following commands:
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
cd C:\fltk-1.4.x <-- change to your FLTK directory
|
|
|
|
mkdir build <-- create an empty directory
|
2017-03-30 04:52:39 +03:00
|
|
|
cd build
|
|
|
|
cmake -G "Visual Studio 7" -D CMAKE_BUILD_TYPE=Release ..
|
|
|
|
|
2017-09-06 01:37:07 +03:00
|
|
|
IMPORTANT: The trailing ".." on the cmake command must be specified
|
2020-01-18 16:29:01 +03:00
|
|
|
(it is NOT an ellipsis). ^^^^^^^^^^^^^^^^^
|
2017-09-06 01:37:07 +03:00
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
This will create the file FLTK.sln in the current 'build' directory.
|
2017-03-30 04:52:39 +03:00
|
|
|
|
|
|
|
3) Open Visual Studio 7, and choose File -> Open -> Project,
|
|
|
|
and pick the "FLTK.sln" created by step #2 in the 'build' directory.
|
|
|
|
|
|
|
|
(Or, if only one version of the Visual Studio compiler is installed,
|
|
|
|
you can just run from DOS: .\FLTK.sln)
|
|
|
|
|
|
|
|
4) Make sure the pulldown menu has either "Release" or "Debug" selected
|
|
|
|
in the "Solution Configurations" pulldown menu.
|
|
|
|
|
|
|
|
5) In the "Solution Explorer", right click on:
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
Solution 'FLTK' (## projects)
|
2017-03-30 04:52:39 +03:00
|
|
|
|
|
|
|
..and in the popup menu, choose "Build Solution"
|
|
|
|
|
|
|
|
5) That's it, that should build FLTK.
|
2017-07-05 20:15:16 +03:00
|
|
|
|
2017-03-30 04:52:39 +03:00
|
|
|
The test programs (*.exe) can be found in e.g.
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
Release: C:\fltk-1.4.x\build\bin\examples\release\*.exe
|
|
|
|
Debug: C:\fltk-1.4.x\build\bin\examples\debug\*.exe
|
2017-03-30 04:52:39 +03:00
|
|
|
|
|
|
|
..and the FLTK include files (*.H & *.h) your own apps can
|
|
|
|
compile with can be found in:
|
2017-07-05 20:15:16 +03:00
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
Release & Debug: C:\fltk-1.4.x\build\FL
|
|
|
|
*and* [1] in: C:\fltk-1.4.x\FL
|
2017-03-30 04:52:39 +03:00
|
|
|
|
|
|
|
..and the FLTK library files (*.lib) which your own apps can
|
|
|
|
link with can be found in:
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
Release: C:\fltk-1.4.x\build\lib\release\*.lib
|
|
|
|
Debug: C:\fltk-1.4.x\build\lib\debug\*.lib
|
2017-03-30 04:52:39 +03:00
|
|
|
|
2017-07-05 20:15:16 +03:00
|
|
|
[1] If you want to build your own FLTK application directly using
|
2020-07-01 19:03:10 +03:00
|
|
|
the build directories (i.e. without "installation") you need
|
|
|
|
to include both the build tree (first) and then the FLTK source
|
|
|
|
tree in the compiler's header search list.
|
2017-07-05 20:15:16 +03:00
|
|
|
|
2017-03-30 04:52:39 +03:00
|
|
|
|
|
|
|
2.5 Building under Windows with MinGW using Makefiles
|
2016-11-01 18:18:31 +03:00
|
|
|
--------------------------------------------------------
|
|
|
|
|
|
|
|
Building with CMake under MinGW requires you to specify the CMake Generator
|
|
|
|
with the -G command line switch. Using
|
|
|
|
|
|
|
|
cmake -G "Unix Makefiles" /path/to/fltk
|
|
|
|
|
|
|
|
is recommended by the FLTK team if you have installed MinGW with the MSYS
|
|
|
|
environment. You can use the stock Windows CMake executables, but you must
|
|
|
|
run the CMake executables from within the MinGW environment so CMake can
|
|
|
|
use your MinGW PATH to find the compilers and build tools. Example:
|
|
|
|
|
|
|
|
alias cmake='/c/CMake/bin/cmake'
|
|
|
|
alias cmake-gui='/c/CMake/bin/cmake-gui'
|
|
|
|
|
|
|
|
mkdir build
|
|
|
|
cd build
|
2017-07-05 20:15:16 +03:00
|
|
|
cmake -G "Unix Makefiles" -D 'CMAKE_BUILD_TYPE=Debug' ..
|
2016-11-01 18:18:31 +03:00
|
|
|
|
|
|
|
Note the path to FLTK ".." in the last command line. Depending on where you
|
|
|
|
installed CMake you may need to adjust the path's in the alias commands.
|
|
|
|
|
|
|
|
|
2017-07-05 18:02:43 +03:00
|
|
|
2.6 Building under MacOS with Xcode
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
Building with CMake under Xcode requires the CMake generator
|
|
|
|
with the -G command line switch. This step need to be done only once. If any
|
2017-07-07 21:28:10 +03:00
|
|
|
of the cmake related files are updated, Xcode will rerun cmake for you.
|
2017-07-05 18:02:43 +03:00
|
|
|
|
|
|
|
1) Open the MacOS Terminal
|
|
|
|
|
|
|
|
2) Change to the directory containing the FLTK project. For example:
|
|
|
|
> cd ~/dev/fltk-1.4.x
|
|
|
|
|
|
|
|
3) Create a build directory
|
|
|
|
> mkdir build
|
|
|
|
> cd build
|
|
|
|
|
|
|
|
4) If you plan different build versions, it is useful to create another
|
|
|
|
subdirectory level
|
|
|
|
> mkdir Xcode
|
|
|
|
> cd Xcode
|
|
|
|
|
2017-07-07 21:28:10 +03:00
|
|
|
5) Let CMake create the required IDE files
|
2017-07-05 18:02:43 +03:00
|
|
|
> cmake -G Xcode ../..
|
|
|
|
This step should end in the message:
|
|
|
|
-- Build files have been written to: .../dev/fltk-1.4.x/build/Xcode
|
|
|
|
|
|
|
|
5a) To build the Release version of FLTK, use
|
|
|
|
> cmake -G Xcode -D CMAKE_BUILD_TYPE=Release ../..
|
|
|
|
|
|
|
|
5b) To create all included libraries instead of using those that come
|
|
|
|
with MacOS, use:
|
|
|
|
> cmake -G Xcode -D OPTION_USE_SYSTEM_LIBJPEG=Off \
|
|
|
|
-D OPTION_USE_SYSTEM_ZLIB=Off \
|
|
|
|
-D OPTION_USE_SYSTEM_LIBPNG=Off \
|
|
|
|
../..
|
|
|
|
|
2017-07-07 21:28:10 +03:00
|
|
|
6) Launch Xcode from the Finder or from the Terminal:
|
2017-07-05 18:02:43 +03:00
|
|
|
> open ./FLTK.xcodeproj
|
2017-07-07 21:28:10 +03:00
|
|
|
When Xcode starts, it asks if it should "Autocreate Schemes". Click on
|
2017-07-05 18:02:43 +03:00
|
|
|
"Automatically Create Schemes" to confirm.
|
|
|
|
|
|
|
|
7) To build and test FLTK, select the scheme "ALL_BUILD" and hit Cmd-B to
|
|
|
|
build. Then select the scheme "demo" and hit Cmd-R to run the FLTK Demo.
|
|
|
|
|
2017-07-07 21:28:10 +03:00
|
|
|
8) The interactive user interface tool "Fluid" will be located in
|
|
|
|
build/Xcode/bin/Debug. The example apps are in .../bin/examples/Debug.
|
2017-07-05 18:02:43 +03:00
|
|
|
Static libraries are in .../lib/Debug/
|
|
|
|
|
|
|
|
9) The "install" Scheme currently fails because it is run with user permission.
|
|
|
|
|
|
|
|
|
|
|
|
2.7 Crosscompiling
|
2016-11-01 18:18:31 +03:00
|
|
|
---------------------
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
Once you have a crosscompiler going, to use CMake to build FLTK you need
|
2010-12-20 23:00:44 +03:00
|
|
|
two more things. You need a toolchain file which tells CMake where your
|
|
|
|
build tools are. The CMake website is a good source of information on
|
2020-01-18 16:29:01 +03:00
|
|
|
this file. Here's one for MinGW (64-bit) under Linux.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
----
|
2020-01-18 16:29:01 +03:00
|
|
|
# CMake Toolchain File for MinGW-w64 (64-bit) Cross Compilation
|
2019-07-03 14:41:42 +03:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
# the name of the target operating system
|
|
|
|
set(CMAKE_SYSTEM_NAME Windows)
|
|
|
|
|
|
|
|
# which tools to use
|
2020-01-18 16:29:01 +03:00
|
|
|
set(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc)
|
|
|
|
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)
|
|
|
|
set(CMAKE_RC_COMPILER /usr/bin/x86_64-w64-mingw32-windres)
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
# here is where the target environment located
|
2020-01-18 16:29:01 +03:00
|
|
|
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
|
|
|
|
|
|
|
|
# adjust the default behavior of the FIND_XXX() commands:
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
# search programs in the host environment
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
2020-01-18 16:29:01 +03:00
|
|
|
|
|
|
|
# search headers and libraries in the target environment
|
2010-12-20 23:00:44 +03:00
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${CMAKE_FIND_ROOT_PATH}/usr CACHE FILEPATH
|
|
|
|
"install path prefix")
|
2019-07-03 14:41:42 +03:00
|
|
|
|
|
|
|
# initialize required linker flags
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static-libgcc -static-libstdc++")
|
|
|
|
|
|
|
|
# end of toolchain file
|
2010-12-20 23:00:44 +03:00
|
|
|
----
|
|
|
|
|
|
|
|
Not too tough. The other thing you need is a native installation of FLTK
|
|
|
|
on your build platform. This is to supply the fluid executable which will
|
|
|
|
compile the *.fl into C++ source and header files.
|
|
|
|
|
|
|
|
So, again from the FLTK tree root.
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
mkdir mingw
|
|
|
|
cd mingw
|
|
|
|
cmake -DCMAKE_TOOLCHAIN_FILE=~/projects/toolchain/Toolchain-mingw32.cmake ..
|
|
|
|
make
|
|
|
|
sudo make install
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2017-09-06 01:37:07 +03:00
|
|
|
IMPORTANT: The trailing ".." on the cmake command must be specified
|
2020-01-18 16:29:01 +03:00
|
|
|
(it is NOT an ellipsis). ^^^^^^^^^^^^^^^^^
|
2017-09-06 01:37:07 +03:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
This will create a default configuration FLTK suitable for mingw/msys and
|
2020-01-18 16:29:01 +03:00
|
|
|
install it in the /usr/x86_64-w64-mingw32/usr tree.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2020-01-18 16:29:01 +03:00
|
|
|
Note: replace 'x86_64-w64-mingw32' with your cross toolchain location as
|
|
|
|
required.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
3. Using CMake with FLTK
|
|
|
|
===========================
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2014-09-27 04:41:06 +04:00
|
|
|
The CMake Export/Import facility can be thought of as an automated
|
2016-11-01 18:18:31 +03:00
|
|
|
fltk-config. For example, if you link your program to the FLTK
|
2014-09-27 04:41:06 +04:00
|
|
|
library, it will automatically link in all of its dependencies. This
|
2016-11-01 18:18:31 +03:00
|
|
|
includes any special flags, i.e. on Linux it includes the -lpthread flag.
|
2014-09-27 04:41:06 +04:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
This howto assumes that you have FLTK libraries which were built using
|
|
|
|
CMake, installed. Building them with CMake generates some CMake helper
|
|
|
|
files which are installed in standard locations, making FLTK easy to find
|
|
|
|
and use.
|
|
|
|
|
|
|
|
Here is a basic CMakeLists.txt file using FLTK.
|
|
|
|
|
|
|
|
------
|
|
|
|
|
2020-11-23 19:22:45 +03:00
|
|
|
cmake_minimum_required(VERSION 3.2.3)
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
project(hello)
|
|
|
|
|
2015-04-07 18:18:35 +03:00
|
|
|
# The following line is required only if (a) you didn't install FLTK
|
|
|
|
# or if (b) find_package can't find your installation directory because
|
|
|
|
# you installed FLTK in a non-standard location. It points to
|
|
|
|
# (a) the base folder of the build directory, or
|
|
|
|
# (b) <fltk-install-prefix>/share/fltk
|
|
|
|
# resp., where <fltk-install-prefix> is the installation prefix you
|
|
|
|
# used to install FLTK.
|
|
|
|
# (The file FLTKConfig.cmake and others must be found in that path.)
|
|
|
|
|
2014-09-27 04:41:06 +04:00
|
|
|
set(FLTK_DIR /path/to/fltk)
|
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
find_package(FLTK REQUIRED NO_MODULE)
|
2016-11-01 18:18:31 +03:00
|
|
|
|
2020-11-24 12:05:20 +03:00
|
|
|
add_executable(hello WIN32 MACOSX_BUNDLE hello.cxx)
|
2020-11-23 19:22:45 +03:00
|
|
|
if (APPLE)
|
|
|
|
target_link_libraries(hello "-framework cocoa")
|
|
|
|
endif (APPLE)
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2020-11-23 19:22:45 +03:00
|
|
|
target_include_directories(hello PUBLIC ${FLTK_INCLUDE_DIRS})
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
target_link_libraries(hello fltk)
|
|
|
|
|
|
|
|
------
|
|
|
|
|
2014-09-27 04:41:06 +04:00
|
|
|
The set(FLTK_DIR ...) command is a superhint to the find_package command.
|
|
|
|
This is very useful if you don't install or have a non-standard install.
|
2010-12-20 23:00:44 +03:00
|
|
|
The find_package command tells CMake to find the package FLTK, REQUIRED
|
|
|
|
means that it is an error if it's not found. NO_MODULE tells it to search
|
|
|
|
only for the FLTKConfig file, not using the FindFLTK.cmake supplied with
|
|
|
|
CMake, which doesn't work with this version of FLTK.
|
|
|
|
|
2020-11-24 12:05:20 +03:00
|
|
|
The "WIN32 MACOSX_BUNDLE" in the add_executable tells this is
|
|
|
|
a GUI app. It is ignored on other platforms and should always be
|
|
|
|
present with FLTK GUI programs for better portability.
|
2020-11-23 19:22:45 +03:00
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
Once the package is found the CMake variable FLTK_INCLUDE_DIRS is defined
|
|
|
|
which can be used to add the FLTK include directories to the definitions
|
2021-02-16 16:21:13 +03:00
|
|
|
used to compile your program using the `target_include_directories()` command.
|
2020-11-23 19:22:45 +03:00
|
|
|
|
2021-02-16 16:21:13 +03:00
|
|
|
The target_link_libraries() command is used to specify all necessary FLTK
|
2020-11-23 19:22:45 +03:00
|
|
|
libraries. Thus, you may have to add fltk_images, fltk_gl, etc…
|
2016-11-01 18:18:31 +03:00
|
|
|
|
|
|
|
Note: the variable FLTK_USE_FILE used to include another file in
|
2020-06-13 14:51:35 +03:00
|
|
|
previous FLTK versions was deprecated since FLTK 1.3.4 and will be
|
|
|
|
removed in FLTK 1.4.0 (this version) or later (maybe 1.4.1).
|
2016-11-01 18:18:31 +03:00
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
3.1 Library Names
|
|
|
|
--------------------
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-08-01 15:50:15 +03:00
|
|
|
When you use the target_link_libraries command, CMake uses its own
|
2010-12-20 23:00:44 +03:00
|
|
|
internal names for libraries. The fltk library names are:
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
fltk fltk_forms fltk_images fltk_gl
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
and for the shared libraries (if built):
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
fltk_SHARED fltk_forms_SHARED fltk_images_SHARED fltk_gl_SHARED
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
The built-in libraries (if built):
|
|
|
|
|
2013-05-16 17:29:49 +04:00
|
|
|
fltk_jpeg fltk_png fltk_z
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
|
2016-11-01 18:18:31 +03:00
|
|
|
3.2 Using Fluid Files
|
|
|
|
------------------------
|
2010-12-20 23:00:44 +03:00
|
|
|
|
|
|
|
CMake has a command named fltk_wrap_ui which helps deal with fluid *.fl
|
2021-04-29 19:32:19 +03:00
|
|
|
files. Unfortunately it is broken in CMake 3.4.x but it seems to work in
|
|
|
|
3.5 and later CMake versions. You can however use add_custom_command()
|
|
|
|
to achieve the same result. This is a more basic approach and should
|
|
|
|
work for all CMake versions.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-02-02 03:49:51 +03:00
|
|
|
Here is a sample CMakeLists.txt which compiles the CubeView example from
|
|
|
|
a directory you've copied the test/Cube* files to.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-02-02 03:49:51 +03:00
|
|
|
---
|
2016-08-01 15:50:15 +03:00
|
|
|
cmake_minimum_required(VERSION 2.6.3)
|
2016-02-02 03:49:51 +03:00
|
|
|
|
|
|
|
project(CubeView)
|
|
|
|
|
2016-08-01 15:50:15 +03:00
|
|
|
# change this to your fltk build directory
|
2016-02-02 03:49:51 +03:00
|
|
|
set(FLTK_DIR /home/msurette/build/fltk-release/)
|
|
|
|
|
|
|
|
find_package(FLTK REQUIRED NO_MODULE)
|
2016-11-01 18:18:31 +03:00
|
|
|
include_directories(${FLTK_INCLUDE_DIRS})
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-02-02 03:49:51 +03:00
|
|
|
#run fluid -c to generate CubeViewUI.cxx and CubeViewUI.h files
|
|
|
|
add_custom_command(
|
2020-07-01 19:03:10 +03:00
|
|
|
OUTPUT "CubeViewUI.cxx" "CubeViewUI.h"
|
|
|
|
COMMAND fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl
|
2016-02-02 03:49:51 +03:00
|
|
|
)
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-11-01 23:45:42 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
2016-08-01 15:50:15 +03:00
|
|
|
add_executable(CubeView WIN32 CubeMain.cxx CubeView.cxx CubeViewUI.cxx)
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-02-02 03:49:51 +03:00
|
|
|
target_link_libraries(CubeView fltk fltk_gl)
|
|
|
|
---
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2020-06-13 16:19:27 +03:00
|
|
|
You can repeat the add_custom_command for each fluid file or if you
|
|
|
|
have a large number of them see the CMake/FLTK-Functions.cmake function
|
|
|
|
FLTK_RUN_FLUID for an example of how to run it in a loop.
|
2010-12-20 23:00:44 +03:00
|
|
|
|
2016-11-01 23:45:42 +03:00
|
|
|
The two lines
|
|
|
|
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
add the current build ("binary") and source directories as include directories.
|
|
|
|
This is necessary for the compiler to find the local header files since the
|
|
|
|
fluid-generated files (CubeViewUI.cxx and CubeViewUI.h) are created in the
|
|
|
|
current build directory.
|
|
|
|
|
|
|
|
|
2010-12-20 23:00:44 +03:00
|
|
|
DOCUMENT HISTORY
|
|
|
|
==================
|
|
|
|
|
|
|
|
Dec 20 2010 - matt: merged and restructures
|
2013-05-16 17:29:49 +04:00
|
|
|
May 15 2013 - erco: small formatting tweaks, added some examples
|
2014-09-27 04:41:06 +04:00
|
|
|
Feb 23 2014 - msurette: updated to reflect changes to the CMake files
|
2015-04-07 18:18:35 +03:00
|
|
|
Apr 07 2015 - AlbrechtS: update use example and more docs
|
2016-02-02 03:49:51 +03:00
|
|
|
Jan 31 2016 - msurette: custom command instead of fltk_wrap_ui
|
2016-11-01 18:18:31 +03:00
|
|
|
Nov 01 2016 - AlbrechtS: remove deprecated FLTK_USE_FILE, add MinGW build
|
2017-07-05 18:02:43 +03:00
|
|
|
Jul 05 2017 - matt: added instructions for MacOS and Xcode
|
2018-12-29 22:04:38 +03:00
|
|
|
Dec 29 2018 - AlbrechtS: add documentation option descriptions
|
2021-04-29 19:32:19 +03:00
|
|
|
Apr 29 2021 - AlbrechtS: document macOS "universal apps" build setup
|