Skip to content

Commit

Permalink
CMake: set FLTK_VERSION and FLTK_FLUID_EXECUTABLE in the cache
Browse files Browse the repository at this point in the history
This is useful if FLTK is built as a subproject, for instance by
using FetchContent.
  • Loading branch information
Albrecht Schlosser committed Feb 12, 2024
1 parent cf551dd commit bddcecd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ if(0)
fl_debug_var(CMAKE_VERSION)
endif()

# Set FLTK_VERSION in the cache so user projects can access it,
# for instance if FLTK is built as a subproject (FetchContent)

set(FLTK_VERSION ${FLTK_VERSION} CACHE STRING "FLTK version" FORCE)

#######################################################################
# basic setup
#######################################################################
Expand Down Expand Up @@ -115,13 +120,22 @@ endif()
add_subdirectory(src)

#######################################################################
# build fluid
# build fluid (optional)
#######################################################################

set(FLTK_FLUID_EXECUTABLE "")

if(FLTK_BUILD_FLUID)
add_subdirectory(fluid)
endif(FLTK_BUILD_FLUID)

# Set FLTK_FLUID_EXECUTABLE in the cache for user projects.
# This can be used if FLTK has been built as a subproject.

set(FLTK_FLUID_EXECUTABLE
"${FLTK_FLUID_EXECUTABLE}" CACHE STRING
"FLTK's 'fluid' executable")

#######################################################################
# build fltk-options
#######################################################################
Expand Down
5 changes: 5 additions & 0 deletions fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ if(WIN32)
list(APPEND TARGETS fluid-cmd)
add_executable(fluid-cmd fluid.cxx)
target_link_libraries(fluid-cmd PRIVATE fluid-lib)
set(FLTK_FLUID_EXECUTABLE fltk::fluid-cmd)
else()
set(FLTK_FLUID_EXECUTABLE fltk::fluid)
endif()

set(FLTK_FLUID_EXECUTABLE "${FLTK_FLUID_EXECUTABLE}" PARENT_SCOPE)

# Create aliases for all targets

foreach(tgt ${TARGETS})
Expand Down

0 comments on commit bddcecd

Please sign in to comment.