{"id":13533303,"url":"https://github.com/fltk/fltk","last_synced_at":"2025-05-13T19:05:52.317Z","repository":{"id":37623286,"uuid":"149260789","full_name":"fltk/fltk","owner":"fltk","description":"FLTK - Fast Light Tool Kit - https://github.com/fltk/fltk - cross platform GUI development","archived":false,"fork":false,"pushed_at":"2025-04-26T16:50:52.000Z","size":41888,"stargazers_count":1865,"open_issues_count":78,"forks_count":305,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-04-26T17:37:31.167Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.fltk.org","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fltk.png","metadata":{"files":{"readme":"README.CMake.txt","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-09-18T09:15:58.000Z","updated_at":"2025-04-25T08:42:14.000Z","dependencies_parsed_at":"2023-09-23T04:52:34.200Z","dependency_job_id":"0929dae6-273a-4f72-bab4-e01b5519a854","html_url":"https://github.com/fltk/fltk","commit_stats":null,"previous_names":[],"tags_count":89,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fltk%2Ffltk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fltk%2Ffltk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fltk%2Ffltk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fltk%2Ffltk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fltk","download_url":"https://codeload.github.com/fltk/fltk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251030251,"owners_count":21525488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:18.512Z","updated_at":"2025-05-13T19:05:52.308Z","avatar_url":"https://github.com/fltk.png","language":"C++","readme":"README.CMake.txt - Building and Using FLTK with CMake\n------------------------------------------------------\n\n\n CONTENTS\n==========\n\n  1     Introduction to CMake\n\n  2     Using CMake to Build FLTK\n\n    2.1    Prerequisites\n    2.2    Options\n    2.2.1  CMake Specific Configuration Options\n    2.2.2  FLTK Specific Configuration Options\n    2.2.3  Documentation Options\n    2.2.4  Special Options\n    2.2.5  Other CMake Cache Variables\n    2.3    Building FLTK with CMake (all Platforms)\n    2.4    Building under Linux with Unix Makefiles\n    2.5    Building under Windows with Visual Studio and/or NMake\n    2.5.1  Building under Windows with Visual Studio\n    2.5.2  Building under Windows with NMake\n    2.6    Building under Windows with MinGW using Makefiles\n    2.7    Building under Windows WSL with Clang using Makefiles\n    2.8    Building under macOS with Xcode\n    2.9    Crosscompiling\n\n  3     Using CMake with FLTK\n\n    3.1    Library Names\n    3.2    Library Aliases\n    3.3    Exported and Imported Targets\n    3.4    Building a Simple \"Hello World\" Program with FLTK\n    3.5    Building a Program Using Fluid Files\n    3.6    Building a Program Using CMake's FetchContent Module\n\n\n  4     FindFLTK.cmake and find_package(FLTK)\n\n 1.  Introduction to CMake\n===========================\n\nCMake was designed to let you create build files for a project once and\nthen compile the project on multiple platforms.\n\nUsing it on any platform consists of the same steps. Create the\nCMakeLists.txt build file(s). Run one of the CMake executables, picking\nyour source directory, build directory, and build target. The \"cmake\"\nexecutable is a one-step process with everything specified on the command\nline. The others let you select options interactively, then configure\nand generate your platform-specific target. You then run the resulting\nMakefile / project file / solution file as you normally would.\n\nCMake can be run in up to three ways, depending on your platform. \"cmake\"\nis the basic command line tool. \"ccmake\" is the curses based interactive\ntool. \"cmake-gui\" is the gui-based interactive tool. Each of these will\ntake command line options in the form of -DOPTION=VALUE. ccmake and\ncmake-gui will also let you change options interactively.\n\nCMake not only supports, but works best with out-of-tree builds. This means\nthat your build directory is not the same as your source directory or with a\ncomplex project, not the same as your source root directory. Note that the\nbuild directory is where, in this case, FLTK will be built, not its final\ninstallation point. If you want to build for multiple targets, such as\nVC++ and MinGW on Windows, or do some cross-compiling you must use out-of-tree\nbuilds exclusively. In-tree builds will gum up the works by putting a\nCMakeCache.txt file in the source root.\n\nFLTK does not allow in-tree builds since version 1.5.0 for safety reasons.\n\nMore information on CMake can be found on its web site https://www.cmake.org.\n\n\n\n 2.  Using CMake to Build FLTK\n===============================\n\n\n 2.1  Prerequisites\n--------------------\n\nThe prerequisites for building FLTK with CMake are staightforward:\nCMake 3.15 or later and a recent FLTK release, snapshot, or Git download\n(working copy). Installation of CMake is covered on its web site.\n\nThis howto will cover building FLTK with the default options using CMake\nunder Linux and MinGW with Unix Makefiles. Chapter 2.5 shows how to use\na MinGW cross compiling toolchain to build a FLTK library for Windows\nunder Linux. Other platforms are just as easy to use.\n\n\n 2.2  Options\n--------------\n\nOptions can be specified to CMake with the -D flag:\n\n    cmake -D \u003cOPTION_NAME\u003e=\u003cOPTION_VALUE\u003e\n\nExample:\n\n    cmake -D CMAKE_BUILD_TYPE=Debug\n\nNotes: the space between '-D' and the option name can be omitted.\nOption values must be quoted if they contain spaces.\n\nOther CMake tools are `ccmake` and `cmake-gui` but these are not\ndescribed here.\n\nAll options have sensible defaults so you won't usually need to specify\nthem explicitly.\n\n\n 2.2.1  CMake Specific Configuration Options\n---------------------------------------------\n\nThere are only four CMake options that you typically want to specify.\nEach option has a specific \":type\" setting which is kind of optional\nbut should usually be specified in scripts.\n\n-G \"Generator\"\n    This specifies the build system you want to use. In most cases the\n    platform specific default can be used, but you may want to use\n    another generator, e.g. \"Ninja\" on Unix-like platforms (Linux) where\n    \"Unix Makefiles\" is the default. On Windows the default is\n    \"Visual Studio xxxx ...\" if it is installed, on macOS it is\n    \"Unix Makefiles\" like on other Unix-like platforms but you can use\n    \"Xcode\" if you like. Other build systems (generators) may be available\n    on your platform, but these are out of the scope of this document.\n    The command `cmake --help` outputs a list of available generators.\n\n-D CMAKE_BUILD_TYPE:STRING=...\n    This specifies what kind of build this is i.e. Release, Debug...\n    Platform specific compile/link flags/options are automatically selected\n    by CMake depending on this value. Some generators, notably IDE systems\n    (e.g. Visual Studio on Windows, Xcode on macOS) ignore this option. You\n    can specify the build type at build time with these generators.\n\n-D CMAKE_INSTALL_PREFIX:PATH=...\n    Where everything will go on install. Defaults are /usr/local for Unix\n    and C:\\Program Files\\FLTK for Windows.\n\n-D CMAKE_OSX_ARCHITECTURES:STRING=...\n    This is macOS specific and ignored on other platforms.\n    Set this to either \"arm64\", \"x86_64\", or a list of both \"arm64;x86_64\".\n    The latter will build \"universal apps\" on macOS, whereas the former\n    will either build Intel (x86_64) or Apple Silicon aka M1 (arm64) apps.\n    The default is to build for the host processor architecture.\n\nNote: the CMake variable BUILD_SHARED_LIBS is ignored by FLTK. FLTK builds\n    static libs by default and can optionally build shared libs as well.\n    Please see FLTK_BUILD_SHARED_LIBS instead.\n\n\n 2.2.2  FLTK Specific Configuration Options\n--------------------------------------------\n\nFollowing are the FLTK specific options. Platform specific options are\nignored on other platforms. For convenience the list of options is ordered\nalphabetically except \"Documentation Options\" and \"Special Options\" that\nfollow in their own sections below.\n\n\nFLTK_ABI_VERSION - default EMPTY\n    Use a numeric value corresponding to the FLTK ABI version you want to\n    build in the form 1xxyy for FLTK 1.x.y (xx and yy with leading zeroes).\n    The default ABI version is 1xx00 (the stable ABI throughout all patch\n    releases of one minor FLTK version). The highest ABI version you may\n    choose is 1xxyy + 1 for FLTK 1.x.y (again with leading zeroes), i.e.\n\n        1xx00 \u003c= FL_ABI_VERSION \u003c= FL_API_VERSION + 1\n\n    since FLTK 1.4.2. In prior versions the highest ABI version that\n    could be set was the same as FL_API_VERSION. The option to set the ABI\n    version one greater than the current API version allows to build FLTK\n    from Git or from a snapshot with the latest ABI features designated\n    for the next higher version as long as the API version is the old\n    version of the latest release.\n    Please see README.abi-version.txt for more details.\n\nFLTK_ARCHFLAGS - default EMPTY\n    Extra \"architecture\" flags used as C and C++ compiler flags.\n    These flags are also \"exported\" to fltk-config.\n\nFLTK_BACKEND_WAYLAND - default ON (only Unix/Linux, not on macOS)\n    Enable the Wayland backend for all window operations, Cairo for all\n    graphics, and Pango for text drawing (Linux+FreeBSD only). Resulting FLTK\n    apps use Wayland when a Wayland compositor is available at runtime, and\n    use X11 for their window operations otherwise (unless FLTK_BACKEND_X11\n    is OFF), but keep using Cairo and Pango - see README.Wayland.txt.\n    If FLTK_BACKEND_X11 has been turned OFF and there is no Wayland\n    compositor at runtime, then FLTK programs fail to start.\n\nFLTK_BACKEND_X11 - default ON on Unix/Linux, OFF elsewhere (Windows, macOS).\n    Enable or disable the X11 backend on platforms that support it.\n    - Unix/Linux: enable or disable the X11 backend when building with\n      Wayland (FLTK_BACKEND_WAYLAND), otherwise this option must be ON.\n    - macOS: enable the X11 backend instead of standard system graphics.\n      This requires XQuartz or a similar X11 installation. This option is\n      tested only with XQuartz by the FLTK team.\n      Use this only if you know what you do and if you have installed X11.\n    - Windows/Cygwin: enable X11 backend for Cygwin platforms. This option\n      is currently (as of FLTK 1.4.0) not supported on Windows.\n\nNote: On platforms that support Wayland you may set FLTK_BACKEND_WAYLAND=ON\n    (this is the default) and FLTK_BACKEND_X11=OFF to build a Wayland-only\n    library or vice versa for an X11-only library.\n\nFLTK_BUILD_EXAMPLES - default OFF\n    Build the example programs in the 'examples' directory.\n\nFLTK_BUILD_FLTK_OPTIONS - default ON\n    Build the FLTK options editor (\"fltk-options\").\n\nFLTK_BUILD_FLUID - default ON\n    Build the Fast Light User-Interface Designer (\"fluid\").\n\nFLTK_BUILD_FORMS - default OFF since 1.5.0, ON in prior versions\n    Build the (X)Forms compatibility library. This option is OFF by default\n    because most FLTK software doesn't need it. You can turn this option\n    on for backwards compatibility if you need (X)Forms compatibility.\n\nFLTK_BUILD_GL - default ON\n    Build the OpenGL support library fltk_gl (fltk::gl) and enable OpenGL\n    support in user programs using fltk_gl.\n\nFLTK_BUILD_SHARED_LIBS - default OFF\n    Normally FLTK is built as static libraries which makes more portable\n    binaries. If you want to use shared libraries, setting this option ON\n    will build them too. You can use shared FLTK libs in your own CMake\n    projects by appending \"-shared\" to FLTK target names as described in\n    sections 3.1 and 3.2.\n\nFLTK_BUILD_TEST - default ON in top-level build, OFF in sub-build\n    Build the test and demo programs in the 'test' directory. The default\n    is ON if FLTK is built in a top-level project so all test and demo\n    programs are built. If FLTK is built as a subproject only the library\n    and the tools (fluid and fltk-config) are built by default.\n\nFLTK_GRAPHICS_CAIRO - default OFF (Unix/Linux: X11 + Wayland only).\n    Make all drawing operations use the Cairo library (rather than Xlib),\n    producing antialiased graphics (X11 platform: implies FLTK_USE_PANGO).\n    When using Wayland this option is always ON (Wayland uses Cairo for\n    drawing).\n\nFLTK_GRAPHICS_GDIPLUS - default ON (Windows only).\n    Make FLTK use GDI+ to draw oblique lines and curves resulting in\n    antialiased graphics. If this option is OFF standard GDI is used.\n\nFLTK_MSVC_RUNTIME_DLL - default ON (Windows: Visual Studio, NMake, clang).\n    Select whether the build uses the MS runtime DLL (ON) or not (OFF).\n    Default is ON: either /MD or /MDd for Release or Debug, respectively.\n    Select OFF for either /MT or /MTd for Release or Debug, respectively.\n    If this variable is defined on other platforms it is silently ignored.\n\nFLTK_OPTION_CAIRO_EXT - default OFF\n    Enable extended libcairo support. Setting this to ON is not recommended,\n    see README.Cairo.txt.\n\nFLTK_OPTION_CAIRO_WINDOW - default OFF\n    Enable support of class Fl_Cairo_Window (all platforms, requires the\n    Cairo library) - see README.Cairo.txt.\n\nFLTK_OPTION_FILESYSTEM_SUPPORT - default ON\n\nFLTK_OPTION_LARGE_FILE - default ON\n    Enables large file (\u003e2G) support.\n\nFLTK_OPTION_OPTIM - default EMPTY\n    Extra optimization flags for the C and C++ compilers, for instance\n    \"-Wall -Wno-deprecated-declarations\". Example:\n    cmake -D FLTK_BUILD_EXAMPLES=on -D FLTK_OPTION_OPTIM=\"-Wall -Wextra -pedantic\" ..\n\nFLTK_OPTION_PRINT_SUPPORT - default ON\n    When turned off, the Fl_Printer class does nothing and the\n    Fl_PostScript_File_Device class cannot be used, but the FLTK library\n    is somewhat smaller. This option makes sense only on the Unix/Linux\n    platform or on macOS when FLTK_BACKEND_X11 is ON.\n\nFLTK_OPTION_STD - removed in FLTK 1.5\n    This option allowed FLTK 1.4 to use some specific C++11 features like\n    std::string in the public API of FLTK 1.4.x.\n    This option has been removed in FLTK 1.5 which uses std::string\n    and other C++11 features by default.\n    You may safely remove this CMake option from your configuration.\n\nFLTK_OPTION_SVG - default ON\n    FLTK has a built-in SVG library and can create (write) SVG image files.\n    Turning this option off disables SVG (read and write) support.\n\nFLTK_USE_LIBDECOR_GTK - default ON (Wayland only).\n    Meaningful only under Wayland and if FLTK_USE_SYSTEM_LIBDECOR is 'OFF'.\n    Allows to use libdecor's GTK plugin to draw window titlebars. Otherwise\n    FLTK does not use GTK and apps will not need linking to GTK.\n\nFLTK_USE_PANGO - default OFF (see note below)\n    This option is highly recommended under X11 if FLTK is expected to draw\n    text that does not use the latin alphabet.\n    Enables use of the Pango library for drawing text. Pango supports all\n    unicode-defined scripts and gives FLTK limited support of right-to-left\n    scripts. This option makes sense only under X11 or Wayland, and also\n    requires Xft.\n    This option is ignored (always ON) if Wayland or FLTK_GRAPHICS_CAIRO\n    is ON.\n\nFLTK_USE_POLL - default OFF\n    Deprecated: don't turn this option ON.\n\nFLTK_USE_PTHREADS - default ON except on Windows.\n    Enables multithreaded support with pthreads if available.\n    This option is ignored (switched OFF internally) on Windows except\n    when using Cygwin.\n\nFLTK_USE_SYSTEM_LIBDECOR - default ON (Wayland only)\n    This option makes FLTK use package libdecor-0-dev to draw window titlebars\n    under Wayland. When OFF or when this package has a version \u003c 0.2.0, FLTK\n    uses its bundled copy of libdecor to draw window titlebars.\n\nFLTK_USE_SYSTEM_LIBJPEG - default ON (macOS and Windows: OFF)\nFLTK_USE_SYSTEM_LIBPNG  - default ON (macOS and Windows: OFF)\nFLTK_USE_SYSTEM_ZLIB    - default ON (macOS and Windows: OFF)\n    FLTK has built-in jpeg, zlib, and png libraries. These options let you\n    use system libraries instead, unless CMake can't find them. If you set\n    any of these options to OFF, then the built-in library will be used.\n    The default is ON on Linux/Unix platforms but OFF on Windows and macOS\n    because of potential incompatibilities on Windows and macOS whereas\n    the system libraries can typically be used on Linux/Unix.\n    Note: if any one of libpng or zlib is not found on the system, both\n    libraries are built using the bundled ones and a warning is issued.\n\nFLTK_USE_XCURSOR  - default ON\nFLTK_USE_XFIXES   - default ON\nFLTK_USE_XFT      - default ON\nFLTK_USE_XINERAMA - default ON\nFLTK_USE_XRENDER  - default ON\n    These are X11 extended libraries. These libs are used if found on the\n    build system unless the respective option is turned off.\n\n\n 2.2.3  Documentation Options\n------------------------------\n\n  These options are only available if `doxygen' is installed and found.\n  PDF related options require also `latex'.\n\nFLTK_BUILD_HTML_DOCS - default ON\nFLTK_BUILD_PDF_DOCS  - default ON\n    These options can be used to enable HTML documentation generation with\n    doxygen. If these are ON the build targets 'html', 'pdf', and 'docs'\n    are generated but must be built explicitly. The target 'docs' is a\n    shortcut for 'html' and 'docs'. Technically the CMake build targets\n    are generated but excluded from 'ALL'.\n    You can safely leave these two options ON if you want to save build\n    time because the docs are not built automatically. This may change\n    in a future release.\n\nFLTK_BUILD_FLUID_DOCS - default OFF\n    If this option is ON, the FLUID user documentation can be built (target\n    'fluid_docs'). If FLTK_BUILD_PDF_DOCS (see above) is ON, the FLUID\n    documentation can also be created in PDF form (target 'fluid_pdf').\n    To generate the screen shots used in the handbook, the CMake build\n    type must be set to \"Debug\".\n    You can safely set these two options ON if you want to save build\n    time because the docs are not built automatically. This may change\n    in a future release.\n\nFLTK_INCLUDE_DRIVER_DOCS - default OFF\n    This option adds driver documentation to HTML and PDF docs (if ON).\n    This option is marked as \"advanced\" since it is only useful for FLTK\n    developers and advanced users. It is only used if at least one of the\n    documentation options above is ON as well.\n\nFLTK_INSTALL_HTML_DOCS  - default OFF\nFLTK_INSTALL_FLUID_DOCS - default OFF\nFLTK_INSTALL_PDF_DOCS   - default OFF\n    If these options are ON then the HTML, FLUID, and/or PDF docs are\n    installed when the 'install' target is executed, e.g. `make install'.\n    You need to select above options FLTK_BUILD_*_DOCS as well and build\n    the documentation manually (this may be improved in a later version).\n\n\n 2.2.4  Special Options\n------------------------\n\nFLTK_INSTALL_LINKS - default OFF\n    Deprecated: install \"compatibility\" links to compensate for typos in\n    include statements (for case sensitive file systems only).\n    You should not use this option, please fix the sources instead for\n    better cross-platform compatibility.\n\n\n 2.2.5  Other CMake Cache Variables\n------------------------------------\n\nThe following CMake cache variables can be used to view their computed values\nin the CMake cache or to change the build behavior in special cases. To view\nthe variables\n\n - use `cmake -LA` or\n - use `cmake-gui` (switch 'Advanced' view ON) or\n - use `ccmake` (hit 't' to \"Toggle advanced mode\")\n - search the CMake cache 'CMakeCache.txt' with your favorite tool.\n\nUse either the `cmake` commandline, `cmake-gui`, or `ccmake` to change these\nvariables if needed.\n\nCMake cache variables can also be preset using a toolchain file (see below)\nand on the commandline.\n\n\nFLTK_FLUID_EXECUTABLE - default = fltk::fluid (see exceptions below)\n\n    This represents the `fluid` executable or CMake target that is used\n    to \"compile\" fluid `.fl` files to source (.cxx) and header (.h) files.\n\n    The default `fltk::fluid` is used when `fluid` is built and not\n    cross-compiled, i.e. the fluid executable that is built can be used.\n    On Windows and macOS `fltk::fluid-cmd` (the console program) is used\n    instead.\n\n    When cross-compiling this variable should be a compatible `fluid`\n    executable on the build host. For details see chapter 2.9.\n\nFLTK_FLUID_HOST - default = fluid executable on the build host\n\n    This variable is used if `fluid` is not built (FLTK_BUILD_FLUID=OFF)\n    or if cross-compiling. It can be preset by the CMake commandline to\n    point the build at a compatible `fluid` executable.\n\nFLUID_PATH - obsolete (FLTK 1.3.x): predecessor of FLTK_FLUID_HOST\n\n    This variable can safely be deleted from the CMake cache if it exists.\n\n\n 2.3  Building FLTK with CMake (all Platforms)\n-----------------------------------------------\n\nCMake is used to generate a build system that will subsequently be used\nto build and install the FLTK library and test and demo applications.\n\nNote that \"installing\" FLTK is optional: you can skip this step if you\nlike to build your own applications directly from the FLTK build tree.\nThis has advantages if you are building FLTK with different options or\nare developing FLTK (changing sources) or if you pull new FLTK versions\nfrom git frequently.\n\nThe following generic commands may need some changes on Windows where\nyou may not have an adequate (POSIX) shell (command window).\n\n(1) Generate the build system in the FLTK root directory:\n\n    cmake -B build [ -G \"Generator\" -D \"Options\" … ]\n\n  This command creates the 'build' subdirectory if it does not exist yet\n  and generates the build (project) files in the 'build' directory.\n  See above for usable options.\n\n  Note: Although this 'build' directory is part of the source tree it\n  is considered an out-of-source build because CMake does not create\n  any files in source directories. You can also use CMake to build FLTK\n  in an arbitrary build folder elsewhere on the system:\n\n    cmake -B /path/to/my-fltk-build [ -G \"Generator\" -D \"Options\" … ]\n\n  Commandline elements in […] are optional.\n\n  Use `cmake --help` to find out which generators are available on your\n  platform. The default generator is marked with '*'.\n\n(2) Build FLTK with the generated build system:\n\n  No matter which generator you selected in (1), the following CMake\n  command can always be used to build the library:\n\n    cmake --build build\n\n  This uses the previously generated build system in the 'build' folder.\n  This works even with Visual Studio where the build will be executed\n  without opening the Visual Studio GUI, similar to NMake.\n\n  Instead of using the above command you can also `cd build` and run\n  the native build command, for instance `make -j7` or `ninja`, or\n  you can open the IDE project (Xcode, Visual Studio, ...).\n\n(3) Install FLTK (optional):\n\n    cmake --install build\n\n  This command installs the previously built library and headers in the\n  installation folder. On Unix/Linux/macOS systems this requires root\n  privileges if the target is a system directory.\n\nThe following chapters describe some special cases in more detail. Skip\nchapters you don't need...\n\n\n 2.4  Building under Linux with Unix Makefiles\n-----------------------------------------------\n\nAfter unpacking the FLTK source, go to the root of the FLTK tree and type\nthe following.\n\n    cmake -B build -G \"Unix Makefiles\" [options]\n    cd build\n    make [ -j 3 ]\n    sudo make install (optional)\n\nThis will build and optionally install a default configuration FLTK.\n\nSome flags can be changed during the 'make' command, such as:\n\n    make VERBOSE=on\n\nwhich builds in verbose mode, so you can see all the compile/link commands.\n\nHint: if you intend to build several different versions of FLTK, e.g.\na Debug and a Release version, or multiple libraries with different ABI\nversions or options, or cross-compile for another platform we recommend\nto use subdirectories in the build folder, like this:\n\n    mkdir build\n    cd build\n    mkdir debug\n    cd debug\n    cmake -D 'CMAKE_BUILD_TYPE=Debug' ../..\n    make\n    sudo make install (optional)\n\n\n 2.5  Building under Windows with Visual Studio and/or NMake\n-------------------------------------------------------------\n\nBuilding with CMake under Visual Studio may require to specify the CMake\ngenerator with the -G\"Visual Studio ...\" command line switch, or the\ngenerator can be selected interactively in the GUI (cmake-gui). If you\nare not sure which one to select use `cmake --help` which lists all\ngenerators known to CMake on your system.\n\n\n 2.5.1 Building under Windows with Visual Studio\n-------------------------------------------------\n\nCMake often finds an installed Visual Studio generator and uses it w/o\nusing the commandline switch, particularly if you are using a special\n\"Visual Studio Command Prompt\":\n\n  - Hit the \"Windows\" key\n\n  - Type \"developer command ...\"\n    ... until you see something like \"Developer Command Prompt for VS xxxx\"\n    (replace 'xxxx' with your installed Visual Studio version)\n\n  - Activate the \"app\" to execute the command prompt (like an old \"DOS\" shell)\n\n  - Inside this command prompt window, run your installed `cmake` (command\n    line) or `cmake-gui` (GUI) program. You may need to specify the full path\n    to this program.\n\n  If you use `cmake-gui` you can select the source and the build folders in\n  the GUI, otherwise change directory to where you downloaded and installed\n  the FLTK sources and execute:\n\n      `cmake` -G \"Visual Studio xxx...\" -B build\n      cd build\n\n  This creates the Visual Studio project files (FLTK.sln and more) in the\n  'build' directory.\n\n  Open Visual Studio, choose File -\u003e Open -\u003e Project, and pick the \"FLTK.sln\"\n  created in the previous step.\n\n  (Or, if only one version of the Visual Studio compiler is installed,\n  you can just run from DOS: .\\FLTK.sln)\n\n  Make sure the pulldown menu has either \"Release\" or \"Debug\" selected\n  in the \"Solution Configurations\" pulldown menu.\n\n  In the \"Solution Explorer\", right click on:\n\n      Solution 'FLTK' (## projects)\n\n      ... and in the popup menu, choose \"Build Solution\"\n\n  or choose 'Build/Build Solution' or 'Build/Rebuild Solution' from the\n  menu at the top of the window.\n\n  That's it, that should build FLTK.\n\n  The test programs (*.exe) can be found relative to the 'build' folder in\n\n      build\\bin\\test\\Release\\*.exe\n      build\\bin\\test\\Debug\\*.exe\n\n  ... and the FLTK include files (*.H \u0026 *.h) your own apps can\n  compile with can be found in:\n\n      build\\FL\n\n  *and* [1] in the source folder where you downloaded FLTK, e.g. in\n\n      C:\\fltk-1.4.x\\FL\n\n  ... and the FLTK library files (*.lib) which your own apps can\n  link with can be found in:\n\n      Release: build\\lib\\Release\\*.lib\n        Debug: build\\lib\\Debug\\*.lib\n\n  [1] If you want to build your own FLTK application directly using\n      the build directories (i.e. without \"installation\") you need\n      to include both the build tree (first) and then the FLTK source\n      tree in the compiler's header search list.\n\n\n 2.5.2 Building under Windows with NMake\n-----------------------------------------\n\n  This example uses cmake to generate + build FLTK in Release mode using nmake,\n  using purely the command line (never need to open the Visual Studio IDE)\n  using the static Multithreaded runtime (/MT):\n\n    mkdir build-nmake\n    cd build-nmake\n    cmake -G \"NMake Makefiles\" -D CMAKE_BUILD_TYPE=Release -D FLTK_MSVC_RUNTIME_DLL=off ..\n    nmake\n\n  which results in a colorful percentage output crawl similar to what we see\n  with unix 'make'.\n\n  Instead of running `nmake` directly you can also use cmake to build:\n\n    cmake --build .\n\n\n 2.6  Building under Windows with MinGW using Makefiles\n--------------------------------------------------------\n\nBuilding with CMake under MinGW requires you to specify the CMake Generator\nwith the -G command line switch. Using\n\n  cmake -G \"Unix Makefiles\" /path/to/fltk\n\nis recommended by the FLTK team if you have installed MinGW with the MSYS\nenvironment. You can use the stock Windows CMake executables, but you must\nrun the CMake executables from within the MinGW environment so CMake can\nuse your MinGW PATH to find the compilers and build tools. Example:\n\n  alias cmake='/c/CMake/bin/cmake'\n  alias cmake-gui='/c/CMake/bin/cmake-gui'\n\n  mkdir build\n  cd build\n  cmake -G \"Unix Makefiles\" -D 'CMAKE_BUILD_TYPE=Debug' ..\n\nNote the path to FLTK \"..\" in the last command line. Depending on where you\ninstalled CMake you may need to adjust the path's in the alias commands.\n\n\n 2.7  Building under Windows WSL with Clang and Makefiles\n----------------------------------------------------------\n\nWSL, the Windows Subsystem for Linux allows developers to run a Linux\nenvironment without the need for a separate virtual machine or dual booting.\nWSL 2 runs inside a managed virtual machine that implements the full\nLinux kernel. WSL requires Windows 11.\n\nFLTK apps generated using WSL are Linux compatible binaries. To run those\nbinaries on Windows, WSL comes with a limited built-in X11 server. Third\nparty X11 servers can be installed that better support all features of FLTK.\n\n1) Install WSL from PowerShell with admin privileges:\n     \u003e wsl --install\n\n2) Reboot and open the Linux terminal. You will need to install the following\n   Linux packages to compile FLTK\n     \u003e sudo apt update\n     \u003e sudo apt install clang cmake freeglut3-dev\n\n3) Change to the directory containing the FLTK project. For example:\n     \u003e cd ~/dev/fltk-1.4.x\n\n4) Use CMake to configure the build system\n     \u003e cmake -B build\n\n5) Use CMake to build the demo app and all dependencies\n     \u003e cmake --build build\n\n6) Run the demo app\n     \u003e ./build/bin/test/demo\n\n\n2.8  Building under macOS with Xcode\n-------------------------------------\n\nBuilding with CMake under Xcode requires the CMake generator with\nthe -G command line switch. This step need to be done only once. If any\nof the CMake related files are updated, Xcode will rerun CMake for you.\n\n1) Open the macOS Terminal\n\n2) Change to the directory containing the FLTK project. For example:\n     \u003e cd ~/dev/fltk-1.4.x\n\n3) Create a build directory\n     \u003e mkdir build\n     \u003e cd build\n\n4) If you plan different build versions, it is useful to create another\n   subdirectory level\n     \u003e mkdir Xcode\n     \u003e cd Xcode\n\n5) Let CMake create the required IDE files\n     \u003e cmake -G Xcode ../..\n   This step should end in the message:\n     -- Build files have been written to: .../dev/fltk-1.4.x/build/Xcode\n\n5a) To build the Release version of FLTK, use\n      \u003e cmake -G Xcode -D CMAKE_BUILD_TYPE=Release ../..\n\n6) Launch Xcode from the Finder or from the Terminal:\n     \u003e open ./FLTK.xcodeproj\n   When Xcode starts, it asks if it should \"Autocreate Schemes\". Click on\n   \"Automatically Create Schemes\" to confirm.\n\n7) To build and test FLTK, select the scheme \"ALL_BUILD\" and hit Cmd-B to\n   build. Then select the scheme \"demo\" and hit Cmd-R to run the FLTK Demo.\n\n8) The interactive user interface tool \"Fluid\" will be located in\n   build/Xcode/bin/Debug. The example apps are in .../bin/examples/Debug.\n   Static libraries are in .../lib/Debug/.\n   Replace 'Debug' with 'Release' for a Release build.\n\n9) The \"install\" Scheme may fail because it is run with user permissions.\n   You may want to configure the build to install in a folder below your\n   home directory.\n\n\n 2.9  Crosscompiling\n---------------------\n\nOnce you have a crosscompiler going, to use CMake to build FLTK you need\ntwo more things. You need a toolchain file which tells CMake where your\nbuild tools are. The CMake website is a good source of information on\nthis file. Here's one for MinGW (64-bit) under Linux.\n\n----\n# CMake Toolchain File for MinGW-w64 (64-bit) Cross Compilation\n\n# the name of the target operating system\nset(CMAKE_SYSTEM_NAME Windows)\n\n# which tools to use\nset(CMAKE_C_COMPILER   /usr/bin/x86_64-w64-mingw32-gcc)\nset(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)\nset(CMAKE_RC_COMPILER  /usr/bin/x86_64-w64-mingw32-windres)\n\n# here is where the target environment located\nset(CMAKE_FIND_ROOT_PATH  /usr/x86_64-w64-mingw32)\n\n# adjust the default behavior of the FIND_XXX() commands:\n\n# search programs in the host environment\nset(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\n# search headers and libraries in the target environment\nset(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nset(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\nset(CMAKE_INSTALL_PREFIX ${CMAKE_FIND_ROOT_PATH}/usr CACHE FILEPATH\n   \"install path prefix\")\n\n# initialize required linker flags to build compatible Windows programs\nset(CMAKE_EXE_LINKER_FLAGS_INIT \"-static-libgcc -static-libstdc++\")\n\n# end of toolchain file\n----\n\nNot too tough. The other thing you need is a native installation of FLTK\non your build platform. This is to supply the fluid executable which will\ncompile the *.fl into C++ source and header files. This is only needed if\nthe test/* and/or example/* demo programs are built.\n\nCMake finds the fluid executable on the build host automatically when\ncross-compiling if it exists and is in the user's PATH. On systems that\nprovide multiple fluid versions (e.g. 1.3.x and 1.4.x) or if only an older\nversion is installed (e.g. 1.3.x) you can set the variable `FLTK_FLUID_HOST`\non the cmake commandline like\n\n    cmake -B mingw -S . [ -G \"Ninja\" ] \\\n      -D CMAKE_BUILD_TYPE=Debug \\\n      -D CMAKE_TOOLCHAIN_FILE=\u003ctoolchain-file\u003e \\\n      -D FLTK_FLUID_HOST=/path/to/fluid [.. more parameters ..]\n\nNote: replace '-G \"Ninja\" ' with the build tool of your choice or omit this\nargument to use the default generator of your platform.\n\nTheoretically the variable FLTK_FLUID_HOST can also be set in a toolchain\nfile. This has been tested successfully but is not recommended because the\ntoolchain file should be independent of the project using it.\n\nAfter generating the build system (above), build and optionally install the\nlibrary:\n\n    cmake --build mingw\n    [sudo] cmake --install mingw  # optional\n\nThis will create a default configuration FLTK suitable for mingw/msys and\ninstall it in the /usr/x86_64-w64-mingw32/usr tree.\n\nNote: replace 'x86_64-w64-mingw32' with your cross toolchain location as\nrequired.\n\n\n 3.  Using CMake with FLTK\n===========================\n\nThe CMake Export/Import facility can be thought of as an automated\nfltk-config. For example, if you link your program to the FLTK\nlibrary, it will automatically link in all of its dependencies. This\nincludes any special flags, i.e. on Linux it includes the -lpthread flag.\n\nThis howto assumes that you have FLTK libraries which were built using CMake,\ninstalled. Building them with CMake generates some CMake helper files which\nare installed in standard locations, making FLTK easy to find and use.\n\nIf FLTK is not installed in a standard system location where it is found\nautomatically, you may need to set a CMake variable to point CMake to the\nright location.\n\nIn the following examples we set the CMake cache variable 'FLTK_DIR' so\nCMake knows where to find the FLTK configuration file 'FLTKConfig.cmake'.\nIt is important (recommended practice) to set this as a CMake cache variable\nwhich enables the user executing 'cmake' to override this path either on the\ncommandline or interactively using the CMake GUI 'cmake-gui' or 'ccmake' on\nUnix/Linux, for instance like this:\n\n  $ cd my-project\n  $ mkdir build\n  $ cd build\n  $ cmake -G \"Unix Makefiles\" -S.. -D \"FLTK_DIR=/home/me/fltk\"\n\n\n 3.1  Library Names\n--------------------\n\nWhen you use the target_link_libraries() command, CMake uses its own internal\n\"target names\" for libraries. The original fltk library names in the build\ntree are:\n\n    fltk    fltk_forms    fltk_images    fltk_gl\n\nThe bundled image and zlib libraries (if built):\n\n    fltk_jpeg    fltk_png    fltk_z\n\nAppend suffix \"-shared\" for shared libraries (Windows: DLL's).\n\nThese library names are used to construct the filename on disk with system\nspecific prefixes and postfixes. For instance, on Linux/Unix 'fltk' is libfltk.a\nand the shared library (fltk-shared) is libfltk.so.1.4.0 (in FLTK 1.4.0) with\nadditional system specific links.\n\nNote: since FLTK 1.5.0 the library fltk_cairo is no longer necessary and\nmust be removed from CMake files of user projects. fltk_cairo was an empty\nlibrary solely for backwards compatibility in FLTK 1.4 and has been removed\nfrom FLTK 1.5.\n\n\n 3.2  Library Aliases\n----------------------\n\nSince FLTK 1.4.0 \"aliases\" for all libraries in the FLTK build tree are\ncreated in the namespace \"fltk::\". These aliases should always be used by\nconsumer projects (projects that use FLTK) for several reasons which are\nbeyond the scope of this README file. The following table shows the FLTK\nlibraries and their aliases in the FLTK build tree.\n\n  Library Name     Alias          Shared Library Alias    Notes\n  --------------------------------------------------------------\n    fltk           fltk::fltk     fltk::fltk-shared       [1]\n    fltk_forms     fltk::forms    fltk::forms-shared      [2]\n    fltk_gl        fltk::gl       fltk::gl-shared         [2]\n    fltk_images    fltk::images   fltk::images-shared     [2]\n    fltk_jpeg      fltk::jpeg     fltk::jpeg-shared       [3]\n    fltk_png       fltk::png      fltk::png-shared        [3]\n    fltk_z         fltk::z        fltk::z-shared          [3]\n\n  [1] The basic FLTK library. Use this if you don't need any of the other\n      libraries for your application.\n  [2] Use one or more of these libraries if you have specific needs,\n      e.g. if you need to read images (fltk::images), OpenGL (fltk::gl),\n      or (X)Forms compatibility (fltk::forms). If you use one of these\n      libraries in your CMakeLists.txt then fltk::fltk will be included\n      automatically.\n  [3] The bundled libraries are only built if requested and are usually\n      not needed in user projects. They are linked in with fltk::images\n      automatically if they were built together with FLTK.\n      The only reason you may need them would be if you used libpng,\n      libjpeg, or zlib functions directly in your application and need\n      to use the bundled FLTK libs (e.g. on Windows).\n\n\n 3.3  Exported and Imported Targets\n------------------------------------\n\nCMake terminology is to \"export\" and \"import\" library \"targets\". FLTK's\nCMake files export targets and its CONFIG module FLTKConfig.cmake imports\ntargets so user projects can use them. Hence, if you use CMake's CONFIG\nmode to find FLTK all library targets will be defined using the namespace\nconvention listed above in the \"Alias\" column. This is what user projects\nare recommended to use.\n\nIn addition to the library targets FLTK defines the \"imported target\"\n'fltk::fluid' which can be used to generate source (.cxx) and header (.h)\nfiles from fluid (.fl) files.\n\nAnother target fltk::fltk-config can be used to set (e.g.) system or user\nspecific FLTK options. This would usually be executed in the installation\nprocess of a user project but should rarely be needed and is beyound the\nscope of this documentation.\n\n\n 3.4  Building a Simple \"Hello World\" Program with FLTK\n--------------------------------------------------------\n\nHere is a basic CMakeLists.txt file using FLTK. It is important that\nthis file can only be used as simple as it is if you use find_package()\nin `CONFIG` mode as shown below. This requires that the FLTK library\nitself has been built with CMake.\n\n---\ncmake_minimum_required(VERSION 3.15)\n\nproject(hello)\n\n# optional (see below):\nset(FLTK_DIR \"/path/to/fltk\"\n    CACHE FILEPATH \"FLTK installation or build directory\")\n\nfind_package(FLTK 1.4 CONFIG REQUIRED)\n\nadd_executable       (hello WIN32 MACOSX_BUNDLE hello.cxx)\ntarget_link_libraries(hello PRIVATE fltk::fltk)\n---\n\nWe recommend to use `cmake_minimum_required(VERSION 3.15)` or higher for\nbuilding projects that use FLTK. Lower CMake versions may work for user\nprojects but this is not tested by FLTK developers.\n\nThe optional `set(FLTK_DIR ...)` command is a superhint to the find_package\ncommand. This is useful if you don't install FLTK or have a non-standard\ninstall location. The path you give to it must be that of a directory that\ncontains the file FLTKConfig.cmake.\n\nYou can omit this statement if CMake finds the required FLTK version\nwithout it. This variable is stored in the CMake Cache so users can change\nit with the ususal CMake GUI interfaces (ccmake, cmake-gui) or on the\nCMake commandline (-D FLTK_DIR=...).\n\nThe find_package command tells CMake to find the package FLTK, '1.4' says\nthat we want FLTK 1.4.x: any patch version of 1.4 will match. 'REQUIRED'\nmeans that it is an error if it's not found. 'CONFIG' tells it to search\nonly for the FLTKConfig.cmake file, not using the FindFLTK.cmake \"module\"\nsupplied with CMake, which doesn't work with this version of FLTK. Since\nwe specify a version (1.4) the file 'FLTKConfigVersion.cmake' must also\nbe found. This file is created since FLTK 1.3.10.\n\n\"WIN32 MACOSX_BUNDLE\" in the add_executable() command tells CMake that\nthis is a GUI app. It is ignored on other platforms than Windows or macOS,\nrespectively, and should always be present with FLTK GUI programs for\nbetter portability - unless you explicitly need to build a \"console program\"\non Windows.\n\nOnce the package is found (in CONFIG mode, as described above) all built\nFLTK libraries are \"imported\" as CMake \"targets\" or aliases and can be used\ndirectly. These CMake library targets contain all necessary informations to\nbe used without having to know about additional include directories or\nother library dependencies. This is what is called \"Modern CMake\".\n\nOlder FLTK versions required to use the variables FLTK_INCLUDE_DIRS and\nFLTK_LIBRARIES (among others). These variables and related commands are\nno longer necessary if your project (CMakeLists.txt) uses CMake's\nCONFIG mode as described in this file.\n\nThe target_link_libraries() command is used to specify all necessary FLTK\nlibraries. Thus you may use fltk::fltk, fltk::images, fltk::gl, fltk::forms,\nor any combination. fltk::fltk is linked automatically if any of the other\nlibs is included.\n\n\n 3.5  Building a Program Using Fluid Files\n-------------------------------------------\n\nCMake has a command named fltk_wrap_ui which helps deal with fluid *.fl\nfiles. Unfortunately it is broken in CMake 3.4.x but it seems to work in\n3.5 and later CMake versions. We recommend to use add_custom_command()\nto achieve the same result in a more explicit and well-defined way.\nThis is a more basic approach and should work for all CMake versions.\nIt is described below.\n\nHere is a sample CMakeLists.txt which compiles the CubeView example from\na directory you've copied the test/Cube* files to.\n\n---\ncmake_minimum_required(VERSION 3.15)\n\nproject(CubeView)\n\n# change this to your fltk build directory\nset(FLTK_DIR \"/path/to/fltk\"\n    CACHE FILEPATH \"FLTK installation or build directory\")\n\nfind_package(FLTK 1.4 CONFIG REQUIRED)\n\n# run fluid -c to generate CubeViewUI.cxx and CubeViewUI.h files\nadd_custom_command(\n    OUTPUT \"CubeViewUI.cxx\" \"CubeViewUI.h\"\n    COMMAND fltk::fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl\n)\n\nadd_executable(CubeView WIN32 MACOSX_BUNDLE\n               CubeMain.cxx CubeView.cxx CubeViewUI.cxx)\n\ntarget_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR})\ntarget_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})\n\ntarget_link_libraries     (CubeView PRIVATE fltk::gl)\n---\n\nYou can repeat the add_custom_command for each fluid file or if you\nhave a large number of them see the fltk_run_fluid() function in\nCMake/FLTK-Functions.cmake for an example of how to run it in a loop.\n\nThe two lines\n\n  target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_BINARY_DIR})\n  target_include_directories(CubeView PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})\n\nadd the current build (\"binary\") and source directories as include directories.\nThis is necessary for the compiler to find the local header files since the\nfluid-generated files (CubeViewUI.cxx and CubeViewUI.h) are created in the\ncurrent build directory and other header files may be in the source directory\n(depending on your project).\n\n\n 3.6  Building a Program Using CMake's FetchContent Module\n-----------------------------------------------------------\n\nFLTK can be downloaded and built within a user project using CMake's\nFetchContent module. A sample CMakeLists.txt file follows.\n\nYou may need to adjust it to your configuration.\n\n---\ncmake_minimum_required(VERSION 3.15)\nproject(hello)\n\ninclude(FetchContent)\n\nFetchContent_Declare(FLTK\n  GIT_REPOSITORY  https://github.com/fltk/fltk\n  GIT_TAG         master\n  GIT_SHALLOW     TRUE\n)\n\nmessage(STATUS \"Download and build FLTK if necessary, please wait...\")\nFetchContent_MakeAvailable(FLTK)\nmessage(STATUS \"Download and build FLTK - done.\")\n\nadd_executable       (hello WIN32 MACOSX_BUNDLE hello.cxx)\ntarget_link_libraries(hello PRIVATE fltk::fltk)\n---\n\nThis is as simple as it can be. The CMake FetchContent module is used to\ndownload the FLTK sources from their Git repository and to build them.\nNote that this will download and build the FLTK library during the CMake\nconfigure phase which can take some time. Therefore the statement\n`FetchContent_MakeAvailable()` is wrapped in `message(STATUS \"...\")`\ncommands to let the user know what's going on.\n\n\n 4  FindFLTK.cmake and find_package(FLTK)\n==========================================\n\nThe FindFLTK.cmake module provided by CMake which is also used in the\nCMake command find_package(FLTK) does not yet support FLTK's new \"Modern\nCMake\" features.\n\nUnfortunately this module has to be used if the FLTK library wasn't built\nwith CMake and thus CONFIG mode can't be used. In this case CMake falls back\nto MODULE mode and find_package() uses this old CMake module.\n\nThere are plans to provide a FindFLTK.cmake module with a later FLTK release.\nLook here for further info if you need it...\n","funding_links":[],"categories":["C++","Libraries"],"sub_categories":["C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffltk%2Ffltk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffltk%2Ffltk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffltk%2Ffltk/lists"}