Skip to content

Commit

Permalink
Warn if we have changed build settings and a populated bext_output
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Mar 8, 2024
1 parent 8ff7d51 commit 0b9a6bb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ option(USE_OSPRAY "OSPRay rendering system" OFF)
option(USE_QT "Qt graphical toolkit support" ON)
option(USE_TCL "Tcl/Tk support" ON)

# If configurations change after a build has been performed,
# we don't automatically scrub a pre-existing output directory
# to remove the files from the newly disabled components.
# Warn the user of this
set(STALE_INSTALL_WARN FALSE)

function(add_project pname)
cmake_parse_arguments(A "" "" "GROUPS" ${ARGN})
string(TOUPPER "${pname}" UPNAME)
Expand All @@ -288,6 +294,7 @@ function(add_project pname)
if (NOT is_added)
if (ENABLE_${UPNAME})
message("Disabling ${pname} due to disabled USE flags")
set(STALE_INSTALL_WARN TRUE PARENT_SCOPE)
endif (ENABLE_${UPNAME})
execute_process(COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/${pname})
unset(ENABLE_${UPNAME} CACHE)
Expand Down Expand Up @@ -609,6 +616,17 @@ add_project(appleseed GROUPS "APPLESEED")
# https://github.com/ospray/OSPRay
add_project(ospray GROUPS "OSPRAY")


# Warn the user if the settings changed in a way the indicate there is
# a risk of now-disabled build products in the output directory
if (EXISTS "${CMAKE_BUNDLE_INSTALL_PREFIX}" AND STALE_INSTALL_WARN)
file(GLOB OFILES_BIN LIST_DIRECTORIES TRUE ${CMAKE_BUNDLE_INSTALL_PREFIX}/bin/* )
file(GLOB OFILES_LIB LIST_DIRECTORIES TRUE ${CMAKE_BUNDLE_INSTALL_PREFIX}/lib/* )
if (OFILES_BIN OR OFILES_LIB)
message(WARNING "\nBuild settings have changed, but build outputs are already present in ${CMAKE_BUNDLE_INSTALL_PREFIX}. Recommend clearing the directory to avoid unexpected files being present when using the build outputs to support compilation.\n")
endif (OFILES_BIN OR OFILES_LIB)
endif (EXISTS "${CMAKE_BUNDLE_INSTALL_PREFIX}" AND STALE_INSTALL_WARN)

# Close out dependencies DOT file
file(APPEND "${CMAKE_BINARY_DIR}/bext.dot" "\n}\n")

Expand Down

0 comments on commit 0b9a6bb

Please sign in to comment.