diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2025-04-17 18:23:55 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2025-04-21 19:50:12 +0200 |
| commit | 1066b69c8e14cea5a71cac5330a8e60cb3cb3c49 (patch) | |
| tree | 6e5863922f921c538de7b9d513a3cae47031e4d8 /test | |
| parent | 48e22d246ddf96aa6c9595b35250992fe9fe3bbc (diff) | |
Fix "fully support ... own shared libraries" (#1238)
- If shared libraries are built, then fluid, fltk-options, and the
"games" are linked against the shared FLTK libraries. On some
platforms the static and the shared versions of fluid and
fltk-options are built. The games are only built if
FLTK_BUILD_TEST is enabled.
- The CMake 'install' target now installs the games (if built)
and their man pages on all platforms (no matter if that is
useful, for instance on Windows).
- On macOS 'CMAKE_INSTALL_RPATH' is set so *installed* programs
automatically find their shared FLTK libraries. The "shared"
versions of fluid and fltk-options got their own '.plist' files.
This works for both the executables themselves as well as those
included in bundles. There may be more to do on the macOS platform.
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a445b05fa..00765a79b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ # # CMakeLists.txt used to build test and demo apps by the CMake build system # -# Copyright 2004-2024 by Bill Spitzak and others. +# Copyright 2004-2025 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -84,14 +84,12 @@ fl_create_example(arc arc.cxx fltk::fltk) fl_create_example(animated animated.cxx fltk::fltk) fl_create_example(ask ask.cxx fltk::fltk) fl_create_example(bitmap bitmap.cxx fltk::fltk) -fl_create_example(blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk;${AUDIOLIBS}") fl_create_example(boxtype boxtype.cxx fltk::fltk) fl_create_example(browser browser.cxx fltk::fltk) fl_create_example(button button.cxx fltk::fltk) fl_create_example(buttons buttons.cxx fltk::fltk) # Cairo demo, built with and w/o Cairo (libcairo is linked implicitly - or not at all) fl_create_example(cairo_test cairo_test.cxx fltk::fltk) -fl_create_example(checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images) fl_create_example(clipboard clipboard.cxx fltk::images) fl_create_example(clock clock.cxx fltk::fltk) fl_create_example(colbrowser colbrowser.cxx fltk::fltk) @@ -161,7 +159,6 @@ fl_create_example(resize-example5c "resize-example5c.cxx;resize-arrows.cxx" fltk fl_create_example(rotated_text rotated_text.cxx fltk::fltk) fl_create_example(scroll scroll.cxx fltk::fltk) fl_create_example(subwindow subwindow.cxx fltk::fltk) -fl_create_example(sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images;${AUDIOLIBS}") fl_create_example(symbols symbols.cxx fltk::fltk) fl_create_example(tabs tabs.fl fltk::fltk) fl_create_example(table table.cxx fltk::fltk) @@ -176,6 +173,14 @@ fl_create_example(valuators valuators.fl fltk::fltk) fl_create_example(windowfocus windowfocus.cxx fltk::fltk) fl_create_example(wizard wizard.cxx fltk::fltk) +# games + +if(NOT FLTK_BUILD_SHARED_LIBS) + fl_create_example(blocks "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk;${AUDIOLIBS}") + fl_create_example(checkers "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images) + fl_create_example(sudoku "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images;${AUDIOLIBS}") +endif() + # unittests uses multiple source files and can be built with or w/o OpenGL and "shared" SET (UNITTEST_SRCS @@ -213,7 +218,9 @@ if(OPENGL_FOUND) fl_create_example(cube cube.cxx "${GLDEMO_LIBS}") fl_create_example(fractals "fractals.cxx;fracviewer.cxx" "${GLDEMO_LIBS}") fl_create_example(glut_test glut_test.cxx "${GLDEMO_LIBS}") - fl_create_example(glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}") + if(NOT FLTK_BUILD_SHARED_LIBS) + fl_create_example(glpuzzle glpuzzle.cxx "${GLDEMO_LIBS}") + endif() fl_create_example(gl_overlay gl_overlay.cxx "${GLDEMO_LIBS}") fl_create_example(shape shape.cxx "${GLDEMO_LIBS}") endif(OPENGL_FOUND) @@ -268,51 +275,29 @@ if(CMAKE_CXX_COMPILER_ID IN_LIST _compilers) endif() # GNU or Clang (-Wshadow test) unset(_compilers) - -# *** EXPERIMENTAL *** # Build some of the demo programs linked against the shared FLTK lib(s). -# This is currently pretty complicated and should be improved. -# It will be simplified significantly when we use more "modern CMake". if(FLTK_BUILD_SHARED_LIBS) if(MSVC) # MS Visual C++ aka. Visual Studio - # We need to link with fl_call_main.c, but this must not be compiled with - # macro FL_DLL, whereas the other source file(s) must be compiled with FL_DLL - # to link against the shared libs. - # - # ;-) I *love* Visual Studio (MSVC) ;-) - # - # Trick: build an object library with just this one file and link the executable - # against the shared library plus this object library. Another way would be to - # add the extra source file fl_call_main.c to the source files of all targets - # and set the FL_DLL compile_definition property only on the main *source* files - # but this doesn't work since the same file must be compiled for the "static" - # and the "shared" target, for instance hello.cxx for "hello" and "hello-shared". - - add_library (CALL_MAIN OBJECT EXCLUDE_FROM_ALL ../src/fl_call_main.c) + # We need to link with fl_call_main.c which is available as an object + # library 'call_main' when built with MSVC (see main CMakeLists.txt). - # define a list of shared targets so we can set COMPILE_DEFINITIONS in a loop - set(SHARED_TARGETS "") + fl_create_example(hello-shared hello.cxx "call_main;fltk::fltk-shared") + fl_create_example(pixmap_browser-shared pixmap_browser.cxx "call_main;fltk::fltk-shared") + fl_create_example(unittests-shared "${UNITTEST_SRCS}" "call_main;${GLDEMO_SHARED}") - fl_create_example(hello-shared hello.cxx "CALL_MAIN;fltk::fltk-shared") - fl_create_example(pixmap_browser-shared pixmap_browser.cxx "CALL_MAIN;fltk::fltk-shared") - fl_create_example(unittests-shared "${UNITTEST_SRCS}" "CALL_MAIN;${GLDEMO_SHARED}") - - list(APPEND SHARED_TARGETS hello pixmap_browser unittests) + # Games + fl_create_example(blocks-shared "blocks.cxx;blocks.plist;blocks.icns" "call_main;fltk::fltk-shared;${AUDIOLIBS}") + fl_create_example(checkers-shared "checkers.cxx;checkers_pieces.fl;checkers.icns" "call_main;fltk::fltk-shared") + fl_create_example(sudoku-shared "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "call_main;fltk::fltk-shared;${AUDIOLIBS}") if(OPENGL_FOUND) - fl_create_example(glpuzzle-shared glpuzzle.cxx "CALL_MAIN;${GLDEMO_SHARED}") - fl_create_example(shape-shared shape.cxx "CALL_MAIN;${GLDEMO_SHARED}") - list(APPEND SHARED_TARGETS glpuzzle shape) + fl_create_example(glpuzzle-shared glpuzzle.cxx "call_main;${GLDEMO_SHARED}") + fl_create_example(shape-shared shape.cxx "call_main;${GLDEMO_SHARED}") endif(OPENGL_FOUND) - # apply property COMPILE_DEFINITIONS "-D FL_DLL" in a loop for all necessary source files - foreach(tgt ${SHARED_TARGETS}) - target_compile_definitions (${tgt}-shared PRIVATE "FL_DLL") - endforeach() - else() # not MSVC fl_create_example(cairo_test-shared cairo_test.cxx fltk::fltk-shared) @@ -320,12 +305,16 @@ if(FLTK_BUILD_SHARED_LIBS) fl_create_example(pixmap_browser-shared pixmap_browser.cxx fltk::images-shared) fl_create_example(unittests-shared "${UNITTEST_SRCS}" "${GLDEMO_SHARED}") + # Games + fl_create_example(blocks-shared "blocks.cxx;blocks.plist;blocks.icns" "fltk::fltk-shared;${AUDIOLIBS}") + fl_create_example(checkers-shared "checkers.cxx;checkers_pieces.fl;checkers.icns" fltk::images-shared) + fl_create_example(sudoku-shared "sudoku.cxx;sudoku.plist;sudoku.icns;sudoku.rc" "fltk::images-shared;${AUDIOLIBS}") + if(OPENGL_FOUND) fl_create_example(glpuzzle-shared glpuzzle.cxx "${GLDEMO_SHARED}") fl_create_example(shape-shared shape.cxx "${GLDEMO_SHARED}") endif(OPENGL_FOUND) - endif(MSVC) # (not MSVC) endif(FLTK_BUILD_SHARED_LIBS) |
