CMake: Build fluid when cross-compiling

This commit is contained in:
Albrecht Schlosser 2021-11-11 23:11:06 +01:00
parent 6d1f5608ba
commit 654e20ff8b
4 changed files with 23 additions and 17 deletions

View File

@ -28,7 +28,7 @@ function (FLTK_RUN_FLUID TARGET SOURCES)
string(REGEX REPLACE "(.*).fl" \\1 basename ${src})
add_custom_command(
OUTPUT "${basename}.cxx" "${basename}.h"
COMMAND fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/${src}
COMMAND ${FLTK_FLUID_EXECUTABLE} -c ${CMAKE_CURRENT_SOURCE_DIR}/${src}
DEPENDS ${src}
MAIN_DEPENDENCY ${src}
)

View File

@ -1,8 +1,8 @@
#
# Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org)
# Export CMake file to build the FLTK project using CMake (www.cmake.org)
# Written by Michael Surette
#
# Copyright 1998-2020 by Bill Spitzak and others.
# Copyright 1998-2021 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
@ -19,27 +19,23 @@
# final config and export
#######################################################################
# Set the fluid executable path
# 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
)
add_executable(fluid IMPORTED)
set (FLTK_FLUID_EXECUTABLE ${FLUID_PATH})
set (FLUID) # no export
set_target_properties(fluid
PROPERTIES IMPORTED_LOCATION ${FLUID_PATH}
)
set (FLUID) # don't export
else ()
add_subdirectory(fluid)
# use the fluid executable we build
set (FLTK_FLUID_EXECUTABLE fluid)
set (FLUID fluid) # export
set (FLUID fluid) # export
endif (CMAKE_CROSSCOMPILING)
add_subdirectory(src)
# generate FLTK-Targets.cmake for build directory use
export(TARGETS ${FLUID} ${FLTK_LIBRARIES} FILE ${CMAKE_CURRENT_BINARY_DIR}/FLTK-Targets.cmake)

View File

@ -114,6 +114,20 @@ endif (debug_build)
unset (debug_build)
#######################################################################
# build the FLTK libraries
#######################################################################
add_subdirectory(src)
#######################################################################
# build fluid
#######################################################################
if (NOT ANDROID)
add_subdirectory(fluid)
endif()
#######################################################################
# variables shared by export and install
# export.cmake creates configuration files for direct use in a built but uninstalled FLTK

View File

@ -14,8 +14,6 @@
# https://www.fltk.org/bugs.php
#
if (NOT ANDROID)
set (CPPFILES
CodeEditor.cxx
StyleParse.cxx
@ -115,5 +113,3 @@ if (UNIX)
)
endforeach()
endif (UNIX)
endif (NOT ANDROID)