Commit Graph

243 Commits

Author SHA1 Message Date
Albrecht Schlosser
b4cf1a9824 Fix and improve generation of fltk-config (#954 and more)
Parts of this commit fix the usage of CMake targets in the generation
process of fltk-config modified by PR #954.

The rest improves handling of variables used to generate fltk-config,
removes obsolete comments, documents variables like GLLIBS etc. which
had to be done anyway.
2024-04-14 19:15:08 +02:00
Jordan Williams
5417ea5f1f
CMake: Use imported targets for PkgConfig packages (#954)
This carries include directories and the required link flags.
Several libraries brought in through pkg_check_modules aren't linked correctly using the _LDFLAGS variables.
Instead, they link the libraries directly with `-l`.
This is problematic because it doesn't properly pull in the actual directory of the library being linked when it is not in a system library directory.
Likewise, the necessary include directories for several of these targets aren't properly set either.
Linking against the imported targets automatically pulls in the necessary include directories.
2024-04-14 19:07:15 +02:00
Jordan Williams
a6651e10ff
CMake: Improve detection of the GLU library and GL/glu.h header file (#953)
* CMake: Improve detection of the GLU library and GL/glu.h header file

Locate the GLU library and header independent of the GL library and header locations.
Add the GLU header location to necessary target_include_directory calls.

* CMake: Locate and use the GL include directory

Find the GL include directory and use it in target_include_directories calls.
2024-04-12 15:58:57 +02:00
Albrecht Schlosser
265e5cd77b Improve CMake build configuration summary
- simplify and unify build option output
- alignment can be changed in only 2 macros in CMake/fl_summary.cmake
- output system library location of image libraries if applicable
2024-04-08 18:56:40 +02:00
Albrecht Schlosser
2f1b8fc726 CMake: Fix detection of trunc() for Windows 2024-04-05 18:45:59 +02:00
Albrecht Schlosser
e5c4c1415b Add replacement for potentially missing trunc() (#944)
- add configure + CMake checks to define HAVE_TRUNC in config.h

- src/Fl_Timeout.cxx: add local replacement function
2024-04-02 16:03:29 +02:00
ManoloFLTK
4742d830be CMake for macOS platform: improve handling of -framework link arguments 2024-03-24 08:48:45 +01:00
ManoloFLTK
97d2836f5e macOS: remove deprecated use of property allowedFileTypes in class NSSavePanel
The recommended replacement requires macos ≥ 11.0 and a new framework: UniformTypeIdentifiers
2024-03-23 17:16:57 +01:00
Albrecht Schlosser
a5bad9a395 CMake: formatting only 2024-03-18 22:44:53 +01:00
Albrecht Schlosser
d3a3ab40b7 Replace setenv() with putenv() on old systems (+937)
Add system check for setenv() function in configure and CMake.
2024-03-18 22:29:50 +01:00
ManoloFLTK
82bd0b6652 Have FLTK use libdecor at version > 0.2.2
- it's no longer necessary to take care of the change in the layout of "struct libdecor"
between versions ≤ 0.2.2 and > 0.2.2 of libdecor
- version > 0.2.2 contains MR131, that is, it defines LIBDECOR_WINDOW_STATE_RESIZING
so the hack to emulate it is no longer  necessary
- CMake option FLTK_USE_SYSTEM_LIBDECOR now requires libdecor version > 0.2.2
to be activated, otherwise the bundled libdecor is used
- what will be the libdecor version after 0.2.2 (0.2.3? 0.3.0?) is not known as of today
2024-03-15 12:21:38 +01:00
ManoloFLTK
7e12981abd To support difference in struct libdecor between built-in and system
That should disappear when next version of libdecor will be released.
2024-03-13 18:53:48 +01:00
ManoloFLTK
3fafeb9ea1 Remove useless X11 libraries when building with -DFLTK_BACKEND_X11=0 2024-03-13 14:57:38 +01:00
ManoloFLTK
40aa9c8609 Allow CMake-based build with -DFLTK_BACKEND_X11=0 under Linux/Unix 2024-03-13 09:06:10 +01:00
Albrecht Schlosser
77c726c79c CMake/macOS/X11: fix "FINK" search directories
note: use only if found.

Todo: check if we can get rid of explicit directory names like /opt/sw,
  /sw, /opt/X11, ...
2024-02-24 19:20:22 +01:00
Albrecht Schlosser
a6dc84ac83 Fix CMake code that should only be evaluated on macOS
Too much simplified code when introducing modern CMake and renaming
some build options caused this issue. It's hopefully fixed nor, or
at least improved.

Todo: the code in question needs to be revised anyway.
2024-02-22 19:42:57 +01:00
Albrecht Schlosser
0987c763ec CMake: fix "LIBDECOR_PLUGIN_DIR" undefined error
This could happen on Linux if built with CMake option
  "-DFLTK_USE_SYSTEM_LIBDECOR=OFF"
2024-02-14 22:57:55 +01:00
Albrecht Schlosser
b282ee0335 CMake: remove unintended debug output 2024-02-14 17:51:51 +01:00
Albrecht Schlosser
7992b0b9ab CMake: fix installation on macOS
fluid and fltk-options are now installed correctly as bundles and as
stand-alone executables side by side in the 'bin' folder relative
to CMAKE_INSTALL_PREFIX.

This works but the installation folders may be changed in the future.

Targets fltk::fluid is now exported correctly so

  find_package(FLTK CONFIG ...)

works with both the build folder and an installed version.
2024-02-14 17:06:10 +01:00
Albrecht Schlosser
cd3cb62770 CMake: simplify resources.cmake
Note: CheckIncludeFiles caches the result in an 'internal' variable.
Hence mark_as_advanced() is not necessary for these variables.
2024-02-13 16:15:46 +01:00
Albrecht Schlosser
0771bc6cee CMake: improve formatting, remove debug statements 2024-02-13 15:10:06 +01:00
Albrecht Schlosser
179c5d3521 CMake: fix some weird internal dependencies (Wayland/X11)
Improve recognition of Wayland and X11 specific build options and
remove duplicates from required dependencies (FLTK_LDLIBS) used in
fltk-config.

This should also fix the GitLab CI build process.

To do: the logic to find the dependencies of Wayland and X11 is
currently suboptimal. This will be improved in a later commit.
2024-02-10 16:27:38 +01:00
Albrecht Schlosser
f4af40fe55 Modern CMake: export shared libraries and fltk-options 2024-02-10 14:19:09 +01:00
Albrecht Schlosser
809ceea075 Fix Cairo related build issues (missing Cairo lib)
... particularly for shared libs
2024-02-09 19:41:45 +01:00
Albrecht Schlosser
c83164fbcc CMake cleanup: fix alignment 2024-02-08 19:31:40 +01:00
Albrecht Schlosser
2ee5ca7ef3 CMake cleanup: mark two more cache variables "advanced" 2024-02-08 19:18:37 +01:00
Albrecht Schlosser
a1d3bf182e Fix GitHub CI build and minor CMake issues
- GitHub CI: fix wrong CMake option name
- fl_add_library: disable debug output (MSVC), fix formatting
2024-02-07 20:03:29 +01:00
Albrecht Schlosser
fd5cd80935 Introduce "Modern CMake" in FLTK
This is a big commit and there are too many changes to list them all.
The main changes are:

- rename all CMake build options to 'FLTK_*'
- export library targets with namespace (prefix) 'fltk::'
- standardize shared library target names with suffix '-shared'
- set public build properties on libraries for consumers
- document library names and aliases in README.CMake.txt
- document changes in "Migrating Code from FLTK 1.3 to 1.4"
- partial backwards compatibility for old user projects

Included but not directly related changes:

- fix Windows (Visual Studio) DLL build
- add CMake function fl_debug_target() to show target properties
- don't build test programs if FLTK is a subproject
- internal: reformat CMake code: remove space before '('

Thanks to Matthias and Manolo for their help, testing, and feeback.
2024-02-07 18:37:34 +01:00
Albrecht Schlosser
007e37d897 Ensure that exporting 'fl_disable_wayland' works
... with cmake_minimum_required(VERSION 3.4) or higher. This version
sets CMP0065 to 'NEW' which by default inhibits exporting global
symbols from executable programs.

For details see CMake policy CMP0065 and README.Wayland.txt.
2023-12-21 19:13:49 +01:00
Albrecht Schlosser
5df5daf78e Make the 'Forms' compatibility library 'fltk_forms' optional
This library is no longer needed in FLTK itself. There is only one
demo program (test/forms.cxx) that uses it if it is built. The demo
program displays a message if fltk_forms is not available.

The default is 'enabled' for backwards compatibility but this may
be changed to 'disabled' in a future version.
2023-12-20 17:33:37 +01:00
Albrecht Schlosser
5ef962781f CMake: remove deprecated 'exec_program' from target 'uninstall'
1. 'exec_program()' should be replaced with 'execute_process()'. Done.

2. 'cmake -E remove' is broken and deprecated since 3.17, hence we use
   'cmake -E rm' (!) for CMake since 3.17 and
   'cmake -E remove' only for older CMake versions.
2023-12-12 00:30:36 +01:00
ManoloFLTK
7bbfa06e38 Wayland+CMake: use set_source_files_properties() for libdecor 2023-12-05 08:52:21 +01:00
Albrecht Schlosser
cf07fa09dc Minor updates of bundled libraries and README.CMake.txt
Update Makefiles, CMakeLists.txt, improve formatting.
2023-12-04 17:31:18 +01:00
Albrecht Schlosser
63c54fe7c8 CMake: Remove UseFLTK.cmake generation and usage 2023-12-03 17:16:58 +01:00
ManoloFLTK
f72748bb45 Wayland: make OPTION_USE_SYSTEM_LIBDECOR ON by default
This commit makes the default FLTK build setting use libdecor
as packaged in Linux when the build system contains packages
libdecor-0-dev and libdecor-0-plugin-1-gtk in version ≥ 0.2.0.
Otherwise, FLTK uses the bundled version of libdecor.
This includes situations where package libdecor-0-dev is
present in an earlier version.
2023-12-02 09:28:08 +01:00
Albrecht Schlosser
4a461efae6 CMake/Windows/MSVC: Add option to select MSVC Runtime
Selects MSVC compiler/build options known as /MT, /MTd, /MD, or /MDd.

This applies to "Visual Studio" (IDE) and "NMake Makefiles" builds.
2023-11-25 21:03:23 +01:00
Albrecht Schlosser
e8ad00d9fe CMake/Windows/MSVC: add DLL path as target property
This modifies the debug environment so demo programs linked to FLTK
DLL's can be debugged w/o copying FLTK DLL's to the build folders
of the demo programs.

This is work in progress and may be improved in a future commit but
it works as it is now for all demo programs.
2023-11-25 20:53:46 +01:00
Albrecht Schlosser
6f021d4830 CMake: Raise cmake_minimum_required from 3.12 to 3.15
Remove code that checks CMake versions lower than 3.15
2023-11-15 21:30:12 +01:00
Albrecht Schlosser
1209e9dcd7 Make Fl_String and Fl_Int_Vector private (#789)
- add CMake option 'OPTION_USE_STD'
- add configure option '--enable-use_std'
- move FL/Fl_String.H to src/Fl_String.H
- move FL/Fl_Int_Vector.H to src/Fl_Int_Vector.H
- remove Fl_String from demo program examples/callbacks.cxx
- remove Fl_Int_Vector from public header FL/Fl_Table.H
- some methods of Fl_Table are no longer inline
- add CMake option OPTION_USE_STD to allow std::string in some
  selected functions and methods

Experimental, may be removed before release:

- use either Fl_Int_Vector or std::vector in Fl_Table depending
  on CMake OPTION_USE_STD or configure --enable-use_std

Move all fl_filename* functions that use Fl_String to fluid

Main changes in fluid:
 - add fluid_filename.h and .cxx
 - include "fluid_filename.h" rather than <FL/filename.H>

Update fl_input(), fl_password() and test/ask

- add maxchar parameter to fl_input() and fl_password()
- fl_input_str() and fl_password_str() are optional and return
  std::string if enabled (FLTK_USE_STD)
2023-10-22 19:35:17 +02:00
Albrecht Schlosser
d11c412f95 CMake: Make compile definitions 'FL_LIBRARY' and 'FL_DLL' private
... so they are not inherited by consumers of the library.

Remove 'add_definitions(-DFL_LIBRARY)' from src/CMakeLists.txt
  This is not necessary, see CMake/fl_add_library.cmake

Don't set obsolete property 'CLEAN_DIRECT_OUTPUT' which was removed
in CMake 2.8.0.
2023-08-28 15:21:58 +02:00
Albrecht Schlosser
372fe4cc99 CMake: fix formatting, add more debug output 2023-08-26 17:33:05 +02:00
ManoloFLTK
3e2c8d5a95 Allow building Wayland platform without dbus - cont'd (#726)
CMake-based building without dbus is made possible
2023-04-30 21:36:19 +02:00
ManoloFLTK
b867488442 Fix "recipe for target '../../src/xdg-decoration-protocol.c' failed" (#704) 2023-04-02 16:04:13 +02:00
Albrecht Schlosser
5175192755 CMake: build shared libs with OPTION_CAIROEXT (issue #250)
- remove separate libfltk_cairo to avoid cyclic dependencies, but
- keep a dummy libfltk_cairo in 1.4.0 for backwards compatibility
- move cairo/Fl_Cairo.cxx to src/Fl_Cairo.cxx
- add preliminary Cairo support for Visual Studio (MSVC)

Static linking is not affected by this change, but users building
with hand-made Makefiles will have to remove libfltk_cairo starting
with FLTK 1.4.0. The dummy library can be linked for backwards
compatibility but it will be removed later (in 1.4.x or 1.5.0).

The shared FLTK library libfltk.{so|dylib|dll|..} depends on libcairo
if and only if FLTK is built with one of the Cairo options. This has
always been the case for OPTION_CAIROEXT but is now also true if only
OPTION_CAIRO is selected, i.e. FLTK programs linked with a Cairo
enabled shared FLTK library will also be linked with libcairo. The same
is true for configure options --enable-cairo and --enable-cairoext,
respectively.

Preliminary Cairo support for MSVC now detects a Cairo installation
using the CMake variable FLTK_CAIRO_DIR which must be set by the user.
Note that this feature is temporary and may be changed in the future
for a better and more comfortable version.
2023-03-09 17:34:05 +01:00
Albrecht Schlosser
fc5f0c13f2 Fix fltk-config --use-images with local image libs (#689)
CMake only: replace wrong variable names with correct ones. Affected
were all image libraries (jpeg, png) and zlib.

These variables had been renamed in an earlier commit when lots of
CMake code had been rewritten.
2023-02-28 14:47:33 +01:00
ManoloFLTK
160eb2926d Remove usage of __APPLE_QUARTZ__ (#673) 2023-02-06 21:42:40 +01:00
Matthias Melcher
1aa6c4fed8
Fix position() methods that shadow Fl_Widget::position()
* `FL_DEPRECATED` macro to mark `position()` method that shadow `Fl_Widget::position()` #69 (#666)
2023-02-02 20:54:19 +01:00
ManoloFLTK
6276822e9e Allow cmake -DOPTION_APPLE_X11=On without -U__APPLE__ 2023-02-02 18:48:24 +01:00
Matthias Melcher
1fc269b0d4
Move global FLTK options into new app fltk-admin (#560) 2023-01-21 17:14:41 +01:00
Matthias Melcher
c8024c7a3b
Make sure that zlib and png are both local or system (#621)
Autoconf syncs png and zlib configuration
Cmake png zlib selection
2023-01-01 17:29:23 +01:00