Make building Fluid optional. (#539)

This commit is contained in:
Matthias Melcher 2022-11-13 20:16:54 +01:00 committed by GitHub
parent 57f61cf5a0
commit edf7510dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 21 deletions

View File

@ -22,6 +22,12 @@
# USAGE: FLTK_RUN_FLUID TARGET_NAME "FLUID_SOURCE [.. FLUID_SOURCE]"
function (FLTK_RUN_FLUID TARGET SOURCES)
if (NOT FLTK_FLUID_EXECUTABLE)
message (WARNING "Not building ${SOURCES}. FLUID executable not found.")
return ()
endif (NOT FLTK_FLUID_EXECUTABLE)
set (CXX_FILES)
foreach (src ${SOURCES})
if ("${src}" MATCHES "\\.fl$")
@ -36,6 +42,7 @@ function (FLTK_RUN_FLUID TARGET SOURCES)
endif ("${src}" MATCHES "\\.fl$")
endforeach ()
set (${TARGET} ${CXX_FILES} PARENT_SCOPE)
endfunction (FLTK_RUN_FLUID TARGET SOURCES)
#######################################################################

View File

@ -10,7 +10,7 @@
# FLTK_INCLUDE_DIRS - FLTK include directories
# FLTK_LIBRARIES - list of FLTK libraries built (not yet implemented)
# FLTK_FLUID_EXECUTABLE - needed by the function FLTK_RUN_FLUID
# (or the deprecated fltk_wrap_ui() CMake command)
# (or the deprecated fltk_wrap_ui() CMake command)
#
# It defines the following deprecated variables for backwards
# compatibility (do not use for new projects):

View File

@ -21,16 +21,7 @@
# Set the fluid executable path used to create .cxx/.h from .fl files
if (CMAKE_CROSSCOMPILING)
# find a fluid executable on the host system
find_file(FLUID_PATH
NAMES fluid fluid.exe
PATHS ENV PATH
NO_CMAKE_FIND_ROOT_PATH
)
set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH})
set (FLUID_EXPORT "") # don't export fluid
else ()
if (FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING)
# use the fluid executable we build
if (WIN32)
set (FLTK_FLUID_EXECUTABLE fluid-cmd)
@ -39,7 +30,16 @@ else ()
set (FLTK_FLUID_EXECUTABLE fluid)
set (FLUID_EXPORT fluid) # export fluid
endif ()
endif (CMAKE_CROSSCOMPILING)
else ()
# find a fluid executable on the host system
find_file(FLUID_PATH
NAMES fluid fluid.exe
PATHS ENV PATH
NO_CMAKE_FIND_ROOT_PATH
)
set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH})
set (FLUID_EXPORT "") # don't export fluid
endif (FLTK_BUILD_FLUID AND NOT CMAKE_CROSSCOMPILING)
# generate FLTK-Targets.cmake for build directory use
export (TARGETS ${FLUID_EXPORT} ${FLTK_LIBRARIES} FILE ${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake)

View File

@ -50,7 +50,7 @@
#
################################################################################
macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
function (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
set (srcs) # source files
set (flsrcs) # fluid source (.fl) files
@ -91,6 +91,10 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
# generate source files from .fl files, add output to sources
if (flsrcs)
if (NOT FLTK_FLUID_EXECUTABLE)
message(STATUS "Example app \"${NAME}\" will not be built. FLUID executable not found.")
return ()
endif ()
FLTK_RUN_FLUID (FLUID_SOURCES "${flsrcs}")
list (APPEND srcs ${FLUID_SOURCES})
unset (FLUID_SOURCES)
@ -176,4 +180,4 @@ macro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
# *unused* # endforeach ()
# *unused* # endif ()
endmacro (CREATE_EXAMPLE NAME SOURCES LIBRARIES)
endfunction ()

View File

@ -122,14 +122,17 @@ if (UNIX OR MSYS OR MINGW)
)
endmacro (INSTALL_MAN FILE LEVEL)
INSTALL_MAN (fluid 1)
if (FLTK_BUILD_FLUID)
INSTALL_MAN (fluid 1)
endif (FLTK_BUILD_FLUID)
INSTALL_MAN (fltk-config 1)
INSTALL_MAN (fltk 3)
# Don't (!) install man pages of games (GitHub issue #23)
# INSTALL_MAN (blocks 6)
# INSTALL_MAN (checkers 6)
# INSTALL_MAN (sudoku 6)
if (FLTK_BUILD_TEST AND FLTK_BUILD_FLUID)
# Don't (!) install man pages of games (GitHub issue #23)
# INSTALL_MAN (blocks 6)
# INSTALL_MAN (checkers 6)
# INSTALL_MAN (sudoku 6)
endif ()
endif (UNIX OR MSYS OR MINGW)

View File

@ -301,6 +301,7 @@ option (OPTION_BUILD_SHARED_LIBS
option (OPTION_PRINT_SUPPORT "allow print support" ON)
option (OPTION_FILESYSTEM_SUPPORT "allow file system support" ON)
option (FLTK_BUILD_FLUID "Build FLUID" ON)
option (FLTK_BUILD_TEST "Build test/demo programs" ON)
option (FLTK_BUILD_EXAMPLES "Build example programs" OFF)

View File

@ -111,7 +111,9 @@ add_subdirectory(src)
# build fluid
#######################################################################
add_subdirectory(fluid)
if (FLTK_BUILD_FLUID)
add_subdirectory (fluid)
endif (FLTK_BUILD_FLUID)
#######################################################################
# variables shared by export and install
@ -210,6 +212,12 @@ else ()
message (STATUS "Shared libraries will not be built (set OPTION_BUILD_SHARED_LIBS=ON to build)")
endif ()
if (FLTK_BUILD_FLUID)
message (STATUS "FLUID will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/fluid")
else ()
message (STATUS "FLUID will not be built (set FLTK_BUILD_FLUID=ON to build)")
endif ()
if (FLTK_BUILD_TEST)
message (STATUS "Test programs will be built in ${CMAKE_CURRENT_BINARY_DIR}/bin/test")
endif ()

View File

@ -119,6 +119,9 @@ OPTION_BUILD_SHARED_LIBS - default OFF
Normally FLTK is built as static libraries which makes more portable
binaries. If you want to use shared libraries, this will build them too.
FLTK_BUILD_FLUID - default ON
Builds the Fast Light User-Interface Designer ("FLUID").
FLTK_BUILD_TEST - default ON
Builds the test and demo programs in the 'test' directory.