From 5288c2799a2866de45754ad8d9e8ad3dcc0b4756 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 14 Jan 2026 16:38:07 -0700 Subject: [PATCH 001/140] fixing cmake and externals --- .gitignore | 1 + Superbuild/BoostExternal.cmake | 138 ++++++++++------------------ Superbuild/CMakeLists.txt | 9 +- Superbuild/Cleaver2External.cmake | 1 + Superbuild/CtkExternal.cmake | 1 + Superbuild/FreetypeExternal.cmake | 1 + Superbuild/GLMExternal.cmake | 1 + Superbuild/GlewExternal.cmake | 1 + Superbuild/GoogleTestExternal.cmake | 1 + Superbuild/LibPNGExternal.cmake | 1 + Superbuild/LodePngExternal.cmake | 1 + Superbuild/OsprayExternal.cmake | 1 + Superbuild/PythonExternal.cmake | 2 +- Superbuild/QwtExternal.cmake | 79 ++++++++++++---- Superbuild/SQLiteExternal.cmake | 1 + Superbuild/SpdLogExternal.cmake | 1 + Superbuild/Superbuild.cmake | 82 ++++++++++++----- Superbuild/TeemExternal.cmake | 1 + Superbuild/TetgenExternal.cmake | 1 + Superbuild/TnyExternal.cmake | 1 + Superbuild/ZlibExternal.cmake | 1 + 21 files changed, 186 insertions(+), 140 deletions(-) diff --git a/.gitignore b/.gitignore index 3e4f3b1088..01bcefc082 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ cmake # Sphinx builds docs/_build/ +/build diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index c12f1b6fe1..10f39a9436 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -24,103 +24,65 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# Borrowed CMake code from the MaidSafe Boost CMake build -# found at https://github.com/maidsafe/MaidSafe/blob/master/cmake_modules/add_boost.cmake -# and code borrowed from ITK4 HDFMacros.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(_boost_git_url "https://github.com/CIBC-Internal/boost.git") +set(_boost_git_tag "v1.90.0") -# disable auto linking -# also set in Seg3D? -SET(boost_CXX_Flags "-DBOOST_ALL_NO_LIB=1") -IF(APPLE) - LIST(APPEND boost_CXX_Flag "-DBOOST_LCAST_NO_WCHAR_T" "-DBOOST_THREAD_DONT_USE_ATOMIC") -ENDIF() -IF(WIN32) - LIST(APPEND boost_CXX_Flag "-DBOOST_BIND_ENABLE_STDCALL") -ENDIF() - -SET( boost_DEPENDENCIES ) - -# explicitly set library list -SET(boost_Libraries - "atomic" - "chrono" - "date_time" - "exception" - "filesystem" - "program_options" - "regex" - "serialization" - "system" - "thread" - CACHE INTERNAL "Boost library name.") - -IF(BUILD_WITH_PYTHON) - ADD_DEFINITIONS(-DBOOST_PYTHON_STATIC_LIB=1) - LIST(APPEND boost_Libraries python) - LIST(APPEND boost_DEPENDENCIES Python_external) - LIST(APPEND boost_CXX_Flag "-DBOOST_PYTHON_STATIC_MODULE" "-DBOOST_PYTHON_STATIC_LIB") -ENDIF() - -# for travis clang builds--need a narrower test -IF(UNIX) - ADD_DEFINITIONS(-DBOOST_NO_CXX11_ALLOCATOR) -ENDIF() - -SET(boost_GIT_TAG "origin/v1.75.0") - -# TODO: set up 64-bit build detection -# Boost Jam needs to have 64-bit build explicitly configured -IF(WIN32) - SET(FORCE_64BIT_BUILD ON) -ENDIF() - - -SET(boost_GIT_URL "https://github.com/CIBC-Internal/boost.git") - -# TODO: fix install step -# -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Boost_external - DEPENDS ${boost_DEPENDENCIES} - GIT_REPOSITORY ${boost_GIT_URL} - GIT_TAG ${boost_GIT_TAG} - BUILD_IN_SOURCE ON - PATCH_COMMAND "" - INSTALL_COMMAND "" - CMAKE_CACHE_ARGS - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_PYTHON:BOOL=${BUILD_WITH_PYTHON} - -DPython_DIR:PATH=${Python_DIR} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DFORCE_64BIT_BUILD:BOOL=${FORCE_64BIT_BUILD} - -DSCI_BOOST_LIBRARIES:STATIC=${boost_Libraries} - -DSCI_BOOST_CXX_FLAGS:STRING=${boost_CXX_Flags} + GIT_REPOSITORY ${_boost_git_url} + GIT_TAG ${_boost_git_tag} + GIT_SHALLOW FALSE + GIT_PROGRESS TRUE + + # Ensure all modular libraries are present + UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir git submodule update --init --recursive + + # Build out of source (let ExternalProject choose dirs) + BUILD_IN_SOURCE OFF + + # Configure using Boost's official CMake support (tools/cmake in the repo) + CONFIGURE_COMMAND + ${CMAKE_COMMAND} + -S + -B + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DSCI_BOOST_CXX_FLAGS=${boost_CXX_Flags} + # Optional: build static by default + # -DBUILD_SHARED_LIBS=OFF + # Optional: enforce Boost.Python if your build requires it + # -DBoost_ENABLE_PYTHON=$ + + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config ${CMAKE_BUILD_TYPE} --parallel + + INSTALL_COMMAND + ${CMAKE_COMMAND} --build --target install --config ${CMAKE_BUILD_TYPE} ) ExternalProject_Get_Property(Boost_external INSTALL_DIR) ExternalProject_Get_Property(Boost_external SOURCE_DIR) -SET(SCI_BOOST_INCLUDE ${SOURCE_DIR}) -SET(SCI_BOOST_LIBRARY_DIR ${SOURCE_DIR}/lib) -SET(SCI_BOOST_USE_FILE ${INSTALL_DIR}/UseBoost.cmake) - -SET(BOOST_PREFIX "boost_") -SET(THREAD_POSTFIX "-mt") -SET(SCI_BOOST_LIBRARY) +# Export the *installed* paths (not the source tree) +set(SCI_BOOST_INCLUDE ${INSTALL_DIR}/include) +set(SCI_BOOST_LIBRARY_DIR ${INSTALL_DIR}/lib) +set(SCI_BOOST_USE_FILE ${INSTALL_DIR}/UseBoost.cmake) -FOREACH(lib ${boost_Libraries}) - SET(LIB_NAME "${BOOST_PREFIX}${lib}${THREAD_POSTFIX}") - LIST(APPEND SCI_BOOST_LIBRARY ${LIB_NAME}) -ENDFOREACH() +set(BOOST_PREFIX "boost_") +set(THREAD_POSTFIX "-mt") -# Boost is special case - normally this should be handled in external library repo -CONFIGURE_FILE(${SUPERBUILD_DIR}/BoostConfig.cmake.in ${INSTALL_DIR}/BoostConfig.cmake @ONLY) -CONFIGURE_FILE(${SUPERBUILD_DIR}/UseBoost.cmake ${SCI_BOOST_USE_FILE} COPYONLY) +set(SCI_BOOST_LIBRARY) +foreach(lib ${boost_Libraries}) + set(LIB_NAME "${BOOST_PREFIX}${lib}${THREAD_POSTFIX}") + list(APPEND SCI_BOOST_LIBRARY ${LIB_NAME}) +endforeach() -SET(Boost_DIR ${INSTALL_DIR} CACHE PATH "") +# If you still need your custom config/use files for SCIRun, keep these lines; +# otherwise consider relying on Boost's installed BoostConfig.cmake. +configure_file(${SUPERBUILD_DIR}/BoostConfig.cmake.in ${INSTALL_DIR}/BoostConfig.cmake @ONLY) +configure_file(${SUPERBUILD_DIR}/UseBoost.cmake ${SCI_BOOST_USE_FILE} COPYONLY) -MESSAGE(STATUS "Boost_DIR: ${Boost_DIR}") +set(Boost_DIR ${INSTALL_DIR} CACHE PATH "") +message(STATUS "Boost_DIR: ${Boost_DIR}") diff --git a/Superbuild/CMakeLists.txt b/Superbuild/CMakeLists.txt index 5940022ca0..d4902667c3 100644 --- a/Superbuild/CMakeLists.txt +++ b/Superbuild/CMakeLists.txt @@ -24,14 +24,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR) - -IF(POLICY CMP0043) - CMAKE_POLICY(SET CMP0043 OLD) -ENDIF() -IF(POLICY CMP0054) - CMAKE_POLICY(SET CMP0054 NEW) -ENDIF() +CMAKE_MINIMUM_REQUIRED(VERSION 3.20) PROJECT(Superbuild) diff --git a/Superbuild/Cleaver2External.cmake b/Superbuild/Cleaver2External.cmake index b4e60e50b6..42235bc229 100644 --- a/Superbuild/Cleaver2External.cmake +++ b/Superbuild/Cleaver2External.cmake @@ -36,6 +36,7 @@ ExternalProject_Add(Cleaver2_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/CtkExternal.cmake b/Superbuild/CtkExternal.cmake index 3aff0deb8e..cb00fd3157 100644 --- a/Superbuild/CtkExternal.cmake +++ b/Superbuild/CtkExternal.cmake @@ -27,6 +27,7 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(CTK_CACHE_ARGS + "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 9b930646ef..1d680aae38 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -36,6 +36,7 @@ ExternalProject_Add(Freetype_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/GLMExternal.cmake b/Superbuild/GLMExternal.cmake index 968bf3796f..42ec0b3052 100644 --- a/Superbuild/GLMExternal.cmake +++ b/Superbuild/GLMExternal.cmake @@ -35,6 +35,7 @@ ExternalProject_Add(GLM_external BUILD_COMMAND "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DGLM_FORCE_CXX03:BOOL=ON -DGLM_FORCE_RADIANS:BOOL=ON diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index eb65c73566..ce905896d9 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -41,6 +41,7 @@ ExternalProject_Add(Glew_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/GoogleTestExternal.cmake b/Superbuild/GoogleTestExternal.cmake index 16af038d8b..318ea69f64 100644 --- a/Superbuild/GoogleTestExternal.cmake +++ b/Superbuild/GoogleTestExternal.cmake @@ -27,6 +27,7 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(GTEST_CACHE_ARGS + "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" diff --git a/Superbuild/LibPNGExternal.cmake b/Superbuild/LibPNGExternal.cmake index 809facc65a..443441be89 100644 --- a/Superbuild/LibPNGExternal.cmake +++ b/Superbuild/LibPNGExternal.cmake @@ -38,6 +38,7 @@ ExternalProject_Add(LibPNG_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/LodePngExternal.cmake b/Superbuild/LodePngExternal.cmake index 1bb401ed2d..028c3170c9 100644 --- a/Superbuild/LodePngExternal.cmake +++ b/Superbuild/LodePngExternal.cmake @@ -33,6 +33,7 @@ ExternalProject_Add(LodePng_external GIT_TAG "origin/master" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 5d02acf248..48ff0e3dba 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -40,6 +40,7 @@ ExternalProject_Add(Ospray_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/PythonExternal.cmake b/Superbuild/PythonExternal.cmake index 8489b7f2d7..0834677f61 100644 --- a/Superbuild/PythonExternal.cmake +++ b/Superbuild/PythonExternal.cmake @@ -28,7 +28,7 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(DEFAULT_PYTHON_VERSION "3.9.10") +SET(DEFAULT_PYTHON_VERSION "3.13.1") set(USER_PYTHON_VERSION ${DEFAULT_PYTHON_VERSION} CACHE STRING "Branch name corresponding to Python version number") set_property(CACHE USER_PYTHON_VERSION PROPERTY STRINGS 3.6.7 3.7.9 3.8.12 3.9.10 3.10.2) diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index 4f07d5a9c7..f771dddcc2 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -24,31 +24,73 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(QWT_CACHE_ARGS +# Assume you already define these at the top-level (as in our previous message): +# set(SCIRUN_QT_MAJOR "6" CACHE STRING "Qt major version to use (5 or 6)") +# set_property(CACHE SCIRUN_QT_MAJOR PROPERTY STRINGS 5 6) +# set(Qt_PATH "" CACHE PATH "Qt install prefix, e.g. C:/Qt/6.3.1/msvc2019_64") + +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + +# Common cache args for the ExternalProject +set(QWT_CACHE_ARGS + "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" - ) - -LIST(APPEND QWT_CACHE_ARGS - "-DQt_PATH:PATH=${Qt_PATH}" - "-DQt5_PATH:PATH=${Qt_PATH}" - "-DQt${QT_VERSION_MAJOR}Core_DIR:PATH=${Qt${QT_VERSION_MAJOR}Core_DIR}" - "-DQt${QT_VERSION_MAJOR}CoreTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}CoreTools_DIR}" - "-DQt${QT_VERSION_MAJOR}Gui_DIR:PATH=${Qt${QT_VERSION_MAJOR}Gui_DIR}" - "-DQt${QT_VERSION_MAJOR}GuiTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}GuiTools_DIR}" ) -if (${QT_VERSION_MAJOR} STREQUAL "5") - SET(qwt_GIT_TAG "origin/qt5-static-6.1.5") +# Sanity check Qt_PATH once, fail early if not set correctly +if (NOT IS_DIRECTORY "${Qt_PATH}") + message(FATAL_ERROR "Qt_PATH is invalid or not set: ${Qt_PATH}") +endif() + +# Help the sub-build find Qt by giving it the correct prefix path. +# On Windows Qt installs, ${Qt_PATH} contains bin/, lib/, plugins/, and cmake/Qt6 (or Qt5). +list(APPEND QWT_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${Qt_PATH}") + +# Pass version-specific hints. Keep them minimal and valid for the chosen major version. +if (SCIRUN_QT_MAJOR STREQUAL "6") + # Primary hint for Qt6 + list(APPEND QWT_CACHE_ARGS "-DQt6_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") + + # OPTIONAL: if Qwt’s CMake looks for module-specific config packages, you can add these: + # (Only if actually needed by their CMake; otherwise leave them out to avoid over-constraining.) + # list(APPEND QWT_CACHE_ARGS "-DQt6Core_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") + # list(APPEND QWT_CACHE_ARGS "-DQt6Gui_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") + # list(APPEND QWT_CACHE_ARGS "-DQt6Widgets_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") + + # Choose a Qt6 branch/tag for Qwt + set(qwt_GIT_TAG "origin/qt6-static-6.2.0") +elseif (SCIRUN_QT_MAJOR STREQUAL "5") + # Primary hint for Qt5 + list(APPEND QWT_CACHE_ARGS "-DQt5_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5") + + # OPTIONAL: same note as above—only pass if Qwt expects these variables. + # list(APPEND QWT_CACHE_ARGS "-DQt5Core_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5Core") + # list(APPEND QWT_CACHE_ARGS "-DQt5Gui_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5Gui") + # list(APPEND QWT_CACHE_ARGS "-DQt5Widgets_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5Widgets") + + set(qwt_GIT_TAG "origin/qt5-static-6.1.5") else() - SET(qwt_GIT_TAG "origin/qt6-static-6.2.0") + message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Current value: ${SCIRUN_QT_MAJOR}") endif() -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). +# If Qwt’s subbuild needs to know which major to target (some CMakeLists choose behavior by this), +# pass a simple cache variable it can use. +list(APPEND QWT_CACHE_ARGS "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}") + +# Remove legacy/fragile arguments that caused trouble: +# -DQt_PATH +# -DQt5_PATH +# -DQt${QT_VERSION_MAJOR}Core_DIR +# -DQt${QT_VERSION_MAJOR}CoreTools_DIR +# -DQt${QT_VERSION_MAJOR}Gui_DIR +# -DQt${QT_VERSION_MAJOR}GuiTools_DIR +# +# These often become empty or point to non-existent packages (e.g., *Tools on Qt6), +# which derails the subbuild's find_package() calls. + ExternalProject_Add(Qwt_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt.git" GIT_TAG ${qwt_GIT_TAG} @@ -59,6 +101,5 @@ ExternalProject_Add(Qwt_external ) ExternalProject_Get_Property(Qwt_external BINARY_DIR) -SET(QWT_DIR ${BINARY_DIR} CACHE PATH "") - -MESSAGE(STATUS "QWT_DIR: ${QWT_DIR}") +set(QWT_DIR ${BINARY_DIR} CACHE PATH "") +message(STATUS "QWT_DIR: ${QWT_DIR}") diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index f30ff6c65f..a4a3943d44 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -36,6 +36,7 @@ ExternalProject_Add(SQLite_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/SpdLogExternal.cmake b/Superbuild/SpdLogExternal.cmake index 5f55b302c8..50b16fff19 100644 --- a/Superbuild/SpdLogExternal.cmake +++ b/Superbuild/SpdLogExternal.cmake @@ -35,6 +35,7 @@ ExternalProject_Add(SpdLog_external BUILD_COMMAND "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} ) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 70d78bd55f..ac8130b9b8 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -92,39 +92,73 @@ ENDIF() # Configure headless build OPTION(BUILD_HEADLESS "Build SCIRun without GUI." OFF) + ########################################### # Configure Qt +########################################### -SET(DEFAULT_QT_MIN_VERSION "5.15.2") +# Allow user to choose whether to use Qt5 or Qt6 +set(SCIRUN_QT_MAJOR "6" CACHE STRING "Qt major version to use (5 or 6)") +set_property(CACHE SCIRUN_QT_MAJOR PROPERTY STRINGS 5 6) -set(SCIRUN_QT_MIN_VERSION ${DEFAULT_QT_MIN_VERSION} CACHE STRING "Qt version") -set_property(CACHE SCIRUN_QT_MIN_VERSION PROPERTY STRINGS 5.12.8 5.15.2 6.3.1) -string(REPLACE "." ";" SCIRUN_QT_MIN_VERSION_LIST ${SCIRUN_QT_MIN_VERSION}) -list(GET SCIRUN_QT_MIN_VERSION_LIST 0 QT_VERSION_MAJOR) -list(GET SCIRUN_QT_MIN_VERSION_LIST 1 QT_VERSION_MINOR) -list(GET SCIRUN_QT_MIN_VERSION_LIST 2 QT_VERSION_PATCH) +# Minimum versions +set(QT5_MIN_VERSION "5.15.2") +set(QT6_MIN_VERSION "6.3.0") -IF(NOT BUILD_HEADLESS) +# User provides Qt base path +set(Qt_PATH "" CACHE PATH "Path to Qt installation (e.g. C:/Qt/6.7.1/msvc2022_64)") - SET(Qt_PATH "" CACHE PATH "Path to directory where Qt is installed. Directory should contain lib and bin subdirectories.") +if (NOT BUILD_HEADLESS) + + if (NOT IS_DIRECTORY "${Qt_PATH}") + message(FATAL_ERROR "Qt_PATH is invalid. Point it to the Qt install prefix that contains the lib/, bin/, and cmake/ directories.") + endif() + + # Qt expects the directory containing Qt6Config.cmake or Qt5Config.cmake + if (SCIRUN_QT_MAJOR STREQUAL "6") + set(QT_MIN_VERSION ${QT6_MIN_VERSION}) + list(APPEND CMAKE_PREFIX_PATH "${Qt_PATH}") + + find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS + Core + Gui + Widgets + Network + Concurrent + PrintSupport + Svg + OpenGL + OpenGLWidgets + REQUIRED + ) + + message(STATUS "Using Qt6 found at: ${Qt6_DIR}") + + elseif (SCIRUN_QT_MAJOR STREQUAL "5") + set(QT_MIN_VERSION ${QT5_MIN_VERSION}) + list(APPEND CMAKE_PREFIX_PATH "${Qt_PATH}") + + find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS + Core + Gui + Widgets + Network + Concurrent + PrintSupport + Svg + OpenGL + REQUIRED + ) + + message(STATUS "Using Qt5 found at: ${Qt5_DIR}") - IF(IS_DIRECTORY ${Qt_PATH}) - if (${QT_VERSION_MAJOR} STREQUAL "6") - FIND_PACKAGE(Qt${QT_VERSION_MAJOR} ${SCIRUN_QT_MIN_VERSION} COMPONENTS DBus DBusTools Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg CoreTools GuiTools WidgetsTools OpenGLWidgets REQUIRED HINTS ${Qt_PATH}) else() - FIND_PACKAGE(Qt${QT_VERSION_MAJOR} ${SCIRUN_QT_MIN_VERSION} COMPONENTS Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg REQUIRED HINTS ${Qt_PATH}) + message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'.") endif() - ELSE() - MESSAGE(SEND_ERROR "Set Qt_PATH to directory where Qt is installed (containing lib and bin subdirectories) or set BUILD_HEADLESS to ON.") - ENDIF() - - IF(APPLE) - SET(MACDEPLOYQT_OUTPUT_LEVEL 0 CACHE STRING "Set macdeployqt output level (0-3)") - MARK_AS_ADVANCED(MACDEPLOYQT_OUTPUT_LEVEL) - ENDIF() -ELSE() - ADD_DEFINITIONS(-DBUILD_HEADLESS) -ENDIF() + +else() + add_definitions(-DBUILD_HEADLESS) +endif() ########################################### diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index ea3c227fdc..fed9a7a12a 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -38,6 +38,7 @@ ExternalProject_Add(Teem_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/TetgenExternal.cmake b/Superbuild/TetgenExternal.cmake index 3d704281a2..f92baaa187 100644 --- a/Superbuild/TetgenExternal.cmake +++ b/Superbuild/TetgenExternal.cmake @@ -30,6 +30,7 @@ ExternalProject_Add(Tetgen_external PATCH_COMMAND "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index 82e4b40ba0..f68f510c7f 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -33,6 +33,7 @@ ExternalProject_Add(Tny_external GIT_TAG "origin/master" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index 4521900532..f665f2b379 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -36,6 +36,7 @@ ExternalProject_Add(Zlib_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON From d808f56fbe94b4d420e71137932d15c5fd74850c Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 15 Jan 2026 14:58:20 -0700 Subject: [PATCH 002/140] boost builds on windows with vs 2022 --- Superbuild/BoostExternal.cmake | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 10f39a9436..7d1b24e33e 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -28,19 +28,17 @@ set(_boost_git_url "https://github.com/CIBC-Internal/boost.git") set(_boost_git_tag "v1.90.0") + ExternalProject_Add(Boost_external GIT_REPOSITORY ${_boost_git_url} GIT_TAG ${_boost_git_tag} GIT_SHALLOW FALSE GIT_PROGRESS TRUE - # Ensure all modular libraries are present UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir git submodule update --init --recursive - # Build out of source (let ExternalProject choose dirs) BUILD_IN_SOURCE OFF - # Configure using Boost's official CMake support (tools/cmake in the repo) CONFIGURE_COMMAND ${CMAKE_COMMAND} -S @@ -50,16 +48,15 @@ ExternalProject_Add(Boost_external -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DSCI_BOOST_CXX_FLAGS=${boost_CXX_Flags} - # Optional: build static by default - # -DBUILD_SHARED_LIBS=OFF - # Optional: enforce Boost.Python if your build requires it - # -DBoost_ENABLE_PYTHON=$ - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config ${CMAKE_BUILD_TYPE} --parallel - INSTALL_COMMAND - ${CMAKE_COMMAND} --build --target install --config ${CMAKE_BUILD_TYPE} + +BUILD_COMMAND + ${CMAKE_COMMAND} --build --config ${CMAKE_CFG_INTDIR} + +INSTALL_COMMAND + ${CMAKE_COMMAND} --build --target install --config ${CMAKE_CFG_INTDIR} + ) ExternalProject_Get_Property(Boost_external INSTALL_DIR) From b9358db3c57481fdc0c0adaa5b6d84971af66460 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 15 Jan 2026 16:41:52 -0700 Subject: [PATCH 003/140] fixing qt errors --- Superbuild/Superbuild.cmake | 6 ++++-- src/CMakeLists.txt | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index ac8130b9b8..7cb183fab5 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -270,14 +270,16 @@ SET(SCIRUN_CACHE_ARGS "-DBoost_DIR:PATH=${Boost_DIR}" "-DTeem_DIR:PATH=${Teem_DIR}" "-DFreetype_DIR:PATH=${Freetype_DIR}" - "-DGLM_DIR:PATH=${GLM_DIR}" + "-DGLM_DIR:PATH=${GLM_DIR}" "-DSPDLOG_DIR:PATH=${SPDLOG_DIR}" "-DTNY_DIR:PATH=${TNY_DIR}" - "-DGLEW_DIR:PATH=${Glew_DIR}" + "-DGLEW_DIR:PATH=${Glew_DIR}" "-DLODEPNG_DIR:PATH=${LODEPNG_DIR}" "-DCLEAVER2_DIR:PATH=${CLEAVER2_DIR}" "-DSCI_DATA_DIR:PATH=${SCI_DATA_DIR}" "-DGENERATE_COMPILATION_DATABASE:BOOL=${GENERATE_COMPILATION_DATABASE}" + "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}" + "-DQt_PATH:PATH=${Qt_PATH}" ) IF(BUILD_WITH_PYTHON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4af66aa1ec..ddcb209ddb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -410,10 +410,19 @@ FIND_PACKAGE(OpenGL REQUIRED) # Find and configure Qt IF(NOT BUILD_HEADLESS) - if (${QT_VERSION_MAJOR} STREQUAL "6") - FIND_PACKAGE(Qt${QT_VERSION_MAJOR} COMPONENTS DBus DBusTools Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg CoreTools GuiTools WidgetsTools OpenGLWidgets REQUIRED HINTS ${Qt_PATH}) + + if (SCIRUN_QT_MAJOR STREQUAL "6") + find_package(Qt6 REQUIRED COMPONENTS + DBus Core Gui Widgets Network OpenGL Concurrent + PrintSupport Svg OpenGLWidgets + HINTS ${Qt_PATH}) + elseif (SCIRUN_QT_MAJOR STREQUAL "5") + find_package(Qt5 REQUIRED COMPONENTS + Core Gui Widgets Network OpenGL Concurrent + PrintSupport Svg + HINTS ${Qt_PATH}) else() - FIND_PACKAGE(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg REQUIRED HINTS ${Qt_PATH}) + message(FATAL_ERROR "Unsupported Qt major version: ${SCIRUN_QT_MAJOR}") endif() IF(Qt${QT_VERSION_MAJOR}Core_FOUND) From 8ef9b25a4f5291a36c4ee4733601a7c44a26558e Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 20 Jan 2026 17:10:51 -0700 Subject: [PATCH 004/140] fixing boost include dir --- Superbuild/Superbuild.cmake | 6 +++ src/CMakeLists.txt | 71 +++++++++++----------------- src/Externals/libxml2/CMakeLists.txt | 16 +------ src/Externals/pugixml/CMakeLists.txt | 2 +- 4 files changed, 36 insertions(+), 59 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 7cb183fab5..6a2e421554 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -236,6 +236,10 @@ ENDIF() ADD_EXTERNAL( ${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external ) +ExternalProject_Get_Property(Boost_external INSTALL_DIR) +set(SCI_BOOST_INCLUDE ${INSTALL_DIR}/include) +set(SCI_BOOST_LIBRARY_DIR ${INSTALL_DIR}/lib) + ########################################### # Download external data sources OPTION(DOWNLOAD_TOOLKITS "Download toolkit repositories." ON) @@ -268,6 +272,8 @@ SET(SCIRUN_CACHE_ARGS "-DZlib_DIR:PATH=${Zlib_DIR}" "-DSQLite_DIR:PATH=${SQLite_DIR}" "-DBoost_DIR:PATH=${Boost_DIR}" + "-DSCI_BOOST_INCLUDE:PATH=${SCI_BOOST_INCLUDE}" + "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" "-DTeem_DIR:PATH=${Teem_DIR}" "-DFreetype_DIR:PATH=${Freetype_DIR}" "-DGLM_DIR:PATH=${GLM_DIR}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ddcb209ddb..61536fbd79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -409,6 +409,7 @@ FIND_PACKAGE(OpenGL REQUIRED) ######################################################################## # Find and configure Qt + IF(NOT BUILD_HEADLESS) if (SCIRUN_QT_MAJOR STREQUAL "6") @@ -425,61 +426,45 @@ IF(NOT BUILD_HEADLESS) message(FATAL_ERROR "Unsupported Qt major version: ${SCIRUN_QT_MAJOR}") endif() - IF(Qt${QT_VERSION_MAJOR}Core_FOUND) - MESSAGE(STATUS "Found Qt version: ${Qt${QT_VERSION_MAJOR}Core_VERSION_STRING}") - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Network_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}OpenGL_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Concurrent_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}PrintSupport_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Svg_INCLUDE_DIRS}) - INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}DBus_INCLUDE_DIRS}) - ELSE() - MESSAGE(FATAL_ERROR "Qt is required for building the SCIRun GUI") - ENDIF() - - IF(Qt${QT_VERSION_MAJOR}Core_FOUND) - INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) - ADD_DEFINITIONS(${QT_DEFINITIONS}) - ELSE() - MESSAGE(FATAL_ERROR "Qt 5.13 or greater is required to build SCIRun") - ENDIF() + if (Qt6_FOUND OR Qt5_FOUND) + message(STATUS "Found Qt version: ${Qt${QT_VERSION_MAJOR}_VERSION}") + else() + message(FATAL_ERROR "Qt is required for building the SCIRun GUI") + endif() - ADD_DEFINITIONS(-DQT_NO_KEYWORDS) + add_definitions(-DQT_NO_KEYWORDS) - if (${QT_VERSION_MAJOR} STREQUAL "6") - ADD_DEFINITIONS(-DSCIRUN_QT6_ENABLED) + if (QT_VERSION_MAJOR EQUAL 6) + add_definitions(-DSCIRUN_QT6_ENABLED) endif() - if (${QT_VERSION_MAJOR} STREQUAL "5") - MACRO(QT_WRAP_UI arg1 arg2) - QT5_WRAP_UI(${arg1} ${arg2}) - ENDMACRO(QT_WRAP_UI) + if (QT_VERSION_MAJOR EQUAL 5) + macro(QT_WRAP_UI arg1 arg2) + qt5_wrap_ui(${arg1} ${arg2}) + endmacro() - MACRO(QT_WRAP_CPP arg1 arg2) - QT5_WRAP_CPP(${arg1} ${arg2}) - ENDMACRO(QT_WRAP_CPP) + macro(QT_WRAP_CPP arg1 arg2) + qt5_wrap_cpp(${arg1} ${arg2}) + endmacro() - MACRO(QT_ADD_RESOURCES arg1 arg2) - QT5_ADD_RESOURCES(${arg1} ${arg2}) - ENDMACRO(QT_ADD_RESOURCES) + macro(QT_ADD_RESOURCES arg1 arg2) + qt5_add_resources(${arg1} ${arg2}) + endmacro() - SET(QT_GRAPHICS_LIBRARIES Qt5::OpenGL) - SET(QT_NETWORK_LIBRARIES Qt5::Network) - SET(QT_LIBRARIES Qt5::Widgets) + set(QT_GRAPHICS_LIBRARIES Qt5::OpenGL) + set(QT_NETWORK_LIBRARIES Qt5::Network) + set(QT_LIBRARIES Qt5::Widgets) else() - SET(QT_GRAPHICS_LIBRARIES Qt::OpenGL Qt::OpenGLWidgets) - SET(QT_NETWORK_LIBRARIES Qt::Network) - SET(QT_LIBRARIES Qt::Widgets) + set(QT_GRAPHICS_LIBRARIES Qt::OpenGL Qt::OpenGLWidgets) + set(QT_NETWORK_LIBRARIES Qt::Network) + set(QT_LIBRARIES Qt::Widgets) endif() ENDIF() -IF(Qt${QT_VERSION_MAJOR}Widgets_VERSION VERSION_LESS 5.13.0) - ADD_DEFINITIONS(-DOLDER_QT_SUPPORT_NEEDED) -ENDIF() +if (QT_VERSION_MAJOR EQUAL 5 AND Qt5Widgets_VERSION VERSION_LESS 5.13.0) + add_definitions(-DOLDER_QT_SUPPORT_NEEDED) +endif() ######################################################################## # Find and configure dl library diff --git a/src/Externals/libxml2/CMakeLists.txt b/src/Externals/libxml2/CMakeLists.txt index ec695fd4b9..bf5776c459 100644 --- a/src/Externals/libxml2/CMakeLists.txt +++ b/src/Externals/libxml2/CMakeLists.txt @@ -25,21 +25,7 @@ # CMake build scripts provided by Scientific Computing and Imaging Institute # Copyright (c) 2009 Scientific Computing and Imaging Institute, University of Utah. -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(VERSION 2.6) - - IF(POLICY CMP0042) - # TODO: when support for versions older than 2.8.12 is dropped, - # enable new policy and get rid of version check - # - # see https://cmake.org/cmake/help/v3.0/policy/CMP0042.html - CMAKE_POLICY(SET CMP0042 OLD) - ENDIF() - IF(POLICY CMP0043) - CMAKE_POLICY(SET CMP0043 OLD) - ENDIF() -ENDIF() +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(libxml2) diff --git a/src/Externals/pugixml/CMakeLists.txt b/src/Externals/pugixml/CMakeLists.txt index 96ef532bda..0ece49fc00 100644 --- a/src/Externals/pugixml/CMakeLists.txt +++ b/src/Externals/pugixml/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.5) project(pugixml VERSION 1.12 LANGUAGES CXX) include(CMakePackageConfigHelpers) From e9dcbbda26969797b3e35da6fa8094ab22c06672 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 22 Jan 2026 15:40:41 -0700 Subject: [PATCH 005/140] cleaned boost issues --- Superbuild/BoostExternal.cmake | 172 +++++++++++++++++++++++++++------ Superbuild/Superbuild.cmake | 22 ++++- src/CMakeLists.txt | 129 +++++++++++++++++++++++-- 3 files changed, 281 insertions(+), 42 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 7d1b24e33e..5a95778f97 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -24,11 +24,67 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - +# --- Inputs --- set(_boost_git_url "https://github.com/CIBC-Internal/boost.git") set(_boost_git_tag "v1.90.0") +include(ExternalProject) + +# ========= Library selection strategy ========= +# Boost CMake superproject builds compiled libs only when listed in BOOST_INCLUDE_LIBRARIES. +# Header-only libs (e.g., signals2, asio, any, optional, variant, etc.) need no listing. + +# A maximal "safe" set that builds everywhere without extra deps: +set(_BOOST_LIBS_SAFE + atomic + chrono + container + context + coroutine + date_time + exception + filesystem + fiber + graph + iostreams + locale + log + math + nowide + program_options + random + regex + serialization + stacktrace + system + thread + timer + type_erasure + wave +) +# Optional libraries that require external dependencies: +option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" OFF) +option(BOOST_ENABLE_MPI "Build Boost.MPI if MPI is available" OFF) +option(BOOST_ENABLE_TEST "Build Boost.Test (unit test framework)" OFF) + +set(_BOOST_LIBS_OPTIONAL "") +if(BOOST_ENABLE_PYTHON) + list(APPEND _BOOST_LIBS_OPTIONAL python) +endif() +if(BOOST_ENABLE_MPI) + list(APPEND _BOOST_LIBS_OPTIONAL mpi) + # graph_parallel depends on MPI as well; include when MPI is on: + list(APPEND _BOOST_LIBS_OPTIONAL graph_parallel) +endif() +if(BOOST_ENABLE_TEST) + list(APPEND _BOOST_LIBS_OPTIONAL test) +endif() + +# Final list passed to the superproject: +set(_BOOST_LIBS ${_BOOST_LIBS_SAFE} ${_BOOST_LIBS_OPTIONAL}) + +# ========= ExternalProject definition ========= ExternalProject_Add(Boost_external GIT_REPOSITORY ${_boost_git_url} GIT_TAG ${_boost_git_tag} @@ -39,47 +95,103 @@ ExternalProject_Add(Boost_external BUILD_IN_SOURCE OFF + # Configure Boost with CMake Superproject CONFIGURE_COMMAND ${CMAKE_COMMAND} -S -B -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_BUILD_TYPE=$,${CMAKE_BUILD_TYPE},$> # support single & multi-config -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DSCI_BOOST_CXX_FLAGS=${boost_CXX_Flags} - - - -BUILD_COMMAND + -DBUILD_TESTING=OFF + # Install headers + requested libs; header-only libs are always usable + -DBOOST_INSTALL_HEADERS=ON + # IMPORTANT: pass the list as a single argument + -DBOOST_INCLUDE_LIBRARIES:STRING=${_BOOST_LIBS} + # Propagate toolchain/flags if you define them in the parent + -DCMAKE_CXX_FLAGS=${boost_CXX_Flags} + + # Build / Install (multi-config generators honor ${CMAKE_CFG_INTDIR}) + BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${CMAKE_CFG_INTDIR} -INSTALL_COMMAND + INSTALL_COMMAND ${CMAKE_COMMAND} --build --target install --config ${CMAKE_CFG_INTDIR} - ) +# ========= Export properties to the superbuild ========= ExternalProject_Get_Property(Boost_external INSTALL_DIR) ExternalProject_Get_Property(Boost_external SOURCE_DIR) -# Export the *installed* paths (not the source tree) -set(SCI_BOOST_INCLUDE ${INSTALL_DIR}/include) -set(SCI_BOOST_LIBRARY_DIR ${INSTALL_DIR}/lib) -set(SCI_BOOST_USE_FILE ${INSTALL_DIR}/UseBoost.cmake) - -set(BOOST_PREFIX "boost_") -set(THREAD_POSTFIX "-mt") - -set(SCI_BOOST_LIBRARY) -foreach(lib ${boost_Libraries}) - set(LIB_NAME "${BOOST_PREFIX}${lib}${THREAD_POSTFIX}") - list(APPEND SCI_BOOST_LIBRARY ${LIB_NAME}) -endforeach() - -# If you still need your custom config/use files for SCIRun, keep these lines; -# otherwise consider relying on Boost's installed BoostConfig.cmake. -configure_file(${SUPERBUILD_DIR}/BoostConfig.cmake.in ${INSTALL_DIR}/BoostConfig.cmake @ONLY) -configure_file(${SUPERBUILD_DIR}/UseBoost.cmake ${SCI_BOOST_USE_FILE} COPYONLY) - -set(Boost_DIR ${INSTALL_DIR} CACHE PATH "") -message(STATUS "Boost_DIR: ${Boost_DIR}") +# Convenience prefix +set(SCI_BOOST_PREFIX "${INSTALL_DIR}") + +# Help both Config and Module (FindBoost) modes in downstream projects: +# - Boost_ROOT + CMAKE_PREFIX_PATH: lets find_package(Boost CONFIG) discover Boost- automatically. +# - We'll still compute Boost_DIR explicitly for consumers that cache/use it directly. +set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix" FORCE) + +# Make sure the prefix is searched (prefer prepending so our Boost wins over system) +if(NOT DEFINED CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH "") +endif() +list(PREPEND CMAKE_PREFIX_PATH "${SCI_BOOST_PREFIX}") +# Re-cache the modified prefix path for dependents in the same configure +set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE PATH "Prefix search path" FORCE) + +# Compute Boost_DIR robustly (handles versioned 'Boost-' and rare unversioned 'Boost/') +set(_boost_cmake_root "${SCI_BOOST_PREFIX}/lib/cmake") +set(_boost_dir_guess "") + +if(EXISTS "${_boost_cmake_root}") + # Prefer versioned directories (Boost-1.90.0, Boost-1.91.0, ...) + file(GLOB _boost_cfg_candidates "${_boost_cmake_root}/Boost-*") + foreach(_cand IN LISTS _boost_cfg_candidates) + if(EXISTS "${_cand}/BoostConfig.cmake") + set(_boost_dir_guess "${_cand}") + break() + endif() + endforeach() + + # Fallback: some older packs use unversioned 'Boost/' + if(NOT _boost_dir_guess AND EXISTS "${_boost_cmake_root}/Boost/BoostConfig.cmake") + set(_boost_dir_guess "${_boost_cmake_root}/Boost") + endif() +endif() + +# Expose Boost_DIR for consumers that look it up directly +# (It may not exist on the first configure until after install; that's okay.) +set(Boost_DIR "${_boost_dir_guess}" CACHE PATH "Boost package directory (for find_package Boost)" FORCE) + +# Fallback hints for Module mode (FindBoost.cmake) +set(SCI_BOOST_INCLUDE "${SCI_BOOST_PREFIX}/include" CACHE PATH "Boost include directory" FORCE) + +# Handle lib vs lib64 on Windows and some Linux distros +if (EXISTS "${SCI_BOOST_PREFIX}/lib64") + set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib64") +else() + set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib") +endif() +set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library directory" FORCE) + +# Optional: legacy use file (kept only if your build still includes it) +set(SUPERBUILD_DIR "${CMAKE_CURRENT_LIST_DIR}") +set(SCI_BOOST_USE_FILE "${SCI_BOOST_PREFIX}/UseBoost.cmake") +if (EXISTS "${SUPERBUILD_DIR}/UseBoost.cmake") + configure_file(${SUPERBUILD_DIR}/UseBoost.cmake ${SCI_BOOST_USE_FILE} COPYONLY) +endif() + +# Diagnostics (helpful during first passes) +message(STATUS "[Boost_ext] INSTALL_DIR: ${SCI_BOOST_PREFIX}") +message(STATUS "[Boost_ext] Boost_ROOT: ${Boost_ROOT}") +message(STATUS "[Boost_ext] Boost_DIR: ${Boost_DIR}") +message(STATUS "[Boost_ext] Include dir: ${SCI_BOOST_INCLUDE}") +message(STATUS "[Boost_ext] Lib dir: ${SCI_BOOST_LIBRARY_DIR}") +message(STATUS "[Boost_ext] BOOST_INCLUDE_LIBRARIES: ${_BOOST_LIBS}") + +if (EXISTS "${Boost_DIR}/BoostConfig.cmake") + message(STATUS "[Boost_ext] Found BoostConfig.cmake at: ${Boost_DIR}/BoostConfig.cmake") +else() + message(STATUS "[Boost_ext] (Will be created after Boost install) Expected under: ${_boost_cmake_root}") +endif() diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 6a2e421554..993606a9d2 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -237,8 +237,16 @@ ENDIF() ADD_EXTERNAL( ${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external ) ExternalProject_Get_Property(Boost_external INSTALL_DIR) -set(SCI_BOOST_INCLUDE ${INSTALL_DIR}/include) -set(SCI_BOOST_LIBRARY_DIR ${INSTALL_DIR}/lib) +set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") +set(SCI_BOOST_INCLUDE "${INSTALL_DIR}/include") +# Define the Boost install prefix for downstream use +set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix (produced by Boost_external)" FORCE) + +if (WIN32 AND EXISTS "${INSTALL_DIR}/lib64") + set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib64") +else() + set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib") +endif() ########################################### # Download external data sources @@ -271,9 +279,13 @@ SET(SCIRUN_CACHE_ARGS "-DEigen_DIR:PATH=${Eigen_DIR}" "-DZlib_DIR:PATH=${Zlib_DIR}" "-DSQLite_DIR:PATH=${SQLite_DIR}" - "-DBoost_DIR:PATH=${Boost_DIR}" - "-DSCI_BOOST_INCLUDE:PATH=${SCI_BOOST_INCLUDE}" - "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" + "-DBoost_DIR:PATH=${Boost_DIR}" # Try CONFIG package first + "-DBOOST_ROOT:PATH=${INSTALL_DIR}" # Fallback: FindBoost + "-DBoost_INCLUDE_DIR:PATH=${SCI_BOOST_INCLUDE}" + "-DBoost_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" + "-DBoost_NO_BOOST_CMAKE:BOOL=OFF" # Allow CONFIG if present + "-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}" + "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" # so the macro can use the prefix "-DTeem_DIR:PATH=${Teem_DIR}" "-DFreetype_DIR:PATH=${Freetype_DIR}" "-DGLM_DIR:PATH=${GLM_DIR}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61536fbd79..874f280433 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -201,12 +201,127 @@ endif() ######################################################################### # External projects -MACRO(CONFIG_STANDARD_EXTERNAL name config_file directory) - FIND_PACKAGE(${name} CONFIGS ${config_file} HINTS ${directory} NO_SYSTEM_ENVIRONMENT_PATH) - IF(NOT ${name}_FOUND) - MESSAGE(FATAL_ERROR "${name} library not found in ${directory}") - ENDIF() -ENDMACRO() + +# CONFIG_STANDARD_EXTERNAL(name config_file directory [REQUIRED]) +# +# - name: Package name (e.g., Boost) +# - config_file: Primary config file to look for (e.g., BoostConfig.cmake) +# - directory: Either the exact package cmake dir OR an install prefix. +# The macro will probe common subpaths and versioned dirs. +# - REQUIRED: Optional. If provided and not found, errors out. Otherwise warns. +# +# Behavior: +# - Respects pre-set ${name}_DIR and ${name}_ROOT if they point to a valid config. +# - If 'directory' points to a prefix, searches under lib/cmake/${name}-* and ${name}/. +# - If 'directory' points to an unversioned ${name}/, also probes siblings ${name}-*. +# - On success, FORCE-caches ${name}_DIR and calls find_package(${name} CONFIG). +# - On failure: +# - If REQUIRED: fatal error with detailed diagnostics. +# - Else: issues a status/warning and returns (for two-phase superbuilds). +# +macro(CONFIG_STANDARD_EXTERNAL name config_file directory) + set(_cse_REQUIRED OFF) + foreach(_arg IN LISTS ARGN) + if(_arg STREQUAL "REQUIRED") + set(_cse_REQUIRED ON) + endif() + endforeach() + + # 0) If caller already set ${name}_DIR and it contains the config, prefer it. + if(DEFINED ${name}_DIR AND EXISTS "${${name}_DIR}/${config_file}") + set(_cse_pkg_dir "${${name}_DIR}") + endif() + + # 1) If not set or invalid, consider ${name}_ROOT + if(NOT DEFINED _cse_pkg_dir AND DEFINED ${name}_ROOT) + # Common place for config under a prefix + set(_cse_try1 "${${name}_ROOT}/lib/cmake/${name}") + set(_cse_try2 "${${name}_ROOT}/lib/cmake/${name}-*") + if(EXISTS "${_cse_try1}/${config_file}") + set(_cse_pkg_dir "${_cse_try1}") + else() + file(GLOB _cse_glob2 "${_cse_try2}") + foreach(_cand IN LISTS _cse_glob2) + if(EXISTS "${_cand}/${config_file}") + set(_cse_pkg_dir "${_cand}") + break() + endif() + endforeach() + endif() + endif() + + # 2) If still not found, interpret 'directory' (may be exact dir or a prefix) + if(NOT DEFINED _cse_pkg_dir) + set(_cse_root "${directory}") + + # If 'directory' itself is a config dir + if(EXISTS "${_cse_root}/${config_file}") + set(_cse_pkg_dir "${_cse_root}") + else() + # If 'directory' looks like .../lib/cmake/${name}, also try versioned siblings + if(EXISTS "${_cse_root}" AND "${_cse_root}" MATCHES "/lib/cmake/${name}$") + file(GLOB _cse_glob3 "${_cse_root}-*") + foreach(_cand IN LISTS _cse_glob3) + if(EXISTS "${_cand}/${config_file}") + set(_cse_pkg_dir "${_cand}") + break() + endif() + endforeach() + endif() + + # Otherwise, treat as prefix and probe common subpaths + if(NOT DEFINED _cse_pkg_dir) + set(_cse_try3 "${_cse_root}/lib/cmake/${name}") + set(_cse_try4 "${_cse_root}/lib/cmake/${name}-*") + if(EXISTS "${_cse_try3}/${config_file}") + set(_cse_pkg_dir "${_cse_try3}") + else() + file(GLOB _cse_glob4 "${_cse_try4}") + foreach(_cand IN LISTS _cse_glob4) + if(EXISTS "${_cand}/${config_file}") + set(_cse_pkg_dir "${_cand}") + break() + endif() + endforeach() + endif() + endif() + endif() + endif() + + # 3) If found, cache it and run find_package in CONFIG mode + if(DEFINED _cse_pkg_dir) + set(${name}_DIR "${_cse_pkg_dir}" CACHE PATH "${name} package directory" FORCE) + + # Prefer config packages and allow hints/prefix path to participate + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + find_package(${name} CONFIG QUIET + HINTS "${${name}_DIR}" "${${name}_ROOT}" + ) + + if(${name}_FOUND) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${name} at ${${name}_DIR}") + return() + endif() + endif() + + # 4) Not found — decide whether to fail now + if(_cse_REQUIRED) + message(FATAL_ERROR + "[CONFIG_STANDARD_EXTERNAL] ${name} not found.\n" + " Tried:\n" + " - ${name}_DIR='${${name}_DIR}'\n" + " - ${name}_ROOT='${${name}_ROOT}'\n" + " - directory='${directory}' (searched versioned '${name}-*' under lib/cmake)\n" + " Hint: ensure the external is built/installed and re-run CMake.\n" + ) + else() + message(STATUS + "[CONFIG_STANDARD_EXTERNAL] ${name} not found yet. " + "This is expected before externals are built. " + "After building ${name}, re-run CMake." + ) + endif() +endmacro() CONFIG_STANDARD_EXTERNAL( Zlib ZlibConfig.cmake ${Zlib_DIR} ) INCLUDE(${ZLIB_USE_FILE}) @@ -228,7 +343,7 @@ IF(BUILD_WITH_PYTHON) INCLUDE(${SCI_PYTHON_USE_FILE}) ENDIF() -CONFIG_STANDARD_EXTERNAL( Boost BoostConfig.cmake ${Boost_DIR} ) +CONFIG_STANDARD_EXTERNAL( Boost BoostConfig.cmake ${SCI_BOOST_PREFIX} REQUIRED) INCLUDE(${SCI_BOOST_USE_FILE}) CONFIG_STANDARD_EXTERNAL( Tny TnyConfig.cmake ${TNY_DIR} ) From c3e0c041f1b584ebedcb4fc82d9a626c75a4c314 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 22 Jan 2026 16:39:40 -0700 Subject: [PATCH 006/140] fixing python new version --- Superbuild/PythonExternal.cmake | 93 ++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/Superbuild/PythonExternal.cmake b/Superbuild/PythonExternal.cmake index 0834677f61..6c50c3b469 100644 --- a/Superbuild/PythonExternal.cmake +++ b/Superbuild/PythonExternal.cmake @@ -102,24 +102,93 @@ IF(UNIX) WORKING_DIRECTORY ) ENDIF() + +# --- Windows path (MSVC) --- ELSE() + # 64-bit build only (keeps your original assumptions) + set(python_WIN32_ARCH "x64") + set(python_WIN32_64BIT_DIR "/amd64") + set(python_ABIFLAG_PYDEBUG "_d") + + # Helper script to resolve and copy pyconfig.h in a version-robust way + # We embed a small -P script rather than relying on shell tricks. + set(_copy_pyconfig_cmake "${CMAKE_CURRENT_BINARY_DIR}/CopyPyConfig.cmake") + file(WRITE "${_copy_pyconfig_cmake}" [=[ + # CopyPyConfig.cmake + # Inputs: + # _SRC : CPython source root + # _DST : Destination include directory (expects Include/) + # _PYEXE: Built python.exe to query sysconfig (optional if legacy fallback used) + + if(NOT DEFINED _SRC OR NOT DEFINED _DST) + message(FATAL_ERROR "CopyPyConfig.cmake: _SRC and _DST must be defined.") + endif() + + file(MAKE_DIRECTORY "${_DST}") + + # 1) Legacy fallback (works for older trees/tags if file exists) + if(EXISTS "${_SRC}/PC/pyconfig.h") + message(STATUS "[Python_external] Using legacy PC/pyconfig.h") + file(COPY "${_SRC}/PC/pyconfig.h" DESTINATION "${_DST}") + return() + endif() + + # 2) Preferred: ask the built interpreter where pyconfig.h is + if(NOT DEFINED _PYEXE OR NOT EXISTS "${_PYEXE}") + message(FATAL_ERROR + "CopyPyConfig.cmake: Built python.exe not found at '${_PYEXE}'.\n" + "Cannot query sysconfig.get_config_h_filename(); please check the build output under PCbuild.") + endif() + + execute_process( + COMMAND "${_PYEXE}" -c "import sysconfig, sys; print(sysconfig.get_config_h_filename())" + OUTPUT_VARIABLE _CFG + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + + if(NOT _CFG OR NOT EXISTS "${_CFG}") + message(FATAL_ERROR + "CopyPyConfig.cmake: sysconfig.get_config_h_filename() returned '${_CFG}', which does not exist.") + endif() + + message(STATUS "[Python_external] Copying pyconfig.h from: ${_CFG}") + file(COPY "${_CFG}" DESTINATION "${_DST}") + ]=]) + ExternalProject_Add(Python_external GIT_REPOSITORY ${python_GIT_URL} - GIT_TAG ${python_GIT_TAG} - PATCH_COMMAND "" - CONFIGURE_COMMAND PCbuild/build.bat + GIT_TAG ${python_GIT_TAG} + PATCH_COMMAND "" + # Pass platform to build.bat so it generates the right artifacts + CONFIGURE_COMMAND PCbuild/build.bat -p ${python_WIN32_ARCH} BUILD_IN_SOURCE ON - BUILD_COMMAND ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo /property:Configuration=Release /property:Platform=${python_WIN32_ARCH} - INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy_if_different - /PC/pyconfig.h - /Include/pyconfig.h + + # Build Release first (keeps your logic) + BUILD_COMMAND + ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo + /property:Configuration=Release + /property:Platform=${python_WIN32_ARCH} + + # INSTALL_COMMAND: robust pyconfig.h copy + # - Prefer sysconfig.get_config_h_filename() from the built interpreter + # - Fallback to legacy PC/pyconfig.h if present + INSTALL_COMMAND + "${CMAKE_COMMAND}" + -D_SRC= + -D_DST=/Include + -D_PYEXE=/PCbuild${python_WIN32_64BIT_DIR}/python.exe + -P "${_copy_pyconfig_cmake}" ) - # build both Release and Debug versions + + # Also build Debug (as you had), and ensure it happens before "install" ExternalProject_Add_Step(Python_external debug_build - COMMAND ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo /property:Configuration=Debug /property:Platform=${python_WIN32_ARCH} - DEPENDEES build - DEPENDERS install - WORKING_DIRECTORY + COMMAND ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo + /property:Configuration=Debug + /property:Platform=${python_WIN32_ARCH} + DEPENDEES build + DEPENDERS install + WORKING_DIRECTORY ) ENDIF() From 4d7ffbccf0d593b537e223b2e38a679a2eacb393 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 26 Jan 2026 14:25:16 -0700 Subject: [PATCH 007/140] udpated cmakes for externals --- Superbuild/Cleaver2External.cmake | 25 +++-- Superbuild/EigenExternal.cmake | 17 ++- Superbuild/FreetypeExternal.cmake | 24 ++-- Superbuild/GLMExternal.cmake | 29 +++-- Superbuild/GlewExternal.cmake | 29 +++-- Superbuild/LodePngExternal.cmake | 33 ++++-- Superbuild/OsprayExternal.cmake | 36 ++++-- Superbuild/QwtExternal.cmake | 61 ++++------ Superbuild/SQLiteExternal.cmake | 24 ++-- Superbuild/SpdLogExternal.cmake | 27 +++-- Superbuild/Superbuild.cmake | 180 ++++++++++++++++++++++-------- Superbuild/TeemExternal.cmake | 38 +++++-- Superbuild/TetgenExternal.cmake | 52 ++++++--- Superbuild/TnyExternal.cmake | 34 ++++-- Superbuild/ZlibExternal.cmake | 29 +++-- 15 files changed, 427 insertions(+), 211 deletions(-) diff --git a/Superbuild/Cleaver2External.cmake b/Superbuild/Cleaver2External.cmake index 42235bc229..60ba3f2b39 100644 --- a/Superbuild/Cleaver2External.cmake +++ b/Superbuild/Cleaver2External.cmake @@ -24,25 +24,34 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# Cleaver2External.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(cleaver2_GIT_TAG "origin/master") -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Cleaver2_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Cleaver2Library.git" GIT_TAG ${cleaver2_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE (they break installation) + # INSTALL_DIR "" + # INSTALL_COMMAND "" + + # Correct: install to a known prefix under Externals/Install CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -) + -DBUILD_SHARED_LIBS:BOOL=OFF + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Cleaver2_external -ExternalProject_Get_Property(Cleaver2_external BINARY_DIR) -SET(CLEAVER2_DIR ${BINARY_DIR} CACHE PATH "") + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "CLEAVER2_DIR: ${CLEAVER2_DIR}") +# For debugging: show where Cleaver2 will be installed +ExternalProject_Get_Property(Cleaver2_external INSTALL_DIR) +message(STATUS "[Cleaver2_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/EigenExternal.cmake b/Superbuild/EigenExternal.cmake index c60af110e2..73fc8076c3 100644 --- a/Superbuild/EigenExternal.cmake +++ b/Superbuild/EigenExternal.cmake @@ -24,18 +24,25 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# EigenExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) ExternalProject_Add(Eigen_external URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz" + UPDATE_DISCONNECTED 1 PATCH_COMMAND "" CONFIGURE_COMMAND "" BUILD_IN_SOURCE ON BUILD_COMMAND "" - INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory + "/Eigen" # headers live under Eigen/ and (for 3.4) CMake files under cmake/ + "${CMAKE_BINARY_DIR}/Externals/Install/Eigen_external/include/Eigen" + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -ExternalProject_Get_Property(Eigen_external SOURCE_DIR) -SET(Eigen_DIR ${SOURCE_DIR} CACHE PATH "") - -MESSAGE(STATUS "Eigen_DIR: ${Eigen_DIR}") +# Optional trace +ExternalProject_Get_Property(Eigen_external INSTALL_DIR) +message(STATUS "[Eigen_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 1d680aae38..4eaf4c8d21 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -24,25 +24,33 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# FreetypeExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(freetype_GIT_TAG "origin/seg3d_external_test") -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Freetype_external GIT_REPOSITORY "https://github.com/CIBC-Internal/freetype.git" GIT_TAG ${freetype_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE (they block installation) + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -) + -DBUILD_SHARED_LIBS:BOOL=OFF + -DFT_WITH_ZLIB:BOOL=ON + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Freetype_external -ExternalProject_Get_Property(Freetype_external BINARY_DIR) -SET(Freetype_DIR ${BINARY_DIR} CACHE PATH "") + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "Freetype_DIR: ${Freetype_DIR}") +ExternalProject_Get_Property(Freetype_external INSTALL_DIR) +message(STATUS "[Freetype_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/GLMExternal.cmake b/Superbuild/GLMExternal.cmake index 42ec0b3052..0e126e0b39 100644 --- a/Superbuild/GLMExternal.cmake +++ b/Superbuild/GLMExternal.cmake @@ -24,24 +24,35 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# GLMExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(GLM_external GIT_REPOSITORY "https://github.com/g-truc/glm.git" GIT_TAG "0.9.9.8" + PATCH_COMMAND "" + + # GLM is header-only — no configure/build steps needed. CONFIGURE_COMMAND "" BUILD_COMMAND "" - INSTALL_COMMAND "" + + # Install headers into the superbuild install tree. + INSTALL_COMMAND + ${CMAKE_COMMAND} -E copy_directory + "/glm" + "${CMAKE_BINARY_DIR}/Externals/Install/GLM_external/include/glm" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DGLM_FORCE_CXX03:BOOL=ON - -DGLM_FORCE_RADIANS:BOOL=ON -) + -DGLM_FORCE_CXX03:BOOL=ON + -DGLM_FORCE_RADIANS:BOOL=ON -ExternalProject_Get_Property(GLM_external SOURCE_DIR) -SET(GLM_DIR ${SOURCE_DIR}) + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "GLM_DIR: ${GLM_DIR}") +ExternalProject_Get_Property(GLM_external INSTALL_DIR) +message(STATUS "[GLM_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index ce905896d9..5c9ec87280 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -24,6 +24,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# GlewExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(glew_GIT_TAG "origin/master") @@ -32,24 +34,31 @@ IF(TRAVIS_BUILD) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") ENDIF() -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Glew_external GIT_REPOSITORY "https://github.com/CIBC-Internal/glew.git" GIT_TAG ${glew_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE (they block installation) + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DCMAKE_CXX_FLAGS:STATIC=${CMAKE_CXX_FLAGS} - -DCMAKE_C_FLAGS:STATIC=${CMAKE_C_FLAGS} -) + -DBUILD_SHARED_LIBS:BOOL=OFF + -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} + -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} + + # Install prefix into the superbuild structure + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Glew_external -ExternalProject_Get_Property(Glew_external BINARY_DIR) -SET(Glew_DIR ${BINARY_DIR} CACHE PATH "") + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "Glew_DIR: ${Glew_DIR}") +ExternalProject_Get_Property(Glew_external INSTALL_DIR) +message(STATUS "[Glew_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/LodePngExternal.cmake b/Superbuild/LodePngExternal.cmake index 028c3170c9..b8acdece31 100644 --- a/Superbuild/LodePngExternal.cmake +++ b/Superbuild/LodePngExternal.cmake @@ -24,21 +24,38 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# LodePngExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(LodePng_external GIT_REPOSITORY "https://github.com/CIBC-Internal/cibc-lodepng.git" GIT_TAG "origin/master" - INSTALL_COMMAND "" + PATCH_COMMAND "" + + # LodePNG has no configure/build step. + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + + # Install manually: headers + source (library is header-only/inline or single .cpp) + INSTALL_COMMAND + ${CMAKE_COMMAND} -E make_directory + "${CMAKE_BINARY_DIR}/Externals/Install/LodePng_external/include/lodepng" + && + ${CMAKE_COMMAND} -E copy_directory + "/lodepng" + "${CMAKE_BINARY_DIR}/Externals/Install/LodePng_external/include/lodepng" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -) + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -ExternalProject_Get_Property(LodePng_external BINARY_DIR) -SET(LODEPNG_DIR ${BINARY_DIR}) + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "LODEPNG_DIR: ${LODEPNG_DIR}") +# Debug output for install prefix +ExternalProject_Get_Property(LodePng_external INSTALL_DIR) +message(STATUS "[LodePng_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 48ff0e3dba..039e9d9049 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -24,32 +24,48 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# OsprayExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(ospray_GIT_TAG "origin/scirun-build-2.10") +# OSPRay depends on GLM set(ospray_DEPENDENCIES) -LIST(APPEND ospray_DEPENDENCIES GLM_external) +list(APPEND ospray_DEPENDENCIES GLM_external) -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Ospray_external DEPENDS ${ospray_DEPENDENCIES} GIT_REPOSITORY "https://github.com/CIBC-Internal/ospray.git" GIT_TAG ${ospray_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE — they suppress installation + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + + # Use ospray's built-in superbuild -DENABLE_OSPRAY_SUPERBUILD:BOOL=ON - -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm + + # IMPORTANT: point glm_DIR to the INSTALL tree, not source tree + -Dglm_DIR:PATH=${CMAKE_BINARY_DIR}/Externals/Install/GLM_external/include/glm/cmake + + # Disable AVX512 unless needed -DBUILD_ISA_AVX512:BOOL=OFF -) -ExternalProject_Get_Property(Ospray_external BINARY_DIR) -SET(OSPRAY_BUILD_DIR ${BINARY_DIR} CACHE PATH "") + # Install OSPRay into the superbuild Install tree + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Ospray_external + + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "OSPRAY_BUILD_DIR: ${OSPRAY_BUILD_DIR}") +# Debug output +ExternalProject_Get_Property(Ospray_external INSTALL_DIR) +message(STATUS "[Ospray_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index f771dddcc2..3358c1b8f8 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -25,11 +25,7 @@ # DEALINGS IN THE SOFTWARE. -# Assume you already define these at the top-level (as in our previous message): -# set(SCIRUN_QT_MAJOR "6" CACHE STRING "Qt major version to use (5 or 6)") -# set_property(CACHE SCIRUN_QT_MAJOR PROPERTY STRINGS 5 6) -# set(Qt_PATH "" CACHE PATH "Qt install prefix, e.g. C:/Qt/6.3.1/msvc2019_64") - +# QwtExternal.cmake set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) # Common cache args for the ExternalProject @@ -46,60 +42,41 @@ if (NOT IS_DIRECTORY "${Qt_PATH}") endif() # Help the sub-build find Qt by giving it the correct prefix path. -# On Windows Qt installs, ${Qt_PATH} contains bin/, lib/, plugins/, and cmake/Qt6 (or Qt5). +# On Windows Qt installs, ${Qt_PATH} contains bin/, lib/, plugins/, and lib/cmake/Qt6 (or Qt5). list(APPEND QWT_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${Qt_PATH}") -# Pass version-specific hints. Keep them minimal and valid for the chosen major version. +# Pass a minimal, version-appropriate Qt hint (primary config package root). if (SCIRUN_QT_MAJOR STREQUAL "6") - # Primary hint for Qt6 list(APPEND QWT_CACHE_ARGS "-DQt6_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") - - # OPTIONAL: if Qwt’s CMake looks for module-specific config packages, you can add these: - # (Only if actually needed by their CMake; otherwise leave them out to avoid over-constraining.) - # list(APPEND QWT_CACHE_ARGS "-DQt6Core_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") - # list(APPEND QWT_CACHE_ARGS "-DQt6Gui_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") - # list(APPEND QWT_CACHE_ARGS "-DQt6Widgets_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") - - # Choose a Qt6 branch/tag for Qwt set(qwt_GIT_TAG "origin/qt6-static-6.2.0") elseif (SCIRUN_QT_MAJOR STREQUAL "5") - # Primary hint for Qt5 list(APPEND QWT_CACHE_ARGS "-DQt5_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5") - - # OPTIONAL: same note as above—only pass if Qwt expects these variables. - # list(APPEND QWT_CACHE_ARGS "-DQt5Core_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5Core") - # list(APPEND QWT_CACHE_ARGS "-DQt5Gui_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5Gui") - # list(APPEND QWT_CACHE_ARGS "-DQt5Widgets_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5Widgets") - set(qwt_GIT_TAG "origin/qt5-static-6.1.5") else() message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Current value: ${SCIRUN_QT_MAJOR}") endif() -# If Qwt’s subbuild needs to know which major to target (some CMakeLists choose behavior by this), -# pass a simple cache variable it can use. +# Let Qwt know which Qt major to target (if its CMake uses this) list(APPEND QWT_CACHE_ARGS "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}") -# Remove legacy/fragile arguments that caused trouble: -# -DQt_PATH -# -DQt5_PATH -# -DQt${QT_VERSION_MAJOR}Core_DIR -# -DQt${QT_VERSION_MAJOR}CoreTools_DIR -# -DQt${QT_VERSION_MAJOR}Gui_DIR -# -DQt${QT_VERSION_MAJOR}GuiTools_DIR -# -# These often become empty or point to non-existent packages (e.g., *Tools on Qt6), -# which derails the subbuild's find_package() calls. - ExternalProject_Add(Qwt_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt.git" GIT_TAG ${qwt_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" - CMAKE_CACHE_ARGS ${QWT_CACHE_ARGS} + + # REMOVE THESE (they suppress installation) + # INSTALL_DIR "" + # INSTALL_COMMAND "" + + CMAKE_CACHE_ARGS + ${QWT_CACHE_ARGS} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external + + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -ExternalProject_Get_Property(Qwt_external BINARY_DIR) -set(QWT_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "QWT_DIR: ${QWT_DIR}") +# For trace/debug: show install prefix (the helper will discover the config from here) +ExternalProject_Get_Property(Qwt_external INSTALL_DIR) +message(STATUS "[Qwt_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index a4a3943d44..dc556de375 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -24,25 +24,33 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. + +# SQLiteExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(sqlite_GIT_TAG "origin/master") -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(SQLite_external GIT_REPOSITORY "https://github.com/CIBC-Internal/sqlite.git" GIT_TAG ${sqlite_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE (they suppress installation) + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -) + -DBUILD_SHARED_LIBS:BOOL=OFF + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/SQLite_external -ExternalProject_Get_Property(SQLite_external BINARY_DIR) -SET(SQLite_DIR ${BINARY_DIR} CACHE PATH "") + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "SQLite_DIR: ${SQLite_DIR}") +# Trace the resolved install prefix (your helper will scan from here) +ExternalProject_Get_Property(SQLite_external INSTALL_DIR) +message(STATUS "[SQLite_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/SpdLogExternal.cmake b/Superbuild/SpdLogExternal.cmake index 50b16fff19..4ff02dcc4c 100644 --- a/Superbuild/SpdLogExternal.cmake +++ b/Superbuild/SpdLogExternal.cmake @@ -24,22 +24,33 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). +# SpdLogExternal.cmake +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + ExternalProject_Add(SpdLog_external GIT_REPOSITORY "https://github.com/gabime/spdlog" GIT_TAG "v1.10.0" + PATCH_COMMAND "" + + # Header-only library — no build needed CONFIGURE_COMMAND "" BUILD_COMMAND "" - INSTALL_COMMAND "" + + # Install headers into the superbuild install prefix + INSTALL_COMMAND + ${CMAKE_COMMAND} -E copy_directory + "/include" + "${CMAKE_BINARY_DIR}/Externals/Install/SpdLog_external/include" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -) -ExternalProject_Get_Property(SpdLog_external SOURCE_DIR) -SET(SPDLOG_DIR ${SOURCE_DIR}) + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "SPDLOG_DIR: ${SPDLOG_DIR}") +ExternalProject_Get_Property(SpdLog_external INSTALL_DIR) +message(STATUS "[SpdLog_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 993606a9d2..8c781e2e95 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -236,18 +236,134 @@ ENDIF() ADD_EXTERNAL( ${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external ) + +# Helper to export a CONFIG package directory to SCIRun_CACHE_ARGS +function(_export_config_dir pkg target subdir_pattern) + # Get the external's install prefix + ExternalProject_Get_Property(${target} INSTALL_DIR) + if(NOT INSTALL_DIR) + message(FATAL_ERROR "INSTALL_DIR not set for ${target}. Ensure INSTALL is enabled in its ExternalProject_Add.") + endif() + + # The folder that contains Config.cmake varies slightly by project. + # Common patterns: lib/cmake/, lib/cmake/, share//cmake + set(_candidates + "${INSTALL_DIR}/lib/cmake/${pkg}" + "${INSTALL_DIR}/lib/cmake/${pkg}-*" + "${INSTALL_DIR}/lib/cmake/${pkg_upper}" + "${INSTALL_DIR}/share/${pkg}/cmake" + ) + + string(TOUPPER "${pkg}" pkg_upper) + unset(_found_dir) + foreach(_cand IN LISTS _candidates) + file(GLOB _hits "${_cand}") + foreach(_d IN LISTS _hits) + if(EXISTS "${_d}/${pkg}Config.cmake" OR EXISTS "${_d}/${pkg_upper}Config.cmake") + set(_found_dir "${_d}") + break() + endif() + endforeach() + if(DEFINED _found_dir) + break() + endif() + endforeach() + + if(NOT DEFINED _found_dir) + message(STATUS "[superbuild] ${pkg}: no *Config.cmake found under ${INSTALL_DIR}. " + "This may be expected if the package does not export configs. " + "We will skip setting ${pkg}_DIR for now.") + return() + endif() + + # Export _DIR to the SCIRun configure cache + set(${pkg}_DIR "${_found_dir}" CACHE PATH "${pkg} config dir" FORCE) + list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") + set(SCIRun_CACHE_ARGS "${SCIRun_CACHE_ARGS}" PARENT_SCOPE) + + message(STATUS "[superbuild] ${pkg}_DIR = ${${pkg}_DIR}") +endfunction() + +# Helper to export just include/lib hints (for header-only or non-config packages) +function(_export_include_lib pkg target) + ExternalProject_Get_Property(${target} INSTALL_DIR) + if(NOT INSTALL_DIR) + message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") + endif() + + # Heuristics: include/ and lib{,64}/ under install prefix + set(_inc "${INSTALL_DIR}/include") + if(EXISTS "${INSTALL_DIR}/lib64") + set(_lib "${INSTALL_DIR}/lib64") + else() + set(_lib "${INSTALL_DIR}/lib") + endif() + + if(EXISTS "${_inc}") + set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) + list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") + endif() + if(EXISTS "${_lib}") + set(${pkg}_LIB_DIR "${_lib}" CACHE PATH "${pkg} lib dir" FORCE) + list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_LIB_DIR:PATH=${${pkg}_LIB_DIR}") + endif() + set(SCIRun_CACHE_ARGS "${SCIRun_CACHE_ARGS}" PARENT_SCOPE) + + message(STATUS "[superbuild] ${pkg}: include=${_inc} lib=${_lib}") +endfunction() + +#get boost properties and pass to SCIRun ExternalProject_Get_Property(Boost_external INSTALL_DIR) set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") set(SCI_BOOST_INCLUDE "${INSTALL_DIR}/include") -# Define the Boost install prefix for downstream use set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix (produced by Boost_external)" FORCE) - if (WIN32 AND EXISTS "${INSTALL_DIR}/lib64") set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib64") else() set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib") endif() +# CONFIG-package externals (expect *Config.cmake) +# Adjust names if the actual package names differ. +_export_config_dir(Zlib Zlib_external "") +_export_config_dir(Freetype Freetype_external "") +_export_config_dir(SQLite SQLite_external "") +_export_config_dir(Qwt Qwt_external "") + +# GLEW: depends on its CMake; if it exports configs, use config; otherwise include/lib +if(WIN32) + _export_config_dir(GLEW Glew_external "") +endif() + +# Python: if your PythonExternal builds a CPython with a CMake export, use config; +# otherwise export include/lib and PYTHONHOME-ish prefix for embedding. +if(BUILD_WITH_PYTHON) + _export_config_dir(Python Python_external "") +endif() + +# Header-only or non-config: export include/lib hints +_export_include_lib(Eigen Eigen_external) +_export_include_lib(GLM GLM_external) +_export_include_lib(SpdLog SpdLog_external) + +# Likely non-config or custom installs—export include/lib for now +_export_include_lib(Teem Teem_external) +_export_include_lib(Tny Tny_external) +_export_include_lib(LodePng LodePng_external) +_export_include_lib(Cleaver2 Cleaver2_external) + +# Optional sets (only if enabled) +if(WITH_TETGEN) + _export_include_lib(Tetgen Tetgen_external) +endif() +if(WITH_OSPRAY) + # OSPRay typically has a config; try config first, fall back to include/lib + _export_config_dir(ospray Ospray_external "") +endif() +if(BUILD_TESTING) + # Test data external likely doesn't export headers/libs; skip +endif() + ########################################### # Download external data sources OPTION(DOWNLOAD_TOOLKITS "Download toolkit repositories." ON) @@ -258,7 +374,9 @@ IF(DOWNLOAD_TOOLKITS) EXTERNAL_TOOLKIT(FwdInvToolkit) ENDIF() -SET(SCIRUN_CACHE_ARGS + +# --- SCIRUN CACHE ARGUMENTS (SCIRun internal settings only) --- +set(SCIRUN_CACHE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}" @@ -276,70 +394,38 @@ SET(SCIRUN_CACHE_ARGS "-DWITH_OSPRAY:BOOL=${WITH_OSPRAY}" "-DREGENERATE_MODULE_FACTORY_CODE:BOOL=${REGENERATE_MODULE_FACTORY_CODE}" "-DGENERATE_MODULE_FACTORY_CODE:BOOL=${GENERATE_MODULE_FACTORY_CODE}" - "-DEigen_DIR:PATH=${Eigen_DIR}" - "-DZlib_DIR:PATH=${Zlib_DIR}" - "-DSQLite_DIR:PATH=${SQLite_DIR}" - "-DBoost_DIR:PATH=${Boost_DIR}" # Try CONFIG package first - "-DBOOST_ROOT:PATH=${INSTALL_DIR}" # Fallback: FindBoost - "-DBoost_INCLUDE_DIR:PATH=${SCI_BOOST_INCLUDE}" - "-DBoost_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" - "-DBoost_NO_BOOST_CMAKE:BOOL=OFF" # Allow CONFIG if present "-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}" - "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" # so the macro can use the prefix - "-DTeem_DIR:PATH=${Teem_DIR}" - "-DFreetype_DIR:PATH=${Freetype_DIR}" - "-DGLM_DIR:PATH=${GLM_DIR}" - "-DSPDLOG_DIR:PATH=${SPDLOG_DIR}" - "-DTNY_DIR:PATH=${TNY_DIR}" - "-DGLEW_DIR:PATH=${Glew_DIR}" - "-DLODEPNG_DIR:PATH=${LODEPNG_DIR}" - "-DCLEAVER2_DIR:PATH=${CLEAVER2_DIR}" - "-DSCI_DATA_DIR:PATH=${SCI_DATA_DIR}" "-DGENERATE_COMPILATION_DATABASE:BOOL=${GENERATE_COMPILATION_DATABASE}" "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}" "-DQt_PATH:PATH=${Qt_PATH}" ) -IF(BUILD_WITH_PYTHON) - LIST(APPEND SCIRUN_CACHE_ARGS - "-DPython_DIR:PATH=${Python_DIR}" +if(BUILD_WITH_PYTHON) + list(APPEND SCIRUN_CACHE_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}" ) -ENDIF() - -IF(WITH_TETGEN) - LIST(APPEND SCIRUN_CACHE_ARGS - "-DTetgen_DIR:PATH=${Tetgen_DIR}" - ) -ENDIF() - -IF(WITH_OSPRAY) - LIST(APPEND SCIRUN_CACHE_ARGS - "-DOspray_External_Dir:PATH=${OSPRAY_BUILD_DIR}" - ) -ENDIF() +endif() -IF(WIN32) - LIST(APPEND SCIRUN_CACHE_ARGS +if(WIN32) + list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}" ) -ENDIF() +endif() -IF(NOT BUILD_HEADLESS) - LIST(APPEND SCIRUN_CACHE_ARGS +if(NOT BUILD_HEADLESS) + list(APPEND SCIRUN_CACHE_ARGS "-DQt_PATH:PATH=${Qt_PATH}" "-DQt${QT_VERSION_MAJOR}Core_DIR:PATH=${Qt${QT_VERSION_MAJOR}Core_DIR}" "-DQt${QT_VERSION_MAJOR}CoreTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}CoreTools_DIR}" "-DQt${QT_VERSION_MAJOR}Gui_DIR:PATH=${Qt${QT_VERSION_MAJOR}Gui_DIR}" "-DQt${QT_VERSION_MAJOR}GuiTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}GuiTools_DIR}" "-DQt${QT_VERSION_MAJOR}OpenGL_DIR:PATH=${Qt${QT_VERSION_MAJOR}OpenGL_DIR}" - "-DQt${QT_VERSION_MAJOR}Network_DIR:PATH=${Qt${QT_VERSION_MAJOR}Network_DIR}" - "-DQt${QT_VERSION_MAJOR}Widgets_DIR:PATH=${Qt${QT_VERSION_MAJOR}Widgets_DIR}" - "-DQt${QT_VERSION_MAJOR}Concurrent_DIR:PATH=${Qt${QT_VERSION_MAJOR}Concurrent_DIR}" + "-DQt${QT_VERSION_MAJOR}Network_DIR:PATH=${Qt${QT_VERSION_MAJOR}Network_DIR}" + "-DQt${QT_VERSION_MAJOR}Widgets_DIR:PATH=${Qt${QT_VERSION_MAJOR}Widgets_DIR}" + "-DQt${QT_VERSION_MAJOR}Concurrent_DIR:PATH=${Qt${QT_VERSION_MAJOR}Concurrent_DIR}" "-DMACDEPLOYQT_OUTPUT_LEVEL:STRING=${MACDEPLOYQT_OUTPUT_LEVEL}" - "-DQWT_DIR:PATH=${QWT_DIR}" ) -ENDIF() +endif() ExternalProject_Add( SCIRun_external DEPENDS ${SCIRun_DEPENDENCIES} diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index fed9a7a12a..c00088641d 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -24,29 +24,43 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(teem_GIT_TAG "origin/adjust-png") -SET(teem_DEPENDENCIES "Zlib_external") -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). +# TeemExternal.cmake +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(teem_GIT_TAG "origin/adjust-png") +set(teem_DEPENDENCIES Zlib_external) + ExternalProject_Add(Teem_external DEPENDS ${teem_DEPENDENCIES} GIT_REPOSITORY "https://github.com/SCIInstitute/teem.git" GIT_TAG ${teem_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE — they suppress installation + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DZlib_DIR:PATH=${Zlib_DIR} + + # Important: point Teem at installed Zlib + -DZlib_DIR:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external/lib/cmake/ZLIB + + # Teem options -DTeem_USE_NRRD_INTERNALS:BOOL=ON -) + -DBUILD_SHARED_LIBS:BOOL=OFF -ExternalProject_Get_Property(Teem_external BINARY_DIR) -SET(Teem_DIR ${BINARY_DIR} CACHE PATH "") + # Install Teem under the superbuild prefix + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Teem_external + + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "Teem_DIR: ${Teem_DIR}") +# Debug: show Teem install prefix (helpers will find include/lib automatically) +ExternalProject_Get_Property(Teem_external INSTALL_DIR) +message(STATUS "[Teem_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/TetgenExternal.cmake b/Superbuild/TetgenExternal.cmake index f92baaa187..ddd9c66617 100644 --- a/Superbuild/TetgenExternal.cmake +++ b/Superbuild/TetgenExternal.cmake @@ -24,31 +24,49 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + +# TetgenExternal.cmake +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + ExternalProject_Add(Tetgen_external URL "https://github.com/CIBC-Internal/SCIRunTestData/releases/download/test/tetgen1.5.1-beta1.tar.gz" PATCH_COMMAND "" - INSTALL_COMMAND "" + + # REMOVE THESE — they suppress installation + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - #-DTETLIBRARY + # -DTETLIBRARY # optional + + # Install Tetgen under the superbuild prefix + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Tetgen_external + + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -ExternalProject_Get_Property(Tetgen_external SOURCE_DIR) -ExternalProject_Get_Property(Tetgen_external BINARY_DIR) +# Extract install directory ExternalProject_Get_Property(Tetgen_external INSTALL_DIR) -SET(TETGEN_INCLUDE ${SOURCE_DIR}) -SET(TETGEN_LIBRARY_DIR ${BINARY_DIR}) -SET(TETGEN_USE_FILE ${INSTALL_DIR}/UseTetgen.cmake) -# see Tetgen CMakeLists.txt file -SET(TETGEN_LIBRARY "tet") -SET(Tetgen_DIR ${INSTALL_DIR} CACHE PATH "") - -# Boost is special case - normally this should be handled in external library repo -CONFIGURE_FILE(${SUPERBUILD_DIR}/TetgenConfig.cmake.in ${INSTALL_DIR}/TetgenConfig.cmake @ONLY) -CONFIGURE_FILE(${SUPERBUILD_DIR}/UseTetgen.cmake ${TETGEN_USE_FILE} COPYONLY) - -MESSAGE(STATUS "Tetgen_DIR: ${Tetgen_DIR}") +message(STATUS "[Tetgen_external] INSTALL_DIR=${INSTALL_DIR}") + +# Custom variables expected by SCIRun (Tetgen's CMake does not export any) +set(TETGEN_INCLUDE ${INSTALL_DIR}/include) +set(TETGEN_LIBRARY_DIR ${INSTALL_DIR}/lib) +set(TETGEN_LIBRARY "tet") # matches Tetgen’s built library name +set(TETGEN_USE_FILE ${INSTALL_DIR}/UseTetgen.cmake) + +# This is the "package root" for SCIRun, not source or build dir +set(Tetgen_DIR ${INSTALL_DIR} CACHE PATH "") + +# Generate the config + use file (same as original) +configure_file(${SUPERBUILD_DIR}/TetgenConfig.cmake.in + ${INSTALL_DIR}/TetgenConfig.cmake @ONLY) + +configure_file(${SUPERBUILD_DIR}/UseTetgen.cmake + ${TETGEN_USE_FILE} COPYONLY) diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index f68f510c7f..5beb093b13 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -24,21 +24,37 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). +# TnyExternal.cmake +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + ExternalProject_Add(Tny_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Tny.git" GIT_TAG "origin/master" - INSTALL_COMMAND "" + PATCH_COMMAND "" + + # Tny has no configure/build — header/ single-file library + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + + # Install headers (and optionally .c/.cpp files) + INSTALL_COMMAND + ${CMAKE_COMMAND} -E make_directory + "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/include/Tny" + && + ${CMAKE_COMMAND} -E copy_directory + "" + "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/include/Tny" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -) + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -ExternalProject_Get_Property(Tny_external BINARY_DIR) -SET(TNY_DIR ${BINARY_DIR}) + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "TNY_DIR: ${TNY_DIR}") +ExternalProject_Get_Property(Tny_external INSTALL_DIR) +message(STATUS "[Tny_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index f665f2b379..03250f3c9b 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -24,25 +24,34 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(zlib_GIT_TAG "origin/master") -# If CMake ever allows overriding the checkout command or adding flags, -# git checkout -q will silence message about detached head (harmless). +# ZlibExternal.cmake +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(zlib_GIT_TAG "origin/master") + ExternalProject_Add(Zlib_external GIT_REPOSITORY "https://github.com/CIBC-Internal/zlib.git" GIT_TAG ${zlib_GIT_TAG} PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" + + # REMOVE THESE — they suppress installation entirely + # INSTALL_DIR "" + # INSTALL_COMMAND "" + CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -) + -DBUILD_SHARED_LIBS:BOOL=OFF + + # Install Zlib under the superbuild install prefix + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external -ExternalProject_Get_Property(Zlib_external BINARY_DIR) -SET(Zlib_DIR ${BINARY_DIR} CACHE PATH "") + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 +) -MESSAGE(STATUS "Zlib_DIR: ${Zlib_DIR}") +ExternalProject_Get_Property(Zlib_external INSTALL_DIR) +message(STATUS "[Zlib_external] INSTALL_DIR=${INSTALL_DIR}") From 18d684c83f4ff4338d3f44f7e1c3f056777f0e0e Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 26 Jan 2026 16:57:40 -0700 Subject: [PATCH 008/140] issues with externals trying to use tetgen as an example to figure out a working solution --- Superbuild/Cleaver2External.cmake | 58 ++++++++++++++++---------- Superbuild/FreetypeExternal.cmake | 48 +++++++++++++++------- Superbuild/GlewExternal.cmake | 56 ++++++++++++++++---------- Superbuild/LodePngExternal.cmake | 10 +---- Superbuild/QwtExternal.cmake | 49 +++++++++++++++------- Superbuild/SQLiteExternal.cmake | 50 +++++++++++++++-------- Superbuild/TeemExternal.cmake | 49 +++++++++++++--------- Superbuild/TetgenExternal.cmake | 67 +++++++++++++++++++------------ Superbuild/TnyExternal.cmake | 10 +---- Superbuild/ZlibExternal.cmake | 46 ++++++++++++++------- 10 files changed, 278 insertions(+), 165 deletions(-) diff --git a/Superbuild/Cleaver2External.cmake b/Superbuild/Cleaver2External.cmake index 60ba3f2b39..1013aa0a6f 100644 --- a/Superbuild/Cleaver2External.cmake +++ b/Superbuild/Cleaver2External.cmake @@ -25,33 +25,49 @@ # DEALINGS IN THE SOFTWARE. -# Cleaver2External.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(cleaver2_GIT_TAG "origin/master") +# Cleaver2External.cmake (fixed) +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(cleaver2_GIT_TAG "origin/master") + +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() ExternalProject_Add(Cleaver2_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Cleaver2Library.git" - GIT_TAG ${cleaver2_GIT_TAG} - PATCH_COMMAND "" - - # REMOVE THESE (they break installation) - # INSTALL_DIR "" - # INSTALL_COMMAND "" - - # Correct: install to a known prefix under Externals/Install - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Cleaver2_external + GIT_TAG ${cleaver2_GIT_TAG} + PATCH_COMMAND "" + + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} + + # --- Explicit build --- + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config + + # --- Explicit install --- + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -# For debugging: show where Cleaver2 will be installed ExternalProject_Get_Property(Cleaver2_external INSTALL_DIR) message(STATUS "[Cleaver2_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 4eaf4c8d21..c06708c447 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -26,31 +26,49 @@ # FreetypeExternal.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(freetype_GIT_TAG "origin/seg3d_external_test") +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(freetype_GIT_TAG "origin/seg3d_external_test") + +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() ExternalProject_Add(Freetype_external GIT_REPOSITORY "https://github.com/CIBC-Internal/freetype.git" GIT_TAG ${freetype_GIT_TAG} PATCH_COMMAND "" - # REMOVE THESE (they block installation) - # INSTALL_DIR "" - # INSTALL_COMMAND "" + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} + + # --- Explicit build step --- + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF - -DFT_WITH_ZLIB:BOOL=ON - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Freetype_external + # --- Explicit install step --- + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) +# Debug info ExternalProject_Get_Property(Freetype_external INSTALL_DIR) message(STATUS "[Freetype_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index 5c9ec87280..14555e1383 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -26,38 +26,52 @@ # GlewExternal.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(glew_GIT_TAG "origin/master") +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(glew_GIT_TAG "origin/master") -IF(TRAVIS_BUILD) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") -ENDIF() +if(TRAVIS_BUILD) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") +endif() + +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() ExternalProject_Add(Glew_external GIT_REPOSITORY "https://github.com/CIBC-Internal/glew.git" GIT_TAG ${glew_GIT_TAG} PATCH_COMMAND "" - # REMOVE THESE (they block installation) - # INSTALL_DIR "" - # INSTALL_COMMAND "" + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF - -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} - -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS} + # --- Explicit build step --- + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config - # Install prefix into the superbuild structure - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Glew_external + # --- Explicit install step --- + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) ExternalProject_Get_Property(Glew_external INSTALL_DIR) diff --git a/Superbuild/LodePngExternal.cmake b/Superbuild/LodePngExternal.cmake index b8acdece31..fb48dd2da9 100644 --- a/Superbuild/LodePngExternal.cmake +++ b/Superbuild/LodePngExternal.cmake @@ -26,22 +26,17 @@ # LodePngExternal.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) ExternalProject_Add(LodePng_external GIT_REPOSITORY "https://github.com/CIBC-Internal/cibc-lodepng.git" GIT_TAG "origin/master" PATCH_COMMAND "" - - # LodePNG has no configure/build step. CONFIGURE_COMMAND "" BUILD_COMMAND "" - # Install manually: headers + source (library is header-only/inline or single .cpp) + # FIX: use a single copy_directory (NO &&) INSTALL_COMMAND - ${CMAKE_COMMAND} -E make_directory - "${CMAKE_BINARY_DIR}/Externals/Install/LodePng_external/include/lodepng" - && ${CMAKE_COMMAND} -E copy_directory "/lodepng" "${CMAKE_BINARY_DIR}/Externals/Install/LodePng_external/include/lodepng" @@ -56,6 +51,5 @@ ExternalProject_Add(LodePng_external LOG_INSTALL 1 ) -# Debug output for install prefix ExternalProject_Get_Property(LodePng_external INSTALL_DIR) message(STATUS "[LodePng_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index 3358c1b8f8..136c0c1752 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -28,7 +28,7 @@ # QwtExternal.cmake set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -# Common cache args for the ExternalProject +# Common cache args set(QWT_CACHE_ARGS "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" @@ -36,16 +36,15 @@ set(QWT_CACHE_ARGS "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" ) -# Sanity check Qt_PATH once, fail early if not set correctly +# Sanity check if (NOT IS_DIRECTORY "${Qt_PATH}") message(FATAL_ERROR "Qt_PATH is invalid or not set: ${Qt_PATH}") endif() -# Help the sub-build find Qt by giving it the correct prefix path. -# On Windows Qt installs, ${Qt_PATH} contains bin/, lib/, plugins/, and lib/cmake/Qt6 (or Qt5). +# Help Qwt find Qt list(APPEND QWT_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${Qt_PATH}") -# Pass a minimal, version-appropriate Qt hint (primary config package root). +# Choose Qt major and tag + give one primary hint if (SCIRUN_QT_MAJOR STREQUAL "6") list(APPEND QWT_CACHE_ARGS "-DQt6_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") set(qwt_GIT_TAG "origin/qt6-static-6.2.0") @@ -56,27 +55,47 @@ else() message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Current value: ${SCIRUN_QT_MAJOR}") endif() -# Let Qwt know which Qt major to target (if its CMake uses this) list(APPEND QWT_CACHE_ARGS "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}") +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() + ExternalProject_Add(Qwt_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt.git" GIT_TAG ${qwt_GIT_TAG} PATCH_COMMAND "" - # REMOVE THESE (they suppress installation) - # INSTALL_DIR "" - # INSTALL_COMMAND "" + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} + + # --- Explicit build --- + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config - CMAKE_CACHE_ARGS - ${QWT_CACHE_ARGS} - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external + # --- Explicit install --- + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -# For trace/debug: show install prefix (the helper will discover the config from here) ExternalProject_Get_Property(Qwt_external INSTALL_DIR) message(STATUS "[Qwt_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index dc556de375..ca67d1fa06 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -26,29 +26,47 @@ # SQLiteExternal.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(sqlite_GIT_TAG "origin/master") +set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set(sqlite_GIT_TAG "origin/master") + +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() ExternalProject_Add(SQLite_external GIT_REPOSITORY "https://github.com/CIBC-Internal/sqlite.git" - GIT_TAG ${sqlite_GIT_TAG} - PATCH_COMMAND "" + GIT_TAG ${sqlite_GIT_TAG} + PATCH_COMMAND "" + + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} - # REMOVE THESE (they suppress installation) - # INSTALL_DIR "" - # INSTALL_COMMAND "" + # Explicit build + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/SQLite_external + # Explicit install + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) # Trace the resolved install prefix (your helper will scan from here) diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index c00088641d..d342649d3d 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -25,42 +25,51 @@ # DEALINGS IN THE SOFTWARE. -# TeemExternal.cmake +# TeemExternal.cmake (fixed) set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) set(teem_GIT_TAG "origin/adjust-png") set(teem_DEPENDENCIES Zlib_external) +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() + ExternalProject_Add(Teem_external DEPENDS ${teem_DEPENDENCIES} GIT_REPOSITORY "https://github.com/SCIInstitute/teem.git" GIT_TAG ${teem_GIT_TAG} PATCH_COMMAND "" - # REMOVE THESE — they suppress installation - # INSTALL_DIR "" - # INSTALL_COMMAND "" - - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Important: point Teem at installed Zlib - -DZlib_DIR:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external/lib/cmake/ZLIB + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} - # Teem options - -DTeem_USE_NRRD_INTERNALS:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF + # --- Explicit build step --- + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config - # Install Teem under the superbuild prefix - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Teem_external + # --- Explicit install step --- + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -# Debug: show Teem install prefix (helpers will find include/lib automatically) ExternalProject_Get_Property(Teem_external INSTALL_DIR) message(STATUS "[Teem_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/TetgenExternal.cmake b/Superbuild/TetgenExternal.cmake index ddd9c66617..3e96b5cb5b 100644 --- a/Superbuild/TetgenExternal.cmake +++ b/Superbuild/TetgenExternal.cmake @@ -24,49 +24,66 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - # TetgenExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +# Common CMake args +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= + + # Force output directories so install() is not needed + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config versions for VS + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin +) + +# Only add CMAKE_BUILD_TYPE for single-config generators (e.g. Ninja) +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() ExternalProject_Add(Tetgen_external URL "https://github.com/CIBC-Internal/SCIRunTestData/releases/download/test/tetgen1.5.1-beta1.tar.gz" PATCH_COMMAND "" - # REMOVE THESE — they suppress installation - # INSTALL_DIR "" - # INSTALL_COMMAND "" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - # -DTETLIBRARY # optional + CMAKE_ARGS ${_cmake_args} - # Install Tetgen under the superbuild prefix - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Tetgen_external + # Skip install entirely + INSTALL_COMMAND "" LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -# Extract install directory -ExternalProject_Get_Property(Tetgen_external INSTALL_DIR) +ExternalProject_Get_Property(Tetgen_external SOURCE_DIR INSTALL_DIR) message(STATUS "[Tetgen_external] INSTALL_DIR=${INSTALL_DIR}") -# Custom variables expected by SCIRun (Tetgen's CMake does not export any) -set(TETGEN_INCLUDE ${INSTALL_DIR}/include) -set(TETGEN_LIBRARY_DIR ${INSTALL_DIR}/lib) -set(TETGEN_LIBRARY "tet") # matches Tetgen’s built library name -set(TETGEN_USE_FILE ${INSTALL_DIR}/UseTetgen.cmake) +# Tetgen headers live in the source tree +set(TETGEN_INCLUDE ${SOURCE_DIR}) +set(TETGEN_LIBRARY_DIR ${INSTALL_DIR}/lib) +set(TETGEN_LIBRARY "tet") # static or shared, same name root -# This is the "package root" for SCIRun, not source or build dir +set(TETGEN_USE_FILE ${INSTALL_DIR}/UseTetgen.cmake) set(Tetgen_DIR ${INSTALL_DIR} CACHE PATH "") -# Generate the config + use file (same as original) +# If you have these files, you can still generate them: configure_file(${SUPERBUILD_DIR}/TetgenConfig.cmake.in ${INSTALL_DIR}/TetgenConfig.cmake @ONLY) configure_file(${SUPERBUILD_DIR}/UseTetgen.cmake - ${TETGEN_USE_FILE} COPYONLY) + ${TETGEN_USE_FILE} COPYONLY) \ No newline at end of file diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index 5beb093b13..22eaa31f03 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -28,29 +28,21 @@ # TnyExternal.cmake set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + ExternalProject_Add(Tny_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Tny.git" GIT_TAG "origin/master" PATCH_COMMAND "" - - # Tny has no configure/build — header/ single-file library CONFIGURE_COMMAND "" BUILD_COMMAND "" - - # Install headers (and optionally .c/.cpp files) INSTALL_COMMAND - ${CMAKE_COMMAND} -E make_directory - "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/include/Tny" - && ${CMAKE_COMMAND} -E copy_directory "" "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/include/Tny" - CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index 03250f3c9b..a40b2aa314 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -29,28 +29,44 @@ set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) set(zlib_GIT_TAG "origin/master") +# Build up args in a list; only add platform/toolset when non-empty. +set(_cmake_args + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= +) + +# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) + list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +endif() + ExternalProject_Add(Zlib_external GIT_REPOSITORY "https://github.com/CIBC-Internal/zlib.git" - GIT_TAG ${zlib_GIT_TAG} - PATCH_COMMAND "" + GIT_TAG ${zlib_GIT_TAG} + PATCH_COMMAND "" + + # Use the built-in generator handling + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + # Only add these if they are set in the parent build + # (CMake treats empty values as "not present") + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # REMOVE THESE — they suppress installation entirely - # INSTALL_DIR "" - # INSTALL_COMMAND "" + # Normal CMake cache/args + CMAKE_ARGS ${_cmake_args} - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF + # --- EXPLICIT BUILD --- + BUILD_COMMAND + ${CMAKE_COMMAND} --build --config - # Install Zlib under the superbuild install prefix - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external + # --- EXPLICIT INSTALL (portable; does not depend on a VS "INSTALL" project) --- + INSTALL_COMMAND + ${CMAKE_COMMAND} --install --config LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) ExternalProject_Get_Property(Zlib_external INSTALL_DIR) From e948db0f7b91c0b4e8b891188f22e4b9904ddadb Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 27 Jan 2026 13:50:53 -0700 Subject: [PATCH 009/140] updated tetgen to install --- Superbuild/TetgenExternal.cmake | 66 +++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/Superbuild/TetgenExternal.cmake b/Superbuild/TetgenExternal.cmake index 3e96b5cb5b..b66a7b3589 100644 --- a/Superbuild/TetgenExternal.cmake +++ b/Superbuild/TetgenExternal.cmake @@ -24,21 +24,21 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# TetgenExternal.cmake +# TetgenExternal.cmake (Variant A: TetGen repo has CMake build) set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") # Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_INSTALL_PREFIX= - # Force output directories so install() is not needed + # Force output directories so we can skip the install step + -DCMAKE_INSTALL_PREFIX= -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - # Multi-config versions for VS + # Multi-config (VS) subdirs -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib @@ -47,43 +47,55 @@ set(_cmake_args -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Only add CMAKE_BUILD_TYPE for single-config generators (e.g. Ninja) +# For single-config generators (Ninja, Makefiles), propagate build type if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Where to build/install inside the superbuild tree +set(_tetgen_src "${CMAKE_BINARY_DIR}/Externals/Source/Tetgen_external") +set(_tetgen_bin "${CMAKE_BINARY_DIR}/Externals/Build/Tetgen_external") +set(_tetgen_inst "${CMAKE_BINARY_DIR}/Externals/Install/Tetgen_external") + ExternalProject_Add(Tetgen_external - URL "https://github.com/CIBC-Internal/SCIRunTestData/releases/download/test/tetgen1.5.1-beta1.tar.gz" - PATCH_COMMAND "" + GIT_REPOSITORY https://github.com/CIBC-Internal/TetGen.git + GIT_TAG v1.6.1 # or your tag like v1.6.0-scirun1 + UPDATE_DISCONNECTED 1 # speed up: don't ping remote every run + + SOURCE_DIR ${_tetgen_src} + BINARY_DIR ${_tetgen_bin} - CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - CMAKE_ARGS ${_cmake_args} + CMAKE_ARGS ${_cmake_args} - # Skip install entirely - INSTALL_COMMAND "" + # We direct outputs to , so a separate "install" step is unnecessary. + INSTALL_COMMAND "" - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -ExternalProject_Get_Property(Tetgen_external SOURCE_DIR INSTALL_DIR) -message(STATUS "[Tetgen_external] INSTALL_DIR=${INSTALL_DIR}") +# Exported properties/variables for SCIRun's internal CMake +ExternalProject_Get_Property(Tetgen_external SOURCE_DIR) +set(TETGEN_SOURCE_DIR ${SOURCE_DIR}) -# Tetgen headers live in the source tree -set(TETGEN_INCLUDE ${SOURCE_DIR}) -set(TETGEN_LIBRARY_DIR ${INSTALL_DIR}/lib) -set(TETGEN_LIBRARY "tet") # static or shared, same name root +# Mirror used above so downstream knows where to look +set(TETGEN_INSTALL_DIR ${_tetgen_inst}) +set(TETGEN_INCLUDE ${TETGEN_SOURCE_DIR}) # headers live in tree for TetGen +set(TETGEN_LIBRARY_DIR ${TETGEN_INSTALL_DIR}/lib) +set(TETGEN_LIBRARY "tet") # adjust if your CMakeLists names it differently -set(TETGEN_USE_FILE ${INSTALL_DIR}/UseTetgen.cmake) -set(Tetgen_DIR ${INSTALL_DIR} CACHE PATH "") - -# If you have these files, you can still generate them: +# (Optional) generate simple config/use files for downstream +file(MAKE_DIRECTORY "${TETGEN_INSTALL_DIR}") configure_file(${SUPERBUILD_DIR}/TetgenConfig.cmake.in - ${INSTALL_DIR}/TetgenConfig.cmake @ONLY) - + ${TETGEN_INSTALL_DIR}/TetgenConfig.cmake @ONLY) configure_file(${SUPERBUILD_DIR}/UseTetgen.cmake - ${TETGEN_USE_FILE} COPYONLY) \ No newline at end of file + ${TETGEN_INSTALL_DIR}/UseTetgen.cmake COPYONLY) + +# Cache hints for find_package(... CONFIG) +set(Tetgen_DIR ${TETGEN_INSTALL_DIR} CACHE PATH "") +message(STATUS "[Tetgen_external] INSTALL_DIR=${TETGEN_INSTALL_DIR}") From 64ec7130309e5288fecf45b6ceac725b567915e5 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 27 Jan 2026 15:02:53 -0700 Subject: [PATCH 010/140] removed errors from cleaver2 --- Superbuild/Cleaver2External.cmake | 64 +++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/Superbuild/Cleaver2External.cmake b/Superbuild/Cleaver2External.cmake index 1013aa0a6f..b6fda7e121 100644 --- a/Superbuild/Cleaver2External.cmake +++ b/Superbuild/Cleaver2External.cmake @@ -24,50 +24,72 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +# Cleaver2External.cmake (corrected + aligned with TetGen pattern) -# Cleaver2External.cmake (fixed) -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set(cleaver2_GIT_TAG "origin/master") +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -# Build up args in a list; only add platform/toolset when non-empty. +# Version tag for Cleaver2 +set(cleaver2_GIT_TAG "v2.0.1") # or your new tag like v2.0.1-scirun1 + +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_cleaver2_src "${CMAKE_BINARY_DIR}/Externals/Source/Cleaver2_external") +set(_cleaver2_bin "${CMAKE_BINARY_DIR}/Externals/Build/Cleaver2_external") +set(_cleaver2_inst "${CMAKE_BINARY_DIR}/Externals/Install/Cleaver2_external") + ExternalProject_Add(Cleaver2_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Cleaver2Library.git" GIT_TAG ${cleaver2_GIT_TAG} - PATCH_COMMAND "" + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_cleaver2_src} + BINARY_DIR ${_cleaver2_bin} - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # --- Explicit build --- - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # --- Explicit install --- - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config - + # Outputs already redirected -> skip install + INSTALL_COMMAND "" + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -ExternalProject_Get_Property(Cleaver2_external INSTALL_DIR) -message(STATUS "[Cleaver2_external] INSTALL_DIR=${INSTALL_DIR}") +# Export properties for SCIRun +ExternalProject_Get_Property(Cleaver2_external SOURCE_DIR) +set(CLEAVER2_SOURCE_DIR ${SOURCE_DIR}) + +set(CLEAVER2_INSTALL_DIR ${_cleaver2_inst}) +set(CLEAVER2_INCLUDE ${CLEAVER2_SOURCE_DIR}/src) # Cleaver2 headers live in src/ +set(CLEAVER2_LIBRARY_DIR ${CLEAVER2_INSTALL_DIR}/lib) +set(CLEAVER2_LIBRARY "cleaver2") # matches add_library(cleaver2 ...) + +message(STATUS "[Cleaver2_external] INSTALL_DIR=${CLEAVER2_INSTALL_DIR}") From f5ef94d0edc21f539f14e147f1f3e3abe5658126 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 27 Jan 2026 16:30:44 -0700 Subject: [PATCH 011/140] updating external cmakes added tags for repos in cibc-internal and use tags to download src --- Superbuild/FreetypeExternal.cmake | 63 ++++++++++++++-------- Superbuild/GlewExternal.cmake | 65 ++++++++++++++--------- Superbuild/QwtExternal.cmake | 86 ++++++++++++++----------------- Superbuild/SQLiteExternal.cmake | 57 ++++++++++++-------- Superbuild/TeemExternal.cmake | 66 +++++++++++++++--------- Superbuild/ZlibExternal.cmake | 60 ++++++++++++++------- 6 files changed, 239 insertions(+), 158 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index c06708c447..9cf6210a7f 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -25,50 +25,69 @@ # DEALINGS IN THE SOFTWARE. -# FreetypeExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set(freetype_GIT_TAG "origin/seg3d_external_test") +# FreetypeExternal.cmake (modernized + consistent) -# Build up args in a list; only add platform/toolset when non-empty. +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +set(freetype_GIT_TAG "v1.0.1") + +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_freetype_src "${CMAKE_BINARY_DIR}/Externals/Source/Freetype_external") +set(_freetype_bin "${CMAKE_BINARY_DIR}/Externals/Build/Freetype_external") +set(_freetype_inst "${CMAKE_BINARY_DIR}/Externals/Install/Freetype_external") + ExternalProject_Add(Freetype_external GIT_REPOSITORY "https://github.com/CIBC-Internal/freetype.git" - GIT_TAG ${freetype_GIT_TAG} - PATCH_COMMAND "" + GIT_TAG ${freetype_GIT_TAG} + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_freetype_src} + BINARY_DIR ${_freetype_bin} - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # --- Explicit build step --- - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # --- Explicit install step --- - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config + # Outputs already redirected -> skip install + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Debug info -ExternalProject_Get_Property(Freetype_external INSTALL_DIR) -message(STATUS "[Freetype_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun +set(FREETYPE_SOURCE_DIR ${_freetype_src}) +set(FREETYPE_INSTALL_DIR ${_freetype_inst}) +set(FREETYPE_INCLUDE ${FREETYPE_SOURCE_DIR}/include) +set(FREETYPE_LIBRARY_DIR ${FREETYPE_INSTALL_DIR}/lib) +set(FREETYPE_LIBRARY "freetype") + +message(STATUS "[Freetype_external] INSTALL_DIR=${FREETYPE_INSTALL_DIR}") diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index 14555e1383..f403660766 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -25,54 +25,69 @@ # DEALINGS IN THE SOFTWARE. -# GlewExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set(glew_GIT_TAG "origin/master") +# GlewExternal.cmake (modernized + consistent) -if(TRAVIS_BUILD) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") -endif() +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +set(glew_GIT_TAG "v1.0.1") -# Build up args in a list; only add platform/toolset when non-empty. +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_glew_src "${CMAKE_BINARY_DIR}/Externals/Source/Glew_external") +set(_glew_bin "${CMAKE_BINARY_DIR}/Externals/Build/Glew_external") +set(_glew_inst "${CMAKE_BINARY_DIR}/Externals/Install/Glew_external") + ExternalProject_Add(Glew_external GIT_REPOSITORY "https://github.com/CIBC-Internal/glew.git" - GIT_TAG ${glew_GIT_TAG} - PATCH_COMMAND "" + GIT_TAG ${glew_GIT_TAG} + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_glew_src} + BINARY_DIR ${_glew_bin} - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # --- Explicit build step --- - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # --- Explicit install step --- - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config + # Outputs already redirected -> skip install + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -ExternalProject_Get_Property(Glew_external INSTALL_DIR) -message(STATUS "[Glew_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun +set(GLEW_SOURCE_DIR ${_glew_src}) +set(GLEW_INSTALL_DIR ${_glew_inst}) +set(GLEW_INCLUDE ${GLEW_SOURCE_DIR}/include) +set(GLEW_LIBRARY_DIR ${GLEW_INSTALL_DIR}/lib) +set(GLEW_LIBRARY "glew") + +message(STATUS "[Glew_external] INSTALL_DIR=${GLEW_INSTALL_DIR}") diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index 136c0c1752..df73a6f755 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -25,77 +25,69 @@ # DEALINGS IN THE SOFTWARE. -# QwtExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) - -# Common cache args -set(QWT_CACHE_ARGS - "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" - "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" - "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" - "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" -) +# QwtExternal.cmake (modernized + consistent) -# Sanity check -if (NOT IS_DIRECTORY "${Qt_PATH}") - message(FATAL_ERROR "Qt_PATH is invalid or not set: ${Qt_PATH}") -endif() +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -# Help Qwt find Qt -list(APPEND QWT_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${Qt_PATH}") - -# Choose Qt major and tag + give one primary hint -if (SCIRUN_QT_MAJOR STREQUAL "6") - list(APPEND QWT_CACHE_ARGS "-DQt6_DIR:PATH=${Qt_PATH}/lib/cmake/Qt6") - set(qwt_GIT_TAG "origin/qt6-static-6.2.0") -elseif (SCIRUN_QT_MAJOR STREQUAL "5") - list(APPEND QWT_CACHE_ARGS "-DQt5_DIR:PATH=${Qt_PATH}/lib/cmake/Qt5") - set(qwt_GIT_TAG "origin/qt5-static-6.1.5") -else() - message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Current value: ${SCIRUN_QT_MAJOR}") -endif() +set(qwt_GIT_TAG "v1.0.1") -list(APPEND QWT_CACHE_ARGS "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}") - -# Build up args in a list; only add platform/toolset when non-empty. +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_qwt_src "${CMAKE_BINARY_DIR}/Externals/Source/Qwt_external") +set(_qwt_bin "${CMAKE_BINARY_DIR}/Externals/Build/Qwt_external") +set(_qwt_inst "${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external") + ExternalProject_Add(Qwt_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt.git" - GIT_TAG ${qwt_GIT_TAG} - PATCH_COMMAND "" + GIT_TAG ${qwt_GIT_TAG} + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_qwt_src} + BINARY_DIR ${_qwt_bin} - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # --- Explicit build --- - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # --- Explicit install --- - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config + # Outputs already redirected -> skip install + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -ExternalProject_Get_Property(Qwt_external INSTALL_DIR) -message(STATUS "[Qwt_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun +set(QWT_SOURCE_DIR ${_qwt_src}) +set(QWT_INSTALL_DIR ${_qwt_inst}) +set(QWT_INCLUDE ${QWT_SOURCE_DIR}/src) +set(QWT_LIBRARY_DIR ${QWT_INSTALL_DIR}/lib) +set(QWT_LIBRARY "qwt") + +message(STATUS "[Qwt_external] INSTALL_DIR=${QWT_INSTALL_DIR}") diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index ca67d1fa06..e2fe1ce13e 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -25,50 +25,65 @@ # DEALINGS IN THE SOFTWARE. -# SQLiteExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set(sqlite_GIT_TAG "origin/master") +# SQLiteExternal.cmake (modernized + consistent) -# Build up args in a list; only add platform/toolset when non-empty. +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +set(sqlite_GIT_TAG "v3.0.1") + +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_sqlite_src "${CMAKE_BINARY_DIR}/Externals/Source/SQLite_external") +set(_sqlite_bin "${CMAKE_BINARY_DIR}/Externals/Build/SQLite_external") +set(_sqlite_inst "${CMAKE_BINARY_DIR}/Externals/Install/SQLite_external") + ExternalProject_Add(SQLite_external GIT_REPOSITORY "https://github.com/CIBC-Internal/sqlite.git" GIT_TAG ${sqlite_GIT_TAG} - PATCH_COMMAND "" + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_sqlite_src} + BINARY_DIR ${_sqlite_bin} - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # Explicit build - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # Explicit install - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config + # Outputs already redirected -> skip install + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Trace the resolved install prefix (your helper will scan from here) -ExternalProject_Get_Property(SQLite_external INSTALL_DIR) -message(STATUS "[SQLite_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun +set(SQLITE_SOURCE_DIR ${_sqlite_src}) +set(SQLITE_INSTALL_DIR ${_sqlite_inst}) +set(SQLITE_INCLUDE \ No newline at end of file diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index d342649d3d..277fa70083 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -25,51 +25,71 @@ # DEALINGS IN THE SOFTWARE. -# TeemExternal.cmake (fixed) -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set(teem_GIT_TAG "origin/adjust-png") +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +# Version/tag for Teem +set(teem_GIT_TAG "v1.11.1") set(teem_DEPENDENCIES Zlib_external) -# Build up args in a list; only add platform/toolset when non-empty. +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_teem_src "${CMAKE_BINARY_DIR}/Externals/Source/Teem_external") +set(_teem_bin "${CMAKE_BINARY_DIR}/Externals/Build/Teem_external") +set(_teem_inst "${CMAKE_BINARY_DIR}/Externals/Install/Teem_external") + ExternalProject_Add(Teem_external DEPENDS ${teem_DEPENDENCIES} - GIT_REPOSITORY "https://github.com/SCIInstitute/teem.git" - GIT_TAG ${teem_GIT_TAG} - PATCH_COMMAND "" - - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + + GIT_REPOSITORY "https://github.com/CIBC-Internal/teem.git" + GIT_TAG ${teem_GIT_TAG} + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_teem_src} + BINARY_DIR ${_teem_bin} + + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # --- Explicit build step --- - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # --- Explicit install step --- - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config + # Outputs already redirected -> skip install + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -ExternalProject_Get_Property(Teem_external INSTALL_DIR) -message(STATUS "[Teem_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun +set(TEEM_SOURCE_DIR ${_teem_src}) +set(TEEM_INSTALL_DIR ${_teem_inst}) +set(TEEM_INCLUDE ${TEEM_SOURCE_DIR}/src) # Teem headers live in source tree +set(TEEM_LIBRARY_DIR ${TEEM_INSTALL_DIR}/lib) +set(TEEM_LIBRARY "teem") + +message(STATUS "[Teem_external] INSTALL_DIR=${TEEM_INSTALL_DIR}") diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index a40b2aa314..878825699c 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -25,49 +25,69 @@ # DEALINGS IN THE SOFTWARE. -# ZlibExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set(zlib_GIT_TAG "origin/master") +# ZlibExternal.cmake (modernized + consistent) -# Build up args in a list; only add platform/toolset when non-empty. +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +set(zlib_GIT_TAG "v1.2.8") + +# Common CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + + # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin + + # Multi-config (VS) + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# Visual Studio generators are multi-config; don't force CMAKE_BUILD_TYPE +# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() +# Superbuild directories +set(_zlib_src "${CMAKE_BINARY_DIR}/Externals/Source/Zlib_external") +set(_zlib_bin "${CMAKE_BINARY_DIR}/Externals/Build/Zlib_external") +set(_zlib_inst "${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external") + ExternalProject_Add(Zlib_external GIT_REPOSITORY "https://github.com/CIBC-Internal/zlib.git" GIT_TAG ${zlib_GIT_TAG} - PATCH_COMMAND "" + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_zlib_src} + BINARY_DIR ${_zlib_bin} - # Use the built-in generator handling - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - # Only add these if they are set in the parent build - # (CMake treats empty values as "not present") + CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Normal CMake cache/args CMAKE_ARGS ${_cmake_args} - # --- EXPLICIT BUILD --- - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config - - # --- EXPLICIT INSTALL (portable; does not depend on a VS "INSTALL" project) --- - INSTALL_COMMAND - ${CMAKE_COMMAND} --install --config + # Outputs already redirected -> skip install + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -ExternalProject_Get_Property(Zlib_external INSTALL_DIR) -message(STATUS "[Zlib_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun +set(ZLIB_SOURCE_DIR ${_zlib_src}) +set(ZLIB_INSTALL_DIR ${_zlib_inst}) +set(ZLIB_INCLUDE ${ZLIB_SOURCE_DIR}) # zlib headers live in source root +set(ZLIB_LIBRARY_DIR ${ZLIB_INSTALL_DIR}/lib) +set(ZLIB_LIBRARY "zlib") # matches add_library(zlib ...) + +message(STATUS "[Zlib_external] INSTALL_DIR=${ZLIB_INSTALL_DIR}") From 336571da390819b48a4ab8d2a3b2ab3d516233cf Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 29 Jan 2026 10:49:07 -0700 Subject: [PATCH 012/140] external cmakes --- Superbuild/SQLiteExternal.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index e2fe1ce13e..f323e73adf 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -86,4 +86,8 @@ ExternalProject_Add(SQLite_external # Export variables for SCIRun set(SQLITE_SOURCE_DIR ${_sqlite_src}) set(SQLITE_INSTALL_DIR ${_sqlite_inst}) -set(SQLITE_INCLUDE \ No newline at end of file +set(SQLITE_INCLUDE ${SQLITE_SOURCE_DIR}) # sqlite3.h lives in source root +set(SQLITE_LIBRARY_DIR ${SQLITE_INSTALL_DIR}/lib) +set(SQLITE_LIBRARY "sqlite") + +message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") From 056c4d13deb5a23af80992e2959f0e55e43a1bc0 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 29 Jan 2026 11:47:09 -0700 Subject: [PATCH 013/140] fixing freetype --- Superbuild/FreetypeExternal.cmake | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 9cf6210a7f..10149935ec 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -29,9 +29,9 @@ set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -set(freetype_GIT_TAG "v1.0.1") +set(freetype_GIT_TAG "v2.14.1") -# Common CMake args +# Common CMake args (keep yours) set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON @@ -49,6 +49,17 @@ set(_cmake_args -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin + + # --- Make FreeType use *your* zlib --- + -DFT_REQUIRE_ZLIB=ON + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE} + -DZLIB_LIBRARY=${_zlib_lib} + + # --- Start minimal: disable other optional deps for now --- + -DFT_DISABLE_BZIP2=ON + -DFT_DISABLE_PNG=ON + -DFT_DISABLE_BROTLI=ON + -DFT_DISABLE_HARFBUZZ=ON ) # Single-config generators @@ -75,6 +86,9 @@ ExternalProject_Add(Freetype_external CMAKE_ARGS ${_cmake_args} + # Ensure zlib builds first + DEPENDS Zlib_external + # Outputs already redirected -> skip install INSTALL_COMMAND "" @@ -83,11 +97,10 @@ ExternalProject_Add(Freetype_external LOG_INSTALL 1 ) -# Export variables for SCIRun +# Export variables for SCIRun (consumer side) set(FREETYPE_SOURCE_DIR ${_freetype_src}) set(FREETYPE_INSTALL_DIR ${_freetype_inst}) -set(FREETYPE_INCLUDE ${FREETYPE_SOURCE_DIR}/include) +set(FREETYPE_INCLUDE ${FREETYPE_SOURCE_DIR}/include) # FreeType's public headers live in source/include set(FREETYPE_LIBRARY_DIR ${FREETYPE_INSTALL_DIR}/lib) -set(FREETYPE_LIBRARY "freetype") - +set(FREETYPE_LIBRARY "freetype") # basename (actual file becomes freetype.lib/libfreetype.a) message(STATUS "[Freetype_external] INSTALL_DIR=${FREETYPE_INSTALL_DIR}") From 7b788d514d6760fa9203ae66e4fa9a796b217183 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 29 Jan 2026 13:48:42 -0700 Subject: [PATCH 014/140] making cmake changes --- Superbuild/FreetypeExternal.cmake | 47 ++++++++++++----------- Superbuild/ZlibExternal.cmake | 62 +++++++++++++++++++++---------- 2 files changed, 66 insertions(+), 43 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 10149935ec..4fdb1c2f98 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -27,35 +27,26 @@ # FreetypeExternal.cmake (modernized + consistent) +# FreetypeExternal.cmake — use installed zlib via CMAKE_PREFIX_PATH + set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(freetype_GIT_TAG "v2.14.1") -# Common CMake args (keep yours) +# Common CMake args for FreeType +# NOTE: +# - We no longer need to redirect all output dirs when using find_package(). +# - We pass CMAKE_PREFIX_PATH to point at the installed zlib prefix. set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - - # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin - - # --- Make FreeType use *your* zlib --- + + # Make FreeType use the zlib we installed in its own external + -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR} -DFT_REQUIRE_ZLIB=ON - -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE} - -DZLIB_LIBRARY=${_zlib_lib} - # --- Start minimal: disable other optional deps for now --- + # Start minimal to avoid surprise dependencies during bring-up -DFT_DISABLE_BZIP2=ON -DFT_DISABLE_PNG=ON -DFT_DISABLE_BROTLI=ON @@ -86,10 +77,10 @@ ExternalProject_Add(Freetype_external CMAKE_ARGS ${_cmake_args} - # Ensure zlib builds first + # Ensure zlib is fully built & installed before configuring FreeType DEPENDS Zlib_external - # Outputs already redirected -> skip install + # Keep FreeType in "no-install" mode for now (you can enable later if desired) INSTALL_COMMAND "" LOG_CONFIGURE 1 @@ -100,7 +91,15 @@ ExternalProject_Add(Freetype_external # Export variables for SCIRun (consumer side) set(FREETYPE_SOURCE_DIR ${_freetype_src}) set(FREETYPE_INSTALL_DIR ${_freetype_inst}) -set(FREETYPE_INCLUDE ${FREETYPE_SOURCE_DIR}/include) # FreeType's public headers live in source/include + +# Public headers for consumers are under source/include +set(FREETYPE_INCLUDE ${FREETYPE_SOURCE_DIR}/include) + +# Libraries land here if you later enable FreeType's install; +# with INSTALL_COMMAND "" it remains empty, but we keep the var for consistency. set(FREETYPE_LIBRARY_DIR ${FREETYPE_INSTALL_DIR}/lib) -set(FREETYPE_LIBRARY "freetype") # basename (actual file becomes freetype.lib/libfreetype.a) -message(STATUS "[Freetype_external] INSTALL_DIR=${FREETYPE_INSTALL_DIR}") + +# Basename (actual file becomes freetype.lib / libfreetype.a / libfreetype.{so,dylib}) +set(FREETYPE_LIBRARY "freetype") + +message(STATUS "[Freetype_external] INSTALL_DIR=${FREETYPE_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index 878825699c..af563d880a 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -27,28 +27,22 @@ # ZlibExternal.cmake (modernized + consistent) +# ZlibExternal.cmake — installs zlib and exports an installed prefix for consumers + set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(zlib_GIT_TAG "v1.2.8") -# Common CMake args +# Common CMake args for the external +# NOTE: We intentionally DO NOT redirect output directories here, +# so that `cmake --install` produces a normal layout. set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - - # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin + + # If your zlib source honors BUILD_SHARED_LIBS, uncomment to force static: + # -DBUILD_SHARED_LIBS=OFF ) # Single-config generators @@ -75,19 +69,49 @@ ExternalProject_Add(Zlib_external CMAKE_ARGS ${_cmake_args} - # Outputs already redirected -> skip install - INSTALL_COMMAND "" + # Run the install step for this external (required for Fix B) + INSTALL_COMMAND "${CMAKE_COMMAND}" --build . --target install LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Export variables for SCIRun +# ---------------------------------------------------------------------- +# Export variables for downstream projects (FreeType, SCIRun, etc.) +# Expect a standard install layout: +# /include/{zlib.h,zconf.h} +# /lib/{z.lib|libz.a|libz.so|libz.dylib} +# ---------------------------------------------------------------------- set(ZLIB_SOURCE_DIR ${_zlib_src}) set(ZLIB_INSTALL_DIR ${_zlib_inst}) -set(ZLIB_INCLUDE ${ZLIB_SOURCE_DIR}) # zlib headers live in source root + +# Public headers for consumers (FreeType only needs zlib.h) +set(ZLIB_INCLUDE ${ZLIB_INSTALL_DIR}/include) + +# Library directory set(ZLIB_LIBRARY_DIR ${ZLIB_INSTALL_DIR}/lib) -set(ZLIB_LIBRARY "zlib") # matches add_library(zlib ...) + +# Pick the most likely library filename for each platform +if(WIN32) + # Your custom zlib typically names the static lib 'z.lib'. + set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/z.lib") +elseif(APPLE) + # Prefer shared if present, otherwise static + if(EXISTS "${ZLIB_LIBRARY_DIR}/libz.dylib") + set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.dylib") + else() + set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.a") + endif() +else() + # Linux/*nix: prefer shared if present, otherwise static + if(EXISTS "${ZLIB_LIBRARY_DIR}/libz.so") + set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.so") + else() + set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.a") + endif() +endif() message(STATUS "[Zlib_external] INSTALL_DIR=${ZLIB_INSTALL_DIR}") +message(STATUS "[Zlib_external] INCLUDE=${ZLIB_INCLUDE}") +message(STATUS "[Zlib_external] LIB=${ZLIB_LIBRARY}") \ No newline at end of file From 5efaeb817ff0f9bcd2d764eb0b857bc993971819 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 29 Jan 2026 17:02:15 -0700 Subject: [PATCH 015/140] fixing dependency on zlib for external libs --- Superbuild/FreetypeExternal.cmake | 45 +++++++++++-- Superbuild/QwtExternal.cmake | 103 +++++++++++++++++++----------- Superbuild/Superbuild.cmake | 102 ++++++++++++++++++++++++++++- Superbuild/TeemExternal.cmake | 80 +++++++++++++++-------- Superbuild/ZlibExternal.cmake | 72 ++++++++++----------- 5 files changed, 292 insertions(+), 110 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 4fdb1c2f98..4b32e776d4 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -63,6 +63,7 @@ set(_freetype_src "${CMAKE_BINARY_DIR}/Externals/Source/Freetype_external") set(_freetype_bin "${CMAKE_BINARY_DIR}/Externals/Build/Freetype_external") set(_freetype_inst "${CMAKE_BINARY_DIR}/Externals/Install/Freetype_external") +# --- FreeType external --- ExternalProject_Add(Freetype_external GIT_REPOSITORY "https://github.com/CIBC-Internal/freetype.git" GIT_TAG ${freetype_GIT_TAG} @@ -75,12 +76,32 @@ ExternalProject_Add(Freetype_external CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - CMAKE_ARGS ${_cmake_args} - - # Ensure zlib is fully built & installed before configuring FreeType + # Use CMAKE_CACHE_ARGS so hints are written into FreeType's *own* CMake cache + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DCMAKE_INSTALL_PREFIX:PATH= + + # Point find_package(ZLIB) to zlib's install prefix + -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} + + # Belt-and-suspenders explicit hints (kept as CACHE so FreeType's run sees them) + -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} + -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include + # If you computed a best-guess lib path in Superbuild.cmake, pass it here: + # -DZLIB_LIBRARY:FILEPATH=${_ZLIB_LIB} + + # Minimal deps while bringing up + -DFT_REQUIRE_ZLIB:BOOL=ON + -DFT_DISABLE_BZIP2:BOOL=ON + -DFT_DISABLE_PNG:BOOL=ON + -DFT_DISABLE_BROTLI:BOOL=ON + -DFT_DISABLE_HARFBUZZ:BOOL=ON + + # Build order at the target level DEPENDS Zlib_external - # Keep FreeType in "no-install" mode for now (you can enable later if desired) + # Keep FreeType "no-install" for now (enable later if desired) INSTALL_COMMAND "" LOG_CONFIGURE 1 @@ -88,6 +109,22 @@ ExternalProject_Add(Freetype_external LOG_INSTALL 1 ) +# --- Force FreeType 'configure' to wait for zlib's actual files --- +# This prevents configure from running before zlib installs headers/libs. +ExternalProject_Add_Step(Freetype_external wait_for_zlib + COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts..." + DEPENDEES download + DEPENDERS configure + DEPENDS + "${ZLIB_INSTALL_DIR}/include/zlib.h" + "${ZLIB_INSTALL_DIR}/include/zconf.h" + # Pick one that matches what you build on each platform: + "${ZLIB_INSTALL_DIR}/lib/z.lib" # Windows static + # "${ZLIB_INSTALL_DIR}/lib/libz.a" # Unix static (if that’s what you build) + # "${ZLIB_INSTALL_DIR}/lib/libz.so" # Linux shared + # "${ZLIB_INSTALL_DIR}/lib/libz.dylib" # macOS shared +) + # Export variables for SCIRun (consumer side) set(FREETYPE_SOURCE_DIR ${_freetype_src}) set(FREETYPE_INSTALL_DIR ${_freetype_inst}) diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index df73a6f755..d17485c31c 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -25,69 +25,94 @@ # DEALINGS IN THE SOFTWARE. -# QwtExternal.cmake (modernized + consistent) +# QwtExternal.cmake — build Qwt 6.3.0 with qmake from the superbuild set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -set(qwt_GIT_TAG "v1.0.1") - -# Common CMake args -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - - # Redirect all outputs so install step is unnecessary - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin -) - -# Single-config generators -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -endif() +# Your mirror/tag +set(qwt_GIT_TAG "v6.3.0") # Superbuild directories set(_qwt_src "${CMAKE_BINARY_DIR}/Externals/Source/Qwt_external") set(_qwt_bin "${CMAKE_BINARY_DIR}/Externals/Build/Qwt_external") set(_qwt_inst "${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external") +# -------- Select build tool per platform -------- +if(WIN32) + # Prefer jom if available; otherwise nmake + find_program(JOM_EXECUTABLE NAMES jom PATHS ENV PATH NO_DEFAULT_PATH) + if(NOT JOM_EXECUTABLE) + find_program(JOM_EXECUTABLE NAMES jom) + endif() + if(JOM_EXECUTABLE) + set(_MAKE_TOOL "${JOM_EXECUTABLE}") + else() + set(_MAKE_TOOL "nmake") + endif() +else() + # make or gmake; ExternalProject will run it in the source tree where qmake generates Makefiles + find_program(MAKE_EXECUTABLE NAMES make gmake) + if(NOT MAKE_EXECUTABLE) + message(FATAL_ERROR "No 'make' tool found for building Qwt.") + endif() + set(_MAKE_TOOL "${MAKE_EXECUTABLE}") +endif() + +# -------- Require the Qt qmake path -------- +if(NOT DEFINED QT_QMAKE_EXECUTABLE OR NOT EXISTS "${QT_QMAKE_EXECUTABLE}") + message(FATAL_ERROR "QT_QMAKE_EXECUTABLE is not set to a valid Qt qmake path (Qt 5/6).") +endif() + +# Qwt’s qmake accepts PREFIX/INSTALLBASE to control where it installs. +# We pass both to cover different setups. +set(_QMAKE_CONFIG + "${QT_QMAKE_EXECUTABLE}" + "qwt.pro" + "PREFIX=${_qwt_inst}" + "INSTALLBASE=${_qwt_inst}" +) + +# Note: +# - We *don’t* set CMAKE_*_OUTPUT_DIRECTORY here—qmake controls build dirs. +# - We *do* run an actual install so downstream consumers get include/lib/plugin layout. + ExternalProject_Add(Qwt_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt.git" - GIT_TAG ${qwt_GIT_TAG} + GIT_TAG ${qwt_GIT_TAG} # v6.3.0 in your setup UPDATE_DISCONNECTED 1 SOURCE_DIR ${_qwt_src} - BINARY_DIR ${_qwt_bin} + BINARY_DIR ${_qwt_bin} # not used by qmake; kept for symmetry/logs - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + # --- Configure: run qmake in the source dir so it finds qwt.pro --- + CONFIGURE_COMMAND + ${CMAKE_COMMAND} -E chdir ${_qwt_src} + "${QT_QMAKE_EXECUTABLE}" qwt.pro + "PREFIX=${_qwt_inst}" + "INSTALLBASE=${_qwt_inst}" - CMAKE_ARGS ${_cmake_args} + # --- Build: run the chosen make tool in the same source dir --- + BUILD_COMMAND + ${CMAKE_COMMAND} -E chdir ${_qwt_src} ${_MAKE_TOOL} - # Outputs already redirected -> skip install - INSTALL_COMMAND "" + # --- Install: same directory (qmake’s Makefile target `install`) --- + INSTALL_COMMAND + ${CMAKE_COMMAND} -E chdir ${_qwt_src} ${_MAKE_TOOL} install LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Export variables for SCIRun +# ------- Export variables for SCIRun / downstream ------- set(QWT_SOURCE_DIR ${_qwt_src}) set(QWT_INSTALL_DIR ${_qwt_inst}) -set(QWT_INCLUDE ${QWT_SOURCE_DIR}/src) -set(QWT_LIBRARY_DIR ${QWT_INSTALL_DIR}/lib) + +# Qwt installs headers under include/ (often include/qwt-6.3.0) and libs under lib/ +set(QWT_INCLUDE "${QWT_INSTALL_DIR}/include") +set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") + +# Library base name (actual file is qwt.lib / libqwt.a / libqwt.{so,dylib}) set(QWT_LIBRARY "qwt") -message(STATUS "[Qwt_external] INSTALL_DIR=${QWT_INSTALL_DIR}") +message(STATUS "[Qwt_external] INSTALL_DIR=${QWT_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 8c781e2e95..ae47420621 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -156,6 +156,46 @@ if (NOT BUILD_HEADLESS) message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'.") endif() + if(SCIRUN_QT_MAJOR STREQUAL "6") + if(TARGET Qt6::qmake) + get_target_property(_qmake_path Qt6::qmake LOCATION) + else() + # Fallback: derive from Qt6_DIR if the qmake target is missing + # Qt6_DIR typically points to .../lib/cmake/Qt6 + # qmake is usually under the corresponding bin/ + get_filename_component(_qt6_cmake_dir "${Qt6_DIR}" DIRECTORY) # .../lib/cmake + get_filename_component(_qt6_prefix "${_qt6_cmake_dir}" DIRECTORY) # .../lib + get_filename_component(_qt6_root "${_qt6_prefix}" DIRECTORY) # ... + if(WIN32) + set(_qmake_path "${_qt6_root}/bin/qmake.exe") + else() + set(_qmake_path "${_qt6_root}/bin/qmake") + endif() + endif() + elseif(SCIRUN_QT_MAJOR STREQUAL "5") + if(TARGET Qt5::qmake) + get_target_property(_qmake_path Qt5::qmake LOCATION) + else() + get_filename_component(_qt5_cmake_dir "${Qt5_DIR}" DIRECTORY) + get_filename_component(_qt5_prefix "${_qt5_cmake_dir}" DIRECTORY) + get_filename_component(_qt5_root "${_qt5_prefix}" DIRECTORY) + if(WIN32) + set(_qmake_path "${_qt5_root}/bin/qmake.exe") + else() + set(_qmake_path "${_qt5_root}/bin/qmake") + endif() + endif() + endif() + + # Validate and publish for QwtExternal.cmake to use + if(NOT _qmake_path OR NOT EXISTS "${_qmake_path}") + message(FATAL_ERROR "Could not locate qmake. Checked: ${_qmake_path}") + endif() + + # Make it visible to the external (cache it so EPs see it in their configure env) + set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH "Path to Qt qmake for building Qwt" FORCE) + + message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") else() add_definitions(-DBUILD_HEADLESS) endif() @@ -328,7 +368,67 @@ endif() _export_config_dir(Zlib Zlib_external "") _export_config_dir(Freetype Freetype_external "") _export_config_dir(SQLite SQLite_external "") -_export_config_dir(Qwt Qwt_external "") + +# Qwt: do not try to 'find' files at configure time; define an imported target +# that will point to the expected install location(s) and depend on the EP. + +# (Optional) This helper won't find anything for Qwt (no CMake config), but harmless +_export_config_dir(Qwt Qwt_external "") + +# Get the external's install prefix +ExternalProject_Get_Property(Qwt_external INSTALL_DIR) +set(QWT_INSTALL_DIR "${INSTALL_DIR}") + +# Include & lib dirs as installed by qmake +set(QWT_INCLUDE_DIR "${QWT_INSTALL_DIR}/include") +set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") + +# Create an imported target that *will* exist after the external builds. +# Use per-config locations on Windows to handle qwt.lib (Release) and qwtd.lib (Debug). +add_library(Qwt::Qwt UNKNOWN IMPORTED GLOBAL) +add_dependencies(Qwt::Qwt Qwt_external) + +# Include directories (Qwt typically installs headers under include/ or include/qwt-) +set_property(TARGET Qwt::Qwt PROPERTY + INTERFACE_INCLUDE_DIRECTORIES + "${QWT_INCLUDE_DIR}" +) + +if(WIN32) + # Windows/MSVC typically uses a 'd' suffix for Debug builds. + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_CONFIGURATIONS "Debug;Release") + + set_property(TARGET Qwt::Qwt PROPERTY + IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") + # Try qwtd.lib first; if your build produces qwt.lib for Debug too, you can + # set both to qwt.lib and it will still work. + set_property(TARGET Qwt::Qwt PROPERTY + IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") + + # If you prefer a single generator expression instead of config-specific props, + # you could do: + # set_property(TARGET Qwt::Qwt PROPERTY + # IMPORTED_LOCATION "$,${QWT_LIBRARY_DIR}/qwtd.lib,${QWT_LIBRARY_DIR}/qwt.lib>") +elseif(APPLE) + # Prefer shared if present, otherwise static (the file will appear at build time) + set_property(TARGET Qwt::Qwt PROPERTY + IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") + # Optional: provide a static fallback for environments that build static + # set_property(TARGET Qwt::Qwt PROPERTY + # IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.a") +else() + # Linux/*nix: prefer shared, static as fallback + # If you know you're building static-only, you can point straight to libqwt.a + set_property(TARGET Qwt::Qwt PROPERTY + IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.so") + # Optional static fallback: + # set_property(TARGET Qwt::Qwt PROPERTY + # IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.a") +endif() + +# IMPORTANT: Do not 'EXISTS'-check the files at configure time. They'll be created during build. +# Now consumers can safely link: +# target_link_libraries(SCIRunGui PRIVATE Qwt::Qwt) # GLEW: depends on its CMake; if it exports configs, use config; otherwise include/lib if(WIN32) diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index 277fa70083..c9423cc167 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -25,42 +25,41 @@ # DEALINGS IN THE SOFTWARE. +# TeemExternal.cmake — wire Teem to the installed zlib + set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -# Version/tag for Teem set(teem_GIT_TAG "v1.11.1") set(teem_DEPENDENCIES Zlib_external) -# Common CMake args +# Superbuild directories +set(_teem_src "${CMAKE_BINARY_DIR}/Externals/Source/Teem_external") +set(_teem_bin "${CMAKE_BINARY_DIR}/Externals/Build/Teem_external") +set(_teem_inst "${CMAKE_BINARY_DIR}/Externals/Install/Teem_external") + +# Teem CMake args (no output redirection needed) set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - - # Redirect all outputs so install step is unnecessary -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin + + # Make Teem find our installed zlib + -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR} + -DZLIB_ROOT=${ZLIB_INSTALL_DIR} + -DZLIB_INCLUDE_DIR=${ZLIB_INSTALL_DIR}/include + + # Start minimal: disable optional deps until zlib link works + # (Uncomment if these options exist in your Teem tree) + # -DTEEM_ZLIB=ON + # -DTEEM_PNG=OFF + # -DTEEM_BZIP2=OFF + # -DTEEM_FFTW=OFF ) -# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() -# Superbuild directories -set(_teem_src "${CMAKE_BINARY_DIR}/Externals/Source/Teem_external") -set(_teem_bin "${CMAKE_BINARY_DIR}/Externals/Build/Teem_external") -set(_teem_inst "${CMAKE_BINARY_DIR}/Externals/Install/Teem_external") - ExternalProject_Add(Teem_external DEPENDS ${teem_DEPENDENCIES} @@ -75,9 +74,18 @@ ExternalProject_Add(Teem_external CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - CMAKE_ARGS ${_cmake_args} - - # Outputs already redirected -> skip install + # Use CMAKE_CACHE_ARGS so Teem's *own* cache sees the hints + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} + -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} + -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include + # If you prefer to be explicit, also pass ZLIB_LIBRARY: + # -DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARY} + + # Keep Teem no-install for now; switch to install later if you want INSTALL_COMMAND "" LOG_CONFIGURE 1 @@ -85,11 +93,27 @@ ExternalProject_Add(Teem_external LOG_INSTALL 1 ) -# Export variables for SCIRun +# Make Teem's configure wait for zlib artifacts to exist +ExternalProject_Add_Step(Teem_external wait_for_zlib + COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts..." + DEPENDEES download + DEPENDERS configure + DEPENDS + "${ZLIB_INSTALL_DIR}/include/zlib.h" + "${ZLIB_INSTALL_DIR}/include/zconf.h" + "${ZLIB_INSTALL_DIR}/lib/z.lib" # Windows static + # "${ZLIB_INSTALL_DIR}/lib/libz.a" # Unix static (if that’s what you build) + # "${ZLIB_INSTALL_DIR}/lib/libz.so" # Linux shared + # "${ZLIB_INSTALL_DIR}/lib/libz.dylib" # macOS shared +) + +# Export variables for SCIRun (consumer side) set(TEEM_SOURCE_DIR ${_teem_src}) set(TEEM_INSTALL_DIR ${_teem_inst}) -set(TEEM_INCLUDE ${TEEM_SOURCE_DIR}/src) # Teem headers live in source tree -set(TEEM_LIBRARY_DIR ${TEEM_INSTALL_DIR}/lib) + +# If you keep Teem in no-install mode for now, public headers remain in source: +set(TEEM_INCLUDE ${TEEM_SOURCE_DIR}/src) +set(TEEM_LIBRARY_DIR ${TEEM_INSTALL_DIR}/lib) # will populate when/if you enable install set(TEEM_LIBRARY "teem") -message(STATUS "[Teem_external] INSTALL_DIR=${TEEM_INSTALL_DIR}") +message(STATUS "[Teem_external] INSTALL_DIR=${TEEM_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index af563d880a..af8059fca6 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -29,28 +29,24 @@ # ZlibExternal.cmake — installs zlib and exports an installed prefix for consumers +# ZlibExternal.cmake — install zlib and export a clean install prefix for consumers + set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(zlib_GIT_TAG "v1.2.8") -# Common CMake args for the external -# NOTE: We intentionally DO NOT redirect output directories here, -# so that `cmake --install` produces a normal layout. +# No output redirection; let install populate a normal prefix set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX= - - # If your zlib source honors BUILD_SHARED_LIBS, uncomment to force static: - # -DBUILD_SHARED_LIBS=OFF + # (optional) -DBUILD_SHARED_LIBS=OFF ) -# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() -# Superbuild directories set(_zlib_src "${CMAKE_BINARY_DIR}/Externals/Source/Zlib_external") set(_zlib_bin "${CMAKE_BINARY_DIR}/Externals/Build/Zlib_external") set(_zlib_inst "${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external") @@ -69,49 +65,49 @@ ExternalProject_Add(Zlib_external CMAKE_ARGS ${_cmake_args} - # Run the install step for this external (required for Fix B) + # Run install to produce a normal layout INSTALL_COMMAND "${CMAKE_COMMAND}" --build . --target install + # Tell the generator which files will exist before dependents configure + BUILD_BYPRODUCTS + "${_zlib_inst}/include/zlib.h" + "${_zlib_inst}/include/zconf.h" + "${_zlib_inst}/lib/z.lib" # Windows static (your custom build) + "${_zlib_inst}/lib/libz.a" # Unix static + "${_zlib_inst}/lib/libz.so" # Linux shared (if built) + "${_zlib_inst}/lib/libz.dylib" # macOS shared (if built) + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# ---------------------------------------------------------------------- -# Export variables for downstream projects (FreeType, SCIRun, etc.) -# Expect a standard install layout: -# /include/{zlib.h,zconf.h} -# /lib/{z.lib|libz.a|libz.so|libz.dylib} -# ---------------------------------------------------------------------- -set(ZLIB_SOURCE_DIR ${_zlib_src}) -set(ZLIB_INSTALL_DIR ${_zlib_inst}) +# ---------------- Export for other externals (FreeType, etc.) ---------------- +# Always export the install prefix and canonical include/lib dirs to the cache. +# IMPORTANT: do NOT test for file existence here — these files are built later. + +# 1) Install prefix +set(ZLIB_INSTALL_DIR "${_zlib_inst}" CACHE PATH "zlib install prefix" FORCE) -# Public headers for consumers (FreeType only needs zlib.h) -set(ZLIB_INCLUDE ${ZLIB_INSTALL_DIR}/include) +# 2) Include directory that contains zlib.h (this is what FindZLIB expects) +set(ZLIB_INCLUDE_DIR "${ZLIB_INSTALL_DIR}/include" CACHE PATH "zlib include dir" FORCE) -# Library directory -set(ZLIB_LIBRARY_DIR ${ZLIB_INSTALL_DIR}/lib) +# 3) Library directory (consumers may choose the exact filename later) +set(ZLIB_LIBRARY_DIR "${ZLIB_INSTALL_DIR}/lib" CACHE PATH "zlib library dir" FORCE) -# Pick the most likely library filename for each platform +# (Optional) Provide a best-guess library filename per platform *without* EXISTS checks. +# Consumers that need an exact file can adjust per their build (static/shared). if(WIN32) - # Your custom zlib typically names the static lib 'z.lib'. - set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/z.lib") + set(_ZLIB_LIB_GUESS "${ZLIB_LIBRARY_DIR}/z.lib") elseif(APPLE) - # Prefer shared if present, otherwise static - if(EXISTS "${ZLIB_LIBRARY_DIR}/libz.dylib") - set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.dylib") - else() - set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.a") - endif() + # prefer shared name; many toolchains will still produce libz.a if shared is off + set(_ZLIB_LIB_GUESS "${ZLIB_LIBRARY_DIR}/libz.dylib") else() - # Linux/*nix: prefer shared if present, otherwise static - if(EXISTS "${ZLIB_LIBRARY_DIR}/libz.so") - set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.so") - else() - set(ZLIB_LIBRARY "${ZLIB_LIBRARY_DIR}/libz.a") - endif() + set(_ZLIB_LIB_GUESS "${ZLIB_LIBRARY_DIR}/libz.so") endif() +set(ZLIB_LIBRARY "${_ZLIB_LIB_GUESS}" CACHE FILEPATH "zlib library (best guess)" FORCE) message(STATUS "[Zlib_external] INSTALL_DIR=${ZLIB_INSTALL_DIR}") -message(STATUS "[Zlib_external] INCLUDE=${ZLIB_INCLUDE}") -message(STATUS "[Zlib_external] LIB=${ZLIB_LIBRARY}") \ No newline at end of file +message(STATUS "[Zlib_external] INCLUDE_DIR=${ZLIB_INCLUDE_DIR}") +message(STATUS "[Zlib_external] LIB_DIR=${ZLIB_LIBRARY_DIR}") +message(STATUS "[Zlib_external] LIB_GUESS=${ZLIB_LIBRARY}") \ No newline at end of file From 1d869a5da8a582ec93e5070f27ba50d1513591e7 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 30 Jan 2026 15:08:43 -0700 Subject: [PATCH 016/140] fixing zlib interdependency --- Superbuild/FreetypeExternal.cmake | 19 +++------------ Superbuild/Superbuild.cmake | 21 +++++++++++++++++ Superbuild/TeemExternal.cmake | 18 +++++++------- Superbuild/ZlibExternal.cmake | 39 ++++++++++++++----------------- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 4b32e776d4..d5fe1cebbb 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -82,26 +82,18 @@ ExternalProject_Add(Freetype_external -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH= - # Point find_package(ZLIB) to zlib's install prefix + # Let FindZLIB.cmake search under zlib's install prefix -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} - - # Belt-and-suspenders explicit hints (kept as CACHE so FreeType's run sees them) -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} - -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include - # If you computed a best-guess lib path in Superbuild.cmake, pass it here: - # -DZLIB_LIBRARY:FILEPATH=${_ZLIB_LIB} + -DZLIB_USE_STATIC_LIBS:BOOL=ON # optional preference, no filename - # Minimal deps while bringing up -DFT_REQUIRE_ZLIB:BOOL=ON -DFT_DISABLE_BZIP2:BOOL=ON -DFT_DISABLE_PNG:BOOL=ON -DFT_DISABLE_BROTLI:BOOL=ON -DFT_DISABLE_HARFBUZZ:BOOL=ON - # Build order at the target level DEPENDS Zlib_external - - # Keep FreeType "no-install" for now (enable later if desired) INSTALL_COMMAND "" LOG_CONFIGURE 1 @@ -117,12 +109,7 @@ ExternalProject_Add_Step(Freetype_external wait_for_zlib DEPENDERS configure DEPENDS "${ZLIB_INSTALL_DIR}/include/zlib.h" - "${ZLIB_INSTALL_DIR}/include/zconf.h" - # Pick one that matches what you build on each platform: - "${ZLIB_INSTALL_DIR}/lib/z.lib" # Windows static - # "${ZLIB_INSTALL_DIR}/lib/libz.a" # Unix static (if that’s what you build) - # "${ZLIB_INSTALL_DIR}/lib/libz.so" # Linux shared - # "${ZLIB_INSTALL_DIR}/lib/libz.dylib" # macOS shared + "${ZLIB_INSTALL_DIR}/lib" # Directory's existence/time is sufficient; no file name ) # Export variables for SCIRun (consumer side) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index ae47420621..eb7ae815fb 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -527,11 +527,32 @@ if(NOT BUILD_HEADLESS) ) endif() +# Ensure ZLIB_INSTALL_DIR is already cached by ZlibExternal.cmake: +# set(ZLIB_INSTALL_DIR "<...>/Externals/Install/Zlib_external" CACHE PATH ... FORCE) + +list(APPEND SCIRUN_CACHE_ARGS + "-DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR}" + "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" + "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" + # Optional preference (keeps things deterministic if both static & shared exist): + "-DZLIB_USE_STATIC_LIBS:BOOL=ON" +) + ExternalProject_Add( SCIRun_external DEPENDS ${SCIRun_DEPENDENCIES} DOWNLOAD_COMMAND "" SOURCE_DIR ${SCIRUN_SOURCE_DIR} BINARY_DIR ${SCIRUN_BINARY_DIR} CMAKE_CACHE_ARGS ${SCIRUN_CACHE_ARGS} + DEPENDS Zlib_external INSTALL_COMMAND "" ) + +ExternalProject_Add_Step(SCIRun wait_for_zlib + COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts before SCIRun configure..." + DEPENDEES download + DEPENDERS configure + DEPENDS + "${ZLIB_INSTALL_DIR}/include/zlib.h" + "${ZLIB_INSTALL_DIR}/lib" +) \ No newline at end of file diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index c9423cc167..683dbce405 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -79,13 +79,19 @@ ExternalProject_Add(Teem_external -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include - # If you prefer to be explicit, also pass ZLIB_LIBRARY: - # -DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARY} + -DZLIB_USE_STATIC_LIBS:BOOL=ON # optional + + # If Teem exposes switches, keep them minimal while bringing up: + # -DTEEM_ZLIB:BOOL=ON + # -DTEEM_PNG:BOOL=OFF + # -DTEEM_BZIP2:BOOL=OFF + # -DTEEM_FFTW:BOOL=OFF - # Keep Teem no-install for now; switch to install later if you want + DEPENDS Zlib_external INSTALL_COMMAND "" LOG_CONFIGURE 1 @@ -100,11 +106,7 @@ ExternalProject_Add_Step(Teem_external wait_for_zlib DEPENDERS configure DEPENDS "${ZLIB_INSTALL_DIR}/include/zlib.h" - "${ZLIB_INSTALL_DIR}/include/zconf.h" - "${ZLIB_INSTALL_DIR}/lib/z.lib" # Windows static - # "${ZLIB_INSTALL_DIR}/lib/libz.a" # Unix static (if that’s what you build) - # "${ZLIB_INSTALL_DIR}/lib/libz.so" # Linux shared - # "${ZLIB_INSTALL_DIR}/lib/libz.dylib" # macOS shared + "${ZLIB_INSTALL_DIR}/lib" ) # Export variables for SCIRun (consumer side) diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index af8059fca6..44fd518e5d 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -52,36 +52,31 @@ set(_zlib_bin "${CMAKE_BINARY_DIR}/Externals/Build/Zlib_external") set(_zlib_inst "${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external") ExternalProject_Add(Zlib_external - GIT_REPOSITORY "https://github.com/CIBC-Internal/zlib.git" - GIT_TAG ${zlib_GIT_TAG} - UPDATE_DISCONNECTED 1 + # ... + CMAKE_ARGS + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_INSTALL_PREFIX= + # Optional – prefer static libraries everywhere: + # -DBUILD_SHARED_LIBS=OFF - SOURCE_DIR ${_zlib_src} - BINARY_DIR ${_zlib_bin} - - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - - CMAKE_ARGS ${_cmake_args} - - # Run install to produce a normal layout INSTALL_COMMAND "${CMAKE_COMMAND}" --build . --target install - # Tell the generator which files will exist before dependents configure + # Let the generator know which files must exist before dependents configure BUILD_BYPRODUCTS "${_zlib_inst}/include/zlib.h" "${_zlib_inst}/include/zconf.h" - "${_zlib_inst}/lib/z.lib" # Windows static (your custom build) - "${_zlib_inst}/lib/libz.a" # Unix static - "${_zlib_inst}/lib/libz.so" # Linux shared (if built) - "${_zlib_inst}/lib/libz.dylib" # macOS shared (if built) - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + # We don't rely on exact names later, but byproducts help ordering. + "${_zlib_inst}/lib/z.lib" + "${_zlib_inst}/lib/libz.a" + "${_zlib_inst}/lib/libz.so" + "${_zlib_inst}/lib/libz.dylib" ) +# Export just the prefix (cached so other files/functions can see it) +ExternalProject_Get_Property(Zlib_external INSTALL_DIR) +set(ZLIB_INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "zlib install prefix" FORCE) + # ---------------- Export for other externals (FreeType, etc.) ---------------- # Always export the install prefix and canonical include/lib dirs to the cache. # IMPORTANT: do NOT test for file existence here — these files are built later. From 0ecda9306bc767232a9ad2a9be0a94c8873b1c8d Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 30 Jan 2026 16:54:48 -0700 Subject: [PATCH 017/140] updated teem --- Superbuild/Superbuild.cmake | 2 +- Superbuild/TeemExternal.cmake | 10 ++++++---- Superbuild/ZlibExternal.cmake | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index eb7ae815fb..11f79df2fd 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -548,7 +548,7 @@ ExternalProject_Add( SCIRun_external INSTALL_COMMAND "" ) -ExternalProject_Add_Step(SCIRun wait_for_zlib +ExternalProject_Add_Step(SCIRun_external wait_for_zlib COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts before SCIRun configure..." DEPENDEES download DEPENDERS configure diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index 683dbce405..86f1613473 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -50,10 +50,10 @@ set(_cmake_args # Start minimal: disable optional deps until zlib link works # (Uncomment if these options exist in your Teem tree) - # -DTEEM_ZLIB=ON - # -DTEEM_PNG=OFF - # -DTEEM_BZIP2=OFF - # -DTEEM_FFTW=OFF + -DTEEM_ZLIB=ON + -DTEEM_PNG=OFF + -DTEEM_BZIP2=OFF + -DTEEM_FFTW=OFF ) if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) @@ -80,6 +80,8 @@ ExternalProject_Add(Teem_external -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH= + -DZlib_DIR:PATH=${Zlib_DIR} + -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index 44fd518e5d..6d719cb634 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -33,7 +33,7 @@ set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -set(zlib_GIT_TAG "v1.2.8") +set(zlib_GIT_TAG "v1.3.1.2") # No output redirection; let install populate a normal prefix set(_cmake_args @@ -52,7 +52,17 @@ set(_zlib_bin "${CMAKE_BINARY_DIR}/Externals/Build/Zlib_external") set(_zlib_inst "${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external") ExternalProject_Add(Zlib_external - # ... + GIT_REPOSITORY "https://github.com/CIBC-Internal/zlib.git" + GIT_TAG ${zlib_GIT_TAG} + UPDATE_DISCONNECTED 1 + + SOURCE_DIR ${_zlib_src} + BINARY_DIR ${_zlib_bin} + + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" + CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + CMAKE_ARGS -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON @@ -76,6 +86,7 @@ ExternalProject_Add(Zlib_external # Export just the prefix (cached so other files/functions can see it) ExternalProject_Get_Property(Zlib_external INSTALL_DIR) set(ZLIB_INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "zlib install prefix" FORCE) +set(Zlib_DIR "${ZLIB_INSTALL_DIR}/lib/cmake/zlib" CACHE PATH "zlib config directory" FORCE) # ---------------- Export for other externals (FreeType, etc.) ---------------- # Always export the install prefix and canonical include/lib dirs to the cache. From cb8a5f24f8ee0d9838cf4f9d9668ba891321828d Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 2 Feb 2026 14:36:19 -0700 Subject: [PATCH 018/140] fixed teem --- Superbuild/TeemExternal.cmake | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index 86f1613473..1b8fdf1156 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -50,10 +50,10 @@ set(_cmake_args # Start minimal: disable optional deps until zlib link works # (Uncomment if these options exist in your Teem tree) - -DTEEM_ZLIB=ON - -DTEEM_PNG=OFF - -DTEEM_BZIP2=OFF - -DTEEM_FFTW=OFF + -DTeem_ZLIB=ON + -DTeem_PNG=OFF + -DTeem_BZIP2=OFF + -DTeem_FFTW=OFF ) if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) @@ -74,6 +74,9 @@ ExternalProject_Add(Teem_external CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + CMAKE_ARGS + ${_cmake_args} + # Use CMAKE_CACHE_ARGS so Teem's *own* cache sees the hints CMAKE_CACHE_ARGS -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} @@ -88,10 +91,10 @@ ExternalProject_Add(Teem_external -DZLIB_USE_STATIC_LIBS:BOOL=ON # optional # If Teem exposes switches, keep them minimal while bringing up: - # -DTEEM_ZLIB:BOOL=ON - # -DTEEM_PNG:BOOL=OFF - # -DTEEM_BZIP2:BOOL=OFF - # -DTEEM_FFTW:BOOL=OFF + -DTeem_ZLIB:BOOL=ON + -DTeem_PNG:BOOL=OFF + -DTeem_BZIP2:BOOL=OFF + -DTeem_FFTW:BOOL=OFF DEPENDS Zlib_external INSTALL_COMMAND "" From 01b54f0d0ddfe6ee1e1c71f267ac51fd41a886f1 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 3 Feb 2026 12:29:15 -0700 Subject: [PATCH 019/140] scirun cmake errors --- Superbuild/Superbuild.cmake | 13 +- src/CMakeLists.txt | 344 ++++++++++++++++++++++++------------ 2 files changed, 247 insertions(+), 110 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 11f79df2fd..9213e2436a 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -536,15 +536,26 @@ list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" # Optional preference (keeps things deterministic if both static & shared exist): "-DZLIB_USE_STATIC_LIBS:BOOL=ON" + "-DBoost_DIR:PATH=${Boost_DIR}" # Direct path to BoostConfig.cmake directory + "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" # Optional: some tooling still honors BOOST_ROOT + "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" # Newer CMake convention + "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" # Custom variable for SCIRun code" + "-DCMAKE_PREFIX_PATH:PATH=${SCI_BOOST_PREFIX}" # Helps both config and module fallbacks + "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" # Avoid leaking to system Boost ) +message(STATUS "Superbuild passing to SCIRun:") +foreach(arg IN LISTS SCIRUN_CACHE_ARGS) + message(STATUS " ${arg}") +endforeach() + ExternalProject_Add( SCIRun_external DEPENDS ${SCIRun_DEPENDENCIES} DOWNLOAD_COMMAND "" SOURCE_DIR ${SCIRUN_SOURCE_DIR} BINARY_DIR ${SCIRUN_BINARY_DIR} CMAKE_CACHE_ARGS ${SCIRUN_CACHE_ARGS} - DEPENDS Zlib_external + DEPENDS Zlib_external Boost_external INSTALL_COMMAND "" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 874f280433..2a8fbbf079 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -201,25 +201,29 @@ endif() ######################################################################### # External projects - # CONFIG_STANDARD_EXTERNAL(name config_file directory [REQUIRED]) # -# - name: Package name (e.g., Boost) -# - config_file: Primary config file to look for (e.g., BoostConfig.cmake) +# - name: Package name as used by find_package (e.g., Boost, ZLIB, Freetype). +# - config_file: Primary config file name (e.g., BoostConfig.cmake). # - directory: Either the exact package cmake dir OR an install prefix. -# The macro will probe common subpaths and versioned dirs. +# This macro probes common subpaths and versioned dirs. # - REQUIRED: Optional. If provided and not found, errors out. Otherwise warns. # # Behavior: -# - Respects pre-set ${name}_DIR and ${name}_ROOT if they point to a valid config. -# - If 'directory' points to a prefix, searches under lib/cmake/${name}-* and ${name}/. -# - If 'directory' points to an unversioned ${name}/, also probes siblings ${name}-*. -# - On success, FORCE-caches ${name}_DIR and calls find_package(${name} CONFIG). +# - Respects pre-set ${name}_DIR, ${NAME}_DIR and ${name}_ROOT, ${NAME}_ROOT if valid. +# - If 'directory' looks like .../lib/cmake/ (or ), probes versioned siblings +# -* / -* even if the unversioned dir DOES NOT exist. +# - If 'directory' is a prefix, probes under lib/cmake/*, lib/cmake/* and */ *. +# - Also probes each entry of CMAKE_PREFIX_PATH with the same rules. +# - On success, caches ${name}_DIR and ${NAME}_DIR, then calls find_package(${name} CONFIG). # - On failure: -# - If REQUIRED: fatal error with detailed diagnostics. -# - Else: issues a status/warning and returns (for two-phase superbuilds). +# - If REQUIRED: fatal error with diagnostics. +# - Else: status message (for two-phase superbuilds). # macro(CONFIG_STANDARD_EXTERNAL name config_file directory) + # --------------------------- + # Parse OPTIONAL 'REQUIRED' + # --------------------------- set(_cse_REQUIRED OFF) foreach(_arg IN LISTS ARGN) if(_arg STREQUAL "REQUIRED") @@ -227,150 +231,272 @@ macro(CONFIG_STANDARD_EXTERNAL name config_file directory) endif() endforeach() - # 0) If caller already set ${name}_DIR and it contains the config, prefer it. - if(DEFINED ${name}_DIR AND EXISTS "${${name}_DIR}/${config_file}") - set(_cse_pkg_dir "${${name}_DIR}") - endif() + # Case variants + set(_cse_name "${name}") + string(TOUPPER "${_cse_name}" _cse_UP) + string(TOLOWER "${_cse_name}" _cse_LOW) + + # Normalize inputs + set(_cse_cfg "${config_file}") + set(_cse_dir "${directory}") + + # For diagnostics + set(_cse_tried_dirs "") + + # Utility: check a candidate dir for config_file and select it + macro(_cse_try_dir _dir) + if(NOT DEFINED _cse_pkg_dir AND _dir AND EXISTS "${_dir}/${_cse_cfg}") + set(_cse_pkg_dir "${_dir}") + list(APPEND _cse_tried_dirs " ✓ ${_dir}/${_cse_cfg}") + elseif(_dir) + list(APPEND _cse_tried_dirs " ${_dir}/${_cse_cfg}") + endif() + endmacro() - # 1) If not set or invalid, consider ${name}_ROOT - if(NOT DEFINED _cse_pkg_dir AND DEFINED ${name}_ROOT) - # Common place for config under a prefix - set(_cse_try1 "${${name}_ROOT}/lib/cmake/${name}") - set(_cse_try2 "${${name}_ROOT}/lib/cmake/${name}-*") - if(EXISTS "${_cse_try1}/${config_file}") - set(_cse_pkg_dir "${_cse_try1}") - else() - file(GLOB _cse_glob2 "${_cse_try2}") - foreach(_cand IN LISTS _cse_glob2) - if(EXISTS "${_cand}/${config_file}") - set(_cse_pkg_dir "${_cand}") + # Utility: probe a prefix for typical config install subdirs (incl. versioned) + macro(_cse_probe_prefix _prefix) + if(NOT _prefix) + return() + endif() + # lib/cmake/ and versioned siblings + file(GLOB _cse_glob_nc "${_prefix}/lib/cmake/${_cse_name}*") + foreach(_cand IN LISTS _cse_glob_nc) + _cse_try_dir("${_cand}") + if(DEFINED _cse_pkg_dir) + break() + endif() + endforeach() + if(NOT DEFINED _cse_pkg_dir) + # Also try uppercase variant directory + file(GLOB _cse_glob_uc "${_prefix}/lib/cmake/${_cse_UP}*") + foreach(_cand IN LISTS _cse_glob_uc) + _cse_try_dir("${_cand}") + if(DEFINED _cse_pkg_dir) + break() + endif() + endforeach() + endif() + if(NOT DEFINED _cse_pkg_dir) + # Some projects install /*/ directly with config inside + file(GLOB _cse_glob_flat_nc "${_prefix}/${_cse_name}*") + foreach(_cand IN LISTS _cse_glob_flat_nc) + _cse_try_dir("${_cand}") + if(DEFINED _cse_pkg_dir) + break() + endif() + endforeach() + endif() + if(NOT DEFINED _cse_pkg_dir) + file(GLOB _cse_glob_flat_uc "${_prefix}/${_cse_UP}*") + foreach(_cand IN LISTS _cse_glob_flat_uc) + _cse_try_dir("${_cand}") + if(DEFINED _cse_pkg_dir) break() endif() endforeach() endif() + endmacro() + + # --------------------------- + # 0) If caller already set *_DIR and it contains the config, prefer it. + # --------------------------- + if(DEFINED ${_cse_name}_DIR) + _cse_try_dir("${${_cse_name}_DIR}") + endif() + if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_UP}_DIR) + _cse_try_dir("${${_cse_UP}_DIR}") endif() - # 2) If still not found, interpret 'directory' (may be exact dir or a prefix) - if(NOT DEFINED _cse_pkg_dir) - set(_cse_root "${directory}") + # --------------------------- + # 1) Consider *_ROOT hints (both cases) + # --------------------------- + if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_name}_ROOT) + _cse_probe_prefix("${${_cse_name}_ROOT}") + endif() + if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_UP}_ROOT) + _cse_probe_prefix("${${_cse_UP}_ROOT}") + endif() - # If 'directory' itself is a config dir - if(EXISTS "${_cse_root}/${config_file}") - set(_cse_pkg_dir "${_cse_root}") - else() - # If 'directory' looks like .../lib/cmake/${name}, also try versioned siblings - if(EXISTS "${_cse_root}" AND "${_cse_root}" MATCHES "/lib/cmake/${name}$") - file(GLOB _cse_glob3 "${_cse_root}-*") - foreach(_cand IN LISTS _cse_glob3) - if(EXISTS "${_cand}/${config_file}") - set(_cse_pkg_dir "${_cand}") + # --------------------------- + # 2) Interpret 'directory' (exact config dir OR prefix), version-tolerant + # --------------------------- + if(NOT DEFINED _cse_pkg_dir AND _cse_dir) + # a) Exact config dir + _cse_try_dir("${_cse_dir}") + + # b) If it looks like .../lib/cmake/, probe versioned siblings, + # even if the unversioned dir doesn't exist. + if(NOT DEFINED _cse_pkg_dir) + if("${_cse_dir}" MATCHES "/lib/cmake/${_cse_name}$" OR "${_cse_dir}" MATCHES "/lib/cmake/${_cse_UP}$") + file(GLOB _cse_siblings_nc "${_cse_dir}-*") + foreach(_cand IN LISTS _cse_siblings_nc) + _cse_try_dir("${_cand}") + if(DEFINED _cse_pkg_dir) break() endif() endforeach() - endif() - - # Otherwise, treat as prefix and probe common subpaths - if(NOT DEFINED _cse_pkg_dir) - set(_cse_try3 "${_cse_root}/lib/cmake/${name}") - set(_cse_try4 "${_cse_root}/lib/cmake/${name}-*") - if(EXISTS "${_cse_try3}/${config_file}") - set(_cse_pkg_dir "${_cse_try3}") - else() - file(GLOB _cse_glob4 "${_cse_try4}") - foreach(_cand IN LISTS _cse_glob4) - if(EXISTS "${_cand}/${config_file}") - set(_cse_pkg_dir "${_cand}") - break() - endif() - endforeach() + if(NOT DEFINED _cse_pkg_dir) + # Also check uppercase base when lowercased given, and vice versa + if("${_cse_dir}" MATCHES "/lib/cmake/${_cse_name}$") + file(GLOB _cse_siblings_uc "${_cse_dir}-${_cse_UP}*") # rarely useful, but harmless + foreach(_cand IN LISTS _cse_siblings_uc) + _cse_try_dir("${_cand}") + if(DEFINED _cse_pkg_dir) + break() + endif() + endforeach() + endif() endif() endif() endif() + + # c) Otherwise treat as prefix and probe typical subpaths + if(NOT DEFINED _cse_pkg_dir) + _cse_probe_prefix("${_cse_dir}") + endif() endif() - # 3) If found, cache it and run find_package in CONFIG mode + # --------------------------- + # 3) Fall back to probing CMAKE_PREFIX_PATH entries + # --------------------------- + if(NOT DEFINED _cse_pkg_dir AND DEFINED CMAKE_PREFIX_PATH AND CMAKE_PREFIX_PATH) + foreach(_cpp IN LISTS CMAKE_PREFIX_PATH) + _cse_probe_prefix("${_cpp}") + if(DEFINED _cse_pkg_dir) + break() + endif() + endforeach() + endif() + + # --------------------------- + # 4) If found, cache it and run find_package in CONFIG mode + # --------------------------- if(DEFINED _cse_pkg_dir) - set(${name}_DIR "${_cse_pkg_dir}" CACHE PATH "${name} package directory" FORCE) + # Cache both case variants for compatibility + set(${_cse_name}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory" FORCE) + set(${_cse_UP}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory (upper)" FORCE) - # Prefer config packages and allow hints/prefix path to participate + # Prefer config packages set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) - find_package(${name} CONFIG QUIET - HINTS "${${name}_DIR}" "${${name}_ROOT}" + + # Use the exact case 'name' the caller provided + find_package(${_cse_name} CONFIG QUIET + HINTS "${${_cse_name}_DIR}" "${${_cse_name}_ROOT}" "${${_cse_UP}_ROOT}" ) - if(${name}_FOUND) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${name} at ${${name}_DIR}") + # Normalize FOUND across case variants + if(DEFINED ${_cse_name}_FOUND AND ${_cse_name}_FOUND) + set(_cse_found TRUE) + elseif(DEFINED ${_cse_UP}_FOUND AND ${_cse_UP}_FOUND) + set(_cse_found TRUE) + endif() + + if(_cse_found) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} at '${_cse_pkg_dir}'") + unset(_cse_found) + unset(_cse_pkg_dir) + unset(_cse_tried_dirs) return() endif() endif() - # 4) Not found — decide whether to fail now + # --------------------------- + # 5) Not found — decide whether to fail now + # --------------------------- if(_cse_REQUIRED) + # Pretty-print diagnostics + set(_cse_dir_print "${_cse_dir}") + set(_cse_name_dir "${${_cse_name}_DIR}") + set(_cse_up_dir "${${_cse_UP}_DIR}") + set(_cse_name_root "${${_cse_name}_ROOT}") + set(_cse_up_root "${${_cse_UP}_ROOT}") + message(FATAL_ERROR - "[CONFIG_STANDARD_EXTERNAL] ${name} not found.\n" - " Tried:\n" - " - ${name}_DIR='${${name}_DIR}'\n" - " - ${name}_ROOT='${${name}_ROOT}'\n" - " - directory='${directory}' (searched versioned '${name}-*' under lib/cmake)\n" - " Hint: ensure the external is built/installed and re-run CMake.\n" + "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found.\n" + " Looked for '${_cse_cfg}' under:\n" + "${_cse_tried_dirs}\n" + " Hints:\n" + " - ${_cse_name}_DIR='${_cse_name_dir}'\n" + " - ${_cse_UP}_DIR='${_cse_up_dir}'\n" + " - ${_cse_name}_ROOT='${_cse_name_root}'\n" + " - ${_cse_UP}_ROOT='${_cse_up_root}'\n" + " - directory='${_cse_dir_print}'\n" + " - CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" + " Hint: ensure the external is built/installed and re-run CMake." ) else() message(STATUS - "[CONFIG_STANDARD_EXTERNAL] ${name} not found yet. " + "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found yet. " "This is expected before externals are built. " - "After building ${name}, re-run CMake." + "After building ${_cse_name}, re-run CMake." ) endif() -endmacro() -CONFIG_STANDARD_EXTERNAL( Zlib ZlibConfig.cmake ${Zlib_DIR} ) -INCLUDE(${ZLIB_USE_FILE}) + # Cleanup locals + unset(_cse_pkg_dir) + unset(_cse_tried_dirs) +endmacro() -CONFIG_STANDARD_EXTERNAL( SQLite SQLiteConfig.cmake ${SQLite_DIR} ) -INCLUDE(${SQLITE_USE_FILE}) +# Zlib: module first (most common), config if present; NO legacy USE_FILE. +CONFIG_STANDARD_EXTERNAL(ZLIB + ROOT ${ZLIB_ROOT} DIR ${ZLIB_DIR} + # MODULE default allowed; CONFIG default allowed; not REQUIRED (two-pass) +) -CONFIG_STANDARD_EXTERNAL( Teem TeemConfig.cmake ${Teem_DIR} ) -INCLUDE(${Teem_USE_FILE}) +CONFIG_STANDARD_EXTERNAL(SQLite + DIR ${SQLite_DIR} CONFIG_FILE SQLiteConfig.cmake +) -CONFIG_STANDARD_EXTERNAL( Freetype FreetypeConfig.cmake ${Freetype_DIR} ) -INCLUDE(${FREETYPE_USE_FILE}) +CONFIG_STANDARD_EXTERNAL(Teem + DIR ${Teem_DIR} CONFIG_FILE TeemConfig.cmake +) -CONFIG_STANDARD_EXTERNAL( Cleaver2 Cleaver2Config.cmake ${CLEAVER2_DIR} ) -INCLUDE(${CLEAVER2_USE_FILE}) +CONFIG_STANDARD_EXTERNAL(Freetype + DIR ${Freetype_DIR} CONFIG_FILE FreetypeConfig.cmake +) -IF(BUILD_WITH_PYTHON) - CONFIG_STANDARD_EXTERNAL( Python PythonConfig.cmake ${Python_DIR} ) - INCLUDE(${SCI_PYTHON_USE_FILE}) -ENDIF() +CONFIG_STANDARD_EXTERNAL(Cleaver2 + DIR ${CLEAVER2_DIR} CONFIG_FILE Cleaver2Config.cmake +) -CONFIG_STANDARD_EXTERNAL( Boost BoostConfig.cmake ${SCI_BOOST_PREFIX} REQUIRED) -INCLUDE(${SCI_BOOST_USE_FILE}) +if(BUILD_WITH_PYTHON) + # Python packaging varies by version (Python3 vs Python). If you ship a config, specify CONFIG_ONLY. + CONFIG_STANDARD_EXTERNAL(Python + DIR ${Python_DIR} CONFIG_FILE PythonConfig.cmake + ) +endif() -CONFIG_STANDARD_EXTERNAL( Tny TnyConfig.cmake ${TNY_DIR} ) -INCLUDE(${TNY_USE_FILE}) +CONFIG_STANDARD_EXTERNAL(Boost + ROOT ${Boost_DIR} + CONFIG_ONLY # You likely rely on BoostConfig.cmake in your superbuild + REQUIRED +) -CONFIG_STANDARD_EXTERNAL( LodePng LodePngConfig.cmake ${LODEPNG_DIR} ) -INCLUDE(${LODEPNG_USE_FILE}) +CONFIG_STANDARD_EXTERNAL(Tny + DIR ${TNY_DIR} CONFIG_FILE TnyConfig.cmake +) -IF(WITH_TETGEN) - CONFIG_STANDARD_EXTERNAL( Tetgen TetgenConfig.cmake ${Tetgen_DIR} ) - INCLUDE(${TETGEN_USE_FILE}) -ENDIF() +CONFIG_STANDARD_EXTERNAL(LodePng + DIR ${LODEPNG_DIR} CONFIG_FILE LodePngConfig.cmake +) -IF(WITH_OSPRAY) - set(ospray_DIR ${Ospray_External_Dir}/install/ospray/lib/cmake/ospray-2.0.1) - find_package(ospray 2.0.0 REQUIRED HINTS ${Ospray_External_Dir}/install/ospray) -ENDIF() +if(WITH_TETGEN) + CONFIG_STANDARD_EXTERNAL(Tetgen + DIR ${Tetgen_DIR} CONFIG_FILE TetgenConfig.cmake + ) +endif() -IF(WIN32) - CONFIG_STANDARD_EXTERNAL( Glew GlewConfig.cmake ${GLEW_DIR} ) - INCLUDE(${GLEW_USE_FILE}) -ENDIF() +if(WIN32) + CONFIG_STANDARD_EXTERNAL(GLEW + DIR ${GLEW_DIR} CONFIG_FILE GlewConfig.cmake + ) +endif() -IF(NOT BUILD_HEADLESS) - CONFIG_STANDARD_EXTERNAL( Qwt QwtConfig.cmake ${QWT_DIR} ) - INCLUDE(${QWT_USE_FILE}) -ENDIF() +if(NOT BUILD_HEADLESS) + CONFIG_STANDARD_EXTERNAL(Qwt + DIR ${QWT_DIR} CONFIG_FILE QwtConfig.cmake + ) +endif() ######################################################################## # Custom compiler flags and definitions From 3ff41f9bf8c1219da4d2b62505edbc059c61ca96 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 3 Feb 2026 16:51:38 -0700 Subject: [PATCH 020/140] making sure paths generated in superbuild are correct. need to check those in scirun cmake next --- Superbuild/Superbuild.cmake | 521 +++++++++++++++++++----------------- src/CMakeLists.txt | 463 +++++++++++++++++++------------- 2 files changed, 545 insertions(+), 439 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 9213e2436a..ad2399d268 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -29,26 +29,28 @@ SET(compress_type "GIT" CACHE INTERNAL "") SET(ep_base "${CMAKE_BINARY_DIR}/Externals" CACHE INTERNAL "") +# Silence CMP0135 warning for ExternalProject downloads (NEW is safer) +if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) +endif() + ########################################### -# Set default CMAKE_BUILD_TYPE -# if empty for Unix Makefile builds +# Set default CMAKE_BUILD_TYPE if empty for Unix Makefile builds IF(CMAKE_GENERATOR MATCHES "Unix Makefiles" AND NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) + SET(CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF() FIND_PACKAGE(Git) - IF(NOT GIT_FOUND) - MESSAGE(ERROR "Cannot find Git. Git is required for SCIRun's Superbuild") + MESSAGE(FATAL_ERROR "Cannot find Git. Git is required for SCIRun's Superbuild") ENDIF() -INCLUDE( ExternalProject ) +INCLUDE(ExternalProject) ########################################### # DETERMINE ARCHITECTURE -# In order for the code to depend on the architecture settings ########################################### - IF(CMAKE_SIZEOF_VOID_P MATCHES 8) SET(SCIRUN_BITS 64) ELSE() @@ -56,42 +58,39 @@ ELSE() ENDIF() ########################################### -# Configure test support -OPTION(BUILD_TESTING "Build with tests." OFF) - +# Options ########################################### -# Configure compilation database generation +OPTION(BUILD_TESTING "Build with tests." OFF) OPTION(GENERATE_COMPILATION_DATABASE "Generate Compilation Database." ON) - -########################################### -# Configure python OPTION(BUILD_WITH_PYTHON "Build with python support." ON) - -########################################### -# Configure tetgen OPTION(WITH_TETGEN "Build Tetgen." ON) - -########################################### -# Configure ospray OPTION(WITH_OSPRAY "Build Ospray." OFF) - -########################################### -# Configure data OPTION(BUILD_WITH_SCIRUN_DATA "Svn checkout data" OFF) - -########################################### -# Configure Windows executable to run with -# or without the console - IF(WIN32) OPTION(SCIRUN_SHOW_CONSOLE "Show Windows console when running SCIRun (useful for debugging)." ON) MARK_AS_ADVANCED(SCIRUN_SHOW_CONSOLE) ENDIF() +OPTION(BUILD_HEADLESS "Build SCIRun without GUI." OFF) ########################################### -# Configure headless build -OPTION(BUILD_HEADLESS "Build SCIRun without GUI." OFF) +# Prefix collector (build ONE clean CMAKE_PREFIX_PATH for SCIRun) +########################################### +# Use a GLOBAL PROPERTY so values persist across functions/macros. +set_property(GLOBAL PROPERTY SCIRUN_PREFIXES "") +function(sb_prefix_append dir_in) + if(NOT dir_in) + return() + endif() + file(TO_CMAKE_PATH "${dir_in}" _norm) + get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) + if(NOT _acc) + set(_acc "") + endif() + list(APPEND _acc "${_norm}") + list(REMOVE_DUPLICATES _acc) + set_property(GLOBAL PROPERTY SCIRUN_PREFIXES "${_acc}") +endfunction() ########################################### # Configure Qt @@ -106,109 +105,117 @@ set(QT5_MIN_VERSION "5.15.2") set(QT6_MIN_VERSION "6.3.0") # User provides Qt base path -set(Qt_PATH "" CACHE PATH "Path to Qt installation (e.g. C:/Qt/6.7.1/msvc2022_64)") +set(Qt_PATH "" CACHE PATH "Path to Qt installation (e.g. C:/Qt/6.10.1/msvc2022_64)") if (NOT BUILD_HEADLESS) - if (NOT IS_DIRECTORY "${Qt_PATH}") - message(FATAL_ERROR "Qt_PATH is invalid. Point it to the Qt install prefix that contains the lib/, bin/, and cmake/ directories.") - endif() + # 1) Validate Qt_PATH + if (NOT IS_DIRECTORY "${Qt_PATH}") + message(FATAL_ERROR + "Qt_PATH is invalid. Point it to the Qt install prefix that contains lib/, bin/, and (lib/cmake/Qt6 or lib/cmake/Qt5).\n" + "Example (MSVC 2022 x64): C:/Qt/6.10.1/msvc2022_64" + ) + endif() - # Qt expects the directory containing Qt6Config.cmake or Qt5Config.cmake - if (SCIRUN_QT_MAJOR STREQUAL "6") - set(QT_MIN_VERSION ${QT6_MIN_VERSION}) - list(APPEND CMAKE_PREFIX_PATH "${Qt_PATH}") - - find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS - Core - Gui - Widgets - Network - Concurrent - PrintSupport - Svg - OpenGL - OpenGLWidgets - REQUIRED - ) - - message(STATUS "Using Qt6 found at: ${Qt6_DIR}") - - elseif (SCIRUN_QT_MAJOR STREQUAL "5") - set(QT_MIN_VERSION ${QT5_MIN_VERSION}) - list(APPEND CMAKE_PREFIX_PATH "${Qt_PATH}") - - find_package(Qt5 ${QT_MIN_VERSION} COMPONENTS - Core - Gui - Widgets - Network - Concurrent - PrintSupport - Svg - OpenGL - REQUIRED - ) - - message(STATUS "Using Qt5 found at: ${Qt5_DIR}") + # 2) Make the prefix visible to find_package (and collect it) + file(TO_CMAKE_PATH "${Qt_PATH}" _Qt_PREFIX) + list(PREPEND CMAKE_PREFIX_PATH "${_Qt_PREFIX}") + sb_prefix_append("${_Qt_PREFIX}") + + # 3) Pick Qt major and set DIR to the exact config folder + if (SCIRUN_QT_MAJOR STREQUAL "6") + set(QT_MIN_VERSION "${QT6_MIN_VERSION}") + set(Qt6_DIR "${_Qt_PREFIX}/lib/cmake/Qt6") + if (NOT EXISTS "${Qt6_DIR}/Qt6Config.cmake") + message(FATAL_ERROR + "Qt6Config.cmake not found at '${Qt6_DIR}'.\n" + "Verify Qt 6 is installed for your compiler and Qt_PATH is correct." + ) + endif() - else() - message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'.") + message(STATUS "[superbuild] Qt_PATH='${Qt_PATH}'") + message(STATUS "[superbuild] Using Qt6_DIR='${Qt6_DIR}'") + message(STATUS "[superbuild] CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'") + + find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS + Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL OpenGLWidgets + HINTS "${Qt_PATH}" + ) + message(STATUS "Using Qt6 found at: ${Qt6_DIR}") + + elseif (SCIRUN_QT_MAJOR STREQUAL "5") + set(QT_MIN_VERSION "${QT5_MIN_VERSION}") + set(Qt5_DIR "${_Qt_PREFIX}/lib/cmake/Qt5") + if (NOT EXISTS "${Qt5_DIR}/Qt5Config.cmake") + message(FATAL_ERROR + "Qt5Config.cmake not found at '${Qt5_DIR}'.\n" + "Verify Qt 5 is installed for your compiler and Qt_PATH is correct." + ) endif() - if(SCIRUN_QT_MAJOR STREQUAL "6") - if(TARGET Qt6::qmake) - get_target_property(_qmake_path Qt6::qmake LOCATION) + message(STATUS "[superbuild] Qt_PATH='${Qt_PATH}'") + message(STATUS "[superbuild] Using Qt5_DIR='${Qt5_DIR}'") + message(STATUS "[superbuild] CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'") + + find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS + Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL + HINTS "${Qt_PATH}" + ) + message(STATUS "Using Qt5 found at: ${Qt5_DIR}") + + else() + message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Got: '${SCIRUN_QT_MAJOR}'") + endif() + + # 4) Locate qmake for the Qwt build step + if (SCIRUN_QT_MAJOR STREQUAL "6") + if (TARGET Qt6::qmake) + get_target_property(_qmake_path Qt6::qmake LOCATION) + else() + get_filename_component(_qt6_cmake_dir "${Qt6_DIR}" DIRECTORY) # .../lib/cmake + get_filename_component(_qt6_prefix "${_qt6_cmake_dir}" DIRECTORY) # .../lib + get_filename_component(_qt6_root "${_qt6_prefix}" DIRECTORY) # ... + if (WIN32) + set(_qmake_path "${_qt6_root}/bin/qmake.exe") else() - # Fallback: derive from Qt6_DIR if the qmake target is missing - # Qt6_DIR typically points to .../lib/cmake/Qt6 - # qmake is usually under the corresponding bin/ - get_filename_component(_qt6_cmake_dir "${Qt6_DIR}" DIRECTORY) # .../lib/cmake - get_filename_component(_qt6_prefix "${_qt6_cmake_dir}" DIRECTORY) # .../lib - get_filename_component(_qt6_root "${_qt6_prefix}" DIRECTORY) # ... - if(WIN32) - set(_qmake_path "${_qt6_root}/bin/qmake.exe") - else() - set(_qmake_path "${_qt6_root}/bin/qmake") - endif() + set(_qmake_path "${_qt6_root}/bin/qmake") endif() - elseif(SCIRUN_QT_MAJOR STREQUAL "5") - if(TARGET Qt5::qmake) - get_target_property(_qmake_path Qt5::qmake LOCATION) + endif() + else() # Qt5 + if (TARGET Qt5::qmake) + get_target_property(_qmake_path Qt5::qmake LOCATION) + else() + get_filename_component(_qt5_cmake_dir "${Qt5_DIR}" DIRECTORY) + get_filename_component(_qt5_prefix "${_qt5_cmake_dir}" DIRECTORY) + get_filename_component(_qt5_root "${_qt5_prefix}" DIRECTORY) + if (WIN32) + set(_qmake_path "${_qt5_root}/bin/qmake.exe") else() - get_filename_component(_qt5_cmake_dir "${Qt5_DIR}" DIRECTORY) - get_filename_component(_qt5_prefix "${_qt5_cmake_dir}" DIRECTORY) - get_filename_component(_qt5_root "${_qt5_prefix}" DIRECTORY) - if(WIN32) - set(_qmake_path "${_qt5_root}/bin/qmake.exe") - else() - set(_qmake_path "${_qt5_root}/bin/qmake") - endif() + set(_qmake_path "${_qt5_root}/bin/qmake") endif() endif() - - # Validate and publish for QwtExternal.cmake to use - if(NOT _qmake_path OR NOT EXISTS "${_qmake_path}") - message(FATAL_ERROR "Could not locate qmake. Checked: ${_qmake_path}") - endif() - - # Make it visible to the external (cache it so EPs see it in their configure env) - set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH "Path to Qt qmake for building Qwt" FORCE) - - message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") + endif() + + if (NOT _qmake_path OR NOT EXISTS "${_qmake_path}") + message(FATAL_ERROR "Could not locate qmake. Checked: ${_qmake_path}") + endif() + + set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH "Path to Qt qmake for building Qwt" FORCE) + message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") + else() - add_definitions(-DBUILD_HEADLESS) + add_definitions(-DBUILD_HEADLESS) endif() - ########################################### # Configure Doxygen documentation +########################################### OPTION(BUILD_DOCUMENTATION "Build documentation" OFF) MARK_AS_ADVANCED(BUILD_DOCUMENTATION) -######################################################################## +########################################### # Factory code generation options - +########################################### OPTION(GENERATE_MODULE_FACTORY_CODE "Generate module factory code from config files" ON) MARK_AS_ADVANCED(GENERATE_MODULE_FACTORY_CODE) @@ -217,11 +224,11 @@ MARK_AS_ADVANCED(REGENERATE_MODULE_FACTORY_CODE) ########################################### # Configure externals - -SET( SCIRun_DEPENDENCIES ) +########################################### +SET(SCIRun_DEPENDENCIES) MACRO(ADD_EXTERNAL cmake_file external) - INCLUDE( ${cmake_file} ) + INCLUDE(${cmake_file}) LIST(APPEND SCIRun_DEPENDENCIES ${external}) ENDMACRO() @@ -230,26 +237,26 @@ SET(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE SET(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) IF(BUILD_TESTING) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/TestDataConfig.cmake SCIRunTestData_external ) + ADD_EXTERNAL(${SUPERBUILD_DIR}/TestDataConfig.cmake SCIRunTestData_external) ENDIF() -ADD_EXTERNAL( ${SUPERBUILD_DIR}/EigenExternal.cmake Eigen_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/ZlibExternal.cmake Zlib_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/SQLiteExternal.cmake SQLite_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/TeemExternal.cmake Teem_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/FreetypeExternal.cmake Freetype_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/GLMExternal.cmake GLM_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/SpdLogExternal.cmake SpdLog_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/TnyExternal.cmake Tny_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/LodePngExternal.cmake LodePng_external ) -ADD_EXTERNAL( ${SUPERBUILD_DIR}/Cleaver2External.cmake Cleaver2_external ) +ADD_EXTERNAL(${SUPERBUILD_DIR}/EigenExternal.cmake Eigen_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/ZlibExternal.cmake Zlib_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/SQLiteExternal.cmake SQLite_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/TeemExternal.cmake Teem_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/FreetypeExternal.cmake Freetype_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/GLMExternal.cmake GLM_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/SpdLogExternal.cmake SpdLog_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/TnyExternal.cmake Tny_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/LodePngExternal.cmake LodePng_external) +ADD_EXTERNAL(${SUPERBUILD_DIR}/Cleaver2External.cmake Cleaver2_external) IF(WIN32) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external ) + ADD_EXTERNAL(${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external) ENDIF() IF(BUILD_WITH_PYTHON) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/PythonExternal.cmake Python_external ) + ADD_EXTERNAL(${SUPERBUILD_DIR}/PythonExternal.cmake Python_external) ENDIF() FIND_PACKAGE(Subversion) @@ -257,44 +264,53 @@ IF(NOT Subversion_FOUND) SET(BUILD_WITH_SCIRUN_DATA OFF) ENDIF() IF(BUILD_WITH_SCIRUN_DATA) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/SCIRunDataExternal.cmake SCI_data_external) + ADD_EXTERNAL(${SUPERBUILD_DIR}/SCIRunDataExternal.cmake SCI_data_external) ENDIF() IF(WITH_TETGEN) MESSAGE(STATUS "Configuring Tetgen library under GPL. The SCIRun InterfaceWithTetGen module can be disabled by setting the CMake build variable WITH_TETGEN to OFF.") - ADD_EXTERNAL( ${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external ) + ADD_EXTERNAL(${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external) ENDIF() IF(WITH_OSPRAY) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external ) + ADD_EXTERNAL(${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external) ENDIF() IF(NOT BUILD_HEADLESS) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external ) - #ADD_EXTERNAL( ${SUPERBUILD_DIR}/CtkExternal.cmake Ctk_external ) + ADD_EXTERNAL(${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external) + # ADD_EXTERNAL(${SUPERBUILD_DIR}/CtkExternal.cmake Ctk_external) ENDIF() -ADD_EXTERNAL( ${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external ) +ADD_EXTERNAL(${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external) +########################################### +# Helpers to export locations to SCIRun and collect prefixes +########################################### -# Helper to export a CONFIG package directory to SCIRun_CACHE_ARGS +# Helper to export a CONFIG package directory to SCIRun cache args function(_export_config_dir pkg target subdir_pattern) - # Get the external's install prefix ExternalProject_Get_Property(${target} INSTALL_DIR) if(NOT INSTALL_DIR) message(FATAL_ERROR "INSTALL_DIR not set for ${target}. Ensure INSTALL is enabled in its ExternalProject_Add.") endif() - # The folder that contains Config.cmake varies slightly by project. - # Common patterns: lib/cmake/, lib/cmake/, share//cmake + # Collect prefix + sb_prefix_append("${INSTALL_DIR}") + + string(TOUPPER "${pkg}" pkg_upper) + + # Candidates where Config.cmake might live set(_candidates "${INSTALL_DIR}/lib/cmake/${pkg}" "${INSTALL_DIR}/lib/cmake/${pkg}-*" "${INSTALL_DIR}/lib/cmake/${pkg_upper}" + "${INSTALL_DIR}/lib64/cmake/${pkg}" + "${INSTALL_DIR}/lib64/cmake/${pkg_upper}" "${INSTALL_DIR}/share/${pkg}/cmake" + "${INSTALL_DIR}/cmake/${pkg}" + "${INSTALL_DIR}/CMake/${pkg}" ) - string(TOUPPER "${pkg}" pkg_upper) unset(_found_dir) foreach(_cand IN LISTS _candidates) file(GLOB _hits "${_cand}") @@ -316,7 +332,7 @@ function(_export_config_dir pkg target subdir_pattern) return() endif() - # Export _DIR to the SCIRun configure cache + # Export _DIR as a cache entry so SCIRun receives it set(${pkg}_DIR "${_found_dir}" CACHE PATH "${pkg} config dir" FORCE) list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") set(SCIRun_CACHE_ARGS "${SCIRun_CACHE_ARGS}" PARENT_SCOPE) @@ -324,13 +340,16 @@ function(_export_config_dir pkg target subdir_pattern) message(STATUS "[superbuild] ${pkg}_DIR = ${${pkg}_DIR}") endfunction() -# Helper to export just include/lib hints (for header-only or non-config packages) +# Helper to export include/lib hints (for header-only or non-config packages) function(_export_include_lib pkg target) ExternalProject_Get_Property(${target} INSTALL_DIR) if(NOT INSTALL_DIR) message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") endif() + # Collect prefix + sb_prefix_append("${INSTALL_DIR}") + # Heuristics: include/ and lib{,64}/ under install prefix set(_inc "${INSTALL_DIR}/include") if(EXISTS "${INSTALL_DIR}/lib64") @@ -352,91 +371,73 @@ function(_export_include_lib pkg target) message(STATUS "[superbuild] ${pkg}: include=${_inc} lib=${_lib}") endfunction() -#get boost properties and pass to SCIRun +########################################### +# Boost properties and hints (robust DIR) +########################################### ExternalProject_Get_Property(Boost_external INSTALL_DIR) -set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") +set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix (produced by Boost_external)" FORCE) set(SCI_BOOST_INCLUDE "${INSTALL_DIR}/include") -set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix (produced by Boost_external)" FORCE) if (WIN32 AND EXISTS "${INSTALL_DIR}/lib64") set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib64") else() set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib") endif() +# Try to pick the exact config dir (versioned) if present; fall back to unversioned +set(Boost_DIR "") +file(GLOB _boost_cfg_dirs "${INSTALL_DIR}/lib/cmake/Boost*") +foreach(_bd IN LISTS _boost_cfg_dirs) + if(EXISTS "${_bd}/BoostConfig.cmake") + set(Boost_DIR "${_bd}") + break() + endif() +endforeach() +if(NOT Boost_DIR) + set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") +endif() + +# Collect Boost prefix too +sb_prefix_append("${INSTALL_DIR}") + +########################################### +# Export locations for externals +########################################### # CONFIG-package externals (expect *Config.cmake) -# Adjust names if the actual package names differ. _export_config_dir(Zlib Zlib_external "") _export_config_dir(Freetype Freetype_external "") _export_config_dir(SQLite SQLite_external "") -# Qwt: do not try to 'find' files at configure time; define an imported target -# that will point to the expected install location(s) and depend on the EP. +# Qwt: create imported target (does not rely on a config package) +_export_config_dir(Qwt Qwt_external "") # harmless if no config is present -# (Optional) This helper won't find anything for Qwt (no CMake config), but harmless -_export_config_dir(Qwt Qwt_external "") - -# Get the external's install prefix ExternalProject_Get_Property(Qwt_external INSTALL_DIR) set(QWT_INSTALL_DIR "${INSTALL_DIR}") - -# Include & lib dirs as installed by qmake set(QWT_INCLUDE_DIR "${QWT_INSTALL_DIR}/include") set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") -# Create an imported target that *will* exist after the external builds. -# Use per-config locations on Windows to handle qwt.lib (Release) and qwtd.lib (Debug). add_library(Qwt::Qwt UNKNOWN IMPORTED GLOBAL) add_dependencies(Qwt::Qwt Qwt_external) -# Include directories (Qwt typically installs headers under include/ or include/qwt-) set_property(TARGET Qwt::Qwt PROPERTY - INTERFACE_INCLUDE_DIRECTORIES - "${QWT_INCLUDE_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${QWT_INCLUDE_DIR}" ) if(WIN32) - # Windows/MSVC typically uses a 'd' suffix for Debug builds. set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_CONFIGURATIONS "Debug;Release") - - set_property(TARGET Qwt::Qwt PROPERTY - IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") - # Try qwtd.lib first; if your build produces qwt.lib for Debug too, you can - # set both to qwt.lib and it will still work. - set_property(TARGET Qwt::Qwt PROPERTY - IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") - - # If you prefer a single generator expression instead of config-specific props, - # you could do: - # set_property(TARGET Qwt::Qwt PROPERTY - # IMPORTED_LOCATION "$,${QWT_LIBRARY_DIR}/qwtd.lib,${QWT_LIBRARY_DIR}/qwt.lib>") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") elseif(APPLE) - # Prefer shared if present, otherwise static (the file will appear at build time) - set_property(TARGET Qwt::Qwt PROPERTY - IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") - # Optional: provide a static fallback for environments that build static - # set_property(TARGET Qwt::Qwt PROPERTY - # IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.a") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") else() - # Linux/*nix: prefer shared, static as fallback - # If you know you're building static-only, you can point straight to libqwt.a - set_property(TARGET Qwt::Qwt PROPERTY - IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.so") - # Optional static fallback: - # set_property(TARGET Qwt::Qwt PROPERTY - # IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.a") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.so") endif() -# IMPORTANT: Do not 'EXISTS'-check the files at configure time. They'll be created during build. -# Now consumers can safely link: -# target_link_libraries(SCIRunGui PRIVATE Qwt::Qwt) - -# GLEW: depends on its CMake; if it exports configs, use config; otherwise include/lib +# GLEW: try config; if none, include/lib hints will still help if(WIN32) _export_config_dir(GLEW Glew_external "") endif() -# Python: if your PythonExternal builds a CPython with a CMake export, use config; -# otherwise export include/lib and PYTHONHOME-ish prefix for embedding. +# Python: prefer config if available; otherwise include/lib if(BUILD_WITH_PYTHON) _export_config_dir(Python Python_external "") endif() @@ -457,15 +458,12 @@ if(WITH_TETGEN) _export_include_lib(Tetgen Tetgen_external) endif() if(WITH_OSPRAY) - # OSPRay typically has a config; try config first, fall back to include/lib _export_config_dir(ospray Ospray_external "") endif() -if(BUILD_TESTING) - # Test data external likely doesn't export headers/libs; skip -endif() ########################################### # Download external data sources +########################################### OPTION(DOWNLOAD_TOOLKITS "Download toolkit repositories." ON) MARK_AS_ADVANCED(DOWNLOAD_TOOLKITS) IF(DOWNLOAD_TOOLKITS) @@ -474,91 +472,114 @@ IF(DOWNLOAD_TOOLKITS) EXTERNAL_TOOLKIT(FwdInvToolkit) ENDIF() - -# --- SCIRUN CACHE ARGUMENTS (SCIRun internal settings only) --- +########################################### +# Build SCIRun cache args (internal settings) +########################################### set(SCIRUN_CACHE_ARGS - "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" - "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" - "-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}" - "-DSCIRUN_BITS:STRING=${SCIRUN_BITS}" - "-DBUILD_TESTING:BOOL=${BUILD_TESTING}" - "-DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}" - "-DBUILD_HEADLESS:BOOL=${BUILD_HEADLESS}" - "-DQT_VERSION_MAJOR:STRING=${QT_VERSION_MAJOR}" - "-DSCIRUN_TEST_RESOURCE_DIR:PATH=${SCIRUN_TEST_RESOURCE_DIR}" - "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" - "-DUSER_PYTHON_VERSION:STRING=${USER_PYTHON_VERSION}" - "-DUSER_PYTHON_VERSION_MAJOR:STRING=${USER_PYTHON_VERSION_MAJOR}" - "-DUSER_PYTHON_VERSION_MINOR:STRING=${USER_PYTHON_VERSION_MINOR}" - "-DWITH_TETGEN:BOOL=${WITH_TETGEN}" - "-DWITH_OSPRAY:BOOL=${WITH_OSPRAY}" - "-DREGENERATE_MODULE_FACTORY_CODE:BOOL=${REGENERATE_MODULE_FACTORY_CODE}" - "-DGENERATE_MODULE_FACTORY_CODE:BOOL=${GENERATE_MODULE_FACTORY_CODE}" - "-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}" - "-DGENERATE_COMPILATION_DATABASE:BOOL=${GENERATE_COMPILATION_DATABASE}" - "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}" - "-DQt_PATH:PATH=${Qt_PATH}" + "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" + "-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}" + "-DSCIRUN_BITS:STRING=${SCIRUN_BITS}" + "-DBUILD_TESTING:BOOL=${BUILD_TESTING}" + "-DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}" + "-DBUILD_HEADLESS:BOOL=${BUILD_HEADLESS}" + "-DSCIRUN_TEST_RESOURCE_DIR:PATH=${SCIRUN_TEST_RESOURCE_DIR}" + "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" + "-DUSER_PYTHON_VERSION:STRING=${USER_PYTHON_VERSION}" + "-DUSER_PYTHON_VERSION_MAJOR:STRING=${USER_PYTHON_VERSION_MAJOR}" + "-DUSER_PYTHON_VERSION_MINOR:STRING=${USER_PYTHON_VERSION_MINOR}" + "-DWITH_TETGEN:BOOL=${WITH_TETGEN}" + "-DWITH_OSPRAY:BOOL=${WITH_OSPRAY}" + "-DREGENERATE_MODULE_FACTORY_CODE:BOOL=${REGENERATE_MODULE_FACTORY_CODE}" + "-DGENERATE_MODULE_FACTORY_CODE:BOOL=${GENERATE_MODULE_FACTORY_CODE}" + "-DGENERATE_COMPILATION_DATABASE:BOOL=${GENERATE_COMPILATION_DATABASE}" + "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}" + "-DQt_PATH:PATH=${Qt_PATH}" ) if(BUILD_WITH_PYTHON) - list(APPEND SCIRUN_CACHE_ARGS - "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}" - ) + if(SCI_PYTHON_EXE) + list(APPEND SCIRUN_CACHE_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}") + endif() endif() if(WIN32) - list(APPEND SCIRUN_CACHE_ARGS - "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}" - ) + list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}") endif() +# (Avoid passing empty Qt component DIR hints; CMAKE_PREFIX_PATH+Qt_PATH are enough) if(NOT BUILD_HEADLESS) - list(APPEND SCIRUN_CACHE_ARGS - "-DQt_PATH:PATH=${Qt_PATH}" - "-DQt${QT_VERSION_MAJOR}Core_DIR:PATH=${Qt${QT_VERSION_MAJOR}Core_DIR}" - "-DQt${QT_VERSION_MAJOR}CoreTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}CoreTools_DIR}" - "-DQt${QT_VERSION_MAJOR}Gui_DIR:PATH=${Qt${QT_VERSION_MAJOR}Gui_DIR}" - "-DQt${QT_VERSION_MAJOR}GuiTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}GuiTools_DIR}" - "-DQt${QT_VERSION_MAJOR}OpenGL_DIR:PATH=${Qt${QT_VERSION_MAJOR}OpenGL_DIR}" - "-DQt${QT_VERSION_MAJOR}Network_DIR:PATH=${Qt${QT_VERSION_MAJOR}Network_DIR}" - "-DQt${QT_VERSION_MAJOR}Widgets_DIR:PATH=${Qt${QT_VERSION_MAJOR}Widgets_DIR}" - "-DQt${QT_VERSION_MAJOR}Concurrent_DIR:PATH=${Qt${QT_VERSION_MAJOR}Concurrent_DIR}" - "-DMACDEPLOYQT_OUTPUT_LEVEL:STRING=${MACDEPLOYQT_OUTPUT_LEVEL}" - ) + if(DEFINED MACDEPLOYQT_OUTPUT_LEVEL) + list(APPEND SCIRUN_CACHE_ARGS "-DMACDEPLOYQT_OUTPUT_LEVEL:STRING=${MACDEPLOYQT_OUTPUT_LEVEL}") + endif() endif() -# Ensure ZLIB_INSTALL_DIR is already cached by ZlibExternal.cmake: -# set(ZLIB_INSTALL_DIR "<...>/Externals/Install/Zlib_external" CACHE PATH ... FORCE) +########################################### +# Explicit Zlib/Boost hints (good to keep) +########################################### +ExternalProject_Get_Property(Zlib_external INSTALL_DIR) +set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR}" "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" - # Optional preference (keeps things deterministic if both static & shared exist): "-DZLIB_USE_STATIC_LIBS:BOOL=ON" - "-DBoost_DIR:PATH=${Boost_DIR}" # Direct path to BoostConfig.cmake directory - "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" # Optional: some tooling still honors BOOST_ROOT - "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" # Newer CMake convention - "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" # Custom variable for SCIRun code" - "-DCMAKE_PREFIX_PATH:PATH=${SCI_BOOST_PREFIX}" # Helps both config and module fallbacks - "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" # Avoid leaking to system Boost + "-DBoost_DIR:PATH=${Boost_DIR}" # points to folder containing BoostConfig.cmake + "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" + "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" + "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" + "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" ) +# If Zlib_DIR is known from _export_config_dir, pass it (helps config-package resolution) +if(DEFINED Zlib_DIR) + list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_DIR:PATH=${Zlib_DIR}") +endif() + +# Compose ONE clean CMAKE_PREFIX_PATH for SCIRun +get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) +set(_joined_prefixes "") +if(_acc) + list(REMOVE_DUPLICATES _acc) + string(JOIN ";" _joined_prefixes ${_acc}) +endif() + +# ESCAPE the semicolons so the whole value stays ONE list element +set(_joined_prefixes_escaped "${_joined_prefixes}") +string(REPLACE ";" "\\;" _joined_prefixes_escaped "${_joined_prefixes}") + +# Remove any earlier -DCMAKE_PREFIX_PATH entries (defensive) +set(_filtered "") +foreach(arg IN LISTS SCIRUN_CACHE_ARGS) + if(NOT arg MATCHES "^-DCMAKE_PREFIX_PATH:PATH=") + list(APPEND _filtered "${arg}") + endif() +endforeach() +set(SCIRUN_CACHE_ARGS "${_filtered}") + +# Append exactly ONE CMAKE_PREFIX_PATH argument (escaped) +list(APPEND SCIRUN_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${_joined_prefixes_escaped}") + +# Log what we will pass +message(STATUS "[superbuild] Final CMAKE_PREFIX_PATH for SCIRun: ${_joined_prefixes}") message(STATUS "Superbuild passing to SCIRun:") foreach(arg IN LISTS SCIRUN_CACHE_ARGS) message(STATUS " ${arg}") endforeach() -ExternalProject_Add( SCIRun_external +########################################### +# ExternalProject for SCIRun +########################################### +ExternalProject_Add(SCIRun_external DEPENDS ${SCIRun_DEPENDENCIES} DOWNLOAD_COMMAND "" SOURCE_DIR ${SCIRUN_SOURCE_DIR} BINARY_DIR ${SCIRUN_BINARY_DIR} CMAKE_CACHE_ARGS ${SCIRUN_CACHE_ARGS} - DEPENDS Zlib_external Boost_external INSTALL_COMMAND "" ) +# Optional: ensure Zlib artifacts exist before SCIRun config (keeps order tidy) ExternalProject_Add_Step(SCIRun_external wait_for_zlib COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts before SCIRun configure..." DEPENDEES download @@ -566,4 +587,4 @@ ExternalProject_Add_Step(SCIRun_external wait_for_zlib DEPENDS "${ZLIB_INSTALL_DIR}/include/zlib.h" "${ZLIB_INSTALL_DIR}/lib" -) \ No newline at end of file +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a8fbbf079..29ce1fad2b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,10 +36,28 @@ IF(GENERATE_COMPILATION_DATABASE) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ENDIF() +# ------------------------------- +# SCIRun path diagnostics (what we actually received from the superbuild) +# ------------------------------- +message(STATUS "[SCIRun] CMAKE_PREFIX_PATH = '${CMAKE_PREFIX_PATH}'") +if(CMAKE_PREFIX_PATH) + message(STATUS "[SCIRun] CMAKE_PREFIX_PATH entries:") + foreach(_p IN LISTS CMAKE_PREFIX_PATH) + file(TO_CMAKE_PATH "${_p}" _p_norm) + if(EXISTS "${_p_norm}") + message(STATUS " ✓ ${_p_norm}") + else() + message(STATUS " ✗ ${_p_norm} (does not exist at configure time)") + endif() + endforeach() +endif() +message(STATUS "[SCIRun] Qt_PATH='${Qt_PATH}'") +message(STATUS "[SCIRun] Boost_DIR='${Boost_DIR}' ; Boost_ROOT='${Boost_ROOT}' ; BOOST_ROOT='${BOOST_ROOT}' ; SCI_BOOST_PREFIX='${SCI_BOOST_PREFIX}'") +message(STATUS "[SCIRun] ZLIB_ROOT='${ZLIB_ROOT}' ; ZLIB_DIR='${ZLIB_DIR}' ; ZLIB_INCLUDE_DIR='${ZLIB_INCLUDE_DIR}'") + ############################################################################### # Don't allow the user to build in the src directory... # - IF(${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR}) MESSAGE( "" ) MESSAGE( "Building SCIRun in the source directory is not allowed." ) @@ -103,7 +121,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules/Version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/Core/Application/Version.cc) set(version_file "${CMAKE_CURRENT_BINARY_DIR}/Core/Application/Version.cc") - ######################################################################## # SCIRUN version number. @@ -113,7 +130,6 @@ SET(SCIRUN_VERSION_PATCH "${VERSION_PATCH}") SET(SCIRUN_VERSION_STRING "${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}") - ######################################################################## # APPLICATION Information (used by CPack) # @@ -127,7 +143,7 @@ SET(APPLICATION_EXTENSION ".srn5" CACHE INTERNAL "Network file extension" FORCE) SET(APPLICATION_URL "www.scirun.org" CACHE INTERNAL "Project URL" FORCE) SET(APPLICATION_VENDOR "SCI" CACHE INTERNAL "Vendor information" FORCE) SET(APPLICATION_CONTACT "scirun-users@sci.utah.edu" CACHE INTERNAL "Contact information" FORCE) -SET(APPLICATION_WINDOWS_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\\\scirun5_32.ico" CACHE INTERNAL "Windows icon" FORCE) +SET(APPLICATION_WINDOWS_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\scirun5_32.ico" CACHE INTERNAL "Windows icon" FORCE) SET(APPLICATION_WINDOWS_RC "${CMAKE_SOURCE_DIR}/Resources/Icons/SCIRun.rc" CACHE INTERNAL "Windows icon" FORCE) SET(APPLICATION_OSX_ICON_FULL_PATH "${CMAKE_SOURCE_DIR}/Resources/Icons/scirun5.icns" CACHE INTERNAL "OSX icon" FORCE) @@ -199,167 +215,201 @@ else() endif() ######################################################################### -# External projects - -# CONFIG_STANDARD_EXTERNAL(name config_file directory [REQUIRED]) +# External projects (configure-time discovery of externals) # -# - name: Package name as used by find_package (e.g., Boost, ZLIB, Freetype). -# - config_file: Primary config file name (e.g., BoostConfig.cmake). -# - directory: Either the exact package cmake dir OR an install prefix. -# This macro probes common subpaths and versioned dirs. -# - REQUIRED: Optional. If provided and not found, errors out. Otherwise warns. +# Robust keyword-based macro + calls with clear diagnostics. +######################################################################### + +# --- Keyword-based CONFIG_STANDARD_EXTERNAL macro --- +include(CMakeParseArguments) + +# CONFIG_STANDARD_EXTERNAL(name [DIR ] [ROOT ] [CFG ] [CFGS ...] +# [CONFIG_ONLY] [REQUIRED] [QUIET] [VERBOSE]) # -# Behavior: -# - Respects pre-set ${name}_DIR, ${NAME}_DIR and ${name}_ROOT, ${NAME}_ROOT if valid. -# - If 'directory' looks like .../lib/cmake/ (or ), probes versioned siblings -# -* / -* even if the unversioned dir DOES NOT exist. -# - If 'directory' is a prefix, probes under lib/cmake/*, lib/cmake/* and */ *. -# - Also probes each entry of CMAKE_PREFIX_PATH with the same rules. -# - On success, caches ${name}_DIR and ${NAME}_DIR, then calls find_package(${name} CONFIG). -# - On failure: -# - If REQUIRED: fatal error with diagnostics. -# - Else: status message (for two-phase superbuilds). +# - name: CMake package name (e.g., ZLIB, Freetype, Boost). +# - DIR: Either an exact config directory (contains *Config.cmake) OR a prefix to probe. +# - ROOT: Install prefix to probe (lib/cmake/*, lib64/cmake/*, share//cmake, etc). +# - CFG: Primary config filename to look for (e.g., ZLIBConfig.cmake). +# - CFGS: Alternative config filenames to try if CFG not present (case variants). +# - CONFIG_ONLY: Prefer config packages (sets CMAKE_FIND_PACKAGE_PREFER_CONFIG ON during the call). +# - REQUIRED: Fail configure if not found. +# - QUIET: Less chatter. +# - VERBOSE: Print every probed path when not found. # -macro(CONFIG_STANDARD_EXTERNAL name config_file directory) - # --------------------------- - # Parse OPTIONAL 'REQUIRED' - # --------------------------- - set(_cse_REQUIRED OFF) - foreach(_arg IN LISTS ARGN) - if(_arg STREQUAL "REQUIRED") - set(_cse_REQUIRED ON) - endif() - endforeach() +macro(CONFIG_STANDARD_EXTERNAL name) + # Parse keywords + set(_cse_one DIR ROOT CFG) + set(_cse_multi CFGS) + set(_cse_bool REQUIRED CONFIG_ONLY QUIET VERBOSE) + cmake_parse_arguments(_CSE "${_cse_bool}" "" "${_cse_one};${_cse_multi}" ${ARGN}) # Case variants set(_cse_name "${name}") string(TOUPPER "${_cse_name}" _cse_UP) string(TOLOWER "${_cse_name}" _cse_LOW) - # Normalize inputs - set(_cse_cfg "${config_file}") - set(_cse_dir "${directory}") + # Build candidate config filename list + set(_cse_cfgs "") + if(_CSE_CFG) + list(APPEND _cse_cfgs "${_CSE_CFG}") + endif() + if(_CSE_CFGS) + list(APPEND _cse_cfgs ${_CSE_CFGS}) + endif() + if(NOT _cse_cfgs) + list(APPEND _cse_cfgs + "${_cse_name}Config.cmake" + "${_cse_UP}Config.cmake" + "${_cse_LOW}Config.cmake" + "${_cse_LOW}-config.cmake" + "${_cse_UP}-config.cmake" + ) + endif() + + # Normalized hints + set(_cse_dir "${_CSE_DIR}") + set(_cse_root "${_CSE_ROOT}") # For diagnostics + unset(_cse_pkg_dir) set(_cse_tried_dirs "") - # Utility: check a candidate dir for config_file and select it - macro(_cse_try_dir _dir) - if(NOT DEFINED _cse_pkg_dir AND _dir AND EXISTS "${_dir}/${_cse_cfg}") - set(_cse_pkg_dir "${_dir}") - list(APPEND _cse_tried_dirs " ✓ ${_dir}/${_cse_cfg}") - elseif(_dir) - list(APPEND _cse_tried_dirs " ${_dir}/${_cse_cfg}") + # Helpers + function(_cse_found_in_dir dir_out) + foreach(_cfg IN LISTS _cse_cfgs) + if(EXISTS "${dir_out}/${_cfg}") + set(_cse_pkg_dir "${dir_out}" PARENT_SCOPE) + return() + endif() + endforeach() + endfunction() + + macro(_cse_mark _dir) + if(NOT _dir) + # skip + else() + set(_hit "") + foreach(_cfg IN LISTS _cse_cfgs) + if(EXISTS "${_dir}/${_cfg}") + set(_hit "✓") + break() + endif() + endforeach() + if(_hit) + list(APPEND _cse_tried_dirs " ✓ ${_dir} (${_cse_cfgs})") + set(_cse_pkg_dir "${_dir}") + else() + list(APPEND _cse_tried_dirs " ${_dir} (${_cse_cfgs})") + endif() endif() endmacro() - # Utility: probe a prefix for typical config install subdirs (incl. versioned) - macro(_cse_probe_prefix _prefix) + function(_cse_probe_prefix _prefix) if(NOT _prefix) return() endif() - # lib/cmake/ and versioned siblings - file(GLOB _cse_glob_nc "${_prefix}/lib/cmake/${_cse_name}*") - foreach(_cand IN LISTS _cse_glob_nc) - _cse_try_dir("${_cand}") - if(DEFINED _cse_pkg_dir) - break() - endif() - endforeach() - if(NOT DEFINED _cse_pkg_dir) - # Also try uppercase variant directory - file(GLOB _cse_glob_uc "${_prefix}/lib/cmake/${_cse_UP}*") - foreach(_cand IN LISTS _cse_glob_uc) - _cse_try_dir("${_cand}") + + # Common locations (with lib64, cmake/CMake, share) + set(_cse_candidate_dirs + "${_prefix}/lib/cmake/${_cse_name}" + "${_prefix}/lib/cmake/${_cse_UP}" + "${_prefix}/lib64/cmake/${_cse_name}" + "${_prefix}/lib64/cmake/${_cse_UP}" + "${_prefix}/cmake/${_cse_name}" + "${_prefix}/cmake/${_cse_UP}" + "${_prefix}/CMake/${_cse_name}" + "${_prefix}/CMake/${_cse_UP}" + "${_prefix}/share/${_cse_name}/cmake" + "${_prefix}/share/${_cse_UP}/cmake" + "${_prefix}/share/${_cse_name}" + "${_prefix}/share/${_cse_UP}" + ) + + # Versioned siblings under lib/cmake and lib64/cmake + foreach(_base IN ITEMS + "${_prefix}/lib/cmake/${_cse_name}" + "${_prefix}/lib/cmake/${_cse_UP}" + "${_prefix}/lib64/cmake/${_cse_name}" + "${_prefix}/lib64/cmake/${_cse_UP}" + ) + if(EXISTS "${_base}") + _cse_mark("${_base}") if(DEFINED _cse_pkg_dir) - break() + set(_cse_pkg_dir "${_cse_pkg_dir}" PARENT_SCOPE) + return() endif() - endforeach() - endif() - if(NOT DEFINED _cse_pkg_dir) - # Some projects install /*/ directly with config inside - file(GLOB _cse_glob_flat_nc "${_prefix}/${_cse_name}*") - foreach(_cand IN LISTS _cse_glob_flat_nc) - _cse_try_dir("${_cand}") - if(DEFINED _cse_pkg_dir) - break() - endif() - endforeach() - endif() - if(NOT DEFINED _cse_pkg_dir) - file(GLOB _cse_glob_flat_uc "${_prefix}/${_cse_UP}*") - foreach(_cand IN LISTS _cse_glob_flat_uc) - _cse_try_dir("${_cand}") + endif() + + file(GLOB _sib "${_base}-*") + foreach(_cand IN LISTS _sib) + _cse_mark("${_cand}") if(DEFINED _cse_pkg_dir) - break() + set(_cse_pkg_dir "${_cse_pkg_dir}" PARENT_SCOPE) + return() endif() endforeach() - endif() - endmacro() + endforeach() + + foreach(_cand IN LISTS _cse_candidate_dirs) + _cse_mark("${_cand}") + if(DEFINED _cse_pkg_dir) + set(_cse_pkg_dir "${_cse_pkg_dir}" PARENT_SCOPE) + return() + endif() + endforeach() + endfunction() + + # Banner + if(NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Probing ${_cse_name} (" + "DIR='${_cse_dir}', ROOT='${_cse_root}', " + "${_cse_name}_DIR='${${_cse_name}_DIR}', ${_cse_UP}_DIR='${${_cse_UP}_DIR}', " + "${_cse_name}_ROOT='${${_cse_name}_ROOT}', ${_cse_UP}_ROOT='${${_cse_UP}_ROOT}')") + endif() - # --------------------------- - # 0) If caller already set *_DIR and it contains the config, prefer it. - # --------------------------- + # 0) Pre-set *_DIR if(DEFINED ${_cse_name}_DIR) - _cse_try_dir("${${_cse_name}_DIR}") + _cse_mark("${${_cse_name}_DIR}") endif() if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_UP}_DIR) - _cse_try_dir("${${_cse_UP}_DIR}") + _cse_mark("${${_cse_UP}_DIR}") endif() - # --------------------------- - # 1) Consider *_ROOT hints (both cases) - # --------------------------- + # 1) *_ROOT and explicit ROOT= if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_name}_ROOT) _cse_probe_prefix("${${_cse_name}_ROOT}") endif() if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_UP}_ROOT) _cse_probe_prefix("${${_cse_UP}_ROOT}") endif() + if(NOT DEFINED _cse_pkg_dir AND _cse_root) + _cse_probe_prefix("${_cse_root}") + endif() - # --------------------------- - # 2) Interpret 'directory' (exact config dir OR prefix), version-tolerant - # --------------------------- + # 2) Interpret DIR as exact config dir, then as prefix if(NOT DEFINED _cse_pkg_dir AND _cse_dir) - # a) Exact config dir - _cse_try_dir("${_cse_dir}") - - # b) If it looks like .../lib/cmake/, probe versioned siblings, - # even if the unversioned dir doesn't exist. + _cse_mark("${_cse_dir}") + if(NOT DEFINED _cse_pkg_dir) - if("${_cse_dir}" MATCHES "/lib/cmake/${_cse_name}$" OR "${_cse_dir}" MATCHES "/lib/cmake/${_cse_UP}$") - file(GLOB _cse_siblings_nc "${_cse_dir}-*") - foreach(_cand IN LISTS _cse_siblings_nc) - _cse_try_dir("${_cand}") + if("${_cse_dir}" MATCHES "/lib64?/cmake/${_cse_name}$" + OR "${_cse_dir}" MATCHES "/lib64?/cmake/${_cse_UP}$") + file(GLOB _sib_dir "${_cse_dir}-*") + foreach(_cand IN LISTS _sib_dir) + _cse_mark("${_cand}") if(DEFINED _cse_pkg_dir) break() endif() endforeach() - if(NOT DEFINED _cse_pkg_dir) - # Also check uppercase base when lowercased given, and vice versa - if("${_cse_dir}" MATCHES "/lib/cmake/${_cse_name}$") - file(GLOB _cse_siblings_uc "${_cse_dir}-${_cse_UP}*") # rarely useful, but harmless - foreach(_cand IN LISTS _cse_siblings_uc) - _cse_try_dir("${_cand}") - if(DEFINED _cse_pkg_dir) - break() - endif() - endforeach() - endif() - endif() endif() endif() - - # c) Otherwise treat as prefix and probe typical subpaths + if(NOT DEFINED _cse_pkg_dir) _cse_probe_prefix("${_cse_dir}") endif() endif() - # --------------------------- - # 3) Fall back to probing CMAKE_PREFIX_PATH entries - # --------------------------- - if(NOT DEFINED _cse_pkg_dir AND DEFINED CMAKE_PREFIX_PATH AND CMAKE_PREFIX_PATH) + # 3) CMAKE_PREFIX_PATH + if(NOT DEFINED _cse_pkg_dir AND CMAKE_PREFIX_PATH) foreach(_cpp IN LISTS CMAKE_PREFIX_PATH) _cse_probe_prefix("${_cpp}") if(DEFINED _cse_pkg_dir) @@ -368,23 +418,26 @@ macro(CONFIG_STANDARD_EXTERNAL name config_file directory) endforeach() endif() - # --------------------------- - # 4) If found, cache it and run find_package in CONFIG mode - # --------------------------- + # CONFIG_ONLY → prefer config packages during this call + if(_CSE_CONFIG_ONLY) + set(_cse_prev_pref "${CMAKE_FIND_PACKAGE_PREFER_CONFIG}") + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + endif() + + # 4) If found, cache *_DIR and call find_package(CONFIG) if(DEFINED _cse_pkg_dir) - # Cache both case variants for compatibility set(${_cse_name}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory" FORCE) set(${_cse_UP}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory (upper)" FORCE) - # Prefer config packages - set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) + if(NOT _CSE_QUIET) + list(JOIN _cse_cfgs ", " _cfgs_join) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name}: using '${_cfgs_join}' in '${_cse_pkg_dir}'") + endif() - # Use the exact case 'name' the caller provided find_package(${_cse_name} CONFIG QUIET - HINTS "${${_cse_name}_DIR}" "${${_cse_name}_ROOT}" "${${_cse_UP}_ROOT}" + HINTS "${${_cse_name}_DIR}" "${${_cse_name}_ROOT}" "${${_cse_UP}_ROOT}" "${_cse_root}" ) - # Normalize FOUND across case variants if(DEFINED ${_cse_name}_FOUND AND ${_cse_name}_FOUND) set(_cse_found TRUE) elseif(DEFINED ${_cse_UP}_FOUND AND ${_cse_UP}_FOUND) @@ -392,112 +445,152 @@ macro(CONFIG_STANDARD_EXTERNAL name config_file directory) endif() if(_cse_found) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} at '${_cse_pkg_dir}'") + if(NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} at '${_cse_pkg_dir}'") + endif() + list(APPEND _CONFIG_STANDARD_SUMMARY " ${_cse_name}: FOUND at '${_cse_pkg_dir}'") + set(_CONFIG_STANDARD_SUMMARY "${_CONFIG_STANDARD_SUMMARY}" PARENT_SCOPE) unset(_cse_found) unset(_cse_pkg_dir) unset(_cse_tried_dirs) + if(_CSE_CONFIG_ONLY) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG "${_cse_prev_pref}") + unset(_cse_prev_pref) + endif() return() endif() endif() - # --------------------------- - # 5) Not found — decide whether to fail now - # --------------------------- - if(_cse_REQUIRED) - # Pretty-print diagnostics - set(_cse_dir_print "${_cse_dir}") - set(_cse_name_dir "${${_cse_name}_DIR}") - set(_cse_up_dir "${${_cse_UP}_DIR}") - set(_cse_name_root "${${_cse_name}_ROOT}") - set(_cse_up_root "${${_cse_UP}_ROOT}") - + # 5) Not found + if(_CSE_REQUIRED) + if(NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") + endif() message(FATAL_ERROR "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found.\n" - " Looked for '${_cse_cfg}' under:\n" - "${_cse_tried_dirs}\n" + " Tried locations for (${_cse_cfgs}):\n${_cse_tried_dirs}\n" " Hints:\n" - " - ${_cse_name}_DIR='${_cse_name_dir}'\n" - " - ${_cse_UP}_DIR='${_cse_up_dir}'\n" - " - ${_cse_name}_ROOT='${_cse_name_root}'\n" - " - ${_cse_UP}_ROOT='${_cse_up_root}'\n" - " - directory='${_cse_dir_print}'\n" + " - ${_cse_name}_DIR='${${_cse_name}_DIR}'\n" + " - ${_cse_UP}_DIR='${${_cse_UP}_DIR}'\n" + " - ${_cse_name}_ROOT='${${_cse_name}_ROOT}'\n" + " - ${_cse_UP}_ROOT='${${_cse_UP}_ROOT}'\n" + " - DIR='${_cse_dir}'\n" + " - ROOT='${_cse_root}'\n" " - CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" " Hint: ensure the external is built/installed and re-run CMake." ) else() - message(STATUS - "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found yet. " - "This is expected before externals are built. " - "After building ${_cse_name}, re-run CMake." - ) + if(_CSE_VERBOSE AND NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") + elseif(NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found yet. This can be expected before externals are built.") + endif() + list(APPEND _CONFIG_STANDARD_SUMMARY " ${_cse_name}: NOT FOUND") + set(_CONFIG_STANDARD_SUMMARY "${_CONFIG_STANDARD_SUMMARY}" PARENT_SCOPE) + endif() + + if(_CSE_CONFIG_ONLY) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG "${_cse_prev_pref}") + unset(_cse_prev_pref) endif() - # Cleanup locals unset(_cse_pkg_dir) unset(_cse_tried_dirs) endmacro() -# Zlib: module first (most common), config if present; NO legacy USE_FILE. +# --- Calls for each external --- + +# ZLIB CONFIG_STANDARD_EXTERNAL(ZLIB - ROOT ${ZLIB_ROOT} DIR ${ZLIB_DIR} - # MODULE default allowed; CONFIG default allowed; not REQUIRED (two-pass) + ROOT "${ZLIB_ROOT}" + DIR "${ZLIB_DIR}" + CFGS "ZLIBConfig.cmake;zlibConfig.cmake;zlib-config.cmake" + # VERBOSE ) +# SQLite (SQLite vs SQLite3) CONFIG_STANDARD_EXTERNAL(SQLite - DIR ${SQLite_DIR} CONFIG_FILE SQLiteConfig.cmake + DIR "${SQLite_DIR}" + CFGS "SQLite3Config.cmake;SQLiteConfig.cmake" ) +# Teem (if a config is exported by your superbuild) CONFIG_STANDARD_EXTERNAL(Teem - DIR ${Teem_DIR} CONFIG_FILE TeemConfig.cmake + DIR "${Teem_DIR}" + CFG "TeemConfig.cmake" ) +# FreeType (case varies) CONFIG_STANDARD_EXTERNAL(Freetype - DIR ${Freetype_DIR} CONFIG_FILE FreetypeConfig.cmake + DIR "${Freetype_DIR}" + CFGS "FreetypeConfig.cmake;FreeTypeConfig.cmake" ) +# Cleaver2 CONFIG_STANDARD_EXTERNAL(Cleaver2 - DIR ${CLEAVER2_DIR} CONFIG_FILE Cleaver2Config.cmake + DIR "${CLEAVER2_DIR}" + CFG "Cleaver2Config.cmake" ) +# Python if(BUILD_WITH_PYTHON) - # Python packaging varies by version (Python3 vs Python). If you ship a config, specify CONFIG_ONLY. CONFIG_STANDARD_EXTERNAL(Python - DIR ${Python_DIR} CONFIG_FILE PythonConfig.cmake + DIR "${Python_DIR}" + CFGS "PythonConfig.cmake;Python3Config.cmake" ) endif() +# Boost — REQUIRED, prefer config package CONFIG_STANDARD_EXTERNAL(Boost - ROOT ${Boost_DIR} - CONFIG_ONLY # You likely rely on BoostConfig.cmake in your superbuild + ROOT "${SCI_BOOST_PREFIX}" + DIR "${Boost_DIR}" + CFG "BoostConfig.cmake" + CONFIG_ONLY REQUIRED ) +# Tiny (Tny) CONFIG_STANDARD_EXTERNAL(Tny - DIR ${TNY_DIR} CONFIG_FILE TnyConfig.cmake + DIR "${TNY_DIR}" + CFG "TnyConfig.cmake" ) +# LodePNG CONFIG_STANDARD_EXTERNAL(LodePng - DIR ${LODEPNG_DIR} CONFIG_FILE LodePngConfig.cmake + DIR "${LODEPNG_DIR}" + CFG "LodePngConfig.cmake" ) +# Tetgen (optional) if(WITH_TETGEN) CONFIG_STANDARD_EXTERNAL(Tetgen - DIR ${Tetgen_DIR} CONFIG_FILE TetgenConfig.cmake + DIR "${Tetgen_DIR}" + CFG "TetgenConfig.cmake" ) endif() +# GLEW (Windows) if(WIN32) CONFIG_STANDARD_EXTERNAL(GLEW - DIR ${GLEW_DIR} CONFIG_FILE GlewConfig.cmake + DIR "${GLEW_DIR}" + CFGS "GLEWConfig.cmake;GlewConfig.cmake" ) endif() +# Qwt (unless headless) if(NOT BUILD_HEADLESS) CONFIG_STANDARD_EXTERNAL(Qwt - DIR ${QWT_DIR} CONFIG_FILE QwtConfig.cmake + DIR "${QWT_DIR}" + CFG "QwtConfig.cmake" ) endif() +# One-shot summary (nice in CI logs) +if(DEFINED _CONFIG_STANDARD_SUMMARY) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Summary:\n${_CONFIG_STANDARD_SUMMARY}") + unset(_CONFIG_STANDARD_SUMMARY) +endif() + ######################################################################## # Custom compiler flags and definitions @@ -650,7 +743,6 @@ FIND_PACKAGE(OpenGL REQUIRED) ######################################################################## # Find and configure Qt - IF(NOT BUILD_HEADLESS) if (SCIRUN_QT_MAJOR STREQUAL "6") @@ -714,15 +806,11 @@ IF(UNIX) FIND_LIBRARY(DL_LIBRARY dl) ENDIF() - ######################################################################## # Includes SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) -#message("SCI_CTK_INCLUDE") -#message(${SCI_CTK_INCLUDE}) - INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${SCIRun_SOURCE_DIR}/ @@ -814,7 +902,6 @@ ADD_SUBDIRECTORY(Graphics) ADD_SUBDIRECTORY(Main) - ADD_SUBDIRECTORY(Testing) ######################################################################## @@ -999,9 +1086,9 @@ SET_PROPERTY(TARGET pugixml PROPERTY FOLDER "Externals") IF(BUILD_TESTING) SET_PROPERTY(TARGET gmock PROPERTY FOLDER "Testing Support") - SET_PROPERTY(TARGET gmock_main PROPERTY FOLDER "Testing Support") + SET_PROPERTY(TARGET gmock_main PROPERTY FOLDER "Testing Support") SET_PROPERTY(TARGET gtest PROPERTY FOLDER "Testing Support") - SET_PROPERTY(TARGET gtest_main PROPERTY FOLDER "Testing Support") + SET_PROPERTY(TARGET gtest_main PROPERTY FOLDER "Testing Support") SET_PROPERTY(TARGET Testing_Utils PROPERTY FOLDER "Testing Support") SET_PROPERTY(TARGET Testing_ModuleTestBase PROPERTY FOLDER "Testing Support") ENDIF() @@ -1066,12 +1153,12 @@ IF(BUILD_TESTING) IF(NOT BUILD_HEADLESS) SET_PROPERTY(TARGET Interface_Modules_Render_Tests PROPERTY FOLDER "Interface/Tests") - SET_PROPERTY(TARGET Modules_Dialog_Factory_Tests PROPERTY FOLDER "Interface/Tests") + SET_PROPERTY(TARGET Modules_Dialog_Factory_Tests PROPERTY FOLDER "Interface/Tests") ENDIF() IF(BUILD_WITH_PYTHON) SET_PROPERTY(TARGET Core_Python_Tests PROPERTY FOLDER "Core/Tests") SET_PROPERTY(TARGET Engine_Python_Tests PROPERTY FOLDER "Dataflow/Engine/Tests") - SET_PROPERTY(TARGET Modules_Python_Tests PROPERTY FOLDER "Modules/Python") + SET_PROPERTY(TARGET Modules_Python_Tests PROPERTY FOLDER "Modules/Python") ENDIF() ENDIF() @@ -1079,10 +1166,10 @@ SET_PROPERTY(TARGET xml2 PROPERTY FOLDER "Externals") IF(BUILD_WITH_PYTHON) SET_PROPERTY(TARGET Core_Python PROPERTY FOLDER "Core") - SET_PROPERTY(TARGET SCIRunPythonAPI PROPERTY FOLDER "Dataflow/Engine") - SET_PROPERTY(TARGET Modules_Python PROPERTY FOLDER "Modules/Python") + SET_PROPERTY(TARGET SCIRunPythonAPI PROPERTY FOLDER "Dataflow/Engine") + SET_PROPERTY(TARGET Modules_Python PROPERTY FOLDER "Modules/Python") IF(NOT BUILD_HEADLESS) - SET_PROPERTY(TARGET Interface_Modules_Python PROPERTY FOLDER "Interface/Modules") + SET_PROPERTY(TARGET Interface_Modules_Python PROPERTY FOLDER "Interface/Modules") ENDIF() ENDIF() @@ -1104,7 +1191,7 @@ SET(PACKAGING_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Welcome.txt" CACHE INTE # TODO: need release notes #SET(PACKAGING_RELEASENOTES "${CMAKE_CURRENT_SOURCE_DIR}/ReleaseNotes.txt" CACHE INTERNAL "Where to find the releasenotes file." FORCE ) -SET(PACKAGING_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\\\scirun5_256.png" CACHE INTERNAL "Packing icon." FORCE ) +SET(PACKAGING_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\scirun5_256.png" CACHE INTERNAL "Packing icon." FORCE ) MESSAGE(STATUS "Configuring SCIRun packaging") @@ -1131,7 +1218,6 @@ SET(CPACK_PACKAGE_VERSION "${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}.${SCI SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${APPLICATION_NAME}_${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}") - # other platform settings will be built up from here IF(APPLE) SET(CPACK_GENERATOR "productbuild;TGZ") @@ -1174,21 +1260,20 @@ ELSEIF(WIN32 AND NOT UNIX) SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8) - SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${APPLICATION_NAME}") + SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\${APPLICATION_NAME}") SET(CPACK_NSIS_MUI_ICON "${APPLICATION_WINDOWS_ICON}") SET(CPACK_NSIS_DISPLAY_NAME "${APPLICATION_NAME} ${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}") - SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\${APPLICATION_URL}") - SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\${APPLICATION_URL}") + SET(CPACK_NSIS_HELP_LINK "http:\\\\${APPLICATION_URL}") + SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\${APPLICATION_URL}") SET(CPACK_NSIS_CONTACT ${APPLICATION_CONTACT} ) SET(CPACK_NSIS_MODIFY_PATH ON) SET(CPACK_PACKAGE_EXECUTABLES "${APPLICATION_NAME}" "${APPLICATION_NAME}") SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " WriteRegStr HKCR '${APPLICATION_EXTENSION}' '' '${APPLICATION_NAME}' - WriteRegStr HKCR '${APPLICATION_NAME}' '' '${APPLICATION_NAME} Network File' - WriteRegStr HKCR '${APPLICATION_NAME}\\\\shell' '' 'open' - WriteRegStr HKCR '${APPLICATION_NAME}\\\\DefaultIcon' '' '$INSTDIR\\\\bin\\\\${APPLICATION_NAME}.exe,0' - WriteRegStr HKCR '${APPLICATION_NAME}\\\\shell\\\\open\\\\command' '' '$INSTDIR\\\\bin\\\\${APPLICATION_NAME}.exe \\\"%1\\\"' - WriteRegStr HKCR '${APPLICATION_NAME}\\\\shell\\\\edit\\\\command' '' '$INSTDIR\\\\bin\\\\${APPLICATION_NAME}.exe \\\"%1\\\"' + WriteRegStr HKCR '${APPLICATION_NAME}\\shell' '' 'open' + WriteRegStr HKCR '${APPLICATION_NAME}\\DefaultIcon' '' '$INSTDIR\\bin\\${APPLICATION_NAME}.exe,0' + WriteRegStr HKCR '${APPLICATION_NAME}\\shell\\open\\command' '' '$INSTDIR\\bin\\${APPLICATION_NAME}.exe \\\"%1\\\"' + WriteRegStr HKCR '${APPLICATION_NAME}\\shell\\edit\\command' '' '$INSTDIR\\bin\\${APPLICATION_NAME}.exe \\\"%1\\\"' System::Call 'Shell32::SHChangeNotify( i 0x800000, i 0, i 0, i 0)' ") SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " @@ -1209,4 +1294,4 @@ MARK_AS_ADVANCED(ENABLE_GCOV_DATAFILES) IF(ENABLE_GCOV_DATA_FILES) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") -ENDIF() +ENDIF() \ No newline at end of file From 103f83bcfacef4310f68e01d5b3e6cc808d39a9b Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 4 Feb 2026 11:32:02 -0700 Subject: [PATCH 021/140] finding boost in scirun src --- src/CMakeLists.txt | 186 ++++++++++++++++++++++++++++++--------------- 1 file changed, 123 insertions(+), 63 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29ce1fad2b..042c3bb07d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -223,6 +223,13 @@ endif() # --- Keyword-based CONFIG_STANDARD_EXTERNAL macro --- include(CMakeParseArguments) +# Initialize global summary storage once (safe to include multiple times) +get_property(_sum_init GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY SET) +if(NOT _sum_init) + set_property(GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY "") +endif() +unset(_sum_init) + # CONFIG_STANDARD_EXTERNAL(name [DIR ] [ROOT ] [CFG ] [CFGS ...] # [CONFIG_ONLY] [REQUIRED] [QUIET] [VERBOSE]) # @@ -232,7 +239,7 @@ include(CMakeParseArguments) # - CFG: Primary config filename to look for (e.g., ZLIBConfig.cmake). # - CFGS: Alternative config filenames to try if CFG not present (case variants). # - CONFIG_ONLY: Prefer config packages (sets CMAKE_FIND_PACKAGE_PREFER_CONFIG ON during the call). -# - REQUIRED: Fail configure if not found. +# - REQUIRED: Fail configure if not found (but optionally gated when in superbuild mode). # - QUIET: Less chatter. # - VERBOSE: Print every probed path when not found. # @@ -243,7 +250,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) set(_cse_bool REQUIRED CONFIG_ONLY QUIET VERBOSE) cmake_parse_arguments(_CSE "${_cse_bool}" "" "${_cse_one};${_cse_multi}" ${ARGN}) - # Case variants + # Derive case variants set(_cse_name "${name}") string(TOUPPER "${_cse_name}" _cse_UP) string(TOLOWER "${_cse_name}" _cse_LOW) @@ -274,16 +281,18 @@ macro(CONFIG_STANDARD_EXTERNAL name) unset(_cse_pkg_dir) set(_cse_tried_dirs "") - # Helpers - function(_cse_found_in_dir dir_out) - foreach(_cfg IN LISTS _cse_cfgs) - if(EXISTS "${dir_out}/${_cfg}") - set(_cse_pkg_dir "${dir_out}" PARENT_SCOPE) - return() - endif() - endforeach() - endfunction() + # Detect superbuild mode heuristically if not already set by the project + if(NOT DEFINED SCIRUN_SUPERBUILD_MODE) + string(FIND "${CMAKE_PREFIX_PATH}" "Externals/Install" _cse_sb_idx) + if(_cse_sb_idx GREATER -1) + set(SCIRUN_SUPERBUILD_MODE ON) + else() + set(SCIRUN_SUPERBUILD_MODE OFF) + endif() + unset(_cse_sb_idx) + endif() + # Helpers macro(_cse_mark _dir) if(NOT _dir) # skip @@ -308,7 +317,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) if(NOT _prefix) return() endif() - + # Common locations (with lib64, cmake/CMake, share) set(_cse_candidate_dirs "${_prefix}/lib/cmake/${_cse_name}" @@ -324,7 +333,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) "${_prefix}/share/${_cse_name}" "${_prefix}/share/${_cse_UP}" ) - + # Versioned siblings under lib/cmake and lib64/cmake foreach(_base IN ITEMS "${_prefix}/lib/cmake/${_cse_name}" @@ -339,7 +348,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) return() endif() endif() - + file(GLOB _sib "${_base}-*") foreach(_cand IN LISTS _sib) _cse_mark("${_cand}") @@ -349,7 +358,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) endif() endforeach() endforeach() - + foreach(_cand IN LISTS _cse_candidate_dirs) _cse_mark("${_cand}") if(DEFINED _cse_pkg_dir) @@ -389,7 +398,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) # 2) Interpret DIR as exact config dir, then as prefix if(NOT DEFINED _cse_pkg_dir AND _cse_dir) _cse_mark("${_cse_dir}") - + if(NOT DEFINED _cse_pkg_dir) if("${_cse_dir}" MATCHES "/lib64?/cmake/${_cse_name}$" OR "${_cse_dir}" MATCHES "/lib64?/cmake/${_cse_UP}$") @@ -402,7 +411,7 @@ macro(CONFIG_STANDARD_EXTERNAL name) endforeach() endif() endif() - + if(NOT DEFINED _cse_pkg_dir) _cse_probe_prefix("${_cse_dir}") endif() @@ -424,78 +433,129 @@ macro(CONFIG_STANDARD_EXTERNAL name) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) endif() - # 4) If found, cache *_DIR and call find_package(CONFIG) + # 4) Always attempt find_package() (even if _cse_pkg_dir wasn't detected). + # Assemble HINTS list from detected dir + all available hints. + set(_cse_hints "") if(DEFINED _cse_pkg_dir) + list(APPEND _cse_hints "${_cse_pkg_dir}") + # Cache *_DIR to stabilize subsequent configures set(${_cse_name}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory" FORCE) set(${_cse_UP}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory (upper)" FORCE) - if(NOT _CSE_QUIET) list(JOIN _cse_cfgs ", " _cfgs_join) message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name}: using '${_cfgs_join}' in '${_cse_pkg_dir}'") endif() + endif() + if(_cse_dir) + list(APPEND _cse_hints "${_cse_dir}") + endif() + if(DEFINED ${_cse_name}_DIR) + list(APPEND _cse_hints "${${_cse_name}_DIR}") + endif() + if(DEFINED ${_cse_UP}_DIR) + list(APPEND _cse_hints "${${_cse_UP}_DIR}") + endif() + if(DEFINED ${_cse_name}_ROOT) + list(APPEND _cse_hints "${${_cse_name}_ROOT}") + endif() + if(DEFINED ${_cse_UP}_ROOT) + list(APPEND _cse_hints "${${_cse_UP}_ROOT}") + endif() + if(_cse_root) + list(APPEND _cse_hints "${_cse_root}") + endif() + foreach(_cpp IN LISTS CMAKE_PREFIX_PATH) + list(APPEND _cse_hints "${_cpp}") + endforeach() + if(_cse_hints) + list(REMOVE_DUPLICATES _cse_hints) + endif() - find_package(${_cse_name} CONFIG QUIET - HINTS "${${_cse_name}_DIR}" "${${_cse_name}_ROOT}" "${${_cse_UP}_ROOT}" "${_cse_root}" - ) - - if(DEFINED ${_cse_name}_FOUND AND ${_cse_name}_FOUND) - set(_cse_found TRUE) - elseif(DEFINED ${_cse_UP}_FOUND AND ${_cse_UP}_FOUND) - set(_cse_found TRUE) - endif() + # Call find_package() in CONFIG mode quietly and let defaults work (no NO_DEFAULT_PATH). + if(_cse_hints) + find_package(${_cse_name} CONFIG QUIET HINTS ${_cse_hints}) + else() + find_package(${_cse_name} CONFIG QUIET) + endif() - if(_cse_found) - if(NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} at '${_cse_pkg_dir}'") - endif() - list(APPEND _CONFIG_STANDARD_SUMMARY " ${_cse_name}: FOUND at '${_cse_pkg_dir}'") - set(_CONFIG_STANDARD_SUMMARY "${_CONFIG_STANDARD_SUMMARY}" PARENT_SCOPE) - unset(_cse_found) - unset(_cse_pkg_dir) - unset(_cse_tried_dirs) - if(_CSE_CONFIG_ONLY) - set(CMAKE_FIND_PACKAGE_PREFER_CONFIG "${_cse_prev_pref}") - unset(_cse_prev_pref) + # Determine FOUND state robustly + set(_cse_found FALSE) + if(DEFINED ${_cse_name}_FOUND AND ${_cse_name}_FOUND) + set(_cse_found TRUE) + elseif(DEFINED ${_cse_UP}_FOUND AND ${_cse_UP}_FOUND) + set(_cse_found TRUE) + else() + # Fallback for well-known packages: check imported targets + if("${_cse_name}" STREQUAL "Boost") + if(TARGET Boost::headers OR TARGET Boost::boost) + set(_cse_found TRUE) endif() - return() endif() endif() - # 5) Not found - if(_CSE_REQUIRED) + # Update summary (GLOBAL property to avoid parent-scope warnings) + get_property(_sum GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY) + if(NOT _sum) + set(_sum "") + endif() + + if(_cse_found) if(NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") + if(DEFINED _cse_pkg_dir) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} at '${_cse_pkg_dir}'") + else() + message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} (via CMake search paths)") + endif() + endif() + if(DEFINED _cse_pkg_dir) + string(APPEND _sum " ${_cse_name}: FOUND at '${_cse_pkg_dir}'\n") + else() + string(APPEND _sum " ${_cse_name}: FOUND\n") endif() - message(FATAL_ERROR - "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found.\n" - " Tried locations for (${_cse_cfgs}):\n${_cse_tried_dirs}\n" - " Hints:\n" - " - ${_cse_name}_DIR='${${_cse_name}_DIR}'\n" - " - ${_cse_UP}_DIR='${${_cse_UP}_DIR}'\n" - " - ${_cse_name}_ROOT='${${_cse_name}_ROOT}'\n" - " - ${_cse_UP}_ROOT='${${_cse_UP}_ROOT}'\n" - " - DIR='${_cse_dir}'\n" - " - ROOT='${_cse_root}'\n" - " - CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" - " Hint: ensure the external is built/installed and re-run CMake." - ) else() - if(_CSE_VERBOSE AND NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") - elseif(NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found yet. This can be expected before externals are built.") + # Not found → decide whether to fail + if(_CSE_REQUIRED AND NOT SCIRUN_SUPERBUILD_MODE) + if(NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") + endif() + set_property(GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY "${_sum}") + # Fatal error for non-superbuild REQUIRED case + message(FATAL_ERROR + "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found.\n" + " Tried locations for (${_cse_cfgs}):\n${_cse_tried_dirs}\n" + " Hints:\n" + " - ${_cse_name}_DIR='${${_cse_name}_DIR}'\n" + " - ${_cse_UP}_DIR='${${_cse_UP}_DIR}'\n" + " - ${_cse_name}_ROOT='${${_cse_name}_ROOT}'\n" + " - ${_cse_UP}_ROOT='${${_cse_UP}_ROOT}'\n" + " - DIR='${_cse_dir}'\n" + " - ROOT='${_cse_root}'\n" + " - CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" + " Hint: ensure the external is built/installed and re-run CMake." + ) + else() + if(_CSE_VERBOSE AND NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") + elseif(NOT _CSE_QUIET) + message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found yet. This can be expected before externals are built.") + endif() + string(APPEND _sum " ${_cse_name}: NOT FOUND\n") endif() - list(APPEND _CONFIG_STANDARD_SUMMARY " ${_cse_name}: NOT FOUND") - set(_CONFIG_STANDARD_SUMMARY "${_CONFIG_STANDARD_SUMMARY}" PARENT_SCOPE) endif() + set_property(GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY "${_sum}") + unset(_sum) + + # Restore prefer-config policy if we changed it if(_CSE_CONFIG_ONLY) set(CMAKE_FIND_PACKAGE_PREFER_CONFIG "${_cse_prev_pref}") unset(_cse_prev_pref) endif() + # Cleanup unset(_cse_pkg_dir) unset(_cse_tried_dirs) + unset(_cse_hints) endmacro() # --- Calls for each external --- From 6d0402abdf0ccf082f73989e57e45e82dede08a1 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 4 Feb 2026 13:11:44 -0700 Subject: [PATCH 022/140] installing boost headers --- Superbuild/BoostExternal.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 5a95778f97..edda3d0f54 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -60,6 +60,7 @@ set(_BOOST_LIBS_SAFE thread timer type_erasure + utility wave ) @@ -107,6 +108,7 @@ ExternalProject_Add(Boost_external -DBUILD_TESTING=OFF # Install headers + requested libs; header-only libs are always usable -DBOOST_INSTALL_HEADERS=ON + -DBOOST_INSTALL_LAYOUT=system # IMPORTANT: pass the list as a single argument -DBOOST_INCLUDE_LIBRARIES:STRING=${_BOOST_LIBS} # Propagate toolchain/flags if you define them in the parent From bac617943587b77a8e121b12cc8b9b7899e31418 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Feb 2026 12:53:32 -0700 Subject: [PATCH 023/140] fixed glm headers but there are more for boost, glew, tny, lodepng --- Superbuild/Superbuild.cmake | 121 ++++++++++++++++++++++++++++++++---- src/CMakeLists.txt | 42 ++++++++++++- 2 files changed, 148 insertions(+), 15 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index ad2399d268..0150d99c33 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -514,9 +514,51 @@ if(NOT BUILD_HEADLESS) endif() endif() -########################################### -# Explicit Zlib/Boost hints (good to keep) -########################################### +# ----------------- Helpers to export include/lib/config dirs ----------------- +function(_sb_export_inc_lib pkg target) + # Export include/lib dirs for an ExternalProject target, even if not yet built. + ExternalProject_Get_Property(${target} INSTALL_DIR) + if(NOT INSTALL_DIR) + message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") + endif() + + # Standard install subdirs + set(_inc "${INSTALL_DIR}/include") + if(EXISTS "${INSTALL_DIR}/lib64") + set(_lib "${INSTALL_DIR}/lib64") + else() + set(_lib "${INSTALL_DIR}/lib") + endif() + + # Unconditionally export include/lib cache args so SCIRun gets them at configure time + set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") + + # Only add lib dir if it exists (some are header-only) + if(EXISTS "${_lib}") + set(${pkg}_LIB_DIR "${_lib}" CACHE PATH "${pkg} lib dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_LIB_DIR:PATH=${${pkg}_LIB_DIR}") + endif() + + set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) + message(STATUS "[superbuild] ${pkg}: include=${_inc} lib=${_lib}") +endfunction() + +function(_sb_export_config pkg target config_subdir) + # Export a *Config.cmake directory for config-package find_package + ExternalProject_Get_Property(${target} INSTALL_DIR) + if(NOT INSTALL_DIR) + message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") + endif() + set(_cfg "${INSTALL_DIR}/${config_subdir}") + # Cache even if it might not exist yet; it will by the time SCIRun compiles + set(${pkg}_DIR "${_cfg}" CACHE PATH "${pkg}Config.cmake dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") + set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) + message(STATUS "[superbuild] ${pkg}_DIR=${_cfg}") +endfunction() + +# ----------------- Zlib + Boost ----------------- ExternalProject_Get_Property(Zlib_external INSTALL_DIR) set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") @@ -524,19 +566,74 @@ list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" "-DZLIB_USE_STATIC_LIBS:BOOL=ON" - "-DBoost_DIR:PATH=${Boost_DIR}" # points to folder containing BoostConfig.cmake + "-DBoost_DIR:PATH=${Boost_DIR}" # folder with BoostConfig.cmake "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" ) -# If Zlib_DIR is known from _export_config_dir, pass it (helps config-package resolution) +# If Zlib config dir is known, pass it as well (improves config-package finding) if(DEFINED Zlib_DIR) list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_DIR:PATH=${Zlib_DIR}") +else() + # Try to export it based on typical layout + _sb_export_config(Zlib Zlib_external "lib/cmake/zlib") endif() -# Compose ONE clean CMAKE_PREFIX_PATH for SCIRun +# ----------------- Export include/lib/config dirs for other externals ----------------- +# GLM (header-only) +_sb_export_inc_lib(GLM GLM_external) # sets GLM_INCLUDE_DIR + +# Eigen (header-only; some builds also export a config) +_sb_export_inc_lib(Eigen Eigen_external) +# If your Eigen install has a config dir, uncomment the next line: +# _sb_export_config(Eigen3 Eigen_external "share/eigen3/cmake") + +# spdlog +_sb_export_inc_lib(SpdLog SpdLog_external) +_sb_export_config(spdlog SpdLog_external "lib/cmake/spdlog") + +# GLEW +_sb_export_inc_lib(GLEW Glew_external) +# Some generators put a config under lib/cmake; if your Glew has config: +# _sb_export_config(GLEW Glew_external "lib/cmake/glew") + +# Freetype +_sb_export_inc_lib(Freetype Freetype_external) +_sb_export_config(Freetype Freetype_external "lib/cmake/freetype") + +# SQLite (optional; used by some builds) +_sb_export_inc_lib(SQLite SQLite_external) + +# Qwt +_sb_export_inc_lib(Qwt Qwt_external) +# If Qwt exports a config, add: +# _sb_export_config(Qwt Qwt_external "lib/cmake/qwt") + +# Python (using the one you already pass via PYTHON_EXECUTABLE) +_sb_export_inc_lib(Python Python_external) +# If there is a config dir, add it similarly. + +# Teem +_sb_export_inc_lib(Teem Teem_external) +_sb_export_config(Teem Teem_external "lib/cmake/Teem") + +# Tny (header-only/small lib) +_sb_export_inc_lib(TNY Tny_external) + +# LodePNG (header-only/small lib) +_sb_export_inc_lib(LODEPNG LodePng_external) + +# Cleaver2 +_sb_export_inc_lib(CLEAVER2 Cleaver2_external) +# If Cleaver2 exports a config: +# _sb_export_config(Cleaver2 Cleaver2_external "lib/cmake/Cleaver2") + +# Tetgen +_sb_export_inc_lib(TETGEN Tetgen_external) + +# ----------------- Re-compose the single CMAKE_PREFIX_PATH ----------------- get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) set(_joined_prefixes "") if(_acc) @@ -544,7 +641,7 @@ if(_acc) string(JOIN ";" _joined_prefixes ${_acc}) endif() -# ESCAPE the semicolons so the whole value stays ONE list element +# escape semicolons so the list stays as a single CMake cache entry set(_joined_prefixes_escaped "${_joined_prefixes}") string(REPLACE ";" "\\;" _joined_prefixes_escaped "${_joined_prefixes}") @@ -557,19 +654,17 @@ foreach(arg IN LISTS SCIRUN_CACHE_ARGS) endforeach() set(SCIRUN_CACHE_ARGS "${_filtered}") -# Append exactly ONE CMAKE_PREFIX_PATH argument (escaped) +# Append exactly one CMAKE_PREFIX_PATH argument list(APPEND SCIRUN_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${_joined_prefixes_escaped}") -# Log what we will pass +# ----------------- Log the final arguments passed to SCIRun ----------------- message(STATUS "[superbuild] Final CMAKE_PREFIX_PATH for SCIRun: ${_joined_prefixes}") message(STATUS "Superbuild passing to SCIRun:") foreach(arg IN LISTS SCIRUN_CACHE_ARGS) message(STATUS " ${arg}") endforeach() -########################################### -# ExternalProject for SCIRun -########################################### +# ----------------- SCIRun ExternalProject remains the same ----------------- ExternalProject_Add(SCIRun_external DEPENDS ${SCIRun_DEPENDENCIES} DOWNLOAD_COMMAND "" @@ -579,7 +674,7 @@ ExternalProject_Add(SCIRun_external INSTALL_COMMAND "" ) -# Optional: ensure Zlib artifacts exist before SCIRun config (keeps order tidy) +# Optional: keep order tidy for artifacts needed during SCIRun configure ExternalProject_Add_Step(SCIRun_external wait_for_zlib COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts before SCIRun configure..." DEPENDEES download diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 042c3bb07d..8ca5a3621f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -871,7 +871,16 @@ ENDIF() SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) -INCLUDE_DIRECTORIES( +# Helper to pretty-print a list variable line by line +function(print_list name) + message(STATUS "${name}:") + foreach(item IN LISTS ${name}) + message(STATUS " - ${item}") + endforeach() +endfunction() + +# Collect the include dirs in one list first (mirrors your INCLUDE_DIRECTORIES block) +set(_SCIRUN_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${SCIRun_SOURCE_DIR}/ ${SCIRun_SOURCE_DIR}/include @@ -885,7 +894,7 @@ INCLUDE_DIRECTORIES( ${SCIRun_BINARY_DIR}/include ${SCI_TEEM_INCLUDE} ${SCI_ZLIB_INCLUDE} - ${GLM_DIR} + ${GLM_INCLUDE_DIR} ${SPDLOG_DIR}/include ${Eigen_DIR} ${SCI_TNY_INCLUDE} @@ -894,6 +903,35 @@ INCLUDE_DIRECTORIES( ${SCI_CLEAVER2_INCLUDE} ) +# Print them before applying +print_list("_SCIRUN_INCLUDE_DIRS") + +# Then actually apply them +include_directories(${_SCIRUN_INCLUDE_DIRS}) + +#INCLUDE_DIRECTORIES( +# ${CMAKE_CURRENT_BINARY_DIR} +# ${SCIRun_SOURCE_DIR}/ +# ${SCIRun_SOURCE_DIR}/include +# ${SCIRun_SOURCE_DIR}/Externals/libxml2/include +# ${SCIRun_SOURCE_DIR}/Externals/spire/ +# ${SCIRun_SOURCE_DIR}/Externals/submodules/googletest/googletest/include +# ${SCIRun_SOURCE_DIR}/Externals/submodules/googletest/googlemock/include +# ${CMAKE_CURRENT_BINARY_DIR}/Externals/libxml2/include +# ${SCIRun_SOURCE_DIR}/Externals/ +# ${SCIRun_BINARY_DIR}/ +# ${SCIRun_BINARY_DIR}/include +# ${SCI_TEEM_INCLUDE} +# ${SCI_ZLIB_INCLUDE} +# ${GLM_INCLUDE_DIR} +# ${SPDLOG_DIR}/include +# ${Eigen_DIR} +# ${SCI_TNY_INCLUDE} +# ${SCI_LODEPNG_INCLUDE} +# ${SCI_QWT_INCLUDE} +# ${SCI_CLEAVER2_INCLUDE} +#) + INCLUDE_DIRECTORIES(SYSTEM ${SCI_BOOST_INCLUDE}) ADD_DEFINITIONS(-DQT_NO_KEYWORDS) From e432dd06e32473d5bf9176093dc1ed95d4f55b10 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Feb 2026 17:03:17 -0700 Subject: [PATCH 024/140] cmake --- Superbuild/BoostExternal.cmake | 134 +++--- Superbuild/Superbuild.cmake | 780 ++++++++++++++++----------------- src/CMakeLists.txt | 92 +++- 3 files changed, 532 insertions(+), 474 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index edda3d0f54..4285988487 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -30,61 +30,32 @@ set(_boost_git_tag "v1.90.0") include(ExternalProject) -# ========= Library selection strategy ========= -# Boost CMake superproject builds compiled libs only when listed in BOOST_INCLUDE_LIBRARIES. -# Header-only libs (e.g., signals2, asio, any, optional, variant, etc.) need no listing. - -# A maximal "safe" set that builds everywhere without extra deps: -set(_BOOST_LIBS_SAFE - atomic - chrono - container - context - coroutine - date_time - exception +# ========= Compiled library selection ========= +# Build ONLY the compiled libraries SCIRun needs to link. +# We will generate + install the FULL header tree separately via `b2 headers`. +set(_BOOST_LIBS filesystem - fiber - graph - iostreams - locale - log - math - nowide - program_options - random - regex - serialization - stacktrace system - thread - timer - type_erasure - utility - wave + atomic + # Add here only if/when linker complains: + # chrono; thread; regex; program_options; iostreams; date_time; serialization ) -# Optional libraries that require external dependencies: -option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" OFF) -option(BOOST_ENABLE_MPI "Build Boost.MPI if MPI is available" OFF) -option(BOOST_ENABLE_TEST "Build Boost.Test (unit test framework)" OFF) +# Optional compiled libs (usually OFF) +option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" OFF) +option(BOOST_ENABLE_MPI "Build Boost.MPI if MPI is available" OFF) +option(BOOST_ENABLE_TEST "Build Boost.Test (unit test framework)" OFF) -set(_BOOST_LIBS_OPTIONAL "") if(BOOST_ENABLE_PYTHON) - list(APPEND _BOOST_LIBS_OPTIONAL python) + list(APPEND _BOOST_LIBS python) endif() if(BOOST_ENABLE_MPI) - list(APPEND _BOOST_LIBS_OPTIONAL mpi) - # graph_parallel depends on MPI as well; include when MPI is on: - list(APPEND _BOOST_LIBS_OPTIONAL graph_parallel) + list(APPEND _BOOST_LIBS mpi graph_parallel) endif() if(BOOST_ENABLE_TEST) - list(APPEND _BOOST_LIBS_OPTIONAL test) + list(APPEND _BOOST_LIBS test) endif() -# Final list passed to the superproject: -set(_BOOST_LIBS ${_BOOST_LIBS_SAFE} ${_BOOST_LIBS_OPTIONAL}) - # ========= ExternalProject definition ========= ExternalProject_Add(Boost_external GIT_REPOSITORY ${_boost_git_url} @@ -92,29 +63,26 @@ ExternalProject_Add(Boost_external GIT_SHALLOW FALSE GIT_PROGRESS TRUE + # Ensure submodules are available UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir git submodule update --init --recursive BUILD_IN_SOURCE OFF - # Configure Boost with CMake Superproject + # Configure Boost with CMake Superproject (build only compiled libs) CONFIGURE_COMMAND ${CMAKE_COMMAND} -S -B -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=$,${CMAKE_BUILD_TYPE},$> # support single & multi-config + -DCMAKE_BUILD_TYPE=$,${CMAKE_BUILD_TYPE},$> # single & multi-config -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DBUILD_TESTING=OFF - # Install headers + requested libs; header-only libs are always usable -DBOOST_INSTALL_HEADERS=ON -DBOOST_INSTALL_LAYOUT=system - # IMPORTANT: pass the list as a single argument - -DBOOST_INCLUDE_LIBRARIES:STRING=${_BOOST_LIBS} - # Propagate toolchain/flags if you define them in the parent + -DBOOST_INCLUDE_LIBRARIES:STRING=${_BOOST_LIBS} # compiled libs only -DCMAKE_CXX_FLAGS=${boost_CXX_Flags} - # Build / Install (multi-config generators honor ${CMAKE_CFG_INTDIR}) BUILD_COMMAND ${CMAKE_COMMAND} --build --config ${CMAKE_CFG_INTDIR} @@ -122,32 +90,66 @@ ExternalProject_Add(Boost_external ${CMAKE_COMMAND} --build --target install --config ${CMAKE_CFG_INTDIR} ) -# ========= Export properties to the superbuild ========= +# ========= Cross-platform b2 header staging ========= +# 1) Bootstrap b2 +if(WIN32) + set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) + set(_B2_HEADERS_CMD cmd /c .\\b2 headers) +else() + # Linux/macOS + set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) + set(_B2_HEADERS_CMD ./b2 headers) +endif() + +ExternalProject_Add_Step(Boost_external bootstrap_b2 + COMMAND ${_B2_BOOTSTRAP_CMD} + WORKING_DIRECTORY + DEPENDEES update + DEPENDERS configure # ensure b2 exists before configure/build + COMMENT "Bootstrapping Boost.Build (b2)" +) + +# 2) Generate the full 'boost/' header tree +ExternalProject_Add_Step(Boost_external stage_headers + COMMAND ${_B2_HEADERS_CMD} + WORKING_DIRECTORY + DEPENDEES bootstrap_b2 + DEPENDERS install # must happen before/with install + COMMENT "Running 'b2 headers' to generate the boost/ header tree" +) + +# 3) Copy the entire header tree into the install prefix +ExternalProject_Add_Step(Boost_external install_full_headers + COMMAND ${CMAKE_COMMAND} -E make_directory /include + COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost + COMMAND ${CMAKE_COMMAND} -E copy_directory /boost /include/boost + DEPENDEES stage_headers + DEPENDERS install + COMMENT "Copying full Boost headers to /include/boost" +) + +# ========= Export properties for downstream ========= ExternalProject_Get_Property(Boost_external INSTALL_DIR) ExternalProject_Get_Property(Boost_external SOURCE_DIR) # Convenience prefix set(SCI_BOOST_PREFIX "${INSTALL_DIR}") -# Help both Config and Module (FindBoost) modes in downstream projects: -# - Boost_ROOT + CMAKE_PREFIX_PATH: lets find_package(Boost CONFIG) discover Boost- automatically. -# - We'll still compute Boost_DIR explicitly for consumers that cache/use it directly. +# For both Config and Module find modes set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix" FORCE) -# Make sure the prefix is searched (prefer prepending so our Boost wins over system) +# Make our Boost take precedence over system if(NOT DEFINED CMAKE_PREFIX_PATH) set(CMAKE_PREFIX_PATH "") endif() list(PREPEND CMAKE_PREFIX_PATH "${SCI_BOOST_PREFIX}") -# Re-cache the modified prefix path for dependents in the same configure set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE PATH "Prefix search path" FORCE) -# Compute Boost_DIR robustly (handles versioned 'Boost-' and rare unversioned 'Boost/') +# Compute Boost_DIR robustly (versioned Boost- or fallback Boost/) set(_boost_cmake_root "${SCI_BOOST_PREFIX}/lib/cmake") set(_boost_dir_guess "") if(EXISTS "${_boost_cmake_root}") - # Prefer versioned directories (Boost-1.90.0, Boost-1.91.0, ...) file(GLOB _boost_cfg_candidates "${_boost_cmake_root}/Boost-*") foreach(_cand IN LISTS _boost_cfg_candidates) if(EXISTS "${_cand}/BoostConfig.cmake") @@ -155,21 +157,15 @@ if(EXISTS "${_boost_cmake_root}") break() endif() endforeach() - - # Fallback: some older packs use unversioned 'Boost/' if(NOT _boost_dir_guess AND EXISTS "${_boost_cmake_root}/Boost/BoostConfig.cmake") set(_boost_dir_guess "${_boost_cmake_root}/Boost") endif() endif() -# Expose Boost_DIR for consumers that look it up directly -# (It may not exist on the first configure until after install; that's okay.) set(Boost_DIR "${_boost_dir_guess}" CACHE PATH "Boost package directory (for find_package Boost)" FORCE) -# Fallback hints for Module mode (FindBoost.cmake) +# Concrete include/lib paths (SCIRun consumes these) set(SCI_BOOST_INCLUDE "${SCI_BOOST_PREFIX}/include" CACHE PATH "Boost include directory" FORCE) - -# Handle lib vs lib64 on Windows and some Linux distros if (EXISTS "${SCI_BOOST_PREFIX}/lib64") set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib64") else() @@ -177,23 +173,23 @@ else() endif() set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library directory" FORCE) -# Optional: legacy use file (kept only if your build still includes it) +# Optional: legacy use file set(SUPERBUILD_DIR "${CMAKE_CURRENT_LIST_DIR}") set(SCI_BOOST_USE_FILE "${SCI_BOOST_PREFIX}/UseBoost.cmake") if (EXISTS "${SUPERBUILD_DIR}/UseBoost.cmake") configure_file(${SUPERBUILD_DIR}/UseBoost.cmake ${SCI_BOOST_USE_FILE} COPYONLY) endif() -# Diagnostics (helpful during first passes) +# Diagnostics message(STATUS "[Boost_ext] INSTALL_DIR: ${SCI_BOOST_PREFIX}") message(STATUS "[Boost_ext] Boost_ROOT: ${Boost_ROOT}") message(STATUS "[Boost_ext] Boost_DIR: ${Boost_DIR}") message(STATUS "[Boost_ext] Include dir: ${SCI_BOOST_INCLUDE}") message(STATUS "[Boost_ext] Lib dir: ${SCI_BOOST_LIBRARY_DIR}") -message(STATUS "[Boost_ext] BOOST_INCLUDE_LIBRARIES: ${_BOOST_LIBS}") +message(STATUS "[Boost_ext] BOOST_INCLUDE_LIBRARIES (compiled only): ${_BOOST_LIBS}") if (EXISTS "${Boost_DIR}/BoostConfig.cmake") message(STATUS "[Boost_ext] Found BoostConfig.cmake at: ${Boost_DIR}/BoostConfig.cmake") else() message(STATUS "[Boost_ext] (Will be created after Boost install) Expected under: ${_boost_cmake_root}") -endif() +endif() \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 0150d99c33..e0a4e48755 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -24,58 +24,57 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -########################################### -# TODO: build from archive - Git not used -SET(compress_type "GIT" CACHE INTERNAL "") -SET(ep_base "${CMAKE_BINARY_DIR}/Externals" CACHE INTERNAL "") +cmake_minimum_required(VERSION 3.20) + +# ========================= +# Global setup / policies +# ========================= +set(compress_type "GIT" CACHE INTERNAL "") +set(ep_base "${CMAKE_BINARY_DIR}/Externals" CACHE INTERNAL "") -# Silence CMP0135 warning for ExternalProject downloads (NEW is safer) if(POLICY CMP0135) - cmake_policy(SET CMP0135 NEW) + cmake_policy(SET CMP0135 NEW) # ExternalProject downloads endif() -########################################### -# Set default CMAKE_BUILD_TYPE if empty for Unix Makefile builds -IF(CMAKE_GENERATOR MATCHES "Unix Makefiles" AND NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE Release CACHE STRING - "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) -ENDIF() - -FIND_PACKAGE(Git) -IF(NOT GIT_FOUND) - MESSAGE(FATAL_ERROR "Cannot find Git. Git is required for SCIRun's Superbuild") -ENDIF() +# Default build type for Unix Makefiles if not set +if(CMAKE_GENERATOR MATCHES "Unix Makefiles" AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build: None Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif() -INCLUDE(ExternalProject) +find_package(Git REQUIRED) +include(ExternalProject) -########################################### -# DETERMINE ARCHITECTURE -########################################### -IF(CMAKE_SIZEOF_VOID_P MATCHES 8) - SET(SCIRUN_BITS 64) -ELSE() - SET(SCIRUN_BITS 32) -ENDIF() +# ========================= +# Architecture +# ========================= +if(CMAKE_SIZEOF_VOID_P MATCHES 8) + set(SCIRUN_BITS 64) +else() + set(SCIRUN_BITS 32) +endif() -########################################### +# ========================= # Options -########################################### -OPTION(BUILD_TESTING "Build with tests." OFF) -OPTION(GENERATE_COMPILATION_DATABASE "Generate Compilation Database." ON) -OPTION(BUILD_WITH_PYTHON "Build with python support." ON) -OPTION(WITH_TETGEN "Build Tetgen." ON) -OPTION(WITH_OSPRAY "Build Ospray." OFF) -OPTION(BUILD_WITH_SCIRUN_DATA "Svn checkout data" OFF) -IF(WIN32) - OPTION(SCIRUN_SHOW_CONSOLE "Show Windows console when running SCIRun (useful for debugging)." ON) - MARK_AS_ADVANCED(SCIRUN_SHOW_CONSOLE) -ENDIF() -OPTION(BUILD_HEADLESS "Build SCIRun without GUI." OFF) - -########################################### -# Prefix collector (build ONE clean CMAKE_PREFIX_PATH for SCIRun) -########################################### -# Use a GLOBAL PROPERTY so values persist across functions/macros. +# ========================= +option(BUILD_TESTING "Build with tests." OFF) +option(GENERATE_COMPILATION_DATABASE "Generate Compilation Database." ON) +option(BUILD_WITH_PYTHON "Build with python support." ON) +option(WITH_TETGEN "Build Tetgen." ON) +option(WITH_OSPRAY "Build Ospray." OFF) +option(BUILD_WITH_SCIRUN_DATA "Svn checkout data" OFF) + +if(WIN32) + option(SCIRUN_SHOW_CONSOLE "Show Windows console when running SCIRun." ON) + mark_as_advanced(SCIRUN_SHOW_CONSOLE) +endif() + +option(BUILD_HEADLESS "Build SCIRun without GUI." OFF) + +# ========================= +# Prefix collector +# ========================= +# Keep one clean CMAKE_PREFIX_PATH for SCIRun via GLOBAL PROPERTY set_property(GLOBAL PROPERTY SCIRUN_PREFIXES "") function(sb_prefix_append dir_in) @@ -92,96 +91,67 @@ function(sb_prefix_append dir_in) set_property(GLOBAL PROPERTY SCIRUN_PREFIXES "${_acc}") endfunction() -########################################### -# Configure Qt -########################################### - -# Allow user to choose whether to use Qt5 or Qt6 +# ========================= +# Qt selection +# ========================= set(SCIRUN_QT_MAJOR "6" CACHE STRING "Qt major version to use (5 or 6)") set_property(CACHE SCIRUN_QT_MAJOR PROPERTY STRINGS 5 6) - -# Minimum versions set(QT5_MIN_VERSION "5.15.2") set(QT6_MIN_VERSION "6.3.0") - -# User provides Qt base path -set(Qt_PATH "" CACHE PATH "Path to Qt installation (e.g. C:/Qt/6.10.1/msvc2022_64)") +set(Qt_PATH "" CACHE PATH "Qt install prefix (e.g. C:/Qt/6.10.1/msvc2022_64)") if (NOT BUILD_HEADLESS) - - # 1) Validate Qt_PATH if (NOT IS_DIRECTORY "${Qt_PATH}") message(FATAL_ERROR - "Qt_PATH is invalid. Point it to the Qt install prefix that contains lib/, bin/, and (lib/cmake/Qt6 or lib/cmake/Qt5).\n" - "Example (MSVC 2022 x64): C:/Qt/6.10.1/msvc2022_64" - ) + "Qt_PATH invalid. Point it to the Qt install prefix with lib/, bin/, and lib/cmake/Qt[56].\n" + "Example: C:/Qt/6.10.1/msvc2022_64") endif() - # 2) Make the prefix visible to find_package (and collect it) file(TO_CMAKE_PATH "${Qt_PATH}" _Qt_PREFIX) list(PREPEND CMAKE_PREFIX_PATH "${_Qt_PREFIX}") sb_prefix_append("${_Qt_PREFIX}") - # 3) Pick Qt major and set DIR to the exact config folder if (SCIRUN_QT_MAJOR STREQUAL "6") set(QT_MIN_VERSION "${QT6_MIN_VERSION}") set(Qt6_DIR "${_Qt_PREFIX}/lib/cmake/Qt6") if (NOT EXISTS "${Qt6_DIR}/Qt6Config.cmake") - message(FATAL_ERROR - "Qt6Config.cmake not found at '${Qt6_DIR}'.\n" - "Verify Qt 6 is installed for your compiler and Qt_PATH is correct." - ) + message(FATAL_ERROR "Qt6Config.cmake not found at '${Qt6_DIR}'") endif() - - message(STATUS "[superbuild] Qt_PATH='${Qt_PATH}'") - message(STATUS "[superbuild] Using Qt6_DIR='${Qt6_DIR}'") - message(STATUS "[superbuild] CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'") - find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL OpenGLWidgets HINTS "${Qt_PATH}" ) - message(STATUS "Using Qt6 found at: ${Qt6_DIR}") - + message(STATUS "[superbuild] Using Qt6_DIR='${Qt6_DIR}'") elseif (SCIRUN_QT_MAJOR STREQUAL "5") set(QT_MIN_VERSION "${QT5_MIN_VERSION}") set(Qt5_DIR "${_Qt_PREFIX}/lib/cmake/Qt5") if (NOT EXISTS "${Qt5_DIR}/Qt5Config.cmake") - message(FATAL_ERROR - "Qt5Config.cmake not found at '${Qt5_DIR}'.\n" - "Verify Qt 5 is installed for your compiler and Qt_PATH is correct." - ) + message(FATAL_ERROR "Qt5Config.cmake not found at '${Qt5_DIR}'") endif() - - message(STATUS "[superbuild] Qt_PATH='${Qt_PATH}'") - message(STATUS "[superbuild] Using Qt5_DIR='${Qt5_DIR}'") - message(STATUS "[superbuild] CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'") - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL HINTS "${Qt_PATH}" ) - message(STATUS "Using Qt5 found at: ${Qt5_DIR}") - + message(STATUS "[superbuild] Using Qt5_DIR='${Qt5_DIR}'") else() message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Got: '${SCIRUN_QT_MAJOR}'") endif() - # 4) Locate qmake for the Qwt build step + # Locate qmake (needed by Qwt external) if (SCIRUN_QT_MAJOR STREQUAL "6") if (TARGET Qt6::qmake) get_target_property(_qmake_path Qt6::qmake LOCATION) else() - get_filename_component(_qt6_cmake_dir "${Qt6_DIR}" DIRECTORY) # .../lib/cmake - get_filename_component(_qt6_prefix "${_qt6_cmake_dir}" DIRECTORY) # .../lib - get_filename_component(_qt6_root "${_qt6_prefix}" DIRECTORY) # ... + get_filename_component(_qt6_cmake_dir "${Qt6_DIR}" DIRECTORY) + get_filename_component(_qt6_prefix "${_qt6_cmake_dir}" DIRECTORY) + get_filename_component(_qt6_root "${_qt6_prefix}" DIRECTORY) if (WIN32) set(_qmake_path "${_qt6_root}/bin/qmake.exe") else() set(_qmake_path "${_qt6_root}/bin/qmake") endif() endif() - else() # Qt5 + else() if (TARGET Qt5::qmake) get_target_property(_qmake_path Qt5::qmake LOCATION) else() @@ -199,7 +169,6 @@ if (NOT BUILD_HEADLESS) if (NOT _qmake_path OR NOT EXISTS "${_qmake_path}") message(FATAL_ERROR "Could not locate qmake. Checked: ${_qmake_path}") endif() - set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH "Path to Qt qmake for building Qwt" FORCE) message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") @@ -207,38 +176,32 @@ else() add_definitions(-DBUILD_HEADLESS) endif() -########################################### -# Configure Doxygen documentation -########################################### -OPTION(BUILD_DOCUMENTATION "Build documentation" OFF) -MARK_AS_ADVANCED(BUILD_DOCUMENTATION) - -########################################### -# Factory code generation options -########################################### -OPTION(GENERATE_MODULE_FACTORY_CODE "Generate module factory code from config files" ON) -MARK_AS_ADVANCED(GENERATE_MODULE_FACTORY_CODE) - -OPTION(REGENERATE_MODULE_FACTORY_CODE "Delete generated module factory code file in order to refresh module list" ON) -MARK_AS_ADVANCED(REGENERATE_MODULE_FACTORY_CODE) - -########################################### -# Configure externals -########################################### -SET(SCIRun_DEPENDENCIES) - -MACRO(ADD_EXTERNAL cmake_file external) - INCLUDE(${cmake_file}) - LIST(APPEND SCIRun_DEPENDENCIES ${external}) -ENDMACRO() - -SET(SUPERBUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE) -SET(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE) -SET(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) - -IF(BUILD_TESTING) +# ========================= +# Doxygen / codegen toggles +# ========================= +option(BUILD_DOCUMENTATION "Build documentation" OFF) +mark_as_advanced(BUILD_DOCUMENTATION) +option(GENERATE_MODULE_FACTORY_CODE "Generate module factory code from config files" ON) +mark_as_advanced(GENERATE_MODULE_FACTORY_CODE) +option(REGENERATE_MODULE_FACTORY_CODE "Delete generated module factory to refresh module list" ON) +mark_as_advanced(REGENERATE_MODULE_FACTORY_CODE) + +# ========================= +# Externals registration +# ========================= +set(SCIRUN_DEPENDENCIES) +macro(ADD_EXTERNAL cmake_file external) + include(${cmake_file}) + list(APPEND SCIRUN_DEPENDENCIES ${external}) +endmacro() + +set(SUPERBUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE) +set(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE) +set(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) + +if(BUILD_TESTING) ADD_EXTERNAL(${SUPERBUILD_DIR}/TestDataConfig.cmake SCIRunTestData_external) -ENDIF() +endif() ADD_EXTERNAL(${SUPERBUILD_DIR}/EigenExternal.cmake Eigen_external) ADD_EXTERNAL(${SUPERBUILD_DIR}/ZlibExternal.cmake Zlib_external) @@ -251,55 +214,50 @@ ADD_EXTERNAL(${SUPERBUILD_DIR}/TnyExternal.cmake Tny_external) ADD_EXTERNAL(${SUPERBUILD_DIR}/LodePngExternal.cmake LodePng_external) ADD_EXTERNAL(${SUPERBUILD_DIR}/Cleaver2External.cmake Cleaver2_external) -IF(WIN32) +if(WIN32) ADD_EXTERNAL(${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external) -ENDIF() +endif() -IF(BUILD_WITH_PYTHON) +if(BUILD_WITH_PYTHON) ADD_EXTERNAL(${SUPERBUILD_DIR}/PythonExternal.cmake Python_external) -ENDIF() +endif() -FIND_PACKAGE(Subversion) -IF(NOT Subversion_FOUND) - SET(BUILD_WITH_SCIRUN_DATA OFF) -ENDIF() -IF(BUILD_WITH_SCIRUN_DATA) +find_package(Subversion) +if(NOT Subversion_FOUND) + set(BUILD_WITH_SCIRUN_DATA OFF) +endif() +if(BUILD_WITH_SCIRUN_DATA) ADD_EXTERNAL(${SUPERBUILD_DIR}/SCIRunDataExternal.cmake SCI_data_external) -ENDIF() +endif() -IF(WITH_TETGEN) - MESSAGE(STATUS "Configuring Tetgen library under GPL. The SCIRun InterfaceWithTetGen module can be disabled by setting the CMake build variable WITH_TETGEN to OFF.") +if(WITH_TETGEN) + message(STATUS "Configuring Tetgen under GPL. Disable WITH_TETGEN to skip.") ADD_EXTERNAL(${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external) -ENDIF() +endif() -IF(WITH_OSPRAY) +if(WITH_OSPRAY) ADD_EXTERNAL(${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external) -ENDIF() - -IF(NOT BUILD_HEADLESS) - ADD_EXTERNAL(${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external) - # ADD_EXTERNAL(${SUPERBUILD_DIR}/CtkExternal.cmake Ctk_external) -ENDIF() +endif() +# Keep Boost last so we can compute Boost_DIR & legacy hints afterward ADD_EXTERNAL(${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external) -########################################### -# Helpers to export locations to SCIRun and collect prefixes -########################################### - -# Helper to export a CONFIG package directory to SCIRun cache args +# ========================= +# Exporters (config dir / include & lib dir) +# ========================= function(_export_config_dir pkg target subdir_pattern) + if(NOT TARGET ${target}) + message(STATUS "[superbuild] ${target} not defined yet; skipping ${pkg}_DIR export.") + return() + endif() ExternalProject_Get_Property(${target} INSTALL_DIR) if(NOT INSTALL_DIR) - message(FATAL_ERROR "INSTALL_DIR not set for ${target}. Ensure INSTALL is enabled in its ExternalProject_Add.") + message(FATAL_ERROR "INSTALL_DIR not set for ${target}. Ensure INSTALL is enabled.") endif() - # Collect prefix sb_prefix_append("${INSTALL_DIR}") string(TOUPPER "${pkg}" pkg_upper) - - # Candidates where Config.cmake might live set(_candidates "${INSTALL_DIR}/lib/cmake/${pkg}" "${INSTALL_DIR}/lib/cmake/${pkg}-*" @@ -310,7 +268,6 @@ function(_export_config_dir pkg target subdir_pattern) "${INSTALL_DIR}/cmake/${pkg}" "${INSTALL_DIR}/CMake/${pkg}" ) - unset(_found_dir) foreach(_cand IN LISTS _candidates) file(GLOB _hits "${_cand}") @@ -326,31 +283,28 @@ function(_export_config_dir pkg target subdir_pattern) endforeach() if(NOT DEFINED _found_dir) - message(STATUS "[superbuild] ${pkg}: no *Config.cmake found under ${INSTALL_DIR}. " - "This may be expected if the package does not export configs. " - "We will skip setting ${pkg}_DIR for now.") + message(STATUS "[superbuild] ${pkg}: no *Config.cmake under ${INSTALL_DIR} (expected if package doesn't export).") return() endif() - # Export _DIR as a cache entry so SCIRun receives it set(${pkg}_DIR "${_found_dir}" CACHE PATH "${pkg} config dir" FORCE) - list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") - set(SCIRun_CACHE_ARGS "${SCIRun_CACHE_ARGS}" PARENT_SCOPE) - + list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") + set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) message(STATUS "[superbuild] ${pkg}_DIR = ${${pkg}_DIR}") endfunction() -# Helper to export include/lib hints (for header-only or non-config packages) -function(_export_include_lib pkg target) +function(_sb_export_inc_lib pkg target) + if(NOT TARGET ${target}) + message(STATUS "[superbuild] ${target} not defined yet; skipping ${pkg} include/lib export.") + return() + endif() ExternalProject_Get_Property(${target} INSTALL_DIR) if(NOT INSTALL_DIR) message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") endif() - # Collect prefix sb_prefix_append("${INSTALL_DIR}") - # Heuristics: include/ and lib{,64}/ under install prefix set(_inc "${INSTALL_DIR}/include") if(EXISTS "${INSTALL_DIR}/lib64") set(_lib "${INSTALL_DIR}/lib64") @@ -358,123 +312,113 @@ function(_export_include_lib pkg target) set(_lib "${INSTALL_DIR}/lib") endif() - if(EXISTS "${_inc}") - set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) - list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") - endif() + # Export include dir (unconditionally; path will exist by build time) + set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") + + # Export lib dir if present if(EXISTS "${_lib}") set(${pkg}_LIB_DIR "${_lib}" CACHE PATH "${pkg} lib dir" FORCE) - list(APPEND SCIRun_CACHE_ARGS "-D${pkg}_LIB_DIR:PATH=${${pkg}_LIB_DIR}") + list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_LIB_DIR:PATH=${${pkg}_LIB_DIR}") endif() - set(SCIRun_CACHE_ARGS "${SCIRun_CACHE_ARGS}" PARENT_SCOPE) + set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) message(STATUS "[superbuild] ${pkg}: include=${_inc} lib=${_lib}") endfunction() -########################################### -# Boost properties and hints (robust DIR) -########################################### -ExternalProject_Get_Property(Boost_external INSTALL_DIR) -set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix (produced by Boost_external)" FORCE) -set(SCI_BOOST_INCLUDE "${INSTALL_DIR}/include") -if (WIN32 AND EXISTS "${INSTALL_DIR}/lib64") - set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib64") -else() - set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib") -endif() - -# Try to pick the exact config dir (versioned) if present; fall back to unversioned -set(Boost_DIR "") -file(GLOB _boost_cfg_dirs "${INSTALL_DIR}/lib/cmake/Boost*") -foreach(_bd IN LISTS _boost_cfg_dirs) - if(EXISTS "${_bd}/BoostConfig.cmake") - set(Boost_DIR "${_bd}") - break() +# ========================= +# Boost props/hints for downstream +# ========================= +if(TARGET Boost_external) + ExternalProject_Get_Property(Boost_external INSTALL_DIR) + set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix" FORCE) + set(SCI_BOOST_INCLUDE "${INSTALL_DIR}/include" CACHE PATH "Boost include directory" FORCE) + if (WIN32 AND EXISTS "${INSTALL_DIR}/lib64") + set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib64") + else() + set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib") endif() -endforeach() -if(NOT Boost_DIR) - set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") + set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library directory" FORCE) + + # Try versioned Boost-* dir first + set(Boost_DIR "") + file(GLOB _boost_cfg_dirs "${INSTALL_DIR}/lib/cmake/Boost*") + foreach(_bd IN LISTS _boost_cfg_dirs) + if(EXISTS "${_bd}/BoostConfig.cmake") + set(Boost_DIR "${_bd}") + break() + endif() + endforeach() + if(NOT Boost_DIR) + set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") + endif() + sb_prefix_append("${INSTALL_DIR}") endif() -# Collect Boost prefix too -sb_prefix_append("${INSTALL_DIR}") - -########################################### -# Export locations for externals -########################################### -# CONFIG-package externals (expect *Config.cmake) +# ========================= +# Export externals (config or include/lib) +# ========================= _export_config_dir(Zlib Zlib_external "") _export_config_dir(Freetype Freetype_external "") _export_config_dir(SQLite SQLite_external "") -# Qwt: create imported target (does not rely on a config package) -_export_config_dir(Qwt Qwt_external "") # harmless if no config is present - -ExternalProject_Get_Property(Qwt_external INSTALL_DIR) -set(QWT_INSTALL_DIR "${INSTALL_DIR}") -set(QWT_INCLUDE_DIR "${QWT_INSTALL_DIR}/include") -set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") +# Qwt block guarded by GUI flag and target existence +if(NOT BUILD_HEADLESS AND TARGET Qwt_external) + _export_config_dir(Qwt Qwt_external "") -add_library(Qwt::Qwt UNKNOWN IMPORTED GLOBAL) -add_dependencies(Qwt::Qwt Qwt_external) + ExternalProject_Get_Property(Qwt_external INSTALL_DIR) + set(QWT_INSTALL_DIR "${INSTALL_DIR}") + set(QWT_INCLUDE_DIR "${QWT_INSTALL_DIR}/include") + if(EXISTS "${QWT_INSTALL_DIR}/lib64") + set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib64") + else() + set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") + endif() -set_property(TARGET Qwt::Qwt PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${QWT_INCLUDE_DIR}" -) + add_library(Qwt::Qwt UNKNOWN IMPORTED GLOBAL) + add_dependencies(Qwt::Qwt Qwt_external) + set_property(TARGET Qwt::Qwt PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${QWT_INCLUDE_DIR}") -if(WIN32) - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_CONFIGURATIONS "Debug;Release") - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") -elseif(APPLE) - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") + if(WIN32) + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_CONFIGURATIONS "Debug;Release") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") + elseif(APPLE) + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") + else() + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.so") + endif() else() - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.so") + message(STATUS "[superbuild] Qwt not present (BUILD_HEADLESS ON or target missing); skipping Qwt exports.") endif() -# GLEW: try config; if none, include/lib hints will still help -if(WIN32) +# Prefer config dirs when possible (Windows GLEW sometimes exports one) +if(WIN32 AND TARGET Glew_external) _export_config_dir(GLEW Glew_external "") endif() -# Python: prefer config if available; otherwise include/lib -if(BUILD_WITH_PYTHON) +if(BUILD_WITH_PYTHON AND TARGET Python_external) _export_config_dir(Python Python_external "") endif() -# Header-only or non-config: export include/lib hints -_export_include_lib(Eigen Eigen_external) -_export_include_lib(GLM GLM_external) -_export_include_lib(SpdLog SpdLog_external) - -# Likely non-config or custom installs—export include/lib for now -_export_include_lib(Teem Teem_external) -_export_include_lib(Tny Tny_external) -_export_include_lib(LodePng LodePng_external) -_export_include_lib(Cleaver2 Cleaver2_external) - -# Optional sets (only if enabled) -if(WITH_TETGEN) - _export_include_lib(Tetgen Tetgen_external) +# Include/lib hints (guarded by target existence) +_sb_export_inc_lib(Eigen Eigen_external) +_sb_export_inc_lib(GLM GLM_external) +_sb_export_inc_lib(SpdLog SpdLog_external) +_sb_export_inc_lib(Teem Teem_external) +_sb_export_inc_lib(Tny Tny_external) +_sb_export_inc_lib(LodePng LodePng_external) +_sb_export_inc_lib(Cleaver2 Cleaver2_external) +if(WITH_TETGEN AND TARGET Tetgen_external) + _sb_export_inc_lib(Tetgen Tetgen_external) endif() -if(WITH_OSPRAY) - _export_config_dir(ospray Ospray_external "") -endif() - -########################################### -# Download external data sources -########################################### -OPTION(DOWNLOAD_TOOLKITS "Download toolkit repositories." ON) -MARK_AS_ADVANCED(DOWNLOAD_TOOLKITS) -IF(DOWNLOAD_TOOLKITS) - INCLUDE(${SUPERBUILD_DIR}/ToolkitsConfig.cmake) - EXTERNAL_TOOLKIT(BrainStimulator) - EXTERNAL_TOOLKIT(FwdInvToolkit) -ENDIF() - -########################################### -# Build SCIRun cache args (internal settings) -########################################### +if(WIN32 AND TARGET Glew_external) + _sb_export_inc_lib(GLEW Glew_external) +endif() + +# ========================= +# Build SCIRun cache args +# ========================= set(SCIRUN_CACHE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" @@ -497,155 +441,76 @@ set(SCIRUN_CACHE_ARGS "-DQt_PATH:PATH=${Qt_PATH}" ) -if(BUILD_WITH_PYTHON) - if(SCI_PYTHON_EXE) - list(APPEND SCIRUN_CACHE_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}") - endif() +if(BUILD_WITH_PYTHON AND SCI_PYTHON_EXE) + list(APPEND SCIRUN_CACHE_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}") endif() if(WIN32) list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}") endif() -# (Avoid passing empty Qt component DIR hints; CMAKE_PREFIX_PATH+Qt_PATH are enough) -if(NOT BUILD_HEADLESS) - if(DEFINED MACDEPLOYQT_OUTPUT_LEVEL) - list(APPEND SCIRUN_CACHE_ARGS "-DMACDEPLOYQT_OUTPUT_LEVEL:STRING=${MACDEPLOYQT_OUTPUT_LEVEL}") - endif() -endif() - -# ----------------- Helpers to export include/lib/config dirs ----------------- -function(_sb_export_inc_lib pkg target) - # Export include/lib dirs for an ExternalProject target, even if not yet built. - ExternalProject_Get_Property(${target} INSTALL_DIR) - if(NOT INSTALL_DIR) - message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") - endif() - - # Standard install subdirs - set(_inc "${INSTALL_DIR}/include") - if(EXISTS "${INSTALL_DIR}/lib64") - set(_lib "${INSTALL_DIR}/lib64") +# Zlib + Boost essential hints (include & lib paths explicitly) +if(TARGET Zlib_external) + ExternalProject_Get_Property(Zlib_external INSTALL_DIR) + set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") + list(APPEND SCIRUN_CACHE_ARGS + "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" + "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" + "-DZLIB_USE_STATIC_LIBS:BOOL=ON" + ) + if(DEFINED Zlib_DIR) + list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_DIR:PATH=${Zlib_DIR}") else() - set(_lib "${INSTALL_DIR}/lib") - endif() - - # Unconditionally export include/lib cache args so SCIRun gets them at configure time - set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") - - # Only add lib dir if it exists (some are header-only) - if(EXISTS "${_lib}") - set(${pkg}_LIB_DIR "${_lib}" CACHE PATH "${pkg} lib dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_LIB_DIR:PATH=${${pkg}_LIB_DIR}") + _export_config_dir(Zlib Zlib_external "lib/cmake/zlib") endif() - - set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) - message(STATUS "[superbuild] ${pkg}: include=${_inc} lib=${_lib}") -endfunction() - -function(_sb_export_config pkg target config_subdir) - # Export a *Config.cmake directory for config-package find_package - ExternalProject_Get_Property(${target} INSTALL_DIR) - if(NOT INSTALL_DIR) - message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") - endif() - set(_cfg "${INSTALL_DIR}/${config_subdir}") - # Cache even if it might not exist yet; it will by the time SCIRun compiles - set(${pkg}_DIR "${_cfg}" CACHE PATH "${pkg}Config.cmake dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") - set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) - message(STATUS "[superbuild] ${pkg}_DIR=${_cfg}") -endfunction() - -# ----------------- Zlib + Boost ----------------- -ExternalProject_Get_Property(Zlib_external INSTALL_DIR) -set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") - -list(APPEND SCIRUN_CACHE_ARGS - "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" - "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" - "-DZLIB_USE_STATIC_LIBS:BOOL=ON" - "-DBoost_DIR:PATH=${Boost_DIR}" # folder with BoostConfig.cmake - "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" - "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" - "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" - "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" -) - -# If Zlib config dir is known, pass it as well (improves config-package finding) -if(DEFINED Zlib_DIR) - list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_DIR:PATH=${Zlib_DIR}") -else() - # Try to export it based on typical layout - _sb_export_config(Zlib Zlib_external "lib/cmake/zlib") endif() -# ----------------- Export include/lib/config dirs for other externals ----------------- -# GLM (header-only) -_sb_export_inc_lib(GLM GLM_external) # sets GLM_INCLUDE_DIR - -# Eigen (header-only; some builds also export a config) -_sb_export_inc_lib(Eigen Eigen_external) -# If your Eigen install has a config dir, uncomment the next line: -# _sb_export_config(Eigen3 Eigen_external "share/eigen3/cmake") - -# spdlog -_sb_export_inc_lib(SpdLog SpdLog_external) -_sb_export_config(spdlog SpdLog_external "lib/cmake/spdlog") - -# GLEW -_sb_export_inc_lib(GLEW Glew_external) -# Some generators put a config under lib/cmake; if your Glew has config: -# _sb_export_config(GLEW Glew_external "lib/cmake/glew") - -# Freetype -_sb_export_inc_lib(Freetype Freetype_external) -_sb_export_config(Freetype Freetype_external "lib/cmake/freetype") - -# SQLite (optional; used by some builds) -_sb_export_inc_lib(SQLite SQLite_external) - -# Qwt -_sb_export_inc_lib(Qwt Qwt_external) -# If Qwt exports a config, add: -# _sb_export_config(Qwt Qwt_external "lib/cmake/qwt") - -# Python (using the one you already pass via PYTHON_EXECUTABLE) -_sb_export_inc_lib(Python Python_external) -# If there is a config dir, add it similarly. - -# Teem -_sb_export_inc_lib(Teem Teem_external) -_sb_export_config(Teem Teem_external "lib/cmake/Teem") - -# Tny (header-only/small lib) -_sb_export_inc_lib(TNY Tny_external) - -# LodePNG (header-only/small lib) -_sb_export_inc_lib(LODEPNG LodePng_external) +if(TARGET Boost_external) + list(APPEND SCIRUN_CACHE_ARGS + "-DBoost_DIR:PATH=${Boost_DIR}" + "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" + "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" + "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" + "-DBoost_INCLUDE_DIR:PATH=${SCI_BOOST_PREFIX}/include" + "-DBoost_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" + "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" + ) +endif() -# Cleaver2 -_sb_export_inc_lib(CLEAVER2 Cleaver2_external) -# If Cleaver2 exports a config: -# _sb_export_config(Cleaver2 Cleaver2_external "lib/cmake/Cleaver2") +# Legacy alias variables (so existing SCIRun CMake picks them up) +# Normalize LodePng var name if needed +if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) + set(LODEPNG_INCLUDE_DIR "${LodePng_INCLUDE_DIR}") +endif() -# Tetgen -_sb_export_inc_lib(TETGEN Tetgen_external) +if(DEFINED GLEW_INCLUDE_DIR) + set(SCI_GLEW_INCLUDE "${GLEW_INCLUDE_DIR}" CACHE PATH "Legacy: GLEW include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-DSCI_GLEW_INCLUDE:PATH=${SCI_GLEW_INCLUDE}") +endif() +if(DEFINED LODEPNG_INCLUDE_DIR) + set(SCI_LODEPNG_INCLUDE "${LODEPNG_INCLUDE_DIR}" CACHE PATH "Legacy: LodePNG include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-DSCI_LODEPNG_INCLUDE:PATH=${SCI_LODEPNG_INCLUDE}") +endif() +if(DEFINED TNY_INCLUDE_DIR) + set(SCI_TNY_INCLUDE "${TNY_INCLUDE_DIR}" CACHE PATH "Legacy: TNY include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-DSCI_TNY_INCLUDE:PATH=${SCI_TNY_INCLUDE}") +endif() +if(DEFINED SQLite_INCLUDE_DIR) + set(SQLite3_INCLUDE_DIR "${SQLite_INCLUDE_DIR}" CACHE PATH "Alias: SQLite3 include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_INCLUDE_DIR:PATH=${SQLite3_INCLUDE_DIR}") +endif() -# ----------------- Re-compose the single CMAKE_PREFIX_PATH ----------------- +# Compose a single CMAKE_PREFIX_PATH for SCIRun get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) set(_joined_prefixes "") if(_acc) list(REMOVE_DUPLICATES _acc) string(JOIN ";" _joined_prefixes ${_acc}) endif() - -# escape semicolons so the list stays as a single CMake cache entry set(_joined_prefixes_escaped "${_joined_prefixes}") string(REPLACE ";" "\\;" _joined_prefixes_escaped "${_joined_prefixes}") -# Remove any earlier -DCMAKE_PREFIX_PATH entries (defensive) +# Ensure only one -DCMAKE_PREFIX_PATH is passed set(_filtered "") foreach(arg IN LISTS SCIRUN_CACHE_ARGS) if(NOT arg MATCHES "^-DCMAKE_PREFIX_PATH:PATH=") @@ -653,20 +518,47 @@ foreach(arg IN LISTS SCIRUN_CACHE_ARGS) endif() endforeach() set(SCIRUN_CACHE_ARGS "${_filtered}") - -# Append exactly one CMAKE_PREFIX_PATH argument list(APPEND SCIRUN_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${_joined_prefixes_escaped}") -# ----------------- Log the final arguments passed to SCIRun ----------------- +# Log what we will pass to SCIRun message(STATUS "[superbuild] Final CMAKE_PREFIX_PATH for SCIRun: ${_joined_prefixes}") message(STATUS "Superbuild passing to SCIRun:") foreach(arg IN LISTS SCIRUN_CACHE_ARGS) message(STATUS " ${arg}") endforeach() -# ----------------- SCIRun ExternalProject remains the same ----------------- +# ========================= +# Helper: gate SCIRun configure on external artifacts +# ========================= +function(_sb_scirun_wait_for) + # Usage: + # _sb_scirun_wait_for(NAME FILES ... DIRS ...) + cmake_parse_arguments(WAIT "" "NAME" "FILES;DIRS" ${ARGN}) + if(NOT WAIT_NAME) + message(FATAL_ERROR "_sb_scirun_wait_for requires NAME") + endif() + set(_deps) + foreach(_f IN LISTS WAIT_FILES) + list(APPEND _deps "${_f}") + endforeach() + foreach(_d IN LISTS WAIT_DIRS) + list(APPEND _deps "${_d}") + endforeach() + if(_deps) + ExternalProject_Add_Step(SCIRun_external "wait_for_${WAIT_NAME}" + COMMAND ${CMAKE_COMMAND} -E echo "Waiting for ${WAIT_NAME} before SCIRun configure..." + DEPENDEES download + DEPENDERS configure + DEPENDS ${_deps} + ) + endif() +endfunction() + +# ========================= +# SCIRun ExternalProject +# ========================= ExternalProject_Add(SCIRun_external - DEPENDS ${SCIRun_DEPENDENCIES} + DEPENDS ${SCIRUN_DEPENDENCIES} DOWNLOAD_COMMAND "" SOURCE_DIR ${SCIRUN_SOURCE_DIR} BINARY_DIR ${SCIRUN_BINARY_DIR} @@ -674,12 +566,116 @@ ExternalProject_Add(SCIRun_external INSTALL_COMMAND "" ) -# Optional: keep order tidy for artifacts needed during SCIRun configure -ExternalProject_Add_Step(SCIRun_external wait_for_zlib - COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts before SCIRun configure..." - DEPENDEES download - DEPENDERS configure - DEPENDS - "${ZLIB_INSTALL_DIR}/include/zlib.h" - "${ZLIB_INSTALL_DIR}/lib" -) +# ========================= +# BOOST: header staging (no delete; copy only) + waits +# ========================= +# Prepare cross-platform commands for b2 bootstrapping and header generation +if(WIN32) + set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) + set(_B2_HEADERS_CMD cmd /c .\\b2 headers) +else() + set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) + set(_B2_HEADERS_CMD ./b2 headers) +endif() + +if(TARGET Boost_external) + # 1) Bootstrap b2 + ExternalProject_Add_Step(Boost_external bootstrap_b2 + COMMAND ${_B2_BOOTSTRAP_CMD} + WORKING_DIRECTORY + DEPENDEES update + DEPENDERS configure + COMMENT "Bootstrapping Boost.Build (b2)" + ) + + # 2) Generate the 'boost/' header tree + ExternalProject_Add_Step(Boost_external stage_headers + COMMAND ${_B2_HEADERS_CMD} + WORKING_DIRECTORY + DEPENDEES bootstrap_b2 + COMMENT "Running 'b2 headers' to generate the boost/ header tree" + ) + + # 3) Copy full headers into install/include WITHOUT deleting first + ExternalProject_Add_Step(Boost_external install_full_headers + COMMAND ${CMAKE_COMMAND} -E make_directory /include/boost + COMMAND ${CMAKE_COMMAND} -E copy_directory /boost /include/boost + DEPENDEES stage_headers + DEPENDERS build + BYPRODUCTS "/include/boost/array.hpp" + COMMENT "Staging full Boost headers into /include/boost (no delete)" + ) + + # Expose step targets for ordering elsewhere if needed + ExternalProject_Add_StepTargets(Boost_external stage_headers install_full_headers) + + # Gate SCIRun configure on staged headers + ExternalProject_Get_Property(Boost_external INSTALL_DIR) + _sb_scirun_wait_for(NAME boost + FILES + "${INSTALL_DIR}/include/boost/array.hpp" + "${INSTALL_DIR}/include/boost/exception/all.hpp" + DIRS "${INSTALL_DIR}/include/boost" + ) + add_dependencies(SCIRun_external Boost_external-install_full_headers) +endif() + +# ========================= +# Gate SCIRun configure on other externals' headers +# ========================= +if(TARGET Glew_external) + ExternalProject_Get_Property(Glew_external INSTALL_DIR) + _sb_scirun_wait_for(NAME glew + FILES "${INSTALL_DIR}/include/GL/glew.h" + DIRS "${INSTALL_DIR}/include" + ) +endif() + +if(TARGET GLM_external) + ExternalProject_Get_Property(GLM_external INSTALL_DIR) + _sb_scirun_wait_for(NAME glm + FILES "${INSTALL_DIR}/include/glm/glm.hpp" + DIRS "${INSTALL_DIR}/include" + ) +endif() + +if(TARGET LodePng_external) + ExternalProject_Get_Property(LodePng_external INSTALL_DIR) + _sb_scirun_wait_for(NAME lodepng + FILES + "${INSTALL_DIR}/include/lodepng/lodepng.h" + "${INSTALL_DIR}/include/lodepng.h" + DIRS "${INSTALL_DIR}/include" + ) +endif() + +if(TARGET SQLite_external) + ExternalProject_Get_Property(SQLite_external INSTALL_DIR) + _sb_scirun_wait_for(NAME sqlite + FILES "${INSTALL_DIR}/include/sqlite3.h" + DIRS "${INSTALL_DIR}/include" + ) +endif() + +if(TARGET Tny_external) + ExternalProject_Get_Property(Tny_external INSTALL_DIR) + _sb_scirun_wait_for(NAME tny + FILES "${INSTALL_DIR}/include/tny/tny.hpp" + DIRS "${INSTALL_DIR}/include" + ) +endif() + +if(TARGET Teem_external) + ExternalProject_Get_Property(Teem_external INSTALL_DIR) + _sb_scirun_wait_for(NAME teem + DIRS "${INSTALL_DIR}/include" + ) +endif() + +if(NOT BUILD_HEADLESS AND TARGET Qwt_external) + ExternalProject_Get_Property(Qwt_external INSTALL_DIR) + _sb_scirun_wait_for(NAME qwt + FILES "${INSTALL_DIR}/include/qwt.h" + DIRS "${INSTALL_DIR}/include" + ) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ca5a3621f..1e549cfa73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -871,15 +871,55 @@ ENDIF() SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) -# Helper to pretty-print a list variable line by line -function(print_list name) - message(STATUS "${name}:") - foreach(item IN LISTS ${name}) - message(STATUS " - ${item}") - endforeach() +# ---------- Diagnostics + optional auto-derive from CMAKE_PREFIX_PATH ---------- +# Helper to derive an include dir from CMAKE_PREFIX_PATH if the var is not set +function(_derive_include_dir _outvar _header_glob) + if(NOT ${_outvar}) + set(_candidates) + foreach(_p IN LISTS CMAKE_PREFIX_PATH) + list(APPEND _candidates "${_p}/include") + endforeach() + find_path(_found_dir + NAMES ${_header_glob} + PATHS ${_candidates} + NO_DEFAULT_PATH + ) + if(_found_dir) + set(${_outvar} "${_found_dir}" PARENT_SCOPE) + endif() + endif() endfunction() -# Collect the include dirs in one list first (mirrors your INCLUDE_DIRECTORIES block) +# Try to fill any missing include dir variables using the expected headers: +_derive_include_dir(GLEW_INCLUDE_DIR "GL/glew.h") +_derive_include_dir(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") +_derive_include_dir(SQLite3_INCLUDE_DIR "sqlite3.h") +_derive_include_dir(TNY_INCLUDE_DIR "tny/tny.hpp") +# Boost_INCLUDE_DIR is already passed; if needed: +# _derive_include_dir(Boost_INCLUDE_DIR "boost/array.hpp") + +# Print diagnostics so you can see them in the configure log +message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") +message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") +message(STATUS "LODEPNG_INCLUDE_DIR='${LODEPNG_INCLUDE_DIR}'") +message(STATUS "SQLite3_INCLUDE_DIR='${SQLite3_INCLUDE_DIR}'") +message(STATUS "TNY_INCLUDE_DIR='${TNY_INCLUDE_DIR}'") + +# Quick existence checks (helpful during iteration) +if(GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") + message(STATUS "GLEW header OK: ${GLEW_INCLUDE_DIR}/GL/glew.h") +endif() +if(LODEPNG_INCLUDE_DIR AND EXISTS "${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") + message(STATUS "LodePNG header OK: ${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") +endif() +if(SQLite3_INCLUDE_DIR AND EXISTS "${SQLite3_INCLUDE_DIR}/sqlite3.h") + message(STATUS "SQLite3 header OK: ${SQLite3_INCLUDE_DIR}/sqlite3.h") +endif() +if(TNY_INCLUDE_DIR AND EXISTS "${TNY_INCLUDE_DIR}/tny/tny.hpp") + message(STATUS "TNY header OK: ${TNY_INCLUDE_DIR}/tny/tny.hpp") +endif() + +# ---------- Build include list with guards to avoid '/include' ---------- set(_SCIRUN_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${SCIRun_SOURCE_DIR}/ @@ -895,18 +935,44 @@ set(_SCIRUN_INCLUDE_DIRS ${SCI_TEEM_INCLUDE} ${SCI_ZLIB_INCLUDE} ${GLM_INCLUDE_DIR} - ${SPDLOG_DIR}/include - ${Eigen_DIR} - ${SCI_TNY_INCLUDE} - ${SCI_LODEPNG_INCLUDE} ${SCI_QWT_INCLUDE} ${SCI_CLEAVER2_INCLUDE} ) -# Print them before applying +# Append externals only if the variables are set (prevents stray '/include') +if(Boost_INCLUDE_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${Boost_INCLUDE_DIR}") +endif() +if(GLEW_INCLUDE_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${GLEW_INCLUDE_DIR}") +endif() +if(LODEPNG_INCLUDE_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${LODEPNG_INCLUDE_DIR}") +endif() +if(SQLite3_INCLUDE_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${SQLite3_INCLUDE_DIR}") +endif() +if(TNY_INCLUDE_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${TNY_INCLUDE_DIR}") +endif() + +# Optional: SPDLOG and Eigen if present; guard to avoid '/include' +if(SPDLOG_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${SPDLOG_DIR}/include") +endif() +if(Eigen_DIR) + list(APPEND _SCIRUN_INCLUDE_DIRS "${Eigen_DIR}") +endif() + +# Debug print and apply +function(print_list name) + message(STATUS "${name}:") + foreach(item IN LISTS ${name}) + message(STATUS " - ${item}") + endforeach() +endfunction() print_list("_SCIRUN_INCLUDE_DIRS") -# Then actually apply them include_directories(${_SCIRUN_INCLUDE_DIRS}) #INCLUDE_DIRECTORIES( From 1168d719f6c4c1457576f31240ad407b59fc4d78 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Feb 2026 17:07:05 -0700 Subject: [PATCH 025/140] cmake --- Superbuild/Superbuild.cmake | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index e0a4e48755..ffe4c43d20 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -597,17 +597,20 @@ if(TARGET Boost_external) ) # 3) Copy full headers into install/include WITHOUT deleting first - ExternalProject_Add_Step(Boost_external install_full_headers - COMMAND ${CMAKE_COMMAND} -E make_directory /include/boost - COMMAND ${CMAKE_COMMAND} -E copy_directory /boost /include/boost - DEPENDEES stage_headers - DEPENDERS build - BYPRODUCTS "/include/boost/array.hpp" - COMMENT "Staging full Boost headers into /include/boost (no delete)" - ) + if(NOT DEFINED _SB_BOOST_HEADERS_COPY_STEP_DEFINED) + ExternalProject_Add_Step(Boost_external stage_boost_headers_copy + COMMAND ${CMAKE_COMMAND} -E make_directory /include/boost + COMMAND ${CMAKE_COMMAND} -E copy_directory /boost /include/boost + DEPENDEES stage_headers + DEPENDERS build + BYPRODUCTS "/include/boost/array.hpp" + COMMENT "Staging full Boost headers into /include/boost (no delete)" + ) + set(_SB_BOOST_HEADERS_COPY_STEP_DEFINED TRUE) + endif() - # Expose step targets for ordering elsewhere if needed - ExternalProject_Add_StepTargets(Boost_external stage_headers install_full_headers) + # Expose step targets for ordering elsewhere + ExternalProject_Add_StepTargets(Boost_external stage_headers stage_boost_headers_copy) # Gate SCIRun configure on staged headers ExternalProject_Get_Property(Boost_external INSTALL_DIR) @@ -617,7 +620,7 @@ if(TARGET Boost_external) "${INSTALL_DIR}/include/boost/exception/all.hpp" DIRS "${INSTALL_DIR}/include/boost" ) - add_dependencies(SCIRun_external Boost_external-install_full_headers) + add_dependencies(SCIRun_external Boost_external-stage_boost_headers_copy) endif() # ========================= From a013417b16cbb452afc0f6e471565e37709c91c9 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Feb 2026 10:59:56 -0700 Subject: [PATCH 026/140] headers --- Superbuild/GlewExternal.cmake | 34 ++++++++++++++++++++++++------- Superbuild/SQLiteExternal.cmake | 24 +++++++++++++++------- Superbuild/Superbuild.cmake | 1 + Superbuild/TnyExternal.cmake | 36 ++++++++++++++++++--------------- 4 files changed, 65 insertions(+), 30 deletions(-) diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index f403660766..3e89249d8b 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -24,9 +24,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - -# GlewExternal.cmake (modernized + consistent) - +# GlewExternal.cmake (modernized + consistent + header copy into Install) set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(glew_GIT_TAG "v1.0.1") @@ -36,7 +34,7 @@ set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - # Redirect all outputs so install step is unnecessary + # Redirect all outputs so install step is unnecessary for libs -DCMAKE_INSTALL_PREFIX= -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib @@ -75,19 +73,41 @@ ExternalProject_Add(Glew_external CMAKE_ARGS ${_cmake_args} - # Outputs already redirected -> skip install + # We skip 'install' to keep the fast redirect flow for libs INSTALL_COMMAND "" + # After build, ensure headers are available in /include + # (glew's headers live in /include) + BUILD_BYPRODUCTS + "/lib" # helps order-only deps + + # Add a step to copy headers into Install prefix + # (idempotent; safe for multi-config) + STEP_TARGETS copy_headers + COMMAND ${CMAKE_COMMAND} -E make_directory "/include" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${_glew_src}/include" "/include" + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) +# Tie the header copy to the build +add_custom_command(TARGET Glew_external + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${_glew_inst}/include" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${_glew_src}/include" "${_glew_inst}/include" + COMMENT "Copying GLEW headers to ${_glew_inst}/include" +) + # Export variables for SCIRun set(GLEW_SOURCE_DIR ${_glew_src}) set(GLEW_INSTALL_DIR ${_glew_inst}) -set(GLEW_INCLUDE ${GLEW_SOURCE_DIR}/include) +set(GLEW_INCLUDE ${GLEW_INSTALL_DIR}/include) set(GLEW_LIBRARY_DIR ${GLEW_INSTALL_DIR}/lib) + +# Library name on Windows built with CMake is typically 'glew' or 'glew32'. +# If you’ve standardized your export to 'glew', keep it: set(GLEW_LIBRARY "glew") -message(STATUS "[Glew_external] INSTALL_DIR=${GLEW_INSTALL_DIR}") +message(STATUS "[Glew_external] INSTALL_DIR=${GLEW_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index f323e73adf..c1bb3816c4 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -24,9 +24,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - -# SQLiteExternal.cmake (modernized + consistent) - +# SQLiteExternal.cmake (redirect libs + copy headers into Install/include) set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(sqlite_GIT_TAG "v3.0.1") @@ -36,7 +34,7 @@ set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - # Redirect all outputs so install step is unnecessary + # Redirect all outputs so install step is unnecessary for libs -DCMAKE_INSTALL_PREFIX= -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib @@ -75,9 +73,16 @@ ExternalProject_Add(SQLite_external CMAKE_ARGS ${_cmake_args} - # Outputs already redirected -> skip install + # Skip 'install' to keep the fast redirect flow for libs INSTALL_COMMAND "" + # After build, ensure headers are available in /include + # (sqlite3.h is typically at the source root; sqlite3ext.h may also be present) + STEP_TARGETS copy_headers + COMMAND ${CMAKE_COMMAND} -E make_directory "/include" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_sqlite_src}/sqlite3.h" "/include/sqlite3.h" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_sqlite_src}/sqlite3ext.h" "/include/sqlite3ext.h" + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 @@ -86,8 +91,13 @@ ExternalProject_Add(SQLite_external # Export variables for SCIRun set(SQLITE_SOURCE_DIR ${_sqlite_src}) set(SQLITE_INSTALL_DIR ${_sqlite_inst}) -set(SQLITE_INCLUDE ${SQLITE_SOURCE_DIR}) # sqlite3.h lives in source root +set(SQLITE_INCLUDE ${SQLITE_INSTALL_DIR}/include) set(SQLITE_LIBRARY_DIR ${SQLITE_INSTALL_DIR}/lib) + +# Library name note: +# Many SQLite CMake builds produce 'sqlite3' as the lib name. +# Your repo tag v3.0.1 may export 'sqlite' or 'sqlite3' depending on CMakeLists. +# If build fails to link, try switching this to 'sqlite3'. set(SQLITE_LIBRARY "sqlite") -message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") +message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index ffe4c43d20..70cf9779ae 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -409,6 +409,7 @@ _sb_export_inc_lib(Teem Teem_external) _sb_export_inc_lib(Tny Tny_external) _sb_export_inc_lib(LodePng LodePng_external) _sb_export_inc_lib(Cleaver2 Cleaver2_external) +_sb_export_inc_lib(SQLite SQLite_external) if(WITH_TETGEN AND TARGET Tetgen_external) _sb_export_inc_lib(Tetgen Tetgen_external) endif() diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index 22eaa31f03..053e4d7e6d 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -24,29 +24,33 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - # TnyExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") +# Superbuild directories (match your pattern—optional but helps clarity) +set(_tny_inst "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external") ExternalProject_Add(Tny_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Tny.git" - GIT_TAG "origin/master" - PATCH_COMMAND "" + GIT_TAG "origin/master" + PATCH_COMMAND "" CONFIGURE_COMMAND "" - BUILD_COMMAND "" + BUILD_COMMAND "" + + # Copy only the headers into a conventional layout: + # /include/tny/tny.hpp INSTALL_COMMAND - ${CMAKE_COMMAND} -E copy_directory - "" - "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/include/Tny" - CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + ${CMAKE_COMMAND} -E make_directory "${_tny_inst}/include/tny" && + ${CMAKE_COMMAND} -E copy_directory "/tny/src/tny" "${_tny_inst}/include/tny" + LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + LOG_BUILD 1 + LOG_INSTALL 1 ) -ExternalProject_Get_Property(Tny_external INSTALL_DIR) -message(STATUS "[Tny_external] INSTALL_DIR=${INSTALL_DIR}") +# Export variables for SCIRun consumption +ExternalProject_Get_Property(Tny_external SOURCE_DIR) +set(TNY_SOURCE_DIR "${SOURCE_DIR}") +set(TNY_INSTALL_DIR "${_tny_inst}") +set(TNY_INCLUDE "${TNY_INSTALL_DIR}/include") +message(STATUS "[Tny_external] INSTALL_DIR=${TNY_INSTALL_DIR}") \ No newline at end of file From ab20c05d2f5ef44b2b0a9e3a1d93e6c613de116d Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Feb 2026 11:50:28 -0700 Subject: [PATCH 027/140] header copy --- Superbuild/SQLiteExternal.cmake | 15 ++++++--------- Superbuild/SQLiteInstall.cmake | 17 +++++++++++++++++ Superbuild/Superbuild.cmake | 11 +++++++++++ Superbuild/TnyExternal.cmake | 9 +++++---- Superbuild/TnyInstall.cmake | 12 ++++++++++++ 5 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 Superbuild/SQLiteInstall.cmake create mode 100644 Superbuild/TnyInstall.cmake diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index c1bb3816c4..8f635204e7 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -73,15 +73,12 @@ ExternalProject_Add(SQLite_external CMAKE_ARGS ${_cmake_args} - # Skip 'install' to keep the fast redirect flow for libs - INSTALL_COMMAND "" - - # After build, ensure headers are available in /include - # (sqlite3.h is typically at the source root; sqlite3ext.h may also be present) - STEP_TARGETS copy_headers - COMMAND ${CMAKE_COMMAND} -E make_directory "/include" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_sqlite_src}/sqlite3.h" "/include/sqlite3.h" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_sqlite_src}/sqlite3ext.h" "/include/sqlite3ext.h" + # Let our script act as the "install" step + INSTALL_COMMAND + ${CMAKE_COMMAND} + -Dsrc= # this is Externals/Source/SQLite_external + -Ddst=${_sqlite_inst}/include + -P ${CMAKE_CURRENT_LIST_DIR}/SQLiteInstall.cmake LOG_CONFIGURE 1 LOG_BUILD 1 diff --git a/Superbuild/SQLiteInstall.cmake b/Superbuild/SQLiteInstall.cmake new file mode 100644 index 0000000000..4d0ae89e1d --- /dev/null +++ b/Superbuild/SQLiteInstall.cmake @@ -0,0 +1,17 @@ +# install-sqlite-headers.cmake +# Usage: cmake -Dsrc=... -Ddst=... -P install-sqlite-headers.cmake + +if(NOT DEFINED src OR NOT DEFINED dst) + message(FATAL_ERROR "install-sqlite-headers.cmake requires -Dsrc and -Ddst") +endif() + +file(MAKE_DIRECTORY "${dst}") +# Copy only the headers you care about; adjust if more headers are needed. +# If you want the whole dir content, use file(COPY ...) like the Tny script. +foreach(h sqlite3.h sqlite3ext.h) + if(EXISTS "${src}/${h}") + file(COPY "${src}/${h}" DESTINATION "${dst}") + else() + message(WARNING "Header not found: ${src}/${h}") + endif() +endforeach() \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 70cf9779ae..1cb3c6d5d4 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -242,6 +242,17 @@ endif() # Keep Boost last so we can compute Boost_DIR & legacy hints afterward ADD_EXTERNAL(${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external) +# Ensure header copy steps run before SCIRun config/build +if(TARGET Glew_external-copy_headers) + add_dependencies(SCIRun_external Glew_external-copy_headers) +endif() +if(TARGET Tny_external-copy_headers) + add_dependencies(SCIRun_external Tny_external-copy_headers) +endif() +if(TARGET SQLite_external-copy_headers) + add_dependencies(SCIRun_external SQLite_external-copy_headers) +endif() + # ========================= # Exporters (config dir / include & lib dir) # ========================= diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index 053e4d7e6d..11e9f148c7 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -37,11 +37,12 @@ ExternalProject_Add(Tny_external CONFIGURE_COMMAND "" BUILD_COMMAND "" - # Copy only the headers into a conventional layout: - # /include/tny/tny.hpp + # Run the script to create the dir and copy headers INSTALL_COMMAND - ${CMAKE_COMMAND} -E make_directory "${_tny_inst}/include/tny" && - ${CMAKE_COMMAND} -E copy_directory "/tny/src/tny" "${_tny_inst}/include/tny" + ${CMAKE_COMMAND} + -Dsrc=/tny/src/tny + -Ddst=${_tny_inst}/include/tny + -P ${CMAKE_CURRENT_LIST_DIR}/TnyInstall.cmake LOG_CONFIGURE 1 LOG_BUILD 1 diff --git a/Superbuild/TnyInstall.cmake b/Superbuild/TnyInstall.cmake new file mode 100644 index 0000000000..28b7eb49a7 --- /dev/null +++ b/Superbuild/TnyInstall.cmake @@ -0,0 +1,12 @@ +# install-tny.cmake +# Usage: cmake -Dsrc=... -Ddst=... -P install-tny.cmake + +if(NOT DEFINED src OR NOT DEFINED dst) + message(FATAL_ERROR "install-tny.cmake requires -Dsrc and -Ddst") +endif() + +# Ensure the destination exists +file(MAKE_DIRECTORY "${dst}") + +# Copy the *contents* of src into dst (note the trailing slash) +file(COPY "${src}/" DESTINATION "${dst}") \ No newline at end of file From 41d0e34df66e42b32fb07374a171d92898a224d1 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Feb 2026 12:38:09 -0700 Subject: [PATCH 028/140] tny header path --- Superbuild/TnyExternal.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index 11e9f148c7..abc5b29573 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -40,7 +40,7 @@ ExternalProject_Add(Tny_external # Run the script to create the dir and copy headers INSTALL_COMMAND ${CMAKE_COMMAND} - -Dsrc=/tny/src/tny + -Dsrc=/src/tny -Ddst=${_tny_inst}/include/tny -P ${CMAKE_CURRENT_LIST_DIR}/TnyInstall.cmake From 65ec89209e831c9c0d250fde3f5e1bf63c1c6396 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Feb 2026 16:37:26 -0700 Subject: [PATCH 029/140] default qt path on my computer --- Superbuild/Superbuild.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 1cb3c6d5d4..b424dd7db9 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -100,10 +100,22 @@ set(QT5_MIN_VERSION "5.15.2") set(QT6_MIN_VERSION "6.3.0") set(Qt_PATH "" CACHE PATH "Qt install prefix (e.g. C:/Qt/6.10.1/msvc2022_64)") +if (WIN32 AND NOT BUILD_HEADLESS) + if (NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") + set(_qt_default "C:/Qt/6.10.1/msvc2022_64") + if (IS_DIRECTORY "${_qt_default}") + message(STATUS "Qt_PATH not set or invalid — defaulting to ${_qt_default}") + set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) + endif() + endif() +endif() + +# Validate if (NOT BUILD_HEADLESS) if (NOT IS_DIRECTORY "${Qt_PATH}") message(FATAL_ERROR - "Qt_PATH invalid. Point it to the Qt install prefix with lib/, bin/, and lib/cmake/Qt[56].\n" + "Qt_PATH invalid or not set.\n" + "Point it to the Qt install prefix with lib/, bin/, and lib/cmake/Qt[56].\n" "Example: C:/Qt/6.10.1/msvc2022_64") endif() From 13ae258da018a2f17e0d9ea2df0520646d5aa80a Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Feb 2026 16:52:55 -0700 Subject: [PATCH 030/140] boost lib version names --- Superbuild/BoostExternal.cmake | 197 ++++++++++++++++++++------------- src/CMakeLists.txt | 60 ++++++++-- 2 files changed, 172 insertions(+), 85 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 4285988487..55159e2d42 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -56,6 +56,24 @@ if(BOOST_ENABLE_TEST) list(APPEND _BOOST_LIBS test) endif() +# Convert to b2 --with- arguments +set(_BOOST_LIBS_B2 "") +foreach(_bl IN LISTS _BOOST_LIBS) + list(APPEND _BOOST_LIBS_B2 "--with-${_bl}") +endforeach() + +# ========= Build knobs for b2 (must match your app's toolchain) ========= +# STATIC vs SHARED Boost libs (import lib + DLL if SHARED) +option(BOOST_USE_STATIC_LIBS "Build static Boost libraries" ON) + +# Runtime library (/MD,/MDd shared; /MT,/MTd static) +option(BOOST_USE_STATIC_RUNTIME "Use static C runtime (/MT,/MTd). OFF = /MD,/MDd" OFF) + +# MSVC toolset (VS 2022 ~ 14.3). Override with -DB2_TOOLSET=msvc-14.3 if needed. +if(NOT DEFINED B2_TOOLSET) + set(B2_TOOLSET msvc-14.3) +endif() + # ========= ExternalProject definition ========= ExternalProject_Add(Boost_external GIT_REPOSITORY ${_boost_git_url} @@ -68,102 +86,99 @@ ExternalProject_Add(Boost_external BUILD_IN_SOURCE OFF - # Configure Boost with CMake Superproject (build only compiled libs) - CONFIGURE_COMMAND - ${CMAKE_COMMAND} - -S - -B - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=$,${CMAKE_BUILD_TYPE},$> # single & multi-config - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DBUILD_TESTING=OFF - -DBOOST_INSTALL_HEADERS=ON - -DBOOST_INSTALL_LAYOUT=system - -DBOOST_INCLUDE_LIBRARIES:STRING=${_BOOST_LIBS} # compiled libs only - -DCMAKE_CXX_FLAGS=${boost_CXX_Flags} - - BUILD_COMMAND - ${CMAKE_COMMAND} --build --config ${CMAKE_CFG_INTDIR} - - INSTALL_COMMAND - ${CMAKE_COMMAND} --build --target install --config ${CMAKE_CFG_INTDIR} + # We will NOT use the CMake superproject for compiled libs + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" ) +ExternalProject_Get_Property(Boost_external SOURCE_DIR) +ExternalProject_Get_Property(Boost_external BINARY_DIR) +ExternalProject_Get_Property(Boost_external INSTALL_DIR) + # ========= Cross-platform b2 header staging ========= # 1) Bootstrap b2 if(WIN32) set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) - set(_B2_HEADERS_CMD cmd /c .\\b2 headers) + set(_B2_CMD cmd /c .\\b2) else() - # Linux/macOS set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) - set(_B2_HEADERS_CMD ./b2 headers) + set(_B2_CMD ./b2) endif() ExternalProject_Add_Step(Boost_external bootstrap_b2 COMMAND ${_B2_BOOTSTRAP_CMD} - WORKING_DIRECTORY + WORKING_DIRECTORY ${SOURCE_DIR} DEPENDEES update - DEPENDERS configure # ensure b2 exists before configure/build COMMENT "Bootstrapping Boost.Build (b2)" ) # 2) Generate the full 'boost/' header tree ExternalProject_Add_Step(Boost_external stage_headers - COMMAND ${_B2_HEADERS_CMD} - WORKING_DIRECTORY + COMMAND ${_B2_CMD} headers + WORKING_DIRECTORY ${SOURCE_DIR} DEPENDEES bootstrap_b2 - DEPENDERS install # must happen before/with install COMMENT "Running 'b2 headers' to generate the boost/ header tree" ) -# 3) Copy the entire header tree into the install prefix +# ========= Build compiled libs with b2 (MSVC-style versioned names) ========= +# Determine b2 arguments +if(BOOST_USE_STATIC_LIBS) + set(_B2_LINK "link=static") +else() + set(_B2_LINK "link=shared") +endif() + +if(BOOST_USE_STATIC_RUNTIME) + set(_B2_RUNTIME_LINK "runtime-link=static") # /MT,/MTd +else() + set(_B2_RUNTIME_LINK "runtime-link=shared") # /MD,/MDd +endif() + +set(_B2_VARIANTS "variant=debug,release") # build both for multi-config IDEs + +# Keep all b2 artifacts under /b2-build +set(_B2_BUILD_DIR ${BINARY_DIR}/b2-build) + +ExternalProject_Add_Step(Boost_external build_b2_libs + COMMAND ${_B2_CMD} + -j${CMAKE_BUILD_PARALLEL_LEVEL} + address-model=64 architecture=x86 + toolset=${B2_TOOLSET} + threading=multi + ${_B2_LINK} + ${_B2_RUNTIME_LINK} + ${_B2_VARIANTS} + --layout=versioned + ${_BOOST_LIBS_B2} + --build-dir=${_B2_BUILD_DIR} + stage + WORKING_DIRECTORY ${SOURCE_DIR} + DEPENDEES stage_headers + COMMENT "Building Boost libs with b2 (versioned names for MSVC auto-link)" +) + +# 3) Install staged libs into /lib +ExternalProject_Add_Step(Boost_external install_b2_libs + COMMAND ${CMAKE_COMMAND} -E make_directory /lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/stage/lib /lib + DEPENDEES build_b2_libs + COMMENT "Installing b2-built Boost libs into /lib" +) + +# 4) Copy the entire header tree into the install prefix ExternalProject_Add_Step(Boost_external install_full_headers COMMAND ${CMAKE_COMMAND} -E make_directory /include COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost - COMMAND ${CMAKE_COMMAND} -E copy_directory /boost /include/boost + COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/boost /include/boost DEPENDEES stage_headers - DEPENDERS install COMMENT "Copying full Boost headers to /include/boost" ) # ========= Export properties for downstream ========= -ExternalProject_Get_Property(Boost_external INSTALL_DIR) -ExternalProject_Get_Property(Boost_external SOURCE_DIR) - # Convenience prefix set(SCI_BOOST_PREFIX "${INSTALL_DIR}") -# For both Config and Module find modes -set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix" FORCE) - -# Make our Boost take precedence over system -if(NOT DEFINED CMAKE_PREFIX_PATH) - set(CMAKE_PREFIX_PATH "") -endif() -list(PREPEND CMAKE_PREFIX_PATH "${SCI_BOOST_PREFIX}") -set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE PATH "Prefix search path" FORCE) - -# Compute Boost_DIR robustly (versioned Boost- or fallback Boost/) -set(_boost_cmake_root "${SCI_BOOST_PREFIX}/lib/cmake") -set(_boost_dir_guess "") - -if(EXISTS "${_boost_cmake_root}") - file(GLOB _boost_cfg_candidates "${_boost_cmake_root}/Boost-*") - foreach(_cand IN LISTS _boost_cfg_candidates) - if(EXISTS "${_cand}/BoostConfig.cmake") - set(_boost_dir_guess "${_cand}") - break() - endif() - endforeach() - if(NOT _boost_dir_guess AND EXISTS "${_boost_cmake_root}/Boost/BoostConfig.cmake") - set(_boost_dir_guess "${_boost_cmake_root}/Boost") - endif() -endif() - -set(Boost_DIR "${_boost_dir_guess}" CACHE PATH "Boost package directory (for find_package Boost)" FORCE) - # Concrete include/lib paths (SCIRun consumes these) set(SCI_BOOST_INCLUDE "${SCI_BOOST_PREFIX}/include" CACHE PATH "Boost include directory" FORCE) if (EXISTS "${SCI_BOOST_PREFIX}/lib64") @@ -173,23 +188,51 @@ else() endif() set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library directory" FORCE) -# Optional: legacy use file -set(SUPERBUILD_DIR "${CMAKE_CURRENT_LIST_DIR}") +# Since we are NOT installing BoostConfig.cmake, prefer MODULE mode if you still call find_package(Boost) +set(Boost_DIR "" CACHE PATH "No BoostConfig.cmake (b2 build). Use FindBoost (MODULE) if needed." FORCE) +set(Boost_NO_BOOST_CMAKE ON CACHE BOOL "Force FindBoost MODULE mode" FORCE) +set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix" FORCE) +set(BOOST_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix (compat)" FORCE) +set(BOOST_LIBRARYDIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library dir (compat)" FORCE) + +# ========= Generate a 'UseBoost.cmake' for consumers (auto-link ON) ========= +# - Adds include and link search dirs. +# - If building shared Boost libs, define BOOST_ALL_DYN_LINK (ensures __declspec(dllimport)). +# - INTENTIONALLY does NOT define BOOST_ALL_NO_LIB (we want auto-link to inject versioned names). set(SCI_BOOST_USE_FILE "${SCI_BOOST_PREFIX}/UseBoost.cmake") -if (EXISTS "${SUPERBUILD_DIR}/UseBoost.cmake") - configure_file(${SUPERBUILD_DIR}/UseBoost.cmake ${SCI_BOOST_USE_FILE} COPYONLY) +set(_usefile "## Auto-generated UseBoost.cmake (b2 + autolink) +# Include dirs for headers +include_guard(GLOBAL) +if(EXISTS \"${SCI_BOOST_INCLUDE}\") + include_directories(\"${SCI_BOOST_INCLUDE}\") +endif() + +# Link search dir so MSVC can find the versioned .lib names injected by auto-link +if(EXISTS \"${SCI_BOOST_LIBRARY_DIR}\") + link_directories(\"${SCI_BOOST_LIBRARY_DIR}\") +endif() + +# If Boost was built as shared libs, define BOOST_ALL_DYN_LINK so import libs/DLLs are used +") +if(NOT BOOST_USE_STATIC_LIBS) + string(APPEND _usefile "add_compile_definitions(BOOST_ALL_DYN_LINK)\n") endif() -# Diagnostics +# Helpful hints for FindBoost (MODULE) if you still want to query variables +string(APPEND _usefile " +set(Boost_ROOT \"${SCI_BOOST_PREFIX}\") +set(BOOST_ROOT \"${SCI_BOOST_PREFIX}\") +set(BOOST_LIBRARYDIR \"${SCI_BOOST_LIBRARY_DIR}\") +") +file(WRITE "${SCI_BOOST_USE_FILE}" "${_usefile}") + +# ========= Diagnostics ========= message(STATUS "[Boost_ext] INSTALL_DIR: ${SCI_BOOST_PREFIX}") -message(STATUS "[Boost_ext] Boost_ROOT: ${Boost_ROOT}") -message(STATUS "[Boost_ext] Boost_DIR: ${Boost_DIR}") message(STATUS "[Boost_ext] Include dir: ${SCI_BOOST_INCLUDE}") message(STATUS "[Boost_ext] Lib dir: ${SCI_BOOST_LIBRARY_DIR}") -message(STATUS "[Boost_ext] BOOST_INCLUDE_LIBRARIES (compiled only): ${_BOOST_LIBS}") - -if (EXISTS "${Boost_DIR}/BoostConfig.cmake") - message(STATUS "[Boost_ext] Found BoostConfig.cmake at: ${Boost_DIR}/BoostConfig.cmake") -else() - message(STATUS "[Boost_ext] (Will be created after Boost install) Expected under: ${_boost_cmake_root}") -endif() \ No newline at end of file +message(STATUS "[Boost_ext] Built libs: ${_BOOST_LIBS}") +message(STATUS "[Boost_ext] b2 link type: ${_B2_LINK}") +message(STATUS "[Boost_ext] b2 runtime link: ${_B2_RUNTIME_LINK}") +message(STATUS "[Boost_ext] b2 toolset: ${B2_TOOLSET}") +message(STATUS "[Boost_ext] Use file: ${SCI_BOOST_USE_FILE}") +message(STATUS "[Boost_ext] Note: No BoostConfig.cmake installed (using b2). Auto-link on MSVC will inject versioned .lib names.") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e549cfa73..fd33bc76f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,45 @@ message(STATUS "[SCIRun] Qt_PATH='${Qt_PATH}'") message(STATUS "[SCIRun] Boost_DIR='${Boost_DIR}' ; Boost_ROOT='${Boost_ROOT}' ; BOOST_ROOT='${BOOST_ROOT}' ; SCI_BOOST_PREFIX='${SCI_BOOST_PREFIX}'") message(STATUS "[SCIRun] ZLIB_ROOT='${ZLIB_ROOT}' ; ZLIB_DIR='${ZLIB_DIR}' ; ZLIB_INCLUDE_DIR='${ZLIB_INCLUDE_DIR}'") +# --- Boost (Windows-only: b2-built libs with MSVC auto-link) --- +# This expects the external Boost builder to have created: +# - ${SCI_BOOST_PREFIX}/include/boost/** (from `b2 headers` copy) +# - ${SCI_BOOST_PREFIX}/lib/libboost_*vc143*.lib (from b2 with --layout=versioned) +# +# It keeps auto-linking ON (do NOT define BOOST_ALL_NO_LIB here). +# It ensures the linker can find the versioned .lib names injected by Boost headers. + +if(WIN32) + if(DEFINED SCI_BOOST_PREFIX) + set(_boost_use "${SCI_BOOST_PREFIX}/UseBoost.cmake") + if(EXISTS "${_boost_use}") + include("${_boost_use}") # adds include + lib search dirs, keeps autolink ON + else() + # Fallback: add include and library search dirs from exported vars + if(DEFINED SCI_BOOST_INCLUDE AND IS_DIRECTORY "${SCI_BOOST_INCLUDE}") + include_directories(SYSTEM "${SCI_BOOST_INCLUDE}") + endif() + if(DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") + # Directory-wide link search path so MSVC finds libboost_*‑vc143‑... .lib files + link_directories("${SCI_BOOST_LIBRARY_DIR}") + endif() + endif() + + # Optional sanity check: warn if no versioned Boost libs were found + if(DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") + file(GLOB _boost_ver_libs "${SCI_BOOST_LIBRARY_DIR}/libboost_*vc*.lib") + if(NOT _boost_ver_libs) + message(WARNING + "[SCIRun] No versioned Boost .lib files detected under '${SCI_BOOST_LIBRARY_DIR}'.\n" + " Ensure your external Boost build used b2 with '--layout=versioned' and staged/installed libs.") + endif() + unset(_boost_ver_libs) + endif() + else() + message(WARNING "[SCIRun] SCI_BOOST_PREFIX is not defined; Windows auto-link may fail to locate Boost libs.") + endif() +endif() + ############################################################################### # Don't allow the user to build in the src directory... # @@ -600,14 +639,19 @@ if(BUILD_WITH_PYTHON) ) endif() -# Boost — REQUIRED, prefer config package -CONFIG_STANDARD_EXTERNAL(Boost - ROOT "${SCI_BOOST_PREFIX}" - DIR "${Boost_DIR}" - CFG "BoostConfig.cmake" - CONFIG_ONLY - REQUIRED -) +# Boost — REQUIRED on non-Windows (prefer config package). +# On Windows with b2-built Boost, skip CONFIG mode: rely on auto-link + link_directories above. +if(WIN32) + message(STATUS "[SCIRun] Boost: using b2-built libraries with MSVC auto-link (no BoostConfig.cmake). Skipping CONFIG package discovery on Windows.") +else() + CONFIG_STANDARD_EXTERNAL(Boost + ROOT "${SCI_BOOST_PREFIX}" + DIR "${Boost_DIR}" + CFG "BoostConfig.cmake" + CONFIG_ONLY + REQUIRED + ) +endif() # Tiny (Tny) CONFIG_STANDARD_EXTERNAL(Tny From 227012c0d242df8f537df108a7742a9230b02bbc Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 9 Feb 2026 15:01:35 -0700 Subject: [PATCH 031/140] sqlite issue --- Superbuild/BoostExternal.cmake | 4 +- Superbuild/SQLiteExternal.cmake | 60 ++++++++-- Superbuild/SQLiteInstall.cmake | 76 +++++++++++-- src/CMakeLists.txt | 172 ++++++++++++++++++----------- src/Core/Utils/Legacy/FileUtils.cc | 40 ++++++- src/Core/Utils/Legacy/FileUtils.h | 1 + 6 files changed, 267 insertions(+), 86 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 55159e2d42..206e7d5745 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -37,8 +37,8 @@ set(_BOOST_LIBS filesystem system atomic - # Add here only if/when linker complains: - # chrono; thread; regex; program_options; iostreams; date_time; serialization + thread + program_options ) # Optional compiled libs (usually OFF) diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index 8f635204e7..adc7a3304a 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -27,7 +27,7 @@ # SQLiteExternal.cmake (redirect libs + copy headers into Install/include) set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -set(sqlite_GIT_TAG "v3.0.1") +set(sqlite_GIT_TAG "v3.51.2") # Common CMake args set(_cmake_args @@ -85,16 +85,62 @@ ExternalProject_Add(SQLite_external LOG_INSTALL 1 ) +ExternalProject_Get_Property(SQLite_external INSTALL_DIR) +set(SQLITE_INSTALL_DIR "${INSTALL_DIR}") +set(SQLITE_INCLUDE "${SQLITE_INSTALL_DIR}/include") +set(SQLITE_LIBRARY_DIR "${SQLITE_INSTALL_DIR}/lib") + +# Detect sqlite library name after build (sqlite vs sqlite3) with multi-config awareness +# We’ll prefer sqlite3.*, then sqlite.* +set(_sqlite_lib_names "sqlite3" "sqlite") +set(_sqlite_lib_exts) +if(WIN32) + list(APPEND _sqlite_lib_exts ".lib") +else() + list(APPEND _sqlite_lib_exts ".a" ".so" ".dylib") +endif() + +# Small CMake script to resolve the name after build +set(_sqlite_check "${CMAKE_BINARY_DIR}/check_sqlite_lib_name.cmake") +file(WRITE "${_sqlite_check}" " + set(LIBDIR \"${SQLITE_LIBRARY_DIR}\") + set(names sqlite3 sqlite) + if(WIN32) + set(exts .lib) + else() + set(exts .a .so .dylib) + endif() + set(found \"\") + foreach(n IN LISTS names) + foreach(e IN LISTS exts) + file(GLOB hits \"${SQLITE_LIBRARY_DIR}/${n}*${e}\") + if(hits) + set(found \"${n}\") + break() + endif() + endforeach() + if(found) + break() + endif() + endforeach() + if(NOT found) + message(FATAL_ERROR \"SQLite lib not found in ${SQLITE_LIBRARY_DIR}. Expected sqlite3 or sqlite.\") + endif() + # Persist the detected base name + set(SQLITE_LIBRARY \"${found}\" CACHE STRING \"SQLite library base name (sqlite vs sqlite3)\" FORCE) + message(STATUS \"[SQLite_external] Detected library basename: ${found}\") +") + +ExternalProject_Add_Step(SQLite_external verify_lib_name + COMMAND ${CMAKE_COMMAND} -P "${_sqlite_check}" + DEPENDEES build + COMMENT "Verifying SQLite library name and caching SQLITE_LIBRARY" +) + # Export variables for SCIRun set(SQLITE_SOURCE_DIR ${_sqlite_src}) set(SQLITE_INSTALL_DIR ${_sqlite_inst}) set(SQLITE_INCLUDE ${SQLITE_INSTALL_DIR}/include) set(SQLITE_LIBRARY_DIR ${SQLITE_INSTALL_DIR}/lib) -# Library name note: -# Many SQLite CMake builds produce 'sqlite3' as the lib name. -# Your repo tag v3.0.1 may export 'sqlite' or 'sqlite3' depending on CMakeLists. -# If build fails to link, try switching this to 'sqlite3'. -set(SQLITE_LIBRARY "sqlite") - message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/SQLiteInstall.cmake b/Superbuild/SQLiteInstall.cmake index 4d0ae89e1d..637e542a48 100644 --- a/Superbuild/SQLiteInstall.cmake +++ b/Superbuild/SQLiteInstall.cmake @@ -1,17 +1,69 @@ -# install-sqlite-headers.cmake -# Usage: cmake -Dsrc=... -Ddst=... -P install-sqlite-headers.cmake +# SQLiteInstall.cmake +# Usage: +# cmake -Dsrc= -Ddst= -P SQLiteInstall.cmake +# +# Copies SQLite public headers into the install include directory in a robust way. +# - Supports both amalgamation layout (headers in repo root) and CMake "include/" layout. +# - Fails fast if sqlite3.h cannot be found in any expected location. + +cmake_minimum_required(VERSION 3.15) if(NOT DEFINED src OR NOT DEFINED dst) - message(FATAL_ERROR "install-sqlite-headers.cmake requires -Dsrc and -Ddst") + message(FATAL_ERROR "SQLiteInstall.cmake requires -Dsrc and -Ddst (got src='${src}', dst='${dst}')") endif() -file(MAKE_DIRECTORY "${dst}") -# Copy only the headers you care about; adjust if more headers are needed. -# If you want the whole dir content, use file(COPY ...) like the Tny script. -foreach(h sqlite3.h sqlite3ext.h) - if(EXISTS "${src}/${h}") - file(COPY "${src}/${h}" DESTINATION "${dst}") - else() - message(WARNING "Header not found: ${src}/${h}") +# Normalize paths +file(TO_CMAKE_PATH "${src}" _SRC) +file(TO_CMAKE_PATH "${dst}" _DST) + +# Create destination include dir +file(MAKE_DIRECTORY "${_DST}") + +# Candidate locations to probe for public headers +# 1) Amalgamation in project root: /sqlite3.h, sqlite3ext.h +# 2) CMake-style include directory: /include/sqlite3.h +# 3) Rare alternative layouts: /inc/sqlite3.h +set(_CANDIDATES + "${_SRC}" + "${_SRC}/include" + "${_SRC}/inc" +) + +# Find a candidate that actually contains sqlite3.h +set(_FOUND_SOURCE "") +foreach(_C IN LISTS _CANDIDATES) + if(EXISTS "${_C}/sqlite3.h") + set(_FOUND_SOURCE "${_C}") + break() endif() -endforeach() \ No newline at end of file +endforeach() + +if(NOT _FOUND_SOURCE) + # Print helpful diagnostics + message(STATUS "[SQLiteInstall.cmake] Probed candidates:") + foreach(_C IN LISTS _CANDIDATES) + message(STATUS " - ${_C}") + endforeach() + message(FATAL_ERROR "Could not find 'sqlite3.h' under any candidate. " + "Searched in: ${_CANDIDATES}") +endif() + +message(STATUS "[SQLiteInstall.cmake] Using header source dir: ${_FOUND_SOURCE}") +message(STATUS "[SQLiteInstall.cmake] Destination include dir: ${_DST}") + +# Copy sqlite3.h (required) +file(COPY "${_FOUND_SOURCE}/sqlite3.h" DESTINATION "${_DST}") + +# Copy sqlite3ext.h if present (optional extension API) +if(EXISTS "${_FOUND_SOURCE}/sqlite3ext.h") + file(COPY "${_FOUND_SOURCE}/sqlite3ext.h" DESTINATION "${_DST}") +else() + message(STATUS "[SQLiteInstall.cmake] Optional header not found: ${_FOUND_SOURCE}/sqlite3ext.h") +endif() + +# Verify copy succeeded +if(NOT EXISTS "${_DST}/sqlite3.h") + message(FATAL_ERROR "Copy failed: '${_DST}/sqlite3.h' not found after copy.") +endif() + +message(STATUS "[SQLiteInstall.cmake] Copied headers into: ${_DST}") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd33bc76f2..e0e868dd8e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -915,41 +915,88 @@ ENDIF() SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) -# ---------- Diagnostics + optional auto-derive from CMAKE_PREFIX_PATH ---------- -# Helper to derive an include dir from CMAKE_PREFIX_PATH if the var is not set -function(_derive_include_dir _outvar _header_glob) - if(NOT ${_outvar}) +# ---------- Diagnostics + robust include discovery ---------- + +# Normalize superbuild-provided names to what SCIRun uses internally +if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) + set(LODEPNG_INCLUDE_DIR "${LodePng_INCLUDE_DIR}") +endif() +if(DEFINED Tny_INCLUDE_DIR AND NOT DEFINED TNY_INCLUDE_DIR) + set(TNY_INCLUDE_DIR "${Tny_INCLUDE_DIR}") +endif() + +# Helper: validate a cached include dir (VAR) by checking it contains REL_HEADER. +# If empty or incorrect, auto-derive from CMAKE_PREFIX_PATH and cache the fix. +function(_ensure_header _var_name _rel_header) + # current value (from cache or parent) + set(_val "${${_var_name}}") + + # Decide if current value is valid + set(_valid FALSE) + if(_val AND EXISTS "${_val}/${_rel_header}") + set(_valid TRUE) + endif() + + if(NOT _valid) + # Try to auto-derive from CMAKE_PREFIX_PATH: look for include dirs that contain the header set(_candidates) - foreach(_p IN LISTS CMAKE_PREFIX_PATH) - list(APPEND _candidates "${_p}/include") + if(CMAKE_PREFIX_PATH) + foreach(_p IN LISTS CMAKE_PREFIX_PATH) + list(APPEND _candidates "${_p}/include") + endforeach() + endif() + + set(_found "") + foreach(_inc IN LISTS _candidates) + if(EXISTS "${_inc}/${_rel_header}") + set(_found "${_inc}") + break() + endif() endforeach() - find_path(_found_dir - NAMES ${_header_glob} - PATHS ${_candidates} - NO_DEFAULT_PATH - ) - if(_found_dir) - set(${_outvar} "${_found_dir}" PARENT_SCOPE) + + if(_found) + # Cache-stabilize the corrected value + set(${_var_name} "${_found}" CACHE PATH "${_var_name}" FORCE) + message(STATUS "[SCIRun] Fixed ${_var_name} -> '${_found}' (found '${_rel_header}')") + else() + # Clear wrong cached value if it was set but invalid + if(_val AND NOT _valid) + message(WARNING "[SCIRun] ${_var_name} ('${_val}') does not contain '${_rel_header}'. Clearing.") + endif() + unset(${_var_name} CACHE) + unset(${_var_name}) endif() + else() + # Keep and cache-stabilize a correct value + set(${_var_name} "${_val}" CACHE PATH "${_var_name}" FORCE) endif() endfunction() -# Try to fill any missing include dir variables using the expected headers: -_derive_include_dir(GLEW_INCLUDE_DIR "GL/glew.h") -_derive_include_dir(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") -_derive_include_dir(SQLite3_INCLUDE_DIR "sqlite3.h") -_derive_include_dir(TNY_INCLUDE_DIR "tny/tny.hpp") -# Boost_INCLUDE_DIR is already passed; if needed: -# _derive_include_dir(Boost_INCLUDE_DIR "boost/array.hpp") - -# Print diagnostics so you can see them in the configure log +# Validate / auto-fix externals we depend on: +# GLEW: GL/glew.h +# LodePNG: lodepng/lodepng.h +# SQLite3: sqlite3.h +# Tny: tny/tny.hpp +# Spdlog: spdlog/spdlog.h +# GLM: glm/glm.hpp +_ensure_header(GLEW_INCLUDE_DIR "GL/glew.h") +_ensure_header(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") +_ensure_header(SQLite3_INCLUDE_DIR "sqlite3.h") +_ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") +_ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") +_ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") + +# Print diagnostics message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") message(STATUS "LODEPNG_INCLUDE_DIR='${LODEPNG_INCLUDE_DIR}'") message(STATUS "SQLite3_INCLUDE_DIR='${SQLite3_INCLUDE_DIR}'") message(STATUS "TNY_INCLUDE_DIR='${TNY_INCLUDE_DIR}'") +message(STATUS "SpdLog_INCLUDE_DIR='${SpdLog_INCLUDE_DIR}'") +message(STATUS "GLM_INCLUDE_DIR='${GLM_INCLUDE_DIR}'") +message(STATUS "Eigen_DIR='${Eigen_DIR}'") -# Quick existence checks (helpful during iteration) +# Quick existence confirmations if(GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") message(STATUS "GLEW header OK: ${GLEW_INCLUDE_DIR}/GL/glew.h") endif() @@ -962,8 +1009,15 @@ endif() if(TNY_INCLUDE_DIR AND EXISTS "${TNY_INCLUDE_DIR}/tny/tny.hpp") message(STATUS "TNY header OK: ${TNY_INCLUDE_DIR}/tny/tny.hpp") endif() +if(SpdLog_INCLUDE_DIR AND EXISTS "${SpdLog_INCLUDE_DIR}/spdlog/spdlog.h") + message(STATUS "Spdlog header OK: ${SpdLog_INCLUDE_DIR}/spdlog/spdlog.h") +endif() +if(GLM_INCLUDE_DIR AND EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp") + message(STATUS "GLM header OK: ${GLM_INCLUDE_DIR}/glm/glm.hpp") +endif() + +# ---------- Build include list with guards to avoid stray '/include' ---------- -# ---------- Build include list with guards to avoid '/include' ---------- set(_SCIRUN_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${SCIRun_SOURCE_DIR}/ @@ -978,37 +1032,55 @@ set(_SCIRUN_INCLUDE_DIRS ${SCIRun_BINARY_DIR}/include ${SCI_TEEM_INCLUDE} ${SCI_ZLIB_INCLUDE} - ${GLM_INCLUDE_DIR} ${SCI_QWT_INCLUDE} ${SCI_CLEAVER2_INCLUDE} ) -# Append externals only if the variables are set (prevents stray '/include') -if(Boost_INCLUDE_DIR) +# Append externals only if valid (directory exists and contains expected header) + +# Boost (legacy var) +if(Boost_INCLUDE_DIR AND EXISTS "${Boost_INCLUDE_DIR}/boost") list(APPEND _SCIRUN_INCLUDE_DIRS "${Boost_INCLUDE_DIR}") endif() -if(GLEW_INCLUDE_DIR) + +# GLEW +if(GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") list(APPEND _SCIRUN_INCLUDE_DIRS "${GLEW_INCLUDE_DIR}") endif() -if(LODEPNG_INCLUDE_DIR) - list(APPEND _SCIRUN_INCLUDE_DIRS "${LODEPNG_INCLUDE_DIR}") -endif() -if(SQLite3_INCLUDE_DIR) + +# SQLite +if(SQLite3_INCLUDE_DIR AND EXISTS "${SQLite3_INCLUDE_DIR}/sqlite3.h") list(APPEND _SCIRUN_INCLUDE_DIRS "${SQLite3_INCLUDE_DIR}") endif() -if(TNY_INCLUDE_DIR) + +# Spdlog (IMPORTANT: do NOT append '/include'; var already points to include dir) +if(SpdLog_INCLUDE_DIR AND EXISTS "${SpdLog_INCLUDE_DIR}/spdlog/spdlog.h") + list(APPEND _SCIRUN_INCLUDE_DIRS "${SpdLog_INCLUDE_DIR}") +endif() + +# GLM +if(GLM_INCLUDE_DIR AND EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp") + list(APPEND _SCIRUN_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") +endif() + +# Tny +if(TNY_INCLUDE_DIR AND EXISTS "${TNY_INCLUDE_DIR}/tny/tny.hpp") list(APPEND _SCIRUN_INCLUDE_DIRS "${TNY_INCLUDE_DIR}") endif() -# Optional: SPDLOG and Eigen if present; guard to avoid '/include' -if(SPDLOG_DIR) - list(APPEND _SCIRUN_INCLUDE_DIRS "${SPDLOG_DIR}/include") +# LodePNG +if(LODEPNG_INCLUDE_DIR AND EXISTS "${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") + list(APPEND _SCIRUN_INCLUDE_DIRS "${LODEPNG_INCLUDE_DIR}") endif() -if(Eigen_DIR) + +# Eigen (if provided as a directory) +if(Eigen_DIR AND IS_DIRECTORY "${Eigen_DIR}") list(APPEND _SCIRUN_INCLUDE_DIRS "${Eigen_DIR}") endif() -# Debug print and apply +# De-duplicate & print for visibility +list(REMOVE_DUPLICATES _SCIRUN_INCLUDE_DIRS) + function(print_list name) message(STATUS "${name}:") foreach(item IN LISTS ${name}) @@ -1018,30 +1090,6 @@ endfunction() print_list("_SCIRUN_INCLUDE_DIRS") include_directories(${_SCIRUN_INCLUDE_DIRS}) - -#INCLUDE_DIRECTORIES( -# ${CMAKE_CURRENT_BINARY_DIR} -# ${SCIRun_SOURCE_DIR}/ -# ${SCIRun_SOURCE_DIR}/include -# ${SCIRun_SOURCE_DIR}/Externals/libxml2/include -# ${SCIRun_SOURCE_DIR}/Externals/spire/ -# ${SCIRun_SOURCE_DIR}/Externals/submodules/googletest/googletest/include -# ${SCIRun_SOURCE_DIR}/Externals/submodules/googletest/googlemock/include -# ${CMAKE_CURRENT_BINARY_DIR}/Externals/libxml2/include -# ${SCIRun_SOURCE_DIR}/Externals/ -# ${SCIRun_BINARY_DIR}/ -# ${SCIRun_BINARY_DIR}/include -# ${SCI_TEEM_INCLUDE} -# ${SCI_ZLIB_INCLUDE} -# ${GLM_INCLUDE_DIR} -# ${SPDLOG_DIR}/include -# ${Eigen_DIR} -# ${SCI_TNY_INCLUDE} -# ${SCI_LODEPNG_INCLUDE} -# ${SCI_QWT_INCLUDE} -# ${SCI_CLEAVER2_INCLUDE} -#) - INCLUDE_DIRECTORIES(SYSTEM ${SCI_BOOST_INCLUDE}) ADD_DEFINITIONS(-DQT_NO_KEYWORDS) diff --git a/src/Core/Utils/Legacy/FileUtils.cc b/src/Core/Utils/Legacy/FileUtils.cc index 0b99966595..314bb914a3 100644 --- a/src/Core/Utils/Legacy/FileUtils.cc +++ b/src/Core/Utils/Legacy/FileUtils.cc @@ -52,6 +52,7 @@ #include #include +#include #include #include @@ -442,24 +443,57 @@ convertToWindowsPath( std::string & unixPath ) } } + int copyFile(const bfs::path& src, const bfs::path& dest) { int code = -1; try { bsys::error_code ec; - bfs::copy_file(src, dest, bfs::copy_option::overwrite_if_exists, ec); + + // Ensure destination directory exists + if (!dest.parent_path().empty()) + { + bfs::create_directories(dest.parent_path(), ec); + ec.clear(); + } + + // If src and dest are the same, nothing to do + if (bfs::exists(src) && bfs::exists(dest)) + { + bsys::error_code eqec; + if (bfs::equivalent(src, dest, eqec)) + { + return 0; + } + } + + // Emulate "overwrite": remove destination if present + if (bfs::exists(dest)) + { + bfs::remove(dest, ec); + ec.clear(); + } + + // Copy without options + bfs::copy_file(src, dest, ec); code = ec.value(); -#if DEBUG + +#if defined(_DEBUG) || !defined(NDEBUG) if (code != bsys::errc::success) { std::cerr << "error " << ec.value() << ": " << ec.message() << std::endl; } #endif } + catch (const std::exception& e) + { + std::cerr << "Error copying " << src.string() << " to " << dest.string() + << ": " << e.what() << std::endl; + } catch (...) { - std::cerr << "Error copying " << src.c_str() << " to " << dest.c_str() << std::endl; + std::cerr << "Error copying " << src.string() << " to " << dest.string() << std::endl; } return code; } diff --git a/src/Core/Utils/Legacy/FileUtils.h b/src/Core/Utils/Legacy/FileUtils.h index 38522ad42f..5b073d391a 100644 --- a/src/Core/Utils/Legacy/FileUtils.h +++ b/src/Core/Utils/Legacy/FileUtils.h @@ -41,6 +41,7 @@ #include #include #include +#include #include From 358c89dec0bec6d8d83d0cb879bc556260bb1746 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 9 Feb 2026 16:28:59 -0700 Subject: [PATCH 032/140] sqlite --- Superbuild/SQLiteExternal.cmake | 218 +++++++++++++++++++------------- Superbuild/SQLiteInstall.cmake | 69 ---------- 2 files changed, 131 insertions(+), 156 deletions(-) delete mode 100644 Superbuild/SQLiteInstall.cmake diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index adc7a3304a..5d80be2e33 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -24,123 +24,167 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# SQLiteExternal.cmake (redirect libs + copy headers into Install/include) +# SQLiteExternal.cmake +# - Clones CIBC-Internal/sqlite at a tag/branch that contains the amalgamation at repo root: +# sqlite3.c, sqlite3.h, (optional) sqlite3ext.h +# - Verifies presence, builds static lib 'sqlite3', installs headers+lib to +# - Exports cache variables for SCIRun + +cmake_minimum_required(VERSION 3.15) + +# Keep ExternalProject data under the superbuild tree (provided by the top-level superbuild) set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(sqlite_GIT_TAG "v3.51.2") -# Common CMake args -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON +# Superbuild layout +set(_sqlite_src "${CMAKE_BINARY_DIR}/Externals/Source/SQLite_external") +set(_sqlite_bin "${CMAKE_BINARY_DIR}/Externals/Build/SQLite_external") +set(_sqlite_inst "${CMAKE_BINARY_DIR}/Externals/Install/SQLite_external") +file(MAKE_DIRECTORY "${_sqlite_inst}") + +include(ExternalProject) + +# ---------- Wrapper project (written into the build tree) ---------- +set(_wrapper_dir "${CMAKE_BINARY_DIR}/Externals/SQLiteWrapper") +file(MAKE_DIRECTORY "${_wrapper_dir}") + +file(WRITE "${_wrapper_dir}/CMakeLists.txt" " +cmake_minimum_required(VERSION 3.15) +project(SQLiteExternal C) + +if(NOT SQLite_SOURCE_DIR) + message(FATAL_ERROR \"SQLiteWrapper requires -DSQLite_SOURCE_DIR=\") +endif() + +# Require amalgamation present at the directory we were told (repo root) +if(NOT EXISTS \"\${SQLite_SOURCE_DIR}/sqlite3.c\") + message(FATAL_ERROR \"sqlite3.c not found in \${SQLite_SOURCE_DIR}\") +endif() +if(NOT EXISTS \"\${SQLite_SOURCE_DIR}/sqlite3.h\") + message(FATAL_ERROR \"sqlite3.h not found in \${SQLite_SOURCE_DIR}\") +endif() + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Build static library from amalgamation +add_library(sqlite3 STATIC \"\${SQLite_SOURCE_DIR}/sqlite3.c\") +target_include_directories(sqlite3 PUBLIC \"\${SQLite_SOURCE_DIR}\") - # Redirect all outputs so install step is unnecessary for libs - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin +# Install lib + headers +install(TARGETS sqlite3 + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) +install(FILES \"\${SQLite_SOURCE_DIR}/sqlite3.h\" DESTINATION include) +if(EXISTS \"\${SQLite_SOURCE_DIR}/sqlite3ext.h\") + install(FILES \"\${SQLite_SOURCE_DIR}/sqlite3ext.h\" DESTINATION include) +endif() +") + +# ---------- Fast pre-check (fail early if files aren't there) ---------- +set(_precheck "${CMAKE_BINARY_DIR}/Externals/SQLitePrecheck.cmake") +file(WRITE "${_precheck}" " + cmake_minimum_required(VERSION 3.15) + if(NOT src) + message(FATAL_ERROR \"SQLitePrecheck.cmake requires -Dsrc\") + endif() + file(TO_CMAKE_PATH \"\${src}\" src) + get_filename_component(src \"\${src}\" ABSOLUTE) + if(NOT EXISTS \"\${src}/sqlite3.c\") + message(FATAL_ERROR \"[SQLite_precheck] Missing: \${src}/sqlite3.c\") + endif() + if(NOT EXISTS \"\${src}/sqlite3.h\") + message(FATAL_ERROR \"[SQLite_precheck] Missing: \${src}/sqlite3.h\") + endif() + message(STATUS \"[SQLite_precheck] Found amalgamation at: \${src}\") +") -# Single-config generators +# Common args for wrapper configure (control outputs; multi-config aware) +set(_cfg_args + -DSQLite_SOURCE_DIR:PATH= + -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=/bin + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=/lib + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG:PATH=/lib + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE:PATH=/lib + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG:PATH=/bin + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE:PATH=/bin +) if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) + list(APPEND _cfg_args -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) endif() -# Superbuild directories -set(_sqlite_src "${CMAKE_BINARY_DIR}/Externals/Source/SQLite_external") -set(_sqlite_bin "${CMAKE_BINARY_DIR}/Externals/Build/SQLite_external") -set(_sqlite_inst "${CMAKE_BINARY_DIR}/Externals/Install/SQLite_external") +# Forward generator settings only if set +set(_gen_fwd CMAKE_GENERATOR "${CMAKE_GENERATOR}") +if(CMAKE_GENERATOR_PLATFORM) + list(APPEND _gen_fwd CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}") +endif() +if(CMAKE_GENERATOR_TOOLSET) + list(APPEND _gen_fwd CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") +endif() ExternalProject_Add(SQLite_external GIT_REPOSITORY "https://github.com/CIBC-Internal/sqlite.git" GIT_TAG ${sqlite_GIT_TAG} + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + + # Prevent the 'update' step from running 'git' in SOURCE_DIR (we pin to a tag) + UPDATE_COMMAND "" + UPDATE_DISCONNECTED 1 SOURCE_DIR ${_sqlite_src} BINARY_DIR ${_sqlite_bin} - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" + # Configure / Build / Install wrapper + CONFIGURE_COMMAND + ${CMAKE_COMMAND} -S "${_wrapper_dir}" -B "/wrap" ${_cfg_args} - CMAKE_ARGS ${_cmake_args} + BUILD_COMMAND + ${CMAKE_COMMAND} --build "/wrap" --config - # Let our script act as the "install" step INSTALL_COMMAND - ${CMAKE_COMMAND} - -Dsrc= # this is Externals/Source/SQLite_external - -Ddst=${_sqlite_inst}/include - -P ${CMAKE_CURRENT_LIST_DIR}/SQLiteInstall.cmake + ${CMAKE_COMMAND} --build "/wrap" --target install --config + + ${_gen_fwd} LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) +# Pre-configure step: verify amalgamation exists at repo root +ExternalProject_Add_Step(SQLite_external verify_amalgamation + COMMAND ${CMAKE_COMMAND} -Dsrc= -P "${_precheck}" + DEPENDEES update + DEPENDERS configure + COMMENT "Verifying sqlite3.c/sqlite3.h exist at (amalgamation at repo root)" +) + +# ---------- Export variables for SCIRun ---------- ExternalProject_Get_Property(SQLite_external INSTALL_DIR) set(SQLITE_INSTALL_DIR "${INSTALL_DIR}") -set(SQLITE_INCLUDE "${SQLITE_INSTALL_DIR}/include") -set(SQLITE_LIBRARY_DIR "${SQLITE_INSTALL_DIR}/lib") - -# Detect sqlite library name after build (sqlite vs sqlite3) with multi-config awareness -# We’ll prefer sqlite3.*, then sqlite.* -set(_sqlite_lib_names "sqlite3" "sqlite") -set(_sqlite_lib_exts) -if(WIN32) - list(APPEND _sqlite_lib_exts ".lib") -else() - list(APPEND _sqlite_lib_exts ".a" ".so" ".dylib") -endif() -# Small CMake script to resolve the name after build -set(_sqlite_check "${CMAKE_BINARY_DIR}/check_sqlite_lib_name.cmake") -file(WRITE "${_sqlite_check}" " - set(LIBDIR \"${SQLITE_LIBRARY_DIR}\") - set(names sqlite3 sqlite) - if(WIN32) - set(exts .lib) - else() - set(exts .a .so .dylib) - endif() - set(found \"\") - foreach(n IN LISTS names) - foreach(e IN LISTS exts) - file(GLOB hits \"${SQLITE_LIBRARY_DIR}/${n}*${e}\") - if(hits) - set(found \"${n}\") - break() - endif() - endforeach() - if(found) - break() - endif() - endforeach() - if(NOT found) - message(FATAL_ERROR \"SQLite lib not found in ${SQLITE_LIBRARY_DIR}. Expected sqlite3 or sqlite.\") - endif() - # Persist the detected base name - set(SQLITE_LIBRARY \"${found}\" CACHE STRING \"SQLite library base name (sqlite vs sqlite3)\" FORCE) - message(STATUS \"[SQLite_external] Detected library basename: ${found}\") -") +# Cache the exported vars so SCIRun configure sees stable values +set(SQLITE_SOURCE_DIR "${_sqlite_src}" CACHE PATH "SQLite source dir (clone)" FORCE) +set(SQLITE_INSTALL_DIR "${SQLITE_INSTALL_DIR}" CACHE PATH "SQLite install dir" FORCE) +set(SQLite_INCLUDE_DIR "${SQLITE_INSTALL_DIR}/include" CACHE PATH "SQLite include dir" FORCE) +set(SQLite_LIBRARY_DIR "${SQLITE_INSTALL_DIR}/lib" CACHE PATH "SQLite library dir" FORCE) -ExternalProject_Add_Step(SQLite_external verify_lib_name - COMMAND ${CMAKE_COMMAND} -P "${_sqlite_check}" - DEPENDEES build - COMMENT "Verifying SQLite library name and caching SQLITE_LIBRARY" -) - -# Export variables for SCIRun -set(SQLITE_SOURCE_DIR ${_sqlite_src}) -set(SQLITE_INSTALL_DIR ${_sqlite_inst}) -set(SQLITE_INCLUDE ${SQLITE_INSTALL_DIR}/include) -set(SQLITE_LIBRARY_DIR ${SQLITE_INSTALL_DIR}/lib) +# Basename built by wrapper +if(NOT DEFINED SQLITE_LIBRARY) + set(SQLITE_LIBRARY "sqlite3" CACHE STRING "SQLite library base name (sqlite vs sqlite3)" FORCE) +endif() -message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") \ No newline at end of file +message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") +message(STATUS "[SQLite_external] Include dir=${SQLite_INCLUDE_DIR}") +message(STATUS "[SQLite_external] Lib dir=${SQLite_LIBRARY_DIR}") +message(STATUS "[SQLite_external] Library base=${SQLITE_LIBRARY}") \ No newline at end of file diff --git a/Superbuild/SQLiteInstall.cmake b/Superbuild/SQLiteInstall.cmake deleted file mode 100644 index 637e542a48..0000000000 --- a/Superbuild/SQLiteInstall.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# SQLiteInstall.cmake -# Usage: -# cmake -Dsrc= -Ddst= -P SQLiteInstall.cmake -# -# Copies SQLite public headers into the install include directory in a robust way. -# - Supports both amalgamation layout (headers in repo root) and CMake "include/" layout. -# - Fails fast if sqlite3.h cannot be found in any expected location. - -cmake_minimum_required(VERSION 3.15) - -if(NOT DEFINED src OR NOT DEFINED dst) - message(FATAL_ERROR "SQLiteInstall.cmake requires -Dsrc and -Ddst (got src='${src}', dst='${dst}')") -endif() - -# Normalize paths -file(TO_CMAKE_PATH "${src}" _SRC) -file(TO_CMAKE_PATH "${dst}" _DST) - -# Create destination include dir -file(MAKE_DIRECTORY "${_DST}") - -# Candidate locations to probe for public headers -# 1) Amalgamation in project root: /sqlite3.h, sqlite3ext.h -# 2) CMake-style include directory: /include/sqlite3.h -# 3) Rare alternative layouts: /inc/sqlite3.h -set(_CANDIDATES - "${_SRC}" - "${_SRC}/include" - "${_SRC}/inc" -) - -# Find a candidate that actually contains sqlite3.h -set(_FOUND_SOURCE "") -foreach(_C IN LISTS _CANDIDATES) - if(EXISTS "${_C}/sqlite3.h") - set(_FOUND_SOURCE "${_C}") - break() - endif() -endforeach() - -if(NOT _FOUND_SOURCE) - # Print helpful diagnostics - message(STATUS "[SQLiteInstall.cmake] Probed candidates:") - foreach(_C IN LISTS _CANDIDATES) - message(STATUS " - ${_C}") - endforeach() - message(FATAL_ERROR "Could not find 'sqlite3.h' under any candidate. " - "Searched in: ${_CANDIDATES}") -endif() - -message(STATUS "[SQLiteInstall.cmake] Using header source dir: ${_FOUND_SOURCE}") -message(STATUS "[SQLiteInstall.cmake] Destination include dir: ${_DST}") - -# Copy sqlite3.h (required) -file(COPY "${_FOUND_SOURCE}/sqlite3.h" DESTINATION "${_DST}") - -# Copy sqlite3ext.h if present (optional extension API) -if(EXISTS "${_FOUND_SOURCE}/sqlite3ext.h") - file(COPY "${_FOUND_SOURCE}/sqlite3ext.h" DESTINATION "${_DST}") -else() - message(STATUS "[SQLiteInstall.cmake] Optional header not found: ${_FOUND_SOURCE}/sqlite3ext.h") -endif() - -# Verify copy succeeded -if(NOT EXISTS "${_DST}/sqlite3.h") - message(FATAL_ERROR "Copy failed: '${_DST}/sqlite3.h' not found after copy.") -endif() - -message(STATUS "[SQLiteInstall.cmake] Copied headers into: ${_DST}") \ No newline at end of file From 8ac87b71380badbbba1b06b7ec0be57004f2c9b3 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 10 Feb 2026 12:31:16 -0700 Subject: [PATCH 033/140] python --- Superbuild/SQLiteExternal.cmake | 10 +- Superbuild/Superbuild.cmake | 42 ++++- Superbuild/TeemExternal.cmake | 34 ++-- src/CMakeLists.txt | 10 +- src/Core/Python/CMakeLists.txt | 193 +++++++++++++++++--- src/Dataflow/Engine/Python/CMakeLists.txt | 140 ++++++++++++-- src/Interface/Modules/Python/CMakeLists.txt | 52 ++++-- src/Modules/Python/CMakeLists.txt | 123 +++++++++++-- 8 files changed, 491 insertions(+), 113 deletions(-) diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index 5d80be2e33..8c031f98df 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -51,6 +51,9 @@ file(MAKE_DIRECTORY "${_wrapper_dir}") file(WRITE "${_wrapper_dir}/CMakeLists.txt" " cmake_minimum_required(VERSION 3.15) +# Force VS to use $(Configuration) instead of +set(CMAKE_CFG_INTDIR \"$(Configuration)\" CACHE STRING \"VS config placeholder\" FORCE) + project(SQLiteExternal C) if(NOT SQLite_SOURCE_DIR) @@ -116,6 +119,7 @@ set(_cfg_args -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE:PATH=/lib -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG:PATH=/bin -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE:PATH=/bin + -DCMAKE_CFG_INTDIR:STRING=$(Configuration) ) if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cfg_args -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) @@ -149,10 +153,10 @@ ExternalProject_Add(SQLite_external ${CMAKE_COMMAND} -S "${_wrapper_dir}" -B "/wrap" ${_cfg_args} BUILD_COMMAND - ${CMAKE_COMMAND} --build "/wrap" --config + ${CMAKE_COMMAND} --build "/wrap" --config Release INSTALL_COMMAND - ${CMAKE_COMMAND} --build "/wrap" --target install --config + ${CMAKE_COMMAND} --build "/wrap" --target install --config Release ${_gen_fwd} @@ -164,7 +168,7 @@ ExternalProject_Add(SQLite_external # Pre-configure step: verify amalgamation exists at repo root ExternalProject_Add_Step(SQLite_external verify_amalgamation COMMAND ${CMAKE_COMMAND} -Dsrc= -P "${_precheck}" - DEPENDEES update + DEPENDEES download DEPENDERS configure COMMENT "Verifying sqlite3.c/sqlite3.h exist at (amalgamation at repo root)" ) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index b424dd7db9..116fe1f206 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -207,6 +207,31 @@ macro(ADD_EXTERNAL cmake_file external) list(APPEND SCIRUN_DEPENDENCIES ${external}) endmacro() +# ========================= +# Python (superbuild-level detection) +# ========================= +if(BUILD_WITH_PYTHON) + # Prefer modern FindPython module (Interpreter + Development) + find_package(Python COMPONENTS Interpreter Development REQUIRED) + + message(STATUS "[superbuild] Python executable: ${Python_EXECUTABLE}") + message(STATUS "[superbuild] Python includes : ${Python_INCLUDE_DIRS}") + message(STATUS "[superbuild] Python libraries : ${Python_LIBRARIES}") + message(STATUS "[superbuild] Python version : ${Python_VERSION}") + + # Optionally bias CMake to not scan the Windows registry for a different Python + # set(Python_FIND_REGISTRY NEVER) + + # If you want the inner configure to also see this location via CMAKE_PREFIX_PATH + # (not required, but harmless), you can append Python's root to prefixes: + # Try to infer a plausible root from exec/include path: + get_filename_component(_py_exec_dir "${Python_EXECUTABLE}" DIRECTORY) + get_filename_component(_py_root "${_py_exec_dir}" DIRECTORY) + if(EXISTS "${_py_root}") + sb_prefix_append("${_py_root}") + endif() +endif() + set(SUPERBUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE) set(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE) set(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) @@ -465,8 +490,21 @@ set(SCIRUN_CACHE_ARGS "-DQt_PATH:PATH=${Qt_PATH}" ) -if(BUILD_WITH_PYTHON AND SCI_PYTHON_EXE) - list(APPEND SCIRUN_CACHE_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}") +# ========================= +# Forward Python values to SCIRun (inner CMake) +# ========================= +if(BUILD_WITH_PYTHON) + # New (modern) variables for FindPython in SCIRun subdirs + list(APPEND SCIRUN_CACHE_ARGS + "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" + "-DPython_EXECUTABLE:FILEPATH=${Python_EXECUTABLE}" + "-DPython_INCLUDE_DIRS:PATH=${Python_INCLUDE_DIRS}" + "-DPython_LIBRARIES:STRING=${Python_LIBRARIES}" + # Mirror for FindPython3 in case inner scripts resolve to that module name + "-DPython3_EXECUTABLE:FILEPATH=${Python_EXECUTABLE}" + "-DPython3_INCLUDE_DIRS:PATH=${Python_INCLUDE_DIRS}" + "-DPython3_LIBRARIES:STRING=${Python_LIBRARIES}" + ) endif() if(WIN32) diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index 1b8fdf1156..d6382867b4 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -25,7 +25,7 @@ # DEALINGS IN THE SOFTWARE. -# TeemExternal.cmake — wire Teem to the installed zlib +# TeemExternal.cmake — wire Teem to the installed zlib set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") @@ -37,7 +37,7 @@ set(_teem_src "${CMAKE_BINARY_DIR}/Externals/Source/Teem_external") set(_teem_bin "${CMAKE_BINARY_DIR}/Externals/Build/Teem_external") set(_teem_inst "${CMAKE_BINARY_DIR}/Externals/Install/Teem_external") -# Teem CMake args (no output redirection needed) +# Teem CMake args set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON @@ -47,13 +47,13 @@ set(_cmake_args -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR} -DZLIB_ROOT=${ZLIB_INSTALL_DIR} -DZLIB_INCLUDE_DIR=${ZLIB_INSTALL_DIR}/include + -DZLIB_USE_STATIC_LIBS=ON - # Start minimal: disable optional deps until zlib link works - # (Uncomment if these options exist in your Teem tree) - -DTeem_ZLIB=ON - -DTeem_PNG=OFF - -DTeem_BZIP2=OFF - -DTeem_FFTW=OFF + # Keep optional deps minimal for now + -DTeem_ZLIB=ON + -DTeem_PNG=OFF + -DTeem_BZIP2=OFF + -DTeem_FFTW=OFF ) if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) @@ -69,6 +69,7 @@ ExternalProject_Add(Teem_external SOURCE_DIR ${_teem_src} BINARY_DIR ${_teem_bin} + INSTALL_DIR ${_teem_inst} # ensure install goes to Externals/Install/Teem_external CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" @@ -77,34 +78,27 @@ ExternalProject_Add(Teem_external CMAKE_ARGS ${_cmake_args} - # Use CMAKE_CACHE_ARGS so Teem's *own* cache sees the hints CMAKE_CACHE_ARGS -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH= -DZlib_DIR:PATH=${Zlib_DIR} - -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include - -DZLIB_USE_STATIC_LIBS:BOOL=ON # optional + -DZLIB_USE_STATIC_LIBS:BOOL=ON - # If Teem exposes switches, keep them minimal while bringing up: -DTeem_ZLIB:BOOL=ON -DTeem_PNG:BOOL=OFF -DTeem_BZIP2:BOOL=OFF -DTeem_FFTW:BOOL=OFF - DEPENDS Zlib_external - INSTALL_COMMAND "" - LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Make Teem's configure wait for zlib artifacts to exist ExternalProject_Add_Step(Teem_external wait_for_zlib COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts..." DEPENDEES download @@ -118,9 +112,9 @@ ExternalProject_Add_Step(Teem_external wait_for_zlib set(TEEM_SOURCE_DIR ${_teem_src}) set(TEEM_INSTALL_DIR ${_teem_inst}) -# If you keep Teem in no-install mode for now, public headers remain in source: -set(TEEM_INCLUDE ${TEEM_SOURCE_DIR}/src) -set(TEEM_LIBRARY_DIR ${TEEM_INSTALL_DIR}/lib) # will populate when/if you enable install +# After enabling install, point includes to the installed headers +set(TEEM_INCLUDE ${TEEM_INSTALL_DIR}/include) +set(TEEM_LIBRARY_DIR ${TEEM_INSTALL_DIR}/lib) set(TEEM_LIBRARY "teem") message(STATUS "[Teem_external] INSTALL_DIR=${TEEM_INSTALL_DIR}") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e0e868dd8e..d123af9176 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -631,14 +631,6 @@ CONFIG_STANDARD_EXTERNAL(Cleaver2 CFG "Cleaver2Config.cmake" ) -# Python -if(BUILD_WITH_PYTHON) - CONFIG_STANDARD_EXTERNAL(Python - DIR "${Python_DIR}" - CFGS "PythonConfig.cmake;Python3Config.cmake" - ) -endif() - # Boost — REQUIRED on non-Windows (prefer config package). # On Windows with b2-built Boost, skip CONFIG mode: rely on auto-link + link_directories above. if(WIN32) @@ -1030,7 +1022,7 @@ set(_SCIRUN_INCLUDE_DIRS ${SCIRun_SOURCE_DIR}/Externals/ ${SCIRun_BINARY_DIR}/ ${SCIRun_BINARY_DIR}/include - ${SCI_TEEM_INCLUDE} + ${SCI_TEEM_INCLUDE}/include ${SCI_ZLIB_INCLUDE} ${SCI_QWT_INCLUDE} ${SCI_CLEAVER2_INCLUDE} diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 602f1e9b8f..de0c928114 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -26,49 +26,190 @@ # -SET(Core_Python_SRCS +# --- Sources --- +set(Core_Python_SRCS PythonInterpreter.cc PythonDatatypeConverter.cc ) -SET(Core_Python_HEADERS +set(Core_Python_HEADERS PythonInterpreter.h PythonDatatypeConverter.h share.h ) +# --- Library target (uses project macro from top-level) --- SCIRUN_ADD_LIBRARY(Core_Python ${Core_Python_HEADERS} ${Core_Python_SRCS} ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Python) -ENDIF(BUILD_SHARED_LIBS) +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Core_Python) +endif() +# --- Unit tests subdir (kept as in your original) --- SCIRUN_ADD_TEST_DIR(Tests) -IF(WIN32) - ADD_DEFINITIONS(-DPYTHONPATH=L"${SCI_PYTHON_MODULE_PARENT_PATH}" - -DPYTHONNAME=L"${SCI_PYTHON_NAME}") -ELSEIF(APPLE) - ADD_DEFINITIONS(-DPYTHONPATH=L"${PYTHON_MODULE_SEARCH_PATH}" - -DPYTHONLIBDIR=L"${SCI_PYTHON_LIBRARY_DIR}" - -DPYTHONLIB=L"${SCI_PYTHON_LIBRARY}") -ELSE() - ADD_DEFINITIONS(-DPYTHONPATH=L"${PYTHON_MODULE_SEARCH_PATH}") -ENDIF() - -TARGET_LINK_LIBRARIES(Core_Python - ${SCI_PYTHON_LIBRARY} - ${SCI_BOOST_LIBRARY} - SCIRunPythonAPI - Core_Matlab - Core_Datatypes - Core_Datatypes_Legacy_Field +# ==================================================================================== +# Cross-platform Python detection (modern-first, legacy fallback for older CMake) +# ==================================================================================== + +# We’ll try in this order: +# 1) FindPython (CMake >= ~3.15) +# 2) FindPython3 (CMake >= ~3.12) +# 3) Legacy FindPythonInterp + FindPythonLibs (CMake >= 3.0) +# +# The result will be: +# - Imported target to link: Python::Python +# - Variables available: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES +# +set(_SCIRUN_PY_OK FALSE) + +# Prefer FindPython (generic) +find_package(Python QUIET COMPONENTS Interpreter Development) +if(Python_Interpreter_FOUND AND Python_Development_FOUND) + set(_SCIRUN_PY_OK TRUE) +elseif(NOT _SCIRUN_PY_OK) + # Try Python3 module + find_package(Python3 QUIET COMPONENTS Interpreter Development) + if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) + # Normalize variable names to Python_* so later logic is uniform + set(Python_EXECUTABLE "${Python3_EXECUTABLE}") + set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") + set(Python_LIBRARIES "${Python3_LIBRARIES}") + # Create a consistent alias so we can always link Python::Python + if(TARGET Python3::Python AND NOT TARGET Python::Python) + add_library(Python::Python ALIAS Python3::Python) + endif() + set(_SCIRUN_PY_OK TRUE) + endif() +endif() + +# Legacy fallback (older CMake or no module found) +if(NOT _SCIRUN_PY_OK) + find_package(PythonInterp REQUIRED) + find_package(PythonLibs REQUIRED) # populates PYTHON_INCLUDE_DIRS / PYTHON_LIBRARIES in old module + # Normalize variable names + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") + set(Python_LIBRARIES "${PYTHON_LIBRARIES}") + # Provide a compatible imported target Python::Python + if(NOT TARGET Python::Python) + add_library(Python::Python UNKNOWN IMPORTED) + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" + ) + if(WIN32) + # On Windows, the link library is an import library (.lib) + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB "${Python_LIBRARIES}" + ) + else() + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION "${Python_LIBRARIES}" + ) + endif() + endif() + set(_SCIRUN_PY_OK TRUE) +endif() + +if(NOT _SCIRUN_PY_OK) + message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build Core_Python.") +endif() + +# ==================================================================================== +# Platform-specific compile definitions derived from the detected Python +# ==================================================================================== + +# Compute a best-effort Python module search path (a parent of site-packages) +# Ask Python directly (portable across platforms/envs). +set(_SCIRUN_PY_QUERY + "import sys,sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" +) +execute_process( + COMMAND "${Python_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" + OUTPUT_VARIABLE _PY_SITE + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE ) +# Parent of site-packages (keeps your original semantics) +set(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}") +if(_PYTHON_MODULE_SEARCH_PARENT) + get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) +endif() -SET_TARGET_PROPERTIES(Core_Python - PROPERTIES - COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON" +# Compute a name like pythonXY (e.g., python311) if your code needs it +set(_SCIRUN_PY_NAME_QUERY "import sys; print('python{}{}'.format(sys.version_info.major, sys.version_info.minor))") +execute_process( + COMMAND "${Python_EXECUTABLE}" -c "${_SCIRUN_PY_NAME_QUERY}" + OUTPUT_VARIABLE _PYTHON_NAME + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE ) + +# For macOS legacy defines that your code used: +set(_PYTHON_LIB "") +if(Python_LIBRARIES) + # If multiple libs are reported, take the first + if(Python_LIBRARIES MATCHES ";") + list(GET Python_LIBRARIES 0 _PYTHON_LIB) + else() + set(_PYTHON_LIB "${Python_LIBRARIES}") + endif() +endif() +get_filename_component(_PYTHON_LIBDIR "${_PYTHON_LIB}" DIRECTORY) + +# Apply your original platform-specific -D defines, but using the computed values +if(WIN32) + # Original: -DPYTHONPATH=L"${SCI_PYTHON_MODULE_PARENT_PATH}" -DPYTHONNAME=L"${SCI_PYTHON_NAME}" + add_definitions( + -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" + -DPYTHONNAME=L"${_PYTHON_NAME}" + ) +elseif(APPLE) + # Original: also defined PYTHONLIBDIR and PYTHONLIB on macOS + add_definitions( + -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" + -DPYTHONLIBDIR=L"${_PYTHON_LIBDIR}" + -DPYTHONLIB=L"${_PYTHON_LIB}" + ) +else() + # Linux/Unix: only PYTHONPATH originally + add_definitions( + -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" + ) +endif() + +# ==================================================================================== +# Link dependencies +# ==================================================================================== + +# Note: +# - Python::Python carries include dirs and platform-correct libs +# - Keep your other links intact +target_link_libraries(Core_Python + PRIVATE + Python::Python + ${SCI_BOOST_LIBRARY} + SCIRunPythonAPI + Core_Matlab + Core_Datatypes + Core_Datatypes_Legacy_Field +) + +# Optional: a little debug output so you can verify in configure logs +message(STATUS "[Core/Python] Using Python executable: ${Python_EXECUTABLE}") +message(STATUS "[Core/Python] Using Python include(s): ${Python_INCLUDE_DIRS}") +message(STATUS "[Core/Python] Using Python library : ${Python_LIBRARIES}") +message(STATUS "[Core/Python] PYTHONPATH define : ${_PYTHON_MODULE_SEARCH_PARENT}") +if(APPLE) + message(STATUS "[Core/Python] macOS PYTHONLIBDIR : ${_PYTHON_LIBDIR}") + message(STATUS "[Core/Python] macOS PYTHONLIB : ${_PYTHON_LIB}") +endif() + +# Keep your existing debug-only definition (unchanged) +set_target_properties(Core_Python + PROPERTIES + COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON" +) \ No newline at end of file diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index acb3abf83e..0bb5f73f01 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -26,43 +26,143 @@ # -SET(SCIRunPythonAPI_SRCS +# ========================================== +# Dataflow/Engine/Python CMakeLists.txt +# ========================================== + +# Optional: if you want to skip this target when Python support is OFF. +# Comment this block out if you prefer to always configure it. +if(NOT BUILD_WITH_PYTHON) + message(STATUS "[Dataflow/Engine/Python] Skipping SCIRunPythonAPI (BUILD_WITH_PYTHON=OFF)") + return() +endif() + +# --- Sources & headers --- +set(SCIRunPythonAPI_SRCS NetworkEditorPythonAPI.cc ) -SET(SCIRunPythonAPI_HEADERS +set(SCIRunPythonAPI_HEADERS NetworkEditorPythonAPI.h NetworkEditorPythonInterface.h SCIRunPythonModule.h share.h ) +# --- Library target --- SCIRUN_ADD_LIBRARY(SCIRunPythonAPI ${SCIRunPythonAPI_HEADERS} ${SCIRunPythonAPI_SRCS} ) -TARGET_LINK_LIBRARIES(SCIRunPythonAPI - Core_Thread - Core_Datatypes_Legacy_Base - Core_Persistent - ${SCI_PYTHON_LIBRARY} - ${SCI_BOOST_LIBRARY} +# ==================================================================================== +# Cross-platform Python detection +# Prefer modern FindPython / FindPython3; fall back to legacy modules if needed. +# Result: +# - Imported target to link: Python::Python +# - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES +# ==================================================================================== + +set(_SCIRUN_API_PY_OK FALSE) + +# 1) Prefer the generic FindPython (Interpreter + Development) +find_package(Python QUIET COMPONENTS Interpreter Development) +if(Python_Interpreter_FOUND AND Python_Development_FOUND) + set(_SCIRUN_API_PY_OK TRUE) +elseif(NOT _SCIRUN_API_PY_OK) + # 2) Try Python3 module + find_package(Python3 QUIET COMPONENTS Interpreter Development) + if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) + # Normalize into Python_* variable names for consistency + set(Python_EXECUTABLE "${Python3_EXECUTABLE}") + set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") + set(Python_LIBRARIES "${Python3_LIBRARIES}") + # Alias target so we can always link Python::Python + if(TARGET Python3::Python AND NOT TARGET Python::Python) + add_library(Python::Python ALIAS Python3::Python) + endif() + set(_SCIRUN_API_PY_OK TRUE) + endif() +endif() + +# 3) Legacy fallback path (older CMake or environments without the newer modules) +if(NOT _SCIRUN_API_PY_OK) + find_package(PythonInterp REQUIRED) + find_package(PythonLibs REQUIRED) + # Normalize var names + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") + set(Python_LIBRARIES "${PYTHON_LIBRARIES}") + + # Provide a compatible imported target so target_link_libraries can always use Python::Python + if(NOT TARGET Python::Python) + add_library(Python::Python UNKNOWN IMPORTED) + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" + ) + if(WIN32) + # On MSVC, the import library (.lib) is what we link against + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB "${Python_LIBRARIES}" + ) + else() + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION "${Python_LIBRARIES}" + ) + endif() + endif() + + set(_SCIRUN_API_PY_OK TRUE) +endif() + +if(NOT _SCIRUN_API_PY_OK) + message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build SCIRunPythonAPI.") +endif() + +# ==================================================================================== +# Link dependencies +# ==================================================================================== + +# Replace legacy ${SCI_PYTHON_LIBRARY} with imported target Python::Python. +# This pulls the include dir for Python.h and the correct platform library. +target_link_libraries(SCIRunPythonAPI + PRIVATE + Core_Thread + Core_Datatypes_Legacy_Base + Core_Persistent + Python::Python + ${SCI_BOOST_LIBRARY} ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_SCIRunPythonAPI) +# ==================================================================================== +# Shared build definitions & Windows .pyd properties (kept from your original) +# ==================================================================================== -IF(WIN32) - SET_TARGET_PROPERTIES(SCIRunPythonAPI - PROPERTIES - IMPORT_SUFFIX ".pyd" - IMPORT_PREFIX "" - PREFIX "" - SUFFIX ".pyd" - ) -ENDIF() +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_SCIRunPythonAPI) -ENDIF(BUILD_SHARED_LIBS) + if(WIN32) + # Build as a Python extension on Windows: .pyd suffix/prefixes + set_target_properties(SCIRunPythonAPI + PROPERTIES + IMPORT_SUFFIX ".pyd" + IMPORT_PREFIX "" + PREFIX "" + SUFFIX ".pyd" + ) + endif() +endif() + +# ==================================================================================== +# Tests +# ==================================================================================== SCIRUN_ADD_TEST_DIR(Tests) + +# ==================================================================================== +# Diagnostics (optional but helpful) +# ==================================================================================== + +message(STATUS "[SCIRunPythonAPI] Python executable : ${Python_EXECUTABLE}") +message(STATUS "[SCIRunPythonAPI] Python include(s) : ${Python_INCLUDE_DIRS}") +message(STATUS "[SCIRunPythonAPI] Python libraries : ${Python_LIBRARIES}") diff --git a/src/Interface/Modules/Python/CMakeLists.txt b/src/Interface/Modules/Python/CMakeLists.txt index c1d1689a34..cf0810d1d0 100644 --- a/src/Interface/Modules/Python/CMakeLists.txt +++ b/src/Interface/Modules/Python/CMakeLists.txt @@ -26,7 +26,17 @@ # -SET(Interface_Modules_Python_FORMS +# ========================================== +# Interface/Modules/Python CMakeLists.txt +# ========================================== + +# Only build this UI module when Python support is enabled +if(NOT BUILD_WITH_PYTHON) + message(STATUS "[Interface/Modules/Python] Skipping (BUILD_WITH_PYTHON=OFF)") + return() +endif() + +set(Interface_Modules_Python_FORMS PythonObjectForwarder.ui InterfaceWithPython.ui ModuleStateModifierTester.ui @@ -36,7 +46,7 @@ SET(Interface_Modules_Python_FORMS CompositeModule.ui ) -SET(Interface_Modules_Python_HEADERS +set(Interface_Modules_Python_HEADERS PythonObjectForwarderDialog.h InterfaceWithPythonDialog.h ModuleStateModifierTesterDialog.h @@ -47,7 +57,7 @@ SET(Interface_Modules_Python_HEADERS share.h ) -SET(Interface_Modules_Python_SOURCES +set(Interface_Modules_Python_SOURCES PythonObjectForwarderDialog.cc InterfaceWithPythonDialog.cc ModuleStateModifierTesterDialog.cc @@ -57,9 +67,13 @@ SET(Interface_Modules_Python_SOURCES CompositeModuleDialog.cc ) +# ---- Qt UI/MOC generation ---- +# Top-level already sets SCIRUN_QT_MAJOR and finds Qt5/Qt6 + defines +# helper macros QT_WRAP_UI / QT_WRAP_CPP accordingly. QT_WRAP_UI(Interface_Modules_Python_FORMS_HEADERS "${Interface_Modules_Python_FORMS}") -QT_WRAP_CPP(Interface_Modules_Python_HEADERS_MOC "${Interface_Modules_Python_HEADERS}") +QT_WRAP_CPP(Interface_Modules_Python_HEADERS_MOC "${Interface_Modules_Python_HEADERS}") +# ---- Library target ---- SCIRUN_ADD_LIBRARY(Interface_Modules_Python ${Interface_Modules_Python_HEADERS} ${Interface_Modules_Python_FORMS_HEADERS} @@ -67,16 +81,24 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Python ${Interface_Modules_Python_SOURCES} ) -TARGET_LINK_LIBRARIES(Interface_Modules_Python - Modules_Python - Modules_Basic - Interface_Modules_Base - ${SCI_BOOST_LIBRARY} - ${QT_LIBRARIES} -) +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Interface_Modules_Python) +endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Interface_Modules_Python) -ENDIF(BUILD_SHARED_LIBS) +# ---- Include current binary dir for generated moc/ui headers ---- +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# ---- Link dependencies ---- +# No direct Python headers here; Python is pulled in by Modules_Python. +# Qt variables are set by the top-level (Qt5 or Qt6). +target_link_libraries(Interface_Modules_Python + PRIVATE + Modules_Python + Modules_Basic + Interface_Modules_Base + ${SCI_BOOST_LIBRARY} + ${QT_LIBRARIES} +) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +# Optional: nice status line during configure +message(STATUS "[Interface/Modules/Python] Configured (Qt ${QT_VERSION_MAJOR}, BUILD_WITH_PYTHON=ON)") diff --git a/src/Modules/Python/CMakeLists.txt b/src/Modules/Python/CMakeLists.txt index 4153d09f3c..c0bcd89ab5 100644 --- a/src/Modules/Python/CMakeLists.txt +++ b/src/Modules/Python/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -26,7 +26,12 @@ # -SET(Modules_Python_SRCS +# ========================= +# Modules/Python CMake file +# ========================= + +# --- Sources & headers --- +set(Modules_Python_SRCS PythonObjectForwarder.cc InterfaceWithPython.cc PythonInterfaceParser.cc @@ -36,7 +41,7 @@ SET(Modules_Python_SRCS #LoopIncrement.cc ) -SET(Modules_Python_HEADERS +set(Modules_Python_HEADERS PythonObjectForwarder.h InterfaceWithPython.h PythonInterfaceParser.h @@ -47,28 +52,110 @@ SET(Modules_Python_HEADERS share.h ) +# --- Library target --- SCIRUN_ADD_LIBRARY(Modules_Python ${Modules_Python_HEADERS} ${Modules_Python_SRCS} ) -TARGET_LINK_LIBRARIES(Modules_Python - Dataflow_Network - Core_Datatypes - Algorithms_Base - Core_Thread +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Modules_Python) +endif() + +# ==================================================================================== +# Optional Python detection (only if the build is configured with Python support) +# ==================================================================================== + +set(_SCIRUN_MODULES_PY_OK FALSE) +if(BUILD_WITH_PYTHON) + # 1) Prefer modern FindPython (generic) + find_package(Python QUIET COMPONENTS Interpreter Development) + if(Python_Interpreter_FOUND AND Python_Development_FOUND) + set(_SCIRUN_MODULES_PY_OK TRUE) + elseif(NOT _SCIRUN_MODULES_PY_OK) + # 2) Try Python3 module + find_package(Python3 QUIET COMPONENTS Interpreter Development) + if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) + # Normalize to Python_* names so logic below is uniform + set(Python_EXECUTABLE "${Python3_EXECUTABLE}") + set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") + set(Python_LIBRARIES "${Python3_LIBRARIES}") + # Alias Python3::Python → Python::Python for consistent linking + if(TARGET Python3::Python AND NOT TARGET Python::Python) + add_library(Python::Python ALIAS Python3::Python) + endif() + set(_SCIRUN_MODULES_PY_OK TRUE) + endif() + endif() + + # 3) Legacy fallback (older CMake or missing modules) + if(NOT _SCIRUN_MODULES_PY_OK) + find_package(PythonInterp REQUIRED) + find_package(PythonLibs REQUIRED) + # Normalize legacy vars + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") + set(Python_LIBRARIES "${PYTHON_LIBRARIES}") + # Provide an imported target for consistency + if(NOT TARGET Python::Python) + add_library(Python::Python UNKNOWN IMPORTED) + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" + ) + if(WIN32) + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB "${Python_LIBRARIES}" + ) + else() + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION "${Python_LIBRARIES}" + ) + endif() + endif() + set(_SCIRUN_MODULES_PY_OK TRUE) + endif() + + if(NOT _SCIRUN_MODULES_PY_OK) + message(FATAL_ERROR "BUILD_WITH_PYTHON is ON, but Python (Interpreter + Development) could not be found.") + endif() +endif() # BUILD_WITH_PYTHON + +# ==================================================================================== +# Link dependencies +# ==================================================================================== + +# Always link these: +target_link_libraries(Modules_Python + PRIVATE + Dataflow_Network + Core_Datatypes + Algorithms_Base + Core_Thread ) -IF(BUILD_WITH_PYTHON) - TARGET_LINK_LIBRARIES(Modules_Python - Core_Python - ) -ENDIF() +# Only link Python-related libs when enabled: +if(BUILD_WITH_PYTHON) + # Link the Python runtime and your Core_Python layer + target_link_libraries(Modules_Python + PRIVATE + Python::Python + Core_Python + ) +endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Modules_Python) -ENDIF(BUILD_SHARED_LIBS) +# ==================================================================================== +# Tests (kept as in your original) +# ==================================================================================== -IF(BUILD_WITH_PYTHON) +if(BUILD_WITH_PYTHON) SCIRUN_ADD_TEST_DIR(Tests) -ENDIF() +endif() + +# ==================================================================================== +# Diagnostics (helpful while bringing up the superbuild) +# ==================================================================================== +if(BUILD_WITH_PYTHON) + message(STATUS "[Modules/Python] Python executable : ${Python_EXECUTABLE}") + message(STATUS "[Modules/Python] Python include(s) : ${Python_INCLUDE_DIRS}") + message(STATUS "[Modules/Python] Python libraries : ${Python_LIBRARIES}") +endif() \ No newline at end of file From f39520011f0db02c4587f83fde6b07d3eefbcbdd Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 10 Feb 2026 15:01:02 -0700 Subject: [PATCH 034/140] python issues --- src/CMakeLists.txt | 9 ++++++++- src/Core/Python/CMakeLists.txt | 1 - src/Dataflow/Engine/Python/CMakeLists.txt | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d123af9176..92a4b99762 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -916,6 +916,12 @@ endif() if(DEFINED Tny_INCLUDE_DIR AND NOT DEFINED TNY_INCLUDE_DIR) set(TNY_INCLUDE_DIR "${Tny_INCLUDE_DIR}") endif() +if(DEFINED Teem_INCLUDE_DIR AND NOT DEFINED SCI_TEEM_INCLUDE) + set(SCI_TEEM_INCLUDE "${Teem_INCLUDE_DIR}") +endif() +if(DEFINED TEEM_INCLUDE AND NOT DEFINED SCI_TEEM_INCLUDE) + set(SCI_TEEM_INCLUDE "${TEEM_INCLUDE}") +endif() # Helper: validate a cached include dir (VAR) by checking it contains REL_HEADER. # If empty or incorrect, auto-derive from CMAKE_PREFIX_PATH and cache the fix. @@ -977,6 +983,7 @@ _ensure_header(SQLite3_INCLUDE_DIR "sqlite3.h") _ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") _ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") _ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") +_ensure_header(SCI_TEEM_INCLUDE "teem/ten.h") # Print diagnostics message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") @@ -1022,7 +1029,7 @@ set(_SCIRUN_INCLUDE_DIRS ${SCIRun_SOURCE_DIR}/Externals/ ${SCIRun_BINARY_DIR}/ ${SCIRun_BINARY_DIR}/include - ${SCI_TEEM_INCLUDE}/include + ${SCI_TEEM_INCLUDE} ${SCI_ZLIB_INCLUDE} ${SCI_QWT_INCLUDE} ${SCI_CLEAVER2_INCLUDE} diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index de0c928114..b30fd935ff 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -192,7 +192,6 @@ target_link_libraries(Core_Python PRIVATE Python::Python ${SCI_BOOST_LIBRARY} - SCIRunPythonAPI Core_Matlab Core_Datatypes Core_Datatypes_Legacy_Field diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index 0bb5f73f01..48830c6e75 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -130,6 +130,7 @@ target_link_libraries(SCIRunPythonAPI Core_Thread Core_Datatypes_Legacy_Base Core_Persistent + Core_Python Python::Python ${SCI_BOOST_LIBRARY} ) From 6d914fae9c0cd2041bfa02e43df3e520f50e7fd7 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 10 Feb 2026 17:07:34 -0700 Subject: [PATCH 035/140] link error --- Superbuild/Superbuild.cmake | 86 ++++++++++ src/Core/DatabaseManager/CMakeLists.txt | 99 ++++++++++-- src/Core/GeometryPrimitives/CMakeLists.txt | 174 +++++++++++++++++++-- 3 files changed, 337 insertions(+), 22 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 116fe1f206..6755009e68 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -561,6 +561,92 @@ if(DEFINED SQLite_INCLUDE_DIR) set(SQLite3_INCLUDE_DIR "${SQLite_INCLUDE_DIR}" CACHE PATH "Alias: SQLite3 include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_INCLUDE_DIR:PATH=${SQLite3_INCLUDE_DIR}") endif() +# --- Ensure SQLite hints are present AFTER SCIRUN_CACHE_ARGS is created --- +if(TARGET SQLite_external) + ExternalProject_Get_Property(SQLite_external INSTALL_DIR) + # Compute lib dir (lib64 preferred when present) + if(EXISTS "${INSTALL_DIR}/lib64") + set(_sqlite_lib_dir "${INSTALL_DIR}/lib64") + else() + set(_sqlite_lib_dir "${INSTALL_DIR}/lib") + endif() + + # Always pass include + lib dir + list(APPEND SCIRUN_CACHE_ARGS + "-DSQLite_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" + "-DSQLite_LIB_DIR:PATH=${_sqlite_lib_dir}" + # Alias the include to SQLite3_* for consumers that use that name + "-DSQLite3_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" + ) + + # Optional: pass the exact library file if it exists (helps consumers) + if(WIN32) + set(_sqlite_lib "${_sqlite_lib_dir}/sqlite3.lib") + if(NOT EXISTS "${_sqlite_lib}" AND EXISTS "${_sqlite_lib_dir}/libsqlite3.lib") + set(_sqlite_lib "${_sqlite_lib_dir}/libsqlite3.lib") + endif() + elseif(APPLE) + set(_sqlite_lib "${_sqlite_lib_dir}/libsqlite3.dylib") + else() + set(_sqlite_lib "${_sqlite_lib_dir}/libsqlite3.so") + endif() + + if(EXISTS "${_sqlite_lib}") + list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_LIBRARY:FILEPATH=${_sqlite_lib}") + message(STATUS "[superbuild] SQLite library: ${_sqlite_lib}") + else() + message(STATUS "[superbuild] SQLite library: (not found yet at configure time)") + endif() + + message(STATUS "[superbuild] SQLite include: ${INSTALL_DIR}/include") + message(STATUS "[superbuild] SQLite lib dir: ${_sqlite_lib_dir}") +endif() + +# --- Ensure Teem hints are present AFTER SCIRUN_CACHE_ARGS is created --- +if(TARGET Teem_external) + ExternalProject_Get_Property(Teem_external INSTALL_DIR) + + # Compute Teem lib dir (prefer lib64 when present) + if(EXISTS "${INSTALL_DIR}/lib64") + set(_teem_lib_dir "${INSTALL_DIR}/lib64") + else() + set(_teem_lib_dir "${INSTALL_DIR}/lib") + endif() + + # Always pass include + lib dir + list(APPEND SCIRUN_CACHE_ARGS + "-DTeem_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" + "-DTeem_LIB_DIR:PATH=${_teem_lib_dir}" + ) + + # Optional: pass full library path if present (helps consumers) + if(WIN32) + set(_teem_lib "${_teem_lib_dir}/teem.lib") + if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.lib") + set(_teem_lib "${_teem_lib_dir}/libteem.lib") + endif() + elseif(APPLE) + set(_teem_lib "${_teem_lib_dir}/libteem.dylib") + if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.a") + set(_teem_lib "${_teem_lib_dir}/libteem.a") + endif() + else() + set(_teem_lib "${_teem_lib_dir}/libteem.so") + if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.a") + set(_teem_lib "${_teem_lib_dir}/libteem.a") + endif() + endif() + + if(EXISTS "${_teem_lib}") + list(APPEND SCIRUN_CACHE_ARGS "-DTeem_LIBRARY:FILEPATH=${_teem_lib}") + message(STATUS "[superbuild] Teem library: ${_teem_lib}") + else() + message(STATUS "[superbuild] Teem library: (not found yet at configure time)") + endif() + + message(STATUS "[superbuild] Teem include: ${INSTALL_DIR}/include") + message(STATUS "[superbuild] Teem lib dir: ${_teem_lib_dir}") +endif() # Compose a single CMAKE_PREFIX_PATH for SCIRun get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) diff --git a/src/Core/DatabaseManager/CMakeLists.txt b/src/Core/DatabaseManager/CMakeLists.txt index 33400d9f49..7f35048984 100644 --- a/src/Core/DatabaseManager/CMakeLists.txt +++ b/src/Core/DatabaseManager/CMakeLists.txt @@ -25,12 +25,12 @@ # DEALINGS IN THE SOFTWARE. # - -SET(Core_DatabaseManager_SRCS +# --- Sources --- +set(Core_DatabaseManager_SRCS DatabaseManager.cc ) -SET(Core_DatabaseManager_HEADERS +set(Core_DatabaseManager_HEADERS DatabaseManager.h share.h ) @@ -40,12 +40,91 @@ SCIRUN_ADD_LIBRARY(Core_DatabaseManager ${Core_DatabaseManager_SRCS} ) -TARGET_LINK_LIBRARIES(Core_DatabaseManager - ${SCI_SQLITE_LIBRARY} - ${SCI_BOOST_LIBRARY}) +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Core_DatabaseManager) +endif() + +# ========================= +# SQLite3 discovery +# ========================= +# 1) Try config package +find_package(SQLite3 CONFIG QUIET) +if(TARGET SQLite::SQLite3) + set(_sqlite_target SQLite::SQLite3) +else() + # 2) If superbuild passed an exact library file, use it + if(SQLite3_LIBRARY AND EXISTS "${SQLite3_LIBRARY}") + add_library(SQLite::SQLite3 UNKNOWN IMPORTED) + set_target_properties(SQLite::SQLite3 PROPERTIES + IMPORTED_LOCATION "${SQLite3_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}" + ) + set(_sqlite_target SQLite::SQLite3) + else() + # 3) Build from hints: include dir and lib dir + if(NOT SQLite3_INCLUDE_DIR) + message(FATAL_ERROR "SQLite3_INCLUDE_DIR not set; superbuild should pass it (path to folder with sqlite3.h).") + endif() + + # Try to locate the library: + # 3a) If SQLite_LIB_DIR is provided, compute the canonical name(s) + set(_sqlite_lib "") + if(SQLite_LIB_DIR) + if(WIN32) + foreach(_cand sqlite3.lib libsqlite3.lib) + if(EXISTS "${SQLite_LIB_DIR}/${_cand}") + set(_sqlite_lib "${SQLite_LIB_DIR}/${_cand}") + break() + endif() + endforeach() + elseif(APPLE) + if(EXISTS "${SQLite_LIB_DIR}/libsqlite3.dylib") + set(_sqlite_lib "${SQLite_LIB_DIR}/libsqlite3.dylib") + endif() + else() + if(EXISTS "${SQLite_LIB_DIR}/libsqlite3.so") + set(_sqlite_lib "${SQLite_LIB_DIR}/libsqlite3.so") + endif() + endif() + endif() + + # 3b) If still not found, fall back to find_library with hints + if(NOT _sqlite_lib) + find_library(SQLite3_LIBRARY + NAMES sqlite3 libsqlite3 + HINTS "${SQLite_LIB_DIR}" + "${CMAKE_PREFIX_PATH}" + "${CMAKE_PREFIX_PATH}/lib" + "${CMAKE_PREFIX_PATH}/lib64" + ) + if(SQLite3_LIBRARY) + set(_sqlite_lib "${SQLite3_LIBRARY}") + endif() + endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_DatabaseManager) -ENDIF(BUILD_SHARED_LIBS) + if(NOT _sqlite_lib OR NOT EXISTS "${_sqlite_lib}") + message(FATAL_ERROR + "SQLite3 library not found.\n" + " SQLite3_INCLUDE_DIR='${SQLite3_INCLUDE_DIR}'\n" + " SQLite_LIB_DIR='${SQLite_LIB_DIR}'\n" + " CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" + "Ensure the SQLite external installs a library (sqlite3.lib/.so/.dylib).") + endif() + + add_library(SQLite::SQLite3 UNKNOWN IMPORTED) + set_target_properties(SQLite::SQLite3 PROPERTIES + IMPORTED_LOCATION "${_sqlite_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}" + ) + set(_sqlite_target SQLite::SQLite3) + endif() +endif() + +target_link_libraries(Core_DatabaseManager + PRIVATE + ${_sqlite_target} + ${SCI_BOOST_LIBRARY} +) -SCIRUN_ADD_TEST_DIR(Tests) +# Tests +SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file diff --git a/src/Core/GeometryPrimitives/CMakeLists.txt b/src/Core/GeometryPrimitives/CMakeLists.txt index a627e3790b..3a1116391b 100644 --- a/src/Core/GeometryPrimitives/CMakeLists.txt +++ b/src/Core/GeometryPrimitives/CMakeLists.txt @@ -26,7 +26,12 @@ # -SET(Core_GeometryPrimitives_SRCS +# ================================ +# Core/GeometryPrimitives CMake +# ================================ + +# --- Sources & headers --- +set(Core_GeometryPrimitives_SRCS BBoxBase.cc BBox.cc OrientedBBox.cc @@ -39,7 +44,7 @@ SET(Core_GeometryPrimitives_SRCS Vector.cc ) -SET(Core_GeometryPrimitives_HEADERS +set(Core_GeometryPrimitives_HEADERS BBoxBase.h BBox.h OrientedBBox.h @@ -60,16 +65,161 @@ SCIRUN_ADD_LIBRARY(Core_Geometry_Primitives ${Core_GeometryPrimitives_SRCS} ) -TARGET_LINK_LIBRARIES(Core_Geometry_Primitives - Core_Math - Core_Util_Legacy - Core_Persistent - ${SCI_ZLIB_LIBRARY} - ${SCI_TEEM_LIBRARY} +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Core_Geometry_Primitives) +endif() + +# ========================================================== +# Teem discovery (provides tenEigensolve_f used by Tensor.cc) +# ========================================================== + +# Preferred: Teem config package if available +# (You can create/export one from the superbuild later; this handles that case automatically.) +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback: Use superbuild hints Teem_INCLUDE_DIR / Teem_LIB_DIR + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + # Try canonical filenames first by platform + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + # Fallback: search by name with hints if not found yet + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + ) + + set(_teem_target Teem::teem) +endif() + +# ============================================ +# ZLIB (needed by Teem; useful for static Teem) +# ============================================ + +# Try to use a config/module package first. +# Your superbuild already exports ZLIB_ROOT & ZLIB_DIR and sets CMAKE_PREFIX_PATH, so this should work. +find_package(ZLIB QUIET) + +# If ZLIB::ZLIB target isn't available but include/lib hints exist, create one. +if(NOT TARGET ZLIB::ZLIB) + # Common superbuild exports include ZLIB_INCLUDE_DIR and a library in /lib[64]. + # Try to deduce them if not set by find_package. + if(NOT ZLIB_INCLUDE_DIR AND DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/include") + set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT}/include") + endif() + + # Try typical library file names if not found by package + set(_zlib_lib "") + # Prefer lib64 when present + if(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib64") + set(_zlib_libdir "${ZLIB_ROOT}/lib64") + elseif(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib") + set(_zlib_libdir "${ZLIB_ROOT}/lib") + endif() + + if(_zlib_libdir) + if(WIN32) + if(EXISTS "${_zlib_libdir}/zlib.lib") + set(_zlib_lib "${_zlib_libdir}/zlib.lib") + elseif(EXISTS "${_zlib_libdir}/zlibstatic.lib") + set(_zlib_lib "${_zlib_libdir}/zlibstatic.lib") + endif() + elseif(APPLE) + if(EXISTS "${_zlib_libdir}/libz.dylib") + set(_zlib_lib "${_zlib_libdir}/libz.dylib") + elseif(EXISTS "${_zlib_libdir}/libz.a") + set(_zlib_lib "${_zlib_libdir}/libz.a") + endif() + else() + if(EXISTS "${_zlib_libdir}/libz.so") + set(_zlib_lib "${_zlib_libdir}/libz.so") + elseif(EXISTS "${_zlib_libdir}/libz.a") + set(_zlib_lib "${_zlib_libdir}/libz.a") + endif() + endif() + endif() + + if(NOT _zlib_lib) + # Last resort: search by name with hints + find_library(ZLIB_LIBRARY + NAMES z zlib zlibstatic + HINTS "${_zlib_libdir}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(ZLIB_LIBRARY) + set(_zlib_lib "${ZLIB_LIBRARY}") + endif() + endif() + + if(_zlib_lib AND ZLIB_INCLUDE_DIR) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${_zlib_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + endif() +endif() + +# =========================== +# Link libraries for this lib +# =========================== +target_link_libraries(Core_Geometry_Primitives + PRIVATE + Core_Math + Core_Util_Legacy + Core_Persistent + ${_teem_target} ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Geometry_Primitives) -ENDIF(BUILD_SHARED_LIBS) +# If ZLIB::ZLIB exists, add it (especially useful when Teem is static and needs zlib symbols) +if(TARGET ZLIB::ZLIB) + target_link_libraries(Core_Geometry_Primitives PRIVATE ZLIB::ZLIB) +endif() -SCIRUN_ADD_TEST_DIR(Tests) +# =========================== +# Tests +# =========================== +SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file From 3925747cf61ae6cfb01415ce531707088a6cbe9f Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 11 Feb 2026 14:37:19 -0700 Subject: [PATCH 036/140] more errors --- Superbuild/Superbuild.cmake | 5 + src/CMakeLists.txt | 12 +- src/Core/Algorithms/DataIO/ReadMatrix.cc | 4 +- .../Algorithms/DataIO/TextToTriSurfField.cc | 4 +- src/Core/Algorithms/DataIO/WriteMatrix.cc | 4 +- .../Legacy/Converter/CMakeLists.txt | 107 +++++++++-- src/Core/Datatypes/CMakeLists.txt | 68 +++++-- src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt | 117 ++++++++++-- src/Core/GeometryPrimitives/CMakeLists.txt | 35 ++-- src/Core/ImportExport/GenericIEPlugin.h | 1 + src/Core/Matlab/CMakeLists.txt | 175 +++++++++++++++--- src/Core/Parser/ArrayMathInterpreter.cc | 2 +- 12 files changed, 439 insertions(+), 95 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 6755009e68..f019f5a037 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -545,6 +545,11 @@ if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) set(LODEPNG_INCLUDE_DIR "${LodePng_INCLUDE_DIR}") endif() +if(DEFINED Eigen_INCLUDE_DIR) + # Stable alias that the inner SCIRun configure can use everywhere. + set(SCIRUN_EIGEN_INCLUDE "${Eigen_INCLUDE_DIR}" CACHE PATH "Alias: Eigen include dir" FORCE) + list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_EIGEN_INCLUDE:PATH=${SCIRUN_EIGEN_INCLUDE}") +endif() if(DEFINED GLEW_INCLUDE_DIR) set(SCI_GLEW_INCLUDE "${GLEW_INCLUDE_DIR}" CACHE PATH "Legacy: GLEW include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-DSCI_GLEW_INCLUDE:PATH=${SCI_GLEW_INCLUDE}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92a4b99762..478390a536 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -922,6 +922,9 @@ endif() if(DEFINED TEEM_INCLUDE AND NOT DEFINED SCI_TEEM_INCLUDE) set(SCI_TEEM_INCLUDE "${TEEM_INCLUDE}") endif() +if(DEFINED SCIRUN_EIGEN_INCLUDE AND NOT DEFINED Eigen_INCLUDE_DIR) + set(Eigen_INCLUDE_DIR "${SCIRUN_EIGEN_INCLUDE}") +endif() # Helper: validate a cached include dir (VAR) by checking it contains REL_HEADER. # If empty or incorrect, auto-derive from CMAKE_PREFIX_PATH and cache the fix. @@ -984,6 +987,7 @@ _ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") _ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") _ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") _ensure_header(SCI_TEEM_INCLUDE "teem/ten.h") +_ensure_header(Eigen_INCLUDE_DIR "Eigen/Dense") # Print diagnostics message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") @@ -993,7 +997,7 @@ message(STATUS "SQLite3_INCLUDE_DIR='${SQLite3_INCLUDE_DIR}'") message(STATUS "TNY_INCLUDE_DIR='${TNY_INCLUDE_DIR}'") message(STATUS "SpdLog_INCLUDE_DIR='${SpdLog_INCLUDE_DIR}'") message(STATUS "GLM_INCLUDE_DIR='${GLM_INCLUDE_DIR}'") -message(STATUS "Eigen_DIR='${Eigen_DIR}'") +message(STATUS "Eigen_INCLUDE_DIR='${Eigen_INCLUDE_DIR}'") # Quick existence confirmations if(GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") @@ -1072,9 +1076,9 @@ if(LODEPNG_INCLUDE_DIR AND EXISTS "${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") list(APPEND _SCIRUN_INCLUDE_DIRS "${LODEPNG_INCLUDE_DIR}") endif() -# Eigen (if provided as a directory) -if(Eigen_DIR AND IS_DIRECTORY "${Eigen_DIR}") - list(APPEND _SCIRUN_INCLUDE_DIRS "${Eigen_DIR}") +# Eigen: add only if the directory contains Eigen/Dense +if(Eigen_INCLUDE_DIR AND EXISTS "${Eigen_INCLUDE_DIR}/Eigen/Dense") + list(APPEND _SCIRUN_INCLUDE_DIRS "${Eigen_INCLUDE_DIR}") endif() # De-duplicate & print for visibility diff --git a/src/Core/Algorithms/DataIO/ReadMatrix.cc b/src/Core/Algorithms/DataIO/ReadMatrix.cc index 50441b152a..b3ad05e336 100644 --- a/src/Core/Algorithms/DataIO/ReadMatrix.cc +++ b/src/Core/Algorithms/DataIO/ReadMatrix.cc @@ -68,7 +68,7 @@ ReadMatrixAlgorithm::Outputs ReadMatrixAlgorithm::run(const ReadMatrixAlgorithm: ENSURE_FILE_EXISTS(filename); } - if (boost::filesystem::extension(filename) == ".txt") + if (boost::filesystem::path(filename).extension().string() == ".txt") { std::ifstream reader(filename.c_str()); DenseMatrixHandle matrix(makeShared()); @@ -76,7 +76,7 @@ ReadMatrixAlgorithm::Outputs ReadMatrixAlgorithm::run(const ReadMatrixAlgorithm: return matrix; } - else if (boost::filesystem::extension(filename) == ".mat") + else if (boost::filesystem::path(filename).extension().string() == ".mat") { status("FOUND .mat file: assuming is SCIRUNv4 Matrix format."); diff --git a/src/Core/Algorithms/DataIO/TextToTriSurfField.cc b/src/Core/Algorithms/DataIO/TextToTriSurfField.cc index fa90beaa1d..c30f6e0008 100644 --- a/src/Core/Algorithms/DataIO/TextToTriSurfField.cc +++ b/src/Core/Algorithms/DataIO/TextToTriSurfField.cc @@ -83,12 +83,12 @@ class TextToTriSurfFieldPrivate : public Lockable // unrecognized extension: .fac or .tri for faces, .pts or .pos for points bool validPointsFileExtention(const std::string& filename) { - return bfs::extension(filename) == ".pts" || bfs::extension(filename) == ".pos"; + return bfs::path(filename).extension().string() == ".pts" || bfs::path(filename).extension().string() == ".pos"; } bool validFacesFileExtention(const std::string& filename) { - return bfs::extension(filename) == ".fac" || bfs::extension(filename) == ".tri"; + return bfs::path(filename).extension().string() == ".fac" || bfs::path(filename).extension().string() == ".tri"; } // these files just contain geometry (note that data can be applied to field from matrix) diff --git a/src/Core/Algorithms/DataIO/WriteMatrix.cc b/src/Core/Algorithms/DataIO/WriteMatrix.cc index 964175ee8d..8711635ef8 100644 --- a/src/Core/Algorithms/DataIO/WriteMatrix.cc +++ b/src/Core/Algorithms/DataIO/WriteMatrix.cc @@ -47,12 +47,12 @@ WriteMatrixAlgorithm::Outputs WriteMatrixAlgorithm::run(const WriteMatrixAlgorit { ENSURE_ALGORITHM_INPUT_NOT_NULL(inputMatrix, "Cannot write null matrix."); - if (boost::filesystem::extension(filename) == ".txt") + if (boost::filesystem::path(filename).extension().string() == ".txt") { std::ofstream writer(filename.c_str()); writer << *inputMatrix; } - else if (boost::filesystem::extension(filename) == ".mat") + else if (boost::filesystem::path(filename).extension().string() == ".mat") { status("Writing matrix file as binary .mat"); diff --git a/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt b/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt index b19e2fbe89..04672a5a56 100644 --- a/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt @@ -26,9 +26,9 @@ # -# Sources of Core/Algorithms/Converter classes +# Sources of Core/Algorithms/Legacy/Converter classes -SET(Core_Algorithms_Legacy_Converter_SRCS +set(Core_Algorithms_Legacy_Converter_SRCS ConverterAlgo.cc #MatrixToField.cc NrrdToField.cc @@ -39,7 +39,7 @@ SET(Core_Algorithms_Legacy_Converter_SRCS ConvertMatrixToString.cc ) -SET(Core_Algorithms_Legacy_Converter_HEADERS +set(Core_Algorithms_Legacy_Converter_HEADERS ConverterAlgo.h NrrdToField.h FieldToNrrd.h @@ -51,16 +51,95 @@ SET(Core_Algorithms_Legacy_Converter_HEADERS SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_Converter ${Core_Algorithms_Legacy_Converter_SRCS} - ${Core_Algorithms_Legacy_Converter_HEADERS}) - -TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Converter - Algorithms_Base - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - Core_Datatypes_Legacy_Bundle + ${Core_Algorithms_Legacy_Converter_HEADERS} ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_Converter) -ENDIF(BUILD_SHARED_LIBS) +# Export macro for this shared library (existing behavior) +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Algorithms_Legacy_Converter PRIVATE BUILD_Core_Algorithms_Legacy_Converter) +endif() + +# ========================================================== +# Teem discovery (same pattern as Core_Geometry_Primitives) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +target_compile_definitions(Core_Algorithms_Legacy_Converter PRIVATE TEEM_STATIC) + +# Existing internal deps +target_link_libraries(Core_Algorithms_Legacy_Converter + PRIVATE + Algorithms_Base + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + Core_Datatypes_Legacy_Bundle + ${_teem_target} +) + +# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: +if(TARGET ZLIB::ZLIB) + target_link_libraries(Core_Algorithms_Legacy_Converter PRIVATE ZLIB::ZLIB) +endif() \ No newline at end of file diff --git a/src/Core/Datatypes/CMakeLists.txt b/src/Core/Datatypes/CMakeLists.txt index c11b7a8023..5fdadc25d0 100644 --- a/src/Core/Datatypes/CMakeLists.txt +++ b/src/Core/Datatypes/CMakeLists.txt @@ -26,7 +26,12 @@ # -SET(Core_Datatypes_SRCS +# ====================================== +# Core/Datatypes - modern CMake (target-based) +# ====================================== + +# ---- Sources & headers ---- +set(Core_Datatypes_SRCS BlockMatrix.cc Color.cc ColorMap.cc @@ -44,7 +49,7 @@ SET(Core_Datatypes_SRCS Feedback.cc ) -SET(Core_Datatypes_HEADERS +set(Core_Datatypes_HEADERS BlockMatrix.h Color.h ColorMap.h @@ -74,23 +79,62 @@ SET(Core_Datatypes_HEADERS SparseRowMatrixFromMap.h String.h Feedback.h - ) +) +# ---- Library target ---- SCIRUN_ADD_LIBRARY(Core_Datatypes ${Core_Datatypes_HEADERS} ${Core_Datatypes_SRCS} ) -TARGET_LINK_LIBRARIES(Core_Datatypes - Core_Persistent - Core_Datatypes_Legacy_Base - Core_Geometry_Primitives +# Shared lib export define (kept behavior) +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Datatypes PRIVATE BUILD_Core_Datatypes) +endif() + +# ---- Dependencies (existing) ---- +target_link_libraries(Core_Datatypes + PRIVATE + Core_Persistent + Core_Datatypes_Legacy_Base + Core_Geometry_Primitives ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Datatypes) -ENDIF(BUILD_SHARED_LIBS) +# ========================================================== +# Eigen (header-only): consume superbuild-exported include dir +# ========================================================== + +# Prefer superbuild's direct export +set(_eigen_inc "") +if(DEFINED Eigen_INCLUDE_DIR AND EXISTS "${Eigen_INCLUDE_DIR}/Eigen/Dense") + set(_eigen_inc "${Eigen_INCLUDE_DIR}") +elseif(DEFINED SCIRUN_EIGEN_INCLUDE AND EXISTS "${SCIRUN_EIGEN_INCLUDE}/Eigen/Dense") + set(_eigen_inc "${SCIRUN_EIGEN_INCLUDE}") +endif() + +# Final check +if(NOT _eigen_inc) + message(FATAL_ERROR + "Eigen headers not found. Provide one of:\n" + " -DEigen_INCLUDE_DIR=E:/PROJECTS/SCIRun/build/Externals/Install/Eigen_external/include\n" + " -DSCIRUN_EIGEN_INCLUDE=E:/PROJECTS/SCIRun/build/Externals/Install/Eigen_external/include\n" + "Or adjust to match your superbuild output.") +endif() + +# Create a simple header-only target that mirrors Eigen3::Eigen semantics +if(NOT TARGET Eigen3::Eigen) + add_library(Eigen3::Eigen INTERFACE IMPORTED) + set_target_properties(Eigen3::Eigen PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_eigen_inc}" + ) +endif() + +# Attach to this target (and any others that include ) +target_link_libraries(Core_Datatypes PRIVATE Eigen3::Eigen) +# =========================== +# Tests and subdirectories +# =========================== SCIRUN_ADD_TEST_DIR(Tests) -ADD_SUBDIRECTORY(Mesh) -ADD_SUBDIRECTORY(Legacy) +add_subdirectory(Mesh) +add_subdirectory(Legacy) \ No newline at end of file diff --git a/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt b/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt index 5144745f59..2e9e7bc2df 100644 --- a/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt +++ b/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt @@ -25,13 +25,16 @@ # DEALINGS IN THE SOFTWARE. # +# ================================ +# Core/Datatypes/Legacy/Nrrd +# ================================ -SET(Core_Datatypes_Legacy_Nrrd_HEADERS +set(Core_Datatypes_Legacy_Nrrd_HEADERS NrrdData.h share.h ) -SET(Core_Datatypes_Legacy_Nrrd_SRCS +set(Core_Datatypes_Legacy_Nrrd_SRCS NrrdData.cc ) @@ -40,23 +43,99 @@ SCIRUN_ADD_LIBRARY(Core_Datatypes_Legacy_Nrrd ${Core_Datatypes_Legacy_Nrrd_HEADERS} ) -TARGET_LINK_LIBRARIES(Core_Datatypes_Legacy_Nrrd - Core_Exceptions_Legacy - Core_Geometry_Primitives - Core_Math - #Core_Persistent - Core_Thread - #Core_Thread_Legacy - Core_Utils - Core_Util_Legacy - Core_Datatypes - Core_Datatypes_Legacy_Base - ${SCI_BOOST_LIBRARY} - ${SCI_TEEM_LIBRARY} +# Export macro for this shared lib (kept behavior) +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Datatypes_Legacy_Nrrd PRIVATE BUILD_Core_Datatypes_Legacy_Nrrd) +endif() + +# ========================================== +# Teem discovery (same pattern as Geometry) +# ========================================== +# Preferred: Teem config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback: Use superbuild hints Teem_INCLUDE_DIR / Teem_LIB_DIR + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + # Try canonical filenames first by platform + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + # Fallback: search by name with hints + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" # static C lib; helps some generators + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +target_compile_definitions(Core_Datatypes_Legacy_Nrrd PRIVATE TEEM_STATIC) + +# Existing internal deps +target_link_libraries(Core_Datatypes_Legacy_Nrrd + PRIVATE + Core_Exceptions_Legacy + Core_Geometry_Primitives + Core_Math + Core_Thread + Core_Utils + Core_Util_Legacy + Core_Datatypes + Core_Datatypes_Legacy_Base + ${_teem_target} ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Datatypes_Legacy_Nrrd) -ENDIF(BUILD_SHARED_LIBS) +# If zlib was enabled in Teem (common for NRRD), static Teem needs zlib symbols +if(TARGET ZLIB::ZLIB) + target_link_libraries(Core_Datatypes_Legacy_Nrrd PRIVATE ZLIB::ZLIB) +endif() -#SCIRUN_ADD_TEST_DIR(Tests) +#SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file diff --git a/src/Core/GeometryPrimitives/CMakeLists.txt b/src/Core/GeometryPrimitives/CMakeLists.txt index 3a1116391b..bf1226917b 100644 --- a/src/Core/GeometryPrimitives/CMakeLists.txt +++ b/src/Core/GeometryPrimitives/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,7 +25,6 @@ # DEALINGS IN THE SOFTWARE. # - # ================================ # Core/GeometryPrimitives CMake # ================================ @@ -69,12 +68,26 @@ if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_Core_Geometry_Primitives) endif() +# ---------------------------------------------------------- +# Teem is currently built as a *static* library in your superbuild +# (you only have teem.lib, no teem.dll). On Windows, Teem headers +# would otherwise mark APIs as __declspec(dllimport), which produces +# __imp_* references and triggers LNK2019 when linking to a static lib. +# Defining TEEM_STATIC disables dllimport in Teem's TEN_EXPORT macros. ⟶ +# See Microsoft docs on dllexport/dllimport and Teem's export macros. ⟶ +# ---------------------------------------------------------- +# References: +# - Microsoft Learn on dllexport/dllimport (__imp_ import thunks) ⟶ https://learn.microsoft.com/ ... (dllexport, dllimport) +# - Teem Windows export macros recommending TEEM_STATIC for static link ⟶ SourceForge mailing list thread +# (Cited below in the chat text for traceability.) +target_compile_definitions(Core_Geometry_Primitives + PRIVATE TEEM_STATIC) + # ========================================================== # Teem discovery (provides tenEigensolve_f used by Tensor.cc) # ========================================================== # Preferred: Teem config package if available -# (You can create/export one from the superbuild later; this handles that case automatically.) find_package(Teem CONFIG QUIET) if(TARGET Teem::teem) @@ -109,7 +122,7 @@ else() endif() endif() - # Fallback: search by name with hints if not found yet + # Fallback: search by name with hints if(NOT _teem_lib) find_library(TEEM_LIBRARY NAMES teem libteem @@ -131,30 +144,23 @@ else() set_target_properties(Teem::teem PROPERTIES IMPORTED_LOCATION "${_teem_lib}" INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" # static C lib; helps some generators ) set(_teem_target Teem::teem) endif() # ============================================ -# ZLIB (needed by Teem; useful for static Teem) +# ZLIB (useful when Teem was built with zlib) # ============================================ - -# Try to use a config/module package first. -# Your superbuild already exports ZLIB_ROOT & ZLIB_DIR and sets CMAKE_PREFIX_PATH, so this should work. find_package(ZLIB QUIET) -# If ZLIB::ZLIB target isn't available but include/lib hints exist, create one. if(NOT TARGET ZLIB::ZLIB) - # Common superbuild exports include ZLIB_INCLUDE_DIR and a library in /lib[64]. - # Try to deduce them if not set by find_package. if(NOT ZLIB_INCLUDE_DIR AND DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/include") set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT}/include") endif() - # Try typical library file names if not found by package set(_zlib_lib "") - # Prefer lib64 when present if(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib64") set(_zlib_libdir "${ZLIB_ROOT}/lib64") elseif(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib") @@ -184,7 +190,6 @@ if(NOT TARGET ZLIB::ZLIB) endif() if(NOT _zlib_lib) - # Last resort: search by name with hints find_library(ZLIB_LIBRARY NAMES z zlib zlibstatic HINTS "${_zlib_libdir}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" @@ -214,7 +219,7 @@ target_link_libraries(Core_Geometry_Primitives ${_teem_target} ) -# If ZLIB::ZLIB exists, add it (especially useful when Teem is static and needs zlib symbols) +# If ZLIB::ZLIB exists, add it (helpful when Teem static needs zlib symbols) if(TARGET ZLIB::ZLIB) target_link_libraries(Core_Geometry_Primitives PRIVATE ZLIB::ZLIB) endif() diff --git a/src/Core/ImportExport/GenericIEPlugin.h b/src/Core/ImportExport/GenericIEPlugin.h index f98240042c..669fac7bad 100644 --- a/src/Core/ImportExport/GenericIEPlugin.h +++ b/src/Core/ImportExport/GenericIEPlugin.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/src/Core/Matlab/CMakeLists.txt b/src/Core/Matlab/CMakeLists.txt index 0bfbf74772..278016aa05 100644 --- a/src/Core/Matlab/CMakeLists.txt +++ b/src/Core/Matlab/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,10 +25,9 @@ # DEALINGS IN THE SOFTWARE. # - # CMakeLists.txt for Core/Matlab -SET(Core_Matlab_SRCS +set(Core_Matlab_SRCS fieldtomatlab.cc matfile.cc matfiledata.cc @@ -38,7 +37,7 @@ SET(Core_Matlab_SRCS matlabtofield.cc ) -SET(Core_Matlab_HEADERS +set(Core_Matlab_HEADERS fieldtomatlab.h matfile.h matfilebase.h @@ -52,26 +51,154 @@ SET(Core_Matlab_HEADERS share.h ) -SCIRUN_ADD_LIBRARY(Core_Matlab ${Core_Matlab_SRCS} ${Core_Matlab_HEADERS}) - -TARGET_LINK_LIBRARIES(Core_Matlab - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - #Core_Exceptions - #Core_Thread - Core_Geometry_Primitives - #Core_Util - Core_Math - Core_Logging - ${SCI_ZLIB_LIBRARY} - ${SCI_TEEM_LIBRARY} +SCIRUN_ADD_LIBRARY(Core_Matlab + ${Core_Matlab_SRCS} + ${Core_Matlab_HEADERS} ) -IF(MATLAB_STRING_OUTPUT_SIGNED_TYPE_FIX_FOR_SCIPY) - ADD_DEFINITIONS(-DMATLAB_STRING_OUTPUT_SIGNED_TYPE_FIX_FOR_SCIPY) -ENDIF() +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Matlab PRIVATE BUILD_Core_Matlab) +endif() + +# ============================================ +# ZLIB (useful when Teem was built with zlib) +# -- Reused verbatim from your working modules +# ============================================ +find_package(ZLIB QUIET) + +if(NOT TARGET ZLIB::ZLIB) + if(NOT ZLIB_INCLUDE_DIR AND DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/include") + set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT}/include") + endif() + + set(_zlib_lib "") + if(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib64") + set(_zlib_libdir "${ZLIB_ROOT}/lib64") + elseif(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib") + set(_zlib_libdir "${ZLIB_ROOT}/lib") + endif() + + if(_zlib_libdir) + if(WIN32) + if(EXISTS "${_zlib_libdir}/zlib.lib") + set(_zlib_lib "${_zlib_libdir}/zlib.lib") + elseif(EXISTS "${_zlib_libdir}/zlibstatic.lib") + set(_zlib_lib "${_zlib_libdir}/zlibstatic.lib") + endif() + elseif(APPLE) + if(EXISTS "${_zlib_libdir}/libz.dylib") + set(_zlib_lib "${_zlib_libdir}/libz.dylib") + elseif(EXISTS "${_zlib_libdir}/libz.a") + set(_zlib_lib "${_zlib_libdir}/libz.a") + endif() + else() + if(EXISTS "${_zlib_libdir}/libz.so") + set(_zlib_lib "${_zlib_libdir}/libz.so") + elseif(EXISTS "${_zlib_libdir}/libz.a") + set(_zlib_lib "${_zlib_libdir}/libz.a") + endif() + endif() + endif() + + if(NOT _zlib_lib) + find_library(ZLIB_LIBRARY + NAMES z zlib zlibstatic + HINTS "${_zlib_libdir}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(ZLIB_LIBRARY) + set(_zlib_lib "${ZLIB_LIBRARY}") + endif() + endif() + + if(_zlib_lib AND ZLIB_INCLUDE_DIR) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${_zlib_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + endif() +endif() + +# ========================================================== +# Teem: (match the pattern you used in other fixed modules) +# ========================================================== +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + set(_teem_target Teem::teem) +endif() + +# Teem is static in your build → prevent dllimport (__imp_*) +target_compile_definitions(Core_Matlab PRIVATE TEEM_STATIC) + +# ----------------------------- +# Link libraries for this module +# ----------------------------- +target_link_libraries(Core_Matlab + PRIVATE + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + Core_Geometry_Primitives + Core_Math + Core_Logging + ${_teem_target} +) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Matlab) -ENDIF(BUILD_SHARED_LIBS) +# Zlib: prefer imported target; otherwise keep legacy variable +if(TARGET ZLIB::ZLIB) + target_link_libraries(Core_Matlab PRIVATE ZLIB::ZLIB) +elseif(DEFINED SCI_ZLIB_LIBRARY) + target_link_libraries(Core_Matlab PRIVATE "${SCI_ZLIB_LIBRARY}") +endif() \ No newline at end of file diff --git a/src/Core/Parser/ArrayMathInterpreter.cc b/src/Core/Parser/ArrayMathInterpreter.cc index 86a9ce1bf8..930aa09f3a 100644 --- a/src/Core/Parser/ArrayMathInterpreter.cc +++ b/src/Core/Parser/ArrayMathInterpreter.cc @@ -1569,7 +1569,7 @@ ArrayMathProgram::run_parallel(int proc) void ArrayMathProgramCode::print() const { - std::cout << "function_ = "< Date: Wed, 11 Feb 2026 14:55:13 -0700 Subject: [PATCH 037/140] freetype --- Superbuild/FreetypeExternal.cmake | 14 +++++----- Superbuild/Superbuild.cmake | 44 +++++++++++++++++++++++++++++++ src/CMakeLists.txt | 17 +++++++++++- 3 files changed, 67 insertions(+), 8 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index d5fe1cebbb..4575839d8a 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -76,16 +76,16 @@ ExternalProject_Add(Freetype_external CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - # Use CMAKE_CACHE_ARGS so hints are written into FreeType's *own* CMake cache CMAKE_CACHE_ARGS -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_INSTALL_LIBDIR:PATH=lib - # Let FindZLIB.cmake search under zlib's install prefix + # Let FreeType find the zlib we built -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} - -DZLIB_USE_STATIC_LIBS:BOOL=ON # optional preference, no filename + -DZLIB_USE_STATIC_LIBS:BOOL=ON -DFT_REQUIRE_ZLIB:BOOL=ON -DFT_DISABLE_BZIP2:BOOL=ON @@ -94,22 +94,22 @@ ExternalProject_Add(Freetype_external -DFT_DISABLE_HARFBUZZ:BOOL=ON DEPENDS Zlib_external - INSTALL_COMMAND "" + # IMPORTANT: let ExternalProject install files (remove the empty INSTALL_COMMAND) + # INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# --- Force FreeType 'configure' to wait for zlib's actual files --- -# This prevents configure from running before zlib installs headers/libs. +# Ensure zlib artifacts exist before FreeType config ExternalProject_Add_Step(Freetype_external wait_for_zlib COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts..." DEPENDEES download DEPENDERS configure DEPENDS "${ZLIB_INSTALL_DIR}/include/zlib.h" - "${ZLIB_INSTALL_DIR}/lib" # Directory's existence/time is sufficient; no file name + "${ZLIB_INSTALL_DIR}/lib" ) # Export variables for SCIRun (consumer side) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index f019f5a037..bd4a06654a 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -451,6 +451,7 @@ endif() # Include/lib hints (guarded by target existence) _sb_export_inc_lib(Eigen Eigen_external) +_sb_export_inc_lib(Freetype Freetype_external) _sb_export_inc_lib(GLM GLM_external) _sb_export_inc_lib(SpdLog SpdLog_external) _sb_export_inc_lib(Teem Teem_external) @@ -511,6 +512,49 @@ if(WIN32) list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}") endif() +# FreeType essential hints (include & lib paths explicitly) +if(TARGET Freetype_external) + ExternalProject_Get_Property(Freetype_external INSTALL_DIR) + set(FREETYPE_INSTALL_DIR "${INSTALL_DIR}") + + # Primary include (contains ft2build.h) and the 'freetype2' sub-include + set(Freetype_INCLUDE_DIR "${FREETYPE_INSTALL_DIR}/include") + set(FREETYPE_INCLUDE_DIR2 "${FREETYPE_INSTALL_DIR}/include/freetype2") + + # Library directory (freetype.lib / libfreetype.{a,so,dylib}) + # If you set CMAKE_INSTALL_LIBDIR=lib in the external, this is stable: + set(Freetype_LIB_DIR "${FREETYPE_INSTALL_DIR}/lib") + + # Append cache args consumed by the inner SCIRun configure + list(APPEND SCIRUN_CACHE_ARGS + "-DFreetype_INCLUDE_DIR:PATH=${Freetype_INCLUDE_DIR}" + "-DFREETYPE_INCLUDE_DIR2:PATH=${FREETYPE_INCLUDE_DIR2}" + "-DFreetype_LIB_DIR:PATH=${Freetype_LIB_DIR}" + ) + + # If the external produced a *Config.cmake, pass its DIR like you do for Zlib. + # Prefer an explicit Freetype_DIR if the superbuild has one; else export the common location. + if(DEFINED Freetype_DIR) + list(APPEND SCIRUN_CACHE_ARGS "-DFreetype_DIR:PATH=${Freetype_DIR}") + else() + # Helper you already use for Zlib to export a config dir that the inner find_package() can pick up. + # Adjust the suffix if your FreeType external installs config files elsewhere. + _export_config_dir(Freetype Freetype_external "lib/cmake/freetype") + endif() + + # (Optional) If you also maintain legacy alias variables for consistency with older code: + set(SCI_FREETYPE_INCLUDE "${Freetype_INCLUDE_DIR}" CACHE PATH "Legacy: FreeType include dir (ft2build.h)" FORCE) + set(SCI_FREETYPE_INCLUDE2 "${FREETYPE_INCLUDE_DIR2}" CACHE PATH "Legacy: FreeType include dir (freetype2)" FORCE) + set(SCI_FREETYPE_LIBRARY_DIR "${Freetype_LIB_DIR}" CACHE PATH "Legacy: FreeType library dir" FORCE) + + # And push those legacy names too if you want them available in the inner cache: + list(APPEND SCIRUN_CACHE_ARGS + "-DSCI_FREETYPE_INCLUDE:PATH=${SCI_FREETYPE_INCLUDE}" + "-DSCI_FREETYPE_INCLUDE2:PATH=${SCI_FREETYPE_INCLUDE2}" + "-DSCI_FREETYPE_LIBRARY_DIR:PATH=${SCI_FREETYPE_LIBRARY_DIR}" + ) +endif() + # Zlib + Boost essential hints (include & lib paths explicitly) if(TARGET Zlib_external) ExternalProject_Get_Property(Zlib_external INSTALL_DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 478390a536..642a63512e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -988,6 +988,7 @@ _ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") _ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") _ensure_header(SCI_TEEM_INCLUDE "teem/ten.h") _ensure_header(Eigen_INCLUDE_DIR "Eigen/Dense") +_ensure_header(Freetype_INCLUDE_DIR "ft2build.h") # Print diagnostics message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") @@ -1039,7 +1040,21 @@ set(_SCIRUN_INCLUDE_DIRS ${SCI_CLEAVER2_INCLUDE} ) -# Append externals only if valid (directory exists and contains expected header) + +# If the second include dir wasn't set, derive it from the first +if(NOT FREETYPE_INCLUDE_DIR2 OR NOT EXISTS "${FREETYPE_INCLUDE_DIR2}/freetype/config/ftheader.h") + if(Freetype_INCLUDE_DIR AND EXISTS "${Freetype_INCLUDE_DIR}/freetype2/freetype/config/ftheader.h") + set(FREETYPE_INCLUDE_DIR2 "${Freetype_INCLUDE_DIR}/freetype2" CACHE PATH "FREETYPE_INCLUDE_DIR2" FORCE) + endif() +endif() + +# Append both include roots (only if they exist) +if(Freetype_INCLUDE_DIR AND EXISTS "${Freetype_INCLUDE_DIR}/ft2build.h") + list(APPEND _SCIRUN_INCLUDE_DIRS "${Freetype_INCLUDE_DIR}") +endif() +if(FREETYPE_INCLUDE_DIR2 AND EXISTS "${FREETYPE_INCLUDE_DIR2}/freetype/config/ftheader.h") + list(APPEND _SCIRUN_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR2}") +endif() # Boost (legacy var) if(Boost_INCLUDE_DIR AND EXISTS "${Boost_INCLUDE_DIR}/boost") From 9fb63ddbc819cdf7c954a901867181c0e3d8a9e8 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 11 Feb 2026 15:37:15 -0700 Subject: [PATCH 038/140] more errors --- .../Algorithms/Legacy/DataIO/CMakeLists.txt | 50 +++++++++++++------ src/Core/Parser/ArrayMathInterpreter.cc | 2 +- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt b/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt index f82185da84..8430f2a14c 100644 --- a/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt @@ -25,10 +25,9 @@ # DEALINGS IN THE SOFTWARE. # +# Sources of Core/Algorithms/Legacy/DataIO classes -# Sources of Core/Algorithms/DataIO classes - -SET(Core_Algorithms_Legacy_DataIO_SRCS +set(Core_Algorithms_Legacy_DataIO_SRCS DataIOAlgo.cc #G3DToFieldReader.cc ObjToFieldReader.cc @@ -38,7 +37,7 @@ SET(Core_Algorithms_Legacy_DataIO_SRCS STLUtils.cc ) -SET(Core_Algorithms_Legacy_DataIO_HEADERS +set(Core_Algorithms_Legacy_DataIO_HEADERS #G3DToFieldReader.h ObjToFieldReader.h VTKToTriSurfReader.h @@ -54,17 +53,36 @@ SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_DataIO ${Core_Algorithms_Legacy_DataIO_HEADERS} ) -TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_DataIO - Algorithms_Base - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd +# Export macro for this shared library (existing behavior) +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Algorithms_Legacy_DataIO PRIVATE BUILD_Core_Algorithms_Legacy_DataIO) +endif() - Core_Math - Core_Persistent - Core_ImportExport -) +# ========================================================== +# Teem discovery (same pattern as Core_Algorithms_Legacy_Converter) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + # Expect these to be set by the superbuild toolchain or cache + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_DataIO) -ENDIF(BUILD_SHARED_LIBS) + # Try to resolve the actual library file + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") diff --git a/src/Core/Parser/ArrayMathInterpreter.cc b/src/Core/Parser/ArrayMathInterpreter.cc index 930aa09f3a..8a1f5640d6 100644 --- a/src/Core/Parser/ArrayMathInterpreter.cc +++ b/src/Core/Parser/ArrayMathInterpreter.cc @@ -1569,7 +1569,7 @@ ArrayMathProgram::run_parallel(int proc) void ArrayMathProgramCode::print() const { - std::cout << "function_ = " << static_cast(reinterpret_cast(function_)) << "\n"; + std::cout << "function_ = " << static_cast(&function_) << "\n"; for (size_t j=0;j Date: Wed, 11 Feb 2026 15:54:52 -0700 Subject: [PATCH 039/140] cmake --- .../Algorithms/Legacy/DataIO/CMakeLists.txt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt b/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt index 8430f2a14c..d0614afe56 100644 --- a/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt @@ -86,3 +86,64 @@ else() elseif(APPLE) if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +# If you are using shared Teem (DLL), comment this line out. +target_compile_definitions(Core_Algorithms_Legacy_DataIO PRIVATE TEEM_STATIC) + +# Existing internal deps + Teem +target_link_libraries(Core_Algorithms_Legacy_DataIO + PRIVATE + Algorithms_Base + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + Core_Math + Core_Persistent + Core_ImportExport + ${_teem_target} +) + +# If Teem was built with zlib (very common for NRRD), static Teem needs zlib symbols too: +if(TARGET ZLIB::ZLIB) + target_link_libraries(Core_Algorithms_Legacy_DataIO PRIVATE ZLIB::ZLIB) +endif() \ No newline at end of file From 50e63188eeb764d5fb569cc5ff77c4d7c500d3fa Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 13 Feb 2026 11:25:12 -0700 Subject: [PATCH 040/140] teem linking error --- src/Core/Parser/CMakeLists.txt | 120 ++++++++++++++++++++++++++++++--- 1 file changed, 110 insertions(+), 10 deletions(-) diff --git a/src/Core/Parser/CMakeLists.txt b/src/Core/Parser/CMakeLists.txt index 0a9790a9d1..1a41f65b1a 100644 --- a/src/Core/Parser/CMakeLists.txt +++ b/src/Core/Parser/CMakeLists.txt @@ -28,7 +28,7 @@ # Sources of Core/Parser classes -SET(Core_Parser_HEADERS +set(Core_Parser_HEADERS ArrayMathEngine.h LinAlgEngine.h Parser.h @@ -39,7 +39,7 @@ SET(Core_Parser_HEADERS LinAlgInterpreter.h ) -SET(Core_Parser_SRCS +set(Core_Parser_SRCS ArrayMathFunctionElement.cc ArrayMathFunctionTensor.cc ArrayMathFunctionVector.cc @@ -63,13 +63,113 @@ SCIRUN_ADD_LIBRARY(Core_Parser ${Core_Parser_SRCS} ) -TARGET_LINK_LIBRARIES(Core_Parser - Core_Datatypes_Legacy_Field - #Core_Algorithms_Math - Core_Datatypes) +# Export macro for this shared library (existing behavior) +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Parser PRIVATE BUILD_Core_Parser) +endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Parser) -ENDIF(BUILD_SHARED_LIBS) +# ========================================================== +# Teem discovery (same pattern as other fixed modules) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) -SCIRUN_ADD_TEST_DIR(Tests) +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + # Expect these to be set by the superbuild toolchain or cache + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + # Try to resolve the actual library file + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +# If you are using shared Teem (DLL), comment this line out. +target_compile_definitions(Core_Parser PRIVATE TEEM_STATIC) + +# Existing internal deps + Teem +target_link_libraries(Core_Parser + PRIVATE + Core_Datatypes_Legacy_Field + Core_Datatypes + ${_teem_target} +) + +# If Teem was built with zlib (very common for NRRD), static Teem needs zlib too. +# Prefer the config target if available, otherwise try a quiet find_package. +if(TARGET ZLIB::ZLIB) + target_link_libraries(Core_Parser PRIVATE ZLIB::ZLIB) +else() + find_package(ZLIB QUIET) + if(ZLIB_FOUND) + # Create an alias target if the package didn't provide one. + if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB INTERFACE IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${ZLIB_LIBRARIES}" + ) + endif() + target_link_libraries(Core_Parser PRIVATE ZLIB::ZLIB) + endif() +endif() + +# Optional: Unix sometimes needs 'm' for static math, not needed on MSVC. +if(UNIX AND NOT APPLE) + target_link_libraries(Core_Parser PRIVATE m) +endif() + +SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file From c1a0d96192ffe607fbdee26f15738d39692206cc Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 13 Feb 2026 17:09:39 -0700 Subject: [PATCH 041/140] linking errors of modules --- Superbuild/Cleaver2External.cmake | 11 + Superbuild/EigenExternal.cmake | 24 +- Superbuild/Superbuild.cmake | 37 ++- src/CMakeLists.txt | 66 +++- src/Core/Python/CMakeLists.txt | 8 + src/Core/Python/PythonInterpreter.cc | 311 ++++++++++++------ .../NetworkDescriptionSerialization.cc | 23 +- src/Modules/DataIO/ReadField.cc | 2 +- src/Modules/DataIO/WriteField.cc | 2 +- 9 files changed, 367 insertions(+), 117 deletions(-) diff --git a/Superbuild/Cleaver2External.cmake b/Superbuild/Cleaver2External.cmake index b6fda7e121..e7ebb7dfe3 100644 --- a/Superbuild/Cleaver2External.cmake +++ b/Superbuild/Cleaver2External.cmake @@ -83,6 +83,17 @@ ExternalProject_Add(Cleaver2_external LOG_INSTALL 1 ) +# After build, copy headers from the source tree into the install/include tree +ExternalProject_Add_Step(Cleaver2_external copy_headers + COMMAND ${CMAKE_COMMAND} -E make_directory "${_cleaver2_inst}/include/cleaver2" + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${_cleaver2_src}/src/lib/cleaver2" + "${_cleaver2_inst}/include/cleaver2" + DEPENDEES build + ALWAYS 1 + COMMENT "Copying Cleaver2 headers to ${_cleaver2_inst}/include/cleaver2" +) + # Export properties for SCIRun ExternalProject_Get_Property(Cleaver2_external SOURCE_DIR) set(CLEAVER2_SOURCE_DIR ${SOURCE_DIR}) diff --git a/Superbuild/EigenExternal.cmake b/Superbuild/EigenExternal.cmake index 73fc8076c3..e8aa529a0c 100644 --- a/Superbuild/EigenExternal.cmake +++ b/Superbuild/EigenExternal.cmake @@ -26,23 +26,29 @@ # EigenExternal.cmake -SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) ExternalProject_Add(Eigen_external URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz" UPDATE_DISCONNECTED 1 - PATCH_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_IN_SOURCE ON - BUILD_COMMAND "" - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory - "/Eigen" # headers live under Eigen/ and (for 3.4) CMake files under cmake/ - "${CMAKE_BINARY_DIR}/Externals/Install/Eigen_external/include/Eigen" + + # Standard CMake configure + install (no build needed for header-only) + CONFIGURE_COMMAND + ${CMAKE_COMMAND} + -S + -B + -DCMAKE_INSTALL_PREFIX= + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + + BUILD_COMMAND "" # header-only + + INSTALL_COMMAND + ${CMAKE_COMMAND} --build --target install + LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Optional trace ExternalProject_Get_Property(Eigen_external INSTALL_DIR) message(STATUS "[Eigen_external] INSTALL_DIR=${INSTALL_DIR}") diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index bd4a06654a..b1e1c848e4 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -450,7 +450,6 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) endif() # Include/lib hints (guarded by target existence) -_sb_export_inc_lib(Eigen Eigen_external) _sb_export_inc_lib(Freetype Freetype_external) _sb_export_inc_lib(GLM GLM_external) _sb_export_inc_lib(SpdLog SpdLog_external) @@ -583,6 +582,28 @@ if(TARGET Boost_external) ) endif() +# ===== Eigen (special-case exporter to prefer include/eigen3) ===== +if(TARGET Eigen_external) + ExternalProject_Get_Property(Eigen_external INSTALL_DIR) + + # Prefer the CMake-installed Eigen layout + set(_eigen_inc "${INSTALL_DIR}/include/eigen3") + if(NOT EXISTS "${_eigen_inc}/Eigen/Dense") + # Legacy fallback when copy-only install was used. + # Strongly recommend switching your Eigen external to CMake install. + set(_eigen_inc "${INSTALL_DIR}/include") + endif() + + # Pass normalized include to SCIRun (it will also verify 'unsupported' exists) + list(APPEND SCIRUN_CACHE_ARGS + "-DEigen_INCLUDE_DIR:PATH=${_eigen_inc}" + "-DSCIRUN_EIGEN_INCLUDE:PATH=${_eigen_inc}" + ) + + # Ensure SCIRun sees Eigen's prefix in CMAKE_PREFIX_PATH + sb_prefix_append("${INSTALL_DIR}") +endif() + # Legacy alias variables (so existing SCIRun CMake picks them up) # Normalize LodePng var name if needed if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) @@ -879,3 +900,17 @@ if(NOT BUILD_HEADLESS AND TARGET Qwt_external) DIRS "${INSTALL_DIR}/include" ) endif() + +# --- Wait for Eigen headers (including unsupported/Tensor) before SCIRun configure --- +if(TARGET Eigen_external) + ExternalProject_Get_Property(Eigen_external INSTALL_DIR) + set(_eigen_inc "${INSTALL_DIR}/include/eigen3") # assume modern layout produced by CMake install + + # Do not check EXISTS here—let ExternalProject step handle availability at build time. + _sb_scirun_wait_for(NAME eigen + FILES + "${_eigen_inc}/Eigen/Dense" + "${_eigen_inc}/unsupported/Eigen/CXX11/Tensor" + DIRS "${_eigen_inc}" + ) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 642a63512e..d8ba23389d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -987,9 +987,73 @@ _ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") _ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") _ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") _ensure_header(SCI_TEEM_INCLUDE "teem/ten.h") -_ensure_header(Eigen_INCLUDE_DIR "Eigen/Dense") _ensure_header(Freetype_INCLUDE_DIR "ft2build.h") +# --- Robust Eigen include discovery (handles eigen3 layout and unsupported) --- +# Try to honor a pre-set Eigen_INCLUDE_DIR first +set(_eigen_ok FALSE) +if(Eigen_INCLUDE_DIR) + if(EXISTS "${Eigen_INCLUDE_DIR}/Eigen/Dense" AND EXISTS "${Eigen_INCLUDE_DIR}/unsupported/Eigen/CXX11/Tensor") + set(_eigen_ok TRUE) + endif() +endif() + +# If not OK, auto-probe from CMAKE_PREFIX_PATH (prefer eigen3 layout) +if(NOT _eigen_ok) + set(_candidates "") + foreach(_p IN LISTS CMAKE_PREFIX_PATH) + list(APPEND _candidates + "${_p}/include/eigen3" + "${_p}/include" # legacy fallback + ) + endforeach() + + set(_found "") + foreach(_inc IN LISTS _candidates) + if(EXISTS "${_inc}/Eigen/Dense" AND EXISTS "${_inc}/unsupported/Eigen/CXX11/Tensor") + set(_found "${_inc}") + break() + endif() + endforeach() + + if(_found) + set(Eigen_INCLUDE_DIR "${_found}" CACHE PATH "Eigen include root (expects Eigen/ and unsupported/)" FORCE) + message(STATUS "[SCIRun] Eigen_INCLUDE_DIR -> '${Eigen_INCLUDE_DIR}' (contains Eigen and unsupported)") + set(_eigen_ok TRUE) + endif() +endif() + +# If we still don’t have unsupported, warn loudly (this will cause compile errors later) +if(NOT _eigen_ok) + # Try to at least find Eigen/Dense to help with diagnostics + set(_fallback "") + foreach(_p IN LISTS CMAKE_PREFIX_PATH) + foreach(_inc IN ITEMS "${_p}/include/eigen3" "${_p}/include") + if(EXISTS "${_inc}/Eigen/Dense") + set(_fallback "${_inc}") + break() + endif() + endforeach() + if(_fallback) + break() + endif() + endforeach() + + if(_fallback) + set(Eigen_INCLUDE_DIR "${_fallback}" CACHE PATH "Eigen include root (no unsupported found)" FORCE) + message(WARNING + "[SCIRun] Found Eigen at '${Eigen_INCLUDE_DIR}', but 'unsupported/Eigen/CXX11/Tensor' is missing.\n" + " Ensure the Eigen external installs the 'unsupported' directory (Eigen 3.4 install puts both under include/eigen3).") + else() + # Clear incorrect cache if present + if(Eigen_INCLUDE_DIR) + message(WARNING "[SCIRun] Eigen_INCLUDE_DIR='${Eigen_INCLUDE_DIR}' does not contain Eigen/Dense. Clearing.") + unset(Eigen_INCLUDE_DIR CACHE) + unset(Eigen_INCLUDE_DIR) + endif() + endif() +endif() + # Print diagnostics message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index b30fd935ff..309eac7dbe 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -44,6 +44,14 @@ SCIRUN_ADD_LIBRARY(Core_Python ${Core_Python_SRCS} ) +if(BUILD_WITH_PYTHON) + # PUBLIC so any target that links Core_Python also sees BUILD_WITH_PYTHON + target_compile_definitions(Core_Python PUBLIC BUILD_WITH_PYTHON) +else() + # Optional: prevent building this lib at all if Python is off + message(STATUS "BUILD_WITH_PYTHON=OFF, Core_Python will not be used") +endif() + if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_Core_Python) endif() diff --git a/src/Core/Python/PythonInterpreter.cc b/src/Core/Python/PythonInterpreter.cc index 5b2ddeb184..bdcebe410d 100644 --- a/src/Core/Python/PythonInterpreter.cc +++ b/src/Core/Python/PythonInterpreter.cc @@ -250,49 +250,171 @@ bool needsSpecialPythonPathTreatment(const std::string& commandLine) #endif } -void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreatment, const boost::filesystem::path& libPath) +void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreatment, + const boost::filesystem::path& libPath) { PRINT_PY_INIT_DEBUG(1); - using namespace boost::python; + using namespace boost::python; - PythonInterpreterPrivate::lock_type lock( this->private_->get_mutex() ); + PythonInterpreterPrivate::lock_type lock(this->private_->get_mutex()); PRINT_PY_INIT_DEBUG(2); - // Register C++ to Python type converters - //RegisterToPythonConverters(); - - // Add the extension modules - PyImport_AppendInittab( "interpreter", PyInit_interpreter ); - PyImport_AppendInittab( "SCIRunPythonAPI", PyInit_SCIRunPythonAPI ); - for ( module_list_type::iterator it = this->private_->modules_.begin(); - it != this->private_->modules_.end(); ++it ) + + // Register built-in extension modules BEFORE initialization (still allowed) + PyImport_AppendInittab("interpreter", PyInit_interpreter); + PyImport_AppendInittab("SCIRunPythonAPI", PyInit_SCIRunPythonAPI); + for (module_list_type::iterator it = this->private_->modules_.begin(); + it != this->private_->modules_.end(); ++it) { - PyImport_AppendInittab( ( *it ).first.c_str(), ( *it ).second ); + PyImport_AppendInittab((*it).first.c_str(), (*it).second); } PRINT_PY_INIT_DEBUG(3); - //std::wcerr << "initialize_eventhandler: program name=" << this->private_->programName() << std::endl; - Py_SetProgramName(const_cast< wchar_t* >(this->private_->programName())); - PRINT_PY_INIT_DEBUG(4); - //std::wcout << "lib_path: " << lib_path.wstring() << std::endl; +#if PY_VERSION_HEX >= 0x03080000 + // ----------------------------- + // Modern init path (Python >=3.8) + // ----------------------------- + // Build a list of module search paths (as wide strings). + std::vector search_paths; + +#if defined(_WIN32) + const std::wstring PATH_SEP(L";"); // not used in PyConfig, but kept for clarity + boost::filesystem::path lib_path = libPath; + boost::filesystem::path top_lib_path = lib_path / PYTHONPATH / PYTHONNAME; + boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; + boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; + + // Historically you only used top + site on Windows. + search_paths.push_back(top_lib_path.wstring()); + search_paths.push_back(site_lib_path.wstring()); + +#elif defined(__APPLE__) + const std::wstring PATH_SEP(L":"); // not used in PyConfig, but kept for clarity + boost::filesystem::path lib_path = libPath.parent_path(); + + std::vector lib_path_list; + lib_path_list.push_back(lib_path.parent_path() / boost::filesystem::path("Frameworks") / PYTHONPATH); + lib_path_list.push_back(lib_path / PYTHONPATH); + lib_path_list.push_back(lib_path.parent_path() / PYTHONPATH); + + if (needsSpecialPythonPathTreatment) + { + boost::filesystem::path full_lib_path(PYTHONLIBDIR); + full_lib_path /= PYTHONLIB; + lib_path_list.push_back(full_lib_path); + } + + for (size_t i = 0; i < lib_path_list.size(); ++i) + { + const auto& path = lib_path_list[i]; + boost::filesystem::path plat_lib_path = path / "plat-darwin"; // keep legacy layout if present + boost::filesystem::path dynload_lib_path= path / "lib-dynload"; + boost::filesystem::path site_lib_path = path / "site-packages"; + + search_paths.push_back(path.wstring()); + search_paths.push_back(plat_lib_path.wstring()); + search_paths.push_back(dynload_lib_path.wstring()); + search_paths.push_back(site_lib_path.wstring()); + } + +#else + // Linux and other Unix + const std::wstring PATH_SEP(L":"); // not used in PyConfig, but kept for clarity + boost::filesystem::path lib_path = libPath; + boost::filesystem::path top_lib_path = lib_path / PYTHONPATH; + boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; + boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; + boost::filesystem::path plat_lib_path = top_lib_path / "plat-linux"; + + search_paths.push_back(top_lib_path.wstring()); + search_paths.push_back(plat_lib_path.wstring()); + search_paths.push_back(dynload_lib_path.wstring()); + search_paths.push_back(site_lib_path.wstring()); +#endif + + // ----------------------------- + // PyPreConfig / PyConfig setup + // ----------------------------- + PyStatus status; + PyPreConfig preconfig; + PyConfig config; + + // If you previously set Py_IgnoreEnvironmentFlag = 1, use "isolated" preinit. + PyPreConfig_InitIsolatedConfig(&preconfig); + status = Py_PreInitialize(&preconfig); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); // exits with message + } + + // Start from isolated defaults (equivalent to ignoring env, no signal handlers, etc.) + PyConfig_InitIsolatedConfig(&config); + + // Replace deprecated Py_SetProgramName(...) with config.program_name + // (Use your stored wide program name) + { + const wchar_t* prog = this->private_->programName(); + status = PyConfig_SetString(&config, &config.program_name, prog); + if (PyStatus_Exception(status)) { + PyConfig_Clear(&config); + Py_ExitStatusException(status); + } + } + + // Replace global flags: + // Py_IgnoreEnvironmentFlag = 1 -> config.use_environment = 0 + // Py_InspectFlag = 1 -> config.inspect = 1 + // Py_OptimizeFlag = 2 -> config.optimization_level = 2 + // Py_NoSiteFlag = 1 (non-Windows)-> config.site_import = 0 + config.use_environment = 0; + config.inspect = 1; + config.optimization_level = 2; +#if !defined(_WIN32) + config.site_import = 0; +#endif + + // Populate module_search_paths (replacement for Py_SetPath) + // NOTE: PyConfig expects absolute, existing directories; add only those that exist. + for (const auto& wpath : search_paths) + { + if (!wpath.empty()) { + // Optional: skip non-existing paths to avoid warnings + // (Converting back to narrow only for filesystem exists check if needed) + // Here we trust the layout and append directly: + status = PyWideStringList_Append(&config.module_search_paths, wpath.c_str()); + if (PyStatus_Exception(status)) { + PyConfig_Clear(&config); + Py_ExitStatusException(status); + } + } + } + + // Finalize initialization + status = Py_InitializeFromConfig(&config); + PyConfig_Clear(&config); + if (PyStatus_Exception(status)) { + Py_ExitStatusException(status); + } + + PRINT_PY_INIT_DEBUG(8); + +#else + // ------------------------------- + // Legacy fallback (Python < 3.8) + // ------------------------------- + Py_SetProgramName(const_cast(this->private_->programName())); + std::wstringstream lib_paths; -#if defined( _WIN32 ) +# if defined(_WIN32) const std::wstring PATH_SEP(L";"); -#else +# else const std::wstring PATH_SEP(L":"); -#endif - PRINT_PY_INIT_DEBUG(5); -#if defined( __APPLE__ ) +# endif + +# if defined(__APPLE__) boost::filesystem::path lib_path = libPath.parent_path(); std::vector lib_path_list; - // relative paths - PRINT_PY_INIT_DEBUG(lib_path); - PRINT_PY_INIT_DEBUG(boost::filesystem::path(PYTHONPATH)); lib_path_list.push_back(lib_path.parent_path() / boost::filesystem::path("Frameworks") / PYTHONPATH); - PRINT_PY_INIT_DEBUG(lib_path_list.back()); lib_path_list.push_back(lib_path / PYTHONPATH); - PRINT_PY_INIT_DEBUG(lib_path_list.back()); lib_path_list.push_back(lib_path.parent_path() / PYTHONPATH); - PRINT_PY_INIT_DEBUG(lib_path_list.back()); if (needsSpecialPythonPathTreatment) { @@ -301,104 +423,95 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat lib_path_list.push_back(full_lib_path); } - for ( size_t i = 0; i < lib_path_list.size(); ++i ) + for (size_t i = 0; i < lib_path_list.size(); ++i) { auto path = lib_path_list[i]; boost::filesystem::path plat_lib_path = path / "plat-darwin"; boost::filesystem::path dynload_lib_path = path / "lib-dynload"; boost::filesystem::path site_lib_path = path / "site-packages"; - if (i > 0) - { - lib_paths << PATH_SEP; - } + if (i > 0) lib_paths << PATH_SEP; lib_paths << path.wstring() << PATH_SEP << plat_lib_path.wstring() << PATH_SEP << dynload_lib_path.wstring() << PATH_SEP << site_lib_path.wstring(); } + Py_SetPath(lib_paths.str().c_str()); - Py_SetPath( lib_paths.str().c_str() ); -#elif defined (_WIN32) - boost::filesystem::path lib_path = libPath;// Application::Instance().executablePath(); - boost::filesystem::path top_lib_path = lib_path / PYTHONPATH / PYTHONNAME; - //std::cout << "top_lib_path: " << top_lib_path.string() << std::endl; - boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; - //std::cout << "dynload_lib_path: " << dynload_lib_path.string() << std::endl; - boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; - //std::cout << "site_lib_path: " << site_lib_path.string() << std::endl; - lib_paths << top_lib_path.wstring() << PATH_SEP - << site_lib_path.wstring(); - //std::wcout << "lib_paths final: " << lib_paths.str() << std::endl; - Py_SetPath( lib_paths.str().c_str() ); - PRINT_PY_INIT_DEBUG(6); -#else - // linux... - boost::filesystem::path lib_path = libPath; - boost::filesystem::path top_lib_path = lib_path / PYTHONPATH; - boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; - boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; - boost::filesystem::path plat_lib_path = top_lib_path / "plat-linux"; - lib_paths << top_lib_path.wstring() << PATH_SEP - << plat_lib_path.wstring() << PATH_SEP - << dynload_lib_path.wstring() << PATH_SEP - << site_lib_path.wstring(); - Py_SetPath( lib_paths.str().c_str() ); -#endif +# elif defined(_WIN32) + { + boost::filesystem::path lib_path = libPath; + boost::filesystem::path top_lib_path = lib_path / PYTHONPATH / PYTHONNAME; + boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; + lib_paths << top_lib_path.wstring() << PATH_SEP + << site_lib_path.wstring(); + Py_SetPath(lib_paths.str().c_str()); + } +# else + { + boost::filesystem::path lib_path = libPath; + boost::filesystem::path top_lib_path = lib_path / PYTHONPATH; + boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; + boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; + boost::filesystem::path plat_lib_path = top_lib_path / "plat-linux"; + lib_paths << top_lib_path.wstring() << PATH_SEP + << plat_lib_path.wstring() << PATH_SEP + << dynload_lib_path.wstring() << PATH_SEP + << site_lib_path.wstring(); + Py_SetPath(lib_paths.str().c_str()); + } +# endif - // TODO: remove debug print when confident python initialization is stable - //std::wcerr << lib_paths.str() << std::endl; - PRINT_PY_INIT_DEBUG(7); Py_IgnoreEnvironmentFlag = 1; Py_InspectFlag = 1; Py_OptimizeFlag = 2; -#if !defined( _WIN32 ) +# if !defined(_WIN32) Py_NoSiteFlag = 1; -#endif +# endif + Py_Initialize(); PRINT_PY_INIT_DEBUG(8); - // Create the compiler object - PyRun_SimpleString( "from codeop import CommandCompiler\n" - "__internal_compiler = CommandCompiler()\n" ); - boost::python::object main_module = boost::python::import( "__main__" ); - boost::python::object main_namespace = main_module.attr( "__dict__" ); - this->private_->compiler_ = main_namespace[ "__internal_compiler" ]; - this->private_->globals_ = main_namespace; - PRINT_PY_INIT_DEBUG(9); - // Set up the prompt strings - PyRun_SimpleString( "import sys\n" - "try:\n" - "\tsys.ps1\n" - "except AttributeError:\n" - "\tsys.ps1 = \">>> \"\n" - "try:\n" - "\tsys.ps2\n" - "except AttributeError:\n" - "\tsys.ps2 = \"... \"\n" ); - boost::python::object sys_module = main_namespace[ "sys" ]; - boost::python::object sys_namespace = sys_module.attr( "__dict__" ); - this->private_->prompt1_ = boost::python::extract< std::string >( sys_namespace[ "ps1" ] ); - this->private_->prompt2_ = boost::python::extract< std::string >( sys_namespace[ "ps2" ] ); - PRINT_PY_INIT_DEBUG(10); - // Hook up the I/O - PyRun_SimpleString( "import interpreter\n" - "__term_io = interpreter.terminalio()\n" - "__term_err = interpreter.terminalerr()\n" ); - PyRun_SimpleString( "import sys\n" - "sys.stdin = __term_io\n" - "sys.stdout = __term_io\n" - "sys.stderr = __term_err\n" ); +#endif // PY_VERSION_HEX >= 0x03080000 + + PyRun_SimpleString( + "from codeop import CommandCompiler\n" + "__internal_compiler = CommandCompiler()\n" ); + + boost::python::object main_module = boost::python::import("__main__"); + boost::python::object main_namespace = main_module.attr("__dict__"); + this->private_->compiler_ = main_namespace["__internal_compiler"]; + this->private_->globals_ = main_namespace; + + PyRun_SimpleString( + "import sys\n" + "try:\n" + "\tsys.ps1\n" + "except AttributeError:\n" + "\tsys.ps1 = \">>> \"\n" + "try:\n" + "\tsys.ps2\n" + "except AttributeError:\n" + "\tsys.ps2 = \"... \"\n"); + + boost::python::object sys_module = main_namespace["sys"]; + boost::python::object sys_namespace = sys_module.attr("__dict__"); + this->private_->prompt1_ = boost::python::extract(sys_namespace["ps1"]); + this->private_->prompt2_ = boost::python::extract(sys_namespace["ps2"]); PyRun_SimpleString( + "import interpreter\n" + "__term_io = interpreter.terminalio()\n" + "__term_err = interpreter.terminalerr()\n" + "import sys\n" + "sys.stdin = __term_io\n" + "sys.stdout = __term_io\n" + "sys.stderr = __term_err\n" "import atexit\n" "def quit_gracefully():\n" "\tprint('Goodbye!')\n" "atexit.register(quit_gracefully)\n" ); - PRINT_PY_INIT_DEBUG(11); - // Remove intermediate python variables - PyRun_SimpleString( "del (interpreter, __internal_compiler, __term_io, __term_err)\n" ); - PRINT_PY_INIT_DEBUG(12); + PyRun_SimpleString("del (interpreter, __internal_compiler, __term_io, __term_err)\n"); this->private_->initialized_ = true; PRINT_PY_INIT_DEBUG(999); diff --git a/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc b/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc index da1e57999b..1fe74479fb 100644 --- a/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc +++ b/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc @@ -31,6 +31,7 @@ #include #include #include +#include using namespace SCIRun::Dataflow::Networks; using namespace SCIRun::Dataflow::State; @@ -59,19 +60,31 @@ namespace return fullBasePath; } + fs::path diffPath(const fs::path& basePath, const fs::path& newPath) { - auto fullBasePath = addSlash(basePath); - auto tmpPath = newPath; - fs::path diffpath; + // Make sure base has a trailing separator (by your rule) + const fs::path fullBasePath = addSlash(basePath); + + fs::path tmpPath = newPath; + fs::path diffpath; // will accumulate the relative pieces without extension + + // Build the relative (stem-only) path from newPath up to fullBasePath while (addSlash(tmpPath) != fullBasePath) { + // Prepend stem (filename without extension) to diffpath diffpath = tmpPath.stem() / diffpath; tmpPath = tmpPath.parent_path(); } - auto filename = diffpath.leaf().string() + newPath.extension().string(); - diffpath.remove_leaf() /= filename; + // Take the last component (currently stem-only) and replace its extension + fs::path filename = diffpath.filename(); // e.g. "foo" + filename.replace_extension(newPath.extension()); // becomes "foo.ext" + + // Move diffpath to its parent and append the updated filename + diffpath.remove_filename(); // modern replacement for remove_leaf() + diffpath /= filename; + return diffpath; } } diff --git a/src/Modules/DataIO/ReadField.cc b/src/Modules/DataIO/ReadField.cc index 82e2a31c09..e06668a46b 100644 --- a/src/Modules/DataIO/ReadField.cc +++ b/src/Modules/DataIO/ReadField.cc @@ -99,5 +99,5 @@ ReadField::execute() bool ReadField::useCustomImporter(const std::string& filename) const { - return boost::filesystem::extension(filename) != ".fld"; + return boost::filesystem::path(filename).extension() != ".fld"; } diff --git a/src/Modules/DataIO/WriteField.cc b/src/Modules/DataIO/WriteField.cc index 332eb60944..5fafe90531 100644 --- a/src/Modules/DataIO/WriteField.cc +++ b/src/Modules/DataIO/WriteField.cc @@ -121,7 +121,7 @@ bool WriteField::useCustomExporter(const std::string& filename) const { auto ft = cstate()->getValue(Variables::FileTypeName).toString(); LOG_DEBUG("WriteField with filetype {}", ft); - auto ret = boost::filesystem::extension(filename) != ".fld"; + auto ret = boost::filesystem::path(filename).extension() != ".fld"; filetype_ = ft.find("SCIRun Field ASCII") != std::string::npos ? "ASCII" : "Binary"; From 362c7819e5503f6833fa15c04df3d5882efe7778 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Feb 2026 11:22:58 -0700 Subject: [PATCH 042/140] cleaver path --- Superbuild/Superbuild.cmake | 32 +++++++ src/CMakeLists.txt | 34 +++++--- src/Core/Algorithms/Field/CMakeLists.txt | 104 ++++++++++++++++++++--- 3 files changed, 147 insertions(+), 23 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index b1e1c848e4..e2675e626a 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -631,6 +631,23 @@ if(DEFINED SQLite_INCLUDE_DIR) set(SQLite3_INCLUDE_DIR "${SQLite_INCLUDE_DIR}" CACHE PATH "Alias: SQLite3 include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_INCLUDE_DIR:PATH=${SQLite3_INCLUDE_DIR}") endif() +# ---- Cleaver2 uppercase aliases for inner CMake (legacy/consistent names) ---- +if(DEFINED Cleaver2_INCLUDE_DIR) + list(APPEND SCIRUN_CACHE_ARGS + "-DCLEAVER2_INCLUDE:PATH=${Cleaver2_INCLUDE_DIR}" + "-DCLEAVER2_INCLUDE_DIR:PATH=${Cleaver2_INCLUDE_DIR}" + ) +endif() +if(DEFINED Cleaver2_LIB_DIR) + list(APPEND SCIRUN_CACHE_ARGS + "-DCLEAVER2_LIBRARY_DIR:PATH=${Cleaver2_LIB_DIR}" + "-DCLEAVER2_LIB_DIR:PATH=${Cleaver2_LIB_DIR}" + ) +endif() +# Library logical name (import lib on Windows will be resolved by consumers) +list(APPEND SCIRUN_CACHE_ARGS + "-DCLEAVER2_LIBRARY:STRING=cleaver2" +) # --- Ensure SQLite hints are present AFTER SCIRUN_CACHE_ARGS is created --- if(TARGET SQLite_external) ExternalProject_Get_Property(SQLite_external INSTALL_DIR) @@ -914,3 +931,18 @@ if(TARGET Eigen_external) DIRS "${_eigen_inc}" ) endif() + +# --- Gate SCIRun configure on Cleaver2 headers (vec3.h) --- +if(TARGET Cleaver2_external) + # Expose a phony target for the copy step so we can depend on it + ExternalProject_Add_StepTargets(Cleaver2_external copy_headers) + + ExternalProject_Get_Property(Cleaver2_external INSTALL_DIR) + _sb_scirun_wait_for(NAME cleaver2 + FILES "${INSTALL_DIR}/include/cleaver2/vec3.h" + DIRS "${INSTALL_DIR}/include/cleaver2" + ) + + # Ensure SCIRun waits specifically for the header copy step to complete + add_dependencies(SCIRun_external Cleaver2_external-copy_headers) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d8ba23389d..db6b9af44f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -929,24 +929,20 @@ endif() # Helper: validate a cached include dir (VAR) by checking it contains REL_HEADER. # If empty or incorrect, auto-derive from CMAKE_PREFIX_PATH and cache the fix. function(_ensure_header _var_name _rel_header) - # current value (from cache or parent) set(_val "${${_var_name}}") - - # Decide if current value is valid set(_valid FALSE) if(_val AND EXISTS "${_val}/${_rel_header}") set(_valid TRUE) endif() if(NOT _valid) - # Try to auto-derive from CMAKE_PREFIX_PATH: look for include dirs that contain the header + # Try to derive from CMAKE_PREFIX_PATH by probing /include set(_candidates) if(CMAKE_PREFIX_PATH) foreach(_p IN LISTS CMAKE_PREFIX_PATH) list(APPEND _candidates "${_p}/include") endforeach() endif() - set(_found "") foreach(_inc IN LISTS _candidates) if(EXISTS "${_inc}/${_rel_header}") @@ -956,19 +952,16 @@ function(_ensure_header _var_name _rel_header) endforeach() if(_found) - # Cache-stabilize the corrected value set(${_var_name} "${_found}" CACHE PATH "${_var_name}" FORCE) message(STATUS "[SCIRun] Fixed ${_var_name} -> '${_found}' (found '${_rel_header}')") else() - # Clear wrong cached value if it was set but invalid - if(_val AND NOT _valid) + if(_val) message(WARNING "[SCIRun] ${_var_name} ('${_val}') does not contain '${_rel_header}'. Clearing.") endif() unset(${_var_name} CACHE) unset(${_var_name}) endif() else() - # Keep and cache-stabilize a correct value set(${_var_name} "${_val}" CACHE PATH "${_var_name}" FORCE) endif() endfunction() @@ -1054,7 +1047,29 @@ if(NOT _eigen_ok) endif() endif() +# ---- Cleaver2 normalization + validation ---- +# Superbuild exports one of: +# Cleaver2_INCLUDE_DIR / Cleaver2_LIB_DIR +# CLEAVER2_INCLUDE / CLEAVER2_INCLUDE_DIR / CLEAVER2_LIBRARY_DIR +# Normalize to SCIRun’s internal names for consistency. +if(DEFINED Cleaver2_INCLUDE_DIR AND NOT DEFINED CLEAVER2_INCLUDE) + set(CLEAVER2_INCLUDE "${Cleaver2_INCLUDE_DIR}") +endif() +if(DEFINED Cleaver2_LIB_DIR AND NOT DEFINED CLEAVER2_LIBRARY_DIR) + set(CLEAVER2_LIBRARY_DIR "${Cleaver2_LIB_DIR}") +endif() +_ensure_header(CLEAVER2_INCLUDE "cleaver2/vec3.h") +# Create easy-to-use internal aliases (like you do for other externals) +if(DEFINED CLEAVER2_INCLUDE) + set(SCI_CLEAVER2_INCLUDE "${CLEAVER2_INCLUDE}" CACHE PATH "Cleaver2 include root (contains 'cleaver2/')" FORCE) +endif() +if(DEFINED CLEAVER2_LIBRARY_DIR) + set(SCI_CLEAVER2_LIBRARY_DIR "${CLEAVER2_LIBRARY_DIR}" CACHE PATH "Cleaver2 library directory" FORCE) +endif() + # Print diagnostics +message(STATUS "CLEAVER2_INCLUDE='${CLEAVER2_INCLUDE}'") +message(STATUS "CLEAVER2_LIBRARY_DIR='${CLEAVER2_LIBRARY_DIR}'") message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") message(STATUS "LODEPNG_INCLUDE_DIR='${LODEPNG_INCLUDE_DIR}'") @@ -1104,7 +1119,6 @@ set(_SCIRUN_INCLUDE_DIRS ${SCI_CLEAVER2_INCLUDE} ) - # If the second include dir wasn't set, derive it from the first if(NOT FREETYPE_INCLUDE_DIR2 OR NOT EXISTS "${FREETYPE_INCLUDE_DIR2}/freetype/config/ftheader.h") if(Freetype_INCLUDE_DIR AND EXISTS "${Freetype_INCLUDE_DIR}/freetype2/freetype/config/ftheader.h") diff --git a/src/Core/Algorithms/Field/CMakeLists.txt b/src/Core/Algorithms/Field/CMakeLists.txt index e929ba4805..9b90dd91b3 100644 --- a/src/Core/Algorithms/Field/CMakeLists.txt +++ b/src/Core/Algorithms/Field/CMakeLists.txt @@ -25,15 +25,16 @@ # DEALINGS IN THE SOFTWARE. # +# ---- Algorithms_Field ---- -SET(Algorithms_Field_SRCS +set(Algorithms_Field_SRCS ReportFieldInfoAlgorithm.cc InterfaceWithCleaver2Algorithm.cc CalculateNodeLocationFrequencyAlgorithm.cc RefineTetMeshLocallyAlgorithm.cc ) -SET(Algorithms_Field_HEADERS +set(Algorithms_Field_HEADERS ReportFieldInfoAlgorithm.h InterfaceWithCleaver2Algorithm.h CalculateNodeLocationFrequencyAlgorithm.h @@ -46,17 +47,94 @@ SCIRUN_ADD_LIBRARY(Algorithms_Field ${Algorithms_Field_SRCS} ) -TARGET_LINK_LIBRARIES(Algorithms_Field - Core_Datatypes - Core_Datatypes_Legacy_Field - Algorithms_Base - Core_Algorithms_Legacy_Fields - ${SCI_BOOST_LIBRARY} - ${SCI_CLEAVER2_LIBRARY} +# Keep original shared define behavior +target_compile_definitions(Algorithms_Field + PRIVATE $<$:BUILD_Algorithms_Field> ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Algorithms_Field) -ENDIF(BUILD_SHARED_LIBS) +# ----------------------------------------------------------------------------------- +# Cleaver2 consumption via superbuild-exported paths (no find_package needed) +# Expected variables (from superbuild -> top-level normalization): +# CLEAVER2_INCLUDE - parent that contains 'cleaver2/vec3.h' (e.g. .../Install/Cleaver2_external/include) +# CLEAVER2_LIBRARY_DIR - directory with the Cleaver2 library file +# (Optional aliases: SCI_CLEAVER2_INCLUDE, SCI_CLEAVER2_LIBRARY_DIR) +# ----------------------------------------------------------------------------------- -SCIRUN_ADD_TEST_DIR(Tests) +# Prefer normalized aliases if defined +if(DEFINED SCI_CLEAVER2_INCLUDE) + set(_c2_inc "${SCI_CLEAVER2_INCLUDE}") +else() + set(_c2_inc "${CLEAVER2_INCLUDE}") +endif() +if(DEFINED SCI_CLEAVER2_LIBRARY_DIR) + set(_c2_libdir "${SCI_CLEAVER2_LIBRARY_DIR}") +else() + set(_c2_libdir "${CLEAVER2_LIBRARY_DIR}") +endif() + +# Validate presence +if(NOT _c2_inc OR NOT EXISTS "${_c2_inc}/cleaver2/vec3.h") + message(FATAL_ERROR + "Cleaver2 include directory is missing or invalid.\n" + " CLEAVER2_INCLUDE='${CLEAVER2_INCLUDE}' ; SCI_CLEAVER2_INCLUDE='${SCI_CLEAVER2_INCLUDE}'\n" + " Expected: '/cleaver2/vec3.h'.") +endif() + +if(NOT _c2_libdir OR NOT EXISTS "${_c2_libdir}") + message(FATAL_ERROR + "Cleaver2 library directory missing.\n" + " CLEAVER2_LIBRARY_DIR='${CLEAVER2_LIBRARY_DIR}' ; SCI_CLEAVER2_LIBRARY_DIR='${SCI_CLEAVER2_LIBRARY_DIR}'") +endif() + +# Locate the library file inside the provided lib dir +set(_c2_libpath "") +if(WIN32) + # Windows import/static lib + foreach(_cand IN ITEMS "cleaver2.lib" "libcleaver2.lib") + if(EXISTS "${_c2_libdir}/${_cand}") + set(_c2_libpath "${_c2_libdir}/${_cand}") + break() + endif() + endforeach() +elseif(APPLE) + foreach(_cand IN ITEMS "libcleaver2.dylib" "libcleaver2.a") + if(EXISTS "${_c2_libdir}/${_cand}") + set(_c2_libpath "${_c2_libdir}/${_cand}") + break() + endif() + endforeach() +else() + foreach(_cand IN ITEMS "libcleaver2.so" "libcleaver2.a") + if(EXISTS "${_c2_libdir}/${_cand}") + set(_c2_libpath "${_c2_libdir}/${_cand}") + break() + endif() + endforeach() +endif() + +if(NOT _c2_libpath) + message(FATAL_ERROR + "Could not find Cleaver2 library under '${_c2_libdir}'.\n" + "Expected one of: cleaver2(.lib|.so|.dylib|.a)") +endif() + +# Define a private imported target so include usage is target-scoped and modern +add_library(Cleaver2::cleaver2 UNKNOWN IMPORTED) +set_target_properties(Cleaver2::cleaver2 PROPERTIES + IMPORTED_LOCATION "${_c2_libpath}" + INTERFACE_INCLUDE_DIRECTORIES "${_c2_inc}" +) + +# Link everything +target_link_libraries(Algorithms_Field + PRIVATE + Core_Datatypes + Core_Datatypes_Legacy_Field + Algorithms_Base + Core_Algorithms_Legacy_Fields + ${SCI_BOOST_LIBRARY} + Cleaver2::cleaver2 +) + +# Tests +SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file From 876f951cc3ef4d4051374af93f14bcc2e4f0068d Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Feb 2026 13:58:39 -0700 Subject: [PATCH 043/140] boost python --- Superbuild/BoostExternal.cmake | 2 +- src/Core/Python/CMakeLists.txt | 224 +++++++++++++++++++++++---------- 2 files changed, 160 insertions(+), 66 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 206e7d5745..1320217b42 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -42,7 +42,7 @@ set(_BOOST_LIBS ) # Optional compiled libs (usually OFF) -option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" OFF) +option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" ON) option(BOOST_ENABLE_MPI "Build Boost.MPI if MPI is available" OFF) option(BOOST_ENABLE_TEST "Build Boost.Test (unit test framework)" OFF) diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 309eac7dbe..5a93f9990b 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,6 +25,7 @@ # DEALINGS IN THE SOFTWARE. # +# ---- Core/Python CMake ---- # --- Sources --- set(Core_Python_SRCS @@ -38,55 +39,48 @@ set(Core_Python_HEADERS share.h ) -# --- Library target (uses project macro from top-level) --- +# Library target (uses project macro from top-level) SCIRUN_ADD_LIBRARY(Core_Python ${Core_Python_HEADERS} ${Core_Python_SRCS} ) +# Preserve original shared define behavior +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Core_Python) +endif() + +# If Python enabled, expose BUILD_WITH_PYTHON so dependents (and sources) can #ifdef code if(BUILD_WITH_PYTHON) - # PUBLIC so any target that links Core_Python also sees BUILD_WITH_PYTHON target_compile_definitions(Core_Python PUBLIC BUILD_WITH_PYTHON) else() - # Optional: prevent building this lib at all if Python is off - message(STATUS "BUILD_WITH_PYTHON=OFF, Core_Python will not be used") -endif() - -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Core_Python) + message(STATUS "BUILD_WITH_PYTHON=OFF, Core_Python will be built in no-Python mode (code must #ifdef accordingly).") endif() -# --- Unit tests subdir (kept as in your original) --- +# --- Unit tests --- SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== -# Cross-platform Python detection (modern-first, legacy fallback for older CMake) +# Python detection (modern-first, robust fallbacks) # ==================================================================================== - -# We’ll try in this order: -# 1) FindPython (CMake >= ~3.15) -# 2) FindPython3 (CMake >= ~3.12) -# 3) Legacy FindPythonInterp + FindPythonLibs (CMake >= 3.0) -# -# The result will be: -# - Imported target to link: Python::Python -# - Variables available: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES -# +# Result: +# - Imported target: Python::Python +# - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES set(_SCIRUN_PY_OK FALSE) -# Prefer FindPython (generic) +# Prefer FindPython (CMake ≥ 3.15) find_package(Python QUIET COMPONENTS Interpreter Development) if(Python_Interpreter_FOUND AND Python_Development_FOUND) set(_SCIRUN_PY_OK TRUE) -elseif(NOT _SCIRUN_PY_OK) - # Try Python3 module +endif() + +# Fallback: FindPython3 (CMake ≥ 3.12) +if(NOT _SCIRUN_PY_OK) find_package(Python3 QUIET COMPONENTS Interpreter Development) if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - # Normalize variable names to Python_* so later logic is uniform - set(Python_EXECUTABLE "${Python3_EXECUTABLE}") + set(Python_EXECUTABLE "${Python3_EXECUTABLE}") set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") set(Python_LIBRARIES "${Python3_LIBRARIES}") - # Create a consistent alias so we can always link Python::Python if(TARGET Python3::Python AND NOT TARGET Python::Python) add_library(Python::Python ALIAS Python3::Python) endif() @@ -94,29 +88,22 @@ elseif(NOT _SCIRUN_PY_OK) endif() endif() -# Legacy fallback (older CMake or no module found) +# Legacy fallback (older CMake) if(NOT _SCIRUN_PY_OK) find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) # populates PYTHON_INCLUDE_DIRS / PYTHON_LIBRARIES in old module - # Normalize variable names + find_package(PythonLibs REQUIRED) set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") set(Python_LIBRARIES "${PYTHON_LIBRARIES}") - # Provide a compatible imported target Python::Python if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) set_target_properties(Python::Python PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" ) if(WIN32) - # On Windows, the link library is an import library (.lib) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB "${Python_LIBRARIES}" - ) + set_target_properties(Python::Python PROPERTIES IMPORTED_IMPLIB "${Python_LIBRARIES}") else() - set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION "${Python_LIBRARIES}" - ) + set_target_properties(Python::Python PROPERTIES IMPORTED_LOCATION "${Python_LIBRARIES}") endif() endif() set(_SCIRUN_PY_OK TRUE) @@ -127,11 +114,10 @@ if(NOT _SCIRUN_PY_OK) endif() # ==================================================================================== -# Platform-specific compile definitions derived from the detected Python +# Platform-specific compile definitions (PYTHONPATH, etc.) # ==================================================================================== -# Compute a best-effort Python module search path (a parent of site-packages) -# Ask Python directly (portable across platforms/envs). +# Ask Python for site-packages and use its parent (matches legacy semantics) set(_SCIRUN_PY_QUERY "import sys,sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" ) @@ -141,13 +127,12 @@ execute_process( ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) -# Parent of site-packages (keeps your original semantics) set(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}") if(_PYTHON_MODULE_SEARCH_PARENT) get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) endif() -# Compute a name like pythonXY (e.g., python311) if your code needs it +# Compute 'pythonXY' (e.g., python313) if code uses it set(_SCIRUN_PY_NAME_QUERY "import sys; print('python{}{}'.format(sys.version_info.major, sys.version_info.minor))") execute_process( COMMAND "${Python_EXECUTABLE}" -c "${_SCIRUN_PY_NAME_QUERY}" @@ -156,10 +141,9 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -# For macOS legacy defines that your code used: +# Extract a representative library and its dir (used on macOS legacy code) set(_PYTHON_LIB "") if(Python_LIBRARIES) - # If multiple libs are reported, take the first if(Python_LIBRARIES MATCHES ";") list(GET Python_LIBRARIES 0 _PYTHON_LIB) else() @@ -168,34 +152,27 @@ if(Python_LIBRARIES) endif() get_filename_component(_PYTHON_LIBDIR "${_PYTHON_LIB}" DIRECTORY) -# Apply your original platform-specific -D defines, but using the computed values +# Apply defines (use add_definitions to preserve your existing behavior / L"...") if(WIN32) - # Original: -DPYTHONPATH=L"${SCI_PYTHON_MODULE_PARENT_PATH}" -DPYTHONNAME=L"${SCI_PYTHON_NAME}" add_definitions( -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" -DPYTHONNAME=L"${_PYTHON_NAME}" ) elseif(APPLE) - # Original: also defined PYTHONLIBDIR and PYTHONLIB on macOS add_definitions( -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" -DPYTHONLIBDIR=L"${_PYTHON_LIBDIR}" -DPYTHONLIB=L"${_PYTHON_LIB}" ) else() - # Linux/Unix: only PYTHONPATH originally - add_definitions( - -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" - ) + add_definitions(-DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}") endif() # ==================================================================================== # Link dependencies # ==================================================================================== -# Note: -# - Python::Python carries include dirs and platform-correct libs -# - Keep your other links intact +# Always link the Python imported target target_link_libraries(Core_Python PRIVATE Python::Python @@ -205,18 +182,135 @@ target_link_libraries(Core_Python Core_Datatypes_Legacy_Field ) -# Optional: a little debug output so you can verify in configure logs -message(STATUS "[Core/Python] Using Python executable: ${Python_EXECUTABLE}") -message(STATUS "[Core/Python] Using Python include(s): ${Python_INCLUDE_DIRS}") -message(STATUS "[Core/Python] Using Python library : ${Python_LIBRARIES}") -message(STATUS "[Core/Python] PYTHONPATH define : ${_PYTHON_MODULE_SEARCH_PARENT}") -if(APPLE) - message(STATUS "[Core/Python] macOS PYTHONLIBDIR : ${_PYTHON_LIBDIR}") - message(STATUS "[Core/Python] macOS PYTHONLIB : ${_PYTHON_LIB}") +# ------------------------------------------------------------------------------------ +# Boost.Python handling +# ------------------------------------------------------------------------------------ +# Strategy: +# - On MSVC (Windows): Prefer Boost's MSVC auto-link. DO NOT name 'boost_python...' +# explicitly; the headers inject the correct /DEFAULTLIB:libboost_python.... +# - Provide an opt-in to link explicitly by detecting the actual .lib names built by b2. +# - On non-Windows, explicitly link Boost.Python (no auto-link there). + +# Option to force explicit linking on Windows (helps when auto-link is altered by other macros) +option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on auto-link" OFF) + +# Compute Python major.minor digits for filename patterns +# (derive from modern FindPython or legacy values) +set(_SCIRUN_PY_M "") +if(DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) + set(_SCIRUN_PY_M "${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") +else() + # Fallback: try to query from interpreter + execute_process( + COMMAND "${Python_EXECUTABLE}" -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')" + OUTPUT_VARIABLE _SCIRUN_PY_M + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +if(MSVC) + if(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK) + # Disable autolink for Boost.Python on this target + target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB) + + # Find actual lib files under Boost's lib dir (Debug has '-gd-') + set(_bp_dbg "") + set(_bp_rel "") + + if(DEFINED SCI_BOOST_LIBRARY_DIR) + file(GLOB _bp_dbg + "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" + ) + file(GLOB _bp_rel_all + "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" + ) + foreach(_cand IN LISTS _bp_rel_all) + if(NOT _cand MATCHES "-gd-") + list(APPEND _bp_rel "${_cand}") + endif() + endforeach() + endif() + + list(SORT _bp_dbg) ; list(REVERSE _bp_dbg) + list(SORT _bp_rel) ; list(REVERSE _bp_rel) + + list(GET _bp_dbg 0 SCI_BOOST_PYTHON_LIB_DEBUG ) + list(GET _bp_rel 0 SCI_BOOST_PYTHON_LIB_RELEASE) + + if(NOT SCI_BOOST_PYTHON_LIB_DEBUG OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}") + message(FATAL_ERROR + "Boost.Python (Debug) not found under '${SCI_BOOST_LIBRARY_DIR}'. " + "Expected 'libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib'") + endif() + if(NOT SCI_BOOST_PYTHON_LIB_RELEASE OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_RELEASE}") + message(FATAL_ERROR + "Boost.Python (Release) not found under '${SCI_BOOST_LIBRARY_DIR}'. " + "Expected 'libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib' (no -gd-)") + endif() + + target_link_libraries(Core_Python PRIVATE + $<$:"${SCI_BOOST_PYTHON_LIB_DEBUG}"> + $<$:"${SCI_BOOST_PYTHON_LIB_RELEASE}"> + $<$:"${SCI_BOOST_PYTHON_LIB_RELEASE}"> + $<$:"${SCI_BOOST_PYTHON_LIB_RELEASE}"> + ) + message(STATUS "[Core/Python] Explicitly linking Boost.Python: ") + message(STATUS " Debug : ${SCI_BOOST_PYTHON_LIB_DEBUG}") + message(STATUS " Release : ${SCI_BOOST_PYTHON_LIB_RELEASE}") + else() + # Auto-link path: do not add boost_python*.lib explicitly. + # Ensure the Boost lib dir is on the search path (top-level does this), + # and avoid defines like BOOST_ALL_NO_LIB / BOOST_PYTHON_NO_LIB here. + message(STATUS "[Core/Python] Using MSVC autolink for Boost.Python (recommended).") + endif() +else() + # Non-Windows: explicitly link Boost.Python + set(_bp_names + "boost_python${_SCIRUN_PY_M}" + "boost_python3" + "boost_python" + ) + set(_bp_lib "") + + # Prefer the superbuild lib dir if present + if(DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") + find_library(BOOST_PYTHON_LIB + NAMES ${_bp_names} + PATHS "${SCI_BOOST_LIBRARY_DIR}" "${SCI_BOOST_PREFIX}/lib" "${SCI_BOOST_PREFIX}/lib64" + NO_DEFAULT_PATH + ) + set(_bp_lib "${BOOST_PYTHON_LIB}") + endif() + + # Fallback to default search paths if still not found + if(NOT _bp_lib) + find_library(BOOST_PYTHON_LIB NAMES ${_bp_names}) + set(_bp_lib "${BOOST_PYTHON_LIB}") + endif() + + if(_bp_lib) + target_link_libraries(Core_Python PRIVATE "${_bp_lib}") + message(STATUS "[Core/Python] Linking Boost.Python: ${_bp_lib}") + else() + message(WARNING + "[Core/Python] Boost.Python library not found on this platform. " + "Link may fail if Boost.Python symbols are used.") + endif() endif() -# Keep your existing debug-only definition (unchanged) +# Debug-only macro (preserve your behavior) set_target_properties(Core_Python PROPERTIES COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON" -) \ No newline at end of file +) + +# Helpful diagnostics +message(STATUS "[Core/Python] Python executable: ${Python_EXECUTABLE}") +message(STATUS "[Core/Python] Python include(s): ${Python_INCLUDE_DIRS}") +message(STATUS "[Core/Python] Python libraries : ${Python_LIBRARIES}") +message(STATUS "[Core/Python] PYTHONPATH : ${_PYTHON_MODULE_SEARCH_PARENT}") +if(APPLE) + message(STATUS "[Core/Python] macOS PYTHONLIBDIR: ${_PYTHON_LIBDIR}") + message(STATUS "[Core/Python] macOS PYTHONLIB : ${_PYTHON_LIB}") +endif() \ No newline at end of file From 7ca6d58baece7fe989f86078614bb5031c6fb532 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Feb 2026 16:51:31 -0700 Subject: [PATCH 044/140] removed some linking errors --- src/Core/Algorithms/Math/CMakeLists.txt | 1 + src/Core/Python/CMakeLists.txt | 116 ++++++++++++------------ 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/src/Core/Algorithms/Math/CMakeLists.txt b/src/Core/Algorithms/Math/CMakeLists.txt index ae073d05b0..fdca64efe0 100644 --- a/src/Core/Algorithms/Math/CMakeLists.txt +++ b/src/Core/Algorithms/Math/CMakeLists.txt @@ -84,6 +84,7 @@ SCIRUN_ADD_LIBRARY(Algorithms_Math TARGET_LINK_LIBRARIES(Algorithms_Math Core_Datatypes + Core_Datatypes_Legacy_Base Core_Thread Algorithms_Base Core_Parser diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 5a93f9990b..2b6ce2f1f8 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -65,7 +65,7 @@ SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== # Result: # - Imported target: Python::Python -# - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES +# - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES, Python_VERSION_* set(_SCIRUN_PY_OK FALSE) # Prefer FindPython (CMake ≥ 3.15) @@ -114,34 +114,37 @@ if(NOT _SCIRUN_PY_OK) endif() # ==================================================================================== -# Platform-specific compile definitions (PYTHONPATH, etc.) +# Platform-specific compile definitions (PYTHONPATH, etc.) -- robust version # ==================================================================================== -# Ask Python for site-packages and use its parent (matches legacy semantics) +# Compute "pythonXY" (e.g., python313) from detected version variables +set(_PYTHON_NAME "") +if(DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) + set(_PYTHON_NAME "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") +endif() + +# Compute parent of site-packages (purelib/platlib) using Python (safe: fully quoted string) +# Note: semicolons inside the quoted string are part of Python code and NOT parsed by CMake. set(_SCIRUN_PY_QUERY - "import sys,sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" + "import sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" ) +set(_PY_SITE "") execute_process( COMMAND "${Python_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" OUTPUT_VARIABLE _PY_SITE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE ) -set(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}") -if(_PYTHON_MODULE_SEARCH_PARENT) + +# Parent folder of site-packages +set(_PYTHON_MODULE_SEARCH_PARENT "") +if(_PY_SITE) get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) + # Normalize slashes so the value is safe in a C string literal L"..." + file(TO_CMAKE_PATH "${_PYTHON_MODULE_SEARCH_PARENT}" _PYTHON_MODULE_SEARCH_PARENT) endif() -# Compute 'pythonXY' (e.g., python313) if code uses it -set(_SCIRUN_PY_NAME_QUERY "import sys; print('python{}{}'.format(sys.version_info.major, sys.version_info.minor))") -execute_process( - COMMAND "${Python_EXECUTABLE}" -c "${_SCIRUN_PY_NAME_QUERY}" - OUTPUT_VARIABLE _PYTHON_NAME - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -# Extract a representative library and its dir (used on macOS legacy code) +# Extract a representative Python lib path and its dir (used on macOS legacy code) set(_PYTHON_LIB "") if(Python_LIBRARIES) if(Python_LIBRARIES MATCHES ";") @@ -152,20 +155,23 @@ if(Python_LIBRARIES) endif() get_filename_component(_PYTHON_LIBDIR "${_PYTHON_LIB}" DIRECTORY) -# Apply defines (use add_definitions to preserve your existing behavior / L"...") +# ALWAYS define these macros so sources never see an undefined identifier. +# We use target_compile_definitions and inject *wide* string literals L"...". if(WIN32) - add_definitions( - -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" - -DPYTHONNAME=L"${_PYTHON_NAME}" + target_compile_definitions(Core_Python PRIVATE + "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" + "PYTHONNAME=L\"${_PYTHON_NAME}\"" ) elseif(APPLE) - add_definitions( - -DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}" - -DPYTHONLIBDIR=L"${_PYTHON_LIBDIR}" - -DPYTHONLIB=L"${_PYTHON_LIB}" + target_compile_definitions(Core_Python PRIVATE + "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" + "PYTHONLIBDIR=L\"${_PYTHON_LIBDIR}\"" + "PYTHONLIB=L\"${_PYTHON_LIB}\"" ) else() - add_definitions(-DPYTHONPATH=L"${_PYTHON_MODULE_SEARCH_PARENT}") + target_compile_definitions(Core_Python PRIVATE + "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" + ) endif() # ==================================================================================== @@ -191,22 +197,12 @@ target_link_libraries(Core_Python # - Provide an opt-in to link explicitly by detecting the actual .lib names built by b2. # - On non-Windows, explicitly link Boost.Python (no auto-link there). -# Option to force explicit linking on Windows (helps when auto-link is altered by other macros) option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on auto-link" OFF) # Compute Python major.minor digits for filename patterns -# (derive from modern FindPython or legacy values) set(_SCIRUN_PY_M "") if(DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) set(_SCIRUN_PY_M "${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") -else() - # Fallback: try to query from interpreter - execute_process( - COMMAND "${Python_EXECUTABLE}" -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')" - OUTPUT_VARIABLE _SCIRUN_PY_M - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) endif() if(MSVC) @@ -215,28 +211,34 @@ if(MSVC) target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB) # Find actual lib files under Boost's lib dir (Debug has '-gd-') - set(_bp_dbg "") - set(_bp_rel "") + set(SCI_BOOST_PYTHON_LIB_DEBUG "") + set(SCI_BOOST_PYTHON_LIB_RELEASE "") - if(DEFINED SCI_BOOST_LIBRARY_DIR) + if(DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") file(GLOB _bp_dbg "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" ) file(GLOB _bp_rel_all "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" ) + set(_bp_rel "") foreach(_cand IN LISTS _bp_rel_all) if(NOT _cand MATCHES "-gd-") list(APPEND _bp_rel "${_cand}") endif() endforeach() - endif() - - list(SORT _bp_dbg) ; list(REVERSE _bp_dbg) - list(SORT _bp_rel) ; list(REVERSE _bp_rel) - list(GET _bp_dbg 0 SCI_BOOST_PYTHON_LIB_DEBUG ) - list(GET _bp_rel 0 SCI_BOOST_PYTHON_LIB_RELEASE) + if(_bp_dbg) + list(SORT _bp_dbg) + list(REVERSE _bp_dbg) + list(GET _bp_dbg 0 SCI_BOOST_PYTHON_LIB_DEBUG) + endif() + if(_bp_rel) + list(SORT _bp_rel) + list(REVERSE _bp_rel) + list(GET _bp_rel 0 SCI_BOOST_PYTHON_LIB_RELEASE) + endif() + endif() if(NOT SCI_BOOST_PYTHON_LIB_DEBUG OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}") message(FATAL_ERROR @@ -249,19 +251,18 @@ if(MSVC) "Expected 'libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib' (no -gd-)") endif() + # Per-config link of the actual .lib files target_link_libraries(Core_Python PRIVATE - $<$:"${SCI_BOOST_PYTHON_LIB_DEBUG}"> - $<$:"${SCI_BOOST_PYTHON_LIB_RELEASE}"> - $<$:"${SCI_BOOST_PYTHON_LIB_RELEASE}"> - $<$:"${SCI_BOOST_PYTHON_LIB_RELEASE}"> + debug "${SCI_BOOST_PYTHON_LIB_DEBUG}" + optimized "${SCI_BOOST_PYTHON_LIB_RELEASE}" ) - message(STATUS "[Core/Python] Explicitly linking Boost.Python: ") + message(STATUS "[Core/Python] Explicitly linking Boost.Python:") message(STATUS " Debug : ${SCI_BOOST_PYTHON_LIB_DEBUG}") message(STATUS " Release : ${SCI_BOOST_PYTHON_LIB_RELEASE}") else() # Auto-link path: do not add boost_python*.lib explicitly. - # Ensure the Boost lib dir is on the search path (top-level does this), - # and avoid defines like BOOST_ALL_NO_LIB / BOOST_PYTHON_NO_LIB here. + # Ensure the Boost lib dir is in the search path (top-level handles it). + # Avoid defines like BOOST_ALL_NO_LIB / BOOST_PYTHON_NO_LIB here. message(STATUS "[Core/Python] Using MSVC autolink for Boost.Python (recommended).") endif() else() @@ -306,11 +307,8 @@ set_target_properties(Core_Python ) # Helpful diagnostics -message(STATUS "[Core/Python] Python executable: ${Python_EXECUTABLE}") -message(STATUS "[Core/Python] Python include(s): ${Python_INCLUDE_DIRS}") -message(STATUS "[Core/Python] Python libraries : ${Python_LIBRARIES}") -message(STATUS "[Core/Python] PYTHONPATH : ${_PYTHON_MODULE_SEARCH_PARENT}") -if(APPLE) - message(STATUS "[Core/Python] macOS PYTHONLIBDIR: ${_PYTHON_LIBDIR}") - message(STATUS "[Core/Python] macOS PYTHONLIB : ${_PYTHON_LIB}") -endif() \ No newline at end of file +message(STATUS "[Core/Python] Python executable : ${Python_EXECUTABLE}") +message(STATUS "[Core/Python] Python include(s) : ${Python_INCLUDE_DIRS}") +message(STATUS "[Core/Python] Python libraries : ${Python_LIBRARIES}") +message(STATUS "[Core/Python] PYTHONNAME : ${_PYTHON_NAME}") +message(STATUS "[Core/Python] PYTHONPATH : ${_PYTHON_MODULE_SEARCH_PARENT}") \ No newline at end of file From e24d46a7d8140d8480e290705e5d6804d0497cfa Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Feb 2026 14:33:10 -0700 Subject: [PATCH 045/140] adding libs to link --- Superbuild/Superbuild.cmake | 2 + .../Algorithms/Legacy/Fields/CMakeLists.txt | 65 +++++++++ src/Core/Algorithms/Math/CMakeLists.txt | 2 + src/Core/Python/CMakeLists.txt | 130 ++++++++++-------- src/Graphics/Datatypes/CMakeLists.txt | 1 + src/Graphics/Glyphs/CMakeLists.txt | 1 + src/Graphics/Widgets/CMakeLists.txt | 1 + src/Modules/Math/CMakeLists.txt | 5 + 8 files changed, 148 insertions(+), 59 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index e2675e626a..a1c77933b5 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -504,6 +504,8 @@ if(BUILD_WITH_PYTHON) "-DPython3_EXECUTABLE:FILEPATH=${Python_EXECUTABLE}" "-DPython3_INCLUDE_DIRS:PATH=${Python_INCLUDE_DIRS}" "-DPython3_LIBRARIES:STRING=${Python_LIBRARIES}" + "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" + "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" ) endif() diff --git a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt index 542aff02ea..6103c457f9 100644 --- a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt @@ -229,6 +229,70 @@ SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_Fields ${Core_Algorithms_Legacy_Fields_SRCS} ) +# ========================================================== +# Teem discovery (same pattern as Core_Geometry_Primitives) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Fields Core_Datatypes Core_Datatypes_Legacy_Field @@ -240,6 +304,7 @@ TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Fields Core_Geometry_Primitives Core_Basis Algorithms_Math + ${_teem_target} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Math/CMakeLists.txt b/src/Core/Algorithms/Math/CMakeLists.txt index fdca64efe0..c12c958250 100644 --- a/src/Core/Algorithms/Math/CMakeLists.txt +++ b/src/Core/Algorithms/Math/CMakeLists.txt @@ -85,6 +85,8 @@ SCIRUN_ADD_LIBRARY(Algorithms_Math TARGET_LINK_LIBRARIES(Algorithms_Math Core_Datatypes Core_Datatypes_Legacy_Base + Core_Datatypes_Legacy_Field + Core_Math Core_Thread Algorithms_Base Core_Parser diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 2b6ce2f1f8..a8aaaf4df5 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -27,6 +27,8 @@ # ---- Core/Python CMake ---- +cmake_minimum_required(VERSION 3.16) # adjust if your project requires different + # --- Sources --- set(Core_Python_SRCS PythonInterpreter.cc @@ -51,6 +53,7 @@ if(BUILD_SHARED_LIBS) endif() # If Python enabled, expose BUILD_WITH_PYTHON so dependents (and sources) can #ifdef code +# IMPORTANT: Keep this PUBLIC only for the macro, not for third-party headers/libs. if(BUILD_WITH_PYTHON) target_compile_definitions(Core_Python PUBLIC BUILD_WITH_PYTHON) else() @@ -62,10 +65,10 @@ SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== # Python detection (modern-first, robust fallbacks) -# ==================================================================================== # Result: # - Imported target: Python::Python # - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES, Python_VERSION_* +# ==================================================================================== set(_SCIRUN_PY_OK FALSE) # Prefer FindPython (CMake ≥ 3.15) @@ -114,7 +117,7 @@ if(NOT _SCIRUN_PY_OK) endif() # ==================================================================================== -# Platform-specific compile definitions (PYTHONPATH, etc.) -- robust version +# Platform-specific compile definitions (PYTHONPATH, etc.) # ==================================================================================== # Compute "pythonXY" (e.g., python313) from detected version variables @@ -123,8 +126,7 @@ if(DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) set(_PYTHON_NAME "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") endif() -# Compute parent of site-packages (purelib/platlib) using Python (safe: fully quoted string) -# Note: semicolons inside the quoted string are part of Python code and NOT parsed by CMake. +# Compute parent of site-packages using Python set(_SCIRUN_PY_QUERY "import sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" ) @@ -140,11 +142,10 @@ execute_process( set(_PYTHON_MODULE_SEARCH_PARENT "") if(_PY_SITE) get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) - # Normalize slashes so the value is safe in a C string literal L"..." file(TO_CMAKE_PATH "${_PYTHON_MODULE_SEARCH_PARENT}" _PYTHON_MODULE_SEARCH_PARENT) endif() -# Extract a representative Python lib path and its dir (used on macOS legacy code) +# Extract a representative Python lib path and its dir (used for legacy macOS code paths) set(_PYTHON_LIB "") if(Python_LIBRARIES) if(Python_LIBRARIES MATCHES ";") @@ -156,7 +157,6 @@ endif() get_filename_component(_PYTHON_LIBDIR "${_PYTHON_LIB}" DIRECTORY) # ALWAYS define these macros so sources never see an undefined identifier. -# We use target_compile_definitions and inject *wide* string literals L"...". if(WIN32) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" @@ -175,29 +175,25 @@ else() endif() # ==================================================================================== -# Link dependencies +# Link dependencies (all PRIVATE to avoid leaking third-party includes to dependents) # ==================================================================================== - -# Always link the Python imported target target_link_libraries(Core_Python PRIVATE Python::Python - ${SCI_BOOST_LIBRARY} + ${SCI_BOOST_LIBRARY} # keep existing boost meta-lib if your project uses it Core_Matlab Core_Datatypes Core_Datatypes_Legacy_Field ) -# ------------------------------------------------------------------------------------ +# ==================================================================================== # Boost.Python handling -# ------------------------------------------------------------------------------------ -# Strategy: -# - On MSVC (Windows): Prefer Boost's MSVC auto-link. DO NOT name 'boost_python...' -# explicitly; the headers inject the correct /DEFAULTLIB:libboost_python.... -# - Provide an opt-in to link explicitly by detecting the actual .lib names built by b2. -# - On non-Windows, explicitly link Boost.Python (no auto-link there). +# - Recommended on MSVC: turn on explicit linking to tolerate 'lib' prefix naming. +# - Otherwise: use MSVC autolink (ensure Boost lib dir is on link path). +# ==================================================================================== -option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on auto-link" OFF) +# Toggle (pass from superbuild via -DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK=ON) +option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on autolink" OFF) # Compute Python major.minor digits for filename patterns set(_SCIRUN_PY_M "") @@ -207,66 +203,82 @@ endif() if(MSVC) if(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK) - # Disable autolink for Boost.Python on this target + # Disable Boost autolink on this target target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB) - # Find actual lib files under Boost's lib dir (Debug has '-gd-') - set(SCI_BOOST_PYTHON_LIB_DEBUG "") - set(SCI_BOOST_PYTHON_LIB_RELEASE "") + # The Boost lib directory should be passed from the superbuild: + # -DSCI_BOOST_LIBRARY_DIR=E:/.../Externals/Install/Boost_external/lib + if (NOT DEFINED SCI_BOOST_LIBRARY_DIR OR NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") + message(FATAL_ERROR "SCI_BOOST_LIBRARY_DIR is not set or does not exist. Pass it from the superbuild.") + endif() - if(DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") - file(GLOB _bp_dbg - "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" - ) - file(GLOB _bp_rel_all - "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" - ) - set(_bp_rel "") - foreach(_cand IN LISTS _bp_rel_all) - if(NOT _cand MATCHES "-gd-") - list(APPEND _bp_rel "${_cand}") - endif() - endforeach() - - if(_bp_dbg) - list(SORT _bp_dbg) - list(REVERSE _bp_dbg) - list(GET _bp_dbg 0 SCI_BOOST_PYTHON_LIB_DEBUG) - endif() - if(_bp_rel) - list(SORT _bp_rel) - list(REVERSE _bp_rel) - list(GET _bp_rel 0 SCI_BOOST_PYTHON_LIB_RELEASE) + # Gather candidates for Debug (-gd-) with and without 'lib' prefix + file(GLOB _bp_dbg_candidates + "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" + ) + + # Gather candidates for Release (no -gd-) with and without 'lib' prefix + file(GLOB _bp_rel_candidates_all + "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" + ) + # Filter out accidental debug files from the release list + set(_bp_rel_candidates "") + foreach(_cand IN LISTS _bp_rel_candidates_all) + if(NOT _cand MATCHES "-gd-") + list(APPEND _bp_rel_candidates "${_cand}") endif() + endforeach() + + # Pick the most specific candidate (sort + take last) + if(_bp_dbg_candidates) + list(SORT _bp_dbg_candidates) + list(REVERSE _bp_dbg_candidates) + list(GET _bp_dbg_candidates 0 SCI_BOOST_PYTHON_LIB_DEBUG) + endif() + if(_bp_rel_candidates) + list(SORT _bp_rel_candidates) + list(REVERSE _bp_rel_candidates) + list(GET _bp_rel_candidates 0 SCI_BOOST_PYTHON_LIB_RELEASE) endif() if(NOT SCI_BOOST_PYTHON_LIB_DEBUG OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}") message(FATAL_ERROR - "Boost.Python (Debug) not found under '${SCI_BOOST_LIBRARY_DIR}'. " - "Expected 'libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib'") + "Boost.Python Debug lib not found under '${SCI_BOOST_LIBRARY_DIR}'. " + "Looked for libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib or boost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" + ) endif() if(NOT SCI_BOOST_PYTHON_LIB_RELEASE OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_RELEASE}") message(FATAL_ERROR - "Boost.Python (Release) not found under '${SCI_BOOST_LIBRARY_DIR}'. " - "Expected 'libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib' (no -gd-)") + "Boost.Python Release lib not found under '${SCI_BOOST_LIBRARY_DIR}'. " + "Looked for libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib or boost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" + ) endif() - # Per-config link of the actual .lib files + # Ensure the linker searches that folder + target_link_directories(Core_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") + + # Link the exact files (per-config) target_link_libraries(Core_Python PRIVATE debug "${SCI_BOOST_PYTHON_LIB_DEBUG}" optimized "${SCI_BOOST_PYTHON_LIB_RELEASE}" ) + message(STATUS "[Core/Python] Explicitly linking Boost.Python:") message(STATUS " Debug : ${SCI_BOOST_PYTHON_LIB_DEBUG}") message(STATUS " Release : ${SCI_BOOST_PYTHON_LIB_RELEASE}") else() - # Auto-link path: do not add boost_python*.lib explicitly. - # Ensure the Boost lib dir is in the search path (top-level handles it). - # Avoid defines like BOOST_ALL_NO_LIB / BOOST_PYTHON_NO_LIB here. - message(STATUS "[Core/Python] Using MSVC autolink for Boost.Python (recommended).") + # Keep autolink, but help the linker find the folder + if (DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") + target_link_directories(Core_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") + endif() + message(STATUS "[Core/Python] Using MSVC autolink for Boost.Python (ensure lib names match).") + # For debugging the exact name autolink requests, uncomment: + # target_compile_definitions(Core_Python PRIVATE BOOST_LIB_DIAGNOSTIC) endif() else() - # Non-Windows: explicitly link Boost.Python + # Non-Windows: explicitly link Boost.Python by name if available set(_bp_names "boost_python${_SCIRUN_PY_M}" "boost_python3" @@ -274,7 +286,7 @@ else() ) set(_bp_lib "") - # Prefer the superbuild lib dir if present + # Prefer superbuild lib dir if present if(DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") find_library(BOOST_PYTHON_LIB NAMES ${_bp_names} @@ -284,7 +296,7 @@ else() set(_bp_lib "${BOOST_PYTHON_LIB}") endif() - # Fallback to default search paths if still not found + # Fallback to default search paths if(NOT _bp_lib) find_library(BOOST_PYTHON_LIB NAMES ${_bp_names}) set(_bp_lib "${BOOST_PYTHON_LIB}") @@ -300,7 +312,7 @@ else() endif() endif() -# Debug-only macro (preserve your behavior) +# Debug-only macro (matches your previous behavior) set_target_properties(Core_Python PROPERTIES COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON" diff --git a/src/Graphics/Datatypes/CMakeLists.txt b/src/Graphics/Datatypes/CMakeLists.txt index e345c037c3..9358921dc5 100644 --- a/src/Graphics/Datatypes/CMakeLists.txt +++ b/src/Graphics/Datatypes/CMakeLists.txt @@ -46,6 +46,7 @@ SCIRUN_ADD_LIBRARY(Graphics_Datatypes TARGET_LINK_LIBRARIES(Graphics_Datatypes Core_Datatypes Core_Geometry_Primitives + Core_Persistent ) IF(BUILD_SHARED_LIBS) diff --git a/src/Graphics/Glyphs/CMakeLists.txt b/src/Graphics/Glyphs/CMakeLists.txt index b0953be2d8..249c706162 100644 --- a/src/Graphics/Glyphs/CMakeLists.txt +++ b/src/Graphics/Glyphs/CMakeLists.txt @@ -52,6 +52,7 @@ TARGET_LINK_LIBRARIES(Graphics_Glyphs Core_Math Core_Datatypes Core_Geometry_Primitives + Core_Utils Graphics_Datatypes ${OPENGL_LIBRARIES} ${SCI_SPIRE_LIBRARY} diff --git a/src/Graphics/Widgets/CMakeLists.txt b/src/Graphics/Widgets/CMakeLists.txt index 16b03012ec..5b446941b3 100644 --- a/src/Graphics/Widgets/CMakeLists.txt +++ b/src/Graphics/Widgets/CMakeLists.txt @@ -65,6 +65,7 @@ TARGET_LINK_LIBRARIES(Graphics_Widgets Core_Math Core_Datatypes Core_Geometry_Primitives + Core_Persistent Graphics_Glyphs Graphics_Datatypes ${OPENGL_LIBRARIES} diff --git a/src/Modules/Math/CMakeLists.txt b/src/Modules/Math/CMakeLists.txt index bee677dd68..798bcc1777 100644 --- a/src/Modules/Math/CMakeLists.txt +++ b/src/Modules/Math/CMakeLists.txt @@ -92,9 +92,14 @@ SCIRUN_ADD_LIBRARY(Modules_Math ${Modules_Math_SRCS} ) +if (MSVC) + target_compile_options(Modules_Math PRIVATE /showIncludes) +endif() + TARGET_LINK_LIBRARIES(Modules_Math Dataflow_Network Core_Datatypes + Core_Datatypes_Legacy_Field Algorithms_Math ) From c07019a3a8304eb1df19a4c1d62282893161e109 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Feb 2026 16:02:12 -0700 Subject: [PATCH 046/140] teem link --- .../Algorithms/Legacy/Fields/CMakeLists.txt | 126 ++++++++++++------ 1 file changed, 88 insertions(+), 38 deletions(-) diff --git a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt index 6103c457f9..52316ab2d9 100644 --- a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt @@ -230,83 +230,133 @@ SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_Fields ) # ========================================================== -# Teem discovery (same pattern as Core_Geometry_Primitives) +# Teem discovery (prefer config, fallback to superbuild vars) +# Static consumption: ensure headers do NOT use dllimport. # ========================================================== -# Prefer a config package if available +# Expect these from superbuild: +# Teem_INCLUDE_DIR -> <.../Externals/Install/Teem_external>/include +# Teem_LIB_DIR -> <.../Externals/Install/Teem_external>/lib + +# Prefer a config package if available (uncommon for Teem, but harmless): find_package(Teem CONFIG QUIET) if(TARGET Teem::teem) + # If this comes from a config that exported a SHARED target, + # force static-consumer macros at call sites: + set_property(TARGET Teem::teem APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS "TEEM_STATIC" + ) + # If your Teem was built with zlib and the config exposes it, link transitively. + # Otherwise we’ll add Zlib explicitly below when we link this target. set(_teem_target Teem::teem) else() - # Fallback to superbuild exports if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) message(FATAL_ERROR "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") endif() - set(_teem_lib "") + # Resolve static library for each config + set(_TEEM_LIB_RELEASE "") + set(_TEEM_LIB_DEBUG "") + if(WIN32) + # Common names used by Teem on Windows if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.lib") + endif() + + # Debug may use the same name or have a trailing 'd' + if(EXISTS "${Teem_LIB_DIR}/teemd.lib") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/teemd.lib") + elseif(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteemd.lib") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteemd.lib") elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.lib") endif() elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + # Prefer static if available + if(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.a") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.a") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + # Shared exists but we still treat consumer as static (headers need static defines) + set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.dylib") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.dylib") endif() else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + if(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.a") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.a") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.so") + set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.so") endif() endif() - if(NOT _teem_lib) - find_library(TEEM_LIBRARY + # Last-resort search + if(NOT _TEEM_LIB_RELEASE) + find_library(TEEM_LIBRARY_RELEASE NAMES teem libteem HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") + if(TEEM_LIBRARY_RELEASE) + set(_TEEM_LIB_RELEASE "${TEEM_LIBRARY_RELEASE}") + set(_TEEM_LIB_DEBUG "${TEEM_LIBRARY_RELEASE}") endif() endif() - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + if(NOT _TEEM_LIB_RELEASE OR NOT EXISTS "${_TEEM_LIB_RELEASE}") message(FATAL_ERROR "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") + "Ensure the Teem external installs a static lib (teem.lib/libteem.a).") endif() - add_library(Teem::teem UNKNOWN IMPORTED) + # Create imported STATIC target and propagate include paths and *static* defines + add_library(Teem::teem STATIC IMPORTED GLOBAL) set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LOCATION_RELEASE "${_TEEM_LIB_RELEASE}" + IMPORTED_LOCATION_DEBUG "${_TEEM_LIB_DEBUG}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + # This disables __declspec(dllimport) in Teem headers for static consumption. + # If you still see __imp_* after a clean rebuild, replace with TEEM_STATIC_DEFINE + # or add module-level defines like AIR_STATIC;NRRD_STATIC, depending on your Teem version. + INTERFACE_COMPILE_DEFINITIONS "TEEM_STATIC" IMPORTED_LINK_INTERFACE_LANGUAGES "C" ) set(_teem_target Teem::teem) endif() -TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Fields - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - Core_Datatypes_Legacy_Bundle - Algorithms_Base - Core_Exceptions_Legacy - Core_Thread - Core_Geometry_Primitives - Core_Basis - Algorithms_Math - ${_teem_target} +# ---- Link this library ---- +# Convert your legacy link line to target-based + PRIVATE for clarity. +target_link_libraries(Core_Algorithms_Legacy_Fields + PRIVATE + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + Core_Datatypes_Legacy_Bundle + Algorithms_Base + Core_Exceptions_Legacy + Core_Thread + Core_Geometry_Primitives + Core_Basis + Algorithms_Math + ${_teem_target} ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_Fields) -ENDIF(BUILD_SHARED_LIBS) +# If your Teem build uses zlib, add it explicitly (static Teem won’t drag it in automatically) +if(TARGET Zlib::Zlib) + target_link_libraries(Core_Algorithms_Legacy_Fields PRIVATE Zlib::Zlib) +endif() + +# Export macro for this DLL, unchanged +if(BUILD_SHARED_LIBS) + target_compile_definitions(Core_Algorithms_Legacy_Fields PRIVATE BUILD_Core_Algorithms_Legacy_Fields) +endif() + From b7b197200d7120740cb007d94f53d0341d792f73 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Feb 2026 16:21:37 -0700 Subject: [PATCH 047/140] fixing python linking errors --- Superbuild/BoostExternal.cmake | 25 +++ Superbuild/PythonExternal.cmake | 15 ++ Superbuild/Superbuild.cmake | 138 ++++++++++++- src/CMakeLists.txt | 75 +++++++ src/Core/Python/CMakeLists.txt | 232 +++++++++++++++------- src/Dataflow/Engine/Python/CMakeLists.txt | 4 + 6 files changed, 411 insertions(+), 78 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 1320217b42..e950644ffa 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -96,6 +96,30 @@ ExternalProject_Get_Property(Boost_external SOURCE_DIR) ExternalProject_Get_Property(Boost_external BINARY_DIR) ExternalProject_Get_Property(Boost_external INSTALL_DIR) +# Optional Python wiring for Boost.Python +set(_B2_PY_ARGS "") +if(BOOST_ENABLE_PYTHON) + set(_PY_LIBDIR "") + if(DEFINED PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") + get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) + elseif(DEFINED PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") + get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) + elseif(DEFINED PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") + set(_PY_LIBDIR "${PYTHON_RUNTIME_DIR}") + endif() + + if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}" AND _PY_LIBDIR AND EXISTS "${_PY_LIBDIR}") + list(APPEND _B2_PY_ARGS + "python=${PY_MAJOR}.${PY_MINOR}" # or hardcode 3.13 + "include=${PYTHON_INCLUDE_DIR}" + "library-path=${_PY_LIBDIR}" + ) + message(STATUS "[Boost_ext] Will build Boost.Python against include='${PYTHON_INCLUDE_DIR}', libdir='${_PY_LIBDIR}'") + else() + message(WARNING "[Boost_ext] BOOST_ENABLE_PYTHON=ON but Python paths are incomplete.") + endif() +endif() + # ========= Cross-platform b2 header staging ========= # 1) Bootstrap b2 if(WIN32) @@ -151,6 +175,7 @@ ExternalProject_Add_Step(Boost_external build_b2_libs ${_B2_VARIANTS} --layout=versioned ${_BOOST_LIBS_B2} + ${_B2_PY_ARGS} --build-dir=${_B2_BUILD_DIR} stage WORKING_DIRECTORY ${SOURCE_DIR} diff --git a/Superbuild/PythonExternal.cmake b/Superbuild/PythonExternal.cmake index 6c50c3b469..f1e5f67afb 100644 --- a/Superbuild/PythonExternal.cmake +++ b/Superbuild/PythonExternal.cmake @@ -255,6 +255,21 @@ ELSE() ENDIF() SET(SCI_PYTHON_USE_FILE ${INSTALL_DIR}/UsePython.cmake) +# ---- Export Python paths to cache so other externals and SCIRun can consume them ---- +set(PYTHON_INCLUDE_DIR "${SCI_PYTHON_INCLUDE}" CACHE PATH "CPython include dir (contains Python.h)" FORCE) +set(PYTHON_PC_INCLUDE_DIR "${SOURCE_DIR}/PC" CACHE PATH "CPython PC include dir (contains pyconfig.h)" FORCE) +set(PYTHON_RUNTIME_DIR "${SCI_PYTHON_LIBRARY_DIR}" CACHE PATH "Folder containing python313[_d].lib/.dll" FORCE) +set(PYTHON_EXECUTABLE "${SCI_PYTHON_EXE}" CACHE FILEPATH "python.exe built by CPython" FORCE) +set(PYTHON_LIBRARY_RELEASE "${SCI_PYTHON_LIBRARY_RELEASE}" CACHE FILEPATH "Release import lib (python313.lib)" FORCE) +set(PYTHON_LIBRARY_DEBUG "${SCI_PYTHON_LIBRARY_DEBUG}" CACHE FILEPATH "Debug import lib (python313_d.lib)" FORCE) + +# Nice for diagnostics +message(STATUS "[Python_external] PYTHON_INCLUDE_DIR = ${PYTHON_INCLUDE_DIR}") +message(STATUS "[Python_external] PYTHON_PC_INCLUDE_DIR = ${PYTHON_PC_INCLUDE_DIR}") +message(STATUS "[Python_external] PYTHON_RUNTIME_DIR = ${PYTHON_RUNTIME_DIR}") +message(STATUS "[Python_external] PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}") +message(STATUS "[Python_external] PYTHON_LIBRARY_RELEASE = ${PYTHON_LIBRARY_RELEASE}") +message(STATUS "[Python_external] PYTHON_LIBRARY_DEBUG = ${PYTHON_LIBRARY_DEBUG}") # Python is special case - normally this should be handled in external library repo CONFIGURE_FILE(${SUPERBUILD_DIR}/PythonConfig.cmake.in ${INSTALL_DIR}/PythonConfig.cmake @ONLY) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index a1c77933b5..9a4559a8ef 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -491,19 +491,99 @@ set(SCIRUN_CACHE_ARGS ) # ========================= -# Forward Python values to SCIRun (inner CMake) +# Forward Python values to SCIRun (inner CMake), version-agnostic # ========================= if(BUILD_WITH_PYTHON) - # New (modern) variables for FindPython in SCIRun subdirs + # Base paths from your external layout + set(_PY_SRC "${ep_base}/Source/Python_external") + set(_PY_PCBUILD "${_PY_SRC}/PCbuild/amd64") + set(_PY_INC "${_PY_SRC}/Include") + set(_PY_PC_INC "${_PY_SRC}/PC") + set(_PY_EXE "${_PY_PCBUILD}/python.exe") + + # Derive MAJOR.MINOR from the built interpreter + set(_PY_MAJ "") + set(_PY_MIN "") + if(EXISTS "${_PY_EXE}") + execute_process( + COMMAND "${_PY_EXE}" -c "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}')" + OUTPUT_VARIABLE _PY_VER_SHORT + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + if(_PY_VER_SHORT MATCHES "^([0-9]+)\\.([0-9]+)$") + set(_PY_MAJ "${CMAKE_MATCH_1}") + set(_PY_MIN "${CMAKE_MATCH_2}") + endif() + endif() + + # Fallback: if the interpreter didn’t run (first configure), try to read cached values you exported + if(NOT _PY_MAJ OR NOT _PY_MIN) + if(DEFINED PY_MAJOR AND DEFINED PY_MINOR) + set(_PY_MAJ "${PY_MAJOR}") + set(_PY_MIN "${PY_MINOR}") + endif() + endif() + + # Construct the Windows import library names: pythonXY(.lib) and pythonXY_d.lib + set(_PY_DIGITS "") + if(_PY_MAJ AND _PY_MIN) + set(_PY_DIGITS "${_PY_MAJ}${_PY_MIN}") # e.g. "313" + else() + # As a last resort, try to detect digits from filename presence in the lib dir + # (See Approach B below for a fuller glob) + message(STATUS "[Python wiring] Could not determine Python version via interpreter; will try folder scan later.") + endif() + + # Resolve actual files in PCbuild/amd64 + set(_PY_LIB_REL "") + set(_PY_LIB_DBG "") + if(_PY_DIGITS AND EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") + set(_PY_LIB_REL "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") + endif() + if(_PY_DIGITS AND EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") + set(_PY_LIB_DBG "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") + endif() + + # If still missing, fall back to a glob (see Approach B) + if(NOT _PY_LIB_REL OR NOT _PY_LIB_DBG) + file(GLOB _py_rel_cand "${_PY_PCBUILD}/python3*.lib") + file(GLOB _py_dbg_cand "${_PY_PCBUILD}/python3*_d.lib") + list(SORT _py_rel_cand) + list(SORT _py_dbg_cand) + list(REVERSE _py_rel_cand) + list(REVERSE _py_dbg_cand) + if(NOT _PY_LIB_REL AND _py_rel_cand) + list(GET _py_rel_cand 0 _PY_LIB_REL) + endif() + if(NOT _PY_LIB_DBG AND _py_dbg_cand) + list(GET _py_dbg_cand 0 _PY_LIB_DBG) + endif() + endif() + + if(NOT (EXISTS "${_PY_LIB_REL}" AND EXISTS "${_PY_LIB_DBG}")) + message(WARNING "[Python wiring] Could not resolve both Python import libs under ${_PY_PCBUILD}. " + "REL='${_PY_LIB_REL}' DBG='${_PY_LIB_DBG}'. " + "First configure after a clean may hit this; they will exist after Python_external builds.") + endif() + + # Append cache args for SCIRun inner build: no version hard-coded list(APPEND SCIRUN_CACHE_ARGS "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" - "-DPython_EXECUTABLE:FILEPATH=${Python_EXECUTABLE}" - "-DPython_INCLUDE_DIRS:PATH=${Python_INCLUDE_DIRS}" - "-DPython_LIBRARIES:STRING=${Python_LIBRARIES}" - # Mirror for FindPython3 in case inner scripts resolve to that module name - "-DPython3_EXECUTABLE:FILEPATH=${Python_EXECUTABLE}" - "-DPython3_INCLUDE_DIRS:PATH=${Python_INCLUDE_DIRS}" - "-DPython3_LIBRARIES:STRING=${Python_LIBRARIES}" + "-DPYTHON_INCLUDE_DIR:PATH=${_PY_INC}" + "-DPYTHON_PC_INCLUDE_DIR:PATH=${_PY_PC_INC}" + "-DPYTHON_EXECUTABLE:FILEPATH=${_PY_EXE}" + "-DPYTHON_RUNTIME_DIR:PATH=${_PY_PCBUILD}" + "-DPYTHON_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}" + "-DPYTHON_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}" + + # Optional hints for legacy find modules + "-DPython_EXECUTABLE:FILEPATH=${_PY_EXE}" + "-DPython_INCLUDE_DIRS:PATH=${_PY_INC};${_PY_PC_INC}" + "-DPython3_EXECUTABLE:FILEPATH=${_PY_EXE}" + "-DPython3_INCLUDE_DIRS:PATH=${_PY_INC};${_PY_PC_INC}" + + # Boost.Python wiring remains as-is "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" ) @@ -560,11 +640,47 @@ endif() if(TARGET Zlib_external) ExternalProject_Get_Property(Zlib_external INSTALL_DIR) set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") + + # Existing hints you already pass: list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" "-DZLIB_USE_STATIC_LIBS:BOOL=ON" ) + + # New: pass the ACTUAL library file (full path). Adjust filename to your build. + if(WIN32) + # If you built static zlib as zlibstatic.lib, set that; otherwise zlib.lib or zlib1.lib + if(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib") + elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlib.lib") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlib.lib") + elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlib1.lib") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlib1.lib") + endif() + elseif(APPLE) + if(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.a") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.a") + elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.dylib") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.dylib") + endif() + else() # Linux/Unix + if(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.a") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.a") + elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.so") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.so") + elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib64/libz.so") + set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib64/libz.so") + endif() + endif() + + if(DEFINED _zlib_lib AND EXISTS "${_zlib_lib}") + list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_LIBRARY:FILEPATH=${_zlib_lib}") + message(STATUS "[superbuild] Zlib library: ${_zlib_lib}") + else() + message(WARNING "[superbuild] Could not resolve ZLIB_LIBRARY at configure time; inner build may still find it via ZLIB_ROOT/CMAKE_PREFIX_PATH.") + endif() + if(DEFINED Zlib_DIR) list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_DIR:PATH=${Zlib_DIR}") else() @@ -860,6 +976,10 @@ if(TARGET Boost_external) add_dependencies(SCIRun_external Boost_external-stage_boost_headers_copy) endif() +if(TARGET Boost_external AND TARGET Python_external) + add_dependencies(Boost_external Python_external) +endif() + # ========================= # Gate SCIRun configure on other externals' headers # ========================= diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bdd99f675a..d997a1b741 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -94,6 +94,81 @@ if(WIN32) endif() endif() +# -------------------------------------------------------------------- +# Imported targets for Zlib and Teem (transitive wiring) +# - Prefer config packages if they exist (ZLIB::ZLIB / Teem::teem) +# - Otherwise, create imported targets from superbuild paths +# - Make Teem::teem depend transitively on Zlib::Zlib +# -------------------------------------------------------------------- + +# Normalize/bridge variables for includes used elsewhere +if(DEFINED ZLIB_INCLUDE_DIR AND NOT DEFINED SCI_ZLIB_INCLUDE) + set(SCI_ZLIB_INCLUDE "${ZLIB_INCLUDE_DIR}") +endif() +# Already present for Teem: SCI_TEEM_INCLUDE + +# 1) Zlib imported target +if(NOT TARGET ZLIB::ZLIB AND NOT TARGET Zlib::Zlib) + # If a package defined ZLIB::ZLIB, prefer it. + # (If CONFIG_STANDARD_EXTERNAL found one earlier, the target may already exist.) + # Otherwise, build an imported target from explicit paths. + if(DEFINED ZLIB_LIBRARY AND EXISTS "${ZLIB_LIBRARY}" AND DEFINED ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") + add_library(Zlib::Zlib UNKNOWN IMPORTED) + set_target_properties(Zlib::Zlib PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + message(STATUS "[SCIRun] Created imported target Zlib::Zlib from explicit paths.") + elseif(TARGET ZLIB::ZLIB) + # OK—package provided it + add_library(Zlib::Zlib ALIAS ZLIB::ZLIB) + message(STATUS "[SCIRun] Using package target ZLIB::ZLIB (aliased to Zlib::Zlib).") + else() + message(WARNING "[SCIRun] Zlib not fully configured yet (need ZLIB_LIBRARY and ZLIB_INCLUDE_DIR). " + "If you are in a first pass before externals install, this can be expected.") + endif() +endif() + +# 2) Teem imported target, transitive to zlib +if(NOT TARGET Teem::teem) + # Prefer a package target if a TeemConfig was found + if(TARGET Teem::Teem OR TARGET Teem::teem) + # Normalize to Teem::teem + if(TARGET Teem::teem) + add_library(Teem__real ALIAS Teem::teem) + else() + add_library(Teem__real ALIAS Teem::Teem) + endif() + add_library(Teem::teem INTERFACE IMPORTED) + if(TARGET Zlib::Zlib) + set_target_properties(Teem::teem PROPERTIES INTERFACE_LINK_LIBRARIES "Teem__real;Zlib::Zlib") + else() + set_target_properties(Teem::teem PROPERTIES INTERFACE_LINK_LIBRARIES "Teem__real") + endif() + message(STATUS "[SCIRun] Teem package target detected; created Teem::teem wrapper with Zlib transitively.") + else() + # Create imported from explicit paths + if(DEFINED Teem_LIBRARY AND EXISTS "${Teem_LIBRARY}" AND DEFINED Teem_INCLUDE_DIR AND EXISTS "${Teem_INCLUDE_DIR}/teem/ten.h") + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${Teem_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + ) + if(TARGET Zlib::Zlib) + set_property(TARGET Teem::teem APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "Zlib::Zlib" + ) + message(STATUS "[SCIRun] Created imported target Teem::teem (transitively links Zlib::Zlib).") + else() + message(WARNING "[SCIRun] Created imported target Teem::teem, but Zlib::Zlib is not available yet.") + endif() + else() + message(WARNING "[SCIRun] Teem not fully configured yet (need Teem_LIBRARY and Teem_INCLUDE_DIR). " + "If you are in a first pass before externals install, this can be expected.") + endif() + endif() +endif() + ############################################################################### # Don't allow the user to build in the src directory... # diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index a8aaaf4df5..091f26737c 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -53,7 +53,6 @@ if(BUILD_SHARED_LIBS) endif() # If Python enabled, expose BUILD_WITH_PYTHON so dependents (and sources) can #ifdef code -# IMPORTANT: Keep this PUBLIC only for the macro, not for third-party headers/libs. if(BUILD_WITH_PYTHON) target_compile_definitions(Core_Python PUBLIC BUILD_WITH_PYTHON) else() @@ -64,52 +63,112 @@ endif() SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== -# Python detection (modern-first, robust fallbacks) -# Result: -# - Imported target: Python::Python -# - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES, Python_VERSION_* +# Python wiring (superbuild-first, robust fallbacks) +# Expected superbuild variables (preferred): +# PYTHON_INCLUDE_DIR -> .../Python_external/Include +# PYTHON_PC_INCLUDE_DIR -> .../Python_external/PC (optional but recommended on Windows) +# PYTHON_LIBRARY_RELEASE -> .../PCbuild/amd64/python313.lib +# PYTHON_LIBRARY_DEBUG -> .../PCbuild/amd64/python313_d.lib +# PYTHON_RUNTIME_DIR -> .../PCbuild/amd64 (optional, for DLLs at runtime) +# PYTHON_EXECUTABLE -> .../PCbuild/amd64/python.exe (optional, used for PYTHONPATH query) # ==================================================================================== + set(_SCIRUN_PY_OK FALSE) +set(_PY_INCLUDE_DIRS "") +set(_PY_EXECUTABLE "") +set(_PY_LIB_DBG "") +set(_PY_LIB_REL "") + +# ---- Path-first: use explicit superbuild variables if provided ---- +if(PYTHON_LIBRARY_DEBUG AND PYTHON_LIBRARY_RELEASE AND PYTHON_INCLUDE_DIR) + if(NOT EXISTS "${PYTHON_LIBRARY_DEBUG}") + message(FATAL_ERROR "PYTHON_LIBRARY_DEBUG does not exist: ${PYTHON_LIBRARY_DEBUG}") + endif() + if(NOT EXISTS "${PYTHON_LIBRARY_RELEASE}") + message(FATAL_ERROR "PYTHON_LIBRARY_RELEASE does not exist: ${PYTHON_LIBRARY_RELEASE}") + endif() + if(NOT EXISTS "${PYTHON_INCLUDE_DIR}") + message(FATAL_ERROR "PYTHON_INCLUDE_DIR does not exist: ${PYTHON_INCLUDE_DIR}") + endif() + + set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") + set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") + + # Includes: Include (always), PC (optional on Windows for pyconfig.h) + list(APPEND _PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") + endif() + + # Imported target with per-config locations + if(NOT TARGET Python::Python) + add_library(Python::Python UNKNOWN IMPORTED) + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" + ) + endif() + + # Provide a best-effort Python_EXECUTABLE for later diagnostics/macros + if(PYTHON_EXECUTABLE AND EXISTS "${PYTHON_EXECUTABLE}") + set(_PY_EXECUTABLE "${PYTHON_EXECUTABLE}") + elseif(PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") + # Common MSVC layout: python.exe next to libs in PCbuild/amd64 + if(EXISTS "${PYTHON_RUNTIME_DIR}/python.exe") + set(_PY_EXECUTABLE "${PYTHON_RUNTIME_DIR}/python.exe") + endif() + endif() -# Prefer FindPython (CMake ≥ 3.15) -find_package(Python QUIET COMPONENTS Interpreter Development) -if(Python_Interpreter_FOUND AND Python_Development_FOUND) set(_SCIRUN_PY_OK TRUE) endif() -# Fallback: FindPython3 (CMake ≥ 3.12) +# ---- Fallback: try modern FindPython / FindPython3 (scoped to superbuild root if hinted) ---- if(NOT _SCIRUN_PY_OK) - find_package(Python3 QUIET COMPONENTS Interpreter Development) - if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - set(Python_EXECUTABLE "${Python3_EXECUTABLE}") - set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") - set(Python_LIBRARIES "${Python3_LIBRARIES}") - if(TARGET Python3::Python AND NOT TARGET Python::Python) - add_library(Python::Python ALIAS Python3::Python) + # If the superbuild gave us a root, hint to CMake + if(DEFINED PYTHON_ROOT_DIR AND EXISTS "${PYTHON_ROOT_DIR}") + set(_PY_HINTS ROOT_DIR "${PYTHON_ROOT_DIR}") + elseif(DEFINED PYTHON_HOME_DIR AND EXISTS "${PYTHON_HOME_DIR}") + set(_PY_HINTS ROOT_DIR "${PYTHON_HOME_DIR}") + else() + set(_PY_HINTS) + endif() + + # Prefer modern module name "Python" (CMake >= 3.15) + find_package(Python QUIET COMPONENTS Interpreter Development ${_PY_HINTS}) + if(Python_Interpreter_FOUND AND Python_Development_FOUND) + if(TARGET Python::Python) + # Good: prefer the imported target directly + set(_SCIRUN_PY_OK TRUE) + set(_PY_EXECUTABLE "${Python_EXECUTABLE}") + # Extract library paths for later macros, if available + set(_PY_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") + # Try to collect per-config (if provided) + # Python::Python usually has single-location; but it's fine for MSVC if it resolves to .lib endif() - set(_SCIRUN_PY_OK TRUE) endif() endif() -# Legacy fallback (older CMake) +# ---- Legacy fallback (really old CMake) ---- if(NOT _SCIRUN_PY_OK) find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) - set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") - set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") - set(Python_LIBRARIES "${PYTHON_LIBRARIES}") if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" + INTERFACE_INCLUDE_DIRECTORIES "${PYTHON_INCLUDE_DIRS}" ) if(WIN32) - set_target_properties(Python::Python PROPERTIES IMPORTED_IMPLIB "${Python_LIBRARIES}") + set_target_properties(Python::Python PROPERTIES IMPORTED_IMPLIB "${PYTHON_LIBRARIES}") else() - set_target_properties(Python::Python PROPERTIES IMPORTED_LOCATION "${Python_LIBRARIES}") + set_target_properties(Python::Python PROPERTIES IMPORTED_LOCATION "${PYTHON_LIBRARIES}") endif() endif() set(_SCIRUN_PY_OK TRUE) + set(_PY_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") endif() if(NOT _SCIRUN_PY_OK) @@ -118,57 +177,72 @@ endif() # ==================================================================================== # Platform-specific compile definitions (PYTHONPATH, etc.) +# - We always define the macros so sources never see an undefined identifier. +# - If we have a Python executable, we query sysconfig for site-packages parent; otherwise fallback to empty. # ==================================================================================== -# Compute "pythonXY" (e.g., python313) from detected version variables +# Compute python name like python313 for macros/diagnostics set(_PYTHON_NAME "") -if(DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) - set(_PYTHON_NAME "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") +set(_SCIRUN_PY_DIGITS "") # "313" form; useful for Boost.Python lib name + +# Try derive digits from explicit libraries first (handles 3.10+) +if(NOT _SCIRUN_PY_DIGITS) + foreach(_cand "${_PY_LIB_DBG}" "${_PY_LIB_REL}") + if(_cand) + get_filename_component(_cand_name "${_cand}" NAME) + # Match python313[_d].lib or libpython313[_d].lib + if(_cand_name MATCHES "python([0-9]+)(_d)?\\.lib$") + set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") + break() + endif() + endif() + endforeach() endif() -# Compute parent of site-packages using Python -set(_SCIRUN_PY_QUERY - "import sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" -) -set(_PY_SITE "") -execute_process( - COMMAND "${Python_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" - OUTPUT_VARIABLE _PY_SITE - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE -) +# If CMake provided version numbers, build name from those +if(NOT _SCIRUN_PY_DIGITS AND DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) + string(CONCAT _SCIRUN_PY_DIGITS "${Python_VERSION_MAJOR}" "${Python_VERSION_MINOR}") +endif() -# Parent folder of site-packages -set(_PYTHON_MODULE_SEARCH_PARENT "") -if(_PY_SITE) - get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) - file(TO_CMAKE_PATH "${_PYTHON_MODULE_SEARCH_PARENT}" _PYTHON_MODULE_SEARCH_PARENT) +if(_SCIRUN_PY_DIGITS) + set(_PYTHON_NAME "python${_SCIRUN_PY_DIGITS}") endif() -# Extract a representative Python lib path and its dir (used for legacy macOS code paths) -set(_PYTHON_LIB "") -if(Python_LIBRARIES) - if(Python_LIBRARIES MATCHES ";") - list(GET Python_LIBRARIES 0 _PYTHON_LIB) - else() - set(_PYTHON_LIB "${Python_LIBRARIES}") +# Compute parent of site-packages using Python (optional) +set(_PYTHON_MODULE_SEARCH_PARENT "") +if(_PY_EXECUTABLE AND EXISTS "${_PY_EXECUTABLE}") + set(_SCIRUN_PY_QUERY + "import sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" + ) + execute_process( + COMMAND "${_PY_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" + OUTPUT_VARIABLE _PY_SITE + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(_PY_SITE) + get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) + file(TO_CMAKE_PATH "${_PYTHON_MODULE_SEARCH_PARENT}" _PYTHON_MODULE_SEARCH_PARENT) endif() endif() -get_filename_component(_PYTHON_LIBDIR "${_PYTHON_LIB}" DIRECTORY) -# ALWAYS define these macros so sources never see an undefined identifier. +# Always define these macros; use empty string if unknown if(WIN32) + target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" "PYTHONNAME=L\"${_PYTHON_NAME}\"" ) elseif(APPLE) + # Apple-specific legacy code paths could also need libdir; leave empty unless known + target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" - "PYTHONLIBDIR=L\"${_PYTHON_LIBDIR}\"" - "PYTHONLIB=L\"${_PYTHON_LIB}\"" + "PYTHONLIBDIR=L\"\"" + "PYTHONLIB=L\"\"" ) else() + target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" ) @@ -180,31 +254,49 @@ endif() target_link_libraries(Core_Python PRIVATE Python::Python + SCIRunPythonAPI ${SCI_BOOST_LIBRARY} # keep existing boost meta-lib if your project uses it Core_Matlab Core_Datatypes Core_Datatypes_Legacy_Field ) +# --- Debug-only: ignore autolinked *release* python import lib (e.g., from Boost.Python) --- +# We already link the correct Debug import lib (pythonXY_d.lib) by full path. +# Compute the release filename to ignore (e.g., "python313.lib"), then pass /NODEFAULTLIB:. +if(MSVC) + # If digits were derived above (e.g., "313"), ignore exactly python313.lib. + if(_SCIRUN_PY_DIGITS) + set(_SCIRUN_PY_RELEASE_NAME "python${_SCIRUN_PY_DIGITS}.lib") + target_link_options(Core_Python PRIVATE + $<$:/NODEFAULTLIB:${_SCIRUN_PY_RELEASE_NAME}> + ) + else() + # Fallback: also ignore the generic "python3.lib" name some toolchains request (rare). + target_link_options(Core_Python PRIVATE + $<$:/NODEFAULTLIB:python3.lib> + ) + endif() +endif() + # ==================================================================================== # Boost.Python handling -# - Recommended on MSVC: turn on explicit linking to tolerate 'lib' prefix naming. -# - Otherwise: use MSVC autolink (ensure Boost lib dir is on link path). +# - Recommended on MSVC: explicit linking to tolerate 'lib' prefix naming, vc toolset, and -gd debug suffix. +# - Otherwise: rely on MSVC autolink (ensure Boost lib dir is on link path). # ==================================================================================== # Toggle (pass from superbuild via -DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK=ON) option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on autolink" OFF) -# Compute Python major.minor digits for filename patterns -set(_SCIRUN_PY_M "") -if(DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) - set(_SCIRUN_PY_M "${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") -endif() +# Digits for Boost.Python name (e.g., 313) +set(_SCIRUN_PY_M "${_SCIRUN_PY_DIGITS}") if(MSVC) if(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK) # Disable Boost autolink on this target target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB) + #static + target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_STATIC_LIB) # The Boost lib directory should be passed from the superbuild: # -DSCI_BOOST_LIBRARY_DIR=E:/.../Externals/Install/Boost_external/lib @@ -256,9 +348,6 @@ if(MSVC) ) endif() - # Ensure the linker searches that folder - target_link_directories(Core_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") - # Link the exact files (per-config) target_link_libraries(Core_Python PRIVATE debug "${SCI_BOOST_PYTHON_LIB_DEBUG}" @@ -319,8 +408,13 @@ set_target_properties(Core_Python ) # Helpful diagnostics -message(STATUS "[Core/Python] Python executable : ${Python_EXECUTABLE}") -message(STATUS "[Core/Python] Python include(s) : ${Python_INCLUDE_DIRS}") -message(STATUS "[Core/Python] Python libraries : ${Python_LIBRARIES}") -message(STATUS "[Core/Python] PYTHONNAME : ${_PYTHON_NAME}") -message(STATUS "[Core/Python] PYTHONPATH : ${_PYTHON_MODULE_SEARCH_PARENT}") \ No newline at end of file +message(STATUS "[Core/Python] PY includes : ${_PY_INCLUDE_DIRS}") +message(STATUS "[Core/Python] PY exec : ${_PY_EXECUTABLE}") +message(STATUS "[Core/Python] PY name : ${_PYTHON_NAME}") +message(STATUS "[Core/Python] PY path : ${_PYTHON_MODULE_SEARCH_PARENT}") +if(_PY_LIB_DBG) + message(STATUS "[Core/Python] PY lib (dbg): ${_PY_LIB_DBG}") +endif() +if(_PY_LIB_REL) + message(STATUS "[Core/Python] PY lib (rel): ${_PY_LIB_REL}") +endif() \ No newline at end of file diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index 48830c6e75..f34a26a610 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -115,6 +115,10 @@ if(NOT _SCIRUN_API_PY_OK) set(_SCIRUN_API_PY_OK TRUE) endif() +if(MSVC) + target_compile_definitions(SCIRunPythonAPI PRIVATE BOOST_PYTHON_STATIC_LIB) +endif() + if(NOT _SCIRUN_API_PY_OK) message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build SCIRunPythonAPI.") endif() From a8ae9117776f02cde9c6c9dc378e68f236c67d9b Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Feb 2026 17:12:41 -0700 Subject: [PATCH 048/140] python issues in boost and scirun python api --- Superbuild/BoostExternal.cmake | 1 - src/Dataflow/Engine/Python/CMakeLists.txt | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index e950644ffa..27b93c1f70 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -110,7 +110,6 @@ if(BOOST_ENABLE_PYTHON) if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}" AND _PY_LIBDIR AND EXISTS "${_PY_LIBDIR}") list(APPEND _B2_PY_ARGS - "python=${PY_MAJOR}.${PY_MINOR}" # or hardcode 3.13 "include=${PYTHON_INCLUDE_DIR}" "library-path=${_PY_LIBDIR}" ) diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index f34a26a610..6503077ecb 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -115,13 +115,15 @@ if(NOT _SCIRUN_API_PY_OK) set(_SCIRUN_API_PY_OK TRUE) endif() +if(NOT _SCIRUN_API_PY_OK) + message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build SCIRunPythonAPI.") +endif() + if(MSVC) target_compile_definitions(SCIRunPythonAPI PRIVATE BOOST_PYTHON_STATIC_LIB) endif() -if(NOT _SCIRUN_API_PY_OK) - message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build SCIRunPythonAPI.") -endif() +target_compile_definitions(SCIRunPythonAPI PRIVATE BUILD_WITH_PYTHON) # ==================================================================================== # Link dependencies @@ -134,7 +136,7 @@ target_link_libraries(SCIRunPythonAPI Core_Thread Core_Datatypes_Legacy_Base Core_Persistent - Core_Python + #Core_Python Python::Python ${SCI_BOOST_LIBRARY} ) From af325887d68993f9e1afd6181449293b8885b34a Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 23 Feb 2026 13:45:58 -0700 Subject: [PATCH 049/140] linking errors, python lib, zlib used by teem --- Superbuild/Superbuild.cmake | 8 + src/CMakeLists.txt | 130 ++++++++++------ src/Core/Algorithms/Describe/CMakeLists.txt | 1 + .../Algorithms/Legacy/Fields/CMakeLists.txt | 50 +++++- src/Dataflow/Engine/Python/CMakeLists.txt | 142 +++++++++++++----- 5 files changed, 238 insertions(+), 93 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 9a4559a8ef..4eb1a4a99f 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -586,6 +586,14 @@ if(BUILD_WITH_PYTHON) # Boost.Python wiring remains as-is "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" + + # === Strong hints for FindPython to stay inside the superbuild tree === + "-DPython_ROOT_DIR:PATH=${_PY_SRC}" + "-DPython3_ROOT_DIR:PATH=${_PY_SRC}" + + # === Explicit paths used by the module-level override (imported target) === + "-DPY_EXT_LIB_DIR:PATH=${_PY_PCBUILD}" + "-DPY_INCLUDE_DIR:PATH=${_PY_INC}" ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d997a1b741..458f3d31eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,75 +96,109 @@ endif() # -------------------------------------------------------------------- # Imported targets for Zlib and Teem (transitive wiring) -# - Prefer config packages if they exist (ZLIB::ZLIB / Teem::teem) -# - Otherwise, create imported targets from superbuild paths -# - Make Teem::teem depend transitively on Zlib::Zlib +# - Canonical name: ZLIB::ZLIB (provide Zlib::Zlib alias) +# - Canonical name: Teem::teem (links transitively to ZLIB::ZLIB) # -------------------------------------------------------------------- # Normalize/bridge variables for includes used elsewhere if(DEFINED ZLIB_INCLUDE_DIR AND NOT DEFINED SCI_ZLIB_INCLUDE) set(SCI_ZLIB_INCLUDE "${ZLIB_INCLUDE_DIR}") endif() -# Already present for Teem: SCI_TEEM_INCLUDE +# SCI_TEEM_INCLUDE is assumed to be set elsewhere by the superbuild +# ------------------------ # 1) Zlib imported target -if(NOT TARGET ZLIB::ZLIB AND NOT TARGET Zlib::Zlib) - # If a package defined ZLIB::ZLIB, prefer it. - # (If CONFIG_STANDARD_EXTERNAL found one earlier, the target may already exist.) - # Otherwise, build an imported target from explicit paths. - if(DEFINED ZLIB_LIBRARY AND EXISTS "${ZLIB_LIBRARY}" AND DEFINED ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") - add_library(Zlib::Zlib UNKNOWN IMPORTED) - set_target_properties(Zlib::Zlib PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" - ) - message(STATUS "[SCIRun] Created imported target Zlib::Zlib from explicit paths.") - elseif(TARGET ZLIB::ZLIB) - # OK—package provided it - add_library(Zlib::Zlib ALIAS ZLIB::ZLIB) - message(STATUS "[SCIRun] Using package target ZLIB::ZLIB (aliased to Zlib::Zlib).") - else() - message(WARNING "[SCIRun] Zlib not fully configured yet (need ZLIB_LIBRARY and ZLIB_INCLUDE_DIR). " - "If you are in a first pass before externals install, this can be expected.") +# ------------------------ +# Goal: ensure ZLIB::ZLIB always exists; provide Zlib::Zlib alias for compatibility. + +if(NOT TARGET ZLIB::ZLIB) + # Try a config package first (may define ZLIB::ZLIB) + # Hints leverage ZLIB_ROOT/ZLIB_DIR/CMAKE_PREFIX_PATH already + find_package(ZLIB QUIET CONFIG) + + if(NOT TARGET ZLIB::ZLIB) + # Fall back to module find (classic FindZLIB) + find_package(ZLIB QUIET) + + if(NOT TARGET ZLIB::ZLIB) + # No package target; build imported target from variables. + # Prefer debug/release split if available. + if((ZLIB_LIBRARY_RELEASE OR ZLIB_LIBRARY) AND ZLIB_INCLUDE_DIR) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + if(ZLIB_LIBRARY_RELEASE) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + endif() + if(ZLIB_LIBRARY_DEBUG) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}" + ) + endif() + if(NOT ZLIB_LIBRARY_RELEASE AND ZLIB_LIBRARY) + # Single lib used for all configs + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + endif() + elseif(ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}" + ) + else() + message(WARNING "[SCIRun] Zlib not fully configured yet (need ZLIB_LIBRARY{_DEBUG/_RELEASE} and ZLIB_INCLUDE_DIR). " + "This can be expected before externals are installed.") + endif() + endif() endif() endif() -# 2) Teem imported target, transitive to zlib +# Provide compatibility alias if canonical exists +if(TARGET ZLIB::ZLIB AND NOT TARGET Zlib::Zlib) + add_library(Zlib::Zlib ALIAS ZLIB::ZLIB) +endif() + +# ------------------------ +# 2) Teem imported target +# ------------------------ +# Goal: ensure Teem::teem exists; link transitively to ZLIB::ZLIB when available. + if(NOT TARGET Teem::teem) - # Prefer a package target if a TeemConfig was found - if(TARGET Teem::Teem OR TARGET Teem::teem) - # Normalize to Teem::teem - if(TARGET Teem::teem) - add_library(Teem__real ALIAS Teem::teem) - else() - add_library(Teem__real ALIAS Teem::Teem) - endif() - add_library(Teem::teem INTERFACE IMPORTED) - if(TARGET Zlib::Zlib) - set_target_properties(Teem::teem PROPERTIES INTERFACE_LINK_LIBRARIES "Teem__real;Zlib::Zlib") - else() - set_target_properties(Teem::teem PROPERTIES INTERFACE_LINK_LIBRARIES "Teem__real") + # Prefer a config-provided target if present + find_package(Teem QUIET CONFIG) + + if(TARGET Teem::teem) + # Already provided by package—augment linkage if needed + if(TARGET ZLIB::ZLIB) + # Append zlib transitively; don't overwrite existing interface links + get_target_property(_teem_links Teem::teem INTERFACE_LINK_LIBRARIES) + if(NOT _teem_links) + set(_teem_links "") + endif() + list(APPEND _teem_links ZLIB::ZLIB) + list(REMOVE_DUPLICATES _teem_links) + set_target_properties(Teem::teem PROPERTIES INTERFACE_LINK_LIBRARIES "${_teem_links}") endif() - message(STATUS "[SCIRun] Teem package target detected; created Teem::teem wrapper with Zlib transitively.") else() - # Create imported from explicit paths + # Create imported from explicit paths (superbuild should provide Teem_LIBRARY/Teem_INCLUDE_DIR) if(DEFINED Teem_LIBRARY AND EXISTS "${Teem_LIBRARY}" AND DEFINED Teem_INCLUDE_DIR AND EXISTS "${Teem_INCLUDE_DIR}/teem/ten.h") add_library(Teem::teem UNKNOWN IMPORTED) set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${Teem_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LOCATION "${Teem_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + # Make consumers treat Teem headers as static-linked (prevents dllimport) + INTERFACE_COMPILE_DEFINITIONS "TEEM_STATIC" ) - if(TARGET Zlib::Zlib) - set_property(TARGET Teem::teem APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "Zlib::Zlib" - ) - message(STATUS "[SCIRun] Created imported target Teem::teem (transitively links Zlib::Zlib).") - else() - message(WARNING "[SCIRun] Created imported target Teem::teem, but Zlib::Zlib is not available yet.") + if(TARGET ZLIB::ZLIB) + set_property(TARGET Teem::teem APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) endif() else() message(WARNING "[SCIRun] Teem not fully configured yet (need Teem_LIBRARY and Teem_INCLUDE_DIR). " - "If you are in a first pass before externals install, this can be expected.") + "This can be expected before externals are built.") endif() endif() endif() diff --git a/src/Core/Algorithms/Describe/CMakeLists.txt b/src/Core/Algorithms/Describe/CMakeLists.txt index 93598799cc..cc1fa4f7ca 100644 --- a/src/Core/Algorithms/Describe/CMakeLists.txt +++ b/src/Core/Algorithms/Describe/CMakeLists.txt @@ -43,6 +43,7 @@ SCIRUN_ADD_LIBRARY(Algorithms_Describe TARGET_LINK_LIBRARIES(Algorithms_Describe Core_Datatypes Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Bundle Algorithms_Field Algorithms_Math ${SCI_BOOST_LIBRARY} diff --git a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt index 52316ab2d9..b49ab98391 100644 --- a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt @@ -350,13 +350,53 @@ target_link_libraries(Core_Algorithms_Legacy_Fields ${_teem_target} ) -# If your Teem build uses zlib, add it explicitly (static Teem won’t drag it in automatically) -if(TARGET Zlib::Zlib) - target_link_libraries(Core_Algorithms_Legacy_Fields PRIVATE Zlib::Zlib) +# ========================================================== +# Zlib is REQUIRED because Teem's gzio uses it (deflate/inflate/crc32). +# Use modern imported target; fall back to variables from the superbuild. +# ========================================================== +set(_zlib_target "") + +# Prefer an existing target if the top-level already created it. +if(TARGET ZLIB::ZLIB) + set(_zlib_target ZLIB::ZLIB) +else() + # Try module find (honors ZLIB_ROOT and CMAKE_PREFIX_PATH). + find_package(ZLIB QUIET) + + if(TARGET ZLIB::ZLIB) + set(_zlib_target ZLIB::ZLIB) + else() + # Fallbacks to superbuild-provided variables. + # Newer CMake may expose ZLIB_LIBRARIES/ZLIB_INCLUDE_DIRS; + # older uses ZLIB_LIBRARY/ZLIB_INCLUDE_DIR. + if(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" + ) + set(_zlib_target ZLIB::ZLIB) + elseif(ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED) + set_target_properties(ZLIB::ZLIB PROPERTIES + IMPORTED_LOCATION "${ZLIB_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}" + ) + set(_zlib_target ZLIB::ZLIB) + else() + message(FATAL_ERROR + "Zlib not found. SCIRun needs it to link Teem (gzio).\n" + "Provide ZLIB_ROOT or ZLIB_LIBRARY/ZLIB_INCLUDE_DIR from the superbuild.\n" + "ZLIB_LIBRARY='${ZLIB_LIBRARY}' ZLIB_LIBRARIES='${ZLIB_LIBRARIES}'\n" + "ZLIB_INCLUDE_DIR='${ZLIB_INCLUDE_DIR}' ZLIB_INCLUDE_DIRS='${ZLIB_INCLUDE_DIRS}'") + endif() + endif() endif() +# Link zlib unconditionally (Teem uses it) +target_link_libraries(Core_Algorithms_Legacy_Fields PRIVATE ${_zlib_target}) + # Export macro for this DLL, unchanged if(BUILD_SHARED_LIBS) target_compile_definitions(Core_Algorithms_Legacy_Fields PRIVATE BUILD_Core_Algorithms_Legacy_Fields) -endif() - +endif() \ No newline at end of file diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index 6503077ecb..5bed94ff7e 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -56,28 +56,23 @@ SCIRUN_ADD_LIBRARY(SCIRunPythonAPI ) # ==================================================================================== -# Cross-platform Python detection -# Prefer modern FindPython / FindPython3; fall back to legacy modules if needed. -# Result: -# - Imported target to link: Python::Python -# - Vars: Python_EXECUTABLE, Python_INCLUDE_DIRS, Python_LIBRARIES +# Cross-platform Python detection with superbuild override (Windows multi-config) # ==================================================================================== -set(_SCIRUN_API_PY_OK FALSE) +# Expect these (or similar) to be passed from the superbuild. Adjust names if yours differ: +# PY_EXT_LIB_DIR: e.g., E:/PROJECTS/SCIRun/build/Externals/Source/Python_external/PCbuild/amd64 +# PY_INCLUDE_DIR: e.g., E:/PROJECTS/SCIRun/build/Externals/Source/Python_external/Include +# PY_EXECUTABLE: e.g., E:/PROJECTS/SCIRun/build/Externals/Source/Python_external/python.exe (optional) -# 1) Prefer the generic FindPython (Interpreter + Development) +# Try modern find first (harmless even if we will override later) +set(_SCIRUN_API_PY_OK FALSE) find_package(Python QUIET COMPONENTS Interpreter Development) if(Python_Interpreter_FOUND AND Python_Development_FOUND) set(_SCIRUN_API_PY_OK TRUE) -elseif(NOT _SCIRUN_API_PY_OK) - # 2) Try Python3 module +else() find_package(Python3 QUIET COMPONENTS Interpreter Development) if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - # Normalize into Python_* variable names for consistency - set(Python_EXECUTABLE "${Python3_EXECUTABLE}") - set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") - set(Python_LIBRARIES "${Python3_LIBRARIES}") - # Alias target so we can always link Python::Python + # normalize to Python::Python if(TARGET Python3::Python AND NOT TARGET Python::Python) add_library(Python::Python ALIAS Python3::Python) endif() @@ -85,31 +80,102 @@ elseif(NOT _SCIRUN_API_PY_OK) endif() endif() -# 3) Legacy fallback path (older CMake or environments without the newer modules) -if(NOT _SCIRUN_API_PY_OK) - find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) - # Normalize var names - set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") - set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") - set(Python_LIBRARIES "${PYTHON_LIBRARIES}") - - # Provide a compatible imported target so target_link_libraries can always use Python::Python +# --- Superbuild override on Windows: construct the imported target from explicit paths +# Accept either the new variables (PY_EXT_LIB_DIR/PY_INCLUDE_DIR) or the legacy ones +# (PYTHON_LIBRARY_DEBUG/RELEASE, PYTHON_INCLUDE_DIR). Prefer the new ones when present. + +if(MSVC) + # Derived names for Python 3.13 (adjust as needed) + set(_PY_DEBUG_LIB_NAME "python313_d.lib") + set(_PY_RELEASE_LIB_NAME "python313.lib") + + # Prefer new-style + set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") + set(_SB_INC_DIR "${PY_INCLUDE_DIR}") + + # Fallback to legacy variables if new-style not provided + if(NOT _SB_LIB_DIR) + # Try to infer from the legacy file paths + if(PYTHON_LIBRARY_DEBUG) + get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) + elseif(PYTHON_LIBRARY_RELEASE) + get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) + endif() + endif() + + if(NOT _SB_INC_DIR) + if(PYTHON_INCLUDE_DIR) + set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") + elseif(Python_INCLUDE_DIRS) + # FindPython may pass a list; use the first element as base include + list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) + endif() + endif() + + # As last resort, try known layout relative to the inner build + if(NOT _SB_LIB_DIR) + set(_SB_LIB_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64") + endif() + if(NOT _SB_INC_DIR) + set(_SB_INC_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/Include") + endif() + + # Resolve per-config import libraries + set(_py_dbg_lib "") + set(_py_rel_lib "") + + # If explicit files were provided by superbuild, use them + if(PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") + set(_py_dbg_lib "${PYTHON_LIBRARY_DEBUG}") + endif() + if(PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") + set(_py_rel_lib "${PYTHON_LIBRARY_RELEASE}") + endif() + + # Otherwise, construct by name under the lib dir + if(NOT _py_dbg_lib) + set(_cand "${_SB_LIB_DIR}/${_PY_DEBUG_LIB_NAME}") + if(EXISTS "${_cand}") + set(_py_dbg_lib "${_cand}") + endif() + endif() + if(NOT _py_rel_lib) + set(_cand "${_SB_LIB_DIR}/${_PY_RELEASE_LIB_NAME}") + if(EXISTS "${_cand}") + set(_py_rel_lib "${_cand}") + endif() + endif() + + # Build/update Python::Python imported target pointing at superbuild libs if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) + endif() + + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" + ) + + if(EXISTS "${_py_rel_lib}") set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" + IMPORTED_IMPLIB_RELEASE "${_py_rel_lib}" + ) + endif() + + if(EXISTS "${_py_dbg_lib}") + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_py_dbg_lib}" + ) + endif() + + # Fail only if absolutely nothing was found and no prior package existed + if(NOT (EXISTS "${_py_rel_lib}" OR EXISTS "${_py_dbg_lib}" OR TARGET Python3::Python)) + message(FATAL_ERROR + "Python import libraries not found for Windows/MSVC.\n" + "Searched:\n _SB_LIB_DIR='${_SB_LIB_DIR}'\n" + "Expected names: ${_PY_RELEASE_LIB_NAME} / ${_PY_DEBUG_LIB_NAME}\n" + "Or explicit: PYTHON_LIBRARY_RELEASE='${PYTHON_LIBRARY_RELEASE}', PYTHON_LIBRARY_DEBUG='${PYTHON_LIBRARY_DEBUG}'\n" + "Include dir: _SB_INC_DIR='${_SB_INC_DIR}'" ) - if(WIN32) - # On MSVC, the import library (.lib) is what we link against - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB "${Python_LIBRARIES}" - ) - else() - set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION "${Python_LIBRARIES}" - ) - endif() endif() set(_SCIRUN_API_PY_OK TRUE) @@ -126,17 +192,13 @@ endif() target_compile_definitions(SCIRunPythonAPI PRIVATE BUILD_WITH_PYTHON) # ==================================================================================== -# Link dependencies +# Link dependencies (Python::Python now guaranteed to point to superbuild libs) # ==================================================================================== - -# Replace legacy ${SCI_PYTHON_LIBRARY} with imported target Python::Python. -# This pulls the include dir for Python.h and the correct platform library. target_link_libraries(SCIRunPythonAPI PRIVATE Core_Thread Core_Datatypes_Legacy_Base Core_Persistent - #Core_Python Python::Python ${SCI_BOOST_LIBRARY} ) From 3dffadad5aae8a2f88f8ff4b724517d900a987a3 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 23 Feb 2026 16:36:41 -0700 Subject: [PATCH 050/140] remove system python from superbuild and stick with external python --- Superbuild/Superbuild.cmake | 31 +---- src/Core/Python/CMakeLists.txt | 67 ++++++++-- src/Dataflow/Engine/Python/CMakeLists.txt | 83 ++++++------ src/Modules/Python/CMakeLists.txt | 149 ++++++++++++++++------ 4 files changed, 219 insertions(+), 111 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 4eb1a4a99f..9aee928e0c 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -207,31 +207,6 @@ macro(ADD_EXTERNAL cmake_file external) list(APPEND SCIRUN_DEPENDENCIES ${external}) endmacro() -# ========================= -# Python (superbuild-level detection) -# ========================= -if(BUILD_WITH_PYTHON) - # Prefer modern FindPython module (Interpreter + Development) - find_package(Python COMPONENTS Interpreter Development REQUIRED) - - message(STATUS "[superbuild] Python executable: ${Python_EXECUTABLE}") - message(STATUS "[superbuild] Python includes : ${Python_INCLUDE_DIRS}") - message(STATUS "[superbuild] Python libraries : ${Python_LIBRARIES}") - message(STATUS "[superbuild] Python version : ${Python_VERSION}") - - # Optionally bias CMake to not scan the Windows registry for a different Python - # set(Python_FIND_REGISTRY NEVER) - - # If you want the inner configure to also see this location via CMAKE_PREFIX_PATH - # (not required, but harmless), you can append Python's root to prefixes: - # Try to infer a plausible root from exec/include path: - get_filename_component(_py_exec_dir "${Python_EXECUTABLE}" DIRECTORY) - get_filename_component(_py_root "${_py_exec_dir}" DIRECTORY) - if(EXISTS "${_py_root}") - sb_prefix_append("${_py_root}") - endif() -endif() - set(SUPERBUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE) set(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE) set(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) @@ -594,6 +569,12 @@ if(BUILD_WITH_PYTHON) # === Explicit paths used by the module-level override (imported target) === "-DPY_EXT_LIB_DIR:PATH=${_PY_PCBUILD}" "-DPY_INCLUDE_DIR:PATH=${_PY_INC}" + + # Bias CMake's FindPython inside the inner build to honor our root and NOT the registry/system + "-DPython_FIND_REGISTRY:STRING=NEVER" + "-DPython_FIND_STRATEGY:STRING=LOCATION" + # Fence typical system install path(s) so they don't creep in via any other find logic + "-DCMAKE_IGNORE_PREFIX_PATH:PATH=C:/Program Files/Python313;C:/Program Files (x86)/Python*" ) endif() diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 091f26737c..9da89dcba4 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -26,27 +26,44 @@ # # ---- Core/Python CMake ---- +cmake_minimum_required(VERSION 3.16) -cmake_minimum_required(VERSION 3.16) # adjust if your project requires different +# --- Guard against system Python being injected via ${Python_LIBRARIES} / ${PYTHON_LIBRARIES} +unset(Python_LIBRARIES) +unset(PYTHON_LIBRARIES) +unset(Python_LIBRARIES CACHE) +unset(PYTHON_LIBRARIES CACHE) # --- Sources --- set(Core_Python_SRCS PythonInterpreter.cc PythonDatatypeConverter.cc ) - set(Core_Python_HEADERS PythonInterpreter.h PythonDatatypeConverter.h share.h ) +# --- Neutralize any directory-scoped link_libraries() *before* the target is created --- +get_property(_dir_links_before DIRECTORY PROPERTY LINK_LIBRARIES) +message(STATUS "[Diag/Core_Python] DIR LINK_LIBRARIES(before)=${_dir_links_before}") + +# Clear directory-scoped link libraries for THIS directory (prevents inheriting system Python) +set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY LINK_LIBRARIES "") + +get_property(_dir_links_after DIRECTORY PROPERTY LINK_LIBRARIES) +message(STATUS "[Diag/Core_Python] DIR LINK_LIBRARIES(after)=${_dir_links_after}") + # Library target (uses project macro from top-level) SCIRUN_ADD_LIBRARY(Core_Python ${Core_Python_HEADERS} ${Core_Python_SRCS} ) +# --- Also wipe anything that was still captured on the target itself (belt-and-suspenders) --- +set_target_properties(Core_Python PROPERTIES LINK_LIBRARIES "") + # Preserve original shared define behavior if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_Core_Python) @@ -80,6 +97,14 @@ set(_PY_LIB_DBG "") set(_PY_LIB_REL "") # ---- Path-first: use explicit superbuild variables if provided ---- +# Expected (from superbuild): +# PYTHON_INCLUDE_DIR -> .../Python_external/Include +# PYTHON_PC_INCLUDE_DIR -> .../Python_external/PC +# PYTHON_LIBRARY_RELEASE -> .../PCbuild/amd64/python313.lib +# PYTHON_LIBRARY_DEBUG -> .../PCbuild/amd64/python313_d.lib +# PYTHON_RUNTIME_DIR -> .../PCbuild/amd64 (optional) +# PYTHON_EXECUTABLE -> .../PCbuild/amd64/python.exe (optional) + if(PYTHON_LIBRARY_DEBUG AND PYTHON_LIBRARY_RELEASE AND PYTHON_INCLUDE_DIR) if(NOT EXISTS "${PYTHON_LIBRARY_DEBUG}") message(FATAL_ERROR "PYTHON_LIBRARY_DEBUG does not exist: ${PYTHON_LIBRARY_DEBUG}") @@ -95,28 +120,40 @@ if(PYTHON_LIBRARY_DEBUG AND PYTHON_LIBRARY_RELEASE AND PYTHON_INCLUDE_DIR) set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") # Includes: Include (always), PC (optional on Windows for pyconfig.h) - list(APPEND _PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") endif() - # Imported target with per-config locations + # Create or override the imported target to **force** superbuild Python if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) + endif() + + if(MSVC) + # On MSVC, link against the import library via IMPORTED_IMPLIB_* (NOT IMPORTED_LOCATION_*) set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + IMPORTED_IMPLIB_DEBUG "${_PY_LIB_DBG}" + IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_IMPLIB_RELEASE "${_PY_LIB_REL}" + IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_REL}" INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" ) + else() + # Non-Windows: link directly to the shared/static lib path + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" + ) endif() - # Provide a best-effort Python_EXECUTABLE for later diagnostics/macros + # Provide a best-effort Python_EXECUTABLE for diagnostics/macros if(PYTHON_EXECUTABLE AND EXISTS "${PYTHON_EXECUTABLE}") set(_PY_EXECUTABLE "${PYTHON_EXECUTABLE}") elseif(PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") - # Common MSVC layout: python.exe next to libs in PCbuild/amd64 if(EXISTS "${PYTHON_RUNTIME_DIR}/python.exe") set(_PY_EXECUTABLE "${PYTHON_RUNTIME_DIR}/python.exe") endif() @@ -417,4 +454,12 @@ if(_PY_LIB_DBG) endif() if(_PY_LIB_REL) message(STATUS "[Core/Python] PY lib (rel): ${_PY_LIB_REL}") -endif() \ No newline at end of file +endif() + +# --- DIAGNOSTICS: show who is adding system Python into Core_Python --- +get_target_property(_cp_links Core_Python LINK_LIBRARIES) +get_target_property(_cp_if Core_Python INTERFACE_LINK_LIBRARIES) +message(STATUS "[Diag/Core_Python] LINK_LIBRARIES=${_cp_links}") +message(STATUS "[Diag/Core_Python] INTERFACE_LINK_LIBRARIES=${_cp_if}") +message(STATUS "[Diag/Core_Python] Python::Python IMPORTED_IMPLIB_DEBUG=$") +message(STATUS "[Diag/Core_Python] Python::Python IMPORTED_IMPLIB_RELEASE=$") \ No newline at end of file diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index 5bed94ff7e..23019dd548 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -30,8 +30,6 @@ # Dataflow/Engine/Python CMakeLists.txt # ========================================== -# Optional: if you want to skip this target when Python support is OFF. -# Comment this block out if you prefer to always configure it. if(NOT BUILD_WITH_PYTHON) message(STATUS "[Dataflow/Engine/Python] Skipping SCIRunPythonAPI (BUILD_WITH_PYTHON=OFF)") return() @@ -59,12 +57,13 @@ SCIRUN_ADD_LIBRARY(SCIRunPythonAPI # Cross-platform Python detection with superbuild override (Windows multi-config) # ==================================================================================== -# Expect these (or similar) to be passed from the superbuild. Adjust names if yours differ: -# PY_EXT_LIB_DIR: e.g., E:/PROJECTS/SCIRun/build/Externals/Source/Python_external/PCbuild/amd64 -# PY_INCLUDE_DIR: e.g., E:/PROJECTS/SCIRun/build/Externals/Source/Python_external/Include -# PY_EXECUTABLE: e.g., E:/PROJECTS/SCIRun/build/Externals/Source/Python_external/python.exe (optional) +# Expect these (from superbuild): +# PY_EXT_LIB_DIR -> .../Externals/Source/Python_external/PCbuild/amd64 +# PY_INCLUDE_DIR -> .../Externals/Source/Python_external/Include +# PYTHON_LIBRARY_DEBUG/RELEASE (legacy names also accepted) +# PYTHON_INCLUDE_DIR (legacy name also accepted) -# Try modern find first (harmless even if we will override later) +# Try modern find first (harmless; we may override below) set(_SCIRUN_API_PY_OK FALSE) find_package(Python QUIET COMPONENTS Interpreter Development) if(Python_Interpreter_FOUND AND Python_Development_FOUND) @@ -72,7 +71,6 @@ if(Python_Interpreter_FOUND AND Python_Development_FOUND) else() find_package(Python3 QUIET COMPONENTS Interpreter Development) if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - # normalize to Python::Python if(TARGET Python3::Python AND NOT TARGET Python::Python) add_library(Python::Python ALIAS Python3::Python) endif() @@ -80,39 +78,32 @@ else() endif() endif() -# --- Superbuild override on Windows: construct the imported target from explicit paths -# Accept either the new variables (PY_EXT_LIB_DIR/PY_INCLUDE_DIR) or the legacy ones -# (PYTHON_LIBRARY_DEBUG/RELEASE, PYTHON_INCLUDE_DIR). Prefer the new ones when present. - +# --- Superbuild override on Windows (force correct import libs per-config) ----------- if(MSVC) - # Derived names for Python 3.13 (adjust as needed) - set(_PY_DEBUG_LIB_NAME "python313_d.lib") + set(_PY_DEBUG_LIB_NAME "python313_d.lib") # adjust if you switch Python versions set(_PY_RELEASE_LIB_NAME "python313.lib") - # Prefer new-style - set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") - set(_SB_INC_DIR "${PY_INCLUDE_DIR}") + # Prefer new-style vars + set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") + set(_SB_INC_DIR "${PY_INCLUDE_DIR}") - # Fallback to legacy variables if new-style not provided + # Fallback to legacy names to infer paths if(NOT _SB_LIB_DIR) - # Try to infer from the legacy file paths if(PYTHON_LIBRARY_DEBUG) get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) elseif(PYTHON_LIBRARY_RELEASE) get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) endif() endif() - if(NOT _SB_INC_DIR) if(PYTHON_INCLUDE_DIR) set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") elseif(Python_INCLUDE_DIRS) - # FindPython may pass a list; use the first element as base include list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) endif() endif() - # As last resort, try known layout relative to the inner build + # Last-resort defaults relative to inner build if(NOT _SB_LIB_DIR) set(_SB_LIB_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64") endif() @@ -132,7 +123,7 @@ if(MSVC) set(_py_rel_lib "${PYTHON_LIBRARY_RELEASE}") endif() - # Otherwise, construct by name under the lib dir + # Otherwise, construct by expected names under the lib dir if(NOT _py_dbg_lib) set(_cand "${_SB_LIB_DIR}/${_PY_DEBUG_LIB_NAME}") if(EXISTS "${_cand}") @@ -146,7 +137,7 @@ if(MSVC) endif() endif() - # Build/update Python::Python imported target pointing at superbuild libs + # Create or update Python::Python so it always points to superbuild import libs if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) endif() @@ -155,19 +146,21 @@ if(MSVC) INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" ) + # IMPORTANT on MSVC: use IMPORTED_IMPLIB_* (not IMPORTED_LOCATION_*) for .lib import libs if(EXISTS "${_py_rel_lib}") set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_py_rel_lib}" + IMPORTED_IMPLIB_RELEASE "${_py_rel_lib}" + IMPORTED_IMPLIB_RELWITHDEBINFO "${_py_rel_lib}" + IMPORTED_IMPLIB_MINSIZEREL "${_py_rel_lib}" ) endif() - if(EXISTS "${_py_dbg_lib}") set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_py_dbg_lib}" + IMPORTED_IMPLIB_DEBUG "${_py_dbg_lib}" ) endif() - # Fail only if absolutely nothing was found and no prior package existed + # Fail only if no usable lib was found and no prior package existed if(NOT (EXISTS "${_py_rel_lib}" OR EXISTS "${_py_dbg_lib}" OR TARGET Python3::Python)) message(FATAL_ERROR "Python import libraries not found for Windows/MSVC.\n" @@ -185,6 +178,7 @@ if(NOT _SCIRUN_API_PY_OK) message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build SCIRunPythonAPI.") endif() +# This target does not use Boost.Python symbols directly; the define is harmless but optional. if(MSVC) target_compile_definitions(SCIRunPythonAPI PRIVATE BOOST_PYTHON_STATIC_LIB) endif() @@ -203,15 +197,30 @@ target_link_libraries(SCIRunPythonAPI ${SCI_BOOST_LIBRARY} ) +# ------------------------------------------------------------------------------------ +# Debug-only insurance: ignore any autolinked *release* python import lib +# (e.g., if a 3rd-party .lib contains /DEFAULTLIB:python313.lib directives). +# ------------------------------------------------------------------------------------ +if(MSVC) + # Compute name to ignore (matches CPython 3.13) + set(_SCIRUN_PY_RELEASE_NAME "python313.lib") + target_link_options(SCIRunPythonAPI PRIVATE + $<$:/NODEFAULTLIB:${_SCIRUN_PY_RELEASE_NAME}> + ) + # Optional belt-and-suspenders: force defaultlib to the debug import lib we set above + # get_target_property(_py_dbg_implib Python::Python IMPORTED_IMPLIB_DEBUG) + # if(_py_dbg_implib) + # target_link_options(SCIRunPythonAPI PRIVATE $<$:/DEFAULTLIB:${_py_dbg_implib}>) + # endif() +endif() + # ==================================================================================== -# Shared build definitions & Windows .pyd properties (kept from your original) +# Shared build: Windows .pyd properties (kept) # ==================================================================================== - if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_SCIRunPythonAPI) if(WIN32) - # Build as a Python extension on Windows: .pyd suffix/prefixes set_target_properties(SCIRunPythonAPI PROPERTIES IMPORT_SUFFIX ".pyd" @@ -225,13 +234,13 @@ endif() # ==================================================================================== # Tests # ==================================================================================== - SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== -# Diagnostics (optional but helpful) +# Diagnostics (show what the imported target is actually using, not Python_LIBRARIES) # ==================================================================================== - -message(STATUS "[SCIRunPythonAPI] Python executable : ${Python_EXECUTABLE}") -message(STATUS "[SCIRunPythonAPI] Python include(s) : ${Python_INCLUDE_DIRS}") -message(STATUS "[SCIRunPythonAPI] Python libraries : ${Python_LIBRARIES}") +get_target_property(_py_inc Python::Python INTERFACE_INCLUDE_DIRECTORIES) +get_target_property(_py_dbg Python::Python IMPORTED_IMPLIB_DEBUG) +get_target_property(_py_rel Python::Python IMPORTED_IMPLIB_RELEASE) +message(STATUS "[SCIRunPythonAPI] Python include(s) : ${_py_inc}") +message(STATUS "[SCIRunPythonAPI] Python importlib : Debug='${_py_dbg}' Release='${_py_rel}'") \ No newline at end of file diff --git a/src/Modules/Python/CMakeLists.txt b/src/Modules/Python/CMakeLists.txt index c0bcd89ab5..e6c5599fb1 100644 --- a/src/Modules/Python/CMakeLists.txt +++ b/src/Modules/Python/CMakeLists.txt @@ -64,23 +64,19 @@ endif() # ==================================================================================== # Optional Python detection (only if the build is configured with Python support) +# - We *always* link to Python::Python (imported target) +# - On MSVC we override Python::Python to the superbuild import libs using IMPORTED_IMPLIB_* # ==================================================================================== - set(_SCIRUN_MODULES_PY_OK FALSE) + if(BUILD_WITH_PYTHON) - # 1) Prefer modern FindPython (generic) + # Prefer modern FindPython; harmless if we will override on MSVC find_package(Python QUIET COMPONENTS Interpreter Development) if(Python_Interpreter_FOUND AND Python_Development_FOUND) set(_SCIRUN_MODULES_PY_OK TRUE) - elseif(NOT _SCIRUN_MODULES_PY_OK) - # 2) Try Python3 module + else() find_package(Python3 QUIET COMPONENTS Interpreter Development) if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - # Normalize to Python_* names so logic below is uniform - set(Python_EXECUTABLE "${Python3_EXECUTABLE}") - set(Python_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") - set(Python_LIBRARIES "${Python3_LIBRARIES}") - # Alias Python3::Python → Python::Python for consistent linking if(TARGET Python3::Python AND NOT TARGET Python::Python) add_library(Python::Python ALIAS Python3::Python) endif() @@ -88,32 +84,102 @@ if(BUILD_WITH_PYTHON) endif() endif() - # 3) Legacy fallback (older CMake or missing modules) - if(NOT _SCIRUN_MODULES_PY_OK) - find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) - # Normalize legacy vars - set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") - set(Python_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") - set(Python_LIBRARIES "${PYTHON_LIBRARIES}") - # Provide an imported target for consistency + # --- Superbuild override on Windows/MSVC: force per-config import libs ----------- + # Superbuild should pass either: + # - New style: PY_EXT_LIB_DIR (..../PCbuild/amd64), PY_INCLUDE_DIR (..../Include) + # - Legacy: PYTHON_LIBRARY_DEBUG/RELEASE, PYTHON_INCLUDE_DIR + if(MSVC) + # Default CPython 3.13 names; adjust if you change Python version + set(_PY_DEBUG_LIB_NAME "python313_d.lib") + set(_PY_RELEASE_LIB_NAME "python313.lib") + + set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") + set(_SB_INC_DIR "${PY_INCLUDE_DIR}") + + # Fallback from legacy variables + if(NOT _SB_LIB_DIR) + if(PYTHON_LIBRARY_DEBUG) + get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) + elseif(PYTHON_LIBRARY_RELEASE) + get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) + endif() + endif() + if(NOT _SB_INC_DIR) + if(PYTHON_INCLUDE_DIR) + set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") + elseif(Python_INCLUDE_DIRS) + list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) + endif() + endif() + + # Last-resort defaults relative to inner build + if(NOT _SB_LIB_DIR) + set(_SB_LIB_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64") + endif() + if(NOT _SB_INC_DIR) + set(_SB_INC_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/Include") + endif() + + # Resolve per-config import libraries + set(_py_dbg_lib "") + set(_py_rel_lib "") + + # Use explicit file paths if provided + if(PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") + set(_py_dbg_lib "${PYTHON_LIBRARY_DEBUG}") + endif() + if(PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") + set(_py_rel_lib "${PYTHON_LIBRARY_RELEASE}") + endif() + + # Otherwise, construct by expected names under the lib dir + if(NOT _py_dbg_lib) + set(_cand "${_SB_LIB_DIR}/${_PY_DEBUG_LIB_NAME}") + if(EXISTS "${_cand}") + set(_py_dbg_lib "${_cand}") + endif() + endif() + if(NOT _py_rel_lib) + set(_cand "${_SB_LIB_DIR}/${_PY_RELEASE_LIB_NAME}") + if(EXISTS "${_cand}") + set(_py_rel_lib "${_cand}") + endif() + endif() + + # Create or update Python::Python so it always points to superbuild import libs if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) + endif() + + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" + ) + + # IMPORTANT: on MSVC the import library must be set via IMPORTED_IMPLIB_* (not IMPORTED_LOCATION_*) + if(EXISTS "${_py_rel_lib}") set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Python_INCLUDE_DIRS}" + IMPORTED_IMPLIB_RELEASE "${_py_rel_lib}" + IMPORTED_IMPLIB_RELWITHDEBINFO "${_py_rel_lib}" + IMPORTED_IMPLIB_MINSIZEREL "${_py_rel_lib}" ) - if(WIN32) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB "${Python_LIBRARIES}" - ) - else() - set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION "${Python_LIBRARIES}" - ) - endif() endif() + if(EXISTS "${_py_dbg_lib}") + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_py_dbg_lib}" + ) + endif() + + if(NOT (EXISTS "${_py_rel_lib}" OR EXISTS "${_py_dbg_lib}" OR TARGET Python3::Python)) + message(FATAL_ERROR + "Python import libraries not found for Windows/MSVC.\n" + "Searched:\n _SB_LIB_DIR='${_SB_LIB_DIR}'\n" + "Expected: ${_PY_RELEASE_LIB_NAME} / ${_PY_DEBUG_LIB_NAME}\n" + "Or explicit: PYTHON_LIBRARY_RELEASE='${PYTHON_LIBRARY_RELEASE}', PYTHON_LIBRARY_DEBUG='${PYTHON_LIBRARY_DEBUG}'\n" + "Include dir: _SB_INC_DIR='${_SB_INC_DIR}'") + endif() + set(_SCIRUN_MODULES_PY_OK TRUE) - endif() + endif() # MSVC if(NOT _SCIRUN_MODULES_PY_OK) message(FATAL_ERROR "BUILD_WITH_PYTHON is ON, but Python (Interpreter + Development) could not be found.") @@ -124,7 +190,6 @@ endif() # BUILD_WITH_PYTHON # Link dependencies # ==================================================================================== -# Always link these: target_link_libraries(Modules_Python PRIVATE Dataflow_Network @@ -133,29 +198,37 @@ target_link_libraries(Modules_Python Core_Thread ) -# Only link Python-related libs when enabled: if(BUILD_WITH_PYTHON) - # Link the Python runtime and your Core_Python layer target_link_libraries(Modules_Python PRIVATE Python::Python Core_Python ) + target_compile_definitions(Modules_Python PRIVATE BUILD_WITH_PYTHON) + if(MSVC) + # If any transitive lib autolinks release python313.lib, ignore it in Debug + target_link_options(Modules_Python PRIVATE + $<$:/NODEFAULTLIB:python313.lib> + ) + # Optional: define if you rely on static Boost.Python in this module + # target_compile_definitions(Modules_Python PRIVATE BOOST_PYTHON_STATIC_LIB) + endif() endif() # ==================================================================================== -# Tests (kept as in your original) +# Tests (kept) # ==================================================================================== - if(BUILD_WITH_PYTHON) SCIRUN_ADD_TEST_DIR(Tests) endif() # ==================================================================================== -# Diagnostics (helpful while bringing up the superbuild) +# Diagnostics (show what the imported target is *actually* using) # ==================================================================================== if(BUILD_WITH_PYTHON) - message(STATUS "[Modules/Python] Python executable : ${Python_EXECUTABLE}") - message(STATUS "[Modules/Python] Python include(s) : ${Python_INCLUDE_DIRS}") - message(STATUS "[Modules/Python] Python libraries : ${Python_LIBRARIES}") + get_target_property(_py_inc Python::Python INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(_py_dbg Python::Python IMPORTED_IMPLIB_DEBUG) + get_target_property(_py_rel Python::Python IMPORTED_IMPLIB_RELEASE) + message(STATUS "[Modules/Python] Python include(s) : ${_py_inc}") + message(STATUS "[Modules/Python] Python importlib : Debug='${_py_dbg}' Release='${_py_rel}'") endif() \ No newline at end of file From e4e52d426390d5024bb54562d1edde74078d2ecd Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 24 Feb 2026 16:40:57 -0700 Subject: [PATCH 051/140] python path and external lib paths --- Superbuild/BoostExternal.cmake | 1 + Superbuild/Superbuild.cmake | 38 ++ .../Legacy/FiniteElements/CMakeLists.txt | 1 - src/Core/Python/CMakeLists.txt | 381 +++++++++--------- .../Legacy/Teem/Converters/CMakeLists.txt | 79 +++- src/Modules/Legacy/Teem/DataIO/CMakeLists.txt | 71 +++- src/Modules/Legacy/Teem/Misc/CMakeLists.txt | 79 +++- src/Modules/Legacy/Teem/Tend/CMakeLists.txt | 77 +++- 8 files changed, 520 insertions(+), 207 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 27b93c1f70..5797a0bbab 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -39,6 +39,7 @@ set(_BOOST_LIBS atomic thread program_options + serialization ) # Optional compiled libs (usually OFF) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 9aee928e0c..1a2e3f945b 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -551,6 +551,8 @@ if(BUILD_WITH_PYTHON) "-DPYTHON_RUNTIME_DIR:PATH=${_PY_PCBUILD}" "-DPYTHON_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}" "-DPYTHON_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}" + "-DPython_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}" + "-DPython_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}" # Optional hints for legacy find modules "-DPython_EXECUTABLE:FILEPATH=${_PY_EXE}" @@ -842,6 +844,42 @@ if(TARGET Teem_external) message(STATUS "[superbuild] Teem lib dir: ${_teem_lib_dir}") endif() +# --- Provide TetGen include/lib hints even if headers aren't 'installed' --- +if(WITH_TETGEN AND TARGET Tetgen_external) + ExternalProject_Get_Property(Tetgen_external INSTALL_DIR) + ExternalProject_Get_Property(Tetgen_external SOURCE_DIR) + + # Prefer install/include; otherwise fall back to SOURCE_DIR where tetgen.h usually lives + set(_tet_inc "${INSTALL_DIR}/include") + if(NOT EXISTS "${_tet_inc}/tetgen.h") + set(_tet_inc "${SOURCE_DIR}") + endif() + + if(EXISTS "${INSTALL_DIR}/lib64") + set(_tet_lib_dir "${INSTALL_DIR}/lib64") + else() + set(_tet_lib_dir "${INSTALL_DIR}/lib") + endif() + + # Pick the actual library file name (tet.lib vs tetgen.lib) + set(_tet_lib "") + if(EXISTS "${_tet_lib_dir}/tet.lib") + set(_tet_lib "${_tet_lib_dir}/tet.lib") + elseif(EXISTS "${_tet_lib_dir}/tetgen.lib") + set(_tet_lib "${_tet_lib_dir}/tetgen.lib") + endif() + + list(APPEND SCIRUN_CACHE_ARGS + "-DTETGEN_INCLUDE_DIR:PATH=${_tet_inc}" + "-DTETGEN_LIB_DIR:PATH=${_tet_lib_dir}" + ) + if(_tet_lib) + list(APPEND SCIRUN_CACHE_ARGS "-DTETGEN_LIBRARY:FILEPATH=${_tet_lib}") + endif() + + message(STATUS "[superbuild] TetGen include=${_tet_inc} libdir=${_tet_lib_dir} lib=${_tet_lib}") +endif() + # Compose a single CMAKE_PREFIX_PATH for SCIRun get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) set(_joined_prefixes "") diff --git a/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt b/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt index 7cc15cd70f..e7e422f925 100644 --- a/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt @@ -65,7 +65,6 @@ TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_FiniteElements # Core_Persistent # Core_Basis Core_Datatypes_Legacy_Field -# ${SCI_TEEM_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 9da89dcba4..0aa4239bc3 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -28,6 +28,12 @@ # ---- Core/Python CMake ---- cmake_minimum_required(VERSION 3.16) +# Silence CMP0111 locally: we intentionally do NOT set IMPORTED_LOCATION_* on MSVC +# to avoid the DLL being placed on the link line by CMake/VS generators. +if(POLICY CMP0111) + cmake_policy(SET CMP0111 OLD) +endif() + # --- Guard against system Python being injected via ${Python_LIBRARIES} / ${PYTHON_LIBRARIES} unset(Python_LIBRARIES) unset(PYTHON_LIBRARIES) @@ -55,13 +61,13 @@ set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY LINK_LIBRARIES "") get_property(_dir_links_after DIRECTORY PROPERTY LINK_LIBRARIES) message(STATUS "[Diag/Core_Python] DIR LINK_LIBRARIES(after)=${_dir_links_after}") -# Library target (uses project macro from top-level) +# ---- Library target (uses project macro from top-level) ---- SCIRUN_ADD_LIBRARY(Core_Python ${Core_Python_HEADERS} ${Core_Python_SRCS} ) -# --- Also wipe anything that was still captured on the target itself (belt-and-suspenders) --- +# (Optional) Belt-and-suspenders wipe in case macro captured anything already set_target_properties(Core_Python PROPERTIES LINK_LIBRARIES "") # Preserve original shared define behavior @@ -69,7 +75,7 @@ if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_Core_Python) endif() -# If Python enabled, expose BUILD_WITH_PYTHON so dependents (and sources) can #ifdef code +# If Python enabled, expose BUILD_WITH_PYTHON so dependents can #ifdef if(BUILD_WITH_PYTHON) target_compile_definitions(Core_Python PUBLIC BUILD_WITH_PYTHON) else() @@ -82,12 +88,12 @@ SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== # Python wiring (superbuild-first, robust fallbacks) # Expected superbuild variables (preferred): -# PYTHON_INCLUDE_DIR -> .../Python_external/Include -# PYTHON_PC_INCLUDE_DIR -> .../Python_external/PC (optional but recommended on Windows) -# PYTHON_LIBRARY_RELEASE -> .../PCbuild/amd64/python313.lib -# PYTHON_LIBRARY_DEBUG -> .../PCbuild/amd64/python313_d.lib -# PYTHON_RUNTIME_DIR -> .../PCbuild/amd64 (optional, for DLLs at runtime) -# PYTHON_EXECUTABLE -> .../PCbuild/amd64/python.exe (optional, used for PYTHONPATH query) +# PYTHON_INCLUDE_DIR -> .../Python_external/Include +# PYTHON_PC_INCLUDE_DIR -> .../Python_external/PC +# PYTHON_LIBRARY_RELEASE -> .../PCbuild/amd64/python313.lib +# PYTHON_LIBRARY_DEBUG -> .../PCbuild/amd64/python313_d.lib +# PYTHON_RUNTIME_DIR -> .../PCbuild/amd64 (optional) +# PYTHON_EXECUTABLE -> .../PCbuild/amd64/python.exe (optional) # ==================================================================================== set(_SCIRUN_PY_OK FALSE) @@ -97,74 +103,27 @@ set(_PY_LIB_DBG "") set(_PY_LIB_REL "") # ---- Path-first: use explicit superbuild variables if provided ---- -# Expected (from superbuild): -# PYTHON_INCLUDE_DIR -> .../Python_external/Include -# PYTHON_PC_INCLUDE_DIR -> .../Python_external/PC -# PYTHON_LIBRARY_RELEASE -> .../PCbuild/amd64/python313.lib -# PYTHON_LIBRARY_DEBUG -> .../PCbuild/amd64/python313_d.lib -# PYTHON_RUNTIME_DIR -> .../PCbuild/amd64 (optional) -# PYTHON_EXECUTABLE -> .../PCbuild/amd64/python.exe (optional) - if(PYTHON_LIBRARY_DEBUG AND PYTHON_LIBRARY_RELEASE AND PYTHON_INCLUDE_DIR) - if(NOT EXISTS "${PYTHON_LIBRARY_DEBUG}") - message(FATAL_ERROR "PYTHON_LIBRARY_DEBUG does not exist: ${PYTHON_LIBRARY_DEBUG}") - endif() - if(NOT EXISTS "${PYTHON_LIBRARY_RELEASE}") - message(FATAL_ERROR "PYTHON_LIBRARY_RELEASE does not exist: ${PYTHON_LIBRARY_RELEASE}") - endif() - if(NOT EXISTS "${PYTHON_INCLUDE_DIR}") - message(FATAL_ERROR "PYTHON_INCLUDE_DIR does not exist: ${PYTHON_INCLUDE_DIR}") - endif() + foreach(_check "${PYTHON_LIBRARY_DEBUG};${PYTHON_LIBRARY_RELEASE};${PYTHON_INCLUDE_DIR}") + if(NOT EXISTS "${_check}") + message(FATAL_ERROR "Python superbuild hint does not exist: ${_check}") + endif() + endforeach() set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") # Includes: Include (always), PC (optional on Windows for pyconfig.h) - set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") endif() - # Create or override the imported target to **force** superbuild Python - if(NOT TARGET Python::Python) - add_library(Python::Python UNKNOWN IMPORTED) - endif() - - if(MSVC) - # On MSVC, link against the import library via IMPORTED_IMPLIB_* (NOT IMPORTED_LOCATION_*) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_PY_LIB_DBG}" - IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_IMPLIB_RELEASE "${_PY_LIB_REL}" - IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_REL}" - INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" - ) - else() - # Non-Windows: link directly to the shared/static lib path - set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" - INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" - ) - endif() - - # Provide a best-effort Python_EXECUTABLE for diagnostics/macros - if(PYTHON_EXECUTABLE AND EXISTS "${PYTHON_EXECUTABLE}") - set(_PY_EXECUTABLE "${PYTHON_EXECUTABLE}") - elseif(PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") - if(EXISTS "${PYTHON_RUNTIME_DIR}/python.exe") - set(_PY_EXECUTABLE "${PYTHON_RUNTIME_DIR}/python.exe") - endif() - endif() - set(_SCIRUN_PY_OK TRUE) endif() -# ---- Fallback: try modern FindPython / FindPython3 (scoped to superbuild root if hinted) ---- +# ---- Fallback: try modern FindPython / FindPython3 (hinted to superbuild root if provided) ---- if(NOT _SCIRUN_PY_OK) - # If the superbuild gave us a root, hint to CMake if(DEFINED PYTHON_ROOT_DIR AND EXISTS "${PYTHON_ROOT_DIR}") set(_PY_HINTS ROOT_DIR "${PYTHON_ROOT_DIR}") elseif(DEFINED PYTHON_HOME_DIR AND EXISTS "${PYTHON_HOME_DIR}") @@ -173,18 +132,11 @@ if(NOT _SCIRUN_PY_OK) set(_PY_HINTS) endif() - # Prefer modern module name "Python" (CMake >= 3.15) find_package(Python QUIET COMPONENTS Interpreter Development ${_PY_HINTS}) - if(Python_Interpreter_FOUND AND Python_Development_FOUND) - if(TARGET Python::Python) - # Good: prefer the imported target directly - set(_SCIRUN_PY_OK TRUE) - set(_PY_EXECUTABLE "${Python_EXECUTABLE}") - # Extract library paths for later macros, if available - set(_PY_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") - # Try to collect per-config (if provided) - # Python::Python usually has single-location; but it's fine for MSVC if it resolves to .lib - endif() + if(Python_Interpreter_FOUND AND Python_Development_FOUND AND TARGET Python::Python) + set(_SCIRUN_PY_OK TRUE) + set(_PY_EXECUTABLE "${Python_EXECUTABLE}") + set(_PY_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") endif() endif() @@ -192,42 +144,141 @@ endif() if(NOT _SCIRUN_PY_OK) find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) - if(NOT TARGET Python::Python) - add_library(Python::Python UNKNOWN IMPORTED) - set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${PYTHON_INCLUDE_DIRS}" - ) - if(WIN32) - set_target_properties(Python::Python PROPERTIES IMPORTED_IMPLIB "${PYTHON_LIBRARIES}") - else() - set_target_properties(Python::Python PROPERTIES IMPORTED_LOCATION "${PYTHON_LIBRARIES}") - endif() - endif() set(_SCIRUN_PY_OK TRUE) set(_PY_EXECUTABLE "${PYTHON_EXECUTABLE}") set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") + # Legacy variables (PYTHON_LIBRARIES) exist, but we will still build our own imported target below. + if(PYTHON_DEBUG_LIBRARY AND EXISTS "${PYTHON_DEBUG_LIBRARY}") + set(_PY_LIB_DBG "${PYTHON_DEBUG_LIBRARY}") + endif() + if(PYTHON_LIBRARY AND EXISTS "${PYTHON_LIBRARY}") + set(_PY_LIB_REL "${PYTHON_LIBRARY}") + endif() endif() if(NOT _SCIRUN_PY_OK) message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build Core_Python.") endif() +# ==================================================================================== +# Ensure Python::Python imported target exists and points to superbuild import libs +# Accept both new (PY_EXT_LIB_DIR/PY_INCLUDE_DIR) and legacy vars. +# ==================================================================================== + +set(_PY_IMPORTED_OK FALSE) + +# Prefer explicit include dir hints from superbuild for MSVC usage requirements +set(_SB_INC_DIR "") +if(PYTHON_INCLUDE_DIR) + set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") +elseif(Python_INCLUDE_DIRS) + list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) +endif() +if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") +endif() + +# Derive a lib dir if only file paths were given +set(_SB_LIB_DIR "") +if(PYTHON_LIBRARY_DEBUG) + get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) +elseif(PYTHON_LIBRARY_RELEASE) + get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) +elseif(PY_EXT_LIB_DIR) + set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") +endif() + +# Fill missing per-config lib paths if needed +if(NOT _PY_LIB_DBG AND _SB_LIB_DIR) + foreach(_name "python313_d.lib" "python312_d.lib" "python311_d.lib" "python310_d.lib") + if(EXISTS "${_SB_LIB_DIR}/${_name}") + set(_PY_LIB_DBG "${_SB_LIB_DIR}/${_name}") + break() + endif() + endforeach() +endif() +if(NOT _PY_LIB_REL AND _SB_LIB_DIR) + foreach(_name "python313.lib" "python312.lib" "python311.lib" "python310.lib") + if(EXISTS "${_SB_LIB_DIR}/${_name}") + set(_PY_LIB_REL "${_SB_LIB_DIR}/${_name}") + break() + endif() + endforeach() +endif() + +# Create/override the imported target +if(NOT TARGET Python::Python) + add_library(Python::Python UNKNOWN IMPORTED) +endif() + +# Always propagate includes via the imported target +if(_SB_INC_DIR) + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" + ) +elseif(_PY_INCLUDE_DIRS) + list(REMOVE_DUPLICATES _PY_INCLUDE_DIRS) + set_target_properties(Python::Python PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" + ) +endif() + +if(MSVC) + # --- MSVC: set ONLY IMPORTED_IMPLIB_* (never IMPORTED_LOCATION_*) so link.exe uses .lib, NOT .dll --- + if(EXISTS "${_PY_LIB_REL}") + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_PY_LIB_REL}" + IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_REL}" + ) + endif() + if(EXISTS "${_PY_LIB_DBG}") + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_PY_LIB_DBG}" + ) + endif() +else() + # Non-Windows: point to the real binary (shared/static) + if(EXISTS "${_PY_LIB_REL}") + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + ) + endif() + if(EXISTS "${_PY_LIB_DBG}") + set_target_properties(Python::Python PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + ) + endif() +endif() + +# Consider imported OK if target exists now +if(TARGET Python::Python) + set(_PY_IMPORTED_OK TRUE) +endif() + +if(NOT _PY_IMPORTED_OK) + message(FATAL_ERROR + "Python::Python imported target could not be created for Core_Python.\n" + "Checked:\n PY_EXT_LIB_DIR='${PY_EXT_LIB_DIR}'\n PYTHON_INCLUDE_DIR='${PYTHON_INCLUDE_DIR}'\n" + " PYTHON_LIBRARY_DEBUG='${PYTHON_LIBRARY_DEBUG}'\n PYTHON_LIBRARY_RELEASE='${PYTHON_LIBRARY_RELEASE}'\n" + "Hint: ensure the superbuild passes these cache args and that Python_external has built import libs." + ) +endif() + # ==================================================================================== # Platform-specific compile definitions (PYTHONPATH, etc.) -# - We always define the macros so sources never see an undefined identifier. -# - If we have a Python executable, we query sysconfig for site-packages parent; otherwise fallback to empty. # ==================================================================================== # Compute python name like python313 for macros/diagnostics set(_PYTHON_NAME "") -set(_SCIRUN_PY_DIGITS "") # "313" form; useful for Boost.Python lib name +set(_SCIRUN_PY_DIGITS "") # "313" form -# Try derive digits from explicit libraries first (handles 3.10+) if(NOT _SCIRUN_PY_DIGITS) foreach(_cand "${_PY_LIB_DBG}" "${_PY_LIB_REL}") if(_cand) get_filename_component(_cand_name "${_cand}" NAME) - # Match python313[_d].lib or libpython313[_d].lib if(_cand_name MATCHES "python([0-9]+)(_d)?\\.lib$") set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") break() @@ -235,24 +286,21 @@ if(NOT _SCIRUN_PY_DIGITS) endif() endforeach() endif() - -# If CMake provided version numbers, build name from those if(NOT _SCIRUN_PY_DIGITS AND DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) string(CONCAT _SCIRUN_PY_DIGITS "${Python_VERSION_MAJOR}" "${Python_VERSION_MINOR}") endif() - if(_SCIRUN_PY_DIGITS) set(_PYTHON_NAME "python${_SCIRUN_PY_DIGITS}") endif() -# Compute parent of site-packages using Python (optional) +# Try to compute parent of site-packages using Python (optional) set(_PYTHON_MODULE_SEARCH_PARENT "") -if(_PY_EXECUTABLE AND EXISTS "${_PY_EXECUTABLE}") +if(PYTHON_EXECUTABLE AND EXISTS "${PYTHON_EXECUTABLE}") set(_SCIRUN_PY_QUERY "import sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" ) execute_process( - COMMAND "${_PY_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" + COMMAND "${PYTHON_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" OUTPUT_VARIABLE _PY_SITE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE @@ -263,23 +311,20 @@ if(_PY_EXECUTABLE AND EXISTS "${_PY_EXECUTABLE}") endif() endif() -# Always define these macros; use empty string if unknown +# Apply includes + macros +target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) if(WIN32) - target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" "PYTHONNAME=L\"${_PYTHON_NAME}\"" ) elseif(APPLE) - # Apple-specific legacy code paths could also need libdir; leave empty unless known - target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" "PYTHONLIBDIR=L\"\"" "PYTHONLIB=L\"\"" ) else() - target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) target_compile_definitions(Core_Python PRIVATE "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" ) @@ -292,24 +337,20 @@ target_link_libraries(Core_Python PRIVATE Python::Python SCIRunPythonAPI - ${SCI_BOOST_LIBRARY} # keep existing boost meta-lib if your project uses it + ${SCI_BOOST_LIBRARY} Core_Matlab Core_Datatypes Core_Datatypes_Legacy_Field ) # --- Debug-only: ignore autolinked *release* python import lib (e.g., from Boost.Python) --- -# We already link the correct Debug import lib (pythonXY_d.lib) by full path. -# Compute the release filename to ignore (e.g., "python313.lib"), then pass /NODEFAULTLIB:. if(MSVC) - # If digits were derived above (e.g., "313"), ignore exactly python313.lib. if(_SCIRUN_PY_DIGITS) set(_SCIRUN_PY_RELEASE_NAME "python${_SCIRUN_PY_DIGITS}.lib") target_link_options(Core_Python PRIVATE $<$:/NODEFAULTLIB:${_SCIRUN_PY_RELEASE_NAME}> ) else() - # Fallback: also ignore the generic "python3.lib" name some toolchains request (rare). target_link_options(Core_Python PRIVATE $<$:/NODEFAULTLIB:python3.lib> ) @@ -318,148 +359,88 @@ endif() # ==================================================================================== # Boost.Python handling -# - Recommended on MSVC: explicit linking to tolerate 'lib' prefix naming, vc toolset, and -gd debug suffix. -# - Otherwise: rely on MSVC autolink (ensure Boost lib dir is on link path). # ==================================================================================== - -# Toggle (pass from superbuild via -DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK=ON) option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on autolink" OFF) - -# Digits for Boost.Python name (e.g., 313) set(_SCIRUN_PY_M "${_SCIRUN_PY_DIGITS}") if(MSVC) if(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK) - # Disable Boost autolink on this target - target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB) - #static - target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_STATIC_LIB) - - # The Boost lib directory should be passed from the superbuild: - # -DSCI_BOOST_LIBRARY_DIR=E:/.../Externals/Install/Boost_external/lib + target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB BOOST_PYTHON_STATIC_LIB) if (NOT DEFINED SCI_BOOST_LIBRARY_DIR OR NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") message(FATAL_ERROR "SCI_BOOST_LIBRARY_DIR is not set or does not exist. Pass it from the superbuild.") endif() - - # Gather candidates for Debug (-gd-) with and without 'lib' prefix file(GLOB _bp_dbg_candidates "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" ) - - # Gather candidates for Release (no -gd-) with and without 'lib' prefix file(GLOB _bp_rel_candidates_all "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" ) - # Filter out accidental debug files from the release list set(_bp_rel_candidates "") foreach(_cand IN LISTS _bp_rel_candidates_all) if(NOT _cand MATCHES "-gd-") list(APPEND _bp_rel_candidates "${_cand}") endif() endforeach() - - # Pick the most specific candidate (sort + take last) if(_bp_dbg_candidates) - list(SORT _bp_dbg_candidates) - list(REVERSE _bp_dbg_candidates) + list(SORT _bp_dbg_candidates) list(REVERSE _bp_dbg_candidates) list(GET _bp_dbg_candidates 0 SCI_BOOST_PYTHON_LIB_DEBUG) endif() if(_bp_rel_candidates) - list(SORT _bp_rel_candidates) - list(REVERSE _bp_rel_candidates) + list(SORT _bp_rel_candidates) list(REVERSE _bp_rel_candidates) list(GET _bp_rel_candidates 0 SCI_BOOST_PYTHON_LIB_RELEASE) endif() - - if(NOT SCI_BOOST_PYTHON_LIB_DEBUG OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}") - message(FATAL_ERROR - "Boost.Python Debug lib not found under '${SCI_BOOST_LIBRARY_DIR}'. " - "Looked for libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib or boost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" - ) - endif() - if(NOT SCI_BOOST_PYTHON_LIB_RELEASE OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_RELEASE}") - message(FATAL_ERROR - "Boost.Python Release lib not found under '${SCI_BOOST_LIBRARY_DIR}'. " - "Looked for libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib or boost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" - ) + if(NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}" OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_RELEASE}") + message(FATAL_ERROR "Boost.Python libs not found under '${SCI_BOOST_LIBRARY_DIR}'.") endif() - - # Link the exact files (per-config) target_link_libraries(Core_Python PRIVATE debug "${SCI_BOOST_PYTHON_LIB_DEBUG}" optimized "${SCI_BOOST_PYTHON_LIB_RELEASE}" ) - - message(STATUS "[Core/Python] Explicitly linking Boost.Python:") - message(STATUS " Debug : ${SCI_BOOST_PYTHON_LIB_DEBUG}") - message(STATUS " Release : ${SCI_BOOST_PYTHON_LIB_RELEASE}") else() - # Keep autolink, but help the linker find the folder if (DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") target_link_directories(Core_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") endif() message(STATUS "[Core/Python] Using MSVC autolink for Boost.Python (ensure lib names match).") - # For debugging the exact name autolink requests, uncomment: - # target_compile_definitions(Core_Python PRIVATE BOOST_LIB_DIAGNOSTIC) endif() else() - # Non-Windows: explicitly link Boost.Python by name if available - set(_bp_names - "boost_python${_SCIRUN_PY_M}" - "boost_python3" - "boost_python" - ) - set(_bp_lib "") - - # Prefer superbuild lib dir if present - if(DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") - find_library(BOOST_PYTHON_LIB - NAMES ${_bp_names} - PATHS "${SCI_BOOST_LIBRARY_DIR}" "${SCI_BOOST_PREFIX}/lib" "${SCI_BOOST_PREFIX}/lib64" - NO_DEFAULT_PATH - ) - set(_bp_lib "${BOOST_PYTHON_LIB}") - endif() - - # Fallback to default search paths - if(NOT _bp_lib) + set(_bp_names "boost_python${_SCIRUN_PY_M}" "boost_python3" "boost_python") + find_library(BOOST_PYTHON_LIB NAMES ${_bp_names} PATHS "${SCI_BOOST_LIBRARY_DIR}" "${SCI_BOOST_PREFIX}/lib" "${SCI_BOOST_PREFIX}/lib64" NO_DEFAULT_PATH) + if(NOT BOOST_PYTHON_LIB) find_library(BOOST_PYTHON_LIB NAMES ${_bp_names}) - set(_bp_lib "${BOOST_PYTHON_LIB}") endif() - - if(_bp_lib) - target_link_libraries(Core_Python PRIVATE "${_bp_lib}") - message(STATUS "[Core/Python] Linking Boost.Python: ${_bp_lib}") + if(BOOST_PYTHON_LIB) + target_link_libraries(Core_Python PRIVATE "${BOOST_PYTHON_LIB}") + message(STATUS "[Core/Python] Linking Boost.Python: ${BOOST_PYTHON_LIB}") else() - message(WARNING - "[Core/Python] Boost.Python library not found on this platform. " - "Link may fail if Boost.Python symbols are used.") + message(WARNING "[Core/Python] Boost.Python library not found on this platform.") endif() endif() # Debug-only macro (matches your previous behavior) -set_target_properties(Core_Python - PROPERTIES - COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON" -) +set_target_properties(Core_Python PROPERTIES COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON") -# Helpful diagnostics -message(STATUS "[Core/Python] PY includes : ${_PY_INCLUDE_DIRS}") -message(STATUS "[Core/Python] PY exec : ${_PY_EXECUTABLE}") -message(STATUS "[Core/Python] PY name : ${_PYTHON_NAME}") -message(STATUS "[Core/Python] PY path : ${_PYTHON_MODULE_SEARCH_PARENT}") -if(_PY_LIB_DBG) - message(STATUS "[Core/Python] PY lib (dbg): ${_PY_LIB_DBG}") -endif() -if(_PY_LIB_REL) - message(STATUS "[Core/Python] PY lib (rel): ${_PY_LIB_REL}") +# ---- TEMP: strip any explicit system Python importlib if it leaked in ---- +get_target_property(_cp_links Core_Python LINK_LIBRARIES) +if(_cp_links) + set(_cleaned "") + foreach(_L IN LISTS _cp_links) + file(TO_CMAKE_PATH "${_L}" _N) + if(_N MATCHES "^C:/Program Files/[^/]*/Python[^/]*/libs/python[0-9]+(_d)?\\.lib$") + # skip system python lib + else() + list(APPEND _cleaned "${_L}") + endif() + endforeach() + set_target_properties(Core_Python PROPERTIES LINK_LIBRARIES "${_cleaned}") endif() -# --- DIAGNOSTICS: show who is adding system Python into Core_Python --- -get_target_property(_cp_links Core_Python LINK_LIBRARIES) -get_target_property(_cp_if Core_Python INTERFACE_LINK_LIBRARIES) -message(STATUS "[Diag/Core_Python] LINK_LIBRARIES=${_cp_links}") -message(STATUS "[Diag/Core_Python] INTERFACE_LINK_LIBRARIES=${_cp_if}") -message(STATUS "[Diag/Core_Python] Python::Python IMPORTED_IMPLIB_DEBUG=$") -message(STATUS "[Diag/Core_Python] Python::Python IMPORTED_IMPLIB_RELEASE=$") \ No newline at end of file +# ---- Helpful diagnostics (actual evaluated properties) ---- +get_target_property(_py_implib_dbg Python::Python IMPORTED_IMPLIB_DEBUG) +get_target_property(_py_implib_rel Python::Python IMPORTED_IMPLIB_RELEASE) +get_target_property(_cp_links2 Core_Python LINK_LIBRARIES) + +message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_DEBUG='${_py_implib_dbg}'") +message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_RELEASE='${_py_implib_rel}'") +message(STATUS "[Diag/Core_Python] LINK_LIBRARIES=${_cp_links2}") \ No newline at end of file diff --git a/src/Modules/Legacy/Teem/Converters/CMakeLists.txt b/src/Modules/Legacy/Teem/Converters/CMakeLists.txt index 24935468ae..b701d83647 100644 --- a/src/Modules/Legacy/Teem/Converters/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/Converters/CMakeLists.txt @@ -46,14 +46,89 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_Converters ${Modules_Legacy_Teem_Converters_HEADERS} ) -TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_Converters +# ========================================================== +# Teem discovery (same pattern as Core_Geometry_Primitives) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +target_compile_definitions(Modules_Legacy_Teem_Converters PRIVATE TEEM_STATIC) + +target_link_libraries(Modules_Legacy_Teem_Converters + PRIVATE Dataflow_Network Core_Datatypes Core_Datatypes_Legacy_Nrrd Core_Algorithms_Legacy_Converter #TODO: remove link - ${SCI_TEEM_LIBRARY} + ${_teem_target} ) +# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: +if(TARGET ZLIB::ZLIB) + target_link_libraries(Modules_Legacy_Teem_Converters PRIVATE ZLIB::ZLIB) +endif() + IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Teem_Converters) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt b/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt index e17aa1a407..7ea0060641 100644 --- a/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt @@ -40,12 +40,81 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_DataIO ${Modules_Legacy_Teem_DataIO_SRCS} ) +# ========================================================== +# Teem discovery (same pattern as Core_Geometry_Primitives) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +target_compile_definitions(Modules_Legacy_Teem_DataIO PRIVATE TEEM_STATIC) + TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_DataIO Dataflow_Network Core_Datatypes Core_Datatypes_Legacy_Nrrd Core_ImportExport - ${SCI_TEEM_LIBRARY} + ${_teem_target} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Teem/Misc/CMakeLists.txt b/src/Modules/Legacy/Teem/Misc/CMakeLists.txt index aea2492f86..ea019d42f6 100644 --- a/src/Modules/Legacy/Teem/Misc/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/Misc/CMakeLists.txt @@ -50,13 +50,88 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_Misc ${Modules_Legacy_Teem_Misc_HEADERS} ) -TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_Misc +# ========================================================== +# Teem discovery (same pattern as Core_Geometry_Primitives) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +target_compile_definitions(Modules_Legacy_Teem_Misc PRIVATE TEEM_STATIC) + +target_link_libraries(Modules_Legacy_Teem_Misc + PRIVATE Dataflow_Network Core_Datatypes Core_Datatypes_Legacy_Nrrd - ${SCI_TEEM_LIBRARY} + ${_teem_target} ) +# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: +if(TARGET ZLIB::ZLIB) + target_link_libraries(Modules_Legacy_Teem_Misc PRIVATE ZLIB::ZLIB) +endif() + IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Teem_Misc) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Teem/Tend/CMakeLists.txt b/src/Modules/Legacy/Teem/Tend/CMakeLists.txt index 0fad81d329..08feca1827 100644 --- a/src/Modules/Legacy/Teem/Tend/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/Tend/CMakeLists.txt @@ -65,17 +65,92 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_Tend ${Modules_Legacy_Teem_Tend_HEADERS} ) +# ========================================================== +# Teem discovery (same pattern as Core_Geometry_Primitives) +# ========================================================== +# Prefer a config package if available +find_package(Teem CONFIG QUIET) + +if(TARGET Teem::teem) + set(_teem_target Teem::teem) +else() + # Fallback to superbuild exports + if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) + message(FATAL_ERROR + "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") + endif() + + set(_teem_lib "") + if(WIN32) + if(EXISTS "${Teem_LIB_DIR}/teem.lib") + set(_teem_lib "${Teem_LIB_DIR}/teem.lib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") + endif() + elseif(APPLE) + if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") + set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + else() + if(EXISTS "${Teem_LIB_DIR}/libteem.so") + set(_teem_lib "${Teem_LIB_DIR}/libteem.so") + elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") + set(_teem_lib "${Teem_LIB_DIR}/libteem.a") + endif() + endif() + + if(NOT _teem_lib) + find_library(TEEM_LIBRARY + NAMES teem libteem + HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" + ) + if(TEEM_LIBRARY) + set(_teem_lib "${TEEM_LIBRARY}") + endif() + endif() + + if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") + message(FATAL_ERROR + "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" + "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" + "Ensure the Teem external installs libteem/teem.") + endif() + + add_library(Teem::teem UNKNOWN IMPORTED) + set_target_properties(Teem::teem PROPERTIES + IMPORTED_LOCATION "${_teem_lib}" + INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + + set(_teem_target Teem::teem) +endif() + +# ------------------------------------------ +# Static Teem consumption: avoid dllimport +# ------------------------------------------ +target_compile_definitions(Core_Algorithms_Legacy_Converter PRIVATE TEEM_STATIC) + TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_Tend + PRIVATE Core_Datatypes Core_Datatypes_Legacy_Nrrd Core_Geometry_Primitives Core_Persistent Dataflow_Network - ${SCI_TEEM_LIBRARY} + ${_teem_target} #${SCI_PNG_LIBRARY} #${SCI_ZLIB_LIBRARY} ) +# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: +if(TARGET ZLIB::ZLIB) + target_link_libraries(Modules_Legacy_Teem_Tend PRIVATE ZLIB::ZLIB) +endif() + IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Teem_Tend) ENDIF(BUILD_SHARED_LIBS) From 0df70da2b197d33e78098f3e7c36948212db739d Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 24 Feb 2026 16:54:22 -0700 Subject: [PATCH 052/140] tetgen inlcude path --- src/Modules/Legacy/Fields/CMakeLists.txt | 64 ++++++++++++++++-------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/src/Modules/Legacy/Fields/CMakeLists.txt b/src/Modules/Legacy/Fields/CMakeLists.txt index e8b50e076f..2793977fa1 100644 --- a/src/Modules/Legacy/Fields/CMakeLists.txt +++ b/src/Modules/Legacy/Fields/CMakeLists.txt @@ -232,33 +232,53 @@ IF(WITH_TETGEN) ADD_DEFINITIONS(-DWITH_TETGEN) ENDIF() +# Create the target (unchanged) SCIRUN_ADD_LIBRARY(Modules_Legacy_Fields ${Modules_Legacy_Fields_HEADERS} ${Modules_Legacy_Fields_SRCS} ) -TARGET_LINK_LIBRARIES(Modules_Legacy_Fields - Dataflow_Network - #TODO: remove - Core_Serialization_Network - Core_Algorithms_Legacy_Fields - Algorithms_Base - Core_Basis - Core_Datatypes - Core_Datatypes_Legacy_Bundle - Core_Exceptions_Legacy - Core_Geometry_Primitives - Core_Math - Core_Parser - Core_Util_Legacy - Graphics_Widgets - Graphics_Datatypes +# ---- Convert to keyword signature and keep all links here ---- +target_link_libraries(Modules_Legacy_Fields + PRIVATE + Dataflow_Network + # TODO: remove + Core_Serialization_Network + Core_Algorithms_Legacy_Fields + Algorithms_Base + Core_Basis + Core_Datatypes + Core_Datatypes_Legacy_Bundle + Core_Exceptions_Legacy + Core_Geometry_Primitives + Core_Math + Core_Parser + Core_Util_Legacy + Graphics_Widgets + Graphics_Datatypes ) -IF(WITH_TETGEN) - TARGET_LINK_LIBRARIES(Modules_Legacy_Fields ${TETGEN_LIBRARY}) -ENDIF() +# ---- TetGen wiring (include + link + define) ---- +if(WITH_TETGEN) + # Add the include directory so 'tetgen.h' is found + if(DEFINED TETGEN_INCLUDE_DIR AND EXISTS "${TETGEN_INCLUDE_DIR}") + target_include_directories(Modules_Legacy_Fields PRIVATE "${TETGEN_INCLUDE_DIR}") + else() + message(FATAL_ERROR "WITH_TETGEN=ON but TETGEN_INCLUDE_DIR is not set or does not exist.") + endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Fields) -ENDIF() + # Link the TetGen library passed from superbuild + if(DEFINED TETGEN_LIBRARY AND EXISTS "${TETGEN_LIBRARY}") + target_link_libraries(Modules_Legacy_Fields PRIVATE "${TETGEN_LIBRARY}") + else() + message(FATAL_ERROR "WITH_TETGEN=ON but TETGEN_LIBRARY is not set or does not exist.") + endif() + + # Define TETLIBRARY when consuming TetGen as a library + target_compile_definitions(Modules_Legacy_Fields PRIVATE TETLIBRARY) +endif() + +# Shared library define (unchanged) +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Modules_Legacy_Fields) +endif() \ No newline at end of file From b976d409b939027663f55faff024b0d689e3b67b Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 27 Feb 2026 15:51:15 -0700 Subject: [PATCH 053/140] tetgen not found issue --- Superbuild/Superbuild.cmake | 170 +++++++++++------------ src/CMakeLists.txt | 34 ++++- src/Core/Python/CMakeLists.txt | 128 ++++++++--------- src/Modules/Legacy/Fields/CMakeLists.txt | 7 + 4 files changed, 176 insertions(+), 163 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 1a2e3f945b..bba28e319b 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -104,7 +104,7 @@ if (WIN32 AND NOT BUILD_HEADLESS) if (NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") set(_qt_default "C:/Qt/6.10.1/msvc2022_64") if (IS_DIRECTORY "${_qt_default}") - message(STATUS "Qt_PATH not set or invalid — defaulting to ${_qt_default}") + message(STATUS "Qt_PATH not set or invalid — defaulting to ${_qt_default}") set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) endif() endif() @@ -244,7 +244,7 @@ endif() if(WITH_TETGEN) message(STATUS "Configuring Tetgen under GPL. Disable WITH_TETGEN to skip.") - ADD_EXTERNAL(${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external) + ADD_EXTERNAL(${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external) # <- lowercase g endif() if(WITH_OSPRAY) @@ -335,7 +335,7 @@ function(_sb_export_inc_lib pkg target) set(_lib "${INSTALL_DIR}/lib") endif() - # Export include dir (unconditionally; path will exist by build time) + # Export include dir (unconditionally; path may exist after build) set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") @@ -432,8 +432,8 @@ _sb_export_inc_lib(Teem Teem_external) _sb_export_inc_lib(Tny Tny_external) _sb_export_inc_lib(LodePng LodePng_external) _sb_export_inc_lib(Cleaver2 Cleaver2_external) -_sb_export_inc_lib(SQLite SQLite_external) -if(WITH_TETGEN AND TARGET Tetgen_external) +_sb_export_inc_lib(SQLite SQLite_external) +if(WITH_TETGEN AND TARGET Tetgen_external) # <- lowercase g _sb_export_inc_lib(Tetgen Tetgen_external) endif() if(WIN32 AND TARGET Glew_external) @@ -441,9 +441,14 @@ if(WIN32 AND TARGET Glew_external) endif() # ========================= -# Build SCIRun cache args +# Build SCIRun cache args (APPEND, do not reset) # ========================= -set(SCIRUN_CACHE_ARGS +# Initialize once, then append everywhere (avoid wiping earlier appends) +if(NOT DEFINED SCIRUN_CACHE_ARGS) + set(SCIRUN_CACHE_ARGS "") +endif() + +list(APPEND SCIRUN_CACHE_ARGS "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}" @@ -492,7 +497,6 @@ if(BUILD_WITH_PYTHON) endif() endif() - # Fallback: if the interpreter didn’t run (first configure), try to read cached values you exported if(NOT _PY_MAJ OR NOT _PY_MIN) if(DEFINED PY_MAJOR AND DEFINED PY_MINOR) set(_PY_MAJ "${PY_MAJOR}") @@ -504,10 +508,6 @@ if(BUILD_WITH_PYTHON) set(_PY_DIGITS "") if(_PY_MAJ AND _PY_MIN) set(_PY_DIGITS "${_PY_MAJ}${_PY_MIN}") # e.g. "313" - else() - # As a last resort, try to detect digits from filename presence in the lib dir - # (See Approach B below for a fuller glob) - message(STATUS "[Python wiring] Could not determine Python version via interpreter; will try folder scan later.") endif() # Resolve actual files in PCbuild/amd64 @@ -520,7 +520,6 @@ if(BUILD_WITH_PYTHON) set(_PY_LIB_DBG "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") endif() - # If still missing, fall back to a glob (see Approach B) if(NOT _PY_LIB_REL OR NOT _PY_LIB_DBG) file(GLOB _py_rel_cand "${_PY_PCBUILD}/python3*.lib") file(GLOB _py_dbg_cand "${_PY_PCBUILD}/python3*_d.lib") @@ -542,7 +541,6 @@ if(BUILD_WITH_PYTHON) "First configure after a clean may hit this; they will exist after Python_external builds.") endif() - # Append cache args for SCIRun inner build: no version hard-coded list(APPEND SCIRUN_CACHE_ARGS "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" "-DPYTHON_INCLUDE_DIR:PATH=${_PY_INC}" @@ -554,28 +552,22 @@ if(BUILD_WITH_PYTHON) "-DPython_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}" "-DPython_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}" - # Optional hints for legacy find modules "-DPython_EXECUTABLE:FILEPATH=${_PY_EXE}" "-DPython_INCLUDE_DIRS:PATH=${_PY_INC};${_PY_PC_INC}" "-DPython3_EXECUTABLE:FILEPATH=${_PY_EXE}" "-DPython3_INCLUDE_DIRS:PATH=${_PY_INC};${_PY_PC_INC}" - # Boost.Python wiring remains as-is "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" - # === Strong hints for FindPython to stay inside the superbuild tree === "-DPython_ROOT_DIR:PATH=${_PY_SRC}" "-DPython3_ROOT_DIR:PATH=${_PY_SRC}" - - # === Explicit paths used by the module-level override (imported target) === + "-DPY_EXT_LIB_DIR:PATH=${_PY_PCBUILD}" "-DPY_INCLUDE_DIR:PATH=${_PY_INC}" - # Bias CMake's FindPython inside the inner build to honor our root and NOT the registry/system "-DPython_FIND_REGISTRY:STRING=NEVER" "-DPython_FIND_STRATEGY:STRING=LOCATION" - # Fence typical system install path(s) so they don't creep in via any other find logic "-DCMAKE_IGNORE_PREFIX_PATH:PATH=C:/Program Files/Python313;C:/Program Files (x86)/Python*" ) endif() @@ -584,42 +576,31 @@ if(WIN32) list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}") endif() -# FreeType essential hints (include & lib paths explicitly) +# FreeType essential hints if(TARGET Freetype_external) ExternalProject_Get_Property(Freetype_external INSTALL_DIR) set(FREETYPE_INSTALL_DIR "${INSTALL_DIR}") - # Primary include (contains ft2build.h) and the 'freetype2' sub-include set(Freetype_INCLUDE_DIR "${FREETYPE_INSTALL_DIR}/include") set(FREETYPE_INCLUDE_DIR2 "${FREETYPE_INSTALL_DIR}/include/freetype2") - - # Library directory (freetype.lib / libfreetype.{a,so,dylib}) - # If you set CMAKE_INSTALL_LIBDIR=lib in the external, this is stable: set(Freetype_LIB_DIR "${FREETYPE_INSTALL_DIR}/lib") - # Append cache args consumed by the inner SCIRun configure list(APPEND SCIRUN_CACHE_ARGS "-DFreetype_INCLUDE_DIR:PATH=${Freetype_INCLUDE_DIR}" "-DFREETYPE_INCLUDE_DIR2:PATH=${FREETYPE_INCLUDE_DIR2}" "-DFreetype_LIB_DIR:PATH=${Freetype_LIB_DIR}" ) - # If the external produced a *Config.cmake, pass its DIR like you do for Zlib. - # Prefer an explicit Freetype_DIR if the superbuild has one; else export the common location. if(DEFINED Freetype_DIR) list(APPEND SCIRUN_CACHE_ARGS "-DFreetype_DIR:PATH=${Freetype_DIR}") else() - # Helper you already use for Zlib to export a config dir that the inner find_package() can pick up. - # Adjust the suffix if your FreeType external installs config files elsewhere. _export_config_dir(Freetype Freetype_external "lib/cmake/freetype") endif() - # (Optional) If you also maintain legacy alias variables for consistency with older code: set(SCI_FREETYPE_INCLUDE "${Freetype_INCLUDE_DIR}" CACHE PATH "Legacy: FreeType include dir (ft2build.h)" FORCE) set(SCI_FREETYPE_INCLUDE2 "${FREETYPE_INCLUDE_DIR2}" CACHE PATH "Legacy: FreeType include dir (freetype2)" FORCE) set(SCI_FREETYPE_LIBRARY_DIR "${Freetype_LIB_DIR}" CACHE PATH "Legacy: FreeType library dir" FORCE) - # And push those legacy names too if you want them available in the inner cache: list(APPEND SCIRUN_CACHE_ARGS "-DSCI_FREETYPE_INCLUDE:PATH=${SCI_FREETYPE_INCLUDE}" "-DSCI_FREETYPE_INCLUDE2:PATH=${SCI_FREETYPE_INCLUDE2}" @@ -627,21 +608,18 @@ if(TARGET Freetype_external) ) endif() -# Zlib + Boost essential hints (include & lib paths explicitly) +# Zlib + Boost essential hints if(TARGET Zlib_external) ExternalProject_Get_Property(Zlib_external INSTALL_DIR) set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") - # Existing hints you already pass: list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" "-DZLIB_USE_STATIC_LIBS:BOOL=ON" ) - # New: pass the ACTUAL library file (full path). Adjust filename to your build. if(WIN32) - # If you built static zlib as zlibstatic.lib, set that; otherwise zlib.lib or zlib1.lib if(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib") set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib") elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlib.lib") @@ -655,7 +633,7 @@ if(TARGET Zlib_external) elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.dylib") set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.dylib") endif() - else() # Linux/Unix + else() if(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.a") set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.a") elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.so") @@ -694,33 +672,24 @@ endif() # ===== Eigen (special-case exporter to prefer include/eigen3) ===== if(TARGET Eigen_external) ExternalProject_Get_Property(Eigen_external INSTALL_DIR) - - # Prefer the CMake-installed Eigen layout set(_eigen_inc "${INSTALL_DIR}/include/eigen3") if(NOT EXISTS "${_eigen_inc}/Eigen/Dense") - # Legacy fallback when copy-only install was used. - # Strongly recommend switching your Eigen external to CMake install. set(_eigen_inc "${INSTALL_DIR}/include") endif() - # Pass normalized include to SCIRun (it will also verify 'unsupported' exists) list(APPEND SCIRUN_CACHE_ARGS "-DEigen_INCLUDE_DIR:PATH=${_eigen_inc}" "-DSCIRUN_EIGEN_INCLUDE:PATH=${_eigen_inc}" ) - - # Ensure SCIRun sees Eigen's prefix in CMAKE_PREFIX_PATH sb_prefix_append("${INSTALL_DIR}") endif() # Legacy alias variables (so existing SCIRun CMake picks them up) -# Normalize LodePng var name if needed if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) set(LODEPNG_INCLUDE_DIR "${LodePng_INCLUDE_DIR}") endif() if(DEFINED Eigen_INCLUDE_DIR) - # Stable alias that the inner SCIRun configure can use everywhere. set(SCIRUN_EIGEN_INCLUDE "${Eigen_INCLUDE_DIR}" CACHE PATH "Alias: Eigen include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_EIGEN_INCLUDE:PATH=${SCIRUN_EIGEN_INCLUDE}") endif() @@ -740,7 +709,7 @@ if(DEFINED SQLite_INCLUDE_DIR) set(SQLite3_INCLUDE_DIR "${SQLite_INCLUDE_DIR}" CACHE PATH "Alias: SQLite3 include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_INCLUDE_DIR:PATH=${SQLite3_INCLUDE_DIR}") endif() -# ---- Cleaver2 uppercase aliases for inner CMake (legacy/consistent names) ---- +# ---- Cleaver2 uppercase aliases if(DEFINED Cleaver2_INCLUDE_DIR) list(APPEND SCIRUN_CACHE_ARGS "-DCLEAVER2_INCLUDE:PATH=${Cleaver2_INCLUDE_DIR}" @@ -753,29 +722,23 @@ if(DEFINED Cleaver2_LIB_DIR) "-DCLEAVER2_LIB_DIR:PATH=${Cleaver2_LIB_DIR}" ) endif() -# Library logical name (import lib on Windows will be resolved by consumers) -list(APPEND SCIRUN_CACHE_ARGS - "-DCLEAVER2_LIBRARY:STRING=cleaver2" -) -# --- Ensure SQLite hints are present AFTER SCIRUN_CACHE_ARGS is created --- +list(APPEND SCIRUN_CACHE_ARGS "-DCLEAVER2_LIBRARY:STRING=cleaver2") + +# --- Ensure SQLite hints are present AFTER base args --- if(TARGET SQLite_external) ExternalProject_Get_Property(SQLite_external INSTALL_DIR) - # Compute lib dir (lib64 preferred when present) if(EXISTS "${INSTALL_DIR}/lib64") set(_sqlite_lib_dir "${INSTALL_DIR}/lib64") else() set(_sqlite_lib_dir "${INSTALL_DIR}/lib") endif() - # Always pass include + lib dir list(APPEND SCIRUN_CACHE_ARGS "-DSQLite_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" "-DSQLite_LIB_DIR:PATH=${_sqlite_lib_dir}" - # Alias the include to SQLite3_* for consumers that use that name "-DSQLite3_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" ) - # Optional: pass the exact library file if it exists (helps consumers) if(WIN32) set(_sqlite_lib "${_sqlite_lib_dir}/sqlite3.lib") if(NOT EXISTS "${_sqlite_lib}" AND EXISTS "${_sqlite_lib_dir}/libsqlite3.lib") @@ -798,24 +761,21 @@ if(TARGET SQLite_external) message(STATUS "[superbuild] SQLite lib dir: ${_sqlite_lib_dir}") endif() -# --- Ensure Teem hints are present AFTER SCIRUN_CACHE_ARGS is created --- +# --- Ensure Teem hints are present AFTER base args --- if(TARGET Teem_external) ExternalProject_Get_Property(Teem_external INSTALL_DIR) - # Compute Teem lib dir (prefer lib64 when present) if(EXISTS "${INSTALL_DIR}/lib64") set(_teem_lib_dir "${INSTALL_DIR}/lib64") else() set(_teem_lib_dir "${INSTALL_DIR}/lib") endif() - # Always pass include + lib dir list(APPEND SCIRUN_CACHE_ARGS "-DTeem_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" "-DTeem_LIB_DIR:PATH=${_teem_lib_dir}" ) - # Optional: pass full library path if present (helps consumers) if(WIN32) set(_teem_lib "${_teem_lib_dir}/teem.lib") if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.lib") @@ -844,40 +804,82 @@ if(TARGET Teem_external) message(STATUS "[superbuild] Teem lib dir: ${_teem_lib_dir}") endif() -# --- Provide TetGen include/lib hints even if headers aren't 'installed' --- +# --- Provide Tetgen include/lib hints + actual library file --- +# Use the actual external target name: Tetgen_external (lowercase g) if(WITH_TETGEN AND TARGET Tetgen_external) ExternalProject_Get_Property(Tetgen_external INSTALL_DIR) ExternalProject_Get_Property(Tetgen_external SOURCE_DIR) - # Prefer install/include; otherwise fall back to SOURCE_DIR where tetgen.h usually lives + # Include dir: prefer install/include, else SOURCE_DIR/src, else SOURCE_DIR set(_tet_inc "${INSTALL_DIR}/include") if(NOT EXISTS "${_tet_inc}/tetgen.h") - set(_tet_inc "${SOURCE_DIR}") + if(EXISTS "${SOURCE_DIR}/src/tetgen.h") + set(_tet_inc "${SOURCE_DIR}/src") + elseif(EXISTS "${SOURCE_DIR}/tetgen.h") + set(_tet_inc "${SOURCE_DIR}") + endif() endif() + # Library dir candidates + set(_tet_lib_dir "") if(EXISTS "${INSTALL_DIR}/lib64") set(_tet_lib_dir "${INSTALL_DIR}/lib64") - else() + elseif(EXISTS "${INSTALL_DIR}/lib") set(_tet_lib_dir "${INSTALL_DIR}/lib") endif() - # Pick the actual library file name (tet.lib vs tetgen.lib) + # Try to locate the actual library file set(_tet_lib "") - if(EXISTS "${_tet_lib_dir}/tet.lib") - set(_tet_lib "${_tet_lib_dir}/tet.lib") - elseif(EXISTS "${_tet_lib_dir}/tetgen.lib") - set(_tet_lib "${_tet_lib_dir}/tetgen.lib") + if(_tet_lib_dir AND EXISTS "${_tet_lib_dir}") + set(_tet_names tetgen libtetgen tet tetgen_static tetgen1.6 tet1.6) + foreach(_nm IN LISTS _tet_names) + if(EXISTS "${_tet_lib_dir}/${_nm}.lib") + set(_tet_lib "${_tet_lib_dir}/${_nm}.lib") + break() + endif() + endforeach() + if(NOT _tet_lib) + file(GLOB _cands + "${_tet_lib_dir}/*.lib" + "${_tet_lib_dir}/**/tet*.lib" + "${_tet_lib_dir}/**/libtet*.lib" + ) + list(SORT _cands) + list(LENGTH _cands _n) + if(_n GREATER 0) + list(GET _cands 0 _tet_lib) + endif() + endif() endif() + # Normalize for cache args + if(_tet_inc) + file(TO_CMAKE_PATH "${_tet_inc}" _tet_inc_norm) + else() + set(_tet_inc_norm "") + endif() + if(_tet_lib_dir) + file(TO_CMAKE_PATH "${_tet_lib_dir}" _tet_lib_dir_norm) + else() + set(_tet_lib_dir_norm "") + endif() + if(_tet_lib) + file(TO_CMAKE_PATH "${_tet_lib}" _tet_lib_norm) + else() + set(_tet_lib_norm "") + endif() + + # Always pass include/lib dir; pass TETGEN_LIBRARY only if file was found list(APPEND SCIRUN_CACHE_ARGS - "-DTETGEN_INCLUDE_DIR:PATH=${_tet_inc}" - "-DTETGEN_LIB_DIR:PATH=${_tet_lib_dir}" + "-DWITH_TETGEN:BOOL=ON" + "-DTETGEN_INCLUDE_DIR:PATH=${_tet_inc_norm}" + "-DTETGEN_LIB_DIR:PATH=${_tet_lib_dir_norm}" ) - if(_tet_lib) - list(APPEND SCIRUN_CACHE_ARGS "-DTETGEN_LIBRARY:FILEPATH=${_tet_lib}") + if(_tet_lib_norm) + list(APPEND SCIRUN_CACHE_ARGS "-DTETGEN_LIBRARY:FILEPATH=${_tet_lib_norm}") endif() - message(STATUS "[superbuild] TetGen include=${_tet_inc} libdir=${_tet_lib_dir} lib=${_tet_lib}") + message(STATUS "[superbuild] Tetgen: include=${_tet_inc_norm} libdir=${_tet_lib_dir_norm} lib=${_tet_lib_norm}") endif() # Compose a single CMAKE_PREFIX_PATH for SCIRun @@ -949,7 +951,6 @@ ExternalProject_Add(SCIRun_external # ========================= # BOOST: header staging (no delete; copy only) + waits # ========================= -# Prepare cross-platform commands for b2 bootstrapping and header generation if(WIN32) set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) set(_B2_HEADERS_CMD cmd /c .\\b2 headers) @@ -959,7 +960,6 @@ else() endif() if(TARGET Boost_external) - # 1) Bootstrap b2 ExternalProject_Add_Step(Boost_external bootstrap_b2 COMMAND ${_B2_BOOTSTRAP_CMD} WORKING_DIRECTORY @@ -968,7 +968,6 @@ if(TARGET Boost_external) COMMENT "Bootstrapping Boost.Build (b2)" ) - # 2) Generate the 'boost/' header tree ExternalProject_Add_Step(Boost_external stage_headers COMMAND ${_B2_HEADERS_CMD} WORKING_DIRECTORY @@ -976,7 +975,6 @@ if(TARGET Boost_external) COMMENT "Running 'b2 headers' to generate the boost/ header tree" ) - # 3) Copy full headers into install/include WITHOUT deleting first if(NOT DEFINED _SB_BOOST_HEADERS_COPY_STEP_DEFINED) ExternalProject_Add_Step(Boost_external stage_boost_headers_copy COMMAND ${CMAKE_COMMAND} -E make_directory /include/boost @@ -989,10 +987,8 @@ if(TARGET Boost_external) set(_SB_BOOST_HEADERS_COPY_STEP_DEFINED TRUE) endif() - # Expose step targets for ordering elsewhere ExternalProject_Add_StepTargets(Boost_external stage_headers stage_boost_headers_copy) - # Gate SCIRun configure on staged headers ExternalProject_Get_Property(Boost_external INSTALL_DIR) _sb_scirun_wait_for(NAME boost FILES @@ -1070,9 +1066,7 @@ endif() # --- Wait for Eigen headers (including unsupported/Tensor) before SCIRun configure --- if(TARGET Eigen_external) ExternalProject_Get_Property(Eigen_external INSTALL_DIR) - set(_eigen_inc "${INSTALL_DIR}/include/eigen3") # assume modern layout produced by CMake install - - # Do not check EXISTS here—let ExternalProject step handle availability at build time. + set(_eigen_inc "${INSTALL_DIR}/include/eigen3") _sb_scirun_wait_for(NAME eigen FILES "${_eigen_inc}/Eigen/Dense" @@ -1083,15 +1077,11 @@ endif() # --- Gate SCIRun configure on Cleaver2 headers (vec3.h) --- if(TARGET Cleaver2_external) - # Expose a phony target for the copy step so we can depend on it ExternalProject_Add_StepTargets(Cleaver2_external copy_headers) - ExternalProject_Get_Property(Cleaver2_external INSTALL_DIR) _sb_scirun_wait_for(NAME cleaver2 FILES "${INSTALL_DIR}/include/cleaver2/vec3.h" DIRS "${INSTALL_DIR}/include/cleaver2" ) - - # Ensure SCIRun waits specifically for the header copy step to complete add_dependencies(SCIRun_external Cleaver2_external-copy_headers) -endif() +endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 458f3d31eb..b40822c9bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -768,10 +768,36 @@ CONFIG_STANDARD_EXTERNAL(LodePng # Tetgen (optional) if(WITH_TETGEN) - CONFIG_STANDARD_EXTERNAL(Tetgen - DIR "${Tetgen_DIR}" - CFG "TetgenConfig.cmake" - ) + # Try package config first (does nothing if no TetgenConfig.cmake in CMAKE_PREFIX_PATH) + #CONFIG_STANDARD_EXTERNAL(Tetgen + # DIR "${Tetgen_DIR}" + # CFG "TetgenConfig.cmake" + #) + + # --- Fallback when Tetgen doesn't export a CMake package --- + # Create an imported target from superbuild-provided cache hints. + if(NOT TARGET Tetgen::Tetgen) + # Heal include dir: if it doesn't contain tetgen.h, try '/src' + set(_TETGEN_INC "${TETGEN_INCLUDE_DIR}") + if(_TETGEN_INC AND NOT EXISTS "${_TETGEN_INC}/tetgen.h" AND EXISTS "${_TETGEN_INC}/src/tetgen.h") + set(_TETGEN_INC "${_TETGEN_INC}/src") + endif() + + # Create imported target if we have a real library file and a valid include dir + if(TETGEN_LIBRARY AND EXISTS "${TETGEN_LIBRARY}" AND _TETGEN_INC AND EXISTS "${_TETGEN_INC}/tetgen.h") + add_library(Tetgen::Tetgen UNKNOWN IMPORTED) + set_target_properties(Tetgen::Tetgen PROPERTIES + IMPORTED_LOCATION "${TETGEN_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${_TETGEN_INC}" + # Define TETLIBRARY for all consumers (TetGen's header expects this when used as a lib) + INTERFACE_COMPILE_DEFINITIONS "TETLIBRARY" + ) + message(STATUS "[SCIRun] Created imported target Tetgen::Tetgen (LIB='${TETGEN_LIBRARY}', INC='${_TETGEN_INC}')") + else() + message(STATUS "[SCIRun] Tetgen package not found and cache hints insufficient yet. " + "TETGEN_LIBRARY='${TETGEN_LIBRARY}', TETGEN_INCLUDE_DIR='${TETGEN_INCLUDE_DIR}'") + endif() + endif() endif() # GLEW (Windows) diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index 0aa4239bc3..a6ce3051f4 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -103,18 +103,30 @@ set(_PY_LIB_DBG "") set(_PY_LIB_REL "") # ---- Path-first: use explicit superbuild variables if provided ---- -if(PYTHON_LIBRARY_DEBUG AND PYTHON_LIBRARY_RELEASE AND PYTHON_INCLUDE_DIR) - foreach(_check "${PYTHON_LIBRARY_DEBUG};${PYTHON_LIBRARY_RELEASE};${PYTHON_INCLUDE_DIR}") - if(NOT EXISTS "${_check}") +# Accept include dir + at least one of debug/release libs. +if(PYTHON_INCLUDE_DIR AND (PYTHON_LIBRARY_DEBUG OR PYTHON_LIBRARY_RELEASE)) + # Build a proper list of checks; skip empties so foreach doesn't see blank items. + set(_py_checks) + if(PYTHON_LIBRARY_DEBUG) + list(APPEND _py_checks "${PYTHON_LIBRARY_DEBUG}") + endif() + if(PYTHON_LIBRARY_RELEASE) + list(APPEND _py_checks "${PYTHON_LIBRARY_RELEASE}") + endif() + list(APPEND _py_checks "${PYTHON_INCLUDE_DIR}") + + foreach(_check IN LISTS _py_checks) + if(_check AND NOT EXISTS "${_check}") message(FATAL_ERROR "Python superbuild hint does not exist: ${_check}") endif() endforeach() + # Remember which ones we actually have set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") # Includes: Include (always), PC (optional on Windows for pyconfig.h) - list(APPEND _PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") + set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") endif() @@ -161,57 +173,15 @@ if(NOT _SCIRUN_PY_OK) endif() # ==================================================================================== -# Ensure Python::Python imported target exists and points to superbuild import libs -# Accept both new (PY_EXT_LIB_DIR/PY_INCLUDE_DIR) and legacy vars. +# Ensure Python::Python imported target exists and is wired for all MSVC configs # ==================================================================================== -set(_PY_IMPORTED_OK FALSE) - -# Prefer explicit include dir hints from superbuild for MSVC usage requirements -set(_SB_INC_DIR "") -if(PYTHON_INCLUDE_DIR) - set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") -elseif(Python_INCLUDE_DIRS) - list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) -endif() -if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") -endif() - -# Derive a lib dir if only file paths were given -set(_SB_LIB_DIR "") -if(PYTHON_LIBRARY_DEBUG) - get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) -elseif(PYTHON_LIBRARY_RELEASE) - get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) -elseif(PY_EXT_LIB_DIR) - set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") -endif() - -# Fill missing per-config lib paths if needed -if(NOT _PY_LIB_DBG AND _SB_LIB_DIR) - foreach(_name "python313_d.lib" "python312_d.lib" "python311_d.lib" "python310_d.lib") - if(EXISTS "${_SB_LIB_DIR}/${_name}") - set(_PY_LIB_DBG "${_SB_LIB_DIR}/${_name}") - break() - endif() - endforeach() -endif() -if(NOT _PY_LIB_REL AND _SB_LIB_DIR) - foreach(_name "python313.lib" "python312.lib" "python311.lib" "python310.lib") - if(EXISTS "${_SB_LIB_DIR}/${_name}") - set(_PY_LIB_REL "${_SB_LIB_DIR}/${_name}") - break() - endif() - endforeach() -endif() - # Create/override the imported target if(NOT TARGET Python::Python) add_library(Python::Python UNKNOWN IMPORTED) endif() -# Always propagate includes via the imported target +# Prefer explicit include dir hints from superbuild for MSVC usage requirements if(_SB_INC_DIR) set_target_properties(Python::Python PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" @@ -223,49 +193,67 @@ elseif(_PY_INCLUDE_DIRS) ) endif() +# ---- MSVC: set config-specific IMPORTED_IMPLIB_* (do NOT guard with EXISTS) ---- if(MSVC) - # --- MSVC: set ONLY IMPORTED_IMPLIB_* (never IMPORTED_LOCATION_*) so link.exe uses .lib, NOT .dll --- - if(EXISTS "${_PY_LIB_REL}") + # Make sure all common configs are recognized + set_target_properties(Python::Python PROPERTIES + IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" + ) + + # Primary assignment (no EXISTS guards; allow the files to appear by build time) + if(_PY_LIB_REL) set_target_properties(Python::Python PROPERTIES IMPORTED_IMPLIB_RELEASE "${_PY_LIB_REL}" IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_REL}" IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_REL}" ) endif() - if(EXISTS "${_PY_LIB_DBG}") + if(_PY_LIB_DBG) set_target_properties(Python::Python PROPERTIES IMPORTED_IMPLIB_DEBUG "${_PY_LIB_DBG}" ) endif() + + # Fallbacks: if one variant is missing, map it to the other so VS never sees NOTFOUND + if(NOT _PY_LIB_DBG AND _PY_LIB_REL) + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB_DEBUG "${_PY_LIB_REL}" + MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" + ) + endif() + if(NOT _PY_LIB_REL AND _PY_LIB_DBG) + set_target_properties(Python::Python PROPERTIES + IMPORTED_IMPLIB_RELEASE "${_PY_LIB_DBG}" + IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_DBG}" + IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_DBG}" + MAP_IMPORTED_CONFIG_RELEASE "Debug" + MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" + MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" + ) + endif() + else() - # Non-Windows: point to the real binary (shared/static) - if(EXISTS "${_PY_LIB_REL}") + # Non-Windows: point to the real binary (shared/static); skip EXISTS guards + if(_PY_LIB_REL) set_target_properties(Python::Python PROPERTIES IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" ) endif() - if(EXISTS "${_PY_LIB_DBG}") + if(_PY_LIB_DBG) set_target_properties(Python::Python PROPERTIES IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" ) endif() endif() -# Consider imported OK if target exists now -if(TARGET Python::Python) - set(_PY_IMPORTED_OK TRUE) -endif() - -if(NOT _PY_IMPORTED_OK) - message(FATAL_ERROR - "Python::Python imported target could not be created for Core_Python.\n" - "Checked:\n PY_EXT_LIB_DIR='${PY_EXT_LIB_DIR}'\n PYTHON_INCLUDE_DIR='${PYTHON_INCLUDE_DIR}'\n" - " PYTHON_LIBRARY_DEBUG='${PYTHON_LIBRARY_DEBUG}'\n PYTHON_LIBRARY_RELEASE='${PYTHON_LIBRARY_RELEASE}'\n" - "Hint: ensure the superbuild passes these cache args and that Python_external has built import libs." - ) -endif() +# Helpful diagnostics (ensure we actually set something) +message(STATUS "[Diag/Core_Python] _PY_LIB_DBG='${_PY_LIB_DBG}' _PY_LIB_REL='${_PY_LIB_REL}'") +get_target_property(_py_implib_dbg Python::Python IMPORTED_IMPLIB_DEBUG) +get_target_property(_py_implib_rel Python::Python IMPORTED_IMPLIB_RELEASE) +message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_DEBUG='${_py_implib_dbg}'") +message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_RELEASE='${_py_implib_rel}'") # ==================================================================================== # Platform-specific compile definitions (PYTHONPATH, etc.) @@ -384,11 +372,13 @@ if(MSVC) endif() endforeach() if(_bp_dbg_candidates) - list(SORT _bp_dbg_candidates) list(REVERSE _bp_dbg_candidates) + list(SORT _bp_dbg_candidates) + list(REVERSE _bp_dbg_candidates) list(GET _bp_dbg_candidates 0 SCI_BOOST_PYTHON_LIB_DEBUG) endif() if(_bp_rel_candidates) - list(SORT _bp_rel_candidates) list(REVERSE _bp_rel_candidates) + list(SORT _bp_rel_candidates) + list(REVERSE _bp_rel_candidates) list(GET _bp_rel_candidates 0 SCI_BOOST_PYTHON_LIB_RELEASE) endif() if(NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}" OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_RELEASE}") diff --git a/src/Modules/Legacy/Fields/CMakeLists.txt b/src/Modules/Legacy/Fields/CMakeLists.txt index 2793977fa1..a402943178 100644 --- a/src/Modules/Legacy/Fields/CMakeLists.txt +++ b/src/Modules/Legacy/Fields/CMakeLists.txt @@ -260,6 +260,13 @@ target_link_libraries(Modules_Legacy_Fields # ---- TetGen wiring (include + link + define) ---- if(WITH_TETGEN) + message(STATUS "[Diag/Tetgen/Fields] WITH_TETGEN='${WITH_TETGEN}'") + message(STATUS "[Diag/Tetgen/Fields] TETGEN_INCLUDE_DIR='${TETGEN_INCLUDE_DIR}'") + message(STATUS "[Diag/Tetgen/Fields] TETGEN_LIB_DIR='${TETGEN_LIB_DIR}'") + message(STATUS "[Diag/Tetgen/Fields] TETGEN_LIBRARY='${TETGEN_LIBRARY}'") + if(TARGET Tetgen::Tetgen) + message(STATUS "[Diag/Tetgen/Fields] TARGET Tetgen::Tetgen is visible here") + endif() # Add the include directory so 'tetgen.h' is found if(DEFINED TETGEN_INCLUDE_DIR AND EXISTS "${TETGEN_INCLUDE_DIR}") target_include_directories(Modules_Legacy_Fields PRIVATE "${TETGEN_INCLUDE_DIR}") From 2b2312ae7304592a312eab2ce86063ca144f80f7 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 2 Mar 2026 16:49:15 -0700 Subject: [PATCH 054/140] python and qwt deprecated qt functions --- Superbuild/Superbuild.cmake | 176 ++++++---- src/Core/Application/CMakeLists.txt | 27 ++ src/Core/ConsoleApplication/CMakeLists.txt | 27 ++ src/Core/Python/CMakeLists.txt | 113 +++--- src/Dataflow/Engine/Controller/CMakeLists.txt | 90 +++-- src/Dataflow/Engine/Python/CMakeLists.txt | 279 ++++++++------- src/Interface/Application/CMakeLists.txt | 27 ++ .../Base/CustomWidgets/CodeEditorWidgets.cc | 80 +++-- .../Base/CustomWidgets/CodeEditorWidgets.h | 7 +- src/Modules/Factory/CMakeLists.txt | 27 ++ src/Modules/Math/CMakeLists.txt | 48 ++- src/Modules/Python/CMakeLists.txt | 324 ++++++++++-------- 12 files changed, 764 insertions(+), 461 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index bba28e319b..d8a3109a48 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -254,6 +254,13 @@ endif() # Keep Boost last so we can compute Boost_DIR & legacy hints afterward ADD_EXTERNAL(${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external) +# Qwt (Qt plotting) — build only when GUI is enabled +option(WITH_QWT "Build Qwt external (Qt plotting widgets)" ON) +if(NOT BUILD_HEADLESS AND WITH_QWT) + # Adjust the path if your QwtExternal.cmake lives elsewhere + ADD_EXTERNAL(${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external) +endif() + # Ensure header copy steps run before SCIRun config/build if(TARGET Glew_external-copy_headers) add_dependencies(SCIRun_external Glew_external-copy_headers) @@ -398,14 +405,22 @@ if(NOT BUILD_HEADLESS AND TARGET Qwt_external) set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") endif() + # (New) Pass fallback include/lib dirs to the inner SCIRun build as cache args, + # in case QwtConfig.cmake is not present. + list(APPEND SCIRUN_CACHE_ARGS + "-DQWT_INCLUDE_DIR:PATH=${QWT_INCLUDE_DIR}" + "-DQWT_LIBRARY_DIR:PATH=${QWT_LIBRARY_DIR}" + ) + + # Imported target here is only visible in superbuild scope; + # the inner project will use Qwt_DIR or QWT_* vars above. add_library(Qwt::Qwt UNKNOWN IMPORTED GLOBAL) add_dependencies(Qwt::Qwt Qwt_external) set_property(TARGET Qwt::Qwt PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${QWT_INCLUDE_DIR}") - if(WIN32) set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_CONFIGURATIONS "Debug;Release") set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") # adjust if your build uses qwt_d.lib elseif(APPLE) set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") else() @@ -471,105 +486,94 @@ list(APPEND SCIRUN_CACHE_ARGS ) # ========================= -# Forward Python values to SCIRun (inner CMake), version-agnostic +# Forward Python values to SCIRun (inner CMake), version-agnostic & robust # ========================= if(BUILD_WITH_PYTHON) - # Base paths from your external layout - set(_PY_SRC "${ep_base}/Source/Python_external") - set(_PY_PCBUILD "${_PY_SRC}/PCbuild/amd64") + # Normalize paths to forward-slash form for CMake cache correctness + file(TO_CMAKE_PATH "${ep_base}/Source/Python_external" _PY_SRC) set(_PY_INC "${_PY_SRC}/Include") set(_PY_PC_INC "${_PY_SRC}/PC") + set(_PY_PCBUILD "${_PY_SRC}/PCbuild/amd64") set(_PY_EXE "${_PY_PCBUILD}/python.exe") - # Derive MAJOR.MINOR from the built interpreter - set(_PY_MAJ "") - set(_PY_MIN "") + # --- Discover import libraries in PCbuild/amd64 --- + set(_PY_LIB_REL "") + set(_PY_LIB_DBG "") + + # Strategy A: use python.exe to get MAJOR.MINOR -> digits + set(_PY_DIGITS "") if(EXISTS "${_PY_EXE}") execute_process( - COMMAND "${_PY_EXE}" -c "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}')" - OUTPUT_VARIABLE _PY_VER_SHORT + COMMAND "${_PY_EXE}" -c "import sys; print(f'{sys.version_info[0]}{sys.version_info[1]}')" + OUTPUT_VARIABLE _PY_DIGITS OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) - if(_PY_VER_SHORT MATCHES "^([0-9]+)\\.([0-9]+)$") - set(_PY_MAJ "${CMAKE_MATCH_1}") - set(_PY_MIN "${CMAKE_MATCH_2}") - endif() - endif() - - if(NOT _PY_MAJ OR NOT _PY_MIN) - if(DEFINED PY_MAJOR AND DEFINED PY_MINOR) - set(_PY_MAJ "${PY_MAJOR}") - set(_PY_MIN "${PY_MINOR}") + if(_PY_DIGITS MATCHES "^[0-9][0-9]+$") + if(EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") + set(_PY_LIB_REL "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") + endif() + if(EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") + set(_PY_LIB_DBG "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") + endif() endif() endif() - # Construct the Windows import library names: pythonXY(.lib) and pythonXY_d.lib - set(_PY_DIGITS "") - if(_PY_MAJ AND _PY_MIN) - set(_PY_DIGITS "${_PY_MAJ}${_PY_MIN}") # e.g. "313" - endif() - - # Resolve actual files in PCbuild/amd64 - set(_PY_LIB_REL "") - set(_PY_LIB_DBG "") - if(_PY_DIGITS AND EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") - set(_PY_LIB_REL "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") - endif() - if(_PY_DIGITS AND EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") - set(_PY_LIB_DBG "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") - endif() - + # Strategy B: scan for the newest python3*.lib if digits not derived or files not found if(NOT _PY_LIB_REL OR NOT _PY_LIB_DBG) - file(GLOB _py_rel_cand "${_PY_PCBUILD}/python3*.lib") - file(GLOB _py_dbg_cand "${_PY_PCBUILD}/python3*_d.lib") - list(SORT _py_rel_cand) - list(SORT _py_dbg_cand) - list(REVERSE _py_rel_cand) - list(REVERSE _py_dbg_cand) - if(NOT _PY_LIB_REL AND _py_rel_cand) - list(GET _py_rel_cand 0 _PY_LIB_REL) - endif() - if(NOT _PY_LIB_DBG AND _py_dbg_cand) - list(GET _py_dbg_cand 0 _PY_LIB_DBG) + file(GLOB _py_libs_all "${_PY_PCBUILD}/python3*.lib") + if(_py_libs_all) + list(SORT _py_libs_all) + list(REVERSE _py_libs_all) + # Pick best candidates by suffix + foreach(_L IN LISTS _py_libs_all) + get_filename_component(_bn "${_L}" NAME) + if(_bn MATCHES "^python([0-9][0-9][0-9])_d\\.lib$" AND NOT _PY_LIB_DBG) + set(_PY_LIB_DBG "${_L}") + elseif(_bn MATCHES "^python([0-9][0-9][0-9])\\.lib$" AND NOT _PY_LIB_REL) + set(_PY_LIB_REL "${_L}") + endif() + endforeach() endif() endif() - if(NOT (EXISTS "${_PY_LIB_REL}" AND EXISTS "${_PY_LIB_DBG}")) - message(WARNING "[Python wiring] Could not resolve both Python import libs under ${_PY_PCBUILD}. " - "REL='${_PY_LIB_REL}' DBG='${_PY_LIB_DBG}'. " - "First configure after a clean may hit this; they will exist after Python_external builds.") + # Helpful warning (first configure after clean may run before Python builds) + if(NOT (EXISTS "${_PY_LIB_REL}" OR EXISTS "${_PY_LIB_DBG}")) + message(WARNING + "[Python wiring] No python import libs found yet under ${_PY_PCBUILD}. " + "SCIRun configure is set to wait for Python_external build, but if you " + "manually run only configure, the files may not exist until Python builds." + ) endif() - list(APPEND SCIRUN_CACHE_ARGS + # --- Build the cache args only with non-empty values --- + set(_SC_PY_ARGS "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" "-DPYTHON_INCLUDE_DIR:PATH=${_PY_INC}" - "-DPYTHON_PC_INCLUDE_DIR:PATH=${_PY_PC_INC}" - "-DPYTHON_EXECUTABLE:FILEPATH=${_PY_EXE}" "-DPYTHON_RUNTIME_DIR:PATH=${_PY_PCBUILD}" - "-DPYTHON_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}" - "-DPYTHON_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}" - "-DPython_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}" - "-DPython_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}" - - "-DPython_EXECUTABLE:FILEPATH=${_PY_EXE}" - "-DPython_INCLUDE_DIRS:PATH=${_PY_INC};${_PY_PC_INC}" - "-DPython3_EXECUTABLE:FILEPATH=${_PY_EXE}" - "-DPython3_INCLUDE_DIRS:PATH=${_PY_INC};${_PY_PC_INC}" - + "-DPython_FIND_REGISTRY:STRING=NEVER" + "-DPython_FIND_STRATEGY:STRING=LOCATION" + "-DPython_ROOT_DIR:PATH=${_PY_SRC}" + "-DCMAKE_IGNORE_PREFIX_PATH:PATH=C:/Program Files/Python*;C:/Program Files (x86)/Python*" "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" + ) - "-DPython_ROOT_DIR:PATH=${_PY_SRC}" - "-DPython3_ROOT_DIR:PATH=${_PY_SRC}" - - "-DPY_EXT_LIB_DIR:PATH=${_PY_PCBUILD}" - "-DPY_INCLUDE_DIR:PATH=${_PY_INC}" + if(EXISTS "${_PY_PC_INC}") + list(APPEND _SC_PY_ARGS "-DPYTHON_PC_INCLUDE_DIR:PATH=${_PY_PC_INC}") + endif() + if(EXISTS "${_PY_EXE}") + list(APPEND _SC_PY_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${_PY_EXE}") + endif() + if(_PY_LIB_REL) + list(APPEND _SC_PY_ARGS "-DPYTHON_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}") + endif() + if(_PY_LIB_DBG) + list(APPEND _SC_PY_ARGS "-DPYTHON_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}") + endif() - "-DPython_FIND_REGISTRY:STRING=NEVER" - "-DPython_FIND_STRATEGY:STRING=LOCATION" - "-DCMAKE_IGNORE_PREFIX_PATH:PATH=C:/Program Files/Python313;C:/Program Files (x86)/Python*" - ) + # Append to the inner project cache + list(APPEND SCIRUN_CACHE_ARGS ${_SC_PY_ARGS}) endif() if(WIN32) @@ -1000,6 +1004,7 @@ if(TARGET Boost_external) endif() if(TARGET Boost_external AND TARGET Python_external) + add_dependencies(SCIRun_external Python_external) add_dependencies(Boost_external Python_external) endif() @@ -1084,4 +1089,27 @@ if(TARGET Cleaver2_external) DIRS "${INSTALL_DIR}/include/cleaver2" ) add_dependencies(SCIRun_external Cleaver2_external-copy_headers) +endif() + +# --- (NEW) Ensure SCIRun configure waits for Python_external build --- +if(BUILD_WITH_PYTHON AND TARGET Python_external) + if(COMMAND ExternalProject_Add_StepDependencies) + ExternalProject_Add_StepDependencies(SCIRun_external configure Python_external) + message(STATUS "[superbuild] SCIRun_external: 'configure' will wait on Python_external.") + endif() + + # (Optional best-effort) Also wait for presence of python import libs/exe + # This makes the configure step defer until the files exist on disk. + set(_py_src_dir "${ep_base}/Source/Python_external") + set(_py_pcbuild "${_py_src_dir}/PCbuild/amd64") + # Gather possible byproducts + file(GLOB _py_wait_libs "${_py_pcbuild}/python3*.lib") + set(_py_wait_files "${_py_pcbuild}/python.exe") + list(APPEND _py_wait_files ${_py_wait_libs}) + if(_py_wait_files) + _sb_scirun_wait_for(NAME python + FILES ${_py_wait_files} + DIRS "${_py_pcbuild}" + ) + endif() endif() \ No newline at end of file diff --git a/src/Core/Application/CMakeLists.txt b/src/Core/Application/CMakeLists.txt index 00141431fa..fece04492e 100644 --- a/src/Core/Application/CMakeLists.txt +++ b/src/Core/Application/CMakeLists.txt @@ -42,6 +42,33 @@ SCIRUN_ADD_LIBRARY(Core_Application ${Core_Application_SRCS} ) +# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h +if (BUILD_WITH_PYTHON) + set(_PY_INCLUDES "") + if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") + endif() + if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") + endif() + if (MSVC AND NOT _PY_INCLUDES) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if (EXISTS "${_py_src}/Include") + list(APPEND _PY_INCLUDES "${_py_src}/Include") + endif() + if (EXISTS "${_py_src}/PC") + list(APPEND _PY_INCLUDES "${_py_src}/PC") + endif() + endif() + if (_PY_INCLUDES) + list(REMOVE_DUPLICATES _PY_INCLUDES) + target_include_directories(Core_Application PRIVATE ${_PY_INCLUDES}) + message(STATUS "[Core/Application] Added Python includes: ${_PY_INCLUDES}") + else() + message(WARNING "[Core/Application] Python includes not found at configure time; Boost.Python compilation may fail.") + endif() +endif() + TARGET_LINK_LIBRARIES(Core_Application Core_CommandLine Engine_Network diff --git a/src/Core/ConsoleApplication/CMakeLists.txt b/src/Core/ConsoleApplication/CMakeLists.txt index ecc78e9dba..6590f10163 100644 --- a/src/Core/ConsoleApplication/CMakeLists.txt +++ b/src/Core/ConsoleApplication/CMakeLists.txt @@ -44,6 +44,33 @@ SCIRUN_ADD_LIBRARY(Core_ConsoleApplication ${Core_ConsoleApplication_SRCS} ) +# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h +if (BUILD_WITH_PYTHON) + set(_PY_INCLUDES "") + if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") + endif() + if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") + endif() + if (MSVC AND NOT _PY_INCLUDES) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if (EXISTS "${_py_src}/Include") + list(APPEND _PY_INCLUDES "${_py_src}/Include") + endif() + if (EXISTS "${_py_src}/PC") + list(APPEND _PY_INCLUDES "${_py_src}/PC") + endif() + endif() + if (_PY_INCLUDES) + list(REMOVE_DUPLICATES _PY_INCLUDES) + target_include_directories(Core_ConsoleApplication PRIVATE ${_PY_INCLUDES}) + message(STATUS "[Core/ConsoleApplication] Added Python includes: ${_PY_INCLUDES}") + else() + message(WARNING "[Core/ConsoleApplication] Python includes not found at configure time; Boost.Python compilation may fail.") + endif() +endif() + TARGET_LINK_LIBRARIES(Core_ConsoleApplication Core_Application Core_Command diff --git a/src/Core/Python/CMakeLists.txt b/src/Core/Python/CMakeLists.txt index a6ce3051f4..22a1442ad0 100644 --- a/src/Core/Python/CMakeLists.txt +++ b/src/Core/Python/CMakeLists.txt @@ -67,9 +67,6 @@ SCIRUN_ADD_LIBRARY(Core_Python ${Core_Python_SRCS} ) -# (Optional) Belt-and-suspenders wipe in case macro captured anything already -set_target_properties(Core_Python PROPERTIES LINK_LIBRARIES "") - # Preserve original shared define behavior if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_Core_Python) @@ -173,87 +170,72 @@ if(NOT _SCIRUN_PY_OK) endif() # ==================================================================================== -# Ensure Python::Python imported target exists and is wired for all MSVC configs +# Imported alias target that points directly to the Python import libs on MSVC +# (Avoids any ambiguity with Python::Python in VS generators) # ==================================================================================== -# Create/override the imported target -if(NOT TARGET Python::Python) - add_library(Python::Python UNKNOWN IMPORTED) +# Create or reuse a global imported target for our Python import library +if(NOT TARGET SCIRunPython) + add_library(SCIRunPython STATIC IMPORTED GLOBAL) endif() -# Prefer explicit include dir hints from superbuild for MSVC usage requirements -if(_SB_INC_DIR) - set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" - ) -elseif(_PY_INCLUDE_DIRS) +# Provide include dirs for consumers (Core_Python and friends) +if(_PY_INCLUDE_DIRS) list(REMOVE_DUPLICATES _PY_INCLUDE_DIRS) - set_target_properties(Python::Python PROPERTIES + set_target_properties(SCIRunPython PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" ) endif() -# ---- MSVC: set config-specific IMPORTED_IMPLIB_* (do NOT guard with EXISTS) ---- +# Configure config-specific locations to the *import libraries* (.lib) on Windows +# For non-MSVC platforms, your existing logic will take over (link to the real .so/.dylib) if(MSVC) - # Make sure all common configs are recognized - set_target_properties(Python::Python PROPERTIES + # Recognize all common configs + set_target_properties(SCIRunPython PROPERTIES IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" ) - # Primary assignment (no EXISTS guards; allow the files to appear by build time) + # Assign debug/release import libs if they were found if(_PY_LIB_REL) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_PY_LIB_REL}" - IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_REL}" + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" ) endif() if(_PY_LIB_DBG) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_PY_LIB_DBG}" + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" ) endif() - # Fallbacks: if one variant is missing, map it to the other so VS never sees NOTFOUND + # Map missing variants so the generator never sees NOTFOUND if(NOT _PY_LIB_DBG AND _PY_LIB_REL) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_PY_LIB_REL}" - MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_REL}" + MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" ) endif() if(NOT _PY_LIB_REL AND _PY_LIB_DBG) - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_PY_LIB_DBG}" - IMPORTED_IMPLIB_RELWITHDEBINFO "${_PY_LIB_DBG}" - IMPORTED_IMPLIB_MINSIZEREL "${_PY_LIB_DBG}" - MAP_IMPORTED_CONFIG_RELEASE "Debug" + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_DBG}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_DBG}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_DBG}" + MAP_IMPORTED_CONFIG_RELEASE "Debug" MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" - MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" - ) - endif() - -else() - # Non-Windows: point to the real binary (shared/static); skip EXISTS guards - if(_PY_LIB_REL) - set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" - ) - endif() - if(_PY_LIB_DBG) - set_target_properties(Python::Python PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" ) endif() endif() # Helpful diagnostics (ensure we actually set something) message(STATUS "[Diag/Core_Python] _PY_LIB_DBG='${_PY_LIB_DBG}' _PY_LIB_REL='${_PY_LIB_REL}'") -get_target_property(_py_implib_dbg Python::Python IMPORTED_IMPLIB_DEBUG) -get_target_property(_py_implib_rel Python::Python IMPORTED_IMPLIB_RELEASE) -message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_DEBUG='${_py_implib_dbg}'") -message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_RELEASE='${_py_implib_rel}'") + +# For the alias imported target we created +get_target_property(_py_imp_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) +get_target_property(_py_imp_rel SCIRunPython IMPORTED_LOCATION_RELEASE) +message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_DEBUG='${_py_imp_dbg}'") +message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_RELEASE='${_py_imp_rel}'") # ==================================================================================== # Platform-specific compile definitions (PYTHONPATH, etc.) @@ -323,7 +305,7 @@ endif() # ==================================================================================== target_link_libraries(Core_Python PRIVATE - Python::Python + SCIRunPython SCIRunPythonAPI ${SCI_BOOST_LIBRARY} Core_Matlab @@ -411,26 +393,11 @@ endif() # Debug-only macro (matches your previous behavior) set_target_properties(Core_Python PROPERTIES COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON") -# ---- TEMP: strip any explicit system Python importlib if it leaked in ---- -get_target_property(_cp_links Core_Python LINK_LIBRARIES) -if(_cp_links) - set(_cleaned "") - foreach(_L IN LISTS _cp_links) - file(TO_CMAKE_PATH "${_L}" _N) - if(_N MATCHES "^C:/Program Files/[^/]*/Python[^/]*/libs/python[0-9]+(_d)?\\.lib$") - # skip system python lib - else() - list(APPEND _cleaned "${_L}") - endif() - endforeach() - set_target_properties(Core_Python PROPERTIES LINK_LIBRARIES "${_cleaned}") -endif() - # ---- Helpful diagnostics (actual evaluated properties) ---- -get_target_property(_py_implib_dbg Python::Python IMPORTED_IMPLIB_DEBUG) -get_target_property(_py_implib_rel Python::Python IMPORTED_IMPLIB_RELEASE) +get_target_property(_py_imp_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) +get_target_property(_py_imp_rel SCIRunPython IMPORTED_LOCATION_RELEASE) get_target_property(_cp_links2 Core_Python LINK_LIBRARIES) -message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_DEBUG='${_py_implib_dbg}'") -message(STATUS "[Diag/Core_Python] PY IMPORTED_IMPLIB_RELEASE='${_py_implib_rel}'") +message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_DEBUG='${_py_imp_dbg}'") +message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_RELEASE='${_py_imp_rel}'") message(STATUS "[Diag/Core_Python] LINK_LIBRARIES=${_cp_links2}") \ No newline at end of file diff --git a/src/Dataflow/Engine/Controller/CMakeLists.txt b/src/Dataflow/Engine/Controller/CMakeLists.txt index fadc96e9ce..5aa3b8bb48 100644 --- a/src/Dataflow/Engine/Controller/CMakeLists.txt +++ b/src/Dataflow/Engine/Controller/CMakeLists.txt @@ -26,7 +26,11 @@ # -SET(Engine_Network_SRCS +# ========================= +# Dataflow/Engine/Network +# ========================= + +set(Engine_Network_SRCS DynamicPortManager.cc NetworkEditorController.cc NetworkCommands.cc @@ -37,7 +41,7 @@ SET(Engine_Network_SRCS PythonImpl.cc ) -SET(Engine_Network_HEADERS +set(Engine_Network_HEADERS ControllerInterfaces.h DynamicPortManager.h NetworkEditorController.h @@ -55,7 +59,7 @@ SCIRUN_ADD_LIBRARY(Engine_Network ${Engine_Network_SRCS} ) -SET(Engine_Network_NonPythonDependentLibs +set(Engine_Network_NonPythonDependentLibs Dataflow_Network Core_Serialization_Network Core_Command @@ -64,28 +68,74 @@ SET(Engine_Network_NonPythonDependentLibs Core_Matlab ) -IF(BUILD_WITH_PYTHON) +# -------------------------------------------------------------------- +# Python includes (needed for Boost.Python headers -> pyconfig.h on Win) +# -------------------------------------------------------------------- +if (BUILD_WITH_PYTHON) + set(_PY_INCLUDES "") - TARGET_LINK_LIBRARIES(Engine_Network - ${Engine_Network_NonPythonDependentLibs} - SCIRunPythonAPI - Core_Python - ) + if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") + endif() + if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") + endif() - INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIR} - ) + # Fallback to PCbuild layout if cache vars aren’t present + if (MSVC AND NOT _PY_INCLUDES) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if (EXISTS "${_py_src}/Include") + list(APPEND _PY_INCLUDES "${_py_src}/Include") + endif() + if (EXISTS "${_py_src}/PC") + list(APPEND _PY_INCLUDES "${_py_src}/PC") + endif() + endif() -ELSE() + if (_PY_INCLUDES) + list(REMOVE_DUPLICATES _PY_INCLUDES) + target_include_directories(Engine_Network PRIVATE ${_PY_INCLUDES}) + message(STATUS "[Engine/Network] Added Python includes: ${_PY_INCLUDES}") + else() + message(WARNING "[Engine/Network] Python includes not found at configure time; Boost.Python compilation may fail.") + endif() +endif() - TARGET_LINK_LIBRARIES(Engine_Network - ${Engine_Network_NonPythonDependentLibs} +# --------------------------------------------------------- +# Link libraries (use targets, not file paths; keep PRIVATE) +# --------------------------------------------------------- +if (BUILD_WITH_PYTHON) + target_link_libraries(Engine_Network + PRIVATE + ${Engine_Network_NonPythonDependentLibs} + # Python bits + Core_Python # SCIRun's Python core (brings Python usage + policies) + SCIRunPythonAPI # link to the target; CMake will use the import .lib, not the .pyd + SCIRunPython # ensure the CPython import libs (python313[_d].lib) are available ) + target_compile_definitions(Engine_Network PRIVATE BOOST_PYTHON_NO_LIB BOOST_PYTHON_STATIC_LIB) +else() + target_link_libraries(Engine_Network + PRIVATE + ${Engine_Network_NonPythonDependentLibs} + ) +endif() -ENDIF() +# ------------------------------------------------------------------------- +# Debug-only: block autolink of release python313.lib (e.g., Boost.Python) +# ------------------------------------------------------------------------- +if (BUILD_WITH_PYTHON) + # If you want to derive digits programmatically, you can, but 313 is fine here. + target_link_options(Engine_Network PRIVATE + $<$:/NODEFAULTLIB:python313.lib> + ) +endif() -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Engine_Network) -ENDIF(BUILD_SHARED_LIBS) +# ----------------------------------- +# DLL build define (preserve behavior) +# ----------------------------------- +if (BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Engine_Network) +endif() -SCIRUN_ADD_TEST_DIR(Tests) +SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index 23019dd548..993bd0f65f 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -25,11 +25,12 @@ # DEALINGS IN THE SOFTWARE. # - # ========================================== # Dataflow/Engine/Python CMakeLists.txt # ========================================== +cmake_minimum_required(VERSION 3.16) + if(NOT BUILD_WITH_PYTHON) message(STATUS "[Dataflow/Engine/Python] Skipping SCIRunPythonAPI (BUILD_WITH_PYTHON=OFF)") return() @@ -54,164 +55,189 @@ SCIRUN_ADD_LIBRARY(SCIRunPythonAPI ) # ==================================================================================== -# Cross-platform Python detection with superbuild override (Windows multi-config) +# Ensure an alias imported target 'SCIRunPython' exists and points to the CPython +# import libraries (Windows/MSVC) or the shared/static python lib on other platforms. +# Prefer the alias from Core/Python; if missing, create a compatible one here. # ==================================================================================== -# Expect these (from superbuild): -# PY_EXT_LIB_DIR -> .../Externals/Source/Python_external/PCbuild/amd64 -# PY_INCLUDE_DIR -> .../Externals/Source/Python_external/Include -# PYTHON_LIBRARY_DEBUG/RELEASE (legacy names also accepted) -# PYTHON_INCLUDE_DIR (legacy name also accepted) - -# Try modern find first (harmless; we may override below) -set(_SCIRUN_API_PY_OK FALSE) -find_package(Python QUIET COMPONENTS Interpreter Development) -if(Python_Interpreter_FOUND AND Python_Development_FOUND) - set(_SCIRUN_API_PY_OK TRUE) -else() - find_package(Python3 QUIET COMPONENTS Interpreter Development) - if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - if(TARGET Python3::Python AND NOT TARGET Python::Python) - add_library(Python::Python ALIAS Python3::Python) - endif() - set(_SCIRUN_API_PY_OK TRUE) - endif() -endif() +set(_PY_INCLUDE_DIRS "") +set(_PY_LIB_REL "") +set(_PY_LIB_DBG "") -# --- Superbuild override on Windows (force correct import libs per-config) ----------- -if(MSVC) - set(_PY_DEBUG_LIB_NAME "python313_d.lib") # adjust if you switch Python versions - set(_PY_RELEASE_LIB_NAME "python313.lib") - - # Prefer new-style vars - set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") - set(_SB_INC_DIR "${PY_INCLUDE_DIR}") - - # Fallback to legacy names to infer paths - if(NOT _SB_LIB_DIR) - if(PYTHON_LIBRARY_DEBUG) - get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) - elseif(PYTHON_LIBRARY_RELEASE) - get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) - endif() - endif() - if(NOT _SB_INC_DIR) - if(PYTHON_INCLUDE_DIR) - set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") - elseif(Python_INCLUDE_DIRS) - list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) - endif() - endif() +# Prefer superbuild hints (typical when using PCbuild layout on Windows) +if(PYTHON_LIBRARY_RELEASE) + set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") +endif() +if(PYTHON_LIBRARY_DEBUG) + set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") +endif() - # Last-resort defaults relative to inner build - if(NOT _SB_LIB_DIR) - set(_SB_LIB_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64") +# Also accept short names (if provided) +if(NOT _PY_LIB_REL AND DEFINED PY_EXT_LIB_DIR) + if(EXISTS "${PY_EXT_LIB_DIR}/python313.lib") + set(_PY_LIB_REL "${PY_EXT_LIB_DIR}/python313.lib") endif() - if(NOT _SB_INC_DIR) - set(_SB_INC_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/Include") +endif() +if(NOT _PY_LIB_DBG AND DEFINED PY_EXT_LIB_DIR) + if(EXISTS "${PY_EXT_LIB_DIR}/python313_d.lib") + set(_PY_LIB_DBG "${PY_EXT_LIB_DIR}/python313_d.lib") endif() +endif() - # Resolve per-config import libraries - set(_py_dbg_lib "") - set(_py_rel_lib "") - - # If explicit files were provided by superbuild, use them - if(PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") - set(_py_dbg_lib "${PYTHON_LIBRARY_DEBUG}") - endif() - if(PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") - set(_py_rel_lib "${PYTHON_LIBRARY_RELEASE}") - endif() +# Includes: prefer superbuild variables +if(PYTHON_INCLUDE_DIR) + list(APPEND _PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +endif() +if(PY_INCLUDE_DIR) + list(APPEND _PY_INCLUDE_DIRS "${PY_INCLUDE_DIR}") +endif() +if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") +endif() - # Otherwise, construct by expected names under the lib dir - if(NOT _py_dbg_lib) - set(_cand "${_SB_LIB_DIR}/${_PY_DEBUG_LIB_NAME}") - if(EXISTS "${_cand}") - set(_py_dbg_lib "${_cand}") +# If still incomplete, try modern FindPython to harvest includes/libs +if((NOT _PY_INCLUDE_DIRS) OR (NOT _PY_LIB_REL AND NOT _PY_LIB_DBG)) + find_package(Python QUIET COMPONENTS Interpreter Development) + if(Python_Development_FOUND AND TARGET Python::Python) + if(NOT _PY_INCLUDE_DIRS AND Python_INCLUDE_DIRS) + set(_PY_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") endif() - endif() - if(NOT _py_rel_lib) - set(_cand "${_SB_LIB_DIR}/${_PY_RELEASE_LIB_NAME}") - if(EXISTS "${_cand}") - set(_py_rel_lib "${_cand}") + # Harvest import libs if present (MSVC) + get_target_property(_try_rel Python::Python IMPORTED_IMPLIB_RELEASE) + get_target_property(_try_dbg Python::Python IMPORTED_IMPLIB_DEBUG) + if(NOT _PY_LIB_REL AND _try_rel) + set(_PY_LIB_REL "${_try_rel}") + endif() + if(NOT _PY_LIB_DBG AND _try_dbg) + set(_PY_LIB_DBG "${_try_dbg}") + endif() + # Non-MSVC: fall back to IMPORTED_LOCATION_* (shared/static) + if(NOT MSVC) + if(NOT _PY_LIB_REL) + get_target_property(_try_loc_rel Python::Python IMPORTED_LOCATION_RELEASE) + if(_try_loc_rel) + set(_PY_LIB_REL "${_try_loc_rel}") + endif() + endif() + if(NOT _PY_LIB_DBG) + get_target_property(_try_loc_dbg Python::Python IMPORTED_LOCATION_DEBUG) + if(_try_loc_dbg) + set(_PY_LIB_DBG "${_try_loc_dbg}") + endif() + endif() endif() endif() +endif() - # Create or update Python::Python so it always points to superbuild import libs - if(NOT TARGET Python::Python) - add_library(Python::Python UNKNOWN IMPORTED) - endif() - - set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" - ) +# If Core/Python has already created SCIRunPython, reuse it. +if(NOT TARGET SCIRunPython) + # Create a compatible alias imported target locally + add_library(SCIRunPython STATIC IMPORTED GLOBAL) - # IMPORTANT on MSVC: use IMPORTED_IMPLIB_* (not IMPORTED_LOCATION_*) for .lib import libs - if(EXISTS "${_py_rel_lib}") - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_py_rel_lib}" - IMPORTED_IMPLIB_RELWITHDEBINFO "${_py_rel_lib}" - IMPORTED_IMPLIB_MINSIZEREL "${_py_rel_lib}" - ) - endif() - if(EXISTS "${_py_dbg_lib}") - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_py_dbg_lib}" + if(_PY_INCLUDE_DIRS) + list(REMOVE_DUPLICATES _PY_INCLUDE_DIRS) + set_target_properties(SCIRunPython PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" ) endif() - # Fail only if no usable lib was found and no prior package existed - if(NOT (EXISTS "${_py_rel_lib}" OR EXISTS "${_py_dbg_lib}" OR TARGET Python3::Python)) - message(FATAL_ERROR - "Python import libraries not found for Windows/MSVC.\n" - "Searched:\n _SB_LIB_DIR='${_SB_LIB_DIR}'\n" - "Expected names: ${_PY_RELEASE_LIB_NAME} / ${_PY_DEBUG_LIB_NAME}\n" - "Or explicit: PYTHON_LIBRARY_RELEASE='${PYTHON_LIBRARY_RELEASE}', PYTHON_LIBRARY_DEBUG='${PYTHON_LIBRARY_DEBUG}'\n" - "Include dir: _SB_INC_DIR='${_SB_INC_DIR}'" + if(MSVC) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" ) + if(_PY_LIB_REL) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + ) + endif() + if(_PY_LIB_DBG) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + ) + endif() + # Map missing variants so the generator never sees NOTFOUND + if(NOT _PY_LIB_DBG AND _PY_LIB_REL) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_REL}" + MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" + ) + endif() + if(NOT _PY_LIB_REL AND _PY_LIB_DBG) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_DBG}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_DBG}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_DBG}" + MAP_IMPORTED_CONFIG_RELEASE "Debug" + MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" + MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" + ) + endif() + else() + # Non-MSVC: the Python library may be a shared/static real library + if(_PY_LIB_REL) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + ) + endif() + if(_PY_LIB_DBG) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + ) + endif() endif() - - set(_SCIRUN_API_PY_OK TRUE) endif() -if(NOT _SCIRUN_API_PY_OK) - message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build SCIRunPythonAPI.") -endif() - -# This target does not use Boost.Python symbols directly; the define is harmless but optional. +# ==================================================================================== +# Compile definitions +# ==================================================================================== if(MSVC) + # This target does not use Boost.Python symbols directly; static lib define is harmless. target_compile_definitions(SCIRunPythonAPI PRIVATE BOOST_PYTHON_STATIC_LIB) endif() - target_compile_definitions(SCIRunPythonAPI PRIVATE BUILD_WITH_PYTHON) # ==================================================================================== -# Link dependencies (Python::Python now guaranteed to point to superbuild libs) +# Link dependencies (Python via SCIRunPython alias; PRIVATE to avoid leaking) # ==================================================================================== target_link_libraries(SCIRunPythonAPI PRIVATE Core_Thread Core_Datatypes_Legacy_Base Core_Persistent - Python::Python + SCIRunPython ${SCI_BOOST_LIBRARY} ) # ------------------------------------------------------------------------------------ # Debug-only insurance: ignore any autolinked *release* python import lib -# (e.g., if a 3rd-party .lib contains /DEFAULTLIB:python313.lib directives). +# (e.g., if a third-party .lib contains /DEFAULTLIB:python313.lib directives). # ------------------------------------------------------------------------------------ +# Derive python digits (e.g. "313") from the selected import libraries +set(_SCIRUN_PY_DIGITS "") +foreach(_cand "${_PY_LIB_DBG}" "${_PY_LIB_REL}") + if(_cand) + get_filename_component(_cand_name "${_cand}" NAME) + if(_cand_name MATCHES "python([0-9]+)(_d)?\\.lib$") + set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") + break() + endif() + endif() +endforeach() + if(MSVC) - # Compute name to ignore (matches CPython 3.13) - set(_SCIRUN_PY_RELEASE_NAME "python313.lib") - target_link_options(SCIRunPythonAPI PRIVATE - $<$:/NODEFAULTLIB:${_SCIRUN_PY_RELEASE_NAME}> - ) - # Optional belt-and-suspenders: force defaultlib to the debug import lib we set above - # get_target_property(_py_dbg_implib Python::Python IMPORTED_IMPLIB_DEBUG) - # if(_py_dbg_implib) - # target_link_options(SCIRunPythonAPI PRIVATE $<$:/DEFAULTLIB:${_py_dbg_implib}>) - # endif() + if(_SCIRUN_PY_DIGITS) + target_link_options(SCIRunPythonAPI PRIVATE + $<$:/NODEFAULTLIB:python${_SCIRUN_PY_DIGITS}.lib> + ) + else() + target_link_options(SCIRunPythonAPI PRIVATE + $<$:/NODEFAULTLIB:python3.lib> + ) + endif() endif() # ==================================================================================== @@ -219,7 +245,6 @@ endif() # ==================================================================================== if(BUILD_SHARED_LIBS) add_definitions(-DBUILD_SCIRunPythonAPI) - if(WIN32) set_target_properties(SCIRunPythonAPI PROPERTIES @@ -237,10 +262,10 @@ endif() SCIRUN_ADD_TEST_DIR(Tests) # ==================================================================================== -# Diagnostics (show what the imported target is actually using, not Python_LIBRARIES) +# Diagnostics (show what the alias imported target is actually using) # ==================================================================================== -get_target_property(_py_inc Python::Python INTERFACE_INCLUDE_DIRECTORIES) -get_target_property(_py_dbg Python::Python IMPORTED_IMPLIB_DEBUG) -get_target_property(_py_rel Python::Python IMPORTED_IMPLIB_RELEASE) -message(STATUS "[SCIRunPythonAPI] Python include(s) : ${_py_inc}") -message(STATUS "[SCIRunPythonAPI] Python importlib : Debug='${_py_dbg}' Release='${_py_rel}'") \ No newline at end of file +get_target_property(_api_py_inc SCIRunPython INTERFACE_INCLUDE_DIRECTORIES) +get_target_property(_api_py_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) +get_target_property(_api_py_rel SCIRunPython IMPORTED_LOCATION_RELEASE) +message(STATUS "[SCIRunPythonAPI] Python include(s) : ${_api_py_inc}") +message(STATUS "[SCIRunPythonAPI] Python importlib : Debug='${_api_py_dbg}' Release='${_api_py_rel}'") \ No newline at end of file diff --git a/src/Interface/Application/CMakeLists.txt b/src/Interface/Application/CMakeLists.txt index 0887669bfe..83ec6a6807 100644 --- a/src/Interface/Application/CMakeLists.txt +++ b/src/Interface/Application/CMakeLists.txt @@ -144,6 +144,33 @@ SCIRUN_ADD_LIBRARY(Interface_Application ${Interface_Application_RESOURCES_RCC} ) +# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h +if (BUILD_WITH_PYTHON) + set(_PY_INCLUDES "") + if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") + endif() + if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") + endif() + if (MSVC AND NOT _PY_INCLUDES) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if (EXISTS "${_py_src}/Include") + list(APPEND _PY_INCLUDES "${_py_src}/Include") + endif() + if (EXISTS "${_py_src}/PC") + list(APPEND _PY_INCLUDES "${_py_src}/PC") + endif() + endif() + if (_PY_INCLUDES) + list(REMOVE_DUPLICATES _PY_INCLUDES) + target_include_directories(Interface_Application PRIVATE ${_PY_INCLUDES}) + message(STATUS "[Interface/Application] Added Python includes: ${_PY_INCLUDES}") + else() + message(WARNING "[Interface/Application] Python includes not found at configure time; Boost.Python compilation may fail.") + endif() +endif() + SET(NonPythonInterface_ApplicationLinkLibraries Dataflow_Network Core_Serialization_Network_Importer diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc index ab7864c147..098c98206e 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc @@ -28,6 +28,9 @@ #include #include +#include +#include +#include using namespace SCIRun::Gui; using namespace SCIRun::Core::Algorithms::Python; @@ -223,73 +226,110 @@ CodeEditorHighlighter::CodeEditorHighlighter(QTextDocument *parent) << "\\bTrue\\b" << "\\bFalse\\b" << "\\bNone\\b"; for (const auto& pattern : keywordPatterns) { - rule.pattern = QRegExp(pattern); + rule.pattern = QRegularExpression(pattern); rule.format = keywordFormat; highlightingRules.append(rule); } classFormat.setFontWeight(QFont::Bold); classFormat.setForeground(Qt::darkMagenta); - rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b"); + rule.pattern = QRegularExpression("\\bQ[A-Za-z]+\\b"); rule.format = classFormat; highlightingRules.append(rule); quotationFormat.setForeground(Qt::darkGreen); - rule.pattern = QRegExp("\".*\""); + rule.pattern = QRegularExpression("\".*\""); rule.format = quotationFormat; highlightingRules.append(rule); functionFormat.setFontItalic(true); functionFormat.setForeground(Qt::cyan); - rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); + rule.pattern = QRegularExpression("\\b[A-Za-z0-9_]+(?=\\()"); rule.format = functionFormat; highlightingRules.append(rule); singleLineCommentFormat.setForeground(Qt::yellow); - rule.pattern = QRegExp("#[^\n]*"); + rule.pattern = QRegularExpression("#[^\n]*"); rule.format = singleLineCommentFormat; highlightingRules.append(rule); multiLineCommentFormat.setForeground(QColor(255,105,180)); - commentStartExpression = QRegExp(matlabDelimiter); - commentEndExpression = QRegExp(matlabDelimiter); + commentStartExpression = QRegularExpression(matlabDelimiter); + commentEndExpression = QRegularExpression(matlabDelimiter); } void CodeEditorHighlighter::highlightBlock(const QString &text) { + // Keep whatever you do here highlightBlockParens(text); + + // --- 1) Per-rule highlighting (QRegularExpression replaces QRegExp) --- for (const auto& rule : highlightingRules) { - QRegExp expression(rule.pattern); - int index = expression.indexIn(text); - while (index >= 0) + // rule.pattern is already a QRegularExpression + QRegularExpressionMatchIterator it = rule.pattern.globalMatch(text); + while (it.hasNext()) { - int length = expression.matchedLength(); - setFormat(index, length, rule.format); - index = expression.indexIn(text, index + length); + const QRegularExpressionMatch m = it.next(); + if (!m.hasMatch()) continue; + + const int index = m.capturedStart(); + const int length = m.capturedLength(); + if (index >= 0 && length > 0) + setFormat(index, length, rule.format); } } + // --- 2) Multi-line comments with block states --- setCurrentBlockState(0); + + // commentStartExpression/commentEndExpression must be QRegularExpression + // e.g., commentStartExpression = QRegularExpression("/\\*"); + // commentEndExpression = QRegularExpression("\\*/"); + int startIndex = 0; if (previousBlockState() != 1) - startIndex = commentStartExpression.indexIn(text); + { + // First occurrence of start delimiter in this block + QRegularExpressionMatch startMatch = commentStartExpression.match(text); + startIndex = startMatch.hasMatch() ? startMatch.capturedStart() : -1; + } + else + { + // We are *inside* a multi-line comment from the previous block + startIndex = 0; + } while (startIndex >= 0) { - int endIndex = commentEndExpression.indexIn(text, startIndex); - int commentLength; - if (endIndex == -1) + // Search for the end delimiter *after* startIndex + QRegularExpressionMatch endMatch = + commentEndExpression.match(text, startIndex); + + int commentLength = 0; + if (!endMatch.hasMatch()) { + // Not closed in this block: color till end and keep state "inside comment" setCurrentBlockState(1); commentLength = text.length() - startIndex; + setFormat(startIndex, commentLength, multiLineCommentFormat); + break; // no more to find in this block } else { - commentLength = endIndex - startIndex + commentEndExpression.matchedLength(); + // Found the end; include the end delimiter + const int endIndex = endMatch.capturedStart(); + const int endLength = endMatch.capturedLength(); // replaces matchedLength() + commentLength = (endIndex - startIndex) + endLength; + + setFormat(startIndex, commentLength, multiLineCommentFormat); + + // Look for next start after this comment + const int nextSearchPos = startIndex + commentLength; + QRegularExpressionMatch nextStart = + commentStartExpression.match(text, nextSearchPos); + startIndex = nextStart.hasMatch() ? nextStart.capturedStart() : -1; } - setFormat(startIndex, commentLength, multiLineCommentFormat); - startIndex = commentStartExpression.indexIn(text, startIndex + commentLength); } } diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h index f9129c12e8..86bd5d69f6 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h @@ -31,6 +31,7 @@ #include #include +#include namespace SCIRun { namespace Gui { @@ -106,13 +107,13 @@ class CodeEditorHighlighter : public QSyntaxHighlighter private: struct HighlightingRule { - QRegExp pattern; + QRegularExpression pattern; QTextCharFormat format; }; QVector highlightingRules; - QRegExp commentStartExpression; - QRegExp commentEndExpression; + QRegularExpression commentStartExpression; + QRegularExpression commentEndExpression; QTextCharFormat keywordFormat; QTextCharFormat classFormat; diff --git a/src/Modules/Factory/CMakeLists.txt b/src/Modules/Factory/CMakeLists.txt index 5dd8a2a62d..b97fbca393 100644 --- a/src/Modules/Factory/CMakeLists.txt +++ b/src/Modules/Factory/CMakeLists.txt @@ -60,6 +60,33 @@ SCIRUN_ADD_LIBRARY(Modules_Factory ${ModuleFactoryImpl_Generated} ) +# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h +if (BUILD_WITH_PYTHON) + set(_PY_INCLUDES "") + if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") + endif() + if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") + endif() + if (MSVC AND NOT _PY_INCLUDES) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if (EXISTS "${_py_src}/Include") + list(APPEND _PY_INCLUDES "${_py_src}/Include") + endif() + if (EXISTS "${_py_src}/PC") + list(APPEND _PY_INCLUDES "${_py_src}/PC") + endif() + endif() + if (_PY_INCLUDES) + list(REMOVE_DUPLICATES _PY_INCLUDES) + target_include_directories(Modules_Factory PRIVATE ${_PY_INCLUDES}) + message(STATUS "[Modules/Factory] Added Python includes: ${_PY_INCLUDES}") + else() + message(WARNING "[Modules/Factory] Python includes not found at configure time; Boost.Python compilation may fail.") + endif() +endif() + IF(GENERATE_MODULE_FACTORY_CODE AND REGENERATE_MODULE_FACTORY_CODE) ADD_CUSTOM_COMMAND( TARGET Modules_Factory diff --git a/src/Modules/Math/CMakeLists.txt b/src/Modules/Math/CMakeLists.txt index 798bcc1777..8bb9fdfd85 100644 --- a/src/Modules/Math/CMakeLists.txt +++ b/src/Modules/Math/CMakeLists.txt @@ -92,8 +92,42 @@ SCIRUN_ADD_LIBRARY(Modules_Math ${Modules_Math_SRCS} ) -if (MSVC) - target_compile_options(Modules_Math PRIVATE /showIncludes) +# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h + +if (BUILD_WITH_PYTHON) + set(_PY_INCLUDES "") + if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") + endif() + if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") + endif() + if (MSVC AND NOT _PY_INCLUDES) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if (EXISTS "${_py_src}/Include") + list(APPEND _PY_INCLUDES "${_py_src}/Include") + endif() + if (EXISTS "${_py_src}/PC") + list(APPEND _PY_INCLUDES "${_py_src}/PC") + endif() + endif() + if (_PY_INCLUDES) + list(REMOVE_DUPLICATES _PY_INCLUDES) + target_include_directories(Modules_Math PRIVATE ${_PY_INCLUDES}) + message(STATUS "[Modules/Math] Added Python includes: ${_PY_INCLUDES}") + else() + message(WARNING "[Modules/Math] Python includes not found at configure time; Boost.Python compilation may fail.") + endif() + + # Disable Boost.Python autolink so this target doesn't try to link Boost/Python + target_compile_definitions(Modules_Math PRIVATE BOOST_PYTHON_NO_LIB) # <-- add this + + # Debug-only: ignore any release python import lib autolink attempts + if(MSVC) + target_link_options(Modules_Math PRIVATE + $<$:/NODEFAULTLIB:python313.lib> + ) + endif() endif() TARGET_LINK_LIBRARIES(Modules_Math @@ -103,14 +137,8 @@ TARGET_LINK_LIBRARIES(Modules_Math Algorithms_Math ) -IF(BUILD_WITH_PYTHON) - TARGET_LINK_LIBRARIES(Modules_Math - Core_Python - ) -ENDIF() - IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Math) -ENDIF(BUILD_SHARED_LIBS) +ENDIF() -SCIRUN_ADD_TEST_DIR(Tests) +SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file diff --git a/src/Modules/Python/CMakeLists.txt b/src/Modules/Python/CMakeLists.txt index e6c5599fb1..64ca25998f 100644 --- a/src/Modules/Python/CMakeLists.txt +++ b/src/Modules/Python/CMakeLists.txt @@ -25,7 +25,6 @@ # DEALINGS IN THE SOFTWARE. # - # ========================= # Modules/Python CMake file # ========================= @@ -63,133 +62,95 @@ if(BUILD_SHARED_LIBS) endif() # ==================================================================================== -# Optional Python detection (only if the build is configured with Python support) -# - We *always* link to Python::Python (imported target) -# - On MSVC we override Python::Python to the superbuild import libs using IMPORTED_IMPLIB_* +# Python wiring: +# - Reuse alias imported target SCIRunPython (created in Core/Python) that points +# to .../PCbuild/amd64/python313[_d].lib and exports Python include dirs. +# - If it does not exist (edge case), create a compatible local alias. # ==================================================================================== -set(_SCIRUN_MODULES_PY_OK FALSE) - if(BUILD_WITH_PYTHON) - # Prefer modern FindPython; harmless if we will override on MSVC - find_package(Python QUIET COMPONENTS Interpreter Development) - if(Python_Interpreter_FOUND AND Python_Development_FOUND) - set(_SCIRUN_MODULES_PY_OK TRUE) - else() - find_package(Python3 QUIET COMPONENTS Interpreter Development) - if(Python3_Interpreter_FOUND AND Python3_Development_FOUND) - if(TARGET Python3::Python AND NOT TARGET Python::Python) - add_library(Python::Python ALIAS Python3::Python) - endif() - set(_SCIRUN_MODULES_PY_OK TRUE) - endif() - endif() - - # --- Superbuild override on Windows/MSVC: force per-config import libs ----------- - # Superbuild should pass either: - # - New style: PY_EXT_LIB_DIR (..../PCbuild/amd64), PY_INCLUDE_DIR (..../Include) - # - Legacy: PYTHON_LIBRARY_DEBUG/RELEASE, PYTHON_INCLUDE_DIR - if(MSVC) - # Default CPython 3.13 names; adjust if you change Python version - set(_PY_DEBUG_LIB_NAME "python313_d.lib") - set(_PY_RELEASE_LIB_NAME "python313.lib") - - set(_SB_LIB_DIR "${PY_EXT_LIB_DIR}") - set(_SB_INC_DIR "${PY_INCLUDE_DIR}") - - # Fallback from legacy variables - if(NOT _SB_LIB_DIR) - if(PYTHON_LIBRARY_DEBUG) - get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) - elseif(PYTHON_LIBRARY_RELEASE) - get_filename_component(_SB_LIB_DIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) - endif() - endif() - if(NOT _SB_INC_DIR) - if(PYTHON_INCLUDE_DIR) - set(_SB_INC_DIR "${PYTHON_INCLUDE_DIR}") - elseif(Python_INCLUDE_DIRS) - list(GET Python_INCLUDE_DIRS 0 _SB_INC_DIR) - endif() - endif() - - # Last-resort defaults relative to inner build - if(NOT _SB_LIB_DIR) - set(_SB_LIB_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64") - endif() - if(NOT _SB_INC_DIR) - set(_SB_INC_DIR "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/Include") - endif() - - # Resolve per-config import libraries - set(_py_dbg_lib "") - set(_py_rel_lib "") + if(NOT TARGET SCIRunPython) + # Minimal local alias (fallback) — prefer superbuild hints if available + add_library(SCIRunPython STATIC IMPORTED GLOBAL) - # Use explicit file paths if provided - if(PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") - set(_py_dbg_lib "${PYTHON_LIBRARY_DEBUG}") + # Includes: prefer superbuild vars + set(_PY_INC_DIRS "") + if(DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") + list(APPEND _PY_INC_DIRS "${PYTHON_INCLUDE_DIR}") endif() - if(PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") - set(_py_rel_lib "${PYTHON_LIBRARY_RELEASE}") + if(DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") + list(APPEND _PY_INC_DIRS "${PYTHON_PC_INCLUDE_DIR}") endif() - - # Otherwise, construct by expected names under the lib dir - if(NOT _py_dbg_lib) - set(_cand "${_SB_LIB_DIR}/${_PY_DEBUG_LIB_NAME}") - if(EXISTS "${_cand}") - set(_py_dbg_lib "${_cand}") + if(MSVC AND NOT _PY_INC_DIRS) + set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") + if(EXISTS "${_py_src}/Include") + list(APPEND _PY_INC_DIRS "${_py_src}/Include") endif() - endif() - if(NOT _py_rel_lib) - set(_cand "${_SB_LIB_DIR}/${_PY_RELEASE_LIB_NAME}") - if(EXISTS "${_cand}") - set(_py_rel_lib "${_cand}") + if(EXISTS "${_py_src}/PC") + list(APPEND _PY_INC_DIRS "${_py_src}/PC") endif() endif() - - # Create or update Python::Python so it always points to superbuild import libs - if(NOT TARGET Python::Python) - add_library(Python::Python UNKNOWN IMPORTED) - endif() - - set_target_properties(Python::Python PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_SB_INC_DIR}" - ) - - # IMPORTANT: on MSVC the import library must be set via IMPORTED_IMPLIB_* (not IMPORTED_LOCATION_*) - if(EXISTS "${_py_rel_lib}") - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_py_rel_lib}" - IMPORTED_IMPLIB_RELWITHDEBINFO "${_py_rel_lib}" - IMPORTED_IMPLIB_MINSIZEREL "${_py_rel_lib}" - ) - endif() - if(EXISTS "${_py_dbg_lib}") - set_target_properties(Python::Python PROPERTIES - IMPORTED_IMPLIB_DEBUG "${_py_dbg_lib}" + if(_PY_INC_DIRS) + list(REMOVE_DUPLICATES _PY_INC_DIRS) + set_target_properties(SCIRunPython PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_PY_INC_DIRS}" ) endif() - if(NOT (EXISTS "${_py_rel_lib}" OR EXISTS "${_py_dbg_lib}" OR TARGET Python3::Python)) - message(FATAL_ERROR - "Python import libraries not found for Windows/MSVC.\n" - "Searched:\n _SB_LIB_DIR='${_SB_LIB_DIR}'\n" - "Expected: ${_PY_RELEASE_LIB_NAME} / ${_PY_DEBUG_LIB_NAME}\n" - "Or explicit: PYTHON_LIBRARY_RELEASE='${PYTHON_LIBRARY_RELEASE}', PYTHON_LIBRARY_DEBUG='${PYTHON_LIBRARY_DEBUG}'\n" - "Include dir: _SB_INC_DIR='${_SB_INC_DIR}'") - endif() + # Point to import libs on MSVC + if(MSVC) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" + ) + set(_PY_LIB_REL "") + set(_PY_LIB_DBG "") + if(PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") + set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") + elseif(DEFINED PY_EXT_LIB_DIR AND EXISTS "${PY_EXT_LIB_DIR}/python313.lib") + set(_PY_LIB_REL "${PY_EXT_LIB_DIR}/python313.lib") + endif() + if(PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") + set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") + elseif(DEFINED PY_EXT_LIB_DIR AND EXISTS "${PY_EXT_LIB_DIR}/python313_d.lib") + set(_PY_LIB_DBG "${PY_EXT_LIB_DIR}/python313_d.lib") + endif() - set(_SCIRUN_MODULES_PY_OK TRUE) - endif() # MSVC + if(_PY_LIB_REL) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" + ) + endif() + if(_PY_LIB_DBG) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" + ) + endif() - if(NOT _SCIRUN_MODULES_PY_OK) - message(FATAL_ERROR "BUILD_WITH_PYTHON is ON, but Python (Interpreter + Development) could not be found.") + # Map if only one variant exists + if(NOT _PY_LIB_DBG AND _PY_LIB_REL) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_DEBUG "${_PY_LIB_REL}" + MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" + ) + endif() + if(NOT _PY_LIB_REL AND _PY_LIB_DBG) + set_target_properties(SCIRunPython PROPERTIES + IMPORTED_LOCATION_RELEASE "${_PY_LIB_DBG}" + IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_DBG}" + IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_DBG}" + MAP_IMPORTED_CONFIG_RELEASE "Debug" + MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" + MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" + ) + endif() + endif() endif() endif() # BUILD_WITH_PYTHON # ==================================================================================== # Link dependencies # ==================================================================================== - target_link_libraries(Modules_Python PRIVATE Dataflow_Network @@ -199,36 +160,131 @@ target_link_libraries(Modules_Python ) if(BUILD_WITH_PYTHON) - target_link_libraries(Modules_Python - PRIVATE - Python::Python - Core_Python - ) - target_compile_definitions(Modules_Python PRIVATE BUILD_WITH_PYTHON) + # Pull in Python headers + import libs (per-config) via the alias + target_link_libraries(Modules_Python PRIVATE SCIRunPython Core_Python) + + # ================================================================================== + # Boost.Python: disable autolink and link the correct libraries explicitly on MSVC. + # Fixes LNK1104 asking for 'boost_python...' (no 'lib' prefix) when your files are + # named 'libboost_python...'. + # ================================================================================== if(MSVC) - # If any transitive lib autolinks release python313.lib, ignore it in Debug - target_link_options(Modules_Python PRIVATE - $<$:/NODEFAULTLIB:python313.lib> + target_compile_definitions(Modules_Python PRIVATE BOOST_PYTHON_NO_LIB BOOST_PYTHON_STATIC_LIB) + + # Locate Boost.Python libraries in SCI_BOOST_LIBRARY_DIR (passed from superbuild) + if (NOT DEFINED SCI_BOOST_LIBRARY_DIR OR NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") + message(FATAL_ERROR + "[Modules/Python] SCI_BOOST_LIBRARY_DIR is not set or does not exist; " + "cannot link Boost.Python explicitly." + ) + endif() + + # Try to infer python digits (e.g., 313) from the CPython import libs we are using + set(_SCIRUN_PY_DIGITS "") + if(TARGET SCIRunPython) + get_target_property(_py_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) + get_target_property(_py_rel SCIRunPython IMPORTED_LOCATION_RELEASE) + foreach(_cand "${_py_dbg}" "${_py_rel}") + if(_cand) + get_filename_component(_bn "${_cand}" NAME) + if(_bn MATCHES "python([0-9]+)(_d)?\\.lib$") + set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") + break() + endif() + endif() + endforeach() + endif() + + # Build candidate patterns (both with/without 'lib' prefix) + if(_SCIRUN_PY_DIGITS) + set(_bp_dbg_patterns + "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_DIGITS}-vc*-mt-gd-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_DIGITS}-vc*-mt-gd-*.lib" + ) + set(_bp_rel_patterns_all + "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_DIGITS}-vc*-mt-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_DIGITS}-vc*-mt-*.lib" + ) + else() + # Fallback: any 3.x debug/release variants + set(_bp_dbg_patterns + "${SCI_BOOST_LIBRARY_DIR}/libboost_python3*-vc*-mt-gd-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_python3*-vc*-mt-gd-*.lib" + ) + set(_bp_rel_patterns_all + "${SCI_BOOST_LIBRARY_DIR}/libboost_python3*-vc*-mt-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_python3*-vc*-mt-*.lib" + ) + endif() + + # Collect and pick best (latest) debug candidate + set(_bp_dbg_candidates "") + foreach(_pat IN LISTS _bp_dbg_patterns) + file(GLOB _hits "${_pat}") + if(_hits) + list(APPEND _bp_dbg_candidates ${_hits}) + endif() + endforeach() + if(_bp_dbg_candidates) + list(SORT _bp_dbg_candidates) + list(REVERSE _bp_dbg_candidates) + list(GET _bp_dbg_candidates 0 _BP_PY_LIB_DEBUG) + endif() + + # Collect and pick best (latest) release candidate, but filter out "-gd-" + set(_bp_rel_candidates "") + foreach(_pat IN LISTS _bp_rel_patterns_all) + file(GLOB _hits "${_pat}") + foreach(_h IN LISTS _hits) + if(NOT _h MATCHES "-gd-") # exclude debug variants + list(APPEND _bp_rel_candidates "${_h}") + endif() + endforeach() + endforeach() + if(_bp_rel_candidates) + list(SORT _bp_rel_candidates) + list(REVERSE _bp_rel_candidates) + list(GET _bp_rel_candidates 0 _BP_PY_LIB_RELEASE) + endif() + + if(NOT (EXISTS "${_BP_PY_LIB_DEBUG}" AND EXISTS "${_BP_PY_LIB_RELEASE}")) + message(FATAL_ERROR + "[Modules/Python] Could not locate Boost.Python libs under '${SCI_BOOST_LIBRARY_DIR}'.\n" + "Debug candidate='${_BP_PY_LIB_DEBUG}'\nRelease candidate='${_BP_PY_LIB_RELEASE}'" + ) + endif() + + # Ensure the directory is on the link path + target_link_directories(Modules_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") + + # Explicitly link Boost.Python (eliminates autolink name mismatch) + target_link_libraries(Modules_Python PRIVATE + debug "${_BP_PY_LIB_DEBUG}" + optimized "${_BP_PY_LIB_RELEASE}" ) - # Optional: define if you rely on static Boost.Python in this module - # target_compile_definitions(Modules_Python PRIVATE BOOST_PYTHON_STATIC_LIB) - endif() -endif() -# ==================================================================================== -# Tests (kept) -# ==================================================================================== -if(BUILD_WITH_PYTHON) - SCIRUN_ADD_TEST_DIR(Tests) -endif() + # Debug-only: ignore any attempt to autolink the *release* python313.lib + if(_SCIRUN_PY_DIGITS) + target_link_options(Modules_Python PRIVATE + $<$:/NODEFAULTLIB:python${_SCIRUN_PY_DIGITS}.lib> + ) + else() + target_link_options(Modules_Python PRIVATE + $<$:/NODEFAULTLIB:python3.lib> + ) + endif() + + # Diagnostics + message(STATUS "[Modules/Python] Boost.Python (debug) : ${_BP_PY_LIB_DEBUG}") + message(STATUS "[Modules/Python] Boost.Python (release) : ${_BP_PY_LIB_RELEASE}") + endif() # MSVC + + target_compile_definitions(Modules_Python PRIVATE BUILD_WITH_PYTHON) +endif() # BUILD_WITH_PYTHON # ==================================================================================== -# Diagnostics (show what the imported target is *actually* using) +# Tests # ==================================================================================== if(BUILD_WITH_PYTHON) - get_target_property(_py_inc Python::Python INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(_py_dbg Python::Python IMPORTED_IMPLIB_DEBUG) - get_target_property(_py_rel Python::Python IMPORTED_IMPLIB_RELEASE) - message(STATUS "[Modules/Python] Python include(s) : ${_py_inc}") - message(STATUS "[Modules/Python] Python importlib : Debug='${_py_dbg}' Release='${_py_rel}'") + SCIRUN_ADD_TEST_DIR(Tests) endif() \ No newline at end of file From 593be222dbd05147eaf2c955e873e8e34758a48e Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 3 Mar 2026 11:18:36 -0700 Subject: [PATCH 055/140] ctk deprecated functions --- .../Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp | 12 ++++++++++++ .../Base/CustomWidgets/CTK/ctkBasePopupWidget.h | 10 ++++++++++ .../Base/CustomWidgets/CTK/ctkPopupWidget.cpp | 12 +++++++++++- .../Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h | 11 ++++++++++- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp index 85304b2bae..ed52de8277 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp @@ -834,3 +834,15 @@ void ctkBasePopupWidget::setEffectGeometry(QRect newGeometry) d->PopupPixmapWidget->setGeometry(newGeometry); d->PopupPixmapWidget->repaint(); } + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void ctkBasePopupWidget::enterEvent(QEnterEvent* event) +{ + QFrame::enterEvent(event); +} +#else +void ctkBasePopupWidget::enterEvent(QEvent* event) +{ + QFrame::enterEvent(event); +} +#endif diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h index c8ea58d300..f7b7d7c398 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h @@ -29,6 +29,10 @@ // CTK includes #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + #include // Needed for QEnterEvent in Qt6 +#endif + class ctkBasePopupWidgetPrivate; /// \ingroup Widgets @@ -195,6 +199,12 @@ public Q_SLOTS: virtual bool event(QEvent* event); virtual void paintEvent(QPaintEvent*); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent* event) override; +#else + void enterEvent(QEvent* event) override; +#endif + protected Q_SLOTS: virtual void onEffectFinished(); void setEffectAlpha(double alpha); diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp index 75d75610ae..f373d18293 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp @@ -428,13 +428,23 @@ void ctkPopupWidget::leaveEvent(QEvent* event) } // -------------------------------------------------------------------------- -void ctkPopupWidget::enterEvent(Q_ENTER_EVENT_CLASS* event) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void ctkPopupWidget::enterEvent(QEnterEvent* event) { Q_D(ctkPopupWidget); //qDebug() << __FUNCTION__ << __LINE__ << layout()->itemAt(0)->widget(); QTimer::singleShot(d->ShowDelay, this, &ctkPopupWidget::updatePopup); this->Superclass::enterEvent(event); } +#else +void ctkPopupWidget::enterEvent(QEvent* event) +{ + Q_D(ctkPopupWidget); + //qDebug() << __FUNCTION__ << __LINE__ << layout()->itemAt(0)->widget(); + QTimer::singleShot(d->ShowDelay, this, &ctkPopupWidget::updatePopup); + this->Superclass::enterEvent(event); +} +#endif // -------------------------------------------------------------------------- bool ctkPopupWidget::eventFilter(QObject* obj, QEvent* event) diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h index b9b1263de7..56fda9f808 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h @@ -25,6 +25,10 @@ #include "ctkBasePopupWidget.h" #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + #include // Ensure this is included for Qt6 +#endif + class ctkPopupWidgetPrivate; /// \ingroup Widgets @@ -114,7 +118,12 @@ public Q_SLOTS: protected: void leaveEvent(QEvent* event) override; - void enterEvent(Q_ENTER_EVENT_CLASS* event) override; + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent* event) override; +#else + void enterEvent(QEvent* event) override; +#endif bool eventFilter(QObject* obj, QEvent* event) override; /// Widget the popup is attached to. It opens right under \a baseWidget From ab2cc9834de314b812b1c094813fd9542ec02062 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 3 Mar 2026 14:27:43 -0700 Subject: [PATCH 056/140] qwt wrapper --- Superbuild/QwtExternal.cmake | 121 +++++++++++++++++------------------ Superbuild/Superbuild.cmake | 12 +++- src/CMakeLists.txt | 61 +++++++++++++++++- 3 files changed, 125 insertions(+), 69 deletions(-) diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index d17485c31c..812c498a77 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -24,95 +24,88 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +# QwtExternal.cmake — build Qwt via the internal CMake wrapper (preferred over qmake) -# QwtExternal.cmake — build Qwt 6.3.0 with qmake from the superbuild +# ---------------------------- +# Single place to pin wrapper tag +# ---------------------------- +# Bump this tag when you cut a new wrapper release (e.g., v0.1.1, v0.2.0) +set(qwt_WRAPPER_GIT_TAG "v0.1.0") -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -# Your mirror/tag +# Keep the legacy variable for visibility; it's the upstream Qwt tag +# that your wrapper fetches internally (informational only here). set(qwt_GIT_TAG "v6.3.0") +# Ensure ExternalProject directories are rooted under the superbuild 'ep_base' +set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") + +# ---------------------------- # Superbuild directories +# ---------------------------- set(_qwt_src "${CMAKE_BINARY_DIR}/Externals/Source/Qwt_external") set(_qwt_bin "${CMAKE_BINARY_DIR}/Externals/Build/Qwt_external") set(_qwt_inst "${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external") -# -------- Select build tool per platform -------- -if(WIN32) - # Prefer jom if available; otherwise nmake - find_program(JOM_EXECUTABLE NAMES jom PATHS ENV PATH NO_DEFAULT_PATH) - if(NOT JOM_EXECUTABLE) - find_program(JOM_EXECUTABLE NAMES jom) - endif() - if(JOM_EXECUTABLE) - set(_MAKE_TOOL "${JOM_EXECUTABLE}") - else() - set(_MAKE_TOOL "nmake") - endif() -else() - # make or gmake; ExternalProject will run it in the source tree where qmake generates Makefiles - find_program(MAKE_EXECUTABLE NAMES make gmake) - if(NOT MAKE_EXECUTABLE) - message(FATAL_ERROR "No 'make' tool found for building Qwt.") - endif() - set(_MAKE_TOOL "${MAKE_EXECUTABLE}") +# ---------------------------- +# Qt discovery hints (optional) +# ---------------------------- +set(_qwt_extra_cmake_args "") +if(DEFINED Qt6_DIR) + list(APPEND _qwt_extra_cmake_args "-DQt6_DIR=${Qt6_DIR}") endif() - -# -------- Require the Qt qmake path -------- -if(NOT DEFINED QT_QMAKE_EXECUTABLE OR NOT EXISTS "${QT_QMAKE_EXECUTABLE}") - message(FATAL_ERROR "QT_QMAKE_EXECUTABLE is not set to a valid Qt qmake path (Qt 5/6).") +if(DEFINED Qt5_DIR) + list(APPEND _qwt_extra_cmake_args "-DQt5_DIR=${Qt5_DIR}") endif() -# Qwt’s qmake accepts PREFIX/INSTALLBASE to control where it installs. -# We pass both to cover different setups. -set(_QMAKE_CONFIG - "${QT_QMAKE_EXECUTABLE}" - "qwt.pro" - "PREFIX=${_qwt_inst}" - "INSTALLBASE=${_qwt_inst}" -) - -# Note: -# - We *don’t* set CMAKE_*_OUTPUT_DIRECTORY here—qmake controls build dirs. -# - We *do* run an actual install so downstream consumers get include/lib/plugin layout. +include(ExternalProject) ExternalProject_Add(Qwt_external - GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt.git" - GIT_TAG ${qwt_GIT_TAG} # v6.3.0 in your setup - UPDATE_DISCONNECTED 1 + # -------------- + # Your internal wrapper repo (CMake-based) + # -------------- + GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt-cmake-wrapper.git" + GIT_TAG ${qwt_WRAPPER_GIT_TAG} + GIT_SHALLOW 1 + GIT_PROGRESS 1 + # NOTE: leave UPDATE_DISCONNECTED OFF for the first successful fetch. + # You can re-enable it later to avoid network hits on re-configures. + # UPDATE_DISCONNECTED 1 SOURCE_DIR ${_qwt_src} - BINARY_DIR ${_qwt_bin} # not used by qmake; kept for symmetry/logs - - # --- Configure: run qmake in the source dir so it finds qwt.pro --- - CONFIGURE_COMMAND - ${CMAKE_COMMAND} -E chdir ${_qwt_src} - "${QT_QMAKE_EXECUTABLE}" qwt.pro - "PREFIX=${_qwt_inst}" - "INSTALLBASE=${_qwt_inst}" - - # --- Build: run the chosen make tool in the same source dir --- - BUILD_COMMAND - ${CMAKE_COMMAND} -E chdir ${_qwt_src} ${_MAKE_TOOL} - - # --- Install: same directory (qmake’s Makefile target `install`) --- - INSTALL_COMMAND - ${CMAKE_COMMAND} -E chdir ${_qwt_src} ${_MAKE_TOOL} install - + BINARY_DIR ${_qwt_bin} + INSTALL_DIR ${_qwt_inst} + + # ---------------------------- + # Configure the wrapper (it will fetch & build official Qwt inside) + # ---------------------------- + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${_qwt_inst} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} # honored for single-config generators + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + # Pass Qt hints if provided: + ${_qwt_extra_cmake_args} + + # ---------------------------- + # MSVC/VS multi-config forwarding (Debug/Release safe) + # ---------------------------- + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $,$,${CMAKE_BUILD_TYPE}> + INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config $,$,${CMAKE_BUILD_TYPE}> + + LOG_DOWNLOAD 1 + LOG_UPDATE 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# ------- Export variables for SCIRun / downstream ------- +# Exported variables for inner project (diagnostics/hints) set(QWT_SOURCE_DIR ${_qwt_src}) +set(QWT_BUILD_DIR ${_qwt_bin}) set(QWT_INSTALL_DIR ${_qwt_inst}) - -# Qwt installs headers under include/ (often include/qwt-6.3.0) and libs under lib/ set(QWT_INCLUDE "${QWT_INSTALL_DIR}/include") set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") - -# Library base name (actual file is qwt.lib / libqwt.a / libqwt.{so,dylib}) +# Consumers should prefer find_package(Qwt CONFIG), but we keep these for legacy: set(QWT_LIBRARY "qwt") +message(STATUS "[Qwt_external] WRAPPER_TAG=${qwt_WRAPPER_GIT_TAG} ; QWT_TAG=${qwt_GIT_TAG}") message(STATUS "[Qwt_external] INSTALL_DIR=${QWT_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index d8a3109a48..2258d65729 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1062,9 +1062,17 @@ endif() if(NOT BUILD_HEADLESS AND TARGET Qwt_external) ExternalProject_Get_Property(Qwt_external INSTALL_DIR) + if(NOT INSTALL_DIR) + set(INSTALL_DIR "${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external") + endif() + _sb_scirun_wait_for(NAME qwt - FILES "${INSTALL_DIR}/include/qwt.h" - DIRS "${INSTALL_DIR}/include" + FILES + "${INSTALL_DIR}/include/qwt/qwt_plot.h" + "${INSTALL_DIR}/lib/cmake/Qwt/QwtConfig.cmake" + DIRS + "${INSTALL_DIR}/include/qwt" + "${INSTALL_DIR}/lib" ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b40822c9bf..cca974972b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -808,11 +808,13 @@ if(WIN32) ) endif() -# Qwt (unless headless) +# Qwt (unless headless) - prefer config packages and fail (outside superbuild) if missing if(NOT BUILD_HEADLESS) CONFIG_STANDARD_EXTERNAL(Qwt - DIR "${QWT_DIR}" - CFG "QwtConfig.cmake" + DIR "${QWT_DIR}" + CFG "QwtConfig.cmake" + CONFIG_ONLY # prefer config packages + REQUIRED # outside superbuild, error out if missing ) endif() @@ -1234,6 +1236,59 @@ if(GLM_INCLUDE_DIR AND EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp") message(STATUS "GLM header OK: ${GLM_INCLUDE_DIR}/glm/glm.hpp") endif() +# ---- Qwt normalization + validation (place before _SCIRUN_INCLUDE_DIRS list) ---- +if(NOT BUILD_HEADLESS) + # 1) If a config package provided Qwt::Qwt, derive legacy SCI_QWT_INCLUDE from it + if(TARGET Qwt::Qwt) + get_target_property(_qwt_incs Qwt::Qwt INTERFACE_INCLUDE_DIRECTORIES) + set(_qwt_inc_ok "") + foreach(_inc IN LISTS _qwt_incs) + # Prefer the path that lets '#include ' work directly + if(EXISTS "${_inc}/qwt_plot.h") + set(_qwt_inc_ok "${_inc}") + break() + elseif(EXISTS "${_inc}/qwt/qwt_plot.h") + # If headers are under include/qwt, set the include root to that subdir + set(_qwt_inc_ok "${_inc}/qwt") + break() + endif() + endforeach() + if(_qwt_inc_ok) + set(SCI_QWT_INCLUDE "${_qwt_inc_ok}" CACHE PATH "Qwt include dir (root for )" FORCE) + message(STATUS "[SCIRun] Qwt include dir set from target: ${SCI_QWT_INCLUDE}") + endif() + endif() + + # 2) If no target or include yet, auto-derive from known install/prefix paths + if(NOT DEFINED SCI_QWT_INCLUDE OR NOT EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") + # If the superbuild exported QWT_INSTALL_DIR, prefer include/qwt under it + if(DEFINED QWT_INSTALL_DIR AND EXISTS "${QWT_INSTALL_DIR}/include/qwt/qwt_plot.h") + set(SCI_QWT_INCLUDE "${QWT_INSTALL_DIR}/include/qwt" CACHE PATH "Qwt include dir" FORCE) + message(STATUS "[SCIRun] Qwt include dir set from QWT_INSTALL_DIR: ${SCI_QWT_INCLUDE}") + else() + # Autoprobe from CMAKE_PREFIX_PATH: look for include/qwt/qwt_plot.h + _ensure_header(_QWT_INC_CAND "qwt/qwt_plot.h") + if(_QWT_INC_CAND AND EXISTS "${_QWT_INC_CAND}/qwt/qwt_plot.h") + set(SCI_QWT_INCLUDE "${_QWT_INC_CAND}/qwt" CACHE PATH "Qwt include dir" FORCE) + message(STATUS "[SCIRun] Qwt include dir auto-derived: ${SCI_QWT_INCLUDE}") + endif() + unset(_QWT_INC_CAND) + endif() + endif() + + # 3) If still no imported target but we have legacy variables, synthesize Qwt::Qwt + if(NOT TARGET Qwt::Qwt + AND DEFINED SCI_QWT_LIBRARY AND EXISTS "${SCI_QWT_LIBRARY}" + AND DEFINED SCI_QWT_INCLUDE AND EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") + add_library(Qwt::Qwt UNKNOWN IMPORTED) + set_target_properties(Qwt::Qwt PROPERTIES + IMPORTED_LOCATION "${SCI_QWT_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SCI_QWT_INCLUDE}" + ) + message(STATUS "[SCIRun] Created imported target Qwt::Qwt from SCI_QWT_* hints.") + endif() +endif() + # ---------- Build include list with guards to avoid stray '/include' ---------- set(_SCIRUN_INCLUDE_DIRS From 83a75c24977dcc71bb244ce24a862086aff4eeeb Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 3 Mar 2026 15:18:24 -0700 Subject: [PATCH 057/140] qwt build --- Superbuild/QwtExternal.cmake | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index 812c498a77..f3a8b538d6 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -24,7 +24,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# QwtExternal.cmake — build Qwt via the internal CMake wrapper (preferred over qmake) +# QwtExternal.cmake — build Qwt via the internal CMake wrapper (preferred over qmake) # ---------------------------- # Single place to pin wrapper tag @@ -59,37 +59,39 @@ endif() include(ExternalProject) +# Detect whether we're using a multi-config generator (e.g., Visual Studio) +get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_is_multi) + # Forward the native config placeholder (e.g., $(Configuration)) + set(_EP_CFG "${CMAKE_CFG_INTDIR}") +else() + # Single-config (e.g., Ninja/Unix Makefiles) → use CMAKE_BUILD_TYPE (may be empty = default) + if(CMAKE_BUILD_TYPE) + set(_EP_CFG "${CMAKE_BUILD_TYPE}") + else() + set(_EP_CFG ".") # no named config; the placeholder is '.' for single-config + endif() +endif() + ExternalProject_Add(Qwt_external - # -------------- - # Your internal wrapper repo (CMake-based) - # -------------- GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt-cmake-wrapper.git" GIT_TAG ${qwt_WRAPPER_GIT_TAG} GIT_SHALLOW 1 GIT_PROGRESS 1 - # NOTE: leave UPDATE_DISCONNECTED OFF for the first successful fetch. - # You can re-enable it later to avoid network hits on re-configures. - # UPDATE_DISCONNECTED 1 SOURCE_DIR ${_qwt_src} BINARY_DIR ${_qwt_bin} INSTALL_DIR ${_qwt_inst} - # ---------------------------- - # Configure the wrapper (it will fetch & build official Qwt inside) - # ---------------------------- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${_qwt_inst} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} # honored for single-config generators + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - # Pass Qt hints if provided: ${_qwt_extra_cmake_args} - # ---------------------------- - # MSVC/VS multi-config forwarding (Debug/Release safe) - # ---------------------------- - BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $,$,${CMAKE_BUILD_TYPE}> - INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config $,$,${CMAKE_BUILD_TYPE}> + # IMPORTANT: use the resolved _EP_CFG; for single-config '.' means "no switch" + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${_EP_CFG} + INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config ${_EP_CFG} LOG_DOWNLOAD 1 LOG_UPDATE 1 From f64bd7ecfecf8578348dd7f1cc6f91126330702f Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Mar 2026 11:13:54 -0700 Subject: [PATCH 058/140] Pin googletest submodule to v1.14.0 (replace missing ref 8565cc5...) --- src/Externals/submodules/googletest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Externals/submodules/googletest b/src/Externals/submodules/googletest index 8565cc529c..f8d7d77c06 160000 --- a/src/Externals/submodules/googletest +++ b/src/Externals/submodules/googletest @@ -1 +1 @@ -Subproject commit 8565cc529c36a226417713404d5782fb218d1369 +Subproject commit f8d7d77c06936315286eb55f8de22cd23c188571 From 2aa633a084e94d2827eeabec1c2c85663b2ce92e Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Mar 2026 13:54:50 -0700 Subject: [PATCH 059/140] boost exception --- .gitmodules | 2 +- Superbuild/QwtExternal.cmake | 9 +++++++-- Superbuild/Superbuild.cmake | 26 +++++++++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.gitmodules b/.gitmodules index b03a4cbe8a..8297bf73a9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/Externals/submodules/googletest"] path = src/Externals/submodules/googletest - url = https://github.com/CIBC-Internal/googletest.git + url = https://github.com/google/googletest.git diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index f3a8b538d6..6983ce3dda 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -76,8 +76,11 @@ endif() ExternalProject_Add(Qwt_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Qwt-cmake-wrapper.git" GIT_TAG ${qwt_WRAPPER_GIT_TAG} - GIT_SHALLOW 1 + + # Make cloning robust for pinned tags (turn off shallow during stabilization) + GIT_SHALLOW 0 # <-- changed from 1 to 0 GIT_PROGRESS 1 + GIT_SUBMODULES "" # explicit: no submodules SOURCE_DIR ${_qwt_src} BINARY_DIR ${_qwt_bin} @@ -89,7 +92,9 @@ ExternalProject_Add(Qwt_external -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${_qwt_extra_cmake_args} - # IMPORTANT: use the resolved _EP_CFG; for single-config '.' means "no switch" + # For pinned tags, skip update step entirely to avoid running git in a non-git tree + UPDATE_COMMAND "" # <-- added: prevents Qwt_external-gitupdate.cmake + BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${_EP_CFG} INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config ${_EP_CFG} diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 2258d65729..c068a4c6f8 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -713,19 +713,27 @@ if(DEFINED SQLite_INCLUDE_DIR) set(SQLite3_INCLUDE_DIR "${SQLite_INCLUDE_DIR}" CACHE PATH "Alias: SQLite3 include dir" FORCE) list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_INCLUDE_DIR:PATH=${SQLite3_INCLUDE_DIR}") endif() -# ---- Cleaver2 uppercase aliases + +# ---- Cleaver2 aliases (map to what inner expects) if(DEFINED Cleaver2_INCLUDE_DIR) + file(TO_CMAKE_PATH "${Cleaver2_INCLUDE_DIR}" _cleaver2_inc_norm) list(APPEND SCIRUN_CACHE_ARGS - "-DCLEAVER2_INCLUDE:PATH=${Cleaver2_INCLUDE_DIR}" - "-DCLEAVER2_INCLUDE_DIR:PATH=${Cleaver2_INCLUDE_DIR}" + "-DCLEAVER2_INCLUDE:PATH=${_cleaver2_inc_norm}" + "-DCLEAVER2_INCLUDE_DIR:PATH=${_cleaver2_inc_norm}" + "-DSCI_CLEAVER2_INCLUDE_DIR:PATH=${_cleaver2_inc_norm}" ) endif() + if(DEFINED Cleaver2_LIB_DIR) + file(TO_CMAKE_PATH "${Cleaver2_LIB_DIR}" _cleaver2_libdir_norm) list(APPEND SCIRUN_CACHE_ARGS - "-DCLEAVER2_LIBRARY_DIR:PATH=${Cleaver2_LIB_DIR}" - "-DCLEAVER2_LIB_DIR:PATH=${Cleaver2_LIB_DIR}" + "-DCLEAVER2_LIBRARY_DIR:PATH=${_cleaver2_libdir_norm}" # <-- REQUIRED by inner + "-DCLEAVER2_LIB_DIR:PATH=${_cleaver2_libdir_norm}" # keep existing alias + "-DSCI_CLEAVER2_LIBRARY_DIR:PATH=${_cleaver2_libdir_norm}" # legacy alias ) endif() + +# library name (import lib on Windows is cleaver2.lib) list(APPEND SCIRUN_CACHE_ARGS "-DCLEAVER2_LIBRARY:STRING=cleaver2") # --- Ensure SQLite hints are present AFTER base args --- @@ -940,6 +948,14 @@ function(_sb_scirun_wait_for) endif() endfunction() +# Force PDB serialization to avoid C1041 under MSVC +if(MSVC) + list(APPEND SCIRUN_CACHE_ARGS + "-DCMAKE_CXX_FLAGS:STRING=/EHsc /FS" + "-DCMAKE_C_FLAGS:STRING=/EHsc /FS" + ) +endif() + # ========================= # SCIRun ExternalProject # ========================= From 359021a91f4da1bd84676d83d0bc9600cbd6f40a Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Mar 2026 15:03:18 -0700 Subject: [PATCH 060/140] vc143.pdb conflicts --- Superbuild/Superbuild.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index c068a4c6f8..21c09c4363 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -948,8 +948,16 @@ function(_sb_scirun_wait_for) endif() endfunction() -# Force PDB serialization to avoid C1041 under MSVC +# --- MSVC: force Embedded debug info + exceptions + /FS, per-config --- if(MSVC) + # Force /Z7 for Debug and RelWithDebInfo so cl.exe writes symbols into .obj (no compile-time PDB contention) + list(APPEND SCIRUN_CACHE_ARGS + "-DCMAKE_CXX_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS" + "-DCMAKE_C_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS" + "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS" + "-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS" + ) + # (Optional) keep global flags too, but per-config is what really matters. list(APPEND SCIRUN_CACHE_ARGS "-DCMAKE_CXX_FLAGS:STRING=/EHsc /FS" "-DCMAKE_C_FLAGS:STRING=/EHsc /FS" From 2bef99c3cc81f727c937a830f0f703c629a8a118 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 5 Mar 2026 16:47:22 -0700 Subject: [PATCH 061/140] vc debug-release mismatch --- Superbuild/Superbuild.cmake | 21 ++++++++----- src/CMakeLists.txt | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 21c09c4363..be25b0bbe9 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -950,17 +950,22 @@ endfunction() # --- MSVC: force Embedded debug info + exceptions + /FS, per-config --- if(MSVC) - # Force /Z7 for Debug and RelWithDebInfo so cl.exe writes symbols into .obj (no compile-time PDB contention) + # Use the dynamic MSVC runtime (/MD for Release, /MDd for Debug), + # which matches Boost libs without the '-s' tag and with '-gd' in Debug. list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_CXX_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS" - "-DCMAKE_C_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS" - "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS" - "-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS" + "-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreadedDLL$<$:Debug>" ) - # (Optional) keep global flags too, but per-config is what really matters. + # Per-config flags list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_CXX_FLAGS:STRING=/EHsc /FS" - "-DCMAKE_C_FLAGS:STRING=/EHsc /FS" + "-DCMAKE_CXX_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" + "-DCMAKE_C_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" + "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" + "-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" + ) + # Global (keep if you want, but per-config is what usually matters) + list(APPEND SCIRUN_CACHE_ARGS + "-DCMAKE_CXX_FLAGS:STRING=/EHsc /FS /D BOOST_ALL_NO_LIB" + "-DCMAKE_C_FLAGS:STRING=/EHsc /FS /D BOOST_ALL_NO_LIB" ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cca974972b..278adae6de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -94,6 +94,68 @@ if(WIN32) endif() endif() +# We will discover Boost.Filesystem and Boost.System libraries and append them to SCI_BOOST_LIBRARY. +# This is required because BOOST_ALL_NO_LIB disables MSVC autolinking from Boost headers. +# (Filesystem is a separately compiled Boost lib and typically requires boost_system.) +# See: https://www.boost.org/doc/libs/release/libs/filesystem/ (needs linking) +# https://stackoverflow.com/a/19944824 (link boost_system too) + +if(WIN32 AND DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") + # Helper: pick first match from a list of patterns + function(_pick_first out_var) + set(_res "") + foreach(_pat IN LISTS ARGN) + file(GLOB _cands "${_pat}") + if(_cands) + list(SORT _cands) + list(GET _cands 0 _res) + break() + endif() + endforeach() + set(${out_var} "${_res}" PARENT_SCOPE) + endfunction() + + # Cover both '-' and '_' separators and version tags; choose first hit. + set(_fs_rel_pats + "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*-vc*-mt-x64-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_filesystem*.lib" + "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*.lib") + set(_fs_dbg_pats + "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*-vc*-mt-gd-x64-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_filesystem*-gd*.lib" + "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*-gd*.lib") + + set(_sys_rel_pats + "${SCI_BOOST_LIBRARY_DIR}/libboost_system*-vc*-mt-x64-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_system*.lib" + "${SCI_BOOST_LIBRARY_DIR}/libboost_system*.lib") + set(_sys_dbg_pats + "${SCI_BOOST_LIBRARY_DIR}/libboost_system*-vc*-mt-gd-x64-*.lib" + "${SCI_BOOST_LIBRARY_DIR}/boost_system*-gd*.lib" + "${SCI_BOOST_LIBRARY_DIR}/libboost_system*-gd*.lib") + + _pick_first(BOOST_FS_LIB_RELEASE ${_fs_rel_pats}) + _pick_first(BOOST_FS_LIB_DEBUG ${_fs_dbg_pats}) + _pick_first(BOOST_SYS_LIB_RELEASE ${_sys_rel_pats}) + _pick_first(BOOST_SYS_LIB_DEBUG ${_sys_dbg_pats}) + + # Append with config mapping so MSVC picks the right one + if(BOOST_FS_LIB_RELEASE OR BOOST_FS_LIB_DEBUG) + list(APPEND SCI_BOOST_LIBRARY + optimized ${BOOST_FS_LIB_RELEASE} debug ${BOOST_FS_LIB_DEBUG}) + endif() + if(BOOST_SYS_LIB_RELEASE OR BOOST_SYS_LIB_DEBUG) + list(APPEND SCI_BOOST_LIBRARY + optimized ${BOOST_SYS_LIB_RELEASE} debug ${BOOST_SYS_LIB_DEBUG}) + endif() + + # Keep in cache if you're caching this across subdirectories + set(SCI_BOOST_LIBRARY "${SCI_BOOST_LIBRARY}" CACHE STRING "Aggregate Boost libs" FORCE) + + message(STATUS "[SCIRun] Boost FS: rel='${BOOST_FS_LIB_RELEASE}' dbg='${BOOST_FS_LIB_DEBUG}'") + message(STATUS "[SCIRun] Boost SYS: rel='${BOOST_SYS_LIB_RELEASE}' dbg='${BOOST_SYS_LIB_DEBUG}'") +endif() + # -------------------------------------------------------------------- # Imported targets for Zlib and Teem (transitive wiring) # - Canonical name: ZLIB::ZLIB (provide Zlib::Zlib alias) From 97ba8fcb235812c3f4fa325e31c97bf3eb7af51a Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Mar 2026 11:25:36 -0700 Subject: [PATCH 062/140] release vs debug crt settings --- src/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 278adae6de..da87da398e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,10 +25,20 @@ # DEALINGS IN THE SOFTWARE. # -CMAKE_MINIMUM_REQUIRED(VERSION 3.9 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.15 FATAL_ERROR) PROJECT(SCIRun) +# Honor CMAKE_MSVC_RUNTIME_LIBRARY for VS generators +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) +endif() + +# Use proper CRT per configuration (Debug -> /MDd, others -> /MD) +if(MSVC) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") +endif() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) From 957ec5945848e9a5e114f7208f8eab22aded22ff Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 6 Mar 2026 14:56:45 -0700 Subject: [PATCH 063/140] qwt lib linking win32 macro def error --- Superbuild/Superbuild.cmake | 33 +-- src/CMakeLists.txt | 227 +++++++++++-------- src/Core/CommandLine/CMakeLists.txt | 3 +- src/Core/Logging/LoggerFwd.h | 2 +- src/Interface/Modules/Inverse/CMakeLists.txt | 5 +- src/Interface/Modules/Math/CMakeLists.txt | 7 +- src/Interface/Modules/Render/CMakeLists.txt | 5 +- 7 files changed, 158 insertions(+), 124 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index be25b0bbe9..0a013429ee 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -555,7 +555,6 @@ if(BUILD_WITH_PYTHON) "-DPython_FIND_STRATEGY:STRING=LOCATION" "-DPython_ROOT_DIR:PATH=${_PY_SRC}" "-DCMAKE_IGNORE_PREFIX_PATH:PATH=C:/Program Files/Python*;C:/Program Files (x86)/Python*" - "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" ) @@ -663,13 +662,12 @@ endif() if(TARGET Boost_external) list(APPEND SCIRUN_CACHE_ARGS - "-DBoost_DIR:PATH=${Boost_DIR}" - "-DBoost_ROOT:PATH=${SCI_BOOST_PREFIX}" - "-DBOOST_ROOT:PATH=${SCI_BOOST_PREFIX}" "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" - "-DBoost_INCLUDE_DIR:PATH=${SCI_BOOST_PREFIX}/include" - "-DBoost_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" - "-DBoost_NO_SYSTEM_PATHS:BOOL=ON" + "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" + # Optional: keep Boost_DIR if you want (SCIRun on Windows skips config mode anyway) + "-DBoost_DIR:PATH=${Boost_DIR}" + # Explicit linking strategy (Option B): inner CMake will add BOOST_ALL_NO_LIB + "-DSCIRUN_EXPLICIT_BOOST_LINK:BOOL=ON" ) endif() @@ -948,27 +946,6 @@ function(_sb_scirun_wait_for) endif() endfunction() -# --- MSVC: force Embedded debug info + exceptions + /FS, per-config --- -if(MSVC) - # Use the dynamic MSVC runtime (/MD for Release, /MDd for Debug), - # which matches Boost libs without the '-s' tag and with '-gd' in Debug. - list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreadedDLL$<$:Debug>" - ) - # Per-config flags - list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_CXX_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" - "-DCMAKE_C_FLAGS_DEBUG:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" - "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" - "-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/Z7 /EHsc /FS /D BOOST_ALL_NO_LIB" - ) - # Global (keep if you want, but per-config is what usually matters) - list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_CXX_FLAGS:STRING=/EHsc /FS /D BOOST_ALL_NO_LIB" - "-DCMAKE_C_FLAGS:STRING=/EHsc /FS /D BOOST_ALL_NO_LIB" - ) -endif() - # ========================= # SCIRun ExternalProject # ========================= diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da87da398e..bf2e781d11 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,13 +65,12 @@ message(STATUS "[SCIRun] Qt_PATH='${Qt_PATH}'") message(STATUS "[SCIRun] Boost_DIR='${Boost_DIR}' ; Boost_ROOT='${Boost_ROOT}' ; BOOST_ROOT='${BOOST_ROOT}' ; SCI_BOOST_PREFIX='${SCI_BOOST_PREFIX}'") message(STATUS "[SCIRun] ZLIB_ROOT='${ZLIB_ROOT}' ; ZLIB_DIR='${ZLIB_DIR}' ; ZLIB_INCLUDE_DIR='${ZLIB_INCLUDE_DIR}'") -# --- Boost (Windows-only: b2-built libs with MSVC auto-link) --- -# This expects the external Boost builder to have created: -# - ${SCI_BOOST_PREFIX}/include/boost/** (from `b2 headers` copy) -# - ${SCI_BOOST_PREFIX}/lib/libboost_*vc143*.lib (from b2 with --layout=versioned) -# -# It keeps auto-linking ON (do NOT define BOOST_ALL_NO_LIB here). -# It ensures the linker can find the versioned .lib names injected by Boost headers. +# --- Boost (Windows-only: b2-built libs from b2/--layout=versioned) --- +# If SCIRUN_EXPLICIT_BOOST_LINK=ON (from superbuild), we DISABLE MSVC autolink +# via BOOST_ALL_NO_LIB and link required Boost components explicitly. +if(SCIRUN_EXPLICIT_BOOST_LINK) + add_compile_definitions(BOOST_ALL_NO_LIB) +endif() if(WIN32) if(DEFINED SCI_BOOST_PREFIX) @@ -104,13 +103,13 @@ if(WIN32) endif() endif() -# We will discover Boost.Filesystem and Boost.System libraries and append them to SCI_BOOST_LIBRARY. -# This is required because BOOST_ALL_NO_LIB disables MSVC autolinking from Boost headers. -# (Filesystem is a separately compiled Boost lib and typically requires boost_system.) -# See: https://www.boost.org/doc/libs/release/libs/filesystem/ (needs linking) -# https://stackoverflow.com/a/19944824 (link boost_system too) +# -------------------------------------------------------------------- +# Boost explicit linking (Windows + SCIRUN_EXPLICIT_BOOST_LINK) +# - Collect concrete .lib files per component and append to SCI_BOOST_LIBRARY. +# - Handles Debug (-gd) and Release variants; falls back if one variant missing. +# -------------------------------------------------------------------- +if(SCIRUN_EXPLICIT_BOOST_LINK AND WIN32 AND DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") -if(WIN32 AND DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") # Helper: pick first match from a list of patterns function(_pick_first out_var) set(_res "") @@ -125,45 +124,60 @@ if(WIN32 AND DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY set(${out_var} "${_res}" PARENT_SCOPE) endfunction() - # Cover both '-' and '_' separators and version tags; choose first hit. - set(_fs_rel_pats - "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*-vc*-mt-x64-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_filesystem*.lib" - "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*.lib") - set(_fs_dbg_pats - "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*-vc*-mt-gd-x64-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_filesystem*-gd*.lib" - "${SCI_BOOST_LIBRARY_DIR}/libboost_filesystem*-gd*.lib") - - set(_sys_rel_pats - "${SCI_BOOST_LIBRARY_DIR}/libboost_system*-vc*-mt-x64-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_system*.lib" - "${SCI_BOOST_LIBRARY_DIR}/libboost_system*.lib") - set(_sys_dbg_pats - "${SCI_BOOST_LIBRARY_DIR}/libboost_system*-vc*-mt-gd-x64-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_system*-gd*.lib" - "${SCI_BOOST_LIBRARY_DIR}/libboost_system*-gd*.lib") - - _pick_first(BOOST_FS_LIB_RELEASE ${_fs_rel_pats}) - _pick_first(BOOST_FS_LIB_DEBUG ${_fs_dbg_pats}) - _pick_first(BOOST_SYS_LIB_RELEASE ${_sys_rel_pats}) - _pick_first(BOOST_SYS_LIB_DEBUG ${_sys_dbg_pats}) - - # Append with config mapping so MSVC picks the right one - if(BOOST_FS_LIB_RELEASE OR BOOST_FS_LIB_DEBUG) - list(APPEND SCI_BOOST_LIBRARY - optimized ${BOOST_FS_LIB_RELEASE} debug ${BOOST_FS_LIB_DEBUG}) - endif() - if(BOOST_SYS_LIB_RELEASE OR BOOST_SYS_LIB_DEBUG) + # Reset the aggregate to avoid duplicates across re-configures + set(SCI_BOOST_LIBRARY "" CACHE STRING "Aggregate Boost libs" FORCE) + + # ---- Generic component adder (release + debug) ---- + function(_boost_pick_component comp) + if(NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") + message(WARNING "[SCIRun] _boost_pick_component: SCI_BOOST_LIBRARY_DIR is invalid.") + return() + endif() + + # Release candidates (versioned names from b2 --layout=versioned) + set(_rel "") + _pick_first(_rel + "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*-vc*-mt-x64-*.lib" # preferred x64 MSVC layout + "${SCI_BOOST_LIBRARY_DIR}/boost_${comp}*.lib" # fallback + "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*.lib") # fallback + # Debug candidates (-gd) + set(_dbg "") + _pick_first(_dbg + "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*-vc*-mt-gd-x64-*.lib" # preferred x64 Debug + "${SCI_BOOST_LIBRARY_DIR}/boost_${comp}*-gd*.lib" + "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*-gd*.lib") + + if(NOT _rel AND NOT _dbg) + message(WARNING "[SCIRun] Boost component '${comp}' not found under '${SCI_BOOST_LIBRARY_DIR}'") + return() + endif() + + # If a variant is missing, fall back to the one we have + if(NOT _rel AND _dbg) + set(_rel "${_dbg}") + endif() + if(NOT _dbg AND _rel) + set(_dbg "${_rel}") + endif() + + # Append with config mapping so MSVC picks the right one list(APPEND SCI_BOOST_LIBRARY - optimized ${BOOST_SYS_LIB_RELEASE} debug ${BOOST_SYS_LIB_DEBUG}) - endif() + optimized "${_rel}" debug "${_dbg}") + + # Save to cache so subdirs see the updated list + set(SCI_BOOST_LIBRARY "${SCI_BOOST_LIBRARY}" CACHE STRING "Aggregate Boost libs" FORCE) + message(STATUS "[SCIRun] Boost ${comp}: rel='${_rel}' dbg='${_dbg}'") + endfunction() - # Keep in cache if you're caching this across subdirectories - set(SCI_BOOST_LIBRARY "${SCI_BOOST_LIBRARY}" CACHE STRING "Aggregate Boost libs" FORCE) + # ---- Pick all required components explicitly ---- + # Filesystem needs System; Thread usually needs System and Atomic. + _boost_pick_component(filesystem) + _boost_pick_component(system) + _boost_pick_component(program_options) + _boost_pick_component(thread) + _boost_pick_component(atomic) + _boost_pick_component(serialization) - message(STATUS "[SCIRun] Boost FS: rel='${BOOST_FS_LIB_RELEASE}' dbg='${BOOST_FS_LIB_DEBUG}'") - message(STATUS "[SCIRun] Boost SYS: rel='${BOOST_SYS_LIB_RELEASE}' dbg='${BOOST_SYS_LIB_DEBUG}'") endif() # -------------------------------------------------------------------- @@ -815,7 +829,11 @@ CONFIG_STANDARD_EXTERNAL(Cleaver2 # Boost — REQUIRED on non-Windows (prefer config package). # On Windows with b2-built Boost, skip CONFIG mode: rely on auto-link + link_directories above. if(WIN32) - message(STATUS "[SCIRun] Boost: using b2-built libraries with MSVC auto-link (no BoostConfig.cmake). Skipping CONFIG package discovery on Windows.") + if(SCIRUN_EXPLICIT_BOOST_LINK) + message(STATUS "[SCIRun] Boost: explicit component linking (BOOST_ALL_NO_LIB) with b2 versioned libs.") + else() + message(STATUS "[SCIRun] Boost: MSVC autolink enabled with b2 versioned libs.") + endif() else() CONFIG_STANDARD_EXTERNAL(Boost ROOT "${SCI_BOOST_PREFIX}" @@ -1308,56 +1326,87 @@ if(GLM_INCLUDE_DIR AND EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp") message(STATUS "GLM header OK: ${GLM_INCLUDE_DIR}/glm/glm.hpp") endif() -# ---- Qwt normalization + validation (place before _SCIRUN_INCLUDE_DIRS list) ---- +# ---- Qwt (STATIC) detection + imported target (place before _SCIRUN_INCLUDE_DIRS) ---- if(NOT BUILD_HEADLESS) - # 1) If a config package provided Qwt::Qwt, derive legacy SCI_QWT_INCLUDE from it - if(TARGET Qwt::Qwt) - get_target_property(_qwt_incs Qwt::Qwt INTERFACE_INCLUDE_DIRECTORIES) - set(_qwt_inc_ok "") - foreach(_inc IN LISTS _qwt_incs) - # Prefer the path that lets '#include ' work directly - if(EXISTS "${_inc}/qwt_plot.h") - set(_qwt_inc_ok "${_inc}") - break() - elseif(EXISTS "${_inc}/qwt/qwt_plot.h") - # If headers are under include/qwt, set the include root to that subdir - set(_qwt_inc_ok "${_inc}/qwt") - break() + # 1) Include dir: prefer install/include/qwt so '#include ' works directly + if(NOT DEFINED SCI_QWT_INCLUDE OR NOT EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") + if(DEFINED QWT_INSTALL_DIR AND EXISTS "${QWT_INSTALL_DIR}/include/qwt/qwt_plot.h") + set(SCI_QWT_INCLUDE "${QWT_INSTALL_DIR}/include/qwt" CACHE PATH "Qwt include dir" FORCE) + elseif(DEFINED QWT_INCLUDE_DIR) + if(EXISTS "${QWT_INCLUDE_DIR}/qwt/qwt_plot.h") + set(SCI_QWT_INCLUDE "${QWT_INCLUDE_DIR}/qwt" CACHE PATH "Qwt include dir" FORCE) + elseif(EXISTS "${QWT_INCLUDE_DIR}/qwt_plot.h") + set(SCI_QWT_INCLUDE "${QWT_INCLUDE_DIR}" CACHE PATH "Qwt include dir" FORCE) endif() - endforeach() - if(_qwt_inc_ok) - set(SCI_QWT_INCLUDE "${_qwt_inc_ok}" CACHE PATH "Qwt include dir (root for )" FORCE) - message(STATUS "[SCIRun] Qwt include dir set from target: ${SCI_QWT_INCLUDE}") + else() + # Probe from prefix path + foreach(_p IN LISTS CMAKE_PREFIX_PATH) + if(EXISTS "${_p}/include/qwt/qwt_plot.h") + set(SCI_QWT_INCLUDE "${_p}/include/qwt" CACHE PATH "Qwt include dir" FORCE) + break() + endif() + endforeach() endif() endif() - # 2) If no target or include yet, auto-derive from known install/prefix paths - if(NOT DEFINED SCI_QWT_INCLUDE OR NOT EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") - # If the superbuild exported QWT_INSTALL_DIR, prefer include/qwt under it - if(DEFINED QWT_INSTALL_DIR AND EXISTS "${QWT_INSTALL_DIR}/include/qwt/qwt_plot.h") - set(SCI_QWT_INCLUDE "${QWT_INSTALL_DIR}/include/qwt" CACHE PATH "Qwt include dir" FORCE) - message(STATUS "[SCIRun] Qwt include dir set from QWT_INSTALL_DIR: ${SCI_QWT_INCLUDE}") + # 2) Library dir (from superbuild) + locate static libs + if(NOT DEFINED QWT_LIBRARY_DIR AND DEFINED QWT_INSTALL_DIR) + if(EXISTS "${QWT_INSTALL_DIR}/lib64") + set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib64") else() - # Autoprobe from CMAKE_PREFIX_PATH: look for include/qwt/qwt_plot.h - _ensure_header(_QWT_INC_CAND "qwt/qwt_plot.h") - if(_QWT_INC_CAND AND EXISTS "${_QWT_INC_CAND}/qwt/qwt_plot.h") - set(SCI_QWT_INCLUDE "${_QWT_INC_CAND}/qwt" CACHE PATH "Qwt include dir" FORCE) - message(STATUS "[SCIRun] Qwt include dir auto-derived: ${SCI_QWT_INCLUDE}") - endif() - unset(_QWT_INC_CAND) + set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") endif() endif() - # 3) If still no imported target but we have legacy variables, synthesize Qwt::Qwt + set(_qwt_rel_lib "") + set(_qwt_dbg_lib "") + if(DEFINED QWT_LIBRARY_DIR AND IS_DIRECTORY "${QWT_LIBRARY_DIR}") + # Typical MSVC names for Qwt static (or single-config import lib when DLLs are absent) + file(GLOB _rel_cands "${QWT_LIBRARY_DIR}/qwt.lib" "${QWT_LIBRARY_DIR}/libqwt.lib") + file(GLOB _dbg_cands "${QWT_LIBRARY_DIR}/qwtd.lib" "${QWT_LIBRARY_DIR}/libqwtd.lib") + list(SORT _rel_cands) + list(SORT _dbg_cands) + list(GET _rel_cands 0 _qwt_rel_lib ERROR_QUIET) + list(GET _dbg_cands 0 _qwt_dbg_lib ERROR_QUIET) + + # If only one variant exists, use it for both configs (common in static-only installs) + if(NOT _qwt_rel_lib AND _qwt_dbg_lib) + set(_qwt_rel_lib "${_qwt_dbg_lib}") + endif() + if(NOT _qwt_dbg_lib AND _qwt_rel_lib) + set(_qwt_dbg_lib "${_qwt_rel_lib}") + endif() + endif() + + # 3) Imported STATIC target (preferred) if(NOT TARGET Qwt::Qwt - AND DEFINED SCI_QWT_LIBRARY AND EXISTS "${SCI_QWT_LIBRARY}" + AND ( _qwt_rel_lib OR _qwt_dbg_lib ) AND DEFINED SCI_QWT_INCLUDE AND EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") - add_library(Qwt::Qwt UNKNOWN IMPORTED) - set_target_properties(Qwt::Qwt PROPERTIES - IMPORTED_LOCATION "${SCI_QWT_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SCI_QWT_INCLUDE}" - ) - message(STATUS "[SCIRun] Created imported target Qwt::Qwt from SCI_QWT_* hints.") + + add_library(Qwt::Qwt STATIC IMPORTED) + set_property(TARGET Qwt::Qwt PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SCI_QWT_INCLUDE}") + if(_qwt_rel_lib) + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${_qwt_rel_lib}") + endif() + if(_qwt_dbg_lib) + set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${_qwt_dbg_lib}") + endif() + + # Consumers of static Qwt: do NOT define QWT_DLL; define QWT_STATIC if Qwt headers look for it. + target_compile_definitions(Qwt::Qwt INTERFACE QWT_STATIC) + + message(STATUS "[SCIRun] Qwt::Qwt (static): rel='${_qwt_rel_lib}', dbg='${_qwt_dbg_lib}', inc='${SCI_QWT_INCLUDE}'") + endif() + + # 4) Legacy variable for modules that still link ${SCI_QWT_LIBRARY} + # Provide an optimized/debug list mapped to the same static libraries. + set(SCI_QWT_LIBRARY "" CACHE STRING "Qwt libraries (optimized/debug)" FORCE) + if(_qwt_rel_lib OR _qwt_dbg_lib) + set(_pair "") + if(_qwt_rel_lib) list(APPEND _pair optimized "${_qwt_rel_lib}") endif() + if(_qwt_dbg_lib) list(APPEND _pair debug "${_qwt_dbg_lib}") endif() + set(SCI_QWT_LIBRARY "${_pair}" CACHE STRING "Qwt libraries (optimized/debug)" FORCE) + unset(_pair) endif() endif() diff --git a/src/Core/CommandLine/CMakeLists.txt b/src/Core/CommandLine/CMakeLists.txt index 31af8bf871..b85afba336 100644 --- a/src/Core/CommandLine/CMakeLists.txt +++ b/src/Core/CommandLine/CMakeLists.txt @@ -41,7 +41,8 @@ SCIRUN_ADD_LIBRARY(Core_CommandLine ) TARGET_LINK_LIBRARIES(Core_CommandLine - ${SCI_BOOST_LIBRARY} + PRIVATE + ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Logging/LoggerFwd.h b/src/Core/Logging/LoggerFwd.h index 98e75aa5e7..45b9d21f4c 100644 --- a/src/Core/Logging/LoggerFwd.h +++ b/src/Core/Logging/LoggerFwd.h @@ -50,7 +50,7 @@ namespace SCIRun } } -#ifdef WIN32 +#ifdef _WIN32 #define LOG_FUNC __FUNCSIG__ #else #define LOG_FUNC __PRETTY_FUNCTION__ diff --git a/src/Interface/Modules/Inverse/CMakeLists.txt b/src/Interface/Modules/Inverse/CMakeLists.txt index 40edb4281c..6c6455e743 100644 --- a/src/Interface/Modules/Inverse/CMakeLists.txt +++ b/src/Interface/Modules/Inverse/CMakeLists.txt @@ -60,9 +60,12 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Inverse Interface_Modules_Base ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} - ${SCI_QWT_LIBRARY} + Qwt::Qwt + #${SCI_QWT_LIBRARY} ) +add_compile_definitions(QWT_STATIC) + IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Interface_Modules_Inverse) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Interface/Modules/Math/CMakeLists.txt b/src/Interface/Modules/Math/CMakeLists.txt index 8e15fe9dd0..43a892022f 100644 --- a/src/Interface/Modules/Math/CMakeLists.txt +++ b/src/Interface/Modules/Math/CMakeLists.txt @@ -135,11 +135,12 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Math Interface_Modules_Base ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} - ${SCI_QWT_LIBRARY} + Qwt::Qwt + #${SCI_QWT_LIBRARY} ) - -ADD_DEFINITIONS(-DQWT_DLL) +add_compile_definitions(QWT_STATIC) +#ADD_DEFINITIONS(-DQWT_DLL) IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Interface_Modules_Math) diff --git a/src/Interface/Modules/Render/CMakeLists.txt b/src/Interface/Modules/Render/CMakeLists.txt index 449c718938..0800d51462 100644 --- a/src/Interface/Modules/Render/CMakeLists.txt +++ b/src/Interface/Modules/Render/CMakeLists.txt @@ -139,9 +139,12 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render ${SCI_FREETYPE_LIBRARY} ${SCI_LODEPNG_LIBRARY} ${SCI_TNY_LIBRARY} - ${SCI_QWT_LIBRARY} + Qwt::Qwt + #${SCI_QWT_LIBRARY} ) +add_compile_definitions(QWT_STATIC) + TARGET_LINK_LIBRARIES(Interface_Modules_Render ${QT_GRAPHICS_LIBRARIES}) IF(BUILD_SHARED_LIBS) From d35e377157590033931d1d4f1d1b00c76b0b2136 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 9 Mar 2026 13:10:20 -0600 Subject: [PATCH 064/140] updated tetgen call to 1.6 signature added boost python to lib list --- src/CMakeLists.txt | 30 +++++++++++++++---- .../Legacy/Fields/InterfaceWithTetGenImpl.cc | 20 +++++++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf2e781d11..4f9e38f2d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -178,6 +178,14 @@ if(SCIRUN_EXPLICIT_BOOST_LINK AND WIN32 AND DEFINED SCI_BOOST_LIBRARY_DIR AND IS _boost_pick_component(atomic) _boost_pick_component(serialization) + # Construct the versioned Boost.Python component name: python313 for Python 3.13 + set(_py_comp "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") + + # Try the versioned component first (common with b2 builds), then fall back to unversioned "python" + # We call _boost_pick_component on both; the function tolerates missing libs and will warn if not found. + _boost_pick_component("${_py_comp}") + _boost_pick_component("python") + endif() # -------------------------------------------------------------------- @@ -1364,10 +1372,16 @@ if(NOT BUILD_HEADLESS) # Typical MSVC names for Qwt static (or single-config import lib when DLLs are absent) file(GLOB _rel_cands "${QWT_LIBRARY_DIR}/qwt.lib" "${QWT_LIBRARY_DIR}/libqwt.lib") file(GLOB _dbg_cands "${QWT_LIBRARY_DIR}/qwtd.lib" "${QWT_LIBRARY_DIR}/libqwtd.lib") - list(SORT _rel_cands) - list(SORT _dbg_cands) - list(GET _rel_cands 0 _qwt_rel_lib ERROR_QUIET) - list(GET _dbg_cands 0 _qwt_dbg_lib ERROR_QUIET) + + if(_rel_cands) + list(SORT _rel_cands) + list(GET _rel_cands 0 _qwt_rel_lib) # safe: list is non-empty + endif() + + if(_dbg_cands) + list(SORT _dbg_cands) + list(GET _dbg_cands 0 _qwt_dbg_lib) # safe: list is non-empty + endif() # If only one variant exists, use it for both configs (common in static-only installs) if(NOT _qwt_rel_lib AND _qwt_dbg_lib) @@ -1403,8 +1417,12 @@ if(NOT BUILD_HEADLESS) set(SCI_QWT_LIBRARY "" CACHE STRING "Qwt libraries (optimized/debug)" FORCE) if(_qwt_rel_lib OR _qwt_dbg_lib) set(_pair "") - if(_qwt_rel_lib) list(APPEND _pair optimized "${_qwt_rel_lib}") endif() - if(_qwt_dbg_lib) list(APPEND _pair debug "${_qwt_dbg_lib}") endif() + if(_qwt_rel_lib) + list(APPEND _pair optimized "${_qwt_rel_lib}") + endif() + if(_qwt_dbg_lib) + list(APPEND _pair debug "${_qwt_dbg_lib}") + endif() set(SCI_QWT_LIBRARY "${_pair}" CACHE STRING "Qwt libraries (optimized/debug)" FORCE) unset(_pair) endif() diff --git a/src/Modules/Legacy/Fields/InterfaceWithTetGenImpl.cc b/src/Modules/Legacy/Fields/InterfaceWithTetGenImpl.cc index 13240f72e8..7e4a7793b3 100644 --- a/src/Modules/Legacy/Fields/InterfaceWithTetGenImpl.cc +++ b/src/Modules/Legacy/Fields/InterfaceWithTetGenImpl.cc @@ -47,6 +47,8 @@ #include #include +#include +#include #include @@ -323,9 +325,23 @@ FieldHandle detail::InterfaceWithTetGenImplImpl::runImpl(const std::deque(cmmd_ln.c_str()), &in, &out, addtgio); + // --- TetGen 1.6+ behavior-based API --- + tetgenbehavior b; + + // parse_commandline expects a mutable C string; copy cmmd_ln. + std::string opts = cmmd_ln; // cmmd_ln is your existing switches string + std::vector buf(opts.begin(), opts.end()); + buf.push_back('\0'); // NUL-terminate + + b.parse_commandline(buf.data()); + + // Map old call: + // tetrahedralize(char* switches, &in, &out, addtgio); + // to new signature: + // tetrahedralize(tetgenbehavior*, &in, &out, addin, bgmmesh); + tetrahedralize(&b, &in, &out, addtgio, nullptr); } - catch(std::exception& e) + catch (std::exception& e) { module_->error(std::string("TetGen failed to generate a mesh: ") + e.what()); return nullptr; From 1ca8c0a278d56562a3123fc24a1aaf10ee8d3f04 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 9 Mar 2026 16:17:20 -0600 Subject: [PATCH 065/140] glew and tny missing --- Superbuild/GLEWConfig.cmake.in | 17 +++++ Superbuild/Superbuild.cmake | 40 ++++++++++ Superbuild/TnyConfig.cmake.in | 16 ++++ Superbuild/TnyExternal.cmake | 84 ++++++++++++++++++--- Superbuild/TnyWriteConfig.cmake | 4 + src/CMakeLists.txt | 17 +++-- src/Externals/spire/CMakeLists.txt | 5 +- src/Graphics/Glyphs/CMakeLists.txt | 1 + src/Graphics/Widgets/CMakeLists.txt | 1 + src/Interface/Modules/Render/CMakeLists.txt | 3 +- src/Modules/Fields/CMakeLists.txt | 1 + 11 files changed, 167 insertions(+), 22 deletions(-) create mode 100644 Superbuild/GLEWConfig.cmake.in create mode 100644 Superbuild/TnyConfig.cmake.in create mode 100644 Superbuild/TnyWriteConfig.cmake diff --git a/Superbuild/GLEWConfig.cmake.in b/Superbuild/GLEWConfig.cmake.in new file mode 100644 index 0000000000..6ad878ba1d --- /dev/null +++ b/Superbuild/GLEWConfig.cmake.in @@ -0,0 +1,17 @@ +# Auto‑generated GLEWConfig.cmake for SCIRun superbuild +# This is a STATIC GLEW build + +if(NOT TARGET GLEW::GLEW) + add_library(GLEW::GLEW STATIC IMPORTED) + + set_target_properties(GLEW::GLEW PROPERTIES + IMPORTED_LOCATION "@GLEW_LIB@" # expands to Path/lib/glew.lib + INTERFACE_INCLUDE_DIRECTORIES "@GLEW_INC@" # expands to Path/include + INTERFACE_COMPILE_DEFINITIONS "GLEW_STATIC" # static GLEW requires this + ) +endif() + +set(GLEW_FOUND TRUE) +set(GLEW_INCLUDE_DIR "@GLEW_INC@") +set(GLEW_LIBRARY "@GLEW_LIB@") +set(GLEW_LIBRARIES "@GLEW_LIB@") \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 0a013429ee..b8f31ebfff 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -455,6 +455,42 @@ if(WIN32 AND TARGET Glew_external) _sb_export_inc_lib(GLEW Glew_external) endif() +# --- Install custom GLEWConfig.cmake for SCIRun --- +if(WIN32 AND TARGET Glew_external) + ExternalProject_Get_Property(Glew_external INSTALL_DIR) + + set(_glew_inc "${INSTALL_DIR}/include") + set(_glew_lib "") + + # Choose lib folder + if(EXISTS "${INSTALL_DIR}/lib/glew.lib") + set(_glew_lib "${INSTALL_DIR}/lib/glew.lib") + elseif(EXISTS "${INSTALL_DIR}/lib64/glew.lib") + set(_glew_lib "${INSTALL_DIR}/lib64/glew.lib") + else() + message(FATAL_ERROR "[superbuild] Could not find glew.lib in Glew_external install.") + endif() + + # Where to place the config + set(_glew_cfg_dir "${INSTALL_DIR}/lib/cmake/GLEW") + file(MAKE_DIRECTORY "${_glew_cfg_dir}") + + # Configure the exported CMake config file + configure_file( + "${SUPERBUILD_DIR}/GLEWConfig.cmake.in" + "${_glew_cfg_dir}/GLEWConfig.cmake" + @ONLY + ) + + message(STATUS "[superbuild] Installed custom GLEWConfig.cmake at ${_glew_cfg_dir}") +endif() + +# Tell SCIRun where the Tny config lives +if(TARGET Tny_wrapper_external) + set(_TNY_CFG_DIR "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/lib/cmake/Tny") + list(APPEND SCIRUN_CACHE_ARGS "-DTny_DIR:PATH=${_TNY_CFG_DIR}") +endif() + # ========================= # Build SCIRun cache args (APPEND, do not reset) # ========================= @@ -485,6 +521,10 @@ list(APPEND SCIRUN_CACHE_ARGS "-DQt_PATH:PATH=${Qt_PATH}" ) +if(WIN32 AND TARGET Glew_external) + list(APPEND SCIRUN_CACHE_ARGS "-DGLEW_DIR:PATH=${_glew_cfg_dir}") +endif() + # ========================= # Forward Python values to SCIRun (inner CMake), version-agnostic & robust # ========================= diff --git a/Superbuild/TnyConfig.cmake.in b/Superbuild/TnyConfig.cmake.in new file mode 100644 index 0000000000..ff07ea90fd --- /dev/null +++ b/Superbuild/TnyConfig.cmake.in @@ -0,0 +1,16 @@ +# Auto-generated by SCIRun superbuild +# Provides an imported target Tny::tny (STATIC) + +if(NOT TARGET Tny::tny) + add_library(Tny::tny STATIC IMPORTED) + set_target_properties(Tny::tny PROPERTIES + IMPORTED_LOCATION "@TNY_LIB@" # absolute path to tny(.lib/.a) + INTERFACE_INCLUDE_DIRECTORIES "@TNY_INC@" # absolute path to include root (contains tny/tny.h) + ) +endif() + +# Legacy variables for consumers that don't use targets +set(Tny_FOUND TRUE) +set(TNY_INCLUDE_DIR "@TNY_INC@") +set(TNY_LIBRARY "@TNY_LIB@") +set(TNY_LIBRARIES "@TNY_LIB@") \ No newline at end of file diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index abc5b29573..9fdc3924e2 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -24,34 +24,94 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# TnyExternal.cmake +# TnyExternal.cmake (updated) + set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -# Superbuild directories (match your pattern—optional but helps clarity) +# Final install prefix for Tny artifacts set(_tny_inst "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external") +# 1) Fetch upstream Tny (no configure/build/install here) ExternalProject_Add(Tny_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Tny.git" GIT_TAG "origin/master" - PATCH_COMMAND "" + UPDATE_DISCONNECTED 1 CONFIGURE_COMMAND "" BUILD_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + LOG_UPDATE 1 +) + +ExternalProject_Get_Property(Tny_external SOURCE_DIR) + +# 2) Copy headers (your existing step) +# Place them under /include/tny/ so #include works +ExternalProject_Add_Step(Tny_external copy_headers + COMMAND ${CMAKE_COMMAND} -E make_directory ${_tny_inst}/include/tny + COMMAND ${CMAKE_COMMAND} -Dsrc=${SOURCE_DIR}/src/tny -Ddst=${_tny_inst}/include/tny + -P ${CMAKE_CURRENT_LIST_DIR}/TnyInstall.cmake + DEPENDEES download + DEPENDERS build + COMMENT "[Tny_external] Copying headers" +) - # Run the script to create the dir and copy headers - INSTALL_COMMAND - ${CMAKE_COMMAND} - -Dsrc=/src/tny - -Ddst=${_tny_inst}/include/tny - -P ${CMAKE_CURRENT_LIST_DIR}/TnyInstall.cmake +# 3) Build a small static library from tny.c using CMake -E cmake_script +# We create a build.ninja/msbuild generator-less compile via a one-off CMake configure+build +set(_tny_build_dir "${CMAKE_BINARY_DIR}/Externals/Build/Tny_wrapper") +file(MAKE_DIRECTORY "${_tny_build_dir}") +# Generate a minimal CMakeLists.txt for building the library +file(WRITE "${_tny_build_dir}/CMakeLists.txt" " +cmake_minimum_required(VERSION 3.16) +project(tny_wrapper C) +add_library(tny STATIC \"${SOURCE_DIR}/src/tny/tny.c\") +target_include_directories(tny PUBLIC \"${_tny_inst}/include\") +if(MSVC) + set_target_properties(tny PROPERTIES DEBUG_POSTFIX d) +endif() +install(TARGETS tny + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) +") + +# Configure & build the wrapper, then install to _tny_inst +ExternalProject_Add(Tny_wrapper_external + SOURCE_DIR "${_tny_build_dir}" + BINARY_DIR "${_tny_build_dir}/_build" + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX:PATH=${_tny_inst} + -DCMAKE_BUILD_TYPE:STRING=$,Debug,Release> + BUILD_ALWAYS 1 + INSTALL_COMMAND ${CMAKE_COMMAND} --build --target install + DEPENDS Tny_external LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Export variables for SCIRun consumption -ExternalProject_Get_Property(Tny_external SOURCE_DIR) -set(TNY_SOURCE_DIR "${SOURCE_DIR}") +# 4) Install a proper TnyConfig.cmake for find_package(Tny CONFIG) +add_custom_target(Tny_export ALL + COMMAND ${CMAKE_COMMAND} -E make_directory ${_tny_inst}/lib/cmake/Tny + COMMAND ${CMAKE_COMMAND} + -DTNY_INC:PATH=${_tny_inst}/include + -DTNY_LIB:PATH=${_tny_inst}/lib/$,tnyd.lib,tny.lib> + -P ${CMAKE_CURRENT_LIST_DIR}/TnyWriteConfig.cmake + DEPENDS Tny_wrapper_external + COMMENT "[Tny_external] Writing TnyConfig.cmake" +) + +# Helper script to expand the @ONLY template with the correct lib for the current config +file(WRITE "${CMAKE_CURRENT_LIST_DIR}/TnyWriteConfig.cmake" " +set(_cfg_dir \"${_tny_inst}/lib/cmake/Tny\") +file(MAKE_DIRECTORY \"\${_cfg_dir}\") +configure_file(\"${SUPERBUILD_DIR}/TnyConfig.cmake.in\" \"\${_cfg_dir}/TnyConfig.cmake\" @ONLY) +") + +# Export paths for downstream (SCIRun) set(TNY_INSTALL_DIR "${_tny_inst}") set(TNY_INCLUDE "${TNY_INSTALL_DIR}/include") +set(TNY_LIBRARY_DIR "${TNY_INSTALL_DIR}/lib") message(STATUS "[Tny_external] INSTALL_DIR=${TNY_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/TnyWriteConfig.cmake b/Superbuild/TnyWriteConfig.cmake new file mode 100644 index 0000000000..c6093e1c77 --- /dev/null +++ b/Superbuild/TnyWriteConfig.cmake @@ -0,0 +1,4 @@ + +set(_cfg_dir "C:/Users/Yong/Documents/SCIRun/build/Externals/Install/Tny_external/lib/cmake/Tny") +file(MAKE_DIRECTORY "${_cfg_dir}") +configure_file("C:/Users/Yong/Documents/SCIRun/Superbuild/TnyConfig.cmake.in" "${_cfg_dir}/TnyConfig.cmake" @ONLY) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f9e38f2d0..f9a7f9db81 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -899,12 +899,12 @@ if(WITH_TETGEN) endif() # GLEW (Windows) -if(WIN32) - CONFIG_STANDARD_EXTERNAL(GLEW - DIR "${GLEW_DIR}" - CFGS "GLEWConfig.cmake;GlewConfig.cmake" - ) -endif() +#if(WIN32) +# CONFIG_STANDARD_EXTERNAL(GLEW +# DIR "${GLEW_DIR}" +# CFGS "GLEWConfig.cmake;GlewConfig.cmake" +# ) +#endif() # Qwt (unless headless) - prefer config packages and fail (outside superbuild) if missing if(NOT BUILD_HEADLESS) @@ -1211,7 +1211,10 @@ endfunction() _ensure_header(GLEW_INCLUDE_DIR "GL/glew.h") _ensure_header(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") _ensure_header(SQLite3_INCLUDE_DIR "sqlite3.h") -_ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") +_ensure_header(TNY_INCLUDE_DIR "tny/tny.h") +if(NOT TNY_INCLUDE_DIR) + _ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") +endif() _ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") _ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") _ensure_header(SCI_TEEM_INCLUDE "teem/ten.h") diff --git a/src/Externals/spire/CMakeLists.txt b/src/Externals/spire/CMakeLists.txt index 31f0b31dd9..19f60102cf 100644 --- a/src/Externals/spire/CMakeLists.txt +++ b/src/Externals/spire/CMakeLists.txt @@ -219,8 +219,9 @@ ADD_LIBRARY ( ${SCI_SPIRE_LIBRARY} target_link_libraries(${SCI_SPIRE_LIBRARY} ${SCI_LODEPNG_LIBRARY} - ${SCI_TNY_LIBRARY} - ${OPENGL_LIBRARIES}) + Tny::tny + ${OPENGL_LIBRARIES} + GLEW::GLEW) IF(WIN32) target_link_libraries(${SCI_SPIRE_LIBRARY} ${SCI_GLEW_LIBRARY}) diff --git a/src/Graphics/Glyphs/CMakeLists.txt b/src/Graphics/Glyphs/CMakeLists.txt index 249c706162..e2bd64d91b 100644 --- a/src/Graphics/Glyphs/CMakeLists.txt +++ b/src/Graphics/Glyphs/CMakeLists.txt @@ -55,6 +55,7 @@ TARGET_LINK_LIBRARIES(Graphics_Glyphs Core_Utils Graphics_Datatypes ${OPENGL_LIBRARIES} + GLEW::GLEW ${SCI_SPIRE_LIBRARY} ${SCI_BOOST_LIBRARY} ) diff --git a/src/Graphics/Widgets/CMakeLists.txt b/src/Graphics/Widgets/CMakeLists.txt index 5b446941b3..2269d12051 100644 --- a/src/Graphics/Widgets/CMakeLists.txt +++ b/src/Graphics/Widgets/CMakeLists.txt @@ -69,6 +69,7 @@ TARGET_LINK_LIBRARIES(Graphics_Widgets Graphics_Glyphs Graphics_Datatypes ${OPENGL_LIBRARIES} + GLEW::GLEW ${SCI_BOOST_LIBRARY} ) diff --git a/src/Interface/Modules/Render/CMakeLists.txt b/src/Interface/Modules/Render/CMakeLists.txt index 0800d51462..aeee522b08 100644 --- a/src/Interface/Modules/Render/CMakeLists.txt +++ b/src/Interface/Modules/Render/CMakeLists.txt @@ -132,13 +132,14 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render Core_Application_Preferences Core_Application ${OPENGL_LIBRARIES} + GLEW::GLEW ${QT_OPENGL_LIBRARY} ${SCI_SPIRE_LIBRARY} ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ${SCI_FREETYPE_LIBRARY} ${SCI_LODEPNG_LIBRARY} - ${SCI_TNY_LIBRARY} + Tny::tny Qwt::Qwt #${SCI_QWT_LIBRARY} ) diff --git a/src/Modules/Fields/CMakeLists.txt b/src/Modules/Fields/CMakeLists.txt index c2e625d62a..854abacd30 100644 --- a/src/Modules/Fields/CMakeLists.txt +++ b/src/Modules/Fields/CMakeLists.txt @@ -60,6 +60,7 @@ TARGET_LINK_LIBRARIES(Modules_Fields Graphics_Datatypes Graphics_Widgets ${OPENGL_LIBRARIES} + GLEW::GLEW ) IF(BUILD_SHARED_LIBS) From 66757701acd9ba2058b3879418e4ab3ccb458e44 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 9 Mar 2026 16:36:46 -0600 Subject: [PATCH 066/140] glew not found --- Superbuild/GlewExternal.cmake | 54 +++++++++++++++++++------------- Superbuild/GlewWriteConfig.cmake | 3 ++ Superbuild/Superbuild.cmake | 4 ++- src/CMakeLists.txt | 48 +++++++++++++++++++++++----- 4 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 Superbuild/GlewWriteConfig.cmake diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index 3e89249d8b..51a1fc6403 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -33,6 +33,8 @@ set(glew_GIT_TAG "v1.0.1") set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DBUILD_SHARED_LIBS=OFF # ensure static + -DGLEW_USE_STATIC_LIBS=ON # if your fork honors this # Redirect all outputs so install step is unnecessary for libs -DCMAKE_INSTALL_PREFIX= @@ -72,32 +74,19 @@ ExternalProject_Add(Glew_external CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" CMAKE_ARGS ${_cmake_args} - - # We skip 'install' to keep the fast redirect flow for libs - INSTALL_COMMAND "" - - # After build, ensure headers are available in /include - # (glew's headers live in /include) - BUILD_BYPRODUCTS - "/lib" # helps order-only deps - - # Add a step to copy headers into Install prefix - # (idempotent; safe for multi-config) - STEP_TARGETS copy_headers - COMMAND ${CMAKE_COMMAND} -E make_directory "/include" - COMMAND ${CMAKE_COMMAND} -E copy_directory "${_glew_src}/include" "/include" + INSTALL_COMMAND "" # we redirect outputs LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 ) -# Tie the header copy to the build -add_custom_command(TARGET Glew_external - POST_BUILD +# Copy headers after build (idempotent) +ExternalProject_Add_Step(Glew_external copy_headers COMMAND ${CMAKE_COMMAND} -E make_directory "${_glew_inst}/include" COMMAND ${CMAKE_COMMAND} -E copy_directory "${_glew_src}/include" "${_glew_inst}/include" - COMMENT "Copying GLEW headers to ${_glew_inst}/include" + DEPENDEES build + COMMENT "[Glew_external] Copying GLEW headers to ${_glew_inst}/include" ) # Export variables for SCIRun @@ -106,8 +95,31 @@ set(GLEW_INSTALL_DIR ${_glew_inst}) set(GLEW_INCLUDE ${GLEW_INSTALL_DIR}/include) set(GLEW_LIBRARY_DIR ${GLEW_INSTALL_DIR}/lib) -# Library name on Windows built with CMake is typically 'glew' or 'glew32'. -# If you’ve standardized your export to 'glew', keep it: -set(GLEW_LIBRARY "glew") +# Pick the actual lib name produced +set(_glew_lib "") +if(EXISTS "${GLEW_LIBRARY_DIR}/glew.lib") + set(_glew_lib "${GLEW_LIBRARY_DIR}/glew.lib") +elseif(EXISTS "${GLEW_LIBRARY_DIR}/glew32s.lib") + set(_glew_lib "${GLEW_LIBRARY_DIR}/glew32s.lib") +elseif(EXISTS "${GLEW_LIBRARY_DIR}/glew32.lib") + set(_glew_lib "${GLEW_LIBRARY_DIR}/glew32.lib") +endif() + +# Generate a config package for GLEW so SCIRun can find GLEW::GLEW deterministically +add_custom_target(Glew_export ALL + COMMAND ${CMAKE_COMMAND} -E make_directory "${GLEW_INSTALL_DIR}/lib/cmake/GLEW" + COMMAND ${CMAKE_COMMAND} + -D GLEW_INC:PATH="${GLEW_INCLUDE}" + -D GLEW_LIB:PATH="${_glew_lib}" + -P "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" + DEPENDS Glew_external copy_headers + COMMENT "[Glew_external] Writing GLEWConfig.cmake" +) + +# Helper script to expand template @ONLY +file(WRITE "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" " + configure_file(\"${SUPERBUILD_DIR}/cmake/GLEWConfig.cmake.in\" + \"${GLEW_INSTALL_DIR}/lib/cmake/GLEW/GLEWConfig.cmake\" @ONLY) +") message(STATUS "[Glew_external] INSTALL_DIR=${GLEW_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/GlewWriteConfig.cmake b/Superbuild/GlewWriteConfig.cmake new file mode 100644 index 0000000000..cf86a3e605 --- /dev/null +++ b/Superbuild/GlewWriteConfig.cmake @@ -0,0 +1,3 @@ + + configure_file("C:/Users/Yong/Documents/SCIRun/Superbuild/cmake/GLEWConfig.cmake.in" + "C:/Users/Yong/Documents/SCIRun/build/Externals/Install/Glew_external/lib/cmake/GLEW/GLEWConfig.cmake" @ONLY) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index b8f31ebfff..c0f678db99 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -521,8 +521,10 @@ list(APPEND SCIRUN_CACHE_ARGS "-DQt_PATH:PATH=${Qt_PATH}" ) +# Tell SCIRun where to find GLEW config if(WIN32 AND TARGET Glew_external) - list(APPEND SCIRUN_CACHE_ARGS "-DGLEW_DIR:PATH=${_glew_cfg_dir}") + ExternalProject_Get_Property(Glew_external INSTALL_DIR) + list(APPEND SCIRUN_CACHE_ARGS "-DGLEW_DIR:PATH=${INSTALL_DIR}/lib/cmake/GLEW") endif() # ========================= diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9a7f9db81..596a12838a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -899,12 +899,12 @@ if(WITH_TETGEN) endif() # GLEW (Windows) -#if(WIN32) -# CONFIG_STANDARD_EXTERNAL(GLEW -# DIR "${GLEW_DIR}" -# CFGS "GLEWConfig.cmake;GlewConfig.cmake" -# ) -#endif() +if(WIN32) + CONFIG_STANDARD_EXTERNAL(GLEW + DIR "${GLEW_DIR}" + CFGS "GLEWConfig.cmake;GlewConfig.cmake" + ) +endif() # Qwt (unless headless) - prefer config packages and fail (outside superbuild) if missing if(NOT BUILD_HEADLESS) @@ -1208,7 +1208,41 @@ endfunction() # Tny: tny/tny.hpp # Spdlog: spdlog/spdlog.h # GLM: glm/glm.hpp -_ensure_header(GLEW_INCLUDE_DIR "GL/glew.h") +# If the package created the imported target, prefer it and sync the include var +# --- GLEW include discovery (target-first, robust fallback) --- +set(_SCIRUN_USE_GLEW_TARGET FALSE) +set(_glew_inc_from_target "") + +# 1) If the package created GLEW::GLEW, prefer its include path +if(TARGET GLEW::GLEW) + get_target_property(_glew_inc_from_target GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES) + if(_glew_inc_from_target) + list(GET _glew_inc_from_target 0 _glew_inc_from_target) # first entry if it's a list + endif() +endif() + +# 2) If the target had a valid include and the header exists there, use it +if(_glew_inc_from_target AND EXISTS "${_glew_inc_from_target}/GL/glew.h") + set(GLEW_INCLUDE_DIR "${_glew_inc_from_target}" CACHE PATH "GLEW include dir (from imported target)" FORCE) + set(_SCIRUN_USE_GLEW_TARGET TRUE) +else() + # 3) Fallback: try to derive from CMAKE_PREFIX_PATH + _ensure_header(GLEW_INCLUDE_DIR "GL/glew.h") + + # 4) Last-resort: force the well-known superbuild path + if(NOT GLEW_INCLUDE_DIR) + set(_sb_glew_inc "${CMAKE_BINARY_DIR}/Externals/Install/Glew_external/include") + if(EXISTS "${_sb_glew_inc}/GL/glew.h") + set(GLEW_INCLUDE_DIR "${_sb_glew_inc}" CACHE PATH "GLEW include dir (superbuild)" FORCE) + endif() + endif() +endif() + +message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") +if(TARGET GLEW::GLEW) + message(STATUS "GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES='${_glew_inc_from_target}'") +endif() + _ensure_header(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") _ensure_header(SQLite3_INCLUDE_DIR "sqlite3.h") _ensure_header(TNY_INCLUDE_DIR "tny/tny.h") From e8ad94f1f83621c867e54b2f24a3f08bdc1ecb79 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 9 Mar 2026 16:49:30 -0600 Subject: [PATCH 067/140] python update error --- Superbuild/GlewExternal.cmake | 39 ++++++++++++++++---------------- Superbuild/GlewWriteConfig.cmake | 6 +++-- Superbuild/PythonExternal.cmake | 2 ++ 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index 51a1fc6403..2b6c4d7657 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -24,7 +24,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# GlewExternal.cmake (modernized + consistent + header copy into Install) +# GlewExternal.cmake set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") set(glew_GIT_TAG "v1.0.1") @@ -33,16 +33,12 @@ set(glew_GIT_TAG "v1.0.1") set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DBUILD_SHARED_LIBS=OFF # ensure static - -DGLEW_USE_STATIC_LIBS=ON # if your fork honors this - - # Redirect all outputs so install step is unnecessary for libs + -DBUILD_SHARED_LIBS=OFF + -DGLEW_USE_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX= -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib @@ -50,13 +46,10 @@ set(_cmake_args -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) - -# Single-config generators if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() -# Superbuild directories set(_glew_src "${CMAKE_BINARY_DIR}/Externals/Source/Glew_external") set(_glew_bin "${CMAKE_BINARY_DIR}/Externals/Build/Glew_external") set(_glew_inst "${CMAKE_BINARY_DIR}/Externals/Install/Glew_external") @@ -65,17 +58,13 @@ ExternalProject_Add(Glew_external GIT_REPOSITORY "https://github.com/CIBC-Internal/glew.git" GIT_TAG ${glew_GIT_TAG} UPDATE_DISCONNECTED 1 - SOURCE_DIR ${_glew_src} BINARY_DIR ${_glew_bin} - CMAKE_GENERATOR "${CMAKE_GENERATOR}" CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - CMAKE_ARGS ${_cmake_args} - INSTALL_COMMAND "" # we redirect outputs - + INSTALL_COMMAND "" LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 @@ -89,13 +78,12 @@ ExternalProject_Add_Step(Glew_external copy_headers COMMENT "[Glew_external] Copying GLEW headers to ${_glew_inst}/include" ) -# Export variables for SCIRun +# Resolve the actual library name produced set(GLEW_SOURCE_DIR ${_glew_src}) set(GLEW_INSTALL_DIR ${_glew_inst}) set(GLEW_INCLUDE ${GLEW_INSTALL_DIR}/include) set(GLEW_LIBRARY_DIR ${GLEW_INSTALL_DIR}/lib) -# Pick the actual lib name produced set(_glew_lib "") if(EXISTS "${GLEW_LIBRARY_DIR}/glew.lib") set(_glew_lib "${GLEW_LIBRARY_DIR}/glew.lib") @@ -105,12 +93,21 @@ elseif(EXISTS "${GLEW_LIBRARY_DIR}/glew32.lib") set(_glew_lib "${GLEW_LIBRARY_DIR}/glew32.lib") endif() -# Generate a config package for GLEW so SCIRun can find GLEW::GLEW deterministically +# Fail early if lib isn't there yet (prevents empty target export) +if(NOT _glew_lib) + message(STATUS "[Glew_external] glew(.lib) not detected at configure-time; will be in ${GLEW_LIBRARY_DIR} after build.") +endif() + +# ---- Write a config package that SCIRun can consume (path fix here) ---- +# Template is kept NEXT TO this file: use ${CMAKE_CURRENT_LIST_DIR} +set(_template "${CMAKE_CURRENT_LIST_DIR}/GLEWConfig.cmake.in") add_custom_target(Glew_export ALL COMMAND ${CMAKE_COMMAND} -E make_directory "${GLEW_INSTALL_DIR}/lib/cmake/GLEW" COMMAND ${CMAKE_COMMAND} -D GLEW_INC:PATH="${GLEW_INCLUDE}" -D GLEW_LIB:PATH="${_glew_lib}" + -D TEMPLATE:PATH="${_template}" + -D OUT_FILE:PATH="${GLEW_INSTALL_DIR}/lib/cmake/GLEW/GLEWConfig.cmake" -P "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" DEPENDS Glew_external copy_headers COMMENT "[Glew_external] Writing GLEWConfig.cmake" @@ -118,8 +115,10 @@ add_custom_target(Glew_export ALL # Helper script to expand template @ONLY file(WRITE "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" " - configure_file(\"${SUPERBUILD_DIR}/cmake/GLEWConfig.cmake.in\" - \"${GLEW_INSTALL_DIR}/lib/cmake/GLEW/GLEWConfig.cmake\" @ONLY) +if(NOT EXISTS \"\${TEMPLATE}\") + message(FATAL_ERROR \"GLEW template not found at: \${TEMPLATE}\") +endif() +configure_file(\"\${TEMPLATE}\" \"\${OUT_FILE}\" @ONLY) ") message(STATUS "[Glew_external] INSTALL_DIR=${GLEW_INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/GlewWriteConfig.cmake b/Superbuild/GlewWriteConfig.cmake index cf86a3e605..8371814f70 100644 --- a/Superbuild/GlewWriteConfig.cmake +++ b/Superbuild/GlewWriteConfig.cmake @@ -1,3 +1,5 @@ - configure_file("C:/Users/Yong/Documents/SCIRun/Superbuild/cmake/GLEWConfig.cmake.in" - "C:/Users/Yong/Documents/SCIRun/build/Externals/Install/Glew_external/lib/cmake/GLEW/GLEWConfig.cmake" @ONLY) +if(NOT EXISTS "${TEMPLATE}") + message(FATAL_ERROR "GLEW template not found at: ${TEMPLATE}") +endif() +configure_file("${TEMPLATE}" "${OUT_FILE}" @ONLY) diff --git a/Superbuild/PythonExternal.cmake b/Superbuild/PythonExternal.cmake index f1e5f67afb..06ef4d718f 100644 --- a/Superbuild/PythonExternal.cmake +++ b/Superbuild/PythonExternal.cmake @@ -159,6 +159,8 @@ ELSE() ExternalProject_Add(Python_external GIT_REPOSITORY ${python_GIT_URL} GIT_TAG ${python_GIT_TAG} + UPDATE_DISCONNECTED 1 + UPDATE_COMMAND "" PATCH_COMMAND "" # Pass platform to build.bat so it generates the right artifacts CONFIGURE_COMMAND PCbuild/build.bat -p ${python_WIN32_ARCH} From 2efffc7216a30707d1befec81ef9621533af50da Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 10 Mar 2026 10:59:50 -0600 Subject: [PATCH 068/140] freetype lib not found --- Superbuild/FreetypeExternal.cmake | 4 +- Superbuild/Superbuild.cmake | 11 +++++ src/CMakeLists.txt | 55 ++++++++++++++++++++++++ src/Modules/Visualization/CMakeLists.txt | 2 +- 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 4575839d8a..0ce881615d 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -117,11 +117,13 @@ set(FREETYPE_SOURCE_DIR ${_freetype_src}) set(FREETYPE_INSTALL_DIR ${_freetype_inst}) # Public headers for consumers are under source/include -set(FREETYPE_INCLUDE ${FREETYPE_SOURCE_DIR}/include) +set(Freetype_INCLUDE_DIR "${FREETYPE_INSTALL_DIR}/include" CACHE PATH "" FORCE) +set(FREETYPE_INCLUDE_DIR2 "${FREETYPE_INSTALL_DIR}/include/freetype2" CACHE PATH "" FORCE) # Libraries land here if you later enable FreeType's install; # with INSTALL_COMMAND "" it remains empty, but we keep the var for consistency. set(FREETYPE_LIBRARY_DIR ${FREETYPE_INSTALL_DIR}/lib) +set(Freetype_LIB_DIR "${FREETYPE_INSTALL_DIR}/lib" CACHE PATH "" FORCE) # Basename (actual file becomes freetype.lib / libfreetype.a / libfreetype.{so,dylib}) set(FREETYPE_LIBRARY "freetype") diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index c0f678db99..d0f552a76f 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1168,4 +1168,15 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) DIRS "${_py_pcbuild}" ) endif() +endif() + +if(TARGET Freetype_external) + ExternalProject_Get_Property(Freetype_external INSTALL_DIR) + + _sb_scirun_wait_for(NAME freetype + FILES + "${INSTALL_DIR}/include/ft2build.h" + "${INSTALL_DIR}/include/freetype2/freetype/config/ftheader.h" + DIRS "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" + ) endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 596a12838a..a82ae1a56e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1243,6 +1243,61 @@ if(TARGET GLEW::GLEW) message(STATUS "GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES='${_glew_inc_from_target}'") endif() +# --- Freetype imported target (robust on Windows) --- +# 1) Try a config package (superbuild may have installed one) +find_package(Freetype QUIET CONFIG) + +if(NOT TARGET Freetype::Freetype) + # 2) Synthesize if config not available + if(DEFINED Freetype_LIB_DIR AND IS_DIRECTORY "${Freetype_LIB_DIR}") + set(_ft_rel "") + set(_ft_dbg "") + + file(GLOB _cand_rel + "${Freetype_LIB_DIR}/freetype.lib" "${Freetype_LIB_DIR}/libfreetype.lib") + file(GLOB _cand_dbg + "${Freetype_LIB_DIR}/freetyped.lib" "${Freetype_LIB_DIR}/libfreetyped.lib") + + if(_cand_rel) + list(SORT _cand_rel) + list(GET _cand_rel 0 _ft_rel) + endif() + if(_cand_dbg) + list(SORT _cand_dbg) + list(GET _cand_dbg 0 _ft_dbg) + endif() + + if(NOT _ft_rel AND _ft_dbg) + set(_ft_rel "${_ft_dbg}") + endif() + if(NOT _ft_dbg AND _ft_rel) + set(_ft_dbg "${_ft_rel}") + endif() + + if(_ft_rel OR _ft_dbg) + add_library(Freetype::Freetype UNKNOWN IMPORTED) + # FreeType expects both roots: ft2build.h and freetype2 headers + set_property(TARGET Freetype::Freetype PROPERTY + INTERFACE_INCLUDE_DIRECTORIES + "${Freetype_INCLUDE_DIR};${FREETYPE_INCLUDE_DIR2}" + ) + if(_ft_rel) + set_property(TARGET Freetype::Freetype PROPERTY IMPORTED_LOCATION_RELEASE "${_ft_rel}") + endif() + if(_ft_dbg) + set_property(TARGET Freetype::Freetype PROPERTY IMPORTED_LOCATION_DEBUG "${_ft_dbg}") + endif() + + message(STATUS "[SCIRun] Freetype::Freetype: rel='${_ft_rel}' dbg='${_ft_dbg}' " + "inc1='${Freetype_INCLUDE_DIR}' inc2='${FREETYPE_INCLUDE_DIR2}'") + else() + message(WARNING "[SCIRun] Could not find freetype{,d}.lib in '${Freetype_LIB_DIR}'") + endif() + else() + message(WARNING "[SCIRun] Freetype_LIB_DIR not set or invalid; cannot synthesize Freetype::Freetype") + endif() +endif() + _ensure_header(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") _ensure_header(SQLite3_INCLUDE_DIR "sqlite3.h") _ensure_header(TNY_INCLUDE_DIR "tny/tny.h") diff --git a/src/Modules/Visualization/CMakeLists.txt b/src/Modules/Visualization/CMakeLists.txt index 8475206447..b88a7c985d 100644 --- a/src/Modules/Visualization/CMakeLists.txt +++ b/src/Modules/Visualization/CMakeLists.txt @@ -77,7 +77,7 @@ TARGET_LINK_LIBRARIES(Modules_Visualization Graphics_Glyphs Graphics_Datatypes Graphics_Widgets - ${SCI_FREETYPE_LIBRARY} + Freetype::Freetype ) IF(BUILD_SHARED_LIBS) From e559ab0f28868cd5593cf5acf03b9d418a41b6e0 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 10 Mar 2026 13:11:17 -0600 Subject: [PATCH 069/140] added Core_Algorithm_Legacy_Fields to where it's needed --- src/Interface/Modules/Bundle/CMakeLists.txt | 1 + src/Interface/Modules/Fields/CMakeLists.txt | 1 + src/Interface/Modules/Render/CMakeLists.txt | 2 +- src/Interface/Modules/Teem/CMakeLists.txt | 1 + src/Modules/Python/CMakeLists.txt | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Interface/Modules/Bundle/CMakeLists.txt b/src/Interface/Modules/Bundle/CMakeLists.txt index 3c0c839815..1825598bfc 100644 --- a/src/Interface/Modules/Bundle/CMakeLists.txt +++ b/src/Interface/Modules/Bundle/CMakeLists.txt @@ -76,6 +76,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Bundle TARGET_LINK_LIBRARIES(Interface_Modules_Bundle Modules_Legacy_Bundle Core_Algorithms_Legacy_Converter + Core_Algorithm_Legacy_Fields Interface_Modules_Base ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES}) diff --git a/src/Interface/Modules/Fields/CMakeLists.txt b/src/Interface/Modules/Fields/CMakeLists.txt index 08dfb2107f..3ee6a76e45 100644 --- a/src/Interface/Modules/Fields/CMakeLists.txt +++ b/src/Interface/Modules/Fields/CMakeLists.txt @@ -213,6 +213,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Fields TARGET_LINK_LIBRARIES(Interface_Modules_Fields Algorithms_Field + Core_Algorithm_Legacy_Fields Modules_Fields Interface_Modules_Base Modules_Legacy_Fields diff --git a/src/Interface/Modules/Render/CMakeLists.txt b/src/Interface/Modules/Render/CMakeLists.txt index aeee522b08..ffb568a22d 100644 --- a/src/Interface/Modules/Render/CMakeLists.txt +++ b/src/Interface/Modules/Render/CMakeLists.txt @@ -137,7 +137,7 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render ${SCI_SPIRE_LIBRARY} ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} - ${SCI_FREETYPE_LIBRARY} + Freetype::Freetype ${SCI_LODEPNG_LIBRARY} Tny::tny Qwt::Qwt diff --git a/src/Interface/Modules/Teem/CMakeLists.txt b/src/Interface/Modules/Teem/CMakeLists.txt index 5fc572a1fd..a2c84a7d0f 100644 --- a/src/Interface/Modules/Teem/CMakeLists.txt +++ b/src/Interface/Modules/Teem/CMakeLists.txt @@ -65,6 +65,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Teem ) TARGET_LINK_LIBRARIES(Interface_Modules_Teem + Core_Algorithm_Legacy_Fields Modules_Legacy_Teem_Misc Modules_Legacy_Teem_Tend Modules_Legacy_Teem_Converters diff --git a/src/Modules/Python/CMakeLists.txt b/src/Modules/Python/CMakeLists.txt index 64ca25998f..9b0b374ee9 100644 --- a/src/Modules/Python/CMakeLists.txt +++ b/src/Modules/Python/CMakeLists.txt @@ -161,7 +161,7 @@ target_link_libraries(Modules_Python if(BUILD_WITH_PYTHON) # Pull in Python headers + import libs (per-config) via the alias - target_link_libraries(Modules_Python PRIVATE SCIRunPython Core_Python) + target_link_libraries(Modules_Python PRIVATE SCIRunPython Core_Python SCIRunPythonAPI) # ================================================================================== # Boost.Python: disable autolink and link the correct libraries explicitly on MSVC. From f6c24fc129d33a1cbae16d8e999a01cfbd2457da Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 10 Mar 2026 15:20:17 -0600 Subject: [PATCH 070/140] typos in lib name --- src/Interface/Modules/Bundle/CMakeLists.txt | 2 +- src/Interface/Modules/Fields/CMakeLists.txt | 2 +- src/Interface/Modules/Teem/CMakeLists.txt | 2 +- src/Modules/Legacy/Fields/InterfaceWithTetGen.h | 2 ++ src/Modules/Python/InterfaceWithPython.h | 2 ++ src/Modules/Python/LoopEnd.h | 2 ++ src/Modules/Python/LoopStart.h | 2 ++ src/Modules/Python/ModuleStateModifierTester.h | 2 ++ 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Interface/Modules/Bundle/CMakeLists.txt b/src/Interface/Modules/Bundle/CMakeLists.txt index 1825598bfc..f71de916a8 100644 --- a/src/Interface/Modules/Bundle/CMakeLists.txt +++ b/src/Interface/Modules/Bundle/CMakeLists.txt @@ -76,7 +76,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Bundle TARGET_LINK_LIBRARIES(Interface_Modules_Bundle Modules_Legacy_Bundle Core_Algorithms_Legacy_Converter - Core_Algorithm_Legacy_Fields + Core_Algorithms_Legacy_Fields Interface_Modules_Base ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES}) diff --git a/src/Interface/Modules/Fields/CMakeLists.txt b/src/Interface/Modules/Fields/CMakeLists.txt index 3ee6a76e45..cef8a4b059 100644 --- a/src/Interface/Modules/Fields/CMakeLists.txt +++ b/src/Interface/Modules/Fields/CMakeLists.txt @@ -213,7 +213,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Fields TARGET_LINK_LIBRARIES(Interface_Modules_Fields Algorithms_Field - Core_Algorithm_Legacy_Fields + Core_Algorithms_Legacy_Fields Modules_Fields Interface_Modules_Base Modules_Legacy_Fields diff --git a/src/Interface/Modules/Teem/CMakeLists.txt b/src/Interface/Modules/Teem/CMakeLists.txt index a2c84a7d0f..0f6cf7505f 100644 --- a/src/Interface/Modules/Teem/CMakeLists.txt +++ b/src/Interface/Modules/Teem/CMakeLists.txt @@ -65,7 +65,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Teem ) TARGET_LINK_LIBRARIES(Interface_Modules_Teem - Core_Algorithm_Legacy_Fields + Core_Algorithms_Legacy_Fields Modules_Legacy_Teem_Misc Modules_Legacy_Teem_Tend Modules_Legacy_Teem_Converters diff --git a/src/Modules/Legacy/Fields/InterfaceWithTetGen.h b/src/Modules/Legacy/Fields/InterfaceWithTetGen.h index 14ce6e64d1..0417993f09 100644 --- a/src/Modules/Legacy/Fields/InterfaceWithTetGen.h +++ b/src/Modules/Legacy/Fields/InterfaceWithTetGen.h @@ -68,6 +68,8 @@ namespace SCIRun { #ifndef WITH_TETGEN DISABLED_WITHOUT_ABOVE_COMPILE_FLAG + #else + public: bool isImplementationDisabled() const override { return false; } #endif INPUT_PORT(0, Main, Field); diff --git a/src/Modules/Python/InterfaceWithPython.h b/src/Modules/Python/InterfaceWithPython.h index 8d60d22374..f850229e48 100644 --- a/src/Modules/Python/InterfaceWithPython.h +++ b/src/Modules/Python/InterfaceWithPython.h @@ -93,6 +93,8 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG + #else + public: bool isImplementationDisabled() const override { return false; } #endif private: static Core::Thread::Mutex lock_; diff --git a/src/Modules/Python/LoopEnd.h b/src/Modules/Python/LoopEnd.h index ea8800b8d6..10f415950e 100644 --- a/src/Modules/Python/LoopEnd.h +++ b/src/Modules/Python/LoopEnd.h @@ -73,6 +73,8 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG + #else + public: bool isImplementationDisabled() const override { return false; } #endif private: SharedPointer translator_; diff --git a/src/Modules/Python/LoopStart.h b/src/Modules/Python/LoopStart.h index 01c5a51ec2..0c97bf6409 100644 --- a/src/Modules/Python/LoopStart.h +++ b/src/Modules/Python/LoopStart.h @@ -76,6 +76,8 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG + #else + public: bool isImplementationDisabled() const override { return false; } #endif private: SharedPointer translator_; diff --git a/src/Modules/Python/ModuleStateModifierTester.h b/src/Modules/Python/ModuleStateModifierTester.h index 0cbcd845b4..dd856ac939 100644 --- a/src/Modules/Python/ModuleStateModifierTester.h +++ b/src/Modules/Python/ModuleStateModifierTester.h @@ -77,6 +77,8 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG + #else + public: bool isImplementationDisabled() const override { return false; } #endif private: //void runTopLevelCode() const; From c4f05ebde718d185c52f76c8f1ba60f86b7daec3 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 11 Mar 2026 10:30:19 -0600 Subject: [PATCH 071/140] more missing libs in link --- src/Core/Application/CMakeLists.txt | 2 ++ src/Interface/Modules/Teem/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Core/Application/CMakeLists.txt b/src/Core/Application/CMakeLists.txt index fece04492e..616c39a939 100644 --- a/src/Core/Application/CMakeLists.txt +++ b/src/Core/Application/CMakeLists.txt @@ -70,8 +70,10 @@ if (BUILD_WITH_PYTHON) endif() TARGET_LINK_LIBRARIES(Core_Application + Core_Command Core_CommandLine Engine_Network + Engine_Scheduler Modules_Factory Algorithms_Factory Dataflow_State diff --git a/src/Interface/Modules/Teem/CMakeLists.txt b/src/Interface/Modules/Teem/CMakeLists.txt index 0f6cf7505f..a1b2d1a728 100644 --- a/src/Interface/Modules/Teem/CMakeLists.txt +++ b/src/Interface/Modules/Teem/CMakeLists.txt @@ -66,6 +66,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Teem TARGET_LINK_LIBRARIES(Interface_Modules_Teem Core_Algorithms_Legacy_Fields + Core_Algorithms_Legacy_Converter Modules_Legacy_Teem_Misc Modules_Legacy_Teem_Tend Modules_Legacy_Teem_Converters From 30130a1def320d0dc25a1d117254d219753d9f58 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 11 Mar 2026 16:42:52 -0600 Subject: [PATCH 072/140] lodepng not found for linking --- Superbuild/LodePNGWrapperProject.cmake.in | 95 +++++++++++ Superbuild/LodePNGWrapper_configure.cmake | 64 ++++++++ Superbuild/LodePNGWrapper_install.cmake | 57 +++++++ Superbuild/LodePngExternal.cmake | 38 +++-- Superbuild/Superbuild.cmake | 24 ++- src/CMakeLists.txt | 34 +++- src/Core/ConsoleApplication/CMakeLists.txt | 152 ++++++++++++++++-- src/Externals/spire/CMakeLists.txt | 2 +- src/Interface/Application/GuiCommands.cc | 2 +- .../SCIRunMainWindowSlotsPrivate.cc | 2 +- src/Interface/Modules/Render/CMakeLists.txt | 2 +- 11 files changed, 434 insertions(+), 38 deletions(-) create mode 100644 Superbuild/LodePNGWrapperProject.cmake.in create mode 100644 Superbuild/LodePNGWrapper_configure.cmake create mode 100644 Superbuild/LodePNGWrapper_install.cmake diff --git a/Superbuild/LodePNGWrapperProject.cmake.in b/Superbuild/LodePNGWrapperProject.cmake.in new file mode 100644 index 0000000000..634bd9dc40 --- /dev/null +++ b/Superbuild/LodePNGWrapperProject.cmake.in @@ -0,0 +1,95 @@ +cmake_minimum_required(VERSION 3.16) +project(LodePNGWrapper LANGUAGES C CXX) + +# Force proper Visual Studio config token, NOT "" +if(MSVC) + # Ensure generated VS project uses $(Configuration), avoiding literal "" anywhere. + set(CMAKE_CFG_INTDIR "$(Configuration)" CACHE STRING "VS config subdir token" FORCE) +endif() + +# Expect: -DLODEPNG_SRC= passed from the configure script +if(NOT DEFINED LODEPNG_SRC) + message(FATAL_ERROR "LODEPNG_SRC not set (path to folder with lodepng.cpp / lodepng.h).") +endif() + +# Sanitize and normalize (defensive) +string(REGEX REPLACE "^\"|\"$" "" LODEPNG_SRC "${LODEPNG_SRC}") +file(TO_CMAKE_PATH "${LODEPNG_SRC}" LODEPNG_SRC) + +message(STATUS "[LodePNGWrapper] LODEPNG_SRC='${LODEPNG_SRC}'") + +# Resolve lodepng.cpp in either layout: +# 1) /lodepng.cpp +# 2) /lodepng/lodepng.cpp +set(_lp_cpp "${LODEPNG_SRC}/lodepng.cpp") +if(NOT EXISTS "${_lp_cpp}") + set(_lp_cpp "${LODEPNG_SRC}/lodepng/lodepng.cpp") +endif() + +if(NOT EXISTS "${_lp_cpp}") + message(FATAL_ERROR "Could not find lodepng.cpp. Checked: + ${LODEPNG_SRC}/lodepng.cpp + ${LODEPNG_SRC}/lodepng/lodepng.cpp") +endif() +message(STATUS "[LodePNGWrapper] Using source file: ${_lp_cpp}") + +# Build a static library +add_library(lodepng STATIC "${_lp_cpp}") +set_target_properties(lodepng PROPERTIES + OUTPUT_NAME "$,lodepngd,lodepng>" + POSITION_INDEPENDENT_CODE ON +) + +# Include dirs: support both header layouts +target_include_directories(lodepng PUBLIC + "${LODEPNG_SRC}" + "${LODEPNG_SRC}/lodepng" +) + +# Install library and header(s) +include(GNUInstallDirs) + +install(TARGETS lodepng + EXPORT LodePNGTargets + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" +) + +# Install whichever header exists: +set(_lp_h1 "${LODEPNG_SRC}/lodepng.h") +set(_lp_h2 "${LODEPNG_SRC}/lodepng/lodepng.h") +if(EXISTS "${_lp_h1}") + install(FILES "${_lp_h1}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/lodepng") +elseif(EXISTS "${_lp_h2}") + install(FILES "${_lp_h2}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/lodepng") +else() + message(WARNING "Could not find lodepng.h under '${LODEPNG_SRC}'. No headers will be installed.") +endif() + +# Export a simple CMake package: LodePNG::lodepng +install(EXPORT LodePNGTargets + NAMESPACE LodePNG:: + FILE LodePNGTargets.cmake + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/LodePNG" +) + +include(CMakePackageConfigHelpers) +set(LodePNG_PACKAGE_VERSION "1.0") +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/LodePNGConfigVersion.cmake" + VERSION "${LodePNG_PACKAGE_VERSION}" + COMPATIBILITY SameMajorVersion +) + +# Minimal Config that includes the exported targets +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LodePNGConfig.cmake" [=[ +# LodePNGConfig.cmake - generated by LodePNGWrapperProject +include("${CMAKE_CURRENT_LIST_DIR}/LodePNGTargets.cmake") +]=]) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/LodePNGConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/LodePNGConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/LodePNG" +) \ No newline at end of file diff --git a/Superbuild/LodePNGWrapper_configure.cmake b/Superbuild/LodePNGWrapper_configure.cmake new file mode 100644 index 0000000000..a602f377a8 --- /dev/null +++ b/Superbuild/LodePNGWrapper_configure.cmake @@ -0,0 +1,64 @@ +# LodePNGWrapper_configure.cmake +# Executed with `cmake -P` from ExternalProject_Add. +# Creates a minimal wrapper source dir and configures it with the chosen generator. + +# Required inputs +foreach(req IN ITEMS WRAPPER_SOURCE_DIR WRAPPER_BUILD_DIR WRAPPER_LIST_FILE LODEPNG_SRC CMAKE_INSTALL_PREFIX CMAKE_GENERATOR) + if(NOT DEFINED ${req}) + message(FATAL_ERROR "Missing required variable: ${req}") + endif() +endforeach() + +# Sanitize: strip accidental surrounding quotes; normalize to CMake-style paths. +foreach(var IN ITEMS WRAPPER_SOURCE_DIR WRAPPER_BUILD_DIR WRAPPER_LIST_FILE LODEPNG_SRC CMAKE_INSTALL_PREFIX) + if(DEFINED ${var}) + string(REGEX REPLACE "^\"|\"$" "" ${var} "${${var}}") + file(TO_CMAKE_PATH "${${var}}" ${var}) + endif() +endforeach() + +file(MAKE_DIRECTORY "${WRAPPER_SOURCE_DIR}") +file(MAKE_DIRECTORY "${WRAPPER_BUILD_DIR}") + +# Copy the wrapper template to a proper CMakeLists.txt +if(NOT EXISTS "${WRAPPER_LIST_FILE}") + message(FATAL_ERROR "WRAPPER_LIST_FILE does not exist: '${WRAPPER_LIST_FILE}'") +endif() +file(COPY "${WRAPPER_LIST_FILE}" DESTINATION "${WRAPPER_SOURCE_DIR}") +file(RENAME "${WRAPPER_SOURCE_DIR}/LodePNGWrapperProject.cmake.in" + "${WRAPPER_SOURCE_DIR}/CMakeLists.txt") + +# Prepare generator args for Visual Studio +set(_GEN_ARGS -G "${CMAKE_GENERATOR}") +if(DEFINED CMAKE_GENERATOR_PLATFORM AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "") + list(APPEND _GEN_ARGS -A "${CMAKE_GENERATOR_PLATFORM}") +endif() +if(DEFINED CMAKE_GENERATOR_TOOLSET AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "") + list(APPEND _GEN_ARGS -T "${CMAKE_GENERATOR_TOOLSET}") +endif() + +message(STATUS "[LodePNGWrapper_configure] LODEPNG_SRC='${LODEPNG_SRC}'") +message(STATUS "[LodePNGWrapper_configure] WRAPPER_SOURCE_DIR='${WRAPPER_SOURCE_DIR}'") +message(STATUS "[LodePNGWrapper_configure] WRAPPER_BUILD_DIR='${WRAPPER_BUILD_DIR}'") +message(STATUS "[LodePNGWrapper_configure] CMAKE_INSTALL_PREFIX='${CMAKE_INSTALL_PREFIX}'") +message(STATUS "[LodePNGWrapper_configure] CMAKE_GENERATOR='${CMAKE_GENERATOR}'") +if(DEFINED CMAKE_GENERATOR_PLATFORM) + message(STATUS "[LodePNGWrapper_configure] CMAKE_GENERATOR_PLATFORM='${CMAKE_GENERATOR_PLATFORM}'") +endif() +if(DEFINED CMAKE_GENERATOR_TOOLSET) + message(STATUS "[LodePNGWrapper_configure] CMAKE_GENERATOR_TOOLSET='${CMAKE_GENERATOR_TOOLSET}'") +endif() + +# Configure the wrapper project +execute_process( + COMMAND "${CMAKE_COMMAND}" ${_GEN_ARGS} + -S "${WRAPPER_SOURCE_DIR}" + -B "${WRAPPER_BUILD_DIR}" + -D LODEPNG_SRC:PATH="${LODEPNG_SRC}" + -D CMAKE_INSTALL_PREFIX:PATH="${CMAKE_INSTALL_PREFIX}" + -D BUILD_SHARED_LIBS:BOOL=OFF + RESULT_VARIABLE _res +) +if(NOT _res EQUAL 0) + message(FATAL_ERROR "Failed to configure LodePNG wrapper project (code=${_res}).") +endif() \ No newline at end of file diff --git a/Superbuild/LodePNGWrapper_install.cmake b/Superbuild/LodePNGWrapper_install.cmake new file mode 100644 index 0000000000..4629a4d2c4 --- /dev/null +++ b/Superbuild/LodePNGWrapper_install.cmake @@ -0,0 +1,57 @@ +# LodePNGWrapper_install.cmake +# Manual install for the wrapper (avoids cmake_install.cmake path issues). + +foreach(req IN ITEMS WRAPPER_BUILD_DIR WRAPPER_SOURCE_DIR LODEPNG_INSTALL_DIR CONFIGURATION) + if(NOT DEFINED ${req}) + message(FATAL_ERROR "Missing required variable: ${req}") + endif() +endforeach() + +# Normalize inputs +foreach(var IN ITEMS WRAPPER_BUILD_DIR WRAPPER_SOURCE_DIR LODEPNG_INSTALL_DIR CONFIGURATION) + string(REGEX REPLACE "^\"|\"$" "" ${var} "${${var}}") + file(TO_CMAKE_PATH "${${var}}" ${var}) +endforeach() + +# 1) Headers: copy whichever layout exists into /include/lodepng/lodepng.h +set(_hdr1 "${WRAPPER_SOURCE_DIR}/lodepng/lodepng.h") +set(_hdr2 "${WRAPPER_SOURCE_DIR}/lodepng.h") +set(_hdr "") +if(EXISTS "${_hdr1}") + set(_hdr "${_hdr1}") +elseif(EXISTS "${_hdr2}") + set(_hdr "${_hdr2}") +endif() + +if(_hdr) + file(MAKE_DIRECTORY "${LODEPNG_INSTALL_DIR}/include/lodepng") + file(COPY "${_hdr}" DESTINATION "${LODEPNG_INSTALL_DIR}/include/lodepng") + message(STATUS "[LodePNGManualInstall] Copied header: ${_hdr} -> ${LODEPNG_INSTALL_DIR}/include/lodepng/") +else() + message(WARNING "[LodePNGManualInstall] No lodepng.h found under: ${WRAPPER_SOURCE_DIR}") +endif() + +# 2) Library: choose name by configuration and copy to /lib +if(CONFIGURATION STREQUAL "Debug") + set(_libname "lodepngd.lib") +else() + set(_libname "lodepng.lib") +endif() + +# VS output typically: //.lib +set(_libsrc "${WRAPPER_BUILD_DIR}/${CONFIGURATION}/${_libname}") +file(MAKE_DIRECTORY "${LODEPNG_INSTALL_DIR}/lib") + +if(EXISTS "${_libsrc}") + file(COPY "${_libsrc}" DESTINATION "${LODEPNG_INSTALL_DIR}/lib") + message(STATUS "[LodePNGManualInstall] Copied lib: ${_libsrc} -> ${LODEPNG_INSTALL_DIR}/lib/") +else() + # Fallback: try without config subdir (just in case) + set(_alt "${WRAPPER_BUILD_DIR}/${_libname}") + if(EXISTS "${_alt}") + file(COPY "${_alt}" DESTINATION "${LODEPNG_INSTALL_DIR}/lib") + message(STATUS "[LodePNGManualInstall] Copied lib (alt): ${_alt} -> ${LODEPNG_INSTALL_DIR}/lib/") + else() + message(FATAL_ERROR "[LodePNGManualInstall] Built library not found.\n Tried:\n ${_libsrc}\n ${_alt}") + endif() +endif() \ No newline at end of file diff --git a/Superbuild/LodePngExternal.cmake b/Superbuild/LodePngExternal.cmake index fb48dd2da9..823fc214bb 100644 --- a/Superbuild/LodePngExternal.cmake +++ b/Superbuild/LodePngExternal.cmake @@ -24,22 +24,40 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - -# LodePngExternal.cmake +# LodePngExternal.cmake (flat, no subdirs) set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +include(ExternalProject) + ExternalProject_Add(LodePng_external GIT_REPOSITORY "https://github.com/CIBC-Internal/cibc-lodepng.git" GIT_TAG "origin/master" - PATCH_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - # FIX: use a single copy_directory (NO &&) + # Configure: generate a tiny wrapper project with the same VS generator/platform/toolset + CONFIGURE_COMMAND + ${CMAKE_COMMAND} + -D WRAPPER_SOURCE_DIR:PATH=/lodepng-wrapper-src + -D WRAPPER_BUILD_DIR:PATH=/lodepng-wrapper-build + -D WRAPPER_LIST_FILE:PATH=${CMAKE_CURRENT_LIST_DIR}/LodePNGWrapperProject.cmake.in + -D LODEPNG_SRC:PATH=/lodepng + -D CMAKE_INSTALL_PREFIX:PATH= # still set, but we won't use install() + -D CMAKE_GENERATOR:STRING=${CMAKE_GENERATOR} + -D CMAKE_GENERATOR_PLATFORM:STRING=${CMAKE_GENERATOR_PLATFORM} + -D CMAKE_GENERATOR_TOOLSET:STRING=${CMAKE_GENERATOR_TOOLSET} + -P ${CMAKE_CURRENT_LIST_DIR}/LodePNGWrapper_configure.cmake + + # VS is multi-config: per-config build + BUILD_COMMAND + ${CMAKE_COMMAND} --build "/lodepng-wrapper-build" --config $(Configuration) + + # ---- IMPORTANT: replace install() with an explicit copy script ---- INSTALL_COMMAND - ${CMAKE_COMMAND} -E copy_directory - "/lodepng" - "${CMAKE_BINARY_DIR}/Externals/Install/LodePng_external/include/lodepng" + ${CMAKE_COMMAND} + -D WRAPPER_BUILD_DIR:PATH=/lodepng-wrapper-build + -D WRAPPER_SOURCE_DIR:PATH= # repo root (we'll probe header in both layouts) + -D LODEPNG_INSTALL_DIR:PATH= + -D CONFIGURATION:STRING=$(Configuration) + -P ${CMAKE_CURRENT_LIST_DIR}/LodePNGWrapper_install.cmake CMAKE_CACHE_ARGS -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 @@ -52,4 +70,4 @@ ExternalProject_Add(LodePng_external ) ExternalProject_Get_Property(LodePng_external INSTALL_DIR) -message(STATUS "[LodePng_external] INSTALL_DIR=${INSTALL_DIR}") +message(STATUS "[LodePng_external] INSTALL_DIR=${INSTALL_DIR}") \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index d0f552a76f..4a39dbcd19 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -439,13 +439,14 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) _export_config_dir(Python Python_external "") endif() +_export_config_dir(LodePNG LodePng_external "") + # Include/lib hints (guarded by target existence) _sb_export_inc_lib(Freetype Freetype_external) _sb_export_inc_lib(GLM GLM_external) _sb_export_inc_lib(SpdLog SpdLog_external) _sb_export_inc_lib(Teem Teem_external) _sb_export_inc_lib(Tny Tny_external) -_sb_export_inc_lib(LodePng LodePng_external) _sb_export_inc_lib(Cleaver2 Cleaver2_external) _sb_export_inc_lib(SQLite SQLite_external) if(WITH_TETGEN AND TARGET Tetgen_external) # <- lowercase g @@ -1077,11 +1078,24 @@ endif() if(TARGET LodePng_external) ExternalProject_Get_Property(LodePng_external INSTALL_DIR) + + set(_lodepng_libdir "") + if(EXISTS "${INSTALL_DIR}/lib64") + set(_lodepng_libdir "${INSTALL_DIR}/lib64") + else() + set(_lodepng_libdir "${INSTALL_DIR}/lib") + endif() + + # Wait for both header and at least one library (Debug or Release) + set(_lp_wait_files + "${INSTALL_DIR}/include/lodepng/lodepng.h" + "${_lodepng_libdir}/lodepng.lib" + "${_lodepng_libdir}/lodepngd.lib" + ) + _sb_scirun_wait_for(NAME lodepng - FILES - "${INSTALL_DIR}/include/lodepng/lodepng.h" - "${INSTALL_DIR}/include/lodepng.h" - DIRS "${INSTALL_DIR}/include" + FILES ${_lp_wait_files} + DIRS "${INSTALL_DIR}/include" "${_lodepng_libdir}" ) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a82ae1a56e..90a39ff456 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -297,6 +297,34 @@ if(NOT TARGET Teem::teem) endif() endif() +# --- LodePNG imported target fallback (manual) --- +# Use the superbuild install paths. Adjust if your layout differs. +if(NOT TARGET LodePNG::lodepng) + set(_LPNG_ROOT "${CMAKE_BINARY_DIR}/../Externals/Install/LodePng_external") + set(_LPNG_INC "${_LPNG_ROOT}/include") + set(_LPNG_LIBD "${_LPNG_ROOT}/lib/lodepngd.lib") + set(_LPNG_LIBR "${_LPNG_ROOT}/lib/lodepng.lib") + + if(EXISTS "${_LPNG_LIBD}" OR EXISTS "${_LPNG_LIBR}") + add_library(LodePNG::lodepng STATIC IMPORTED) + set_target_properties(LodePNG::lodepng PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_LPNG_INC}" + ) + if(EXISTS "${_LPNG_LIBD}") + set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_DEBUG "${_LPNG_LIBD}") + endif() + if(EXISTS "${_LPNG_LIBR}") + set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_RELEASE "${_LPNG_LIBR}") + set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_RELWITHDEBINFO "${_LPNG_LIBR}") + set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_MINSIZEREL "${_LPNG_LIBR}") + endif() + message(STATUS "[SCIRun] LodePNG::lodepng imported: inc='${_LPNG_INC}', " + "dbg='${_LPNG_LIBD}', rel='${_LPNG_LIBR}'") + else() + message(WARNING "[SCIRun] LodePNG libs not found under '${_LPNG_ROOT}/lib'. Build LodePng_external first.") + endif() +endif() + ############################################################################### # Don't allow the user to build in the src directory... # @@ -859,9 +887,9 @@ CONFIG_STANDARD_EXTERNAL(Tny ) # LodePNG -CONFIG_STANDARD_EXTERNAL(LodePng - DIR "${LODEPNG_DIR}" - CFG "LodePngConfig.cmake" +CONFIG_STANDARD_EXTERNAL(LodePNG + DIR "${LodePNG_DIR}" + CFGS "LodePNGConfig.cmake" ) # Tetgen (optional) diff --git a/src/Core/ConsoleApplication/CMakeLists.txt b/src/Core/ConsoleApplication/CMakeLists.txt index 6590f10163..6bb2145aca 100644 --- a/src/Core/ConsoleApplication/CMakeLists.txt +++ b/src/Core/ConsoleApplication/CMakeLists.txt @@ -25,26 +25,95 @@ # DEALINGS IN THE SOFTWARE. # +# Optional: make CMake report condition errors clearly (silences the dev warning) +if (POLICY CMP0130) + cmake_policy(SET CMP0130 NEW) +endif() -SET(Core_ConsoleApplication_SRCS +# ---- Sources ---- +set(Core_ConsoleApplication_SRCS ConsoleApplication.cc ConsoleCommandFactory.cc ConsoleCommands.cc ) -SET(Core_ConsoleApplication_HEADERS +set(Core_ConsoleApplication_HEADERS ConsoleApplication.h ConsoleCommandFactory.h ConsoleCommands.h share.h ) +# ---- Target ---- SCIRUN_ADD_LIBRARY(Core_ConsoleApplication ${Core_ConsoleApplication_HEADERS} ${Core_ConsoleApplication_SRCS} ) -# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h +# Disable Boost header auto-linking on this target (prevents implicit /DEFAULTLIB from headers) +target_compile_definitions(Core_ConsoleApplication PRIVATE + BOOST_ALL_NO_LIB BOOST_PYTHON_NO_LIB +) + +# ---- Build a local Boost list WITHOUT Boost.Python, preserving debug/optimized pairs ---- +set(_src_boost_list "${SCI_BOOST_LIBRARY}") +set(_boost_libs_filtered "") + +# Match any Boost.Python library variant +set(_boost_python_rx ".*[Bb]oost[_-]python.*\\.lib$") + +list(LENGTH _src_boost_list _n) +set(_i 0) +while(_i LESS _n) + list(GET _src_boost_list ${_i} _item) + + if((_item STREQUAL "debug") OR (_item STREQUAL "optimized")) + # Ensure there is a following library for the keyword + math(EXPR _j "${_i} + 1") + if(_j LESS _n) + list(GET _src_boost_list ${_j} _lib) + if(_lib MATCHES "${_boost_python_rx}") + # Skip the pair (keyword + python lib) + math(EXPR _i "${_i} + 2") + continue() + else() + # Keep both keyword and library + list(APPEND _boost_libs_filtered "${_item}" "${_lib}") + math(EXPR _i "${_i} + 2") + continue() + endif() + else() + # Dangling keyword (defensive) + math(EXPR _i "${_i} + 1") + continue() + endif() + else() + # Non-keyword item + if(_item MATCHES "${_boost_python_rx}") + # Skip unqualified python lib + math(EXPR _i "${_i} + 1") + continue() + else() + list(APPEND _boost_libs_filtered "${_item}") + math(EXPR _i "${_i} + 1") + continue() + endif() + endif() +endwhile() + +# Optional diagnostics +message(STATUS "[Core/ConsoleApplication] Boost libs after filtering: ${_boost_libs_filtered}") + +# ---- Link base deps + filtered Boost (no Boost.Python) ---- +# Use keyword form consistently to avoid the mixed-signature error +target_link_libraries(Core_ConsoleApplication PRIVATE + Core_Application + Core_Command + ${_boost_libs_filtered} + LodePNG::lodepng +) + +# ---- Python includes (unchanged from your version) ---- if (BUILD_WITH_PYTHON) set(_PY_INCLUDES "") if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") @@ -71,19 +140,70 @@ if (BUILD_WITH_PYTHON) endif() endif() -TARGET_LINK_LIBRARIES(Core_ConsoleApplication - Core_Application - Core_Command - ${SCI_BOOST_LIBRARY} -) +# ---- Link Core_Python if requested (your curated aggregation) ---- +if (BUILD_WITH_PYTHON) + target_link_libraries(Core_ConsoleApplication PRIVATE Core_Python) +endif() -IF(BUILD_WITH_PYTHON) -TARGET_LINK_LIBRARIES(Core_ConsoleApplication - Core_Python) -ENDIF() +# ---- Force the correct Python import lib per configuration & ignore wrong defaultlibs ---- +if (MSVC AND BUILD_WITH_PYTHON) + # Neutralize wrong defaultlibs embedded by dependent .libs (e.g., Boost.Python) + target_link_options(Core_ConsoleApplication PRIVATE + $<$:/NODEFAULTLIB:python313.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + ) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Core_ConsoleApplication) -ENDIF(BUILD_SHARED_LIBS) + # Prefer your imported Python target (from superbuild helper) + if (TARGET SCIRunPython::Python) + target_link_libraries(Core_ConsoleApplication PRIVATE + $<$:SCIRunPython::Python> + $<$>:SCIRunPython::Python> + ) + elseif (TARGET Python::Python) + target_link_libraries(Core_ConsoleApplication PRIVATE + $<$:Python::Python> + $<$>:Python::Python> + ) + else() + # Fallback to explicit path probing for python313[_d].lib within superbuild + set(_PY_DBG "") + set(_PY_REL "") + foreach(dir + "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/libs" + "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/lib" + "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64" + ) + if (EXISTS "${dir}/python313_d.lib" AND NOT _PY_DBG) + set(_PY_DBG "${dir}/python313_d.lib") + endif() + if (EXISTS "${dir}/python313.lib" AND NOT _PY_REL) + set(_PY_REL "${dir}/python313.lib") + endif() + endforeach() + + if (_PY_DBG) + target_link_libraries(Core_ConsoleApplication PRIVATE + $<$:${_PY_DBG}> + ) + message(STATUS "[Core/ConsoleApplication] Using ${_PY_DBG} for Debug") + else() + message(WARNING "[Core/ConsoleApplication] Could not locate python313_d.lib; Debug link may still fail.") + endif() + + if (_PY_REL) + target_link_libraries(Core_ConsoleApplication PRIVATE + $<$>:${_PY_REL}> + ) + message(STATUS "[Core/ConsoleApplication] Using ${_PY_REL} for non-Debug") + else() + message(WARNING "[Core/ConsoleApplication] Could not locate python313.lib; non-Debug link may fail.") + endif() + endif() +endif() -#SCIRUN_ADD_TEST_DIR(Tests) +# ---- Shared libs define ---- +if(BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Core_ConsoleApplication) +endif() \ No newline at end of file diff --git a/src/Externals/spire/CMakeLists.txt b/src/Externals/spire/CMakeLists.txt index 19f60102cf..0754d0e52d 100644 --- a/src/Externals/spire/CMakeLists.txt +++ b/src/Externals/spire/CMakeLists.txt @@ -218,7 +218,7 @@ ADD_LIBRARY ( ${SCI_SPIRE_LIBRARY} ) target_link_libraries(${SCI_SPIRE_LIBRARY} - ${SCI_LODEPNG_LIBRARY} + LodePNG::lodepng Tny::tny ${OPENGL_LIBRARIES} GLEW::GLEW) diff --git a/src/Interface/Application/GuiCommands.cc b/src/Interface/Application/GuiCommands.cc index 94bae951c5..38622d0fb4 100644 --- a/src/Interface/Application/GuiCommands.cc +++ b/src/Interface/Application/GuiCommands.cc @@ -352,7 +352,7 @@ bool ToolkitUnpackerCommand::execute() auto add = !toolkit.networks.empty(); if (add) - SCIRunMainWindow::Instance()->addToolkit(QString::fromStdString(filename.leaf().stem().string()), + SCIRunMainWindow::Instance()->addToolkit(QString::fromStdString(filename.filename().stem().string()), QString::fromStdString(filename.parent_path().string()), toolkit); return add; diff --git a/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc b/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc index f55c2c6f42..00bc1c0398 100644 --- a/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc +++ b/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc @@ -915,7 +915,7 @@ void SCIRunMainWindow::loadToolkitsFromFile(const QString& filename) { auto file = command.get(Variables::Filename).toFilename(); - auto stem = QString::fromStdString(file.leaf().stem().string()); + auto stem = QString::fromStdString(file.filename().stem().string()); auto dir = QString::fromStdString(file.parent_path().string()); auto added = toolkitDirectories_.contains(stem); if (added && toolkitDirectories_[stem] == dir) diff --git a/src/Interface/Modules/Render/CMakeLists.txt b/src/Interface/Modules/Render/CMakeLists.txt index ffb568a22d..ae9ae015db 100644 --- a/src/Interface/Modules/Render/CMakeLists.txt +++ b/src/Interface/Modules/Render/CMakeLists.txt @@ -138,7 +138,7 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} Freetype::Freetype - ${SCI_LODEPNG_LIBRARY} + LodePNG::lodepng Tny::tny Qwt::Qwt #${SCI_QWT_LIBRARY} From a302be363fa642f9ec0a0886c8e7f9594b7c84d9 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 12 Mar 2026 12:43:29 -0600 Subject: [PATCH 073/140] qt flag not passed to modules highligher_ exposed in codeeditor when qt6 is enabled --- src/CMakeLists.txt | 29 ++++++++++++++++--- src/Interface/Application/CMakeLists.txt | 26 ++++++++++------- .../Base/CustomWidgets/CodeEditorWidgets.h | 2 ++ src/Main/CMakeLists.txt | 1 + 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90a39ff456..428c0cc493 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -998,6 +998,21 @@ IF(APPLE) MARK_AS_ADVANCED(AWK) ENDIF() +# 1) Real interface target +add_library(SCIRunCompileConfig INTERFACE) + +# 2) Namespaced alias (optional, for nice linking syntax) +add_library(SCIRun::CompileConfig ALIAS SCIRunCompileConfig) + +# 3) Put your global compile definitions here +# (Use your authoritative Qt selector: SCIRUN_QT_MAJOR is already in your top-level) +if (SCIRUN_QT_MAJOR STREQUAL "6") + target_compile_definitions(SCIRunCompileConfig INTERFACE SCIRUN_QT6_ENABLED) +endif() + +# You also set QT_NO_KEYWORDS globally in a few places—centralize it here: +target_compile_definitions(SCIRunCompileConfig INTERFACE QT_NO_KEYWORDS) + ######################################################################## # Configure documentation @@ -1126,10 +1141,6 @@ IF(NOT BUILD_HEADLESS) add_definitions(-DQT_NO_KEYWORDS) - if (QT_VERSION_MAJOR EQUAL 6) - add_definitions(-DSCIRUN_QT6_ENABLED) - endif() - if (QT_VERSION_MAJOR EQUAL 5) macro(QT_WRAP_UI arg1 arg2) qt5_wrap_ui(${arg1} ${arg2}) @@ -1154,6 +1165,10 @@ IF(NOT BUILD_HEADLESS) ENDIF() +if (QT_VERSION_MAJOR EQUAL 6) + add_compile_definitions(SCIRUN_QT6_ENABLED) +endif() + if (QT_VERSION_MAJOR EQUAL 5 AND Qt5Widgets_VERSION VERSION_LESS 5.13.0) add_definitions(-DOLDER_QT_SUPPORT_NEEDED) endif() @@ -1660,6 +1675,12 @@ ENDMACRO() MACRO(SCIRUN_ADD_LIBRARY library) ADD_LIBRARY(${library} ${ARGN}) + # Attach global compile definitions (Qt6, QT_NO_KEYWORDS, etc.) + if (SCIRUN_QT_MAJOR STREQUAL "6") + target_compile_definitions(${library} PUBLIC SCIRUN_QT6_ENABLED) + endif() + target_compile_definitions(${library} PUBLIC QT_NO_KEYWORDS) + if(MSVC) # TODO: # target_compile_options(${library} PRIVATE /W4 /WX) diff --git a/src/Interface/Application/CMakeLists.txt b/src/Interface/Application/CMakeLists.txt index 83ec6a6807..35dad897c7 100644 --- a/src/Interface/Application/CMakeLists.txt +++ b/src/Interface/Application/CMakeLists.txt @@ -188,25 +188,29 @@ SET(NonPythonInterface_ApplicationLinkLibraries IF(BUILD_WITH_PYTHON) -TARGET_LINK_LIBRARIES(Interface_Application - ${NonPythonInterface_ApplicationLinkLibraries} - Core_Python - SCIRunPythonAPI -) + TARGET_LINK_LIBRARIES(Interface_Application + PUBLIC + ${NonPythonInterface_ApplicationLinkLibraries} + Core_Python + SCIRunPythonAPI + ) ELSE() -TARGET_LINK_LIBRARIES(Interface_Application - ${NonPythonInterface_ApplicationLinkLibraries} -) + TARGET_LINK_LIBRARIES(Interface_Application + PUBLIC + ${NonPythonInterface_ApplicationLinkLibraries} + ) ENDIF() TARGET_LINK_LIBRARIES(Interface_Application - ${QT_NETWORK_LIBRARIES}) + PUBLIC + ${QT_NETWORK_LIBRARIES} +) IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Interface_Application) -ENDIF(BUILD_SHARED_LIBS) +ENDIF() -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h index 86bd5d69f6..4867fdc2c2 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h @@ -64,7 +64,9 @@ private Q_SLOTS: private: QWidget* lineNumberArea_; +#ifndef SCIRUN_QT6_ENABLED class CodeEditorHighlighter* highlighter_ {nullptr}; +#endif void createParenthesisSelection(int pos, const QColor& color); bool matchLeftParenthesis(const MatchingPair& type, QTextBlock currentBlock, int index, int numRightParentheses); bool matchRightParenthesis(const MatchingPair& type, QTextBlock currentBlock, int index, int numLeftParentheses); diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index e546b24912..375c531586 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -134,6 +134,7 @@ FOREACH(app ${APPS}) IF(BUILD_WITH_PYTHON) TARGET_LINK_LIBRARIES(${app} Core_Python + SCIRunPython ) ENDIF() ENDFOREACH() From 8e8f84d507986a20a226d1a5717bce8488659759 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 12 Mar 2026 14:27:06 -0600 Subject: [PATCH 074/140] python lib in main --- src/Interface/Application/CMakeLists.txt | 158 ++++++++++++---- .../Base/CustomWidgets/CodeEditorWidgets.cc | 2 +- .../Base/CustomWidgets/CodeEditorWidgets.h | 4 +- src/Main/CMakeLists.txt | 174 +++++++----------- 4 files changed, 196 insertions(+), 142 deletions(-) diff --git a/src/Interface/Application/CMakeLists.txt b/src/Interface/Application/CMakeLists.txt index 35dad897c7..2ece153acf 100644 --- a/src/Interface/Application/CMakeLists.txt +++ b/src/Interface/Application/CMakeLists.txt @@ -25,8 +25,15 @@ # DEALINGS IN THE SOFTWARE. # +# ========================= +# Interface_Application +# ========================= -SET(Interface_Application_SOURCES +# Allow building the GUI app without Python even if global BUILD_WITH_PYTHON=ON +# Set to OFF in the superbuild cache to remove all Python linkage from this app. +option(BUILD_INTERFACE_APPLICATION_WITH_PYTHON "Enable Python console in Interface_Application" ON) + +set(Interface_Application_SOURCES ClosestPortFinder.cc DeveloperConsole.cc GuiApplication.cc @@ -49,7 +56,6 @@ SET(Interface_Application_SOURCES NoteEditor.cc Port.cc PreferencesWindow.cc - PythonConsoleWidget.cc Settings.cc ShortcutsInterface.cc TagManagerWindow.cc @@ -65,7 +71,7 @@ SET(Interface_Application_SOURCES ModuleOptionsDialogConfiguration.cc ) -SET(Interface_Application_HEADERS +set(Interface_Application_HEADERS ClosestPortFinder.h DeveloperConsole.h GuiApplication.h @@ -87,7 +93,6 @@ SET(Interface_Application_HEADERS Port.h PositionProvider.h PreferencesWindow.h - PythonConsoleWidget.h TagManagerWindow.h NetworkEditor.h NetworkEditorControllerGuiProxy.h @@ -101,7 +106,7 @@ SET(Interface_Application_HEADERS ModuleOptionsDialogConfiguration.h ) -SET(Interface_Application_FORMS +set(Interface_Application_FORMS DeveloperConsole.ui Module.ui ConnectionStyleWizardPage.ui @@ -110,9 +115,6 @@ SET(Interface_Application_FORMS NoteEditor.ui Preferences.ui ProvenanceWindow.ui - PythonWizardPage.ui - PythonWizardCodePage.ui - IntWithPythonPage.ui SCIRunMainWindow.ui ShortcutsInterface.ui SubnetEditor.ui @@ -124,17 +126,34 @@ SET(Interface_Application_FORMS StateViewer.ui ) -SET(Interface_Application_RESOURCES -scirun5.qrc +# ---- Python-specific sources/UI (conditionally included) ---- +set(Interface_Application_PY_SOURCES + PythonConsoleWidget.cc +) +set(Interface_Application_PY_HEADERS + PythonConsoleWidget.h +) +set(Interface_Application_PY_FORMS + PythonWizardPage.ui + PythonWizardCodePage.ui + IntWithPythonPage.ui ) -QT_WRAP_UI(Interface_Application_FORMS_HEADERS "${Interface_Application_FORMS}") -QT_WRAP_CPP(Interface_Application_HEADERS_MOC "${Interface_Application_HEADERS}") -QT_ADD_RESOURCES(Interface_Application_RESOURCES_RCC "${Interface_Application_RESOURCES}") +if (BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) + list(APPEND Interface_Application_SOURCES ${Interface_Application_PY_SOURCES}) + list(APPEND Interface_Application_HEADERS ${Interface_Application_PY_HEADERS}) + list(APPEND Interface_Application_FORMS ${Interface_Application_PY_FORMS}) +endif() + +set(Interface_Application_RESOURCES scirun5.qrc) -IF(BUILD_BUNDLE) - ADD_DEFINITIONS(-DBUILD_BUNDLE) -ENDIF() +qt_wrap_ui(Interface_Application_FORMS_HEADERS "${Interface_Application_FORMS}") +qt_wrap_cpp(Interface_Application_HEADERS_MOC "${Interface_Application_HEADERS}") +qt_add_resources(Interface_Application_RESOURCES_RCC "${Interface_Application_RESOURCES}") + +if (BUILD_BUNDLE) + add_definitions(-DBUILD_BUNDLE) +endif() SCIRUN_ADD_LIBRARY(Interface_Application ${Interface_Application_SOURCES} @@ -144,8 +163,8 @@ SCIRUN_ADD_LIBRARY(Interface_Application ${Interface_Application_RESOURCES_RCC} ) -# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h -if (BUILD_WITH_PYTHON) +# ---- Add Python include dirs *only if this app builds with Python* ---- +if (BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) set(_PY_INCLUDES "") if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") @@ -171,7 +190,8 @@ if (BUILD_WITH_PYTHON) endif() endif() -SET(NonPythonInterface_ApplicationLinkLibraries +# ---- Link libraries ---- +set(NonPythonInterface_ApplicationLinkLibraries Dataflow_Network Core_Serialization_Network_Importer Core_Application @@ -181,36 +201,102 @@ SET(NonPythonInterface_ApplicationLinkLibraries Interface_Modules_Base Interface_Modules_Factory Core_Application_Preferences - ${SCI_BOOST_LIBRARY} + ${SCI_BOOST_LIBRARY} # Ensure this doesn't include Boost.Python for this app ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS} ) -IF(BUILD_WITH_PYTHON) - - TARGET_LINK_LIBRARIES(Interface_Application +if (BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) + target_link_libraries(Interface_Application PUBLIC ${NonPythonInterface_ApplicationLinkLibraries} Core_Python SCIRunPythonAPI ) - -ELSE() - - TARGET_LINK_LIBRARIES(Interface_Application +else() + target_link_libraries(Interface_Application PUBLIC ${NonPythonInterface_ApplicationLinkLibraries} ) +endif() -ENDIF() +target_link_libraries(Interface_Application PUBLIC ${QT_NETWORK_LIBRARIES}) -TARGET_LINK_LIBRARIES(Interface_Application - PUBLIC - ${QT_NETWORK_LIBRARIES} -) +if (BUILD_SHARED_LIBS) + add_definitions(-DBUILD_Interface_Application) +endif() + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) -IF(BUILD_SHARED_LIBS) - ADD_DEFINITIONS(-DBUILD_Interface_Application) -ENDIF() +# ------------------------------------------------------------- +# ---- Force the correct Python import lib per configuration +# & ignore wrong defaultlibs (MSVC only), like in Core_ConsoleApplication +# ------------------------------------------------------------- +if (MSVC AND BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) + # Neutralize wrong defaultlibs embedded by dependent .libs (e.g., Boost.Python) + target_link_options(Interface_Application PRIVATE + $<$:/NODEFAULTLIB:python313.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + ) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file + # Prefer the imported Python target from superbuild helpers + if (TARGET SCIRunPython::Python) + target_link_libraries(Interface_Application PRIVATE + $<$:SCIRunPython::Python> + $<$>:SCIRunPython::Python> + ) + elseif (TARGET Python::Python) + target_link_libraries(Interface_Application PRIVATE + $<$:Python::Python> + $<$>:Python::Python> + ) + else() + # Fallback to explicit path probing for python313[_d].lib within superbuild + set(_PY_DBG "") + set(_PY_REL "") + foreach(dir + "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/libs" + "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/lib" + "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64" + ) + if (EXISTS "${dir}/python313_d.lib" AND NOT _PY_DBG) + set(_PY_DBG "${dir}/python313_d.lib") + endif() + if (EXISTS "${dir}/python313.lib" AND NOT _PY_REL) + set(_PY_REL "${dir}/python313.lib") + endif() + endforeach() + + if (_PY_DBG) + target_link_libraries(Interface_Application PRIVATE + $<$:${_PY_DBG}> + ) + message(STATUS "[Interface/Application] Using ${_PY_DBG} for Debug") + else() + message(WARNING "[Interface/Application] Could not locate python313_d.lib; Debug link may still fail.") + endif() + + if (_PY_REL) + target_link_libraries(Interface_Application PRIVATE + $<$>:${_PY_REL}> + ) + message(STATUS "[Interface/Application] Using ${_PY_REL} for non-Debug") + else() + message(WARNING "[Interface/Application] Could not locate python313.lib; non-Debug link may fail.") + endif() + endif() +endif() + +# ------------------------------------------------------------- +# Hard-kill any stray literal python313 libs if they leaked in +# (e.g., via LINK_LIBRARIES property). This is a safety net. +# ------------------------------------------------------------- +if (MSVC) + get_target_property(_ia_link_libs Interface_Application LINK_LIBRARIES) + if (_ia_link_libs) + list(FILTER _ia_link_libs EXCLUDE REGEX ".*python313(_d)?\\.lib$") + set_property(TARGET Interface_Application PROPERTY LINK_LIBRARIES "${_ia_link_libs}") + endif() +endif() \ No newline at end of file diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc index 098c98206e..47010b08a1 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc @@ -46,7 +46,7 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) updateLineNumberAreaWidth(0); highlightCurrentLine(); -#ifndef SCIRUN_QT6_ENABLED +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) highlighter_ = new CodeEditorHighlighter(document()); #endif diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h index 4867fdc2c2..44d57d001c 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h @@ -64,7 +64,7 @@ private Q_SLOTS: private: QWidget* lineNumberArea_; -#ifndef SCIRUN_QT6_ENABLED +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) class CodeEditorHighlighter* highlighter_ {nullptr}; #endif void createParenthesisSelection(int pos, const QColor& color); @@ -95,7 +95,7 @@ class LineNumberArea : public QWidget CodeEditor *codeEditor; }; -#ifndef SCIRUN_QT6_ENABLED +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) class CodeEditorHighlighter : public QSyntaxHighlighter { Q_OBJECT diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 375c531586..3a0d13676d 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -118,128 +118,96 @@ ENDIF() FOREACH(app ${APPS}) TARGET_LINK_LIBRARIES(${app} + PRIVATE Core_Util_Legacy ) IF(BUILD_HEADLESS) TARGET_LINK_LIBRARIES(${app} + PRIVATE Core_ConsoleApplication ) ELSE() TARGET_LINK_LIBRARIES(${app} + PRIVATE Interface_Application ) ENDIF() + # ---- Only add Python linkage when requested ---- IF(BUILD_WITH_PYTHON) TARGET_LINK_LIBRARIES(${app} + PRIVATE Core_Python SCIRunPython + SCIRunPythonAPI ) - ENDIF() -ENDFOREACH() - - -IF(APPLE) - IF(${CMAKE_GENERATOR} MATCHES "Xcode") - SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib/$) - ELSE() - SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib) - ENDIF() -ENDIF() - -IF(APPLE) - -ELSE() - IF(WIN32) - IF(BUILD_WITH_PYTHON) - # TODO: change $ to $ when upgrading to cmake 3 - # TODO: copy python dll - ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} ARGS -E make_directory $/${PYTHON_MODULE_SEARCH_PATH} - COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCI_PYTHON_MODULE_LIBRARY_PATH} $/${PYTHON_MODULE_SEARCH_PATH} - WORKING_DIRECTORY ${SCIRun_BINARY_DIR}) - ENDIF() - - IF(NOT BUILD_HEADLESS) - # Note: installer is created from Release build only! - GET_TARGET_PROPERTY(QTCORENAME Qt${QT_VERSION_MAJOR}::Core LOCATION) - GET_TARGET_PROPERTY(QTGUINAME Qt${QT_VERSION_MAJOR}::Gui LOCATION) - GET_TARGET_PROPERTY(QTOPENGLNAME Qt${QT_VERSION_MAJOR}::OpenGL LOCATION) - if (QT_VERSION_MAJOR VERSION_GREATER 5) - GET_TARGET_PROPERTY(QTOPENGLWIDGETSNAME Qt${QT_VERSION_MAJOR}::OpenGLWidgets LOCATION) - endif() - GET_TARGET_PROPERTY(QTWIDGETSNAME Qt${QT_VERSION_MAJOR}::Widgets LOCATION) - GET_TARGET_PROPERTY(QTNETWORKNAME Qt${QT_VERSION_MAJOR}::Network LOCATION) - GET_TARGET_PROPERTY(QTCONCURRENTNAME Qt${QT_VERSION_MAJOR}::Concurrent LOCATION) - GET_TARGET_PROPERTY(QTSVGNAME Qt${QT_VERSION_MAJOR}::Svg LOCATION) - GET_TARGET_PROPERTY(QTPRINTSUPPORTNAME Qt${QT_VERSION_MAJOR}::PrintSupport LOCATION) - ENDIF() - INSTALL(TARGETS ${APPLICATION_NAME} RUNTIME DESTINATION bin) - IF(NOT BUILD_HEADLESS) - INSTALL(PROGRAMS - ${QTCORENAME} - ${QTGUINAME} - ${QTOPENGLNAME} - ${QTNETWORKNAME} - ${QTWIDGETSNAME} - ${QTCONCURRENTNAME} - ${QTSVGNAME} - ${QTPRINTSUPPORTNAME} - DESTINATION bin) - if (QT_VERSION_MAJOR VERSION_GREATER 5) - INSTALL(PROGRAMS - ${QTOPENGLWIDGETSNAME} - DESTINATION bin) + # ---- MSVC: Neutralize wrong defaultlibs and force correct python import lib ---- + if (MSVC) + # Ignore the wrong defaultlib per configuration + target_link_options(${app} PRIVATE + $<$:/NODEFAULTLIB:python313.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + $<$:/NODEFAULTLIB:python313_d.lib> + ) + + # Prefer imported python target from superbuild/helpers + if (TARGET SCIRunPython::Python) + target_link_libraries(${app} PRIVATE + $<$:SCIRunPython::Python> + $<$>:SCIRunPython::Python> + ) + elseif (TARGET Python::Python) + target_link_libraries(${app} PRIVATE + $<$:Python::Python> + $<$>:Python::Python> + ) + else() + # Fallback: probe superbuild locations for python313[_d].lib + set(_PY_DBG "") + set(_PY_REL "") + foreach(dir + "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/libs" + "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/lib" + "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64" + ) + if (EXISTS "${dir}/python313_d.lib" AND NOT _PY_DBG) + set(_PY_DBG "${dir}/python313_d.lib") + endif() + if (EXISTS "${dir}/python313.lib" AND NOT _PY_REL) + set(_PY_REL "${dir}/python313.lib") + endif() + endforeach() + + if (_PY_DBG) + target_link_libraries(${app} PRIVATE + $<$:${_PY_DBG}> + ) + message(STATUS "[${app}] Using ${_PY_DBG} for Debug") + else() + message(WARNING "[${app}] Could not locate python313_d.lib; Debug link may still fail.") + endif() + + if (_PY_REL) + target_link_libraries(${app} PRIVATE + $<$>:${_PY_REL}> + ) + message(STATUS "[${app}] Using ${_PY_REL} for non-Debug") + else() + message(WARNING "[${app}] Could not locate python313.lib; non-Debug link may fail.") + endif() endif() - INSTALL(PROGRAMS "${SCI_QWT_LIBRARY_DIR}/Release/${SCI_QWT_LIBRARY}.dll" DESTINATION bin CONFIGURATIONS Release) - INSTALL(PROGRAMS "${Qt_PATH}/plugins/platforms/qwindows.dll" DESTINATION bin/platforms CONFIGURATIONS Release) - ENDIF() - IF(BUILD_WITH_PYTHON) - INSTALL(PROGRAMS - ${SCI_PYTHON_DLL_PATH} - DESTINATION bin) - INSTALL(DIRECTORY "${SCI_PYTHON_MODULE_LIBRARY_PATH}/" DESTINATION bin/${PYTHON_MODULE_SEARCH_PATH}) - ENDIF() - - IF(BUILD_WITH_PYTHON) - INSTALL(PROGRAMS - ${SCI_PYTHON_DLL_PATH} - DESTINATION bin) - INSTALL(DIRECTORY "${SCI_PYTHON_MODULE_LIBRARY_PATH}/" DESTINATION bin/${PYTHON_MODULE_SEARCH_PATH}) - ENDIF() - - INSTALL(DIRECTORY "${SCIRun_BINARY_DIR}/Shaders" DESTINATION bin USE_SOURCE_PERMISSIONS) - INSTALL(DIRECTORY "${SCIRun_BINARY_DIR}/Assets" DESTINATION bin USE_SOURCE_PERMISSIONS) - INSTALL(DIRECTORY "${SCIRun_BINARY_DIR}/Fonts" DESTINATION bin USE_SOURCE_PERMISSIONS) - ELSE() - IF(BUILD_HEADLESS) - MESSAGE(STATUS "Building headless SCIRun") - ENDIF() - - IF(BUILD_WITH_PYTHON) - ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${PYTHON_MODULE_SEARCH_PATH} - COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCI_PYTHON_MODULE_LIBRARY_PATH} ${PYTHON_MODULE_SEARCH_PATH} - WORKING_DIRECTORY ${SCIRun_BINARY_DIR}) - IF(SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH AND EXISTS ${SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH}) - ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH} ${PYTHON_MODULE_SEARCH_PATH} - WORKING_DIRECTORY ${SCIRun_BINARY_DIR}) - ENDIF() - ENDIF() - ENDIF() -ENDIF() - -SET(NETWORKS_DESTINATION_DIR "./SCIRunNetworks") -# TODO: be careful of SCIRun network file extension -# TODO: refactor when networks are reorganized -INSTALL(DIRECTORY "${SCIRun_SOURCE_DIR}/ExampleNets/regression" DESTINATION ${NETWORKS_DESTINATION_DIR} - USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*.srn5") + # Safety net: strip any literal python313 libs that leaked in via LINK_LIBRARIES + get_target_property(_app_link_libs ${app} LINK_LIBRARIES) + if (_app_link_libs) + list(FILTER _app_link_libs EXCLUDE REGEX ".*python313(_d)?\\.lib$") + set_property(TARGET ${app} PROPERTY LINK_LIBRARIES "${_app_link_libs}") + endif() + endif() # MSVC + ENDIF() # BUILD_WITH_PYTHON +ENDFOREACH() -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file From b37362428d9b392531ba94316a13994eb83ebbce Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 12 Mar 2026 16:11:06 -0600 Subject: [PATCH 075/140] startup crash --- .../NetworkExecutionProgressBar.cc | 84 ++++++++++++++----- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/src/Interface/Application/NetworkExecutionProgressBar.cc b/src/Interface/Application/NetworkExecutionProgressBar.cc index 1824c167d5..82fb1bdb76 100644 --- a/src/Interface/Application/NetworkExecutionProgressBar.cc +++ b/src/Interface/Application/NetworkExecutionProgressBar.cc @@ -151,22 +151,33 @@ void SCIRunProgressBar::paintEvent(QPaintEvent*) QPainter p(this); { - //done modules: either green (good) or red (errored) - //qDebug() << "done modules: green" << status_->finished() << "red" << status_->errored(); - auto finished = status_->finished(); - auto errored = status_->errored(); - - auto fracFinished = (static_cast(finished) / (finished + errored)) * pos; + // done modules: either green (good) or red (errored) + // qDebug() << "done modules: green" << status_->finished() << "red" << status_->errored(); + const int finished = status_->finished(); + const int errored = status_->errored(); + const int doneTotal = finished + errored; + + // Avoid 0/0 => NaN, and keep geometry as ints in [0, pos]. + int wFinished = 0; + if (pos > 0 && doneTotal > 0) + { + const double frac = static_cast(finished) / static_cast(doneTotal); + // Round to reduce visual bias; clamp to [0, pos]. + wFinished = static_cast(std::round(frac * pos)); + if (wFinished < 0) wFinished = 0; + if (wFinished > pos) wFinished = pos; + } p.setPen(Qt::green); p.setBrush(QBrush(Qt::green)); - p.drawRect(0, 0, std::min((int)fracFinished, pos), height()); + if (wFinished > 0) p.drawRect(0, 0, wFinished, height()); - if (errored > 0) + const int wErrored = pos - wFinished; + if (errored > 0 && wErrored > 0) { p.setPen(Qt::red); p.setBrush(QBrush(Qt::red)); - p.drawRect(fracFinished, 0, pos - fracFinished, height()); + p.drawRect(wFinished, 0, wErrored, height()); } } @@ -184,26 +195,55 @@ void SCIRunProgressBar::paintEvent(QPaintEvent*) if (totalNotDone > 0) { - auto fracExecuting = (static_cast(executing) / totalNotDone) * leftToFill; + if (leftToFill < 0) leftToFill = 0; + auto fracExecuting = (static_cast(executing) / static_cast(totalNotDone)) * leftToFill; p.setPen(Qt::blue); p.setBrush(QBrush(Qt::blue)); - p.drawRect(pos, 0, fracExecuting, height()); - - auto fracWaiting = (static_cast(waiting) / totalNotDone) * leftToFill; - p.setPen(Qt::lightGray); - p.setBrush(QBrush(Qt::lightGray)); - p.drawRect(pos + fracExecuting, 0, fracWaiting, height()); - - auto fracUnexecuted = (static_cast(unexecuted) / totalNotDone) * leftToFill; - p.setPen(Qt::darkYellow); - p.setBrush(QBrush(Qt::darkYellow, Qt::BDiagPattern)); - p.drawRect(pos + fracExecuting + fracWaiting, 0, fracUnexecuted, height()); + { + int wExec = static_cast(std::floor(fracExecuting)); + if (wExec < 0) wExec = 0; + if (wExec > leftToFill) wExec = leftToFill; + if (wExec > 0) + p.drawRect(pos, 0, wExec, height()); + // reuse wExec below + auto fracWaiting = (static_cast(waiting) / static_cast(totalNotDone)) * leftToFill; + p.setPen(Qt::lightGray); + p.setBrush(QBrush(Qt::lightGray)); + int wWait = static_cast(std::floor(fracWaiting)); + if (wWait < 0) wWait = 0; + if (wWait > leftToFill - wExec) wWait = leftToFill - wExec; + if (wWait > 0) + p.drawRect(pos + wExec, 0, wWait, height()); + + auto fracUnexecuted = (static_cast(unexecuted) / static_cast(totalNotDone)) * leftToFill; + p.setPen(Qt::darkYellow); + p.setBrush(QBrush(Qt::darkYellow, Qt::BDiagPattern)); + int used = wExec + wWait; + int wUnex = leftToFill - used; + // In case of rounding loss, prefer to fill remaining space rather than leave gaps. + if (wUnex < 0) wUnex = 0; + if (wUnex > 0) + p.drawRect(pos + used, 0, wUnex, height()); + } + + //auto fracWaiting = (static_cast(waiting) / totalNotDone) * leftToFill; + //p.setPen(Qt::lightGray); + //p.setBrush(QBrush(Qt::lightGray)); + //p.drawRect(pos + fracExecuting, 0, fracWaiting, height()); + + //auto fracUnexecuted = (static_cast(unexecuted) / totalNotDone) * leftToFill; + //p.setPen(Qt::darkYellow); + //p.setBrush(QBrush(Qt::darkYellow, Qt::BDiagPattern)); + //p.drawRect(pos + fracExecuting + fracWaiting, 0, fracUnexecuted, height()); } else { p.setPen(Qt::lightGray); p.setBrush(QBrush(Qt::lightGray)); - p.drawRect(pos, 0, width(), height()); + int rem = width() - pos; + if (rem < 0) rem = 0; + if (rem > 0) + p.drawRect(pos, 0, rem, height()); } } From 4b589cf93dd7d6629c98eaa4205479a15d082c3c Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Mar 2026 14:44:26 -0600 Subject: [PATCH 076/140] lodepng on mac --- Superbuild/LodePNGWrapper_install.cmake | 62 ++++++++++++++++--------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/Superbuild/LodePNGWrapper_install.cmake b/Superbuild/LodePNGWrapper_install.cmake index 4629a4d2c4..5fb7d67ef2 100644 --- a/Superbuild/LodePNGWrapper_install.cmake +++ b/Superbuild/LodePNGWrapper_install.cmake @@ -1,5 +1,4 @@ -# LodePNGWrapper_install.cmake -# Manual install for the wrapper (avoids cmake_install.cmake path issues). +# Cross‑platform manual install script for LodePNG wrapper. foreach(req IN ITEMS WRAPPER_BUILD_DIR WRAPPER_SOURCE_DIR LODEPNG_INSTALL_DIR CONFIGURATION) if(NOT DEFINED ${req}) @@ -7,16 +6,19 @@ foreach(req IN ITEMS WRAPPER_BUILD_DIR WRAPPER_SOURCE_DIR LODEPNG_INSTALL_DIR CO endif() endforeach() -# Normalize inputs +# Normalize paths foreach(var IN ITEMS WRAPPER_BUILD_DIR WRAPPER_SOURCE_DIR LODEPNG_INSTALL_DIR CONFIGURATION) string(REGEX REPLACE "^\"|\"$" "" ${var} "${${var}}") file(TO_CMAKE_PATH "${${var}}" ${var}) endforeach() -# 1) Headers: copy whichever layout exists into /include/lodepng/lodepng.h +# --------------------------------------------------------------- +# 1) HEADER +# --------------------------------------------------------------- set(_hdr1 "${WRAPPER_SOURCE_DIR}/lodepng/lodepng.h") set(_hdr2 "${WRAPPER_SOURCE_DIR}/lodepng.h") -set(_hdr "") +set(_hdr "") + if(EXISTS "${_hdr1}") set(_hdr "${_hdr1}") elseif(EXISTS "${_hdr2}") @@ -26,32 +28,46 @@ endif() if(_hdr) file(MAKE_DIRECTORY "${LODEPNG_INSTALL_DIR}/include/lodepng") file(COPY "${_hdr}" DESTINATION "${LODEPNG_INSTALL_DIR}/include/lodepng") - message(STATUS "[LodePNGManualInstall] Copied header: ${_hdr} -> ${LODEPNG_INSTALL_DIR}/include/lodepng/") + message(STATUS "[LodePNGManualInstall] Copied header: ${_hdr}") else() message(WARNING "[LodePNGManualInstall] No lodepng.h found under: ${WRAPPER_SOURCE_DIR}") endif() -# 2) Library: choose name by configuration and copy to /lib -if(CONFIGURATION STREQUAL "Debug") - set(_libname "lodepngd.lib") +# --------------------------------------------------------------- +# 2) LIBRARY (Windows: .lib macOS/Linux: .a) +# --------------------------------------------------------------- + +if(WIN32) + # Multi‑config: Debug gets lodepngd.lib + if(CONFIGURATION STREQUAL "Debug") + set(_libname "lodepngd.lib") + else() + set(_libname "lodepng.lib") + endif() else() - set(_libname "lodepng.lib") + # Unix always produces liblodepng.a for static library + set(_libname "liblodepng.a") endif() -# VS output typically: //.lib -set(_libsrc "${WRAPPER_BUILD_DIR}/${CONFIGURATION}/${_libname}") file(MAKE_DIRECTORY "${LODEPNG_INSTALL_DIR}/lib") -if(EXISTS "${_libsrc}") - file(COPY "${_libsrc}" DESTINATION "${LODEPNG_INSTALL_DIR}/lib") - message(STATUS "[LodePNGManualInstall] Copied lib: ${_libsrc} -> ${LODEPNG_INSTALL_DIR}/lib/") +# Try // +set(_primary "${WRAPPER_BUILD_DIR}/${CONFIGURATION}/${_libname}") + +# Try / (single-config generators) +set(_alt "${WRAPPER_BUILD_DIR}/${_libname}") + +if(EXISTS "${_primary}") + file(COPY "${_primary}" DESTINATION "${LODEPNG_INSTALL_DIR}/lib") + message(STATUS "[LodePNGManualInstall] Copied lib: ${_primary}") +elseif(EXISTS "${_alt}") + file(COPY "${_alt}" DESTINATION "${LODEPNG_INSTALL_DIR}/lib") + message(STATUS "[LodePNGManualInstall] Copied lib (alt): ${_alt}") else() - # Fallback: try without config subdir (just in case) - set(_alt "${WRAPPER_BUILD_DIR}/${_libname}") - if(EXISTS "${_alt}") - file(COPY "${_alt}" DESTINATION "${LODEPNG_INSTALL_DIR}/lib") - message(STATUS "[LodePNGManualInstall] Copied lib (alt): ${_alt} -> ${LODEPNG_INSTALL_DIR}/lib/") - else() - message(FATAL_ERROR "[LodePNGManualInstall] Built library not found.\n Tried:\n ${_libsrc}\n ${_alt}") - endif() + message(FATAL_ERROR + "[LodePNGManualInstall] Built library not found.\n" + " Tried:\n" + " ${_primary}\n" + " ${_alt}" + ) endif() \ No newline at end of file From a4741ce82395f9ba810549001fe03e207d948248 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Mar 2026 14:51:46 -0600 Subject: [PATCH 077/140] added default qt path for easy testing on current macbook --- Superbuild/Superbuild.cmake | 53 +++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 4a39dbcd19..935368077d 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -98,8 +98,12 @@ set(SCIRUN_QT_MAJOR "6" CACHE STRING "Qt major version to use (5 or 6)") set_property(CACHE SCIRUN_QT_MAJOR PROPERTY STRINGS 5 6) set(QT5_MIN_VERSION "5.15.2") set(QT6_MIN_VERSION "6.3.0") -set(Qt_PATH "" CACHE PATH "Qt install prefix (e.g. C:/Qt/6.10.1/msvc2022_64)") +set(Qt_PATH "" CACHE PATH "Qt install prefix (e.g. C:/Qt/6.10.1/msvc2022_64 or /Users//Qt/6.10.2/macos)") + +# ------------------------- +# Default Qt path on Windows +# ------------------------- if (WIN32 AND NOT BUILD_HEADLESS) if (NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") set(_qt_default "C:/Qt/6.10.1/msvc2022_64") @@ -110,46 +114,77 @@ if (WIN32 AND NOT BUILD_HEADLESS) endif() endif() -# Validate +# ------------------------- +# Default Qt path on macOS +# ------------------------- +if (APPLE AND NOT BUILD_HEADLESS) + if (NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") + set(_qt_default "/Users/basisunus/Qt/6.10.2/macos") + if (IS_DIRECTORY "${_qt_default}") + message(STATUS "Qt_PATH not set or invalid — defaulting to ${_qt_default}") + set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) + endif() + endif() +endif() + +# ------------------------- +# Validate Qt_PATH +# ------------------------- if (NOT BUILD_HEADLESS) if (NOT IS_DIRECTORY "${Qt_PATH}") message(FATAL_ERROR "Qt_PATH invalid or not set.\n" - "Point it to the Qt install prefix with lib/, bin/, and lib/cmake/Qt[56].\n" - "Example: C:/Qt/6.10.1/msvc2022_64") + "Must point to a Qt install prefix with lib/, bin/, and lib/cmake/QtX.\n" + "Examples:\n" + " Windows: C:/Qt/6.10.1/msvc2022_64\n" + " macOS: /Users//Qt/6.10.2/macos\n" + ) endif() file(TO_CMAKE_PATH "${Qt_PATH}" _Qt_PREFIX) list(PREPEND CMAKE_PREFIX_PATH "${_Qt_PREFIX}") sb_prefix_append("${_Qt_PREFIX}") + # ------------------------- + # Qt6 + # ------------------------- if (SCIRUN_QT_MAJOR STREQUAL "6") set(QT_MIN_VERSION "${QT6_MIN_VERSION}") set(Qt6_DIR "${_Qt_PREFIX}/lib/cmake/Qt6") if (NOT EXISTS "${Qt6_DIR}/Qt6Config.cmake") message(FATAL_ERROR "Qt6Config.cmake not found at '${Qt6_DIR}'") endif() + find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL OpenGLWidgets HINTS "${Qt_PATH}" ) + message(STATUS "[superbuild] Using Qt6_DIR='${Qt6_DIR}'") + + # ------------------------- + # Qt5 + # ------------------------- elseif (SCIRUN_QT_MAJOR STREQUAL "5") set(QT_MIN_VERSION "${QT5_MIN_VERSION}") set(Qt5_DIR "${_Qt_PREFIX}/lib/cmake/Qt5") - if (NOT EXISTS "${Qt5_DIR}/Qt5Config.cmake") + if (NOT EXISTS "${Qt5_DIR}/Qt5Config.cmake}") message(FATAL_ERROR "Qt5Config.cmake not found at '${Qt5_DIR}'") endif() + find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL HINTS "${Qt_PATH}" ) + message(STATUS "[superbuild] Using Qt5_DIR='${Qt5_DIR}'") else() message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Got: '${SCIRUN_QT_MAJOR}'") endif() - # Locate qmake (needed by Qwt external) + # ------------------------- + # Locate qmake (needed by Qwt) + # ------------------------- if (SCIRUN_QT_MAJOR STREQUAL "6") if (TARGET Qt6::qmake) get_target_property(_qmake_path Qt6::qmake LOCATION) @@ -181,9 +216,11 @@ if (NOT BUILD_HEADLESS) if (NOT _qmake_path OR NOT EXISTS "${_qmake_path}") message(FATAL_ERROR "Could not locate qmake. Checked: ${_qmake_path}") endif() - set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH "Path to Qt qmake for building Qwt" FORCE) - message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") + set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH + "Path to Qt qmake for building Qwt" FORCE) + + message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") else() add_definitions(-DBUILD_HEADLESS) endif() From b69f06a8837d17f3c162a8c24d46bc9e3c9c8928 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Mar 2026 16:25:32 -0600 Subject: [PATCH 078/140] boost on mac --- Superbuild/BoostExternal.cmake | 198 ++++++++------------------------- 1 file changed, 45 insertions(+), 153 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 5797a0bbab..e76c7fae2c 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -63,90 +63,35 @@ foreach(_bl IN LISTS _BOOST_LIBS) list(APPEND _BOOST_LIBS_B2 "--with-${_bl}") endforeach() -# ========= Build knobs for b2 (must match your app's toolchain) ========= -# STATIC vs SHARED Boost libs (import lib + DLL if SHARED) -option(BOOST_USE_STATIC_LIBS "Build static Boost libraries" ON) +# ========= Cross‑platform Boost toolset detection ========= +# On Windows → use msvc +# On macOS → use clang-darwin (Boost’s preferred Darwin toolset) +# On Linux → use gcc or clang depending on CMAKE_CXX_COMPILER_ID -# Runtime library (/MD,/MDd shared; /MT,/MTd static) -option(BOOST_USE_STATIC_RUNTIME "Use static C runtime (/MT,/MTd). OFF = /MD,/MDd" OFF) - -# MSVC toolset (VS 2022 ~ 14.3). Override with -DB2_TOOLSET=msvc-14.3 if needed. -if(NOT DEFINED B2_TOOLSET) - set(B2_TOOLSET msvc-14.3) -endif() - -# ========= ExternalProject definition ========= -ExternalProject_Add(Boost_external - GIT_REPOSITORY ${_boost_git_url} - GIT_TAG ${_boost_git_tag} - GIT_SHALLOW FALSE - GIT_PROGRESS TRUE - - # Ensure submodules are available - UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir git submodule update --init --recursive - - BUILD_IN_SOURCE OFF - - # We will NOT use the CMake superproject for compiled libs - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) - -ExternalProject_Get_Property(Boost_external SOURCE_DIR) -ExternalProject_Get_Property(Boost_external BINARY_DIR) -ExternalProject_Get_Property(Boost_external INSTALL_DIR) - -# Optional Python wiring for Boost.Python -set(_B2_PY_ARGS "") -if(BOOST_ENABLE_PYTHON) - set(_PY_LIBDIR "") - if(DEFINED PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") - get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) - elseif(DEFINED PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") - get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) - elseif(DEFINED PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") - set(_PY_LIBDIR "${PYTHON_RUNTIME_DIR}") - endif() - - if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}" AND _PY_LIBDIR AND EXISTS "${_PY_LIBDIR}") - list(APPEND _B2_PY_ARGS - "include=${PYTHON_INCLUDE_DIR}" - "library-path=${_PY_LIBDIR}" - ) - message(STATUS "[Boost_ext] Will build Boost.Python against include='${PYTHON_INCLUDE_DIR}', libdir='${_PY_LIBDIR}'") +if(WIN32) + set(_B2_TOOLSET "msvc") +elseif(APPLE) + # Boost official recommended toolset on macOS + set(_B2_TOOLSET "clang-darwin") +else() # Linux / Unix + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set(_B2_TOOLSET "gcc") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(_B2_TOOLSET "clang") else() - message(WARNING "[Boost_ext] BOOST_ENABLE_PYTHON=ON but Python paths are incomplete.") + message(FATAL_ERROR "Unsupported compiler '${CMAKE_CXX_COMPILER_ID}' for Boost build") endif() endif() -# ========= Cross-platform b2 header staging ========= -# 1) Bootstrap b2 -if(WIN32) - set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) - set(_B2_CMD cmd /c .\\b2) -else() - set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) - set(_B2_CMD ./b2) -endif() - -ExternalProject_Add_Step(Boost_external bootstrap_b2 - COMMAND ${_B2_BOOTSTRAP_CMD} - WORKING_DIRECTORY ${SOURCE_DIR} - DEPENDEES update - COMMENT "Bootstrapping Boost.Build (b2)" -) +message(STATUS "[Boost_ext] Auto-selected b2 toolset: ${_B2_TOOLSET}") -# 2) Generate the full 'boost/' header tree -ExternalProject_Add_Step(Boost_external stage_headers - COMMAND ${_B2_CMD} headers - WORKING_DIRECTORY ${SOURCE_DIR} - DEPENDEES bootstrap_b2 - COMMENT "Running 'b2 headers' to generate the boost/ header tree" -) +# Allow manual override +if(DEFINED B2_TOOLSET) + message(STATUS "[Boost_ext] Overriding toolset with user B2_TOOLSET=${B2_TOOLSET}") + set(_B2_TOOLSET "${B2_TOOLSET}") +endif() -# ========= Build compiled libs with b2 (MSVC-style versioned names) ========= -# Determine b2 arguments +# ========= Linkage settings ========= if(BOOST_USE_STATIC_LIBS) set(_B2_LINK "link=static") else() @@ -154,110 +99,57 @@ else() endif() if(BOOST_USE_STATIC_RUNTIME) - set(_B2_RUNTIME_LINK "runtime-link=static") # /MT,/MTd + set(_B2_RUNTIME_LINK "runtime-link=static") else() - set(_B2_RUNTIME_LINK "runtime-link=shared") # /MD,/MDd + set(_B2_RUNTIME_LINK "runtime-link=shared") endif() -set(_B2_VARIANTS "variant=debug,release") # build both for multi-config IDEs +set(_B2_VARIANTS "variant=debug,release") + +# ========= b2 executable paths ========= +if(WIN32) + set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) + set(_B2_CMD cmd /c .\\b2) +else() + set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) + set(_B2_CMD ./b2) +endif() -# Keep all b2 artifacts under /b2-build +# ========= Build directory for b2 artifacts ========= set(_B2_BUILD_DIR ${BINARY_DIR}/b2-build) +# ========= Build command (cross‑platform) ========= ExternalProject_Add_Step(Boost_external build_b2_libs COMMAND ${_B2_CMD} -j${CMAKE_BUILD_PARALLEL_LEVEL} - address-model=64 architecture=x86 - toolset=${B2_TOOLSET} + toolset=${_B2_TOOLSET} threading=multi ${_B2_LINK} ${_B2_RUNTIME_LINK} ${_B2_VARIANTS} - --layout=versioned + --layout=tagged ${_BOOST_LIBS_B2} ${_B2_PY_ARGS} --build-dir=${_B2_BUILD_DIR} stage WORKING_DIRECTORY ${SOURCE_DIR} DEPENDEES stage_headers - COMMENT "Building Boost libs with b2 (versioned names for MSVC auto-link)" + COMMENT "Building Boost with b2 (cross‑platform toolset=${_B2_TOOLSET})" ) -# 3) Install staged libs into /lib +# ========= Install libs ========= ExternalProject_Add_Step(Boost_external install_b2_libs COMMAND ${CMAKE_COMMAND} -E make_directory /lib COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/stage/lib /lib DEPENDEES build_b2_libs - COMMENT "Installing b2-built Boost libs into /lib" + COMMENT "Installing Boost libs" ) -# 4) Copy the entire header tree into the install prefix +# ========= Install headers ========= ExternalProject_Add_Step(Boost_external install_full_headers COMMAND ${CMAKE_COMMAND} -E make_directory /include COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/boost /include/boost DEPENDEES stage_headers - COMMENT "Copying full Boost headers to /include/boost" -) - -# ========= Export properties for downstream ========= -# Convenience prefix -set(SCI_BOOST_PREFIX "${INSTALL_DIR}") - -# Concrete include/lib paths (SCIRun consumes these) -set(SCI_BOOST_INCLUDE "${SCI_BOOST_PREFIX}/include" CACHE PATH "Boost include directory" FORCE) -if (EXISTS "${SCI_BOOST_PREFIX}/lib64") - set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib64") -else() - set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib") -endif() -set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library directory" FORCE) - -# Since we are NOT installing BoostConfig.cmake, prefer MODULE mode if you still call find_package(Boost) -set(Boost_DIR "" CACHE PATH "No BoostConfig.cmake (b2 build). Use FindBoost (MODULE) if needed." FORCE) -set(Boost_NO_BOOST_CMAKE ON CACHE BOOL "Force FindBoost MODULE mode" FORCE) -set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix" FORCE) -set(BOOST_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "Boost install prefix (compat)" FORCE) -set(BOOST_LIBRARYDIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library dir (compat)" FORCE) - -# ========= Generate a 'UseBoost.cmake' for consumers (auto-link ON) ========= -# - Adds include and link search dirs. -# - If building shared Boost libs, define BOOST_ALL_DYN_LINK (ensures __declspec(dllimport)). -# - INTENTIONALLY does NOT define BOOST_ALL_NO_LIB (we want auto-link to inject versioned names). -set(SCI_BOOST_USE_FILE "${SCI_BOOST_PREFIX}/UseBoost.cmake") -set(_usefile "## Auto-generated UseBoost.cmake (b2 + autolink) -# Include dirs for headers -include_guard(GLOBAL) -if(EXISTS \"${SCI_BOOST_INCLUDE}\") - include_directories(\"${SCI_BOOST_INCLUDE}\") -endif() - -# Link search dir so MSVC can find the versioned .lib names injected by auto-link -if(EXISTS \"${SCI_BOOST_LIBRARY_DIR}\") - link_directories(\"${SCI_BOOST_LIBRARY_DIR}\") -endif() - -# If Boost was built as shared libs, define BOOST_ALL_DYN_LINK so import libs/DLLs are used -") -if(NOT BOOST_USE_STATIC_LIBS) - string(APPEND _usefile "add_compile_definitions(BOOST_ALL_DYN_LINK)\n") -endif() - -# Helpful hints for FindBoost (MODULE) if you still want to query variables -string(APPEND _usefile " -set(Boost_ROOT \"${SCI_BOOST_PREFIX}\") -set(BOOST_ROOT \"${SCI_BOOST_PREFIX}\") -set(BOOST_LIBRARYDIR \"${SCI_BOOST_LIBRARY_DIR}\") -") -file(WRITE "${SCI_BOOST_USE_FILE}" "${_usefile}") - -# ========= Diagnostics ========= -message(STATUS "[Boost_ext] INSTALL_DIR: ${SCI_BOOST_PREFIX}") -message(STATUS "[Boost_ext] Include dir: ${SCI_BOOST_INCLUDE}") -message(STATUS "[Boost_ext] Lib dir: ${SCI_BOOST_LIBRARY_DIR}") -message(STATUS "[Boost_ext] Built libs: ${_BOOST_LIBS}") -message(STATUS "[Boost_ext] b2 link type: ${_B2_LINK}") -message(STATUS "[Boost_ext] b2 runtime link: ${_B2_RUNTIME_LINK}") -message(STATUS "[Boost_ext] b2 toolset: ${B2_TOOLSET}") -message(STATUS "[Boost_ext] Use file: ${SCI_BOOST_USE_FILE}") -message(STATUS "[Boost_ext] Note: No BoostConfig.cmake installed (using b2). Auto-link on MSVC will inject versioned .lib names.") \ No newline at end of file + COMMENT "Installing Boost headers" +) \ No newline at end of file From d483a85d332e4a1dc805a436bc9d0a355a9f0473 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 17 Mar 2026 16:36:33 -0600 Subject: [PATCH 079/140] boost update --- Superbuild/BoostExternal.cmake | 134 ++++++++++++++++++++++++++++----- 1 file changed, 114 insertions(+), 20 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index e76c7fae2c..98b312bfc7 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -31,8 +31,6 @@ set(_boost_git_tag "v1.90.0") include(ExternalProject) # ========= Compiled library selection ========= -# Build ONLY the compiled libraries SCIRun needs to link. -# We will generate + install the FULL header tree separately via `b2 headers`. set(_BOOST_LIBS filesystem system @@ -42,7 +40,6 @@ set(_BOOST_LIBS serialization ) -# Optional compiled libs (usually OFF) option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" ON) option(BOOST_ENABLE_MPI "Build Boost.MPI if MPI is available" OFF) option(BOOST_ENABLE_TEST "Build Boost.Test (unit test framework)" OFF) @@ -57,23 +54,71 @@ if(BOOST_ENABLE_TEST) list(APPEND _BOOST_LIBS test) endif() -# Convert to b2 --with- arguments set(_BOOST_LIBS_B2 "") foreach(_bl IN LISTS _BOOST_LIBS) list(APPEND _BOOST_LIBS_B2 "--with-${_bl}") endforeach() -# ========= Cross‑platform Boost toolset detection ========= -# On Windows → use msvc -# On macOS → use clang-darwin (Boost’s preferred Darwin toolset) -# On Linux → use gcc or clang depending on CMAKE_CXX_COMPILER_ID +# ============================================================ +# 1) Define the external project FIRST (required by CMake) +# ============================================================ +ExternalProject_Add(Boost_external + GIT_REPOSITORY ${_boost_git_url} + GIT_TAG ${_boost_git_tag} + GIT_SHALLOW FALSE + GIT_PROGRESS TRUE + UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir git submodule update --init --recursive + + BUILD_IN_SOURCE OFF + + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) + +# ============================================================ +# 2) Retrieve SOURCE_DIR, BINARY_DIR, INSTALL_DIR +# ============================================================ +ExternalProject_Get_Property(Boost_external SOURCE_DIR) +ExternalProject_Get_Property(Boost_external BINARY_DIR) +ExternalProject_Get_Property(Boost_external INSTALL_DIR) + +# ============================================================ +# 3) Optional Boost.Python config +# ============================================================ +set(_B2_PY_ARGS "") +if(BOOST_ENABLE_PYTHON) + set(_PY_LIBDIR "") + + if(DEFINED PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") + get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) + elseif(DEFINED PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") + get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) + elseif(DEFINED PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") + set(_PY_LIBDIR "${PYTHON_RUNTIME_DIR}") + endif() + + if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}" AND + _PY_LIBDIR AND EXISTS "${_PY_LIBDIR}") + list(APPEND _B2_PY_ARGS + "include=${PYTHON_INCLUDE_DIR}" + "library-path=${_PY_LIBDIR}" + ) + message(STATUS "[Boost_ext] Will build Boost.Python against include='${PYTHON_INCLUDE_DIR}', libdir='${_PY_LIBDIR}'") + else() + message(WARNING "[Boost_ext] BOOST_ENABLE_PYTHON=ON but Python paths incomplete.") + endif() +endif() + +# ============================================================ +# 4) Cross‑platform Boost toolset detection +# ============================================================ if(WIN32) set(_B2_TOOLSET "msvc") elseif(APPLE) - # Boost official recommended toolset on macOS set(_B2_TOOLSET "clang-darwin") -else() # Linux / Unix +else() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(_B2_TOOLSET "gcc") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") @@ -85,13 +130,14 @@ endif() message(STATUS "[Boost_ext] Auto-selected b2 toolset: ${_B2_TOOLSET}") -# Allow manual override if(DEFINED B2_TOOLSET) - message(STATUS "[Boost_ext] Overriding toolset with user B2_TOOLSET=${B2_TOOLSET}") + message(STATUS "[Boost_ext] Overriding toolset with B2_TOOLSET=${B2_TOOLSET}") set(_B2_TOOLSET "${B2_TOOLSET}") endif() -# ========= Linkage settings ========= +# ============================================================ +# 5) Link options +# ============================================================ if(BOOST_USE_STATIC_LIBS) set(_B2_LINK "link=static") else() @@ -106,7 +152,9 @@ endif() set(_B2_VARIANTS "variant=debug,release") -# ========= b2 executable paths ========= +# ============================================================ +# 6) b2 executable and build dir +# ============================================================ if(WIN32) set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) set(_B2_CMD cmd /c .\\b2) @@ -115,10 +163,31 @@ else() set(_B2_CMD ./b2) endif() -# ========= Build directory for b2 artifacts ========= set(_B2_BUILD_DIR ${BINARY_DIR}/b2-build) -# ========= Build command (cross‑platform) ========= +# ============================================================ +# 7) bootstrap b2 +# ============================================================ +ExternalProject_Add_Step(Boost_external bootstrap_b2 + COMMAND ${_B2_BOOTSTRAP_CMD} + WORKING_DIRECTORY ${SOURCE_DIR} + DEPENDEES update + COMMENT "Bootstrapping b2" +) + +# ============================================================ +# 8) Run b2 headers +# ============================================================ +ExternalProject_Add_Step(Boost_external stage_headers + COMMAND ${_B2_CMD} headers + WORKING_DIRECTORY ${SOURCE_DIR} + DEPENDEES bootstrap_b2 + COMMENT "Generating Boost headers (b2 headers)" +) + +# ============================================================ +# 9) Build Boost libraries +# ============================================================ ExternalProject_Add_Step(Boost_external build_b2_libs COMMAND ${_B2_CMD} -j${CMAKE_BUILD_PARALLEL_LEVEL} @@ -134,10 +203,12 @@ ExternalProject_Add_Step(Boost_external build_b2_libs stage WORKING_DIRECTORY ${SOURCE_DIR} DEPENDEES stage_headers - COMMENT "Building Boost with b2 (cross‑platform toolset=${_B2_TOOLSET})" + COMMENT "Building Boost libs" ) -# ========= Install libs ========= +# ============================================================ +# 10) Install b2-built libs +# ============================================================ ExternalProject_Add_Step(Boost_external install_b2_libs COMMAND ${CMAKE_COMMAND} -E make_directory /lib COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/stage/lib /lib @@ -145,11 +216,34 @@ ExternalProject_Add_Step(Boost_external install_b2_libs COMMENT "Installing Boost libs" ) -# ========= Install headers ========= +# ============================================================ +# 11) Install full header tree +# ============================================================ ExternalProject_Add_Step(Boost_external install_full_headers COMMAND ${CMAKE_COMMAND} -E make_directory /include COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/boost /include/boost DEPENDEES stage_headers COMMENT "Installing Boost headers" -) \ No newline at end of file +) + +# ============================================================ +# 12) Export paths to superbuild +# ============================================================ +set(SCI_BOOST_PREFIX "${INSTALL_DIR}") + +set(SCI_BOOST_INCLUDE "${SCI_BOOST_PREFIX}/include" CACHE PATH "Boost include dir" FORCE) + +if(EXISTS "${SCI_BOOST_PREFIX}/lib64") + set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib64") +else() + set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib") +endif() + +set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library dir" FORCE) + +set(Boost_DIR "" CACHE PATH "" FORCE) +set(Boost_NO_BOOST_CMAKE ON CACHE BOOL "" FORCE) +set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "" FORCE) +set(BOOST_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "" FORCE) +set(BOOST_LIBRARYDIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "" FORCE) \ No newline at end of file From cfc1ba2ffb9d7884546f54465965df52f0faf65f Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 11:44:36 -0600 Subject: [PATCH 080/140] freetype include path on macos --- Superbuild/Superbuild.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 935368077d..4aea1099d7 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1226,7 +1226,8 @@ if(TARGET Freetype_external) _sb_scirun_wait_for(NAME freetype FILES - "${INSTALL_DIR}/include/ft2build.h" + "${INSTALL_DIR}/include/ft2build.h" # Windows + "${INSTALL_DIR}/include/freetype2/ft2build.h" # macOS/Linux "${INSTALL_DIR}/include/freetype2/freetype/config/ftheader.h" DIRS "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" ) From d248c5661dcc78f038d163eead2f4e0dc25146cf Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 12:40:57 -0600 Subject: [PATCH 081/140] freetype path was still incorrect on macos --- Superbuild/Superbuild.cmake | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 4aea1099d7..2e5c436468 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1224,11 +1224,22 @@ endif() if(TARGET Freetype_external) ExternalProject_Get_Property(Freetype_external INSTALL_DIR) - _sb_scirun_wait_for(NAME freetype - FILES - "${INSTALL_DIR}/include/ft2build.h" # Windows - "${INSTALL_DIR}/include/freetype2/ft2build.h" # macOS/Linux - "${INSTALL_DIR}/include/freetype2/freetype/config/ftheader.h" - DIRS "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" - ) + if(WIN32) + # Windows installs flat include layout + _sb_scirun_wait_for(NAME freetype + FILES + "${INSTALL_DIR}/include/ft2build.h" + DIRS + "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" + ) + else() + # macOS / Linux layout (freetype2/) + _sb_scirun_wait_for(NAME freetype + FILES + "${INSTALL_DIR}/include/freetype2/ft2build.h" + "${INSTALL_DIR}/include/freetype2/freetype/config/ftheader.h" + DIRS + "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" + ) + endif() endif() \ No newline at end of file From ca2438702c0362e758e41f78d1acce5227124e83 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 12:49:08 -0600 Subject: [PATCH 082/140] lodepng path incorrect on macos similar to freetype --- Superbuild/Superbuild.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 2e5c436468..d3d5383df9 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1116,18 +1116,20 @@ endif() if(TARGET LodePng_external) ExternalProject_Get_Property(LodePng_external INSTALL_DIR) - set(_lodepng_libdir "") + # Detect lib directory + set(_lodepng_libdir "${INSTALL_DIR}/lib") if(EXISTS "${INSTALL_DIR}/lib64") set(_lodepng_libdir "${INSTALL_DIR}/lib64") - else() - set(_lodepng_libdir "${INSTALL_DIR}/lib") endif() - # Wait for both header and at least one library (Debug or Release) + # Cross‑platform library names set(_lp_wait_files - "${INSTALL_DIR}/include/lodepng/lodepng.h" - "${_lodepng_libdir}/lodepng.lib" - "${_lodepng_libdir}/lodepngd.lib" + "${INSTALL_DIR}/include/lodepng/lodepng.h" # header (same everywhere) + "${_lodepng_libdir}/liblodepng.a" # macOS/Linux static + "${_lodepng_libdir}/liblodepng.so" # Linux shared + "${_lodepng_libdir}/liblodepng.dylib" # macOS shared + "${_lodepng_libdir}/lodepng.lib" # Windows + "${_lodepng_libdir}/lodepngd.lib" # Windows Debug ) _sb_scirun_wait_for(NAME lodepng From 8c9258de1bd79408416276b8814e69e159b5f70b Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 13:07:21 -0600 Subject: [PATCH 083/140] lodepng lib not set correctly for mac --- Superbuild/Superbuild.cmake | 46 ++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index d3d5383df9..7024fb7022 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1116,26 +1116,44 @@ endif() if(TARGET LodePng_external) ExternalProject_Get_Property(LodePng_external INSTALL_DIR) - # Detect lib directory + # Detect lib dir set(_lodepng_libdir "${INSTALL_DIR}/lib") if(EXISTS "${INSTALL_DIR}/lib64") set(_lodepng_libdir "${INSTALL_DIR}/lib64") endif() - # Cross‑platform library names - set(_lp_wait_files - "${INSTALL_DIR}/include/lodepng/lodepng.h" # header (same everywhere) - "${_lodepng_libdir}/liblodepng.a" # macOS/Linux static - "${_lodepng_libdir}/liblodepng.so" # Linux shared - "${_lodepng_libdir}/liblodepng.dylib" # macOS shared - "${_lodepng_libdir}/lodepng.lib" # Windows - "${_lodepng_libdir}/lodepngd.lib" # Windows Debug - ) + if(WIN32) + # Windows produces .lib and optionally .pdb + _sb_scirun_wait_for(NAME lodepng + FILES + "${INSTALL_DIR}/include/lodepng/lodepng.h" + "${_lodepng_libdir}/lodepng.lib" + "${_lodepng_libdir}/lodepngd.lib" + DIRS + "${INSTALL_DIR}/include" "${_lodepng_libdir}" + ) - _sb_scirun_wait_for(NAME lodepng - FILES ${_lp_wait_files} - DIRS "${INSTALL_DIR}/include" "${_lodepng_libdir}" - ) + elseif(APPLE) + # macOS: static lib only (liblodepng.a) + _sb_scirun_wait_for(NAME lodepng + FILES + "${INSTALL_DIR}/include/lodepng/lodepng.h" + "${_lodepng_libdir}/liblodepng.a" + DIRS + "${INSTALL_DIR}/include" "${_lodepng_libdir}" + ) + + else() # Linux / other Unix + # Linux may build static or shared lib + _sb_scirun_wait_for(NAME lodepng + FILES + "${INSTALL_DIR}/include/lodepng/lodepng.h" + "${_lodepng_libdir}/liblodepng.a" + "${_lodepng_libdir}/liblodepng.so" + DIRS + "${INSTALL_DIR}/include" "${_lodepng_libdir}" + ) + endif() endif() if(TARGET SQLite_external) From 3b7de4bb8378c94a5dd35675074dd2b4aa14336f Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 14:27:45 -0600 Subject: [PATCH 084/140] python verification incorrect for mac --- Superbuild/Superbuild.cmake | 62 +++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 7024fb7022..90064cb91e 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1218,26 +1218,68 @@ if(TARGET Cleaver2_external) add_dependencies(SCIRun_external Cleaver2_external-copy_headers) endif() -# --- (NEW) Ensure SCIRun configure waits for Python_external build --- +# --- Cross‑platform: Ensure SCIRun configure waits for Python_external build --- if(BUILD_WITH_PYTHON AND TARGET Python_external) + + # Make SCIRun_external configure depend on Python_external finishing configure if(COMMAND ExternalProject_Add_StepDependencies) ExternalProject_Add_StepDependencies(SCIRun_external configure Python_external) message(STATUS "[superbuild] SCIRun_external: 'configure' will wait on Python_external.") endif() - # (Optional best-effort) Also wait for presence of python import libs/exe - # This makes the configure step defer until the files exist on disk. - set(_py_src_dir "${ep_base}/Source/Python_external") - set(_py_pcbuild "${_py_src_dir}/PCbuild/amd64") - # Gather possible byproducts - file(GLOB _py_wait_libs "${_py_pcbuild}/python3*.lib") - set(_py_wait_files "${_py_pcbuild}/python.exe") - list(APPEND _py_wait_files ${_py_wait_libs}) - if(_py_wait_files) + ExternalProject_Get_Property(Python_external SOURCE_DIR) + ExternalProject_Get_Property(Python_external INSTALL_DIR) + + if(WIN32) + # ----------------------------- + # Windows CPython (MSVC / PCbuild) + # ----------------------------- + set(_py_pcbuild "${SOURCE_DIR}/PCbuild/amd64") + + # python.exe + python3XY.lib + file(GLOB _py_wait_libs "${_py_pcbuild}/python3*.lib") + set(_py_wait_files + "${_py_pcbuild}/python.exe" + ${_py_wait_libs} + ) + _sb_scirun_wait_for(NAME python FILES ${_py_wait_files} DIRS "${_py_pcbuild}" ) + + else() + # ----------------------------- + # macOS / Linux CPython build + # ----------------------------- + # The CMake build of CPython installs: + # bin/python3, python3.x, python3.xm + # lib/libpython3.x.{a,so,dylib} + + set(_py_bin "${INSTALL_DIR}/bin") + set(_py_lib "${INSTALL_DIR}/lib") + + # executables: python3, python3.x, python3.xm + file(GLOB _py_wait_bins + "${_py_bin}/python3" + "${_py_bin}/python3.*" + ) + + # libraries: .a (static), .so (Linux), .dylib (macOS) + file(GLOB _py_wait_libs + "${_py_lib}/libpython*.a" + "${_py_lib}/libpython*.so" + "${_py_lib}/libpython*.dylib" + ) + + _sb_scirun_wait_for(NAME python + FILES + ${_py_wait_bins} + ${_py_wait_libs} + DIRS + "${_py_bin}" + "${_py_lib}" + ) endif() endif() From 5e5df621d0f18213ab6a853e59242090bf80bfd1 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 14:43:01 -0600 Subject: [PATCH 085/140] python lib path still incorrect --- Superbuild/Superbuild.cmake | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 90064cb91e..ffd54e7c1e 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1218,25 +1218,24 @@ if(TARGET Cleaver2_external) add_dependencies(SCIRun_external Cleaver2_external-copy_headers) endif() -# --- Cross‑platform: Ensure SCIRun configure waits for Python_external build --- +# --- Cross-platform: Ensure SCIRun configure waits for Python_external build --- if(BUILD_WITH_PYTHON AND TARGET Python_external) - # Make SCIRun_external configure depend on Python_external finishing configure + # Make SCIRun_external configure wait for Python_external first if(COMMAND ExternalProject_Add_StepDependencies) ExternalProject_Add_StepDependencies(SCIRun_external configure Python_external) message(STATUS "[superbuild] SCIRun_external: 'configure' will wait on Python_external.") endif() ExternalProject_Get_Property(Python_external SOURCE_DIR) - ExternalProject_Get_Property(Python_external INSTALL_DIR) + ExternalProject_Get_Property(Python_external BINARY_DIR) if(WIN32) # ----------------------------- - # Windows CPython (MSVC / PCbuild) + # Windows CPython (PCbuild) # ----------------------------- set(_py_pcbuild "${SOURCE_DIR}/PCbuild/amd64") - # python.exe + python3XY.lib file(GLOB _py_wait_libs "${_py_pcbuild}/python3*.lib") set(_py_wait_files "${_py_pcbuild}/python.exe" @@ -1250,26 +1249,24 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) else() # ----------------------------- - # macOS / Linux CPython build + # macOS / Linux CPython (CMake build) + # Python DOES NOT install into + # The built interpreter is in BINARY_DIR # ----------------------------- - # The CMake build of CPython installs: - # bin/python3, python3.x, python3.xm - # lib/libpython3.x.{a,so,dylib} + set(_py_bin_dir "${BINARY_DIR}/bin") + set(_py_lib_dir "${BINARY_DIR}/lib") - set(_py_bin "${INSTALL_DIR}/bin") - set(_py_lib "${INSTALL_DIR}/lib") - - # executables: python3, python3.x, python3.xm + # python3, python3.x, python3.xm file(GLOB _py_wait_bins - "${_py_bin}/python3" - "${_py_bin}/python3.*" + "${_py_bin_dir}/python3" + "${_py_bin_dir}/python3.*" ) - # libraries: .a (static), .so (Linux), .dylib (macOS) + # libpythonX.Y.{a,so,dylib} file(GLOB _py_wait_libs - "${_py_lib}/libpython*.a" - "${_py_lib}/libpython*.so" - "${_py_lib}/libpython*.dylib" + "${_py_lib_dir}/libpython*.a" + "${_py_lib_dir}/libpython*.so" + "${_py_lib_dir}/libpython*.dylib" ) _sb_scirun_wait_for(NAME python @@ -1277,8 +1274,8 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) ${_py_wait_bins} ${_py_wait_libs} DIRS - "${_py_bin}" - "${_py_lib}" + "${_py_bin_dir}" + "${_py_lib_dir}" ) endif() endif() From 3f5dd251bfed13b9101f4a4f200ecf4c851c9bc9 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 14:50:28 -0600 Subject: [PATCH 086/140] bin dir for python not found --- Superbuild/Superbuild.cmake | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index ffd54e7c1e..5685811de4 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1221,7 +1221,6 @@ endif() # --- Cross-platform: Ensure SCIRun configure waits for Python_external build --- if(BUILD_WITH_PYTHON AND TARGET Python_external) - # Make SCIRun_external configure wait for Python_external first if(COMMAND ExternalProject_Add_StepDependencies) ExternalProject_Add_StepDependencies(SCIRun_external configure Python_external) message(STATUS "[superbuild] SCIRun_external: 'configure' will wait on Python_external.") @@ -1232,7 +1231,7 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) if(WIN32) # ----------------------------- - # Windows CPython (PCbuild) + # Windows CPython build # ----------------------------- set(_py_pcbuild "${SOURCE_DIR}/PCbuild/amd64") @@ -1249,24 +1248,19 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) else() # ----------------------------- - # macOS / Linux CPython (CMake build) - # Python DOES NOT install into - # The built interpreter is in BINARY_DIR + # macOS/Linux: CPython via CMake + # No install step; all outputs live directly in BINARY_DIR # ----------------------------- - set(_py_bin_dir "${BINARY_DIR}/bin") - set(_py_lib_dir "${BINARY_DIR}/lib") - - # python3, python3.x, python3.xm file(GLOB _py_wait_bins - "${_py_bin_dir}/python3" - "${_py_bin_dir}/python3.*" + "${BINARY_DIR}/python3" + "${BINARY_DIR}/python3.*" + "${BINARY_DIR}/python" ) - # libpythonX.Y.{a,so,dylib} file(GLOB _py_wait_libs - "${_py_lib_dir}/libpython*.a" - "${_py_lib_dir}/libpython*.so" - "${_py_lib_dir}/libpython*.dylib" + "${BINARY_DIR}/libpython*.a" + "${BINARY_DIR}/libpython*.dylib" + "${BINARY_DIR}/libpython*.so" ) _sb_scirun_wait_for(NAME python @@ -1274,8 +1268,7 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) ${_py_wait_bins} ${_py_wait_libs} DIRS - "${_py_bin_dir}" - "${_py_lib_dir}" + "${BINARY_DIR}" ) endif() endif() From 837022b3882745909298ba65f2663170cec3623e Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 15:02:04 -0600 Subject: [PATCH 087/140] tetgen lib not found --- Superbuild/Superbuild.cmake | 53 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 5685811de4..6970c167ec 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -910,36 +910,39 @@ if(WITH_TETGEN AND TARGET Tetgen_external) endif() endif() - # Library dir candidates - set(_tet_lib_dir "") + # Library directory if(EXISTS "${INSTALL_DIR}/lib64") set(_tet_lib_dir "${INSTALL_DIR}/lib64") - elseif(EXISTS "${INSTALL_DIR}/lib") + else() set(_tet_lib_dir "${INSTALL_DIR}/lib") endif() - # Try to locate the actual library file + # ---- Cross‑platform library detection ---- set(_tet_lib "") - if(_tet_lib_dir AND EXISTS "${_tet_lib_dir}") - set(_tet_names tetgen libtetgen tet tetgen_static tetgen1.6 tet1.6) - foreach(_nm IN LISTS _tet_names) - if(EXISTS "${_tet_lib_dir}/${_nm}.lib") - set(_tet_lib "${_tet_lib_dir}/${_nm}.lib") - break() - endif() - endforeach() - if(NOT _tet_lib) - file(GLOB _cands - "${_tet_lib_dir}/*.lib" - "${_tet_lib_dir}/**/tet*.lib" - "${_tet_lib_dir}/**/libtet*.lib" - ) - list(SORT _cands) - list(LENGTH _cands _n) - if(_n GREATER 0) - list(GET _cands 0 _tet_lib) - endif() - endif() + + # macOS/Linux static/shared libs + file(GLOB _tet_lib_candidates + "${_tet_lib_dir}/libtet.a" + "${_tet_lib_dir}/libtetgen.a" + "${_tet_lib_dir}/libtetgen*.a" + "${_tet_lib_dir}/libtet.dylib" + "${_tet_lib_dir}/libtetgen.dylib" + ) + + # Windows import libs + file(GLOB _tet_lib_candidates_win + "${_tet_lib_dir}/tetgen.lib" + "${_tet_lib_dir}/tet.lib" + "${_tet_lib_dir}/libtetgen.lib" + ) + + # Combine lists + list(APPEND _tet_lib_candidates ${_tet_lib_candidates_win}) + + # Pick first valid candidate + list(LENGTH _tet_lib_candidates _n) + if(_n GREATER 0) + list(GET _tet_lib_candidates 0 _tet_lib) endif() # Normalize for cache args @@ -948,11 +951,13 @@ if(WITH_TETGEN AND TARGET Tetgen_external) else() set(_tet_inc_norm "") endif() + if(_tet_lib_dir) file(TO_CMAKE_PATH "${_tet_lib_dir}" _tet_lib_dir_norm) else() set(_tet_lib_dir_norm "") endif() + if(_tet_lib) file(TO_CMAKE_PATH "${_tet_lib}" _tet_lib_norm) else() From 4668d224b602f45d1a92d8dee863e3c7fdaddc5d Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 18 Mar 2026 15:13:47 -0600 Subject: [PATCH 088/140] lodepng and glew not defined for mac --- Superbuild/Superbuild.cmake | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 6970c167ec..ba8047e247 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -477,6 +477,47 @@ if(BUILD_WITH_PYTHON AND TARGET Python_external) endif() _export_config_dir(LodePNG LodePng_external "") +if(TARGET LodePng_external) + ExternalProject_Get_Property(LodePng_external INSTALL_DIR) + + set(_lp_inc "${INSTALL_DIR}/include") + set(_lp_lib "") + + # lib folder + if(EXISTS "${INSTALL_DIR}/lib64") + set(_lp_libdir "${INSTALL_DIR}/lib64") + else() + set(_lp_libdir "${INSTALL_DIR}/lib") + endif() + + # Cross‑platform library detection + if(WIN32) + if(EXISTS "${_lp_libdir}/lodepng.lib") + set(_lp_lib "${_lp_libdir}/lodepng.lib") + elseif(EXISTS "${_lp_libdir}/lodepngd.lib") + set(_lp_lib "${_lp_libdir}/lodepngd.lib") + endif() + elseif(APPLE) + if(EXISTS "${_lp_libdir}/liblodepng.a") + set(_lp_lib "${_lp_libdir}/liblodepng.a") + elseif(EXISTS "${_lp_libdir}/liblodepng.dylib") + set(_lp_lib "${_lp_libdir}/liblodepng.dylib") + endif() + else() + if(EXISTS "${_lp_libdir}/liblodepng.so") + set(_lp_lib "${_lp_libdir}/liblodepng.so") + elseif(EXISTS "${_lp_libdir}/liblodepng.a") + set(_lp_lib "${_lp_libdir}/liblodepng.a") + endif() + endif() + + # Define imported target + add_library(LodePNG::lodepng UNKNOWN IMPORTED GLOBAL) + set_property(TARGET LodePNG::lodepng PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_lp_inc}") + set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION "${_lp_lib}") + + message(STATUS "[superbuild] Created imported target LodePNG::lodepng = ${_lp_lib}") +endif() # Include/lib hints (guarded by target existence) _sb_export_inc_lib(Freetype Freetype_external) @@ -522,6 +563,17 @@ if(WIN32 AND TARGET Glew_external) message(STATUS "[superbuild] Installed custom GLEWConfig.cmake at ${_glew_cfg_dir}") endif() +if(APPLE AND NOT TARGET GLEW::GLEW) + find_package(GLEW REQUIRED) + + add_library(GLEW::GLEW UNKNOWN IMPORTED GLOBAL) + set_property(TARGET GLEW::GLEW PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + set_property(TARGET GLEW::GLEW PROPERTY + IMPORTED_LOCATION "${GLEW_LIBRARIES}") + + message(STATUS "[superbuild] Using system GLEW: ${GLEW_LIBRARIES}") +endif() # Tell SCIRun where the Tny config lives if(TARGET Tny_wrapper_external) From 497086b199ce4ba39f60a5b2367e354270874f49 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 11:35:04 -0600 Subject: [PATCH 089/140] glew not built on mac --- Superbuild/Superbuild.cmake | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index ba8047e247..53d3a8d707 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -263,9 +263,7 @@ ADD_EXTERNAL(${SUPERBUILD_DIR}/TnyExternal.cmake Tny_external) ADD_EXTERNAL(${SUPERBUILD_DIR}/LodePngExternal.cmake LodePng_external) ADD_EXTERNAL(${SUPERBUILD_DIR}/Cleaver2External.cmake Cleaver2_external) -if(WIN32) - ADD_EXTERNAL(${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external) -endif() +ADD_EXTERNAL(${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external) if(BUILD_WITH_PYTHON) ADD_EXTERNAL(${SUPERBUILD_DIR}/PythonExternal.cmake Python_external) @@ -563,17 +561,6 @@ if(WIN32 AND TARGET Glew_external) message(STATUS "[superbuild] Installed custom GLEWConfig.cmake at ${_glew_cfg_dir}") endif() -if(APPLE AND NOT TARGET GLEW::GLEW) - find_package(GLEW REQUIRED) - - add_library(GLEW::GLEW UNKNOWN IMPORTED GLOBAL) - set_property(TARGET GLEW::GLEW PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") - set_property(TARGET GLEW::GLEW PROPERTY - IMPORTED_LOCATION "${GLEW_LIBRARIES}") - - message(STATUS "[superbuild] Using system GLEW: ${GLEW_LIBRARIES}") -endif() # Tell SCIRun where the Tny config lives if(TARGET Tny_wrapper_external) From 4d399f886c0382aec17a7a85ecba64bb2f6d6d58 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 11:46:14 -0600 Subject: [PATCH 090/140] glew copy failed on mac --- Superbuild/GlewExternal.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index 2b6c4d7657..38cf1fdb30 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -78,6 +78,8 @@ ExternalProject_Add_Step(Glew_external copy_headers COMMENT "[Glew_external] Copying GLEW headers to ${_glew_inst}/include" ) +ExternalProject_Add_StepTargets(Glew_external copy_headers) + # Resolve the actual library name produced set(GLEW_SOURCE_DIR ${_glew_src}) set(GLEW_INSTALL_DIR ${_glew_inst}) @@ -109,7 +111,7 @@ add_custom_target(Glew_export ALL -D TEMPLATE:PATH="${_template}" -D OUT_FILE:PATH="${GLEW_INSTALL_DIR}/lib/cmake/GLEW/GLEWConfig.cmake" -P "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" - DEPENDS Glew_external copy_headers + DEPENDS Glew_external Glew_external-copy_headers COMMENT "[Glew_external] Writing GLEWConfig.cmake" ) From a52aff2f283f963934b3136dedb41815cf262fa0 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 12:32:40 -0600 Subject: [PATCH 091/140] glew dependency order --- Superbuild/Superbuild.cmake | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 53d3a8d707..9522f05b94 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -296,17 +296,6 @@ if(NOT BUILD_HEADLESS AND WITH_QWT) ADD_EXTERNAL(${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external) endif() -# Ensure header copy steps run before SCIRun config/build -if(TARGET Glew_external-copy_headers) - add_dependencies(SCIRun_external Glew_external-copy_headers) -endif() -if(TARGET Tny_external-copy_headers) - add_dependencies(SCIRun_external Tny_external-copy_headers) -endif() -if(TARGET SQLite_external-copy_headers) - add_dependencies(SCIRun_external SQLite_external-copy_headers) -endif() - # ========================= # Exporters (config dir / include & lib dir) # ========================= @@ -1082,6 +1071,17 @@ ExternalProject_Add(SCIRun_external INSTALL_COMMAND "" ) +# Ensure header copy steps run before SCIRun config/build +if(TARGET Glew_external-copy_headers) + add_dependencies(SCIRun_external Glew_external-copy_headers) +endif() +if(TARGET Tny_external-copy_headers) + add_dependencies(SCIRun_external Tny_external-copy_headers) +endif() +if(TARGET SQLite_external-copy_headers) + add_dependencies(SCIRun_external SQLite_external-copy_headers) +endif() + # ========================= # BOOST: header staging (no delete; copy only) + waits # ========================= From a2a867e5bc66407d425dca5af2a6cef827e93536 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 15:38:25 -0600 Subject: [PATCH 092/140] glew win and mac settings difference --- Superbuild/Superbuild.cmake | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 9522f05b94..5a23365ea5 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -455,7 +455,7 @@ else() endif() # Prefer config dirs when possible (Windows GLEW sometimes exports one) -if(WIN32 AND TARGET Glew_external) +if(TARGET Glew_external) _export_config_dir(GLEW Glew_external "") endif() @@ -517,9 +517,28 @@ _sb_export_inc_lib(SQLite SQLite_external) if(WITH_TETGEN AND TARGET Tetgen_external) # <- lowercase g _sb_export_inc_lib(Tetgen Tetgen_external) endif() -if(WIN32 AND TARGET Glew_external) +if(TARGET Glew_external) _sb_export_inc_lib(GLEW Glew_external) endif() +# macOS GLEW imported target +if(APPLE AND TARGET Glew_external) + ExternalProject_Get_Property(Glew_external INSTALL_DIR) + + set(_glew_inc "${INSTALL_DIR}/include") + set(_glew_libdir "${INSTALL_DIR}/lib") + + if(EXISTS "${_glew_libdir}/libGLEW.a") + set(_glew_lib "${_glew_libdir}/libGLEW.a") + elseif(EXISTS "${_glew_libdir}/libGLEW.dylib") + set(_glew_lib "${_glew_libdir}/libGLEW.dylib") + endif() + + add_library(GLEW::GLEW UNKNOWN IMPORTED GLOBAL) + set_property(TARGET GLEW::GLEW PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_glew_inc}") + set_property(TARGET GLEW::GLEW PROPERTY IMPORTED_LOCATION "${_glew_lib}") + + message(STATUS "[superbuild] Created GLEW::GLEW for macOS = ${_glew_lib}") +endif() # --- Install custom GLEWConfig.cmake for SCIRun --- if(WIN32 AND TARGET Glew_external) From e2f9f6139ab38bcb556c35333f79c27025309176 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 15:47:34 -0600 Subject: [PATCH 093/140] case mismatch of glew file name on mac --- Superbuild/Superbuild.cmake | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 5a23365ea5..b8728abb58 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -527,10 +527,24 @@ if(APPLE AND TARGET Glew_external) set(_glew_inc "${INSTALL_DIR}/include") set(_glew_libdir "${INSTALL_DIR}/lib") - if(EXISTS "${_glew_libdir}/libGLEW.a") - set(_glew_lib "${_glew_libdir}/libGLEW.a") - elseif(EXISTS "${_glew_libdir}/libGLEW.dylib") - set(_glew_lib "${_glew_libdir}/libGLEW.dylib") + # Accept both libGLEW.* and libglew.* (uppercase or lowercase) + set(_glew_candidates + "${_glew_libdir}/libGLEW.a" + "${_glew_libdir}/libGLEW.dylib" + "${_glew_libdir}/libglew.a" + "${_glew_libdir}/libglew.dylib" + ) + + unset(_glew_lib) + foreach(_f IN LISTS _glew_candidates) + if(EXISTS "${_f}") + set(_glew_lib "${_f}") + break() + endif() + endforeach() + + if(NOT _glew_lib) + message(FATAL_ERROR "[superbuild] Could not locate GLEW library in ${_glew_libdir}") endif() add_library(GLEW::GLEW UNKNOWN IMPORTED GLOBAL) From 8b76fff1bf70a93c70b6fc7b55bc3756e37873ea Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 15:52:01 -0600 Subject: [PATCH 094/140] still not right case --- Superbuild/Superbuild.cmake | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index b8728abb58..1b360d5802 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -527,26 +527,25 @@ if(APPLE AND TARGET Glew_external) set(_glew_inc "${INSTALL_DIR}/include") set(_glew_libdir "${INSTALL_DIR}/lib") - # Accept both libGLEW.* and libglew.* (uppercase or lowercase) - set(_glew_candidates - "${_glew_libdir}/libGLEW.a" - "${_glew_libdir}/libGLEW.dylib" - "${_glew_libdir}/libglew.a" - "${_glew_libdir}/libglew.dylib" + # Robust: match any case (libGLEW.a / libglew.a / .dylib / versioned) + file(GLOB _glew_candidates + "${_glew_libdir}/libGLEW*.a" + "${_glew_libdir}/libGLEW*.dylib" + "${_glew_libdir}/libglew*.a" + "${_glew_libdir}/libglew*.dylib" ) - unset(_glew_lib) - foreach(_f IN LISTS _glew_candidates) - if(EXISTS "${_f}") - set(_glew_lib "${_f}") - break() - endif() - endforeach() - - if(NOT _glew_lib) - message(FATAL_ERROR "[superbuild] Could not locate GLEW library in ${_glew_libdir}") + list(LENGTH _glew_candidates _n) + if(_n EQUAL 0) + message(FATAL_ERROR + "[superbuild] No GLEW library found in ${_glew_libdir}. " + "Expected libGLEW.a or libglew.a etc." + ) endif() + # Use the first match + list(GET _glew_candidates 0 _glew_lib) + add_library(GLEW::GLEW UNKNOWN IMPORTED GLOBAL) set_property(TARGET GLEW::GLEW PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_glew_inc}") set_property(TARGET GLEW::GLEW PROPERTY IMPORTED_LOCATION "${_glew_lib}") From 5a7e702a19ec6ae5b7927ffcc7d6c82019bf07d2 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 16:03:31 -0600 Subject: [PATCH 095/140] glew install cross platform --- Superbuild/Superbuild.cmake | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 1b360d5802..1a90645131 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -553,23 +553,28 @@ if(APPLE AND TARGET Glew_external) message(STATUS "[superbuild] Created GLEW::GLEW for macOS = ${_glew_lib}") endif() -# --- Install custom GLEWConfig.cmake for SCIRun --- -if(WIN32 AND TARGET Glew_external) +# --- Install custom GLEWConfig.cmake for SCIRun on ALL platforms --- +if(TARGET Glew_external) ExternalProject_Get_Property(Glew_external INSTALL_DIR) set(_glew_inc "${INSTALL_DIR}/include") - set(_glew_lib "") + set(_glew_libdir "${INSTALL_DIR}/lib") - # Choose lib folder - if(EXISTS "${INSTALL_DIR}/lib/glew.lib") - set(_glew_lib "${INSTALL_DIR}/lib/glew.lib") - elseif(EXISTS "${INSTALL_DIR}/lib64/glew.lib") - set(_glew_lib "${INSTALL_DIR}/lib64/glew.lib") - else() - message(FATAL_ERROR "[superbuild] Could not find glew.lib in Glew_external install.") + # Match both uppercase/lowercase and static/shared + file(GLOB _glew_candidates + "${_glew_libdir}/libGLEW*.a" + "${_glew_libdir}/libGLEW*.dylib" + "${_glew_libdir}/libglew*.a" + "${_glew_libdir}/libglew*.dylib" + ) + + if(NOT _glew_candidates) + message(FATAL_ERROR "[superbuild] Could not locate a GLEW library in ${_glew_libdir}") endif() - # Where to place the config + list(GET _glew_candidates 0 _glew_lib) + + # Create config folder set(_glew_cfg_dir "${INSTALL_DIR}/lib/cmake/GLEW") file(MAKE_DIRECTORY "${_glew_cfg_dir}") @@ -620,7 +625,7 @@ list(APPEND SCIRUN_CACHE_ARGS ) # Tell SCIRun where to find GLEW config -if(WIN32 AND TARGET Glew_external) +if(TARGET Glew_external) ExternalProject_Get_Property(Glew_external INSTALL_DIR) list(APPEND SCIRUN_CACHE_ARGS "-DGLEW_DIR:PATH=${INSTALL_DIR}/lib/cmake/GLEW") endif() From fe61d7ab3711c1622d4e212a9a2171c39c1a59f1 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 16:23:20 -0600 Subject: [PATCH 096/140] find_package for glew in scirun cmake --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 428c0cc493..d50d3e6aa1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1255,7 +1255,7 @@ endfunction() # --- GLEW include discovery (target-first, robust fallback) --- set(_SCIRUN_USE_GLEW_TARGET FALSE) set(_glew_inc_from_target "") - +find_package(GLEW REQUIRED) # 1) If the package created GLEW::GLEW, prefer its include path if(TARGET GLEW::GLEW) get_target_property(_glew_inc_from_target GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES) From accab9dc69e0122589a5e2dcff43e070924a430b Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 16:33:17 -0600 Subject: [PATCH 097/140] lode png not configed correctly for mac --- src/CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d50d3e6aa1..e3c526c8e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -297,31 +297,54 @@ if(NOT TARGET Teem::teem) endif() endif() -# --- LodePNG imported target fallback (manual) --- -# Use the superbuild install paths. Adjust if your layout differs. +# --- LodePNG imported target fallback (manual, cross‑platform) --- if(NOT TARGET LodePNG::lodepng) set(_LPNG_ROOT "${CMAKE_BINARY_DIR}/../Externals/Install/LodePng_external") set(_LPNG_INC "${_LPNG_ROOT}/include") - set(_LPNG_LIBD "${_LPNG_ROOT}/lib/lodepngd.lib") - set(_LPNG_LIBR "${_LPNG_ROOT}/lib/lodepng.lib") + set(_LPNG_LIBDIR "${_LPNG_ROOT}/lib") - if(EXISTS "${_LPNG_LIBD}" OR EXISTS "${_LPNG_LIBR}") - add_library(LodePNG::lodepng STATIC IMPORTED) - set_target_properties(LodePNG::lodepng PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_LPNG_INC}" - ) - if(EXISTS "${_LPNG_LIBD}") - set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_DEBUG "${_LPNG_LIBD}") + # Cross‑platform library detection + set(_LPNG_LIB "") + + if(WIN32) + if(EXISTS "${_LPNG_LIBDIR}/lodepngd.lib") + set(_LPNG_LIB "${_LPNG_LIBDIR}/lodepngd.lib") + elseif(EXISTS "${_LPNG_LIBDIR}/lodepng.lib") + set(_LPNG_LIB "${_LPNG_LIBDIR}/lodepng.lib") endif() - if(EXISTS "${_LPNG_LIBR}") - set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_RELEASE "${_LPNG_LIBR}") - set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_RELWITHDEBINFO "${_LPNG_LIBR}") - set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION_MINSIZEREL "${_LPNG_LIBR}") + elseif(APPLE) + # macOS: static or shared + if(EXISTS "${_LPNG_LIBDIR}/liblodepng.a") + set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.a") + elseif(EXISTS "${_LPNG_LIBDIR}/liblodepng.dylib") + set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.dylib") endif() - message(STATUS "[SCIRun] LodePNG::lodepng imported: inc='${_LPNG_INC}', " - "dbg='${_LPNG_LIBD}', rel='${_LPNG_LIBR}'") else() - message(WARNING "[SCIRun] LodePNG libs not found under '${_LPNG_ROOT}/lib'. Build LodePng_external first.") + # Linux: static or shared + if(EXISTS "${_LPNG_LIBDIR}/liblodepng.a") + set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.a") + elseif(EXISTS "${_LPNG_LIBDIR}/liblodepng.so") + set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.so") + endif() + endif() + + if(_LPNG_LIB) + add_library(LodePNG::lodepng UNKNOWN IMPORTED) + + set_target_properties(LodePNG::lodepng PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_LPNG_INC}" + IMPORTED_LOCATION "${_LPNG_LIB}" + ) + + message(STATUS + "[SCIRun] LodePNG::lodepng imported:" + " inc='${_LPNG_INC}', lib='${_LPNG_LIB}'" + ) + else() + message(WARNING + "[SCIRun] LodePNG not found under '${_LPNG_LIBDIR}'. " + "Build LodePng_external first." + ) endif() endif() From 6c30d81cab698a9f830b2b83ae2dee81e33cdaed Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 20 Mar 2026 16:46:49 -0600 Subject: [PATCH 098/140] boost include dir --- Superbuild/Superbuild.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 1a90645131..cfee57fc3c 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -408,6 +408,9 @@ if(TARGET Boost_external) endif() sb_prefix_append("${INSTALL_DIR}") endif() +list(APPEND SCIRUN_CACHE_ARGS + "-DSCI_BOOST_INCLUDE:PATH=${SCI_BOOST_INCLUDE}" +) # ========================= # Export externals (config or include/lib) From 5cb4b4ce435515793b7034bf88caafed55436c12 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 21 Apr 2026 15:59:39 -0600 Subject: [PATCH 099/140] updated to match refactor-to-master --- .gitmodules | 2 +- Superbuild/BoostConfig.cmake.in | 187 +- Superbuild/BoostExternal.cmake | 453 +++-- Superbuild/Cleaver2External.cmake | 87 +- Superbuild/CtkExternal.cmake | 1 - Superbuild/EigenExternal.cmake | 33 +- Superbuild/FreetypeExternal.cmake | 123 +- Superbuild/GLMExternal.cmake | 30 +- Superbuild/GlewExternal.cmake | 112 +- Superbuild/GoogleTestExternal.cmake | 1 - Superbuild/LibPNGExternal.cmake | 1 - Superbuild/LodePngExternal.cmake | 48 +- Superbuild/OsprayExternal.cmake | 37 +- Superbuild/PythonConfig.cmake.in | 56 +- Superbuild/PythonExternal.cmake | 129 +- Superbuild/QwtExternal.cmake | 48 +- Superbuild/SQLiteExternal.cmake | 191 +- Superbuild/SpdLogExternal.cmake | 28 +- Superbuild/Superbuild.cmake | 1593 +++-------------- Superbuild/TeemExternal.cmake | 101 +- Superbuild/TetgenExternal.cmake | 64 +- Superbuild/TnyExternal.cmake | 96 +- Superbuild/WriteProjectConfigJam.cmake | 3 + Superbuild/ZlibExternal.cmake | 116 +- scripts/clean-boost-only.ps1 | 16 + scripts/clean-build.ps1 | 54 + src/CMakeLists.txt | 1457 ++------------- .../Algorithms/BrainStimulator/CMakeLists.txt | 1 - src/Core/Algorithms/DataIO/CMakeLists.txt | 1 - src/Core/Algorithms/Describe/CMakeLists.txt | 2 - src/Core/Algorithms/Factory/CMakeLists.txt | 4 +- .../Algorithms/Factory/Tests/CMakeLists.txt | 1 - src/Core/Algorithms/Field/CMakeLists.txt | 103 +- .../Legacy/Converter/CMakeLists.txt | 107 +- .../Algorithms/Legacy/DataIO/CMakeLists.txt | 109 +- .../Algorithms/Legacy/Fields/CMakeLists.txt | 183 +- .../Legacy/FiniteElements/CMakeLists.txt | 1 + .../Algorithms/Legacy/Inverse/CMakeLists.txt | 1 - src/Core/Algorithms/Math/CMakeLists.txt | 4 - .../Algorithms/Visualization/CMakeLists.txt | 1 - src/Core/Application/CMakeLists.txt | 30 - .../Application/Preferences/CMakeLists.txt | 1 - src/Core/Application/Session/CMakeLists.txt | 1 - src/Core/Basis/CMakeLists.txt | 4 + src/Core/Command/CMakeLists.txt | 1 - src/Core/CommandLine/CMakeLists.txt | 4 +- src/Core/ConsoleApplication/CMakeLists.txt | 170 +- src/Core/DatabaseManager/CMakeLists.txt | 101 +- src/Core/Datatypes/CMakeLists.txt | 68 +- .../Datatypes/Legacy/Field/CMakeLists.txt | 1 - src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt | 116 +- src/Core/Datatypes/Mesh/CMakeLists.txt | 1 - src/Core/Exceptions/CMakeLists.txt | 1 + src/Core/GeometryPrimitives/CMakeLists.txt | 181 +- src/Core/ImportExport/GenericIEPlugin.h | 1 - src/Core/Logging/CMakeLists.txt | 1 + src/Core/Logging/LoggerFwd.h | 2 +- src/Core/Matlab/CMakeLists.txt | 175 +- src/Core/Parser/ArrayMathInterpreter.cc | 2 +- src/Core/Parser/CMakeLists.txt | 120 +- src/Core/Python/CMakeLists.txt | 391 +--- src/Core/Thread/CMakeLists.txt | 2 +- src/Core/Utils/CMakeLists.txt | 2 +- src/Core/Utils/Legacy/CMakeLists.txt | 1 - src/Core/Utils/Legacy/FileUtils.cc | 40 +- src/Dataflow/Engine/Controller/CMakeLists.txt | 90 +- src/Dataflow/Engine/Python/CMakeLists.txt | 243 +-- .../Engine/Scheduler/Tests/CMakeLists.txt | 1 - src/Dataflow/Network/CMakeLists.txt | 1 - .../Serialization/Network/CMakeLists.txt | 2 +- .../Network/Importer/CMakeLists.txt | 1 - .../NetworkDescriptionSerialization.cc | 25 +- .../Network/Tools/CMakeLists.txt | 1 - src/Externals/spire/CMakeLists.txt | 7 +- src/Externals/submodules/googletest | 2 +- src/Graphics/Datatypes/CMakeLists.txt | 1 - src/Graphics/Glyphs/CMakeLists.txt | 3 - src/Graphics/Widgets/CMakeLists.txt | 3 - src/Interface/Application/CMakeLists.txt | 186 +- .../NetworkExecutionProgressBar.cc | 84 +- src/Interface/Modules/Base/CMakeLists.txt | 1 - .../CustomWidgets/CTK/ctkBasePopupWidget.cpp | 12 - .../CustomWidgets/CTK/ctkBasePopupWidget.h | 10 - .../Base/CustomWidgets/CTK/ctkPopupWidget.cpp | 12 +- .../Base/CustomWidgets/CTK/ctkPopupWidget.h | 11 +- .../Base/CustomWidgets/CodeEditorWidgets.cc | 82 +- .../Base/CustomWidgets/CodeEditorWidgets.h | 11 +- .../Modules/BrainStimulator/CMakeLists.txt | 1 - src/Interface/Modules/Bundle/CMakeLists.txt | 2 - src/Interface/Modules/DataIO/CMakeLists.txt | 1 - src/Interface/Modules/Factory/CMakeLists.txt | 2 - src/Interface/Modules/Fields/CMakeLists.txt | 2 - .../Modules/FiniteElements/CMakeLists.txt | 1 - src/Interface/Modules/Forward/CMakeLists.txt | 1 - src/Interface/Modules/Inverse/CMakeLists.txt | 10 +- .../SolveInverseProblemWithTikhonovDialog.cc | 10 +- src/Interface/Modules/Math/CMakeLists.txt | 23 +- src/Interface/Modules/Math/PlotDialog.cc | 22 +- src/Interface/Modules/Math/PlotDialog.h | 4 +- src/Interface/Modules/Matlab/CMakeLists.txt | 1 - src/Interface/Modules/Python/CMakeLists.txt | 51 +- src/Interface/Modules/Render/CMakeLists.txt | 18 +- .../Modules/Render/Tests/CMakeLists.txt | 1 - .../Modules/Render/ViewSceneControlsDock.cc | 4 +- src/Interface/Modules/String/CMakeLists.txt | 1 - src/Interface/Modules/Teem/CMakeLists.txt | 3 - .../Modules/Visualization/CMakeLists.txt | 1 - src/LATEST_TAG.txt | 2 +- src/Main/CMakeLists.txt | 199 +- src/Modules/DataIO/CMakeLists.txt | 1 - src/Modules/DataIO/ReadField.cc | 2 +- src/Modules/DataIO/Tests/CMakeLists.txt | 1 - src/Modules/DataIO/WriteField.cc | 2 +- src/Modules/Factory/CMakeLists.txt | 27 - src/Modules/Factory/Generator/CMakeLists.txt | 4 +- src/Modules/Fields/CMakeLists.txt | 1 - src/Modules/Legacy/Fields/CMakeLists.txt | 71 +- .../Legacy/Fields/InterfaceWithTetGen.h | 2 - .../Legacy/Matlab/DataIO/Tests/CMakeLists.txt | 1 - .../Legacy/Teem/Converters/CMakeLists.txt | 79 +- src/Modules/Legacy/Teem/DataIO/CMakeLists.txt | 71 +- src/Modules/Legacy/Teem/Misc/CMakeLists.txt | 79 +- src/Modules/Legacy/Teem/Tend/CMakeLists.txt | 77 +- src/Modules/Math/CMakeLists.txt | 49 +- src/Modules/Python/CMakeLists.txt | 250 +-- src/Modules/Python/InterfaceWithPython.h | 2 - src/Modules/Python/LoopEnd.h | 2 - src/Modules/Python/LoopStart.h | 2 - .../Python/ModuleStateModifierTester.h | 2 - src/Modules/Visualization/CMakeLists.txt | 2 +- src/Testing/ModuleTestBase/CMakeLists.txt | 1 - src/Testing/Utils/CMakeLists.txt | 1 - 132 files changed, 1904 insertions(+), 6976 deletions(-) create mode 100644 Superbuild/WriteProjectConfigJam.cmake create mode 100644 scripts/clean-boost-only.ps1 create mode 100644 scripts/clean-build.ps1 diff --git a/.gitmodules b/.gitmodules index 8297bf73a9..b03a4cbe8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/Externals/submodules/googletest"] path = src/Externals/submodules/googletest - url = https://github.com/google/googletest.git + url = https://github.com/CIBC-Internal/googletest.git diff --git a/Superbuild/BoostConfig.cmake.in b/Superbuild/BoostConfig.cmake.in index fbfc876a84..37be542103 100644 --- a/Superbuild/BoostConfig.cmake.in +++ b/Superbuild/BoostConfig.cmake.in @@ -1,6 +1,181 @@ -set(SCI_BOOST_INCLUDE "@SCI_BOOST_INCLUDE@") - -# These are IMPORTED targets created by FooBarTargets.cmake -set(SCI_BOOST_LIBRARY @SCI_BOOST_LIBRARY@) -set(SCI_BOOST_LIBRARY_DIR "@SCI_BOOST_LIBRARY_DIR@") -set(SCI_BOOST_USE_FILE "@SCI_BOOST_USE_FILE@") +# ============================================================================ +# BoostConfig.cmake - generated by SCIRun superbuild +# ============================================================================ + +@PACKAGE_INIT@ + +set(Boost_FOUND TRUE) + +# --------------------------------------------------------------------------- +# Paths +# --------------------------------------------------------------------------- +set(Boost_INCLUDE_DIRS "@SCI_BOOST_INCLUDE@") +set(Boost_LIBRARY_DIR "@SCI_BOOST_LIBRARY_DIR@") + +# --------------------------------------------------------------------------- +# Helper: define Boost imported library target (cross-platform) +# --------------------------------------------------------------------------- +function(_scirun_define_boost_target lib) + # If Boost already created the target, just ensure includes + if(TARGET Boost::${lib}) + set_target_properties(Boost::${lib} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}" + ) + return() + endif() + + # Boost.Atomic is header-only on macOS + if(APPLE AND lib STREQUAL "atomic") + add_library(Boost::atomic INTERFACE IMPORTED) + set_target_properties(Boost::atomic PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}" + ) + return() + endif() + + # Create imported library target + add_library(Boost::${lib} UNKNOWN IMPORTED) + set_target_properties(Boost::${lib} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}" + ) + + # Boost.Python static macro (SCIRun convention) + if(lib MATCHES "^python") + set_target_properties(Boost::${lib} PROPERTIES + INTERFACE_COMPILE_DEFINITIONS BOOST_PYTHON_STATIC_LIB + ) + endif() + + # Detect architecture + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_boost_arch "x64") + else() + set(_boost_arch "x32") + endif() + + set(_release_lib "") + set(_debug_lib "") + + # ------------------------------------------------------------------------- + # Windows: SCIRun-built Boost uses tagged .lib names + # ------------------------------------------------------------------------- + if(WIN32) + file(GLOB _all_candidates + "${Boost_LIBRARY_DIR}/libboost_${lib}-*.lib" + ) + + list(FILTER _all_candidates INCLUDE REGEX "-${_boost_arch}-") + + if(NOT _all_candidates) + message(FATAL_ERROR + "Boost '${lib}' not found for architecture ${_boost_arch}\n" + "Directory: ${Boost_LIBRARY_DIR}" + ) + endif() + + # ----------------------------------------------------------------------- + # ABI-aware Debug / Release selection (Boost 1.8+) + # + # Rules: + # - Debug libraries contain '-g' + # - Release libraries do NOT contain '-g' + # - 'y' means Python enabled and may appear in BOTH + # ----------------------------------------------------------------------- + + # Debug candidates + set(_dbg_candidates "${_all_candidates}") + list(FILTER _dbg_candidates INCLUDE REGEX "-g") + + if(_dbg_candidates) + list(GET _dbg_candidates 0 _debug_lib) + endif() + + # Release candidates + set(_rel_candidates "${_all_candidates}") + list(FILTER _rel_candidates EXCLUDE REGEX "-g") + + if(_rel_candidates) + list(GET _rel_candidates 0 _release_lib) + endif() + + # ------------------------------------------------------------------------- + # macOS / Linux + # ------------------------------------------------------------------------- + else() + file(GLOB _all_candidates + "${Boost_LIBRARY_DIR}/libboost_${lib}.a" + "${Boost_LIBRARY_DIR}/libboost_${lib}-mt.a" + "${Boost_LIBRARY_DIR}/libboost_${lib}.dylib" + "${Boost_LIBRARY_DIR}/libboost_${lib}-mt.dylib" + ) + + if(NOT _all_candidates) + message(FATAL_ERROR + "Boost library '${lib}' could not be resolved.\n" + "Directory: ${Boost_LIBRARY_DIR}\n" + "Platform: ${CMAKE_SYSTEM_NAME}" + ) + endif() + + list(GET _all_candidates 0 _release_lib) + set(_debug_lib "${_release_lib}") + endif() + + # ------------------------------------------------------------------------- + # Fail fast if resolution failed + # ------------------------------------------------------------------------- + if(NOT _release_lib OR NOT _debug_lib) + message(FATAL_ERROR + "Boost library '${lib}' could not be resolved for both configurations.\n" + "All candidates:\n ${_all_candidates}" + ) + endif() + + set_target_properties(Boost::${lib} PROPERTIES + IMPORTED_CONFIGURATIONS "Release;Debug" + IMPORTED_LOCATION_RELEASE "${_release_lib}" + IMPORTED_LOCATION_DEBUG "${_debug_lib}" + ) +endfunction() + +# --------------------------------------------------------------------------- +# Core Boost components +# --------------------------------------------------------------------------- +_scirun_define_boost_target(atomic) +_scirun_define_boost_target(chrono) +_scirun_define_boost_target(date_time) +_scirun_define_boost_target(filesystem) +_scirun_define_boost_target(program_options) +_scirun_define_boost_target(regex) +_scirun_define_boost_target(serialization) +_scirun_define_boost_target(thread) + +# --------------------------------------------------------------------------- +# Boost.Python (optional) +# --------------------------------------------------------------------------- +if(@BUILD_WITH_PYTHON@) + _scirun_define_boost_target(python@SCI_PYTHON_VERSION_SHORT_WIN32@) +endif() + +# --------------------------------------------------------------------------- +# Compatibility variables +# --------------------------------------------------------------------------- +set(Boost_LIBRARIES + Boost::atomic + Boost::chrono + Boost::date_time + Boost::filesystem + Boost::program_options + Boost::regex + Boost::serialization + Boost::thread +) + +add_library(Boost::headers INTERFACE IMPORTED) +set_target_properties(Boost::headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}" +) + +if(@BUILD_WITH_PYTHON@) + list(APPEND Boost_LIBRARIES Boost::python@SCI_PYTHON_VERSION_SHORT_WIN32@) +endif() \ No newline at end of file diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index 98b312bfc7..f4225648a2 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -24,226 +24,309 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# --- Inputs --- -set(_boost_git_url "https://github.com/CIBC-Internal/boost.git") -set(_boost_git_tag "v1.90.0") - -include(ExternalProject) +# +# Boost External Project for SCIRun Superbuild +# -# ========= Compiled library selection ========= -set(_BOOST_LIBS - filesystem - system +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) + +# ------------------------------------------------------------------------------ +# Boost compile flags +# ------------------------------------------------------------------------------ +SET(boost_CXX_Flags "-DBOOST_ALL_NO_LIB=1") +IF(APPLE) + LIST(APPEND boost_CXX_Flags "-DBOOST_LCAST_NO_WCHAR_T" "-DBOOST_THREAD_DONT_USE_ATOMIC") +ENDIF() +IF(WIN32) + LIST(APPEND boost_CXX_Flags "-DBOOST_BIND_ENABLE_STDCALL") +ENDIF() + +SET(boost_DEPENDENCIES) + +# ------------------------------------------------------------------------------ +# Explicit library list +# ------------------------------------------------------------------------------ +SET(boost_Libraries atomic - thread + chrono + date_time + exception + filesystem program_options + regex serialization + thread + CACHE INTERNAL "Boost library names." ) -option(BOOST_ENABLE_PYTHON "Build Boost.Python if Python is available" ON) -option(BOOST_ENABLE_MPI "Build Boost.MPI if MPI is available" OFF) -option(BOOST_ENABLE_TEST "Build Boost.Test (unit test framework)" OFF) - -if(BOOST_ENABLE_PYTHON) - list(APPEND _BOOST_LIBS python) -endif() -if(BOOST_ENABLE_MPI) - list(APPEND _BOOST_LIBS mpi graph_parallel) -endif() -if(BOOST_ENABLE_TEST) - list(APPEND _BOOST_LIBS test) -endif() - -set(_BOOST_LIBS_B2 "") -foreach(_bl IN LISTS _BOOST_LIBS) - list(APPEND _BOOST_LIBS_B2 "--with-${_bl}") -endforeach() - -# ============================================================ -# 1) Define the external project FIRST (required by CMake) -# ============================================================ -ExternalProject_Add(Boost_external - GIT_REPOSITORY ${_boost_git_url} - GIT_TAG ${_boost_git_tag} - GIT_SHALLOW FALSE - GIT_PROGRESS TRUE - - UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir git submodule update --init --recursive - - BUILD_IN_SOURCE OFF - - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" -) - -# ============================================================ -# 2) Retrieve SOURCE_DIR, BINARY_DIR, INSTALL_DIR -# ============================================================ -ExternalProject_Get_Property(Boost_external SOURCE_DIR) -ExternalProject_Get_Property(Boost_external BINARY_DIR) -ExternalProject_Get_Property(Boost_external INSTALL_DIR) - -# ============================================================ -# 3) Optional Boost.Python config -# ============================================================ -set(_B2_PY_ARGS "") -if(BOOST_ENABLE_PYTHON) - set(_PY_LIBDIR "") - - if(DEFINED PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") - get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_DEBUG}" DIRECTORY) - elseif(DEFINED PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") - get_filename_component(_PY_LIBDIR "${PYTHON_LIBRARY_RELEASE}" DIRECTORY) - elseif(DEFINED PYTHON_RUNTIME_DIR AND EXISTS "${PYTHON_RUNTIME_DIR}") - set(_PY_LIBDIR "${PYTHON_RUNTIME_DIR}") - endif() - - if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}" AND - _PY_LIBDIR AND EXISTS "${_PY_LIBDIR}") - list(APPEND _B2_PY_ARGS - "include=${PYTHON_INCLUDE_DIR}" - "library-path=${_PY_LIBDIR}" - ) - message(STATUS "[Boost_ext] Will build Boost.Python against include='${PYTHON_INCLUDE_DIR}', libdir='${_PY_LIBDIR}'") - else() - message(WARNING "[Boost_ext] BOOST_ENABLE_PYTHON=ON but Python paths incomplete.") - endif() -endif() - -# ============================================================ -# 4) Cross‑platform Boost toolset detection -# ============================================================ -if(WIN32) - set(_B2_TOOLSET "msvc") +IF(BUILD_WITH_PYTHON) + ADD_DEFINITIONS(-DBOOST_PYTHON_STATIC_LIB=1) + LIST(APPEND boost_Libraries python) + LIST(APPEND boost_DEPENDENCIES Python_external) + LIST(APPEND boost_CXX_Flags "-DBOOST_PYTHON_STATIC_MODULE" "-DBOOST_PYTHON_STATIC_LIB") +ENDIF() + +# ------------------------------------------------------------------------------ +# Darwin/Unix/Windows consistency flags +# ------------------------------------------------------------------------------ +IF(UNIX) + ADD_DEFINITIONS(-DBOOST_NO_CXX11_ALLOCATOR) +ENDIF() + +IF(WIN32) + SET(FORCE_64BIT_BUILD ON) +ENDIF() + +SET(_boost_git_url "https://github.com/CIBC-Internal/boost.git") +SET(_boost_git_tag "v1.90.0") + +# ------------------------------------------------------------------------------ +# Compute Python library filenames +# ------------------------------------------------------------------------------ +if(WIN32 AND MSVC) + set(SCI_PYTHON_LIBRARY_FILE_RELEASE + "${SCI_PYTHON_LIBRARY_RELEASE}") + set(SCI_PYTHON_LIBRARY_FILE_DEBUG + "${SCI_PYTHON_LIBRARY_DEBUG}") elseif(APPLE) - set(_B2_TOOLSET "clang-darwin") + set(SCI_PYTHON_LIBRARY_FILE + "${SCI_PYTHON_LIBRARY_DIR}/libpython${SCI_PYTHON_VERSION_SHORT}.dylib") else() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(_B2_TOOLSET "gcc") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(_B2_TOOLSET "clang") - else() - message(FATAL_ERROR "Unsupported compiler '${CMAKE_CXX_COMPILER_ID}' for Boost build") - endif() + set(SCI_PYTHON_LIBRARY_FILE + "${SCI_PYTHON_LIBRARY_DIR}/libpython${SCI_PYTHON_VERSION_SHORT}.so") endif() -message(STATUS "[Boost_ext] Auto-selected b2 toolset: ${_B2_TOOLSET}") - -if(DEFINED B2_TOOLSET) - message(STATUS "[Boost_ext] Overriding toolset with B2_TOOLSET=${B2_TOOLSET}") - set(_B2_TOOLSET "${B2_TOOLSET}") -endif() +# ------------------------------------------------------------------------------ +# Compute b2 Python flags (MUST be separate arguments) +# ------------------------------------------------------------------------------ +IF(BUILD_WITH_PYTHON) + SET(BOOST_PYTHON_WITH_FLAG --with-python) + #SET(BOOST_PYTHON_EXE_FLAG python=${SCI_PYTHON_EXE}) + #SET(BOOST_PYTHON_INC_FLAG include=${SCI_PYTHON_INCLUDE}) + #SET(BOOST_PYTHON_LIB_FLAG library-path=${SCI_PYTHON_LIBRARY_DIR}) + SET(BOOST_PYTHON_VERSION_FLAG python-version=${SCI_PYTHON_VERSION_SHORT}) +ELSE() + SET(BOOST_PYTHON_WITH_FLAG --without-python) + SET(BOOST_PYTHON_EXE_FLAG "") + SET(BOOST_PYTHON_INC_FLAG "") + SET(BOOST_PYTHON_LIB_FLAG "") +ENDIF() -# ============================================================ -# 5) Link options -# ============================================================ -if(BOOST_USE_STATIC_LIBS) - set(_B2_LINK "link=static") -else() - set(_B2_LINK "link=shared") -endif() - -if(BOOST_USE_STATIC_RUNTIME) - set(_B2_RUNTIME_LINK "runtime-link=static") -else() - set(_B2_RUNTIME_LINK "runtime-link=shared") -endif() - -set(_B2_VARIANTS "variant=debug,release") - -# ============================================================ -# 6) b2 executable and build dir -# ============================================================ if(WIN32) - set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) - set(_B2_CMD cmd /c .\\b2) + # Convert Windows PATH to CMake-friendly forward-slash form + file(TO_CMAKE_PATH "$ENV{PATH}" _SCIRUN_ENV_PATH_CMAKE) else() - set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) - set(_B2_CMD ./b2) + set(_SCIRUN_ENV_PATH_CMAKE "$ENV{PATH}") endif() +# ------------------------------------------------------------------------------ +# ExternalProject_Add: Boost +# ------------------------------------------------------------------------------ +ExternalProject_Add(Boost_external + DEPENDS ${boost_DEPENDENCIES} + GIT_REPOSITORY ${_boost_git_url} + GIT_TAG ${_boost_git_tag} + BUILD_IN_SOURCE ON + PATCH_COMMAND "" + INSTALL_COMMAND "" + + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DFORCE_64BIT_BUILD:BOOL=${FORCE_64BIT_BUILD} + + # ---------- Python ON/OFF controlled by SCIRun option ---------- + -DBUILD_PYTHON:BOOL=${BUILD_WITH_PYTHON} + #-DBOOST_ENABLE_PYTHON:BOOL=${BUILD_WITH_PYTHON} + + # ---------- FORCE FindPython3 to use SCIRun Python, not Xcode ---------- + -DPython3_FIND_FRAMEWORK:STRING=NEVER + -DPython3_FIND_STRATEGY:STRING=LOCATION + -DPython3_FIND_REQUIRED:BOOL=${BUILD_WITH_PYTHON} + -DPython3_ROOT_DIR:PATH=${SCI_PYTHON_ROOT_DIR} + -DPython3_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE} + -DPython3_INCLUDE_DIR:PATH=${SCI_PYTHON_INCLUDE} + if(WIN32 AND MSVC) + -DPython3_LIBRARY_DEBUG:FILEPATH=${SCI_PYTHON_LIBRARY_FILE_DEBUG} + -DPython3_LIBRARY_RELEASE:FILEPATH=${SCI_PYTHON_LIBRARY_FILE_RELEASE} + else() + -DPython3_LIBRARY:FILEPATH=${SCI_PYTHON_LIBRARY_FILE} + endif() + + CMAKE_COMMAND_ENV + "PYTHONHOME=${SCI_PYTHON_ROOT_DIR}" + "PYTHONPATH=" + "PATH=${SCI_PYTHON_ROOT_DIR}/bin:${_SCIRUN_ENV_PATH_CMAKE}" + "CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=FALSE" + "CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=FALSE" + "CMAKE_FIND_FRAMEWORK=NEVER" + "Python3_FIND_FRAMEWORK=NEVER" + "Python3_FIND_STRATEGY=LOCATION" +) -set(_B2_BUILD_DIR ${BINARY_DIR}/b2-build) +# ------------------------------------------------------------------------------ +# Internal paths from ExternalProject +# ------------------------------------------------------------------------------ +ExternalProject_Get_Property(Boost_external INSTALL_DIR) +ExternalProject_Get_Property(Boost_external SOURCE_DIR) -# ============================================================ -# 7) bootstrap b2 -# ============================================================ +IF(WIN32) + SET(_B2_CMD ${SOURCE_DIR}/b2.exe) + SET(_B2_BOOTSTRAP_CMD bootstrap.bat) +ELSE() + SET(_B2_CMD ${SOURCE_DIR}/b2) + SET(_B2_BOOTSTRAP_CMD ./bootstrap.sh) +ENDIF() + +# -------------------------------------------------------------- +# Step: bootstrap b2 +# -------------------------------------------------------------- ExternalProject_Add_Step(Boost_external bootstrap_b2 COMMAND ${_B2_BOOTSTRAP_CMD} WORKING_DIRECTORY ${SOURCE_DIR} DEPENDEES update + INDEPENDENT 1 COMMENT "Bootstrapping b2" ) -# ============================================================ -# 8) Run b2 headers -# ============================================================ +# -------------------------------------------------------------- +# Step: write project-config.jam (AFTER bootstrap) +# -------------------------------------------------------------- +ExternalProject_Add_Step(Boost_external write_project_config + COMMAND ${CMAKE_COMMAND} + -DOUTPUT_FILE=${SOURCE_DIR}/project-config.jam + -DVERSION=${SCI_PYTHON_VERSION_SHORT} + -DEXE=${SCI_PYTHON_EXE} + -DINCLUDE=${SCI_PYTHON_INCLUDE} + -DLIB_RELEASE=${SCI_PYTHON_LIBRARY_RELEASE} + -DLIB_DEBUG=${SCI_PYTHON_LIBRARY_DEBUG} + -P ${SUPERBUILD_DIR}/WriteProjectConfigJam.cmake + DEPENDEES bootstrap_b2 + INDEPENDENT 1 + + COMMENT "Overwriting project-config.jam with Python toolset AFTER bootstrap" +) + +# -------------------------------------------------------------- +# Step: verify project-config.jam +# -------------------------------------------------------------- +ExternalProject_Add_Step(Boost_external verify_project_config + COMMAND ${CMAKE_COMMAND} -E echo "==== VERIFY project-config.jam AFTER bootstrap ====" + COMMAND ${CMAKE_COMMAND} -E cat ${SOURCE_DIR}/project-config.jam + + DEPENDEES write_project_config + INDEPENDENT 1 + + COMMENT "Verifying final project-config.jam" +) + +# ------------------------------------------------------------------------------ +# Step: b2 headers +# ------------------------------------------------------------------------------ ExternalProject_Add_Step(Boost_external stage_headers COMMAND ${_B2_CMD} headers WORKING_DIRECTORY ${SOURCE_DIR} - DEPENDEES bootstrap_b2 - COMMENT "Generating Boost headers (b2 headers)" + DEPENDEES write_project_config + COMMENT "Running b2 headers" ) -# ============================================================ -# 9) Build Boost libraries -# ============================================================ -ExternalProject_Add_Step(Boost_external build_b2_libs - COMMAND ${_B2_CMD} - -j${CMAKE_BUILD_PARALLEL_LEVEL} - toolset=${_B2_TOOLSET} - threading=multi - ${_B2_LINK} - ${_B2_RUNTIME_LINK} - ${_B2_VARIANTS} - --layout=tagged - ${_BOOST_LIBS_B2} - ${_B2_PY_ARGS} - --build-dir=${_B2_BUILD_DIR} - stage +# ------------------------------------------------------------------------------ +# Step: Install full headers +# ------------------------------------------------------------------------------ +ExternalProject_Add_Step(Boost_external install_full_headers + COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALL_DIR}/include + COMMAND ${CMAKE_COMMAND} -E remove_directory ${INSTALL_DIR}/include/boost + COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/boost ${INSTALL_DIR}/include/boost WORKING_DIRECTORY ${SOURCE_DIR} DEPENDEES stage_headers - COMMENT "Building Boost libs" + DEPENDERS install + COMMENT "Installing full Boost headers" ) -# ============================================================ -# 10) Install b2-built libs -# ============================================================ -ExternalProject_Add_Step(Boost_external install_b2_libs - COMMAND ${CMAKE_COMMAND} -E make_directory /lib - COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/stage/lib /lib - DEPENDEES build_b2_libs - COMMENT "Installing Boost libs" -) +# ------------------------------------------------------------------------------ +# Step: Build Boost libraries +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------ +# Common Boost b2 build arguments (used for echo + real build) +# ------------------------------------------------------------------ +if(WIN32) + set(_BOOST_CXXFLAGS "") +else() + set(_BOOST_CXXFLAGS cxxflags=-fPIC) +endif() +# ------------------------------------------------------------------ +# Boost.Python debug ABI (Windows requires this for python313_d + 'y') +# ------------------------------------------------------------------ +if(WIN32 AND MSVC AND BUILD_WITH_PYTHON) + set(BOOST_PYTHON_DEBUGGING_FLAG python-debugging=on) +else() + set(BOOST_PYTHON_DEBUGGING_FLAG "") +endif() -# ============================================================ -# 11) Install full header tree -# ============================================================ -ExternalProject_Add_Step(Boost_external install_full_headers - COMMAND ${CMAKE_COMMAND} -E make_directory /include - COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost - COMMAND ${CMAKE_COMMAND} -E copy_directory ${SOURCE_DIR}/boost /include/boost - DEPENDEES stage_headers - COMMENT "Installing Boost headers" +set(_BOOST_B2_ARGS + --with-atomic + --with-chrono + --with-date_time + --with-filesystem + --with-program_options + --with-regex + --with-serialization + --with-thread + + ${BOOST_PYTHON_WITH_FLAG} + ${BOOST_PYTHON_DEBUGGING_FLAG} + + link=static + runtime-link=shared + variant=release,debug + threading=multi + stage ) -# ============================================================ -# 12) Export paths to superbuild -# ============================================================ -set(SCI_BOOST_PREFIX "${INSTALL_DIR}") +ExternalProject_Add_Step(Boost_external build_libs + COMMAND ${CMAKE_COMMAND} -E echo "=== B2 PYTHON FLAGS ===" + COMMAND ${CMAKE_COMMAND} -E echo "${BOOST_PYTHON_WITH_FLAG}" + COMMAND ${CMAKE_COMMAND} -E echo "${BOOST_PYTHON_EXE_FLAG}" + COMMAND ${CMAKE_COMMAND} -E echo "${BOOST_PYTHON_INC_FLAG}" + COMMAND ${CMAKE_COMMAND} -E echo "${BOOST_PYTHON_LIB_FLAG}" + COMMAND ${CMAKE_COMMAND} -E echo "SCI_PYTHON_EXE = ${SCI_PYTHON_EXE}" + COMMAND ${CMAKE_COMMAND} -E echo "SCI_PYTHON_INCLUDE = ${SCI_PYTHON_INCLUDE}" + COMMAND ${CMAKE_COMMAND} -E echo "SCI_PYTHON_LIBRARY_DIR = ${SCI_PYTHON_LIBRARY_DIR}" -set(SCI_BOOST_INCLUDE "${SCI_BOOST_PREFIX}/include" CACHE PATH "Boost include dir" FORCE) + COMMAND ${CMAKE_COMMAND} -E echo "=== B2 FULL CMD ===" + COMMAND ${CMAKE_COMMAND} -E echo "${_B2_CMD} ${_BOOST_B2_ARGS}" -if(EXISTS "${SCI_BOOST_PREFIX}/lib64") - set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib64") -else() - set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_PREFIX}/lib") -endif() + COMMAND ${_B2_CMD} ${_BOOST_B2_ARGS} -set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library dir" FORCE) + WORKING_DIRECTORY ${SOURCE_DIR} + DEPENDEES stage_headers + COMMENT "Building Boost static libraries (Debug + Release)" +) -set(Boost_DIR "" CACHE PATH "" FORCE) -set(Boost_NO_BOOST_CMAKE ON CACHE BOOL "" FORCE) -set(Boost_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "" FORCE) -set(BOOST_ROOT "${SCI_BOOST_PREFIX}" CACHE PATH "" FORCE) -set(BOOST_LIBRARYDIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "" FORCE) \ No newline at end of file +# ------------------------------------------------------------------------------ +# Export Boost library info +# ------------------------------------------------------------------------------ +SET(SCI_BOOST_INCLUDE ${INSTALL_DIR}/include) +SET(SCI_BOOST_LIBRARY_DIR ${SOURCE_DIR}/stage/lib) +#SET(SCI_BOOST_USE_FILE ${INSTALL_DIR}/UseBoost.cmake) + +SET(BOOST_PREFIX "boost_") +SET(THREAD_POSTFIX "") + +#SET(SCI_BOOST_LIBRARY) +#FOREACH(lib ${boost_Libraries}) +# IF(lib STREQUAL "python") +# # Python library is versioned: e.g., boost_python313 +# LIST(APPEND SCI_BOOST_LIBRARY "${BOOST_PREFIX}${lib}${SCI_PYTHON_VERSION_SHORT_WIN32}") +# ELSE() +# LIST(APPEND SCI_BOOST_LIBRARY "${BOOST_PREFIX}${lib}${THREAD_POSTFIX}") +# ENDIF() +#ENDFOREACH() + +CONFIGURE_FILE(${SUPERBUILD_DIR}/BoostConfig.cmake.in + ${INSTALL_DIR}/BoostConfig.cmake @ONLY) +#CONFIGURE_FILE(${SUPERBUILD_DIR}/UseBoost.cmake +# ${SCI_BOOST_USE_FILE} COPYONLY) + +SET(Boost_DIR ${INSTALL_DIR} CACHE PATH "") +MESSAGE(STATUS "Boost_DIR: ${Boost_DIR}") \ No newline at end of file diff --git a/Superbuild/Cleaver2External.cmake b/Superbuild/Cleaver2External.cmake index e7ebb7dfe3..ecc82d58ce 100644 --- a/Superbuild/Cleaver2External.cmake +++ b/Superbuild/Cleaver2External.cmake @@ -24,83 +24,24 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# Cleaver2External.cmake (corrected + aligned with TetGen pattern) - -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -# Version tag for Cleaver2 -set(cleaver2_GIT_TAG "v2.0.1") # or your new tag like v2.0.1-scirun1 - -# Common CMake args -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - - # Redirect all outputs so install step is unnecessary - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin -) - -# Single-config generators -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -endif() - -# Superbuild directories -set(_cleaver2_src "${CMAKE_BINARY_DIR}/Externals/Source/Cleaver2_external") -set(_cleaver2_bin "${CMAKE_BINARY_DIR}/Externals/Build/Cleaver2_external") -set(_cleaver2_inst "${CMAKE_BINARY_DIR}/Externals/Install/Cleaver2_external") +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +SET(cleaver2_GIT_TAG "origin/scirun-5.0.0-beta") +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Cleaver2_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Cleaver2Library.git" - GIT_TAG ${cleaver2_GIT_TAG} - UPDATE_DISCONNECTED 1 - - SOURCE_DIR ${_cleaver2_src} - BINARY_DIR ${_cleaver2_bin} - - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - - CMAKE_ARGS ${_cmake_args} - - # Outputs already redirected -> skip install + GIT_TAG ${cleaver2_GIT_TAG} + PATCH_COMMAND "" + INSTALL_DIR "" INSTALL_COMMAND "" - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) -# After build, copy headers from the source tree into the install/include tree -ExternalProject_Add_Step(Cleaver2_external copy_headers - COMMAND ${CMAKE_COMMAND} -E make_directory "${_cleaver2_inst}/include/cleaver2" - COMMAND ${CMAKE_COMMAND} -E copy_directory - "${_cleaver2_src}/src/lib/cleaver2" - "${_cleaver2_inst}/include/cleaver2" - DEPENDEES build - ALWAYS 1 - COMMENT "Copying Cleaver2 headers to ${_cleaver2_inst}/include/cleaver2" -) - -# Export properties for SCIRun -ExternalProject_Get_Property(Cleaver2_external SOURCE_DIR) -set(CLEAVER2_SOURCE_DIR ${SOURCE_DIR}) - -set(CLEAVER2_INSTALL_DIR ${_cleaver2_inst}) -set(CLEAVER2_INCLUDE ${CLEAVER2_SOURCE_DIR}/src) # Cleaver2 headers live in src/ -set(CLEAVER2_LIBRARY_DIR ${CLEAVER2_INSTALL_DIR}/lib) -set(CLEAVER2_LIBRARY "cleaver2") # matches add_library(cleaver2 ...) +ExternalProject_Get_Property(Cleaver2_external BINARY_DIR) +SET(CLEAVER2_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "[Cleaver2_external] INSTALL_DIR=${CLEAVER2_INSTALL_DIR}") +MESSAGE(STATUS "CLEAVER2_DIR: ${CLEAVER2_DIR}") diff --git a/Superbuild/CtkExternal.cmake b/Superbuild/CtkExternal.cmake index cb00fd3157..3aff0deb8e 100644 --- a/Superbuild/CtkExternal.cmake +++ b/Superbuild/CtkExternal.cmake @@ -27,7 +27,6 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(CTK_CACHE_ARGS - "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" diff --git a/Superbuild/EigenExternal.cmake b/Superbuild/EigenExternal.cmake index e8aa529a0c..c60af110e2 100644 --- a/Superbuild/EigenExternal.cmake +++ b/Superbuild/EigenExternal.cmake @@ -24,31 +24,18 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - -# EigenExternal.cmake -set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) ExternalProject_Add(Eigen_external URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz" - UPDATE_DISCONNECTED 1 - - # Standard CMake configure + install (no build needed for header-only) - CONFIGURE_COMMAND - ${CMAKE_COMMAND} - -S - -B - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - - BUILD_COMMAND "" # header-only - - INSTALL_COMMAND - ${CMAKE_COMMAND} --build --target install - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + PATCH_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE ON + BUILD_COMMAND "" + INSTALL_COMMAND "" ) -ExternalProject_Get_Property(Eigen_external INSTALL_DIR) -message(STATUS "[Eigen_external] INSTALL_DIR=${INSTALL_DIR}") +ExternalProject_Get_Property(Eigen_external SOURCE_DIR) +SET(Eigen_DIR ${SOURCE_DIR} CACHE PATH "") + +MESSAGE(STATUS "Eigen_DIR: ${Eigen_DIR}") diff --git a/Superbuild/FreetypeExternal.cmake b/Superbuild/FreetypeExternal.cmake index 0ce881615d..a07e655e9e 100644 --- a/Superbuild/FreetypeExternal.cmake +++ b/Superbuild/FreetypeExternal.cmake @@ -1,21 +1,21 @@ # For more information, please see: http://software.sci.utah.edu -# +# # The MIT License -# +# # Copyright (c) 2015 Scientific Computing and Imaging Institute, # University of Utah. -# -# +# +# # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# +# in all copies or substantial portions of the Software. +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -24,108 +24,25 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +SET(freetype_GIT_TAG "origin/scirun-5.0.0") -# FreetypeExternal.cmake (modernized + consistent) - -# FreetypeExternal.cmake — use installed zlib via CMAKE_PREFIX_PATH - -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -set(freetype_GIT_TAG "v2.14.1") - -# Common CMake args for FreeType -# NOTE: -# - We no longer need to redirect all output dirs when using find_package(). -# - We pass CMAKE_PREFIX_PATH to point at the installed zlib prefix. -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_INSTALL_PREFIX= - - # Make FreeType use the zlib we installed in its own external - -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR} - -DFT_REQUIRE_ZLIB=ON - - # Start minimal to avoid surprise dependencies during bring-up - -DFT_DISABLE_BZIP2=ON - -DFT_DISABLE_PNG=ON - -DFT_DISABLE_BROTLI=ON - -DFT_DISABLE_HARFBUZZ=ON -) - -# Single-config generators -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -endif() - -# Superbuild directories -set(_freetype_src "${CMAKE_BINARY_DIR}/Externals/Source/Freetype_external") -set(_freetype_bin "${CMAKE_BINARY_DIR}/Externals/Build/Freetype_external") -set(_freetype_inst "${CMAKE_BINARY_DIR}/Externals/Install/Freetype_external") - -# --- FreeType external --- +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Freetype_external GIT_REPOSITORY "https://github.com/CIBC-Internal/freetype.git" - GIT_TAG ${freetype_GIT_TAG} - UPDATE_DISCONNECTED 1 - - SOURCE_DIR ${_freetype_src} - BINARY_DIR ${_freetype_bin} - - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - + GIT_TAG ${freetype_GIT_TAG} + PATCH_COMMAND "" + INSTALL_DIR "" + INSTALL_COMMAND "" CMAKE_CACHE_ARGS -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_INSTALL_LIBDIR:PATH=lib - - # Let FreeType find the zlib we built - -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} - -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} - -DZLIB_USE_STATIC_LIBS:BOOL=ON - - -DFT_REQUIRE_ZLIB:BOOL=ON - -DFT_DISABLE_BZIP2:BOOL=ON - -DFT_DISABLE_PNG:BOOL=ON - -DFT_DISABLE_BROTLI:BOOL=ON - -DFT_DISABLE_HARFBUZZ:BOOL=ON - - DEPENDS Zlib_external - - # IMPORTANT: let ExternalProject install files (remove the empty INSTALL_COMMAND) - # INSTALL_COMMAND "" - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + -DZLIB_LIBRARY_RELEASE:STRING=${Zlib_DIR} ) -# Ensure zlib artifacts exist before FreeType config -ExternalProject_Add_Step(Freetype_external wait_for_zlib - COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts..." - DEPENDEES download - DEPENDERS configure - DEPENDS - "${ZLIB_INSTALL_DIR}/include/zlib.h" - "${ZLIB_INSTALL_DIR}/lib" -) - -# Export variables for SCIRun (consumer side) -set(FREETYPE_SOURCE_DIR ${_freetype_src}) -set(FREETYPE_INSTALL_DIR ${_freetype_inst}) - -# Public headers for consumers are under source/include -set(Freetype_INCLUDE_DIR "${FREETYPE_INSTALL_DIR}/include" CACHE PATH "" FORCE) -set(FREETYPE_INCLUDE_DIR2 "${FREETYPE_INSTALL_DIR}/include/freetype2" CACHE PATH "" FORCE) - -# Libraries land here if you later enable FreeType's install; -# with INSTALL_COMMAND "" it remains empty, but we keep the var for consistency. -set(FREETYPE_LIBRARY_DIR ${FREETYPE_INSTALL_DIR}/lib) -set(Freetype_LIB_DIR "${FREETYPE_INSTALL_DIR}/lib" CACHE PATH "" FORCE) - -# Basename (actual file becomes freetype.lib / libfreetype.a / libfreetype.{so,dylib}) -set(FREETYPE_LIBRARY "freetype") +ExternalProject_Get_Property(Freetype_external BINARY_DIR) +SET(Freetype_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "[Freetype_external] INSTALL_DIR=${FREETYPE_INSTALL_DIR}") \ No newline at end of file +MESSAGE(STATUS "Freetype_DIR: ${Freetype_DIR}") diff --git a/Superbuild/GLMExternal.cmake b/Superbuild/GLMExternal.cmake index 0e126e0b39..968bf3796f 100644 --- a/Superbuild/GLMExternal.cmake +++ b/Superbuild/GLMExternal.cmake @@ -24,35 +24,23 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - -# GLMExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(GLM_external GIT_REPOSITORY "https://github.com/g-truc/glm.git" GIT_TAG "0.9.9.8" - PATCH_COMMAND "" - - # GLM is header-only — no configure/build steps needed. CONFIGURE_COMMAND "" BUILD_COMMAND "" - - # Install headers into the superbuild install tree. - INSTALL_COMMAND - ${CMAKE_COMMAND} -E copy_directory - "/glm" - "${CMAKE_BINARY_DIR}/Externals/Install/GLM_external/include/glm" - + INSTALL_COMMAND "" CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DGLM_FORCE_CXX03:BOOL=ON - -DGLM_FORCE_RADIANS:BOOL=ON - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + -DGLM_FORCE_CXX03:BOOL=ON + -DGLM_FORCE_RADIANS:BOOL=ON ) -ExternalProject_Get_Property(GLM_external INSTALL_DIR) -message(STATUS "[GLM_external] INSTALL_DIR=${INSTALL_DIR}") +ExternalProject_Get_Property(GLM_external SOURCE_DIR) +SET(GLM_DIR ${SOURCE_DIR}) + +MESSAGE(STATUS "GLM_DIR: ${GLM_DIR}") diff --git a/Superbuild/GlewExternal.cmake b/Superbuild/GlewExternal.cmake index 38cf1fdb30..712edba76f 100644 --- a/Superbuild/GlewExternal.cmake +++ b/Superbuild/GlewExternal.cmake @@ -24,103 +24,31 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# GlewExternal.cmake -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +SET(glew_GIT_TAG "origin/scirun-5.0.0-beta") -set(glew_GIT_TAG "v1.0.1") - -# Common CMake args -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DBUILD_SHARED_LIBS=OFF - -DGLEW_USE_STATIC_LIBS=ON - -DCMAKE_INSTALL_PREFIX= - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin -) -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -endif() - -set(_glew_src "${CMAKE_BINARY_DIR}/Externals/Source/Glew_external") -set(_glew_bin "${CMAKE_BINARY_DIR}/Externals/Build/Glew_external") -set(_glew_inst "${CMAKE_BINARY_DIR}/Externals/Install/Glew_external") +IF(TRAVIS_BUILD) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") +ENDIF() +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Glew_external GIT_REPOSITORY "https://github.com/CIBC-Internal/glew.git" - GIT_TAG ${glew_GIT_TAG} - UPDATE_DISCONNECTED 1 - SOURCE_DIR ${_glew_src} - BINARY_DIR ${_glew_bin} - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - CMAKE_ARGS ${_cmake_args} + GIT_TAG ${glew_GIT_TAG} + PATCH_COMMAND "" + INSTALL_DIR "" INSTALL_COMMAND "" - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 -) - -# Copy headers after build (idempotent) -ExternalProject_Add_Step(Glew_external copy_headers - COMMAND ${CMAKE_COMMAND} -E make_directory "${_glew_inst}/include" - COMMAND ${CMAKE_COMMAND} -E copy_directory "${_glew_src}/include" "${_glew_inst}/include" - DEPENDEES build - COMMENT "[Glew_external] Copying GLEW headers to ${_glew_inst}/include" -) - -ExternalProject_Add_StepTargets(Glew_external copy_headers) - -# Resolve the actual library name produced -set(GLEW_SOURCE_DIR ${_glew_src}) -set(GLEW_INSTALL_DIR ${_glew_inst}) -set(GLEW_INCLUDE ${GLEW_INSTALL_DIR}/include) -set(GLEW_LIBRARY_DIR ${GLEW_INSTALL_DIR}/lib) - -set(_glew_lib "") -if(EXISTS "${GLEW_LIBRARY_DIR}/glew.lib") - set(_glew_lib "${GLEW_LIBRARY_DIR}/glew.lib") -elseif(EXISTS "${GLEW_LIBRARY_DIR}/glew32s.lib") - set(_glew_lib "${GLEW_LIBRARY_DIR}/glew32s.lib") -elseif(EXISTS "${GLEW_LIBRARY_DIR}/glew32.lib") - set(_glew_lib "${GLEW_LIBRARY_DIR}/glew32.lib") -endif() - -# Fail early if lib isn't there yet (prevents empty target export) -if(NOT _glew_lib) - message(STATUS "[Glew_external] glew(.lib) not detected at configure-time; will be in ${GLEW_LIBRARY_DIR} after build.") -endif() - -# ---- Write a config package that SCIRun can consume (path fix here) ---- -# Template is kept NEXT TO this file: use ${CMAKE_CURRENT_LIST_DIR} -set(_template "${CMAKE_CURRENT_LIST_DIR}/GLEWConfig.cmake.in") -add_custom_target(Glew_export ALL - COMMAND ${CMAKE_COMMAND} -E make_directory "${GLEW_INSTALL_DIR}/lib/cmake/GLEW" - COMMAND ${CMAKE_COMMAND} - -D GLEW_INC:PATH="${GLEW_INCLUDE}" - -D GLEW_LIB:PATH="${_glew_lib}" - -D TEMPLATE:PATH="${_template}" - -D OUT_FILE:PATH="${GLEW_INSTALL_DIR}/lib/cmake/GLEW/GLEWConfig.cmake" - -P "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" - DEPENDS Glew_external Glew_external-copy_headers - COMMENT "[Glew_external] Writing GLEWConfig.cmake" + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DCMAKE_CXX_FLAGS:STATIC=${CMAKE_CXX_FLAGS} + -DCMAKE_C_FLAGS:STATIC=${CMAKE_C_FLAGS} ) -# Helper script to expand template @ONLY -file(WRITE "${CMAKE_CURRENT_LIST_DIR}/GlewWriteConfig.cmake" " -if(NOT EXISTS \"\${TEMPLATE}\") - message(FATAL_ERROR \"GLEW template not found at: \${TEMPLATE}\") -endif() -configure_file(\"\${TEMPLATE}\" \"\${OUT_FILE}\" @ONLY) -") +ExternalProject_Get_Property(Glew_external BINARY_DIR) +SET(Glew_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "[Glew_external] INSTALL_DIR=${GLEW_INSTALL_DIR}") \ No newline at end of file +MESSAGE(STATUS "Glew_DIR: ${Glew_DIR}") diff --git a/Superbuild/GoogleTestExternal.cmake b/Superbuild/GoogleTestExternal.cmake index 318ea69f64..16af038d8b 100644 --- a/Superbuild/GoogleTestExternal.cmake +++ b/Superbuild/GoogleTestExternal.cmake @@ -27,7 +27,6 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(GTEST_CACHE_ARGS - "-DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5" "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" "-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON" diff --git a/Superbuild/LibPNGExternal.cmake b/Superbuild/LibPNGExternal.cmake index 443441be89..809facc65a 100644 --- a/Superbuild/LibPNGExternal.cmake +++ b/Superbuild/LibPNGExternal.cmake @@ -38,7 +38,6 @@ ExternalProject_Add(LibPNG_external INSTALL_DIR "" INSTALL_COMMAND "" CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON diff --git a/Superbuild/LodePngExternal.cmake b/Superbuild/LodePngExternal.cmake index 823fc214bb..1bb401ed2d 100644 --- a/Superbuild/LodePngExternal.cmake +++ b/Superbuild/LodePngExternal.cmake @@ -24,50 +24,20 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# LodePngExternal.cmake (flat, no subdirs) -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) - -include(ExternalProject) +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(LodePng_external GIT_REPOSITORY "https://github.com/CIBC-Internal/cibc-lodepng.git" GIT_TAG "origin/master" - - # Configure: generate a tiny wrapper project with the same VS generator/platform/toolset - CONFIGURE_COMMAND - ${CMAKE_COMMAND} - -D WRAPPER_SOURCE_DIR:PATH=/lodepng-wrapper-src - -D WRAPPER_BUILD_DIR:PATH=/lodepng-wrapper-build - -D WRAPPER_LIST_FILE:PATH=${CMAKE_CURRENT_LIST_DIR}/LodePNGWrapperProject.cmake.in - -D LODEPNG_SRC:PATH=/lodepng - -D CMAKE_INSTALL_PREFIX:PATH= # still set, but we won't use install() - -D CMAKE_GENERATOR:STRING=${CMAKE_GENERATOR} - -D CMAKE_GENERATOR_PLATFORM:STRING=${CMAKE_GENERATOR_PLATFORM} - -D CMAKE_GENERATOR_TOOLSET:STRING=${CMAKE_GENERATOR_TOOLSET} - -P ${CMAKE_CURRENT_LIST_DIR}/LodePNGWrapper_configure.cmake - - # VS is multi-config: per-config build - BUILD_COMMAND - ${CMAKE_COMMAND} --build "/lodepng-wrapper-build" --config $(Configuration) - - # ---- IMPORTANT: replace install() with an explicit copy script ---- - INSTALL_COMMAND - ${CMAKE_COMMAND} - -D WRAPPER_BUILD_DIR:PATH=/lodepng-wrapper-build - -D WRAPPER_SOURCE_DIR:PATH= # repo root (we'll probe header in both layouts) - -D LODEPNG_INSTALL_DIR:PATH= - -D CONFIGURATION:STRING=$(Configuration) - -P ${CMAKE_CURRENT_LIST_DIR}/LodePNGWrapper_install.cmake - + INSTALL_COMMAND "" CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) -ExternalProject_Get_Property(LodePng_external INSTALL_DIR) -message(STATUS "[LodePng_external] INSTALL_DIR=${INSTALL_DIR}") \ No newline at end of file +ExternalProject_Get_Property(LodePng_external BINARY_DIR) +SET(LODEPNG_DIR ${BINARY_DIR}) + +MESSAGE(STATUS "LODEPNG_DIR: ${LODEPNG_DIR}") diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 6f4cf2638b..75ebb751c3 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -24,48 +24,31 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. - -# OsprayExternal.cmake SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(ospray_GIT_TAG "origin/scirun-build-2.10") -# OSPRay depends on GLM set(ospray_DEPENDENCIES) -list(APPEND ospray_DEPENDENCIES GLM_external) +LIST(APPEND ospray_DEPENDENCIES GLM_external) +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Ospray_external DEPENDS ${ospray_DEPENDENCIES} GIT_REPOSITORY "https://github.com/CIBC-Internal/ospray.git" GIT_TAG ${ospray_GIT_TAG} PATCH_COMMAND "" - - # REMOVE THESE — they suppress installation - # INSTALL_DIR "" - # INSTALL_COMMAND "" - + INSTALL_DIR "" + INSTALL_COMMAND "" CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - - # Use ospray's built-in superbuild -DENABLE_OSPRAY_SUPERBUILD:BOOL=ON - - # IMPORTANT: point glm_DIR to the INSTALL tree, not source tree - -Dglm_DIR:PATH=${CMAKE_BINARY_DIR}/Externals/Install/GLM_external/include/glm/cmake - - # Disable AVX512 unless needed + -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm -DBUILD_ISA_AVX512:BOOL=OFF - - # Install OSPRay into the superbuild Install tree - -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/Externals/Install/Ospray_external - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 ) -# Debug output -ExternalProject_Get_Property(Ospray_external INSTALL_DIR) -message(STATUS "[Ospray_external] INSTALL_DIR=${INSTALL_DIR}") +ExternalProject_Get_Property(Ospray_external BINARY_DIR) +SET(OSPRAY_BUILD_DIR ${BINARY_DIR} CACHE PATH "") + +MESSAGE(STATUS "OSPRAY_BUILD_DIR: ${OSPRAY_BUILD_DIR}") diff --git a/Superbuild/PythonConfig.cmake.in b/Superbuild/PythonConfig.cmake.in index e720d28530..223811712f 100644 --- a/Superbuild/PythonConfig.cmake.in +++ b/Superbuild/PythonConfig.cmake.in @@ -1,23 +1,62 @@ +# ----------------------------------------------------------------------------- +# SCIRun Python configuration +# ----------------------------------------------------------------------------- set(SCI_PYTHON_VERSION_SHORT "@SCI_PYTHON_VERSION_SHORT@") set(SCI_PYTHON_ROOT "@SCI_PYTHON_ROOT_DIR@") set(SCI_PYTHON_INCLUDE "@SCI_PYTHON_INCLUDE@") + +# NOTE: +# This variable historically held "the" Python library. +# On Windows/MSVC this is unsafe for multi-config generators, +# so consumers should prefer SCI_PYTHON_LIBRARIES instead. set(SCI_PYTHON_LIBRARY "@SCI_PYTHON_LIBRARY@") + set(SCI_PYTHON_LIBRARY_DIR "@SCI_PYTHON_LIBRARY_DIR@") set(SCI_PYTHON_LINK_LIBRARY_DIRS "@SCI_PYTHON_LINK_LIBRARY_DIRS@") set(SCI_PYTHON_EXE "@SCI_PYTHON_EXE@") + +# ----------------------------------------------------------------------------- +# Windows / MSVC-specific Python settings +# ----------------------------------------------------------------------------- if(WIN32 AND MSVC) set(SCI_PYTHON_VERSION_SHORT_WIN32 "@SCI_PYTHON_VERSION_SHORT_WIN32@") set(SCI_PYTHON_DEBUG_EXE "@SCI_PYTHON_DEBUG_EXE@") + + # Explicit Python import libraries set(SCI_PYTHON_LIBRARY_RELEASE "@SCI_PYTHON_LIBRARY_RELEASE@") - set(SCI_PYTHON_LIBRARY_DEBUG "@SCI_PYTHON_LIBRARY_DEBUG@") - set(SCI_PYTHON_DLL_PATH "@SCI_PYTHON_DLL_PATH@") - set(SCI_PYTHON_DLL_DEBUG_PATH "@SCI_PYTHON_DLL_DEBUG_PATH@") + set(SCI_PYTHON_LIBRARY_DEBUG "@SCI_PYTHON_LIBRARY_DEBUG@") + + # Runtime DLL search paths + set(SCI_PYTHON_DLL_PATH "@SCI_PYTHON_DLL_PATH@") + set(SCI_PYTHON_DLL_DEBUG_PATH "@SCI_PYTHON_DLL_DEBUG_PATH@") + set(SCI_PYTHON_MODULE_PARENT_PATH "@SCI_PYTHON_MODULE_PARENT_PATH@") set(SCI_PYTHON_NAME "@SCI_PYTHON_NAME@") + + # --------------------------------------------------------------------------- + # NEW: Canonical, configuration-safe Python library variable + # + # This must be used by all targets that link against Python on Windows. + # --------------------------------------------------------------------------- + set(SCI_PYTHON_LIBRARIES + "$<$:${SCI_PYTHON_LIBRARY_DEBUG}>" + "$<$>:${SCI_PYTHON_LIBRARY_RELEASE}>" + ) + +else() + # --------------------------------------------------------------------------- + # Non-Windows platforms (Linux, macOS): + # Python has a single ABI, so a single library is correct. + # --------------------------------------------------------------------------- + set(SCI_PYTHON_LIBRARIES "${SCI_PYTHON_LIBRARY}") endif() + +# ----------------------------------------------------------------------------- +# macOS framework support +# ----------------------------------------------------------------------------- if(APPLE) set(SCI_PYTHON_FRAMEWORK "@SCI_PYTHON_FRAMEWORK@") set(SCI_PYTHON_FRAMEWORK_ARCHIVE "@SCI_PYTHON_FRAMEWORK_ARCHIVE@") @@ -26,5 +65,14 @@ else() set(SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH "@SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH@") endif() + +# ----------------------------------------------------------------------------- +# Python module search path +# ----------------------------------------------------------------------------- set(PYTHON_MODULE_SEARCH_PATH "@PYTHON_MODULE_SEARCH_PATH@") -set(SCI_PYTHON_USE_FILE "@SCI_PYTHON_USE_FILE@") + + +# ----------------------------------------------------------------------------- +# Entry point for consumers +# ----------------------------------------------------------------------------- +set(SCI_PYTHON_USE_FILE "@SCI_PYTHON_USE_FILE@") \ No newline at end of file diff --git a/Superbuild/PythonExternal.cmake b/Superbuild/PythonExternal.cmake index 06ef4d718f..9eac14c6ef 100644 --- a/Superbuild/PythonExternal.cmake +++ b/Superbuild/PythonExternal.cmake @@ -31,7 +31,7 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(DEFAULT_PYTHON_VERSION "3.13.1") set(USER_PYTHON_VERSION ${DEFAULT_PYTHON_VERSION} CACHE STRING "Branch name corresponding to Python version number") -set_property(CACHE USER_PYTHON_VERSION PROPERTY STRINGS 3.6.7 3.7.9 3.8.12 3.9.10 3.10.2) +set_property(CACHE USER_PYTHON_VERSION PROPERTY STRINGS 3.10.16 3.11.11 3.12.8 3.13.1) string(REPLACE "." ";" USER_PYTHON_VERSION_LIST ${USER_PYTHON_VERSION}) list(GET USER_PYTHON_VERSION_LIST 0 USER_PYTHON_VERSION_MAJOR) @@ -102,95 +102,25 @@ IF(UNIX) WORKING_DIRECTORY ) ENDIF() - -# --- Windows path (MSVC) --- ELSE() - # 64-bit build only (keeps your original assumptions) - set(python_WIN32_ARCH "x64") - set(python_WIN32_64BIT_DIR "/amd64") - set(python_ABIFLAG_PYDEBUG "_d") - - # Helper script to resolve and copy pyconfig.h in a version-robust way - # We embed a small -P script rather than relying on shell tricks. - set(_copy_pyconfig_cmake "${CMAKE_CURRENT_BINARY_DIR}/CopyPyConfig.cmake") - file(WRITE "${_copy_pyconfig_cmake}" [=[ - # CopyPyConfig.cmake - # Inputs: - # _SRC : CPython source root - # _DST : Destination include directory (expects Include/) - # _PYEXE: Built python.exe to query sysconfig (optional if legacy fallback used) - - if(NOT DEFINED _SRC OR NOT DEFINED _DST) - message(FATAL_ERROR "CopyPyConfig.cmake: _SRC and _DST must be defined.") - endif() - - file(MAKE_DIRECTORY "${_DST}") - - # 1) Legacy fallback (works for older trees/tags if file exists) - if(EXISTS "${_SRC}/PC/pyconfig.h") - message(STATUS "[Python_external] Using legacy PC/pyconfig.h") - file(COPY "${_SRC}/PC/pyconfig.h" DESTINATION "${_DST}") - return() - endif() - - # 2) Preferred: ask the built interpreter where pyconfig.h is - if(NOT DEFINED _PYEXE OR NOT EXISTS "${_PYEXE}") - message(FATAL_ERROR - "CopyPyConfig.cmake: Built python.exe not found at '${_PYEXE}'.\n" - "Cannot query sysconfig.get_config_h_filename(); please check the build output under PCbuild.") - endif() - - execute_process( - COMMAND "${_PYEXE}" -c "import sysconfig, sys; print(sysconfig.get_config_h_filename())" - OUTPUT_VARIABLE _CFG - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - - if(NOT _CFG OR NOT EXISTS "${_CFG}") - message(FATAL_ERROR - "CopyPyConfig.cmake: sysconfig.get_config_h_filename() returned '${_CFG}', which does not exist.") - endif() - - message(STATUS "[Python_external] Copying pyconfig.h from: ${_CFG}") - file(COPY "${_CFG}" DESTINATION "${_DST}") - ]=]) - ExternalProject_Add(Python_external GIT_REPOSITORY ${python_GIT_URL} - GIT_TAG ${python_GIT_TAG} - UPDATE_DISCONNECTED 1 - UPDATE_COMMAND "" - PATCH_COMMAND "" - # Pass platform to build.bat so it generates the right artifacts - CONFIGURE_COMMAND PCbuild/build.bat -p ${python_WIN32_ARCH} + GIT_TAG ${python_GIT_TAG} + PATCH_COMMAND "" + CONFIGURE_COMMAND PCbuild/build.bat BUILD_IN_SOURCE ON - - # Build Release first (keeps your logic) - BUILD_COMMAND - ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo - /property:Configuration=Release - /property:Platform=${python_WIN32_ARCH} - - # INSTALL_COMMAND: robust pyconfig.h copy - # - Prefer sysconfig.get_config_h_filename() from the built interpreter - # - Fallback to legacy PC/pyconfig.h if present - INSTALL_COMMAND - "${CMAKE_COMMAND}" - -D_SRC= - -D_DST=/Include - -D_PYEXE=/PCbuild${python_WIN32_64BIT_DIR}/python.exe - -P "${_copy_pyconfig_cmake}" + BUILD_COMMAND ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo /property:Configuration=Release /property:Platform=${python_WIN32_ARCH} + INSTALL_COMMAND "${CMAKE_COMMAND}" -E + copy_if_different + /PCbuild/${python_WIN32_64BIT_DIR}/pyconfig.h + /Include/pyconfig.h ) - - # Also build Debug (as you had), and ensure it happens before "install" + # build both Release and Debug versions ExternalProject_Add_Step(Python_external debug_build - COMMAND ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo - /property:Configuration=Debug - /property:Platform=${python_WIN32_ARCH} - DEPENDEES build - DEPENDERS install - WORKING_DIRECTORY + COMMAND ${CMAKE_BUILD_TOOL} PCbuild/pcbuild.sln /nologo /property:Configuration=Debug /property:Platform=${python_WIN32_ARCH} + DEPENDEES build + DEPENDERS install + WORKING_DIRECTORY ) ENDIF() @@ -202,22 +132,24 @@ SET(SCI_PYTHON_MODULE_PARENT_PATH lib) IF(UNIX) SET(SCI_PYTHON_NAME python${SCI_PYTHON_VERSION_SHORT}) IF(APPLE) - # TODO: check Xcode IDE builds... - SET(SCI_PYTHON_FRAMEWORK ${INSTALL_DIR}/Python.framework) SET(SCI_PYTHON_ROOT_DIR ${SCI_PYTHON_FRAMEWORK}/Versions/${SCI_PYTHON_VERSION_SHORT}) SET(SCI_PYTHON_INCLUDE ${SCI_PYTHON_ROOT_DIR}/Headers) SET(SCI_PYTHON_LIBRARY_DIR ${SCI_PYTHON_ROOT_DIR}/lib) SET(SCI_PYTHON_LINK_LIBRARY_DIRS ${SCI_PYTHON_LIBRARY_DIR}) - SET(SCI_PYTHON_EXE ${SCI_PYTHON_ROOT_DIR}/bin/${SCI_PYTHON_NAME}) - SET(SCI_PYTHON_LIBRARY ${SCI_PYTHON_NAME}) - # required by interpreter interface + # Boost.Build requires python3, NOT python3.x inside frameworks + SET(SCI_PYTHON_EXE ${SCI_PYTHON_ROOT_DIR}/bin/python3) + + # Keep SCI_PYTHON_LIBRARY as the module name (python3.11 works here) + SET(SCI_PYTHON_LIBRARY python${SCI_PYTHON_VERSION_SHORT}) + IF(BUILD_HEADLESS) - SET(PYTHON_MODULE_SEARCH_PATH Python.framework/Versions/${SCI_PYTHON_VERSION_SHORT}/${SCI_PYTHON_MODULE_PARENT_PATH}/${SCI_PYTHON_NAME} CACHE INTERNAL "Python modules." FORCE) + SET(PYTHON_MODULE_SEARCH_PATH Python.framework/Versions/${SCI_PYTHON_VERSION_SHORT}/${SCI_PYTHON_MODULE_PARENT_PATH}/${SCI_PYTHON_LIBRARY} CACHE INTERNAL "Python modules." FORCE) ELSE() - SET(PYTHON_MODULE_SEARCH_PATH Frameworks/Python.framework/Versions/${SCI_PYTHON_VERSION_SHORT}/${SCI_PYTHON_MODULE_PARENT_PATH}/${SCI_PYTHON_NAME} CACHE INTERNAL "Python modules." FORCE) + SET(PYTHON_MODULE_SEARCH_PATH Frameworks/Python.framework/Versions/${SCI_PYTHON_VERSION_SHORT}/${SCI_PYTHON_MODULE_PARENT_PATH}/${SCI_PYTHON_LIBRARY} CACHE INTERNAL "Python modules." FORCE) ENDIF() + SET(SCI_PYTHON_FRAMEWORK_ARCHIVE ${INSTALL_DIR}/${python_FRAMEWORK_ARCHIVE}) ELSE() SET(SCI_PYTHON_ROOT_DIR ${INSTALL_DIR}) @@ -257,21 +189,6 @@ ELSE() ENDIF() SET(SCI_PYTHON_USE_FILE ${INSTALL_DIR}/UsePython.cmake) -# ---- Export Python paths to cache so other externals and SCIRun can consume them ---- -set(PYTHON_INCLUDE_DIR "${SCI_PYTHON_INCLUDE}" CACHE PATH "CPython include dir (contains Python.h)" FORCE) -set(PYTHON_PC_INCLUDE_DIR "${SOURCE_DIR}/PC" CACHE PATH "CPython PC include dir (contains pyconfig.h)" FORCE) -set(PYTHON_RUNTIME_DIR "${SCI_PYTHON_LIBRARY_DIR}" CACHE PATH "Folder containing python313[_d].lib/.dll" FORCE) -set(PYTHON_EXECUTABLE "${SCI_PYTHON_EXE}" CACHE FILEPATH "python.exe built by CPython" FORCE) -set(PYTHON_LIBRARY_RELEASE "${SCI_PYTHON_LIBRARY_RELEASE}" CACHE FILEPATH "Release import lib (python313.lib)" FORCE) -set(PYTHON_LIBRARY_DEBUG "${SCI_PYTHON_LIBRARY_DEBUG}" CACHE FILEPATH "Debug import lib (python313_d.lib)" FORCE) - -# Nice for diagnostics -message(STATUS "[Python_external] PYTHON_INCLUDE_DIR = ${PYTHON_INCLUDE_DIR}") -message(STATUS "[Python_external] PYTHON_PC_INCLUDE_DIR = ${PYTHON_PC_INCLUDE_DIR}") -message(STATUS "[Python_external] PYTHON_RUNTIME_DIR = ${PYTHON_RUNTIME_DIR}") -message(STATUS "[Python_external] PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}") -message(STATUS "[Python_external] PYTHON_LIBRARY_RELEASE = ${PYTHON_LIBRARY_RELEASE}") -message(STATUS "[Python_external] PYTHON_LIBRARY_DEBUG = ${PYTHON_LIBRARY_DEBUG}") # Python is special case - normally this should be handled in external library repo CONFIGURE_FILE(${SUPERBUILD_DIR}/PythonConfig.cmake.in ${INSTALL_DIR}/PythonConfig.cmake @ONLY) diff --git a/Superbuild/QwtExternal.cmake b/Superbuild/QwtExternal.cmake index 88286a03a6..93a27d2323 100644 --- a/Superbuild/QwtExternal.cmake +++ b/Superbuild/QwtExternal.cmake @@ -30,7 +30,7 @@ # Single place to pin wrapper tag # ---------------------------- # Bump this tag when you cut a new wrapper release (e.g., v0.1.1, v0.2.0) -set(qwt_WRAPPER_GIT_TAG "v0.1.0") +set(qwt_WRAPPER_GIT_TAG "v0.1.1") # Keep the legacy variable for visibility; it's the upstream Qwt tag # that your wrapper fetches internally (informational only here). @@ -46,6 +46,11 @@ set(_qwt_src "${CMAKE_BINARY_DIR}/Externals/Source/Qwt_external") set(_qwt_bin "${CMAKE_BINARY_DIR}/Externals/Build/Qwt_external") set(_qwt_inst "${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external") +# Qwt install layout +set(QWT_INSTALL_DIR "${_qwt_inst}") +set(QWT_INCLUDE "${_qwt_inst}/include") +set(QWT_LIBRARY_DIR "${_qwt_inst}/lib") + # ---------------------------- # Qt discovery hints (optional) # ---------------------------- @@ -105,14 +110,37 @@ ExternalProject_Add(Qwt_external LOG_INSTALL 1 ) -# Exported variables for inner project (diagnostics/hints) -set(QWT_SOURCE_DIR ${_qwt_src}) -set(QWT_BUILD_DIR ${_qwt_bin}) -set(QWT_INSTALL_DIR ${_qwt_inst}) -set(QWT_INCLUDE "${QWT_INSTALL_DIR}/include") -set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") -# Consumers should prefer find_package(Qwt CONFIG), but we keep these for legacy: -set(QWT_LIBRARY "qwt") +# ---------------------------- +# Exported Qwt library variables (config-aware) +# ---------------------------- + +if(WIN32) + # Qwt wrapper uses qwtd.lib for Debug, qwt.lib for Release + set(QWT_LIBRARY_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") + set(QWT_LIBRARY_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") + + # Generator-expression aware library selection + set(QWT_LIBRARY + $<$:${QWT_LIBRARY_DEBUG}> + $<$:${QWT_LIBRARY_RELEASE}> + $<$:${QWT_LIBRARY_RELEASE}> + $<$:${QWT_LIBRARY_RELEASE}> + ) + +elseif(APPLE) + set(QWT_LIBRARY "${QWT_LIBRARY_DIR}/libqwt.a") +else() + set(QWT_LIBRARY "${QWT_LIBRARY_DIR}/libqwt.a") +endif() + +# Export to SCIRun +# Export to parent (SCIRun superbuild) +set(QWT_INSTALL_DIR "${QWT_INSTALL_DIR}" PARENT_SCOPE) +set(QWT_INCLUDE "${QWT_INCLUDE}" PARENT_SCOPE) +set(QWT_LIBRARY_DIR "${QWT_LIBRARY_DIR}" PARENT_SCOPE) +set(QWT_LIBRARY "${QWT_LIBRARY}" PARENT_SCOPE) message(STATUS "[Qwt_external] WRAPPER_TAG=${qwt_WRAPPER_GIT_TAG} ; QWT_TAG=${qwt_GIT_TAG}") -message(STATUS "[Qwt_external] INSTALL_DIR=${QWT_INSTALL_DIR}") \ No newline at end of file +message(STATUS "[Qwt_external] INSTALL_DIR=${QWT_INSTALL_DIR}") +message(STATUS "[Qwt_external] INCLUDE=${QWT_INCLUDE}") +message(STATUS "[Qwt_external] LIBDIR=${QWT_LIBRARY_DIR}") diff --git a/Superbuild/SQLiteExternal.cmake b/Superbuild/SQLiteExternal.cmake index 8c031f98df..f38e240d5c 100644 --- a/Superbuild/SQLiteExternal.cmake +++ b/Superbuild/SQLiteExternal.cmake @@ -1,21 +1,21 @@ # For more information, please see: http://software.sci.utah.edu -# +# # The MIT License -# +# # Copyright (c) 2015 Scientific Computing and Imaging Institute, # University of Utah. -# -# +# +# # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# +# in all copies or substantial portions of the Software. +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -24,171 +24,24 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# SQLiteExternal.cmake -# - Clones CIBC-Internal/sqlite at a tag/branch that contains the amalgamation at repo root: -# sqlite3.c, sqlite3.h, (optional) sqlite3ext.h -# - Verifies presence, builds static lib 'sqlite3', installs headers+lib to -# - Exports cache variables for SCIRun - -cmake_minimum_required(VERSION 3.15) - -# Keep ExternalProject data under the superbuild tree (provided by the top-level superbuild) -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -set(sqlite_GIT_TAG "v3.51.2") - -# Superbuild layout -set(_sqlite_src "${CMAKE_BINARY_DIR}/Externals/Source/SQLite_external") -set(_sqlite_bin "${CMAKE_BINARY_DIR}/Externals/Build/SQLite_external") -set(_sqlite_inst "${CMAKE_BINARY_DIR}/Externals/Install/SQLite_external") -file(MAKE_DIRECTORY "${_sqlite_inst}") - -include(ExternalProject) - -# ---------- Wrapper project (written into the build tree) ---------- -set(_wrapper_dir "${CMAKE_BINARY_DIR}/Externals/SQLiteWrapper") -file(MAKE_DIRECTORY "${_wrapper_dir}") - -file(WRITE "${_wrapper_dir}/CMakeLists.txt" " -cmake_minimum_required(VERSION 3.15) -# Force VS to use $(Configuration) instead of -set(CMAKE_CFG_INTDIR \"$(Configuration)\" CACHE STRING \"VS config placeholder\" FORCE) - -project(SQLiteExternal C) - -if(NOT SQLite_SOURCE_DIR) - message(FATAL_ERROR \"SQLiteWrapper requires -DSQLite_SOURCE_DIR=\") -endif() - -# Require amalgamation present at the directory we were told (repo root) -if(NOT EXISTS \"\${SQLite_SOURCE_DIR}/sqlite3.c\") - message(FATAL_ERROR \"sqlite3.c not found in \${SQLite_SOURCE_DIR}\") -endif() -if(NOT EXISTS \"\${SQLite_SOURCE_DIR}/sqlite3.h\") - message(FATAL_ERROR \"sqlite3.h not found in \${SQLite_SOURCE_DIR}\") -endif() - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -# Build static library from amalgamation -add_library(sqlite3 STATIC \"\${SQLite_SOURCE_DIR}/sqlite3.c\") -target_include_directories(sqlite3 PUBLIC \"\${SQLite_SOURCE_DIR}\") - -# Install lib + headers -install(TARGETS sqlite3 - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin -) -install(FILES \"\${SQLite_SOURCE_DIR}/sqlite3.h\" DESTINATION include) -if(EXISTS \"\${SQLite_SOURCE_DIR}/sqlite3ext.h\") - install(FILES \"\${SQLite_SOURCE_DIR}/sqlite3ext.h\" DESTINATION include) -endif() -") - -# ---------- Fast pre-check (fail early if files aren't there) ---------- -set(_precheck "${CMAKE_BINARY_DIR}/Externals/SQLitePrecheck.cmake") -file(WRITE "${_precheck}" " - cmake_minimum_required(VERSION 3.15) - if(NOT src) - message(FATAL_ERROR \"SQLitePrecheck.cmake requires -Dsrc\") - endif() - file(TO_CMAKE_PATH \"\${src}\" src) - get_filename_component(src \"\${src}\" ABSOLUTE) - if(NOT EXISTS \"\${src}/sqlite3.c\") - message(FATAL_ERROR \"[SQLite_precheck] Missing: \${src}/sqlite3.c\") - endif() - if(NOT EXISTS \"\${src}/sqlite3.h\") - message(FATAL_ERROR \"[SQLite_precheck] Missing: \${src}/sqlite3.h\") - endif() - message(STATUS \"[SQLite_precheck] Found amalgamation at: \${src}\") -") - -# Common args for wrapper configure (control outputs; multi-config aware) -set(_cfg_args - -DSQLite_SOURCE_DIR:PATH= - -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=/bin - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG:PATH=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE:PATH=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG:PATH=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE:PATH=/bin - -DCMAKE_CFG_INTDIR:STRING=$(Configuration) -) -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cfg_args -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) -endif() - -# Forward generator settings only if set -set(_gen_fwd CMAKE_GENERATOR "${CMAKE_GENERATOR}") -if(CMAKE_GENERATOR_PLATFORM) - list(APPEND _gen_fwd CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}") -endif() -if(CMAKE_GENERATOR_TOOLSET) - list(APPEND _gen_fwd CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") -endif() +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +SET(sqlite_GIT_TAG "origin/scirun-5.0.0-beta") +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(SQLite_external GIT_REPOSITORY "https://github.com/CIBC-Internal/sqlite.git" - GIT_TAG ${sqlite_GIT_TAG} - GIT_SHALLOW TRUE - GIT_PROGRESS TRUE - - # Prevent the 'update' step from running 'git' in SOURCE_DIR (we pin to a tag) - UPDATE_COMMAND "" - - UPDATE_DISCONNECTED 1 - - SOURCE_DIR ${_sqlite_src} - BINARY_DIR ${_sqlite_bin} - - # Configure / Build / Install wrapper - CONFIGURE_COMMAND - ${CMAKE_COMMAND} -S "${_wrapper_dir}" -B "/wrap" ${_cfg_args} - - BUILD_COMMAND - ${CMAKE_COMMAND} --build "/wrap" --config Release - - INSTALL_COMMAND - ${CMAKE_COMMAND} --build "/wrap" --target install --config Release - - ${_gen_fwd} - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + GIT_TAG ${sqlite_GIT_TAG} + PATCH_COMMAND "" + INSTALL_DIR "" + INSTALL_COMMAND "" + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) -# Pre-configure step: verify amalgamation exists at repo root -ExternalProject_Add_Step(SQLite_external verify_amalgamation - COMMAND ${CMAKE_COMMAND} -Dsrc= -P "${_precheck}" - DEPENDEES download - DEPENDERS configure - COMMENT "Verifying sqlite3.c/sqlite3.h exist at (amalgamation at repo root)" -) - -# ---------- Export variables for SCIRun ---------- -ExternalProject_Get_Property(SQLite_external INSTALL_DIR) -set(SQLITE_INSTALL_DIR "${INSTALL_DIR}") - -# Cache the exported vars so SCIRun configure sees stable values -set(SQLITE_SOURCE_DIR "${_sqlite_src}" CACHE PATH "SQLite source dir (clone)" FORCE) -set(SQLITE_INSTALL_DIR "${SQLITE_INSTALL_DIR}" CACHE PATH "SQLite install dir" FORCE) -set(SQLite_INCLUDE_DIR "${SQLITE_INSTALL_DIR}/include" CACHE PATH "SQLite include dir" FORCE) -set(SQLite_LIBRARY_DIR "${SQLITE_INSTALL_DIR}/lib" CACHE PATH "SQLite library dir" FORCE) - -# Basename built by wrapper -if(NOT DEFINED SQLITE_LIBRARY) - set(SQLITE_LIBRARY "sqlite3" CACHE STRING "SQLite library base name (sqlite vs sqlite3)" FORCE) -endif() +ExternalProject_Get_Property(SQLite_external BINARY_DIR) +SET(SQLite_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "[SQLite_external] INSTALL_DIR=${SQLITE_INSTALL_DIR}") -message(STATUS "[SQLite_external] Include dir=${SQLite_INCLUDE_DIR}") -message(STATUS "[SQLite_external] Lib dir=${SQLite_LIBRARY_DIR}") -message(STATUS "[SQLite_external] Library base=${SQLITE_LIBRARY}") \ No newline at end of file +MESSAGE(STATUS "SQLite_DIR: ${SQLite_DIR}") diff --git a/Superbuild/SpdLogExternal.cmake b/Superbuild/SpdLogExternal.cmake index 4ff02dcc4c..5f55b302c8 100644 --- a/Superbuild/SpdLogExternal.cmake +++ b/Superbuild/SpdLogExternal.cmake @@ -24,33 +24,21 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -# SpdLogExternal.cmake -set_property(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) - +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(SpdLog_external GIT_REPOSITORY "https://github.com/gabime/spdlog" GIT_TAG "v1.10.0" - PATCH_COMMAND "" - - # Header-only library — no build needed CONFIGURE_COMMAND "" BUILD_COMMAND "" - - # Install headers into the superbuild install prefix - INSTALL_COMMAND - ${CMAKE_COMMAND} -E copy_directory - "/include" - "${CMAKE_BINARY_DIR}/Externals/Install/SpdLog_external/include" - + INSTALL_COMMAND "" CMAKE_CACHE_ARGS - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 ) -ExternalProject_Get_Property(SpdLog_external INSTALL_DIR) -message(STATUS "[SpdLog_external] INSTALL_DIR=${INSTALL_DIR}") +ExternalProject_Get_Property(SpdLog_external SOURCE_DIR) +SET(SPDLOG_DIR ${SOURCE_DIR}) + +MESSAGE(STATUS "SPDLOG_DIR: ${SPDLOG_DIR}") diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index cfee57fc3c..0b6ea6b20d 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -24,1358 +24,347 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -cmake_minimum_required(VERSION 3.20) +########################################### +# TODO: build from archive - Git not used +SET(compress_type "GIT" CACHE INTERNAL "") +SET(ep_base "${CMAKE_BINARY_DIR}/Externals" CACHE INTERNAL "") -# ========================= -# Global setup / policies -# ========================= -set(compress_type "GIT" CACHE INTERNAL "") -set(ep_base "${CMAKE_BINARY_DIR}/Externals" CACHE INTERNAL "") +########################################### +# Set default CMAKE_BUILD_TYPE +# if empty for Unix Makefile builds +IF(CMAKE_GENERATOR MATCHES "Unix Makefiles" AND NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) +ENDIF() -if(POLICY CMP0135) - cmake_policy(SET CMP0135 NEW) # ExternalProject downloads -endif() +FIND_PACKAGE(Git) -# Default build type for Unix Makefiles if not set -if(CMAKE_GENERATOR MATCHES "Unix Makefiles" AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING - "Choose the type of build: None Debug Release RelWithDebInfo MinSizeRel." FORCE) -endif() +IF(NOT GIT_FOUND) + MESSAGE(ERROR "Cannot find Git. Git is required for SCIRun's Superbuild") +ENDIF() -find_package(Git REQUIRED) -include(ExternalProject) +INCLUDE( ExternalProject ) -# ========================= -# Architecture -# ========================= -if(CMAKE_SIZEOF_VOID_P MATCHES 8) - set(SCIRUN_BITS 64) -else() - set(SCIRUN_BITS 32) -endif() +########################################### +# DETERMINE ARCHITECTURE +# In order for the code to depend on the architecture settings +########################################### -# ========================= -# Options -# ========================= -option(BUILD_TESTING "Build with tests." OFF) -option(GENERATE_COMPILATION_DATABASE "Generate Compilation Database." ON) -option(BUILD_WITH_PYTHON "Build with python support." ON) -option(WITH_TETGEN "Build Tetgen." ON) -option(WITH_OSPRAY "Build Ospray." OFF) -option(BUILD_WITH_SCIRUN_DATA "Svn checkout data" OFF) +IF(CMAKE_SIZEOF_VOID_P MATCHES 8) + SET(SCIRUN_BITS 64) +ELSE() + SET(SCIRUN_BITS 32) +ENDIF() -if(WIN32) - option(SCIRUN_SHOW_CONSOLE "Show Windows console when running SCIRun." ON) - mark_as_advanced(SCIRUN_SHOW_CONSOLE) -endif() +########################################### +# Configure test support +OPTION(BUILD_TESTING "Build with tests." OFF) -option(BUILD_HEADLESS "Build SCIRun without GUI." OFF) +########################################### +# Configure compilation database generation +OPTION(GENERATE_COMPILATION_DATABASE "Generate Compilation Database." ON) -# ========================= -# Prefix collector -# ========================= -# Keep one clean CMAKE_PREFIX_PATH for SCIRun via GLOBAL PROPERTY -set_property(GLOBAL PROPERTY SCIRUN_PREFIXES "") +########################################### +# Configure python +OPTION(BUILD_WITH_PYTHON "Build with python support." ON) -function(sb_prefix_append dir_in) - if(NOT dir_in) - return() - endif() - file(TO_CMAKE_PATH "${dir_in}" _norm) - get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) - if(NOT _acc) - set(_acc "") - endif() - list(APPEND _acc "${_norm}") - list(REMOVE_DUPLICATES _acc) - set_property(GLOBAL PROPERTY SCIRUN_PREFIXES "${_acc}") -endfunction() +########################################### +# Configure tetgen +OPTION(WITH_TETGEN "Build Tetgen." ON) -# ========================= -# Qt selection -# ========================= -set(SCIRUN_QT_MAJOR "6" CACHE STRING "Qt major version to use (5 or 6)") -set_property(CACHE SCIRUN_QT_MAJOR PROPERTY STRINGS 5 6) -set(QT5_MIN_VERSION "5.15.2") -set(QT6_MIN_VERSION "6.3.0") +########################################### +# Configure ospray +OPTION(WITH_OSPRAY "Build Ospray." OFF) -set(Qt_PATH "" CACHE PATH "Qt install prefix (e.g. C:/Qt/6.10.1/msvc2022_64 or /Users//Qt/6.10.2/macos)") +########################################### +# Configure data +OPTION(BUILD_WITH_SCIRUN_DATA "Svn checkout data" OFF) -# ------------------------- -# Default Qt path on Windows -# ------------------------- -if (WIN32 AND NOT BUILD_HEADLESS) - if (NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") - set(_qt_default "C:/Qt/6.10.1/msvc2022_64") - if (IS_DIRECTORY "${_qt_default}") - message(STATUS "Qt_PATH not set or invalid — defaulting to ${_qt_default}") - set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) - endif() - endif() -endif() +########################################### +# Configure Windows executable to run with +# or without the console -# ------------------------- -# Default Qt path on macOS -# ------------------------- -if (APPLE AND NOT BUILD_HEADLESS) - if (NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") - set(_qt_default "/Users/basisunus/Qt/6.10.2/macos") - if (IS_DIRECTORY "${_qt_default}") - message(STATUS "Qt_PATH not set or invalid — defaulting to ${_qt_default}") - set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) - endif() - endif() -endif() +IF(WIN32) + OPTION(SCIRUN_SHOW_CONSOLE "Show Windows console when running SCIRun (useful for debugging)." ON) + MARK_AS_ADVANCED(SCIRUN_SHOW_CONSOLE) +ENDIF() -# ------------------------- -# Validate Qt_PATH -# ------------------------- -if (NOT BUILD_HEADLESS) - if (NOT IS_DIRECTORY "${Qt_PATH}") - message(FATAL_ERROR - "Qt_PATH invalid or not set.\n" - "Must point to a Qt install prefix with lib/, bin/, and lib/cmake/QtX.\n" - "Examples:\n" - " Windows: C:/Qt/6.10.1/msvc2022_64\n" - " macOS: /Users//Qt/6.10.2/macos\n" - ) - endif() +########################################### +# Configure headless build +OPTION(BUILD_HEADLESS "Build SCIRun without GUI." OFF) - file(TO_CMAKE_PATH "${Qt_PATH}" _Qt_PREFIX) - list(PREPEND CMAKE_PREFIX_PATH "${_Qt_PREFIX}") - sb_prefix_append("${_Qt_PREFIX}") +########################################### +# Configure Qt - # ------------------------- - # Qt6 - # ------------------------- - if (SCIRUN_QT_MAJOR STREQUAL "6") - set(QT_MIN_VERSION "${QT6_MIN_VERSION}") - set(Qt6_DIR "${_Qt_PREFIX}/lib/cmake/Qt6") - if (NOT EXISTS "${Qt6_DIR}/Qt6Config.cmake") - message(FATAL_ERROR "Qt6Config.cmake not found at '${Qt6_DIR}'") - endif() +SET(DEFAULT_QT_MIN_VERSION "5.15.2") - find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS - Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL OpenGLWidgets - HINTS "${Qt_PATH}" - ) +set(SCIRUN_QT_MIN_VERSION ${DEFAULT_QT_MIN_VERSION} CACHE STRING "Qt version") +set_property(CACHE SCIRUN_QT_MIN_VERSION PROPERTY STRINGS 5.12.8 5.15.2 6.3.1) +string(REPLACE "." ";" SCIRUN_QT_MIN_VERSION_LIST ${SCIRUN_QT_MIN_VERSION}) +list(GET SCIRUN_QT_MIN_VERSION_LIST 0 QT_VERSION_MAJOR) +list(GET SCIRUN_QT_MIN_VERSION_LIST 1 QT_VERSION_MINOR) +list(GET SCIRUN_QT_MIN_VERSION_LIST 2 QT_VERSION_PATCH) - message(STATUS "[superbuild] Using Qt6_DIR='${Qt6_DIR}'") +IF(NOT BUILD_HEADLESS) - # ------------------------- - # Qt5 - # ------------------------- - elseif (SCIRUN_QT_MAJOR STREQUAL "5") - set(QT_MIN_VERSION "${QT5_MIN_VERSION}") - set(Qt5_DIR "${_Qt_PREFIX}/lib/cmake/Qt5") - if (NOT EXISTS "${Qt5_DIR}/Qt5Config.cmake}") - message(FATAL_ERROR "Qt5Config.cmake not found at '${Qt5_DIR}'") - endif() + SET(Qt_PATH "" CACHE PATH + "Path to directory where Qt is installed. Directory should contain lib and bin subdirectories.") - find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS - Core Gui Widgets Network Concurrent PrintSupport Svg OpenGL - HINTS "${Qt_PATH}" - ) + # ------------------------------------------------------------ + # Platform-specific Qt auto-detection + # ------------------------------------------------------------ + if(APPLE OR WIN32) - message(STATUS "[superbuild] Using Qt5_DIR='${Qt5_DIR}'") - else() - message(FATAL_ERROR "SCIRUN_QT_MAJOR must be '5' or '6'. Got: '${SCIRUN_QT_MAJOR}'") - endif() + # If user did NOT set Qt_PATH or path is invalid → try auto-detect + if(NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") - # ------------------------- - # Locate qmake (needed by Qwt) - # ------------------------- - if (SCIRUN_QT_MAJOR STREQUAL "6") - if (TARGET Qt6::qmake) - get_target_property(_qmake_path Qt6::qmake LOCATION) - else() - get_filename_component(_qt6_cmake_dir "${Qt6_DIR}" DIRECTORY) - get_filename_component(_qt6_prefix "${_qt6_cmake_dir}" DIRECTORY) - get_filename_component(_qt6_root "${_qt6_prefix}" DIRECTORY) - if (WIN32) - set(_qmake_path "${_qt6_root}/bin/qmake.exe") - else() - set(_qmake_path "${_qt6_root}/bin/qmake") - endif() - endif() - else() - if (TARGET Qt5::qmake) - get_target_property(_qmake_path Qt5::qmake LOCATION) - else() - get_filename_component(_qt5_cmake_dir "${Qt5_DIR}" DIRECTORY) - get_filename_component(_qt5_prefix "${_qt5_cmake_dir}" DIRECTORY) - get_filename_component(_qt5_root "${_qt5_prefix}" DIRECTORY) - if (WIN32) - set(_qmake_path "${_qt5_root}/bin/qmake.exe") - else() - set(_qmake_path "${_qt5_root}/bin/qmake") + if(APPLE) + set(_qt_default "/Users/basisunus/Qt/6.10.2/macos") + elseif(WIN32) + set(_qt_default "C:/Qt/6.10.1/msvc2022_64") endif() - endif() - endif() - - if (NOT _qmake_path OR NOT EXISTS "${_qmake_path}") - message(FATAL_ERROR "Could not locate qmake. Checked: ${_qmake_path}") - endif() - - set(QT_QMAKE_EXECUTABLE "${_qmake_path}" CACHE FILEPATH - "Path to Qt qmake for building Qwt" FORCE) - - message(STATUS "QT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}") -else() - add_definitions(-DBUILD_HEADLESS) -endif() -# ========================= -# Doxygen / codegen toggles -# ========================= -option(BUILD_DOCUMENTATION "Build documentation" OFF) -mark_as_advanced(BUILD_DOCUMENTATION) -option(GENERATE_MODULE_FACTORY_CODE "Generate module factory code from config files" ON) -mark_as_advanced(GENERATE_MODULE_FACTORY_CODE) -option(REGENERATE_MODULE_FACTORY_CODE "Delete generated module factory to refresh module list" ON) -mark_as_advanced(REGENERATE_MODULE_FACTORY_CODE) + if(IS_DIRECTORY "${_qt_default}") + message(STATUS + "Qt_PATH not set or invalid — using auto-detected Qt: ${_qt_default}" + ) -# ========================= -# Externals registration -# ========================= -set(SCIRUN_DEPENDENCIES) -macro(ADD_EXTERNAL cmake_file external) - include(${cmake_file}) - list(APPEND SCIRUN_DEPENDENCIES ${external}) -endmacro() + # Force-set Qt_PATH + set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) -set(SUPERBUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE) -set(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE) -set(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) + # -------------------------------------------------------- + # Auto-detect Qt version from directory structure + # + # Examples: + # macOS : /Users/.../Qt/6.10.2/macos + # Windows: C:/Qt/6.10.1/msvc2022_64 + # -------------------------------------------------------- + get_filename_component(_qt_parent "${_qt_default}" DIRECTORY) + get_filename_component(_qt_version "${_qt_parent}" NAME) -if(BUILD_TESTING) - ADD_EXTERNAL(${SUPERBUILD_DIR}/TestDataConfig.cmake SCIRunTestData_external) -endif() + set(SCIRUN_QT_MIN_VERSION + "${_qt_version}" + CACHE STRING "Qt version" FORCE) -ADD_EXTERNAL(${SUPERBUILD_DIR}/EigenExternal.cmake Eigen_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/ZlibExternal.cmake Zlib_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/SQLiteExternal.cmake SQLite_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/TeemExternal.cmake Teem_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/FreetypeExternal.cmake Freetype_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/GLMExternal.cmake GLM_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/SpdLogExternal.cmake SpdLog_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/TnyExternal.cmake Tny_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/LodePngExternal.cmake LodePng_external) -ADD_EXTERNAL(${SUPERBUILD_DIR}/Cleaver2External.cmake Cleaver2_external) + string(REPLACE "." ";" SCIRUN_QT_MIN_VERSION_LIST + ${SCIRUN_QT_MIN_VERSION}) -ADD_EXTERNAL(${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external) + list(GET SCIRUN_QT_MIN_VERSION_LIST 0 QT_VERSION_MAJOR) + list(GET SCIRUN_QT_MIN_VERSION_LIST 1 QT_VERSION_MINOR) + list(GET SCIRUN_QT_MIN_VERSION_LIST 2 QT_VERSION_PATCH) -if(BUILD_WITH_PYTHON) - ADD_EXTERNAL(${SUPERBUILD_DIR}/PythonExternal.cmake Python_external) -endif() - -find_package(Subversion) -if(NOT Subversion_FOUND) - set(BUILD_WITH_SCIRUN_DATA OFF) -endif() -if(BUILD_WITH_SCIRUN_DATA) - ADD_EXTERNAL(${SUPERBUILD_DIR}/SCIRunDataExternal.cmake SCI_data_external) -endif() - -if(WITH_TETGEN) - message(STATUS "Configuring Tetgen under GPL. Disable WITH_TETGEN to skip.") - ADD_EXTERNAL(${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external) # <- lowercase g -endif() - -if(WITH_OSPRAY) - ADD_EXTERNAL(${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external) -endif() - -# Keep Boost last so we can compute Boost_DIR & legacy hints afterward -ADD_EXTERNAL(${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external) - -# Qwt (Qt plotting) — build only when GUI is enabled -option(WITH_QWT "Build Qwt external (Qt plotting widgets)" ON) -if(NOT BUILD_HEADLESS AND WITH_QWT) - # Adjust the path if your QwtExternal.cmake lives elsewhere - ADD_EXTERNAL(${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external) -endif() - -# ========================= -# Exporters (config dir / include & lib dir) -# ========================= -function(_export_config_dir pkg target subdir_pattern) - if(NOT TARGET ${target}) - message(STATUS "[superbuild] ${target} not defined yet; skipping ${pkg}_DIR export.") - return() - endif() - ExternalProject_Get_Property(${target} INSTALL_DIR) - if(NOT INSTALL_DIR) - message(FATAL_ERROR "INSTALL_DIR not set for ${target}. Ensure INSTALL is enabled.") - endif() - - sb_prefix_append("${INSTALL_DIR}") - - string(TOUPPER "${pkg}" pkg_upper) - set(_candidates - "${INSTALL_DIR}/lib/cmake/${pkg}" - "${INSTALL_DIR}/lib/cmake/${pkg}-*" - "${INSTALL_DIR}/lib/cmake/${pkg_upper}" - "${INSTALL_DIR}/lib64/cmake/${pkg}" - "${INSTALL_DIR}/lib64/cmake/${pkg_upper}" - "${INSTALL_DIR}/share/${pkg}/cmake" - "${INSTALL_DIR}/cmake/${pkg}" - "${INSTALL_DIR}/CMake/${pkg}" - ) - unset(_found_dir) - foreach(_cand IN LISTS _candidates) - file(GLOB _hits "${_cand}") - foreach(_d IN LISTS _hits) - if(EXISTS "${_d}/${pkg}Config.cmake" OR EXISTS "${_d}/${pkg_upper}Config.cmake") - set(_found_dir "${_d}") - break() endif() - endforeach() - if(DEFINED _found_dir) - break() - endif() - endforeach() - - if(NOT DEFINED _found_dir) - message(STATUS "[superbuild] ${pkg}: no *Config.cmake under ${INSTALL_DIR} (expected if package doesn't export).") - return() - endif() - - set(${pkg}_DIR "${_found_dir}" CACHE PATH "${pkg} config dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_DIR:PATH=${${pkg}_DIR}") - set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) - message(STATUS "[superbuild] ${pkg}_DIR = ${${pkg}_DIR}") -endfunction() - -function(_sb_export_inc_lib pkg target) - if(NOT TARGET ${target}) - message(STATUS "[superbuild] ${target} not defined yet; skipping ${pkg} include/lib export.") - return() - endif() - ExternalProject_Get_Property(${target} INSTALL_DIR) - if(NOT INSTALL_DIR) - message(FATAL_ERROR "INSTALL_DIR not set for ${target}.") - endif() - - sb_prefix_append("${INSTALL_DIR}") - - set(_inc "${INSTALL_DIR}/include") - if(EXISTS "${INSTALL_DIR}/lib64") - set(_lib "${INSTALL_DIR}/lib64") - else() - set(_lib "${INSTALL_DIR}/lib") - endif() - - # Export include dir (unconditionally; path may exist after build) - set(${pkg}_INCLUDE_DIR "${_inc}" CACHE PATH "${pkg} include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_INCLUDE_DIR:PATH=${${pkg}_INCLUDE_DIR}") - - # Export lib dir if present - if(EXISTS "${_lib}") - set(${pkg}_LIB_DIR "${_lib}" CACHE PATH "${pkg} lib dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-D${pkg}_LIB_DIR:PATH=${${pkg}_LIB_DIR}") - endif() - - set(SCIRUN_CACHE_ARGS "${SCIRUN_CACHE_ARGS}" PARENT_SCOPE) - message(STATUS "[superbuild] ${pkg}: include=${_inc} lib=${_lib}") -endfunction() - -# ========================= -# Boost props/hints for downstream -# ========================= -if(TARGET Boost_external) - ExternalProject_Get_Property(Boost_external INSTALL_DIR) - set(SCI_BOOST_PREFIX "${INSTALL_DIR}" CACHE PATH "Boost install prefix" FORCE) - set(SCI_BOOST_INCLUDE "${INSTALL_DIR}/include" CACHE PATH "Boost include directory" FORCE) - if (WIN32 AND EXISTS "${INSTALL_DIR}/lib64") - set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib64") - else() - set(SCI_BOOST_LIBRARY_DIR "${INSTALL_DIR}/lib") - endif() - set(SCI_BOOST_LIBRARY_DIR "${SCI_BOOST_LIBRARY_DIR}" CACHE PATH "Boost library directory" FORCE) - - # Try versioned Boost-* dir first - set(Boost_DIR "") - file(GLOB _boost_cfg_dirs "${INSTALL_DIR}/lib/cmake/Boost*") - foreach(_bd IN LISTS _boost_cfg_dirs) - if(EXISTS "${_bd}/BoostConfig.cmake") - set(Boost_DIR "${_bd}") - break() - endif() - endforeach() - if(NOT Boost_DIR) - set(Boost_DIR "${INSTALL_DIR}/lib/cmake/Boost") - endif() - sb_prefix_append("${INSTALL_DIR}") -endif() -list(APPEND SCIRUN_CACHE_ARGS - "-DSCI_BOOST_INCLUDE:PATH=${SCI_BOOST_INCLUDE}" -) - -# ========================= -# Export externals (config or include/lib) -# ========================= -_export_config_dir(Zlib Zlib_external "") -_export_config_dir(Freetype Freetype_external "") -_export_config_dir(SQLite SQLite_external "") - -# Qwt block guarded by GUI flag and target existence -if(NOT BUILD_HEADLESS AND TARGET Qwt_external) - _export_config_dir(Qwt Qwt_external "") - - ExternalProject_Get_Property(Qwt_external INSTALL_DIR) - set(QWT_INSTALL_DIR "${INSTALL_DIR}") - set(QWT_INCLUDE_DIR "${QWT_INSTALL_DIR}/include") - if(EXISTS "${QWT_INSTALL_DIR}/lib64") - set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib64") - else() - set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") - endif() - - # (New) Pass fallback include/lib dirs to the inner SCIRun build as cache args, - # in case QwtConfig.cmake is not present. - list(APPEND SCIRUN_CACHE_ARGS - "-DQWT_INCLUDE_DIR:PATH=${QWT_INCLUDE_DIR}" - "-DQWT_LIBRARY_DIR:PATH=${QWT_LIBRARY_DIR}" - ) - - # Imported target here is only visible in superbuild scope; - # the inner project will use Qwt_DIR or QWT_* vars above. - add_library(Qwt::Qwt UNKNOWN IMPORTED GLOBAL) - add_dependencies(Qwt::Qwt Qwt_external) - set_property(TARGET Qwt::Qwt PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${QWT_INCLUDE_DIR}") - if(WIN32) - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_CONFIGURATIONS "Debug;Release") - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${QWT_LIBRARY_DIR}/qwt.lib") - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${QWT_LIBRARY_DIR}/qwtd.lib") # adjust if your build uses qwt_d.lib - elseif(APPLE) - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.dylib") - else() - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION "${QWT_LIBRARY_DIR}/libqwt.so") - endif() -else() - message(STATUS "[superbuild] Qwt not present (BUILD_HEADLESS ON or target missing); skipping Qwt exports.") -endif() - -# Prefer config dirs when possible (Windows GLEW sometimes exports one) -if(TARGET Glew_external) - _export_config_dir(GLEW Glew_external "") -endif() - -if(BUILD_WITH_PYTHON AND TARGET Python_external) - _export_config_dir(Python Python_external "") -endif() - -_export_config_dir(LodePNG LodePng_external "") -if(TARGET LodePng_external) - ExternalProject_Get_Property(LodePng_external INSTALL_DIR) - - set(_lp_inc "${INSTALL_DIR}/include") - set(_lp_lib "") - - # lib folder - if(EXISTS "${INSTALL_DIR}/lib64") - set(_lp_libdir "${INSTALL_DIR}/lib64") - else() - set(_lp_libdir "${INSTALL_DIR}/lib") - endif() - - # Cross‑platform library detection - if(WIN32) - if(EXISTS "${_lp_libdir}/lodepng.lib") - set(_lp_lib "${_lp_libdir}/lodepng.lib") - elseif(EXISTS "${_lp_libdir}/lodepngd.lib") - set(_lp_lib "${_lp_libdir}/lodepngd.lib") - endif() - elseif(APPLE) - if(EXISTS "${_lp_libdir}/liblodepng.a") - set(_lp_lib "${_lp_libdir}/liblodepng.a") - elseif(EXISTS "${_lp_libdir}/liblodepng.dylib") - set(_lp_lib "${_lp_libdir}/liblodepng.dylib") - endif() - else() - if(EXISTS "${_lp_libdir}/liblodepng.so") - set(_lp_lib "${_lp_libdir}/liblodepng.so") - elseif(EXISTS "${_lp_libdir}/liblodepng.a") - set(_lp_lib "${_lp_libdir}/liblodepng.a") - endif() - endif() - - # Define imported target - add_library(LodePNG::lodepng UNKNOWN IMPORTED GLOBAL) - set_property(TARGET LodePNG::lodepng PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_lp_inc}") - set_property(TARGET LodePNG::lodepng PROPERTY IMPORTED_LOCATION "${_lp_lib}") - - message(STATUS "[superbuild] Created imported target LodePNG::lodepng = ${_lp_lib}") -endif() - -# Include/lib hints (guarded by target existence) -_sb_export_inc_lib(Freetype Freetype_external) -_sb_export_inc_lib(GLM GLM_external) -_sb_export_inc_lib(SpdLog SpdLog_external) -_sb_export_inc_lib(Teem Teem_external) -_sb_export_inc_lib(Tny Tny_external) -_sb_export_inc_lib(Cleaver2 Cleaver2_external) -_sb_export_inc_lib(SQLite SQLite_external) -if(WITH_TETGEN AND TARGET Tetgen_external) # <- lowercase g - _sb_export_inc_lib(Tetgen Tetgen_external) -endif() -if(TARGET Glew_external) - _sb_export_inc_lib(GLEW Glew_external) -endif() -# macOS GLEW imported target -if(APPLE AND TARGET Glew_external) - ExternalProject_Get_Property(Glew_external INSTALL_DIR) - - set(_glew_inc "${INSTALL_DIR}/include") - set(_glew_libdir "${INSTALL_DIR}/lib") - - # Robust: match any case (libGLEW.a / libglew.a / .dylib / versioned) - file(GLOB _glew_candidates - "${_glew_libdir}/libGLEW*.a" - "${_glew_libdir}/libGLEW*.dylib" - "${_glew_libdir}/libglew*.a" - "${_glew_libdir}/libglew*.dylib" - ) - - list(LENGTH _glew_candidates _n) - if(_n EQUAL 0) - message(FATAL_ERROR - "[superbuild] No GLEW library found in ${_glew_libdir}. " - "Expected libGLEW.a or libglew.a etc." - ) - endif() - - # Use the first match - list(GET _glew_candidates 0 _glew_lib) - - add_library(GLEW::GLEW UNKNOWN IMPORTED GLOBAL) - set_property(TARGET GLEW::GLEW PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_glew_inc}") - set_property(TARGET GLEW::GLEW PROPERTY IMPORTED_LOCATION "${_glew_lib}") - - message(STATUS "[superbuild] Created GLEW::GLEW for macOS = ${_glew_lib}") -endif() - -# --- Install custom GLEWConfig.cmake for SCIRun on ALL platforms --- -if(TARGET Glew_external) - ExternalProject_Get_Property(Glew_external INSTALL_DIR) - - set(_glew_inc "${INSTALL_DIR}/include") - set(_glew_libdir "${INSTALL_DIR}/lib") - - # Match both uppercase/lowercase and static/shared - file(GLOB _glew_candidates - "${_glew_libdir}/libGLEW*.a" - "${_glew_libdir}/libGLEW*.dylib" - "${_glew_libdir}/libglew*.a" - "${_glew_libdir}/libglew*.dylib" - ) - - if(NOT _glew_candidates) - message(FATAL_ERROR "[superbuild] Could not locate a GLEW library in ${_glew_libdir}") - endif() - - list(GET _glew_candidates 0 _glew_lib) - - # Create config folder - set(_glew_cfg_dir "${INSTALL_DIR}/lib/cmake/GLEW") - file(MAKE_DIRECTORY "${_glew_cfg_dir}") - - # Configure the exported CMake config file - configure_file( - "${SUPERBUILD_DIR}/GLEWConfig.cmake.in" - "${_glew_cfg_dir}/GLEWConfig.cmake" - @ONLY - ) - - message(STATUS "[superbuild] Installed custom GLEWConfig.cmake at ${_glew_cfg_dir}") -endif() - -# Tell SCIRun where the Tny config lives -if(TARGET Tny_wrapper_external) - set(_TNY_CFG_DIR "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external/lib/cmake/Tny") - list(APPEND SCIRUN_CACHE_ARGS "-DTny_DIR:PATH=${_TNY_CFG_DIR}") -endif() - -# ========================= -# Build SCIRun cache args (APPEND, do not reset) -# ========================= -# Initialize once, then append everywhere (avoid wiping earlier appends) -if(NOT DEFINED SCIRUN_CACHE_ARGS) - set(SCIRUN_CACHE_ARGS "") -endif() -list(APPEND SCIRUN_CACHE_ARGS - "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" - "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" - "-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}" - "-DSCIRUN_BITS:STRING=${SCIRUN_BITS}" - "-DBUILD_TESTING:BOOL=${BUILD_TESTING}" - "-DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}" - "-DBUILD_HEADLESS:BOOL=${BUILD_HEADLESS}" - "-DSCIRUN_TEST_RESOURCE_DIR:PATH=${SCIRUN_TEST_RESOURCE_DIR}" - "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" - "-DUSER_PYTHON_VERSION:STRING=${USER_PYTHON_VERSION}" - "-DUSER_PYTHON_VERSION_MAJOR:STRING=${USER_PYTHON_VERSION_MAJOR}" - "-DUSER_PYTHON_VERSION_MINOR:STRING=${USER_PYTHON_VERSION_MINOR}" - "-DWITH_TETGEN:BOOL=${WITH_TETGEN}" - "-DWITH_OSPRAY:BOOL=${WITH_OSPRAY}" - "-DREGENERATE_MODULE_FACTORY_CODE:BOOL=${REGENERATE_MODULE_FACTORY_CODE}" - "-DGENERATE_MODULE_FACTORY_CODE:BOOL=${GENERATE_MODULE_FACTORY_CODE}" - "-DGENERATE_COMPILATION_DATABASE:BOOL=${GENERATE_COMPILATION_DATABASE}" - "-DSCIRUN_QT_MAJOR:STRING=${SCIRUN_QT_MAJOR}" - "-DQt_PATH:PATH=${Qt_PATH}" -) - -# Tell SCIRun where to find GLEW config -if(TARGET Glew_external) - ExternalProject_Get_Property(Glew_external INSTALL_DIR) - list(APPEND SCIRUN_CACHE_ARGS "-DGLEW_DIR:PATH=${INSTALL_DIR}/lib/cmake/GLEW") -endif() - -# ========================= -# Forward Python values to SCIRun (inner CMake), version-agnostic & robust -# ========================= -if(BUILD_WITH_PYTHON) - # Normalize paths to forward-slash form for CMake cache correctness - file(TO_CMAKE_PATH "${ep_base}/Source/Python_external" _PY_SRC) - set(_PY_INC "${_PY_SRC}/Include") - set(_PY_PC_INC "${_PY_SRC}/PC") - set(_PY_PCBUILD "${_PY_SRC}/PCbuild/amd64") - set(_PY_EXE "${_PY_PCBUILD}/python.exe") - - # --- Discover import libraries in PCbuild/amd64 --- - set(_PY_LIB_REL "") - set(_PY_LIB_DBG "") - - # Strategy A: use python.exe to get MAJOR.MINOR -> digits - set(_PY_DIGITS "") - if(EXISTS "${_PY_EXE}") - execute_process( - COMMAND "${_PY_EXE}" -c "import sys; print(f'{sys.version_info[0]}{sys.version_info[1]}')" - OUTPUT_VARIABLE _PY_DIGITS - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) - if(_PY_DIGITS MATCHES "^[0-9][0-9]+$") - if(EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") - set(_PY_LIB_REL "${_PY_PCBUILD}/python${_PY_DIGITS}.lib") - endif() - if(EXISTS "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") - set(_PY_LIB_DBG "${_PY_PCBUILD}/python${_PY_DIGITS}_d.lib") - endif() + else() + message(STATUS "Using user-provided Qt_PATH: ${Qt_PATH}") endif() - endif() - # Strategy B: scan for the newest python3*.lib if digits not derived or files not found - if(NOT _PY_LIB_REL OR NOT _PY_LIB_DBG) - file(GLOB _py_libs_all "${_PY_PCBUILD}/python3*.lib") - if(_py_libs_all) - list(SORT _py_libs_all) - list(REVERSE _py_libs_all) - # Pick best candidates by suffix - foreach(_L IN LISTS _py_libs_all) - get_filename_component(_bn "${_L}" NAME) - if(_bn MATCHES "^python([0-9][0-9][0-9])_d\\.lib$" AND NOT _PY_LIB_DBG) - set(_PY_LIB_DBG "${_L}") - elseif(_bn MATCHES "^python([0-9][0-9][0-9])\\.lib$" AND NOT _PY_LIB_REL) - set(_PY_LIB_REL "${_L}") - endif() - endforeach() + endif() # APPLE OR WIN32 + + # ------------------------------------------------------------ + # Qt package discovery + # ------------------------------------------------------------ + IF(IS_DIRECTORY "${Qt_PATH}") + if (QT_VERSION_MAJOR STREQUAL "6") + FIND_PACKAGE(Qt${QT_VERSION_MAJOR} ${SCIRUN_QT_MIN_VERSION} + COMPONENTS + DBus DBusTools + Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg + CoreTools GuiTools WidgetsTools OpenGLWidgets + REQUIRED + HINTS ${Qt_PATH}) + else() + FIND_PACKAGE(Qt${QT_VERSION_MAJOR} ${SCIRUN_QT_MIN_VERSION} + COMPONENTS + Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg + REQUIRED + HINTS ${Qt_PATH}) endif() - endif() - - # Helpful warning (first configure after clean may run before Python builds) - if(NOT (EXISTS "${_PY_LIB_REL}" OR EXISTS "${_PY_LIB_DBG}")) - message(WARNING - "[Python wiring] No python import libs found yet under ${_PY_PCBUILD}. " - "SCIRun configure is set to wait for Python_external build, but if you " - "manually run only configure, the files may not exist until Python builds." - ) - endif() - - # --- Build the cache args only with non-empty values --- - set(_SC_PY_ARGS + ELSE() + MESSAGE(SEND_ERROR + "Set Qt_PATH to the Qt install prefix (with bin/ and lib/) or enable BUILD_HEADLESS.") + ENDIF() + + # ------------------------------------------------------------ + # macOS-only settings + # ------------------------------------------------------------ + IF(APPLE) + SET(MACDEPLOYQT_OUTPUT_LEVEL 0 CACHE STRING + "Set macdeployqt output level (0–3)") + MARK_AS_ADVANCED(MACDEPLOYQT_OUTPUT_LEVEL) + ENDIF() + +ELSE() + ADD_DEFINITIONS(-DBUILD_HEADLESS) +ENDIF() + +########################################### +# Configure Doxygen documentation +OPTION(BUILD_DOCUMENTATION "Build documentation" OFF) +MARK_AS_ADVANCED(BUILD_DOCUMENTATION) + +######################################################################## +# Factory code generation options + +OPTION(GENERATE_MODULE_FACTORY_CODE "Generate module factory code from config files" ON) +MARK_AS_ADVANCED(GENERATE_MODULE_FACTORY_CODE) + +OPTION(REGENERATE_MODULE_FACTORY_CODE "Delete generated module factory code file in order to refresh module list" ON) +MARK_AS_ADVANCED(REGENERATE_MODULE_FACTORY_CODE) + +########################################### +# Configure externals + +SET( SCIRun_DEPENDENCIES ) + +MACRO(ADD_EXTERNAL cmake_file external) + INCLUDE( ${cmake_file} ) + LIST(APPEND SCIRun_DEPENDENCIES ${external}) +ENDMACRO() + +SET(SUPERBUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE) +SET(SCIRUN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src CACHE INTERNAL "" FORCE) +SET(SCIRUN_BINARY_DIR ${CMAKE_BINARY_DIR}/SCIRun CACHE INTERNAL "" FORCE) + +IF(BUILD_TESTING) + ADD_EXTERNAL( ${SUPERBUILD_DIR}/TestDataConfig.cmake SCIRunTestData_external ) +ENDIF() + +ADD_EXTERNAL( ${SUPERBUILD_DIR}/EigenExternal.cmake Eigen_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/ZlibExternal.cmake Zlib_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/SQLiteExternal.cmake SQLite_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/TeemExternal.cmake Teem_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/FreetypeExternal.cmake Freetype_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/GLMExternal.cmake GLM_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/SpdLogExternal.cmake SpdLog_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/TnyExternal.cmake Tny_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/LodePngExternal.cmake LodePng_external ) +ADD_EXTERNAL( ${SUPERBUILD_DIR}/Cleaver2External.cmake Cleaver2_external ) + +IF(WIN32) + ADD_EXTERNAL( ${SUPERBUILD_DIR}/GlewExternal.cmake Glew_external ) +ENDIF() + +IF(BUILD_WITH_PYTHON) + ADD_EXTERNAL( ${SUPERBUILD_DIR}/PythonExternal.cmake Python_external ) +ENDIF() + +FIND_PACKAGE(Subversion) +IF(NOT Subversion_FOUND) + SET(BUILD_WITH_SCIRUN_DATA OFF) +ENDIF() +IF(BUILD_WITH_SCIRUN_DATA) + ADD_EXTERNAL( ${SUPERBUILD_DIR}/SCIRunDataExternal.cmake SCI_data_external) +ENDIF() + +IF(WITH_TETGEN) + MESSAGE(STATUS "Configuring Tetgen library under GPL. The SCIRun InterfaceWithTetGen module can be disabled by setting the CMake build variable WITH_TETGEN to OFF.") + ADD_EXTERNAL( ${SUPERBUILD_DIR}/TetgenExternal.cmake Tetgen_external ) +ENDIF() + +IF(WITH_OSPRAY) + ADD_EXTERNAL( ${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external ) +ENDIF() + +IF(NOT BUILD_HEADLESS) + ADD_EXTERNAL( ${SUPERBUILD_DIR}/QwtExternal.cmake Qwt_external ) + #ADD_EXTERNAL( ${SUPERBUILD_DIR}/CtkExternal.cmake Ctk_external ) +ENDIF() + +ADD_EXTERNAL( ${SUPERBUILD_DIR}/BoostExternal.cmake Boost_external ) + +########################################### +# Download external data sources +OPTION(DOWNLOAD_TOOLKITS "Download toolkit repositories." ON) +MARK_AS_ADVANCED(DOWNLOAD_TOOLKITS) +IF(DOWNLOAD_TOOLKITS) + INCLUDE(${SUPERBUILD_DIR}/ToolkitsConfig.cmake) + EXTERNAL_TOOLKIT(BrainStimulator) + EXTERNAL_TOOLKIT(FwdInvToolkit) +ENDIF() + +SET(SCIRUN_CACHE_ARGS + "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" + "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}" + "-DSCIRUN_BINARY_DIR:PATH=${SCIRUN_BINARY_DIR}" + "-DSCIRUN_BITS:STRING=${SCIRUN_BITS}" + "-DBUILD_TESTING:BOOL=${BUILD_TESTING}" + "-DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}" + "-DBUILD_HEADLESS:BOOL=${BUILD_HEADLESS}" + "-DQT_VERSION_MAJOR:STRING=${QT_VERSION_MAJOR}" + "-DSCIRUN_TEST_RESOURCE_DIR:PATH=${SCIRUN_TEST_RESOURCE_DIR}" "-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}" - "-DPYTHON_INCLUDE_DIR:PATH=${_PY_INC}" - "-DPYTHON_RUNTIME_DIR:PATH=${_PY_PCBUILD}" - "-DPython_FIND_REGISTRY:STRING=NEVER" - "-DPython_FIND_STRATEGY:STRING=LOCATION" - "-DPython_ROOT_DIR:PATH=${_PY_SRC}" - "-DCMAKE_IGNORE_PREFIX_PATH:PATH=C:/Program Files/Python*;C:/Program Files (x86)/Python*" - "-DSCIRUN_EXPLICIT_BOOST_PYTHON_LINK:BOOL=ON" - ) - - if(EXISTS "${_PY_PC_INC}") - list(APPEND _SC_PY_ARGS "-DPYTHON_PC_INCLUDE_DIR:PATH=${_PY_PC_INC}") - endif() - if(EXISTS "${_PY_EXE}") - list(APPEND _SC_PY_ARGS "-DPYTHON_EXECUTABLE:FILEPATH=${_PY_EXE}") - endif() - if(_PY_LIB_REL) - list(APPEND _SC_PY_ARGS "-DPYTHON_LIBRARY_RELEASE:FILEPATH=${_PY_LIB_REL}") - endif() - if(_PY_LIB_DBG) - list(APPEND _SC_PY_ARGS "-DPYTHON_LIBRARY_DEBUG:FILEPATH=${_PY_LIB_DBG}") - endif() - - # Append to the inner project cache - list(APPEND SCIRUN_CACHE_ARGS ${_SC_PY_ARGS}) -endif() - -if(WIN32) - list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}") -endif() - -# FreeType essential hints -if(TARGET Freetype_external) - ExternalProject_Get_Property(Freetype_external INSTALL_DIR) - set(FREETYPE_INSTALL_DIR "${INSTALL_DIR}") - - set(Freetype_INCLUDE_DIR "${FREETYPE_INSTALL_DIR}/include") - set(FREETYPE_INCLUDE_DIR2 "${FREETYPE_INSTALL_DIR}/include/freetype2") - set(Freetype_LIB_DIR "${FREETYPE_INSTALL_DIR}/lib") - - list(APPEND SCIRUN_CACHE_ARGS - "-DFreetype_INCLUDE_DIR:PATH=${Freetype_INCLUDE_DIR}" - "-DFREETYPE_INCLUDE_DIR2:PATH=${FREETYPE_INCLUDE_DIR2}" - "-DFreetype_LIB_DIR:PATH=${Freetype_LIB_DIR}" - ) - - if(DEFINED Freetype_DIR) - list(APPEND SCIRUN_CACHE_ARGS "-DFreetype_DIR:PATH=${Freetype_DIR}") - else() - _export_config_dir(Freetype Freetype_external "lib/cmake/freetype") - endif() - - set(SCI_FREETYPE_INCLUDE "${Freetype_INCLUDE_DIR}" CACHE PATH "Legacy: FreeType include dir (ft2build.h)" FORCE) - set(SCI_FREETYPE_INCLUDE2 "${FREETYPE_INCLUDE_DIR2}" CACHE PATH "Legacy: FreeType include dir (freetype2)" FORCE) - set(SCI_FREETYPE_LIBRARY_DIR "${Freetype_LIB_DIR}" CACHE PATH "Legacy: FreeType library dir" FORCE) - - list(APPEND SCIRUN_CACHE_ARGS - "-DSCI_FREETYPE_INCLUDE:PATH=${SCI_FREETYPE_INCLUDE}" - "-DSCI_FREETYPE_INCLUDE2:PATH=${SCI_FREETYPE_INCLUDE2}" - "-DSCI_FREETYPE_LIBRARY_DIR:PATH=${SCI_FREETYPE_LIBRARY_DIR}" - ) -endif() - -# Zlib + Boost essential hints -if(TARGET Zlib_external) - ExternalProject_Get_Property(Zlib_external INSTALL_DIR) - set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") - - list(APPEND SCIRUN_CACHE_ARGS - "-DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR}" - "-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include" - "-DZLIB_USE_STATIC_LIBS:BOOL=ON" - ) - - if(WIN32) - if(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib") - elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlib.lib") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlib.lib") - elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/zlib1.lib") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/zlib1.lib") - endif() - elseif(APPLE) - if(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.a") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.a") - elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.dylib") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.dylib") - endif() - else() - if(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.a") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.a") - elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib/libz.so") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib/libz.so") - elseif(EXISTS "${ZLIB_INSTALL_DIR}/lib64/libz.so") - set(_zlib_lib "${ZLIB_INSTALL_DIR}/lib64/libz.so") - endif() - endif() - - if(DEFINED _zlib_lib AND EXISTS "${_zlib_lib}") - list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_LIBRARY:FILEPATH=${_zlib_lib}") - message(STATUS "[superbuild] Zlib library: ${_zlib_lib}") - else() - message(WARNING "[superbuild] Could not resolve ZLIB_LIBRARY at configure time; inner build may still find it via ZLIB_ROOT/CMAKE_PREFIX_PATH.") - endif() - - if(DEFINED Zlib_DIR) - list(APPEND SCIRUN_CACHE_ARGS "-DZLIB_DIR:PATH=${Zlib_DIR}") - else() - _export_config_dir(Zlib Zlib_external "lib/cmake/zlib") - endif() -endif() - -if(TARGET Boost_external) - list(APPEND SCIRUN_CACHE_ARGS - "-DSCI_BOOST_PREFIX:PATH=${SCI_BOOST_PREFIX}" - "-DSCI_BOOST_LIBRARY_DIR:PATH=${SCI_BOOST_LIBRARY_DIR}" - # Optional: keep Boost_DIR if you want (SCIRun on Windows skips config mode anyway) + "-DUSER_PYTHON_VERSION:STRING=${USER_PYTHON_VERSION}" + "-DUSER_PYTHON_VERSION_MAJOR:STRING=${USER_PYTHON_VERSION_MAJOR}" + "-DUSER_PYTHON_VERSION_MINOR:STRING=${USER_PYTHON_VERSION_MINOR}" + "-DWITH_TETGEN:BOOL=${WITH_TETGEN}" + "-DWITH_OSPRAY:BOOL=${WITH_OSPRAY}" + "-DREGENERATE_MODULE_FACTORY_CODE:BOOL=${REGENERATE_MODULE_FACTORY_CODE}" + "-DGENERATE_MODULE_FACTORY_CODE:BOOL=${GENERATE_MODULE_FACTORY_CODE}" + "-DEigen_DIR:PATH=${Eigen_DIR}" + "-DZlib_DIR:PATH=${Zlib_DIR}" + "-DSQLite_DIR:PATH=${SQLite_DIR}" "-DBoost_DIR:PATH=${Boost_DIR}" - # Explicit linking strategy (Option B): inner CMake will add BOOST_ALL_NO_LIB - "-DSCIRUN_EXPLICIT_BOOST_LINK:BOOL=ON" - ) -endif() - -# ===== Eigen (special-case exporter to prefer include/eigen3) ===== -if(TARGET Eigen_external) - ExternalProject_Get_Property(Eigen_external INSTALL_DIR) - set(_eigen_inc "${INSTALL_DIR}/include/eigen3") - if(NOT EXISTS "${_eigen_inc}/Eigen/Dense") - set(_eigen_inc "${INSTALL_DIR}/include") - endif() - - list(APPEND SCIRUN_CACHE_ARGS - "-DEigen_INCLUDE_DIR:PATH=${_eigen_inc}" - "-DSCIRUN_EIGEN_INCLUDE:PATH=${_eigen_inc}" - ) - sb_prefix_append("${INSTALL_DIR}") -endif() - -# Legacy alias variables (so existing SCIRun CMake picks them up) -if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) - set(LODEPNG_INCLUDE_DIR "${LodePng_INCLUDE_DIR}") -endif() - -if(DEFINED Eigen_INCLUDE_DIR) - set(SCIRUN_EIGEN_INCLUDE "${Eigen_INCLUDE_DIR}" CACHE PATH "Alias: Eigen include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-DSCIRUN_EIGEN_INCLUDE:PATH=${SCIRUN_EIGEN_INCLUDE}") -endif() -if(DEFINED GLEW_INCLUDE_DIR) - set(SCI_GLEW_INCLUDE "${GLEW_INCLUDE_DIR}" CACHE PATH "Legacy: GLEW include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-DSCI_GLEW_INCLUDE:PATH=${SCI_GLEW_INCLUDE}") -endif() -if(DEFINED LODEPNG_INCLUDE_DIR) - set(SCI_LODEPNG_INCLUDE "${LODEPNG_INCLUDE_DIR}" CACHE PATH "Legacy: LodePNG include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-DSCI_LODEPNG_INCLUDE:PATH=${SCI_LODEPNG_INCLUDE}") -endif() -if(DEFINED TNY_INCLUDE_DIR) - set(SCI_TNY_INCLUDE "${TNY_INCLUDE_DIR}" CACHE PATH "Legacy: TNY include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-DSCI_TNY_INCLUDE:PATH=${SCI_TNY_INCLUDE}") -endif() -if(DEFINED SQLite_INCLUDE_DIR) - set(SQLite3_INCLUDE_DIR "${SQLite_INCLUDE_DIR}" CACHE PATH "Alias: SQLite3 include dir" FORCE) - list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_INCLUDE_DIR:PATH=${SQLite3_INCLUDE_DIR}") -endif() - -# ---- Cleaver2 aliases (map to what inner expects) -if(DEFINED Cleaver2_INCLUDE_DIR) - file(TO_CMAKE_PATH "${Cleaver2_INCLUDE_DIR}" _cleaver2_inc_norm) - list(APPEND SCIRUN_CACHE_ARGS - "-DCLEAVER2_INCLUDE:PATH=${_cleaver2_inc_norm}" - "-DCLEAVER2_INCLUDE_DIR:PATH=${_cleaver2_inc_norm}" - "-DSCI_CLEAVER2_INCLUDE_DIR:PATH=${_cleaver2_inc_norm}" - ) -endif() - -if(DEFINED Cleaver2_LIB_DIR) - file(TO_CMAKE_PATH "${Cleaver2_LIB_DIR}" _cleaver2_libdir_norm) - list(APPEND SCIRUN_CACHE_ARGS - "-DCLEAVER2_LIBRARY_DIR:PATH=${_cleaver2_libdir_norm}" # <-- REQUIRED by inner - "-DCLEAVER2_LIB_DIR:PATH=${_cleaver2_libdir_norm}" # keep existing alias - "-DSCI_CLEAVER2_LIBRARY_DIR:PATH=${_cleaver2_libdir_norm}" # legacy alias - ) -endif() - -# library name (import lib on Windows is cleaver2.lib) -list(APPEND SCIRUN_CACHE_ARGS "-DCLEAVER2_LIBRARY:STRING=cleaver2") - -# --- Ensure SQLite hints are present AFTER base args --- -if(TARGET SQLite_external) - ExternalProject_Get_Property(SQLite_external INSTALL_DIR) - if(EXISTS "${INSTALL_DIR}/lib64") - set(_sqlite_lib_dir "${INSTALL_DIR}/lib64") - else() - set(_sqlite_lib_dir "${INSTALL_DIR}/lib") - endif() + "-DTeem_DIR:PATH=${Teem_DIR}" + "-DFreetype_DIR:PATH=${Freetype_DIR}" + "-DGLM_DIR:PATH=${GLM_DIR}" + "-DSPDLOG_DIR:PATH=${SPDLOG_DIR}" + "-DTNY_DIR:PATH=${TNY_DIR}" + "-DGLEW_DIR:PATH=${Glew_DIR}" + "-DLODEPNG_DIR:PATH=${LODEPNG_DIR}" + "-DCLEAVER2_DIR:PATH=${CLEAVER2_DIR}" + "-DSCI_DATA_DIR:PATH=${SCI_DATA_DIR}" + "-DGENERATE_COMPILATION_DATABASE:BOOL=${GENERATE_COMPILATION_DATABASE}" +) - list(APPEND SCIRUN_CACHE_ARGS - "-DSQLite_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" - "-DSQLite_LIB_DIR:PATH=${_sqlite_lib_dir}" - "-DSQLite3_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" +IF(BUILD_WITH_PYTHON) + LIST(APPEND SCIRUN_CACHE_ARGS + "-DPython_DIR:PATH=${Python_DIR}" + "-DPYTHON_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE}" ) +ENDIF() - if(WIN32) - set(_sqlite_lib "${_sqlite_lib_dir}/sqlite3.lib") - if(NOT EXISTS "${_sqlite_lib}" AND EXISTS "${_sqlite_lib_dir}/libsqlite3.lib") - set(_sqlite_lib "${_sqlite_lib_dir}/libsqlite3.lib") - endif() - elseif(APPLE) - set(_sqlite_lib "${_sqlite_lib_dir}/libsqlite3.dylib") - else() - set(_sqlite_lib "${_sqlite_lib_dir}/libsqlite3.so") - endif() - - if(EXISTS "${_sqlite_lib}") - list(APPEND SCIRUN_CACHE_ARGS "-DSQLite3_LIBRARY:FILEPATH=${_sqlite_lib}") - message(STATUS "[superbuild] SQLite library: ${_sqlite_lib}") - else() - message(STATUS "[superbuild] SQLite library: (not found yet at configure time)") - endif() - - message(STATUS "[superbuild] SQLite include: ${INSTALL_DIR}/include") - message(STATUS "[superbuild] SQLite lib dir: ${_sqlite_lib_dir}") -endif() - -# --- Ensure Teem hints are present AFTER base args --- -if(TARGET Teem_external) - ExternalProject_Get_Property(Teem_external INSTALL_DIR) - - if(EXISTS "${INSTALL_DIR}/lib64") - set(_teem_lib_dir "${INSTALL_DIR}/lib64") - else() - set(_teem_lib_dir "${INSTALL_DIR}/lib") - endif() - - list(APPEND SCIRUN_CACHE_ARGS - "-DTeem_INCLUDE_DIR:PATH=${INSTALL_DIR}/include" - "-DTeem_LIB_DIR:PATH=${_teem_lib_dir}" +IF(WITH_TETGEN) + LIST(APPEND SCIRUN_CACHE_ARGS + "-DTetgen_DIR:PATH=${Tetgen_DIR}" ) +ENDIF() - if(WIN32) - set(_teem_lib "${_teem_lib_dir}/teem.lib") - if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.lib") - set(_teem_lib "${_teem_lib_dir}/libteem.lib") - endif() - elseif(APPLE) - set(_teem_lib "${_teem_lib_dir}/libteem.dylib") - if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.a") - set(_teem_lib "${_teem_lib_dir}/libteem.a") - endif() - else() - set(_teem_lib "${_teem_lib_dir}/libteem.so") - if(NOT EXISTS "${_teem_lib}" AND EXISTS "${_teem_lib_dir}/libteem.a") - set(_teem_lib "${_teem_lib_dir}/libteem.a") - endif() - endif() - - if(EXISTS "${_teem_lib}") - list(APPEND SCIRUN_CACHE_ARGS "-DTeem_LIBRARY:FILEPATH=${_teem_lib}") - message(STATUS "[superbuild] Teem library: ${_teem_lib}") - else() - message(STATUS "[superbuild] Teem library: (not found yet at configure time)") - endif() - - message(STATUS "[superbuild] Teem include: ${INSTALL_DIR}/include") - message(STATUS "[superbuild] Teem lib dir: ${_teem_lib_dir}") -endif() - -# --- Provide Tetgen include/lib hints + actual library file --- -# Use the actual external target name: Tetgen_external (lowercase g) -if(WITH_TETGEN AND TARGET Tetgen_external) - ExternalProject_Get_Property(Tetgen_external INSTALL_DIR) - ExternalProject_Get_Property(Tetgen_external SOURCE_DIR) - - # Include dir: prefer install/include, else SOURCE_DIR/src, else SOURCE_DIR - set(_tet_inc "${INSTALL_DIR}/include") - if(NOT EXISTS "${_tet_inc}/tetgen.h") - if(EXISTS "${SOURCE_DIR}/src/tetgen.h") - set(_tet_inc "${SOURCE_DIR}/src") - elseif(EXISTS "${SOURCE_DIR}/tetgen.h") - set(_tet_inc "${SOURCE_DIR}") - endif() - endif() - - # Library directory - if(EXISTS "${INSTALL_DIR}/lib64") - set(_tet_lib_dir "${INSTALL_DIR}/lib64") - else() - set(_tet_lib_dir "${INSTALL_DIR}/lib") - endif() - - # ---- Cross‑platform library detection ---- - set(_tet_lib "") - - # macOS/Linux static/shared libs - file(GLOB _tet_lib_candidates - "${_tet_lib_dir}/libtet.a" - "${_tet_lib_dir}/libtetgen.a" - "${_tet_lib_dir}/libtetgen*.a" - "${_tet_lib_dir}/libtet.dylib" - "${_tet_lib_dir}/libtetgen.dylib" +IF(WITH_OSPRAY) + LIST(APPEND SCIRUN_CACHE_ARGS + "-DOspray_External_Dir:PATH=${OSPRAY_BUILD_DIR}" ) +ENDIF() - # Windows import libs - file(GLOB _tet_lib_candidates_win - "${_tet_lib_dir}/tetgen.lib" - "${_tet_lib_dir}/tet.lib" - "${_tet_lib_dir}/libtetgen.lib" +IF(WIN32) + LIST(APPEND SCIRUN_CACHE_ARGS + "-DSCIRUN_SHOW_CONSOLE:BOOL=${SCIRUN_SHOW_CONSOLE}" ) - - # Combine lists - list(APPEND _tet_lib_candidates ${_tet_lib_candidates_win}) - - # Pick first valid candidate - list(LENGTH _tet_lib_candidates _n) - if(_n GREATER 0) - list(GET _tet_lib_candidates 0 _tet_lib) - endif() - - # Normalize for cache args - if(_tet_inc) - file(TO_CMAKE_PATH "${_tet_inc}" _tet_inc_norm) - else() - set(_tet_inc_norm "") - endif() - - if(_tet_lib_dir) - file(TO_CMAKE_PATH "${_tet_lib_dir}" _tet_lib_dir_norm) - else() - set(_tet_lib_dir_norm "") - endif() - - if(_tet_lib) - file(TO_CMAKE_PATH "${_tet_lib}" _tet_lib_norm) - else() - set(_tet_lib_norm "") - endif() - - # Always pass include/lib dir; pass TETGEN_LIBRARY only if file was found - list(APPEND SCIRUN_CACHE_ARGS - "-DWITH_TETGEN:BOOL=ON" - "-DTETGEN_INCLUDE_DIR:PATH=${_tet_inc_norm}" - "-DTETGEN_LIB_DIR:PATH=${_tet_lib_dir_norm}" +ENDIF() + +IF(NOT BUILD_HEADLESS) + LIST(APPEND SCIRUN_CACHE_ARGS + "-DQt_PATH:PATH=${Qt_PATH}" + "-DQt${QT_VERSION_MAJOR}Core_DIR:PATH=${Qt${QT_VERSION_MAJOR}Core_DIR}" + "-DQt${QT_VERSION_MAJOR}CoreTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}CoreTools_DIR}" + "-DQt${QT_VERSION_MAJOR}Gui_DIR:PATH=${Qt${QT_VERSION_MAJOR}Gui_DIR}" + "-DQt${QT_VERSION_MAJOR}GuiTools_DIR:PATH=${Qt${QT_VERSION_MAJOR}GuiTools_DIR}" + "-DQt${QT_VERSION_MAJOR}OpenGL_DIR:PATH=${Qt${QT_VERSION_MAJOR}OpenGL_DIR}" + "-DQt${QT_VERSION_MAJOR}Network_DIR:PATH=${Qt${QT_VERSION_MAJOR}Network_DIR}" + "-DQt${QT_VERSION_MAJOR}Widgets_DIR:PATH=${Qt${QT_VERSION_MAJOR}Widgets_DIR}" + "-DQt${QT_VERSION_MAJOR}Concurrent_DIR:PATH=${Qt${QT_VERSION_MAJOR}Concurrent_DIR}" + "-DMACDEPLOYQT_OUTPUT_LEVEL:STRING=${MACDEPLOYQT_OUTPUT_LEVEL}" + "-DQWT_INCLUDE:PATH=${QWT_INCLUDE}" + "-DQWT_LIBRARY_DIR:PATH=${QWT_LIBRARY_DIR}" + "-DQWT_LIBRARY:STRING=${QWT_LIBRARY}" + "-DQWT_INSTALL_DIR:PATH=${QWT_INSTALL_DIR}" ) - if(_tet_lib_norm) - list(APPEND SCIRUN_CACHE_ARGS "-DTETGEN_LIBRARY:FILEPATH=${_tet_lib_norm}") - endif() - - message(STATUS "[superbuild] Tetgen: include=${_tet_inc_norm} libdir=${_tet_lib_dir_norm} lib=${_tet_lib_norm}") -endif() - -# Compose a single CMAKE_PREFIX_PATH for SCIRun -get_property(_acc GLOBAL PROPERTY SCIRUN_PREFIXES) -set(_joined_prefixes "") -if(_acc) - list(REMOVE_DUPLICATES _acc) - string(JOIN ";" _joined_prefixes ${_acc}) -endif() -set(_joined_prefixes_escaped "${_joined_prefixes}") -string(REPLACE ";" "\\;" _joined_prefixes_escaped "${_joined_prefixes}") +ENDIF() -# Ensure only one -DCMAKE_PREFIX_PATH is passed -set(_filtered "") -foreach(arg IN LISTS SCIRUN_CACHE_ARGS) - if(NOT arg MATCHES "^-DCMAKE_PREFIX_PATH:PATH=") - list(APPEND _filtered "${arg}") - endif() -endforeach() -set(SCIRUN_CACHE_ARGS "${_filtered}") -list(APPEND SCIRUN_CACHE_ARGS "-DCMAKE_PREFIX_PATH:PATH=${_joined_prefixes_escaped}") - -# Log what we will pass to SCIRun -message(STATUS "[superbuild] Final CMAKE_PREFIX_PATH for SCIRun: ${_joined_prefixes}") -message(STATUS "Superbuild passing to SCIRun:") -foreach(arg IN LISTS SCIRUN_CACHE_ARGS) - message(STATUS " ${arg}") -endforeach() - -# ========================= -# Helper: gate SCIRun configure on external artifacts -# ========================= -function(_sb_scirun_wait_for) - # Usage: - # _sb_scirun_wait_for(NAME FILES ... DIRS ...) - cmake_parse_arguments(WAIT "" "NAME" "FILES;DIRS" ${ARGN}) - if(NOT WAIT_NAME) - message(FATAL_ERROR "_sb_scirun_wait_for requires NAME") - endif() - set(_deps) - foreach(_f IN LISTS WAIT_FILES) - list(APPEND _deps "${_f}") - endforeach() - foreach(_d IN LISTS WAIT_DIRS) - list(APPEND _deps "${_d}") - endforeach() - if(_deps) - ExternalProject_Add_Step(SCIRun_external "wait_for_${WAIT_NAME}" - COMMAND ${CMAKE_COMMAND} -E echo "Waiting for ${WAIT_NAME} before SCIRun configure..." - DEPENDEES download - DEPENDERS configure - DEPENDS ${_deps} - ) - endif() -endfunction() - -# ========================= -# SCIRun ExternalProject -# ========================= -ExternalProject_Add(SCIRun_external - DEPENDS ${SCIRUN_DEPENDENCIES} +ExternalProject_Add( SCIRun_external + DEPENDS ${SCIRun_DEPENDENCIES} DOWNLOAD_COMMAND "" SOURCE_DIR ${SCIRUN_SOURCE_DIR} BINARY_DIR ${SCIRUN_BINARY_DIR} CMAKE_CACHE_ARGS ${SCIRUN_CACHE_ARGS} INSTALL_COMMAND "" ) - -# Ensure header copy steps run before SCIRun config/build -if(TARGET Glew_external-copy_headers) - add_dependencies(SCIRun_external Glew_external-copy_headers) -endif() -if(TARGET Tny_external-copy_headers) - add_dependencies(SCIRun_external Tny_external-copy_headers) -endif() -if(TARGET SQLite_external-copy_headers) - add_dependencies(SCIRun_external SQLite_external-copy_headers) -endif() - -# ========================= -# BOOST: header staging (no delete; copy only) + waits -# ========================= -if(WIN32) - set(_B2_BOOTSTRAP_CMD cmd /c bootstrap.bat) - set(_B2_HEADERS_CMD cmd /c .\\b2 headers) -else() - set(_B2_BOOTSTRAP_CMD ./bootstrap.sh) - set(_B2_HEADERS_CMD ./b2 headers) -endif() - -if(TARGET Boost_external) - ExternalProject_Add_Step(Boost_external bootstrap_b2 - COMMAND ${_B2_BOOTSTRAP_CMD} - WORKING_DIRECTORY - DEPENDEES update - DEPENDERS configure - COMMENT "Bootstrapping Boost.Build (b2)" - ) - - ExternalProject_Add_Step(Boost_external stage_headers - COMMAND ${_B2_HEADERS_CMD} - WORKING_DIRECTORY - DEPENDEES bootstrap_b2 - COMMENT "Running 'b2 headers' to generate the boost/ header tree" - ) - - if(NOT DEFINED _SB_BOOST_HEADERS_COPY_STEP_DEFINED) - ExternalProject_Add_Step(Boost_external stage_boost_headers_copy - COMMAND ${CMAKE_COMMAND} -E make_directory /include/boost - COMMAND ${CMAKE_COMMAND} -E copy_directory /boost /include/boost - DEPENDEES stage_headers - DEPENDERS build - BYPRODUCTS "/include/boost/array.hpp" - COMMENT "Staging full Boost headers into /include/boost (no delete)" - ) - set(_SB_BOOST_HEADERS_COPY_STEP_DEFINED TRUE) - endif() - - ExternalProject_Add_StepTargets(Boost_external stage_headers stage_boost_headers_copy) - - ExternalProject_Get_Property(Boost_external INSTALL_DIR) - _sb_scirun_wait_for(NAME boost - FILES - "${INSTALL_DIR}/include/boost/array.hpp" - "${INSTALL_DIR}/include/boost/exception/all.hpp" - DIRS "${INSTALL_DIR}/include/boost" - ) - add_dependencies(SCIRun_external Boost_external-stage_boost_headers_copy) -endif() - -if(TARGET Boost_external AND TARGET Python_external) - add_dependencies(SCIRun_external Python_external) - add_dependencies(Boost_external Python_external) -endif() - -# ========================= -# Gate SCIRun configure on other externals' headers -# ========================= -if(TARGET Glew_external) - ExternalProject_Get_Property(Glew_external INSTALL_DIR) - _sb_scirun_wait_for(NAME glew - FILES "${INSTALL_DIR}/include/GL/glew.h" - DIRS "${INSTALL_DIR}/include" - ) -endif() - -if(TARGET GLM_external) - ExternalProject_Get_Property(GLM_external INSTALL_DIR) - _sb_scirun_wait_for(NAME glm - FILES "${INSTALL_DIR}/include/glm/glm.hpp" - DIRS "${INSTALL_DIR}/include" - ) -endif() - -if(TARGET LodePng_external) - ExternalProject_Get_Property(LodePng_external INSTALL_DIR) - - # Detect lib dir - set(_lodepng_libdir "${INSTALL_DIR}/lib") - if(EXISTS "${INSTALL_DIR}/lib64") - set(_lodepng_libdir "${INSTALL_DIR}/lib64") - endif() - - if(WIN32) - # Windows produces .lib and optionally .pdb - _sb_scirun_wait_for(NAME lodepng - FILES - "${INSTALL_DIR}/include/lodepng/lodepng.h" - "${_lodepng_libdir}/lodepng.lib" - "${_lodepng_libdir}/lodepngd.lib" - DIRS - "${INSTALL_DIR}/include" "${_lodepng_libdir}" - ) - - elseif(APPLE) - # macOS: static lib only (liblodepng.a) - _sb_scirun_wait_for(NAME lodepng - FILES - "${INSTALL_DIR}/include/lodepng/lodepng.h" - "${_lodepng_libdir}/liblodepng.a" - DIRS - "${INSTALL_DIR}/include" "${_lodepng_libdir}" - ) - - else() # Linux / other Unix - # Linux may build static or shared lib - _sb_scirun_wait_for(NAME lodepng - FILES - "${INSTALL_DIR}/include/lodepng/lodepng.h" - "${_lodepng_libdir}/liblodepng.a" - "${_lodepng_libdir}/liblodepng.so" - DIRS - "${INSTALL_DIR}/include" "${_lodepng_libdir}" - ) - endif() -endif() - -if(TARGET SQLite_external) - ExternalProject_Get_Property(SQLite_external INSTALL_DIR) - _sb_scirun_wait_for(NAME sqlite - FILES "${INSTALL_DIR}/include/sqlite3.h" - DIRS "${INSTALL_DIR}/include" - ) -endif() - -if(TARGET Tny_external) - ExternalProject_Get_Property(Tny_external INSTALL_DIR) - _sb_scirun_wait_for(NAME tny - FILES "${INSTALL_DIR}/include/tny/tny.hpp" - DIRS "${INSTALL_DIR}/include" - ) -endif() - -if(TARGET Teem_external) - ExternalProject_Get_Property(Teem_external INSTALL_DIR) - _sb_scirun_wait_for(NAME teem - DIRS "${INSTALL_DIR}/include" - ) -endif() - -if(NOT BUILD_HEADLESS AND TARGET Qwt_external) - ExternalProject_Get_Property(Qwt_external INSTALL_DIR) - if(NOT INSTALL_DIR) - set(INSTALL_DIR "${CMAKE_BINARY_DIR}/Externals/Install/Qwt_external") - endif() - - _sb_scirun_wait_for(NAME qwt - FILES - "${INSTALL_DIR}/include/qwt/qwt_plot.h" - "${INSTALL_DIR}/lib/cmake/Qwt/QwtConfig.cmake" - DIRS - "${INSTALL_DIR}/include/qwt" - "${INSTALL_DIR}/lib" - ) -endif() - -# --- Wait for Eigen headers (including unsupported/Tensor) before SCIRun configure --- -if(TARGET Eigen_external) - ExternalProject_Get_Property(Eigen_external INSTALL_DIR) - set(_eigen_inc "${INSTALL_DIR}/include/eigen3") - _sb_scirun_wait_for(NAME eigen - FILES - "${_eigen_inc}/Eigen/Dense" - "${_eigen_inc}/unsupported/Eigen/CXX11/Tensor" - DIRS "${_eigen_inc}" - ) -endif() - -# --- Gate SCIRun configure on Cleaver2 headers (vec3.h) --- -if(TARGET Cleaver2_external) - ExternalProject_Add_StepTargets(Cleaver2_external copy_headers) - ExternalProject_Get_Property(Cleaver2_external INSTALL_DIR) - _sb_scirun_wait_for(NAME cleaver2 - FILES "${INSTALL_DIR}/include/cleaver2/vec3.h" - DIRS "${INSTALL_DIR}/include/cleaver2" - ) - add_dependencies(SCIRun_external Cleaver2_external-copy_headers) -endif() - -# --- Cross-platform: Ensure SCIRun configure waits for Python_external build --- -if(BUILD_WITH_PYTHON AND TARGET Python_external) - - if(COMMAND ExternalProject_Add_StepDependencies) - ExternalProject_Add_StepDependencies(SCIRun_external configure Python_external) - message(STATUS "[superbuild] SCIRun_external: 'configure' will wait on Python_external.") - endif() - - ExternalProject_Get_Property(Python_external SOURCE_DIR) - ExternalProject_Get_Property(Python_external BINARY_DIR) - - if(WIN32) - # ----------------------------- - # Windows CPython build - # ----------------------------- - set(_py_pcbuild "${SOURCE_DIR}/PCbuild/amd64") - - file(GLOB _py_wait_libs "${_py_pcbuild}/python3*.lib") - set(_py_wait_files - "${_py_pcbuild}/python.exe" - ${_py_wait_libs} - ) - - _sb_scirun_wait_for(NAME python - FILES ${_py_wait_files} - DIRS "${_py_pcbuild}" - ) - - else() - # ----------------------------- - # macOS/Linux: CPython via CMake - # No install step; all outputs live directly in BINARY_DIR - # ----------------------------- - file(GLOB _py_wait_bins - "${BINARY_DIR}/python3" - "${BINARY_DIR}/python3.*" - "${BINARY_DIR}/python" - ) - - file(GLOB _py_wait_libs - "${BINARY_DIR}/libpython*.a" - "${BINARY_DIR}/libpython*.dylib" - "${BINARY_DIR}/libpython*.so" - ) - - _sb_scirun_wait_for(NAME python - FILES - ${_py_wait_bins} - ${_py_wait_libs} - DIRS - "${BINARY_DIR}" - ) - endif() -endif() - -if(TARGET Freetype_external) - ExternalProject_Get_Property(Freetype_external INSTALL_DIR) - - if(WIN32) - # Windows installs flat include layout - _sb_scirun_wait_for(NAME freetype - FILES - "${INSTALL_DIR}/include/ft2build.h" - DIRS - "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" - ) - else() - # macOS / Linux layout (freetype2/) - _sb_scirun_wait_for(NAME freetype - FILES - "${INSTALL_DIR}/include/freetype2/ft2build.h" - "${INSTALL_DIR}/include/freetype2/freetype/config/ftheader.h" - DIRS - "${INSTALL_DIR}/include" "${INSTALL_DIR}/lib" - ) - endif() -endif() \ No newline at end of file diff --git a/Superbuild/TeemExternal.cmake b/Superbuild/TeemExternal.cmake index d6382867b4..ea3c227fdc 100644 --- a/Superbuild/TeemExternal.cmake +++ b/Superbuild/TeemExternal.cmake @@ -1,4 +1,4 @@ -# For more information, please see: http://software.sci.utah.edu +# For more information, please see: http://software.sci.utah.edu # # The MIT License # @@ -24,97 +24,28 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +SET(teem_GIT_TAG "origin/adjust-png") +SET(teem_DEPENDENCIES "Zlib_external") -# TeemExternal.cmake — wire Teem to the installed zlib - -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -set(teem_GIT_TAG "v1.11.1") -set(teem_DEPENDENCIES Zlib_external) - -# Superbuild directories -set(_teem_src "${CMAKE_BINARY_DIR}/Externals/Source/Teem_external") -set(_teem_bin "${CMAKE_BINARY_DIR}/Externals/Build/Teem_external") -set(_teem_inst "${CMAKE_BINARY_DIR}/Externals/Install/Teem_external") - -# Teem CMake args -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_INSTALL_PREFIX= - - # Make Teem find our installed zlib - -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR} - -DZLIB_ROOT=${ZLIB_INSTALL_DIR} - -DZLIB_INCLUDE_DIR=${ZLIB_INSTALL_DIR}/include - -DZLIB_USE_STATIC_LIBS=ON - - # Keep optional deps minimal for now - -DTeem_ZLIB=ON - -DTeem_PNG=OFF - -DTeem_BZIP2=OFF - -DTeem_FFTW=OFF -) - -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -endif() - +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Teem_external DEPENDS ${teem_DEPENDENCIES} - - GIT_REPOSITORY "https://github.com/CIBC-Internal/teem.git" - GIT_TAG ${teem_GIT_TAG} - UPDATE_DISCONNECTED 1 - - SOURCE_DIR ${_teem_src} - BINARY_DIR ${_teem_bin} - INSTALL_DIR ${_teem_inst} # ensure install goes to Externals/Install/Teem_external - - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - - CMAKE_ARGS - ${_cmake_args} - + GIT_REPOSITORY "https://github.com/SCIInstitute/teem.git" + GIT_TAG ${teem_GIT_TAG} + PATCH_COMMAND "" + INSTALL_DIR "" + INSTALL_COMMAND "" CMAKE_CACHE_ARGS -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DCMAKE_INSTALL_PREFIX:PATH= - -DZlib_DIR:PATH=${Zlib_DIR} - -DCMAKE_PREFIX_PATH:PATH=${ZLIB_INSTALL_DIR} - -DZLIB_ROOT:PATH=${ZLIB_INSTALL_DIR} - -DZLIB_INCLUDE_DIR:PATH=${ZLIB_INSTALL_DIR}/include - -DZLIB_USE_STATIC_LIBS:BOOL=ON - - -DTeem_ZLIB:BOOL=ON - -DTeem_PNG:BOOL=OFF - -DTeem_BZIP2:BOOL=OFF - -DTeem_FFTW:BOOL=OFF - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + -DTeem_USE_NRRD_INTERNALS:BOOL=ON ) -ExternalProject_Add_Step(Teem_external wait_for_zlib - COMMAND ${CMAKE_COMMAND} -E echo "Waiting for zlib artifacts..." - DEPENDEES download - DEPENDERS configure - DEPENDS - "${ZLIB_INSTALL_DIR}/include/zlib.h" - "${ZLIB_INSTALL_DIR}/lib" -) - -# Export variables for SCIRun (consumer side) -set(TEEM_SOURCE_DIR ${_teem_src}) -set(TEEM_INSTALL_DIR ${_teem_inst}) - -# After enabling install, point includes to the installed headers -set(TEEM_INCLUDE ${TEEM_INSTALL_DIR}/include) -set(TEEM_LIBRARY_DIR ${TEEM_INSTALL_DIR}/lib) -set(TEEM_LIBRARY "teem") +ExternalProject_Get_Property(Teem_external BINARY_DIR) +SET(Teem_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "[Teem_external] INSTALL_DIR=${TEEM_INSTALL_DIR}") \ No newline at end of file +MESSAGE(STATUS "Teem_DIR: ${Teem_DIR}") diff --git a/Superbuild/TetgenExternal.cmake b/Superbuild/TetgenExternal.cmake index b66a7b3589..f40cfd33f9 100644 --- a/Superbuild/TetgenExternal.cmake +++ b/Superbuild/TetgenExternal.cmake @@ -24,43 +24,37 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# TetgenExternal.cmake (Variant A: TetGen repo has CMake build) +# ------------------------------------------------------- +# TetgenExternal.cmake - unified Windows/macOS/Linux version +# ------------------------------------------------------- + set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") -# Common CMake args +# Common CMake args for external TetGen set(_cmake_args -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON - # Force output directories so we can skip the install step -DCMAKE_INSTALL_PREFIX= -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=/lib -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/lib -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/bin - - # Multi-config (VS) subdirs - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG=/lib - -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=/lib - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=/bin - -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=/bin ) -# For single-config generators (Ninja, Makefiles), propagate build type +# Handle single‑config (Ninja/Makefiles) if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) endif() -# Where to build/install inside the superbuild tree -set(_tetgen_src "${CMAKE_BINARY_DIR}/Externals/Source/Tetgen_external") -set(_tetgen_bin "${CMAKE_BINARY_DIR}/Externals/Build/Tetgen_external") +# Superbuild paths +set(_tetgen_src "${CMAKE_BINARY_DIR}/Externals/Source/Tetgen_external") +set(_tetgen_bin "${CMAKE_BINARY_DIR}/Externals/Build/Tetgen_external") set(_tetgen_inst "${CMAKE_BINARY_DIR}/Externals/Install/Tetgen_external") ExternalProject_Add(Tetgen_external GIT_REPOSITORY https://github.com/CIBC-Internal/TetGen.git - GIT_TAG v1.6.1 # or your tag like v1.6.0-scirun1 - UPDATE_DISCONNECTED 1 # speed up: don't ping remote every run + GIT_TAG v1.6.1 + UPDATE_DISCONNECTED 1 SOURCE_DIR ${_tetgen_src} BINARY_DIR ${_tetgen_bin} @@ -70,32 +64,36 @@ ExternalProject_Add(Tetgen_external CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" CMAKE_ARGS ${_cmake_args} - - # We direct outputs to , so a separate "install" step is unnecessary. - INSTALL_COMMAND "" - - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 + INSTALL_COMMAND "" # because we set output dirs directly ) -# Exported properties/variables for SCIRun's internal CMake +# Obtain external project properties ExternalProject_Get_Property(Tetgen_external SOURCE_DIR) -set(TETGEN_SOURCE_DIR ${SOURCE_DIR}) +ExternalProject_Get_Property(Tetgen_external BINARY_DIR) +ExternalProject_Get_Property(Tetgen_external INSTALL_DIR) + +# ------------------------------------------------------- +# Unified exported variables (working on Windows + macOS) +# ------------------------------------------------------- -# Mirror used above so downstream knows where to look set(TETGEN_INSTALL_DIR ${_tetgen_inst}) -set(TETGEN_INCLUDE ${TETGEN_SOURCE_DIR}) # headers live in tree for TetGen -set(TETGEN_LIBRARY_DIR ${TETGEN_INSTALL_DIR}/lib) -set(TETGEN_LIBRARY "tet") # adjust if your CMakeLists names it differently +set(TETGEN_INCLUDE ${SOURCE_DIR}) +set(TETGEN_LIBRARY_DIR ${TETGEN_INSTALL_DIR}/lib) +set(TETGEN_LIBRARY "tet") # matches TetGen’s CMakeLists -# (Optional) generate simple config/use files for downstream +# Create config + use scripts for downstream projects file(MAKE_DIRECTORY "${TETGEN_INSTALL_DIR}") + +set(TETGEN_USE_FILE "${TETGEN_INSTALL_DIR}/UseTetgen.cmake") + configure_file(${SUPERBUILD_DIR}/TetgenConfig.cmake.in ${TETGEN_INSTALL_DIR}/TetgenConfig.cmake @ONLY) + configure_file(${SUPERBUILD_DIR}/UseTetgen.cmake - ${TETGEN_INSTALL_DIR}/UseTetgen.cmake COPYONLY) + ${TETGEN_USE_FILE} COPYONLY) -# Cache hints for find_package(... CONFIG) +# register for find_package(Tetgen CONFIG) set(Tetgen_DIR ${TETGEN_INSTALL_DIR} CACHE PATH "") + message(STATUS "[Tetgen_external] INSTALL_DIR=${TETGEN_INSTALL_DIR}") +message(STATUS "[Tetgen_external] USE_FILE=${TETGEN_USE_FILE}") \ No newline at end of file diff --git a/Superbuild/TnyExternal.cmake b/Superbuild/TnyExternal.cmake index 9fdc3924e2..f852d21a4b 100644 --- a/Superbuild/TnyExternal.cmake +++ b/Superbuild/TnyExternal.cmake @@ -24,94 +24,20 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# TnyExternal.cmake (updated) +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -# Final install prefix for Tny artifacts -set(_tny_inst "${CMAKE_BINARY_DIR}/Externals/Install/Tny_external") - -# 1) Fetch upstream Tny (no configure/build/install here) +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Tny_external GIT_REPOSITORY "https://github.com/CIBC-Internal/Tny.git" - GIT_TAG "origin/master" - UPDATE_DISCONNECTED 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - LOG_DOWNLOAD 1 - LOG_UPDATE 1 -) - -ExternalProject_Get_Property(Tny_external SOURCE_DIR) - -# 2) Copy headers (your existing step) -# Place them under /include/tny/ so #include works -ExternalProject_Add_Step(Tny_external copy_headers - COMMAND ${CMAKE_COMMAND} -E make_directory ${_tny_inst}/include/tny - COMMAND ${CMAKE_COMMAND} -Dsrc=${SOURCE_DIR}/src/tny -Ddst=${_tny_inst}/include/tny - -P ${CMAKE_CURRENT_LIST_DIR}/TnyInstall.cmake - DEPENDEES download - DEPENDERS build - COMMENT "[Tny_external] Copying headers" -) - -# 3) Build a small static library from tny.c using CMake -E cmake_script -# We create a build.ninja/msbuild generator-less compile via a one-off CMake configure+build -set(_tny_build_dir "${CMAKE_BINARY_DIR}/Externals/Build/Tny_wrapper") -file(MAKE_DIRECTORY "${_tny_build_dir}") - -# Generate a minimal CMakeLists.txt for building the library -file(WRITE "${_tny_build_dir}/CMakeLists.txt" " -cmake_minimum_required(VERSION 3.16) -project(tny_wrapper C) -add_library(tny STATIC \"${SOURCE_DIR}/src/tny/tny.c\") -target_include_directories(tny PUBLIC \"${_tny_inst}/include\") -if(MSVC) - set_target_properties(tny PROPERTIES DEBUG_POSTFIX d) -endif() -install(TARGETS tny - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin -) -") - -# Configure & build the wrapper, then install to _tny_inst -ExternalProject_Add(Tny_wrapper_external - SOURCE_DIR "${_tny_build_dir}" - BINARY_DIR "${_tny_build_dir}/_build" - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX:PATH=${_tny_inst} - -DCMAKE_BUILD_TYPE:STRING=$,Debug,Release> - BUILD_ALWAYS 1 - INSTALL_COMMAND ${CMAKE_COMMAND} --build --target install - DEPENDS Tny_external - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 -) - -# 4) Install a proper TnyConfig.cmake for find_package(Tny CONFIG) -add_custom_target(Tny_export ALL - COMMAND ${CMAKE_COMMAND} -E make_directory ${_tny_inst}/lib/cmake/Tny - COMMAND ${CMAKE_COMMAND} - -DTNY_INC:PATH=${_tny_inst}/include - -DTNY_LIB:PATH=${_tny_inst}/lib/$,tnyd.lib,tny.lib> - -P ${CMAKE_CURRENT_LIST_DIR}/TnyWriteConfig.cmake - DEPENDS Tny_wrapper_external - COMMENT "[Tny_external] Writing TnyConfig.cmake" + GIT_TAG "origin/scirun-5.0.0" + INSTALL_COMMAND "" + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) -# Helper script to expand the @ONLY template with the correct lib for the current config -file(WRITE "${CMAKE_CURRENT_LIST_DIR}/TnyWriteConfig.cmake" " -set(_cfg_dir \"${_tny_inst}/lib/cmake/Tny\") -file(MAKE_DIRECTORY \"\${_cfg_dir}\") -configure_file(\"${SUPERBUILD_DIR}/TnyConfig.cmake.in\" \"\${_cfg_dir}/TnyConfig.cmake\" @ONLY) -") +ExternalProject_Get_Property(Tny_external BINARY_DIR) +SET(TNY_DIR ${BINARY_DIR}) -# Export paths for downstream (SCIRun) -set(TNY_INSTALL_DIR "${_tny_inst}") -set(TNY_INCLUDE "${TNY_INSTALL_DIR}/include") -set(TNY_LIBRARY_DIR "${TNY_INSTALL_DIR}/lib") -message(STATUS "[Tny_external] INSTALL_DIR=${TNY_INSTALL_DIR}") \ No newline at end of file +MESSAGE(STATUS "TNY_DIR: ${TNY_DIR}") diff --git a/Superbuild/WriteProjectConfigJam.cmake b/Superbuild/WriteProjectConfigJam.cmake new file mode 100644 index 0000000000..27cc404780 --- /dev/null +++ b/Superbuild/WriteProjectConfigJam.cmake @@ -0,0 +1,3 @@ +file(WRITE "${OUTPUT_FILE}" +"using python : ${VERSION} : ${EXE} : ${INCLUDE} : ${LIBDIR} ; +") diff --git a/Superbuild/ZlibExternal.cmake b/Superbuild/ZlibExternal.cmake index 6d719cb634..40da2a5d92 100644 --- a/Superbuild/ZlibExternal.cmake +++ b/Superbuild/ZlibExternal.cmake @@ -1,21 +1,21 @@ # For more information, please see: http://software.sci.utah.edu -# +# # The MIT License -# +# # Copyright (c) 2015 Scientific Computing and Imaging Institute, # University of Utah. -# -# +# +# # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# +# in all copies or substantial portions of the Software. +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -24,96 +24,24 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) +SET(zlib_GIT_TAG "origin/1.3.1") -# ZlibExternal.cmake (modernized + consistent) - -# ZlibExternal.cmake — installs zlib and exports an installed prefix for consumers - -# ZlibExternal.cmake — install zlib and export a clean install prefix for consumers - -set_property(DIRECTORY PROPERTY EP_BASE "${ep_base}") - -set(zlib_GIT_TAG "v1.3.1.2") - -# No output redirection; let install populate a normal prefix -set(_cmake_args - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_INSTALL_PREFIX= - # (optional) -DBUILD_SHARED_LIBS=OFF -) - -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) - list(APPEND _cmake_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -endif() - -set(_zlib_src "${CMAKE_BINARY_DIR}/Externals/Source/Zlib_external") -set(_zlib_bin "${CMAKE_BINARY_DIR}/Externals/Build/Zlib_external") -set(_zlib_inst "${CMAKE_BINARY_DIR}/Externals/Install/Zlib_external") - +# If CMake ever allows overriding the checkout command or adding flags, +# git checkout -q will silence message about detached head (harmless). ExternalProject_Add(Zlib_external GIT_REPOSITORY "https://github.com/CIBC-Internal/zlib.git" - GIT_TAG ${zlib_GIT_TAG} - UPDATE_DISCONNECTED 1 - - SOURCE_DIR ${_zlib_src} - BINARY_DIR ${_zlib_bin} - - CMAKE_GENERATOR "${CMAKE_GENERATOR}" - CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" - CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" - - CMAKE_ARGS - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_INSTALL_PREFIX= - # Optional – prefer static libraries everywhere: - # -DBUILD_SHARED_LIBS=OFF - - INSTALL_COMMAND "${CMAKE_COMMAND}" --build . --target install - - # Let the generator know which files must exist before dependents configure - BUILD_BYPRODUCTS - "${_zlib_inst}/include/zlib.h" - "${_zlib_inst}/include/zconf.h" - # We don't rely on exact names later, but byproducts help ordering. - "${_zlib_inst}/lib/z.lib" - "${_zlib_inst}/lib/libz.a" - "${_zlib_inst}/lib/libz.so" - "${_zlib_inst}/lib/libz.dylib" + GIT_TAG ${zlib_GIT_TAG} + PATCH_COMMAND "" + INSTALL_DIR "" + INSTALL_COMMAND "" + CMAKE_CACHE_ARGS + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ) -# Export just the prefix (cached so other files/functions can see it) -ExternalProject_Get_Property(Zlib_external INSTALL_DIR) -set(ZLIB_INSTALL_DIR "${INSTALL_DIR}" CACHE PATH "zlib install prefix" FORCE) -set(Zlib_DIR "${ZLIB_INSTALL_DIR}/lib/cmake/zlib" CACHE PATH "zlib config directory" FORCE) - -# ---------------- Export for other externals (FreeType, etc.) ---------------- -# Always export the install prefix and canonical include/lib dirs to the cache. -# IMPORTANT: do NOT test for file existence here — these files are built later. - -# 1) Install prefix -set(ZLIB_INSTALL_DIR "${_zlib_inst}" CACHE PATH "zlib install prefix" FORCE) - -# 2) Include directory that contains zlib.h (this is what FindZLIB expects) -set(ZLIB_INCLUDE_DIR "${ZLIB_INSTALL_DIR}/include" CACHE PATH "zlib include dir" FORCE) - -# 3) Library directory (consumers may choose the exact filename later) -set(ZLIB_LIBRARY_DIR "${ZLIB_INSTALL_DIR}/lib" CACHE PATH "zlib library dir" FORCE) - -# (Optional) Provide a best-guess library filename per platform *without* EXISTS checks. -# Consumers that need an exact file can adjust per their build (static/shared). -if(WIN32) - set(_ZLIB_LIB_GUESS "${ZLIB_LIBRARY_DIR}/z.lib") -elseif(APPLE) - # prefer shared name; many toolchains will still produce libz.a if shared is off - set(_ZLIB_LIB_GUESS "${ZLIB_LIBRARY_DIR}/libz.dylib") -else() - set(_ZLIB_LIB_GUESS "${ZLIB_LIBRARY_DIR}/libz.so") -endif() -set(ZLIB_LIBRARY "${_ZLIB_LIB_GUESS}" CACHE FILEPATH "zlib library (best guess)" FORCE) +ExternalProject_Get_Property(Zlib_external BINARY_DIR) +SET(Zlib_DIR ${BINARY_DIR} CACHE PATH "") -message(STATUS "[Zlib_external] INSTALL_DIR=${ZLIB_INSTALL_DIR}") -message(STATUS "[Zlib_external] INCLUDE_DIR=${ZLIB_INCLUDE_DIR}") -message(STATUS "[Zlib_external] LIB_DIR=${ZLIB_LIBRARY_DIR}") -message(STATUS "[Zlib_external] LIB_GUESS=${ZLIB_LIBRARY}") \ No newline at end of file +MESSAGE(STATUS "Zlib_DIR: ${Zlib_DIR}") diff --git a/scripts/clean-boost-only.ps1 b/scripts/clean-boost-only.ps1 new file mode 100644 index 0000000000..674b6f1ad1 --- /dev/null +++ b/scripts/clean-boost-only.ps1 @@ -0,0 +1,16 @@ +$BuildDir = "C:\Users\Yong\Documents\SCIRun\build" +$BoostDirs = @( + "Boost_external", + "boost", + "_deps" +) + +foreach ($name in $BoostDirs) { + $path = Join-Path $BuildDir $name + if (Test-Path $path) { + Write-Host "Removing $path" + Remove-Item -Recurse -Force $path + } +} + +Write-Host "? Boost-related directories removed." \ No newline at end of file diff --git a/scripts/clean-build.ps1 b/scripts/clean-build.ps1 new file mode 100644 index 0000000000..82d30cc642 --- /dev/null +++ b/scripts/clean-build.ps1 @@ -0,0 +1,54 @@ +# ============================================================ +# Safe SCIRun build directory cleanup +# ============================================================ + +$ExpectedBuildDir = "C:\Users\Yong\Documents\SCIRun\build" + +Write-Host "SCIRun safe cleanup script" +Write-Host "Target directory:" +Write-Host " $ExpectedBuildDir" +Write-Host "" + +# Resolve actual path +try { + $Resolved = (Resolve-Path $ExpectedBuildDir).Path +} catch { + Write-Error "ERROR: Build directory does not exist." + exit 1 +} + +# Safety checks +if ($Resolved -ne $ExpectedBuildDir) { + Write-Error "ERROR: Resolved path mismatch." + Write-Error "Resolved: $Resolved" + exit 1 +} + +if ($Resolved -match "^C:\\Users\\Yong\\?$") { + Write-Error "ERROR: Refusing to operate on user directory." + exit 1 +} + +if ($Resolved -ne "C:\Users\Yong\Documents\SCIRun\build") { + Write-Error "ERROR: Refusing to clean unexpected path: $Resolved" + exit 1 +} + +Write-Host "? Safety checks passed." +Write-Host "" + +# Confirmation +$answer = Read-Host "Type 'DELETE BUILD DIR' to continue" +if ($answer -ne "DELETE BUILD DIR") { + Write-Host "Aborted." + exit 0 +} + +Write-Host "" +Write-Host "Cleaning build contents (directory preserved)..." +Write-Host "" + +Get-ChildItem -Path $Resolved -Force | + Remove-Item -Recurse -Force -ErrorAction Stop + +Write-Host "? Build directory cleaned safely." diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e3c526c8e8..c28df374f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,20 +25,10 @@ # DEALINGS IN THE SOFTWARE. # -CMAKE_MINIMUM_REQUIRED(VERSION 3.15 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.9 FATAL_ERROR) PROJECT(SCIRun) -# Honor CMAKE_MSVC_RUNTIME_LIBRARY for VS generators -if(POLICY CMP0091) - cmake_policy(SET CMP0091 NEW) -endif() - -# Use proper CRT per configuration (Debug -> /MDd, others -> /MD) -if(MSVC) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") -endif() - set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -46,311 +36,10 @@ IF(GENERATE_COMPILATION_DATABASE) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ENDIF() -# ------------------------------- -# SCIRun path diagnostics (what we actually received from the superbuild) -# ------------------------------- -message(STATUS "[SCIRun] CMAKE_PREFIX_PATH = '${CMAKE_PREFIX_PATH}'") -if(CMAKE_PREFIX_PATH) - message(STATUS "[SCIRun] CMAKE_PREFIX_PATH entries:") - foreach(_p IN LISTS CMAKE_PREFIX_PATH) - file(TO_CMAKE_PATH "${_p}" _p_norm) - if(EXISTS "${_p_norm}") - message(STATUS " ✓ ${_p_norm}") - else() - message(STATUS " ✗ ${_p_norm} (does not exist at configure time)") - endif() - endforeach() -endif() -message(STATUS "[SCIRun] Qt_PATH='${Qt_PATH}'") -message(STATUS "[SCIRun] Boost_DIR='${Boost_DIR}' ; Boost_ROOT='${Boost_ROOT}' ; BOOST_ROOT='${BOOST_ROOT}' ; SCI_BOOST_PREFIX='${SCI_BOOST_PREFIX}'") -message(STATUS "[SCIRun] ZLIB_ROOT='${ZLIB_ROOT}' ; ZLIB_DIR='${ZLIB_DIR}' ; ZLIB_INCLUDE_DIR='${ZLIB_INCLUDE_DIR}'") - -# --- Boost (Windows-only: b2-built libs from b2/--layout=versioned) --- -# If SCIRUN_EXPLICIT_BOOST_LINK=ON (from superbuild), we DISABLE MSVC autolink -# via BOOST_ALL_NO_LIB and link required Boost components explicitly. -if(SCIRUN_EXPLICIT_BOOST_LINK) - add_compile_definitions(BOOST_ALL_NO_LIB) -endif() - -if(WIN32) - if(DEFINED SCI_BOOST_PREFIX) - set(_boost_use "${SCI_BOOST_PREFIX}/UseBoost.cmake") - if(EXISTS "${_boost_use}") - include("${_boost_use}") # adds include + lib search dirs, keeps autolink ON - else() - # Fallback: add include and library search dirs from exported vars - if(DEFINED SCI_BOOST_INCLUDE AND IS_DIRECTORY "${SCI_BOOST_INCLUDE}") - include_directories(SYSTEM "${SCI_BOOST_INCLUDE}") - endif() - if(DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") - # Directory-wide link search path so MSVC finds libboost_*‑vc143‑... .lib files - link_directories("${SCI_BOOST_LIBRARY_DIR}") - endif() - endif() - - # Optional sanity check: warn if no versioned Boost libs were found - if(DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") - file(GLOB _boost_ver_libs "${SCI_BOOST_LIBRARY_DIR}/libboost_*vc*.lib") - if(NOT _boost_ver_libs) - message(WARNING - "[SCIRun] No versioned Boost .lib files detected under '${SCI_BOOST_LIBRARY_DIR}'.\n" - " Ensure your external Boost build used b2 with '--layout=versioned' and staged/installed libs.") - endif() - unset(_boost_ver_libs) - endif() - else() - message(WARNING "[SCIRun] SCI_BOOST_PREFIX is not defined; Windows auto-link may fail to locate Boost libs.") - endif() -endif() - -# -------------------------------------------------------------------- -# Boost explicit linking (Windows + SCIRUN_EXPLICIT_BOOST_LINK) -# - Collect concrete .lib files per component and append to SCI_BOOST_LIBRARY. -# - Handles Debug (-gd) and Release variants; falls back if one variant missing. -# -------------------------------------------------------------------- -if(SCIRUN_EXPLICIT_BOOST_LINK AND WIN32 AND DEFINED SCI_BOOST_LIBRARY_DIR AND IS_DIRECTORY "${SCI_BOOST_LIBRARY_DIR}") - - # Helper: pick first match from a list of patterns - function(_pick_first out_var) - set(_res "") - foreach(_pat IN LISTS ARGN) - file(GLOB _cands "${_pat}") - if(_cands) - list(SORT _cands) - list(GET _cands 0 _res) - break() - endif() - endforeach() - set(${out_var} "${_res}" PARENT_SCOPE) - endfunction() - - # Reset the aggregate to avoid duplicates across re-configures - set(SCI_BOOST_LIBRARY "" CACHE STRING "Aggregate Boost libs" FORCE) - - # ---- Generic component adder (release + debug) ---- - function(_boost_pick_component comp) - if(NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") - message(WARNING "[SCIRun] _boost_pick_component: SCI_BOOST_LIBRARY_DIR is invalid.") - return() - endif() - - # Release candidates (versioned names from b2 --layout=versioned) - set(_rel "") - _pick_first(_rel - "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*-vc*-mt-x64-*.lib" # preferred x64 MSVC layout - "${SCI_BOOST_LIBRARY_DIR}/boost_${comp}*.lib" # fallback - "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*.lib") # fallback - # Debug candidates (-gd) - set(_dbg "") - _pick_first(_dbg - "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*-vc*-mt-gd-x64-*.lib" # preferred x64 Debug - "${SCI_BOOST_LIBRARY_DIR}/boost_${comp}*-gd*.lib" - "${SCI_BOOST_LIBRARY_DIR}/libboost_${comp}*-gd*.lib") - - if(NOT _rel AND NOT _dbg) - message(WARNING "[SCIRun] Boost component '${comp}' not found under '${SCI_BOOST_LIBRARY_DIR}'") - return() - endif() - - # If a variant is missing, fall back to the one we have - if(NOT _rel AND _dbg) - set(_rel "${_dbg}") - endif() - if(NOT _dbg AND _rel) - set(_dbg "${_rel}") - endif() - - # Append with config mapping so MSVC picks the right one - list(APPEND SCI_BOOST_LIBRARY - optimized "${_rel}" debug "${_dbg}") - - # Save to cache so subdirs see the updated list - set(SCI_BOOST_LIBRARY "${SCI_BOOST_LIBRARY}" CACHE STRING "Aggregate Boost libs" FORCE) - message(STATUS "[SCIRun] Boost ${comp}: rel='${_rel}' dbg='${_dbg}'") - endfunction() - - # ---- Pick all required components explicitly ---- - # Filesystem needs System; Thread usually needs System and Atomic. - _boost_pick_component(filesystem) - _boost_pick_component(system) - _boost_pick_component(program_options) - _boost_pick_component(thread) - _boost_pick_component(atomic) - _boost_pick_component(serialization) - - # Construct the versioned Boost.Python component name: python313 for Python 3.13 - set(_py_comp "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}") - - # Try the versioned component first (common with b2 builds), then fall back to unversioned "python" - # We call _boost_pick_component on both; the function tolerates missing libs and will warn if not found. - _boost_pick_component("${_py_comp}") - _boost_pick_component("python") - -endif() - -# -------------------------------------------------------------------- -# Imported targets for Zlib and Teem (transitive wiring) -# - Canonical name: ZLIB::ZLIB (provide Zlib::Zlib alias) -# - Canonical name: Teem::teem (links transitively to ZLIB::ZLIB) -# -------------------------------------------------------------------- - -# Normalize/bridge variables for includes used elsewhere -if(DEFINED ZLIB_INCLUDE_DIR AND NOT DEFINED SCI_ZLIB_INCLUDE) - set(SCI_ZLIB_INCLUDE "${ZLIB_INCLUDE_DIR}") -endif() -# SCI_TEEM_INCLUDE is assumed to be set elsewhere by the superbuild - -# ------------------------ -# 1) Zlib imported target -# ------------------------ -# Goal: ensure ZLIB::ZLIB always exists; provide Zlib::Zlib alias for compatibility. - -if(NOT TARGET ZLIB::ZLIB) - # Try a config package first (may define ZLIB::ZLIB) - # Hints leverage ZLIB_ROOT/ZLIB_DIR/CMAKE_PREFIX_PATH already - find_package(ZLIB QUIET CONFIG) - - if(NOT TARGET ZLIB::ZLIB) - # Fall back to module find (classic FindZLIB) - find_package(ZLIB QUIET) - - if(NOT TARGET ZLIB::ZLIB) - # No package target; build imported target from variables. - # Prefer debug/release split if available. - if((ZLIB_LIBRARY_RELEASE OR ZLIB_LIBRARY) AND ZLIB_INCLUDE_DIR) - add_library(ZLIB::ZLIB UNKNOWN IMPORTED) - if(ZLIB_LIBRARY_RELEASE) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION_RELEASE "${ZLIB_LIBRARY_RELEASE}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" - ) - endif() - if(ZLIB_LIBRARY_DEBUG) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION_DEBUG "${ZLIB_LIBRARY_DEBUG}" - ) - endif() - if(NOT ZLIB_LIBRARY_RELEASE AND ZLIB_LIBRARY) - # Single lib used for all configs - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" - ) - endif() - elseif(ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS) - add_library(ZLIB::ZLIB UNKNOWN IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}" - ) - else() - message(WARNING "[SCIRun] Zlib not fully configured yet (need ZLIB_LIBRARY{_DEBUG/_RELEASE} and ZLIB_INCLUDE_DIR). " - "This can be expected before externals are installed.") - endif() - endif() - endif() -endif() - -# Provide compatibility alias if canonical exists -if(TARGET ZLIB::ZLIB AND NOT TARGET Zlib::Zlib) - add_library(Zlib::Zlib ALIAS ZLIB::ZLIB) -endif() - -# ------------------------ -# 2) Teem imported target -# ------------------------ -# Goal: ensure Teem::teem exists; link transitively to ZLIB::ZLIB when available. - -if(NOT TARGET Teem::teem) - # Prefer a config-provided target if present - find_package(Teem QUIET CONFIG) - - if(TARGET Teem::teem) - # Already provided by package—augment linkage if needed - if(TARGET ZLIB::ZLIB) - # Append zlib transitively; don't overwrite existing interface links - get_target_property(_teem_links Teem::teem INTERFACE_LINK_LIBRARIES) - if(NOT _teem_links) - set(_teem_links "") - endif() - list(APPEND _teem_links ZLIB::ZLIB) - list(REMOVE_DUPLICATES _teem_links) - set_target_properties(Teem::teem PROPERTIES INTERFACE_LINK_LIBRARIES "${_teem_links}") - endif() - else() - # Create imported from explicit paths (superbuild should provide Teem_LIBRARY/Teem_INCLUDE_DIR) - if(DEFINED Teem_LIBRARY AND EXISTS "${Teem_LIBRARY}" AND DEFINED Teem_INCLUDE_DIR AND EXISTS "${Teem_INCLUDE_DIR}/teem/ten.h") - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${Teem_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - # Make consumers treat Teem headers as static-linked (prevents dllimport) - INTERFACE_COMPILE_DEFINITIONS "TEEM_STATIC" - ) - if(TARGET ZLIB::ZLIB) - set_property(TARGET Teem::teem APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB) - endif() - else() - message(WARNING "[SCIRun] Teem not fully configured yet (need Teem_LIBRARY and Teem_INCLUDE_DIR). " - "This can be expected before externals are built.") - endif() - endif() -endif() - -# --- LodePNG imported target fallback (manual, cross‑platform) --- -if(NOT TARGET LodePNG::lodepng) - set(_LPNG_ROOT "${CMAKE_BINARY_DIR}/../Externals/Install/LodePng_external") - set(_LPNG_INC "${_LPNG_ROOT}/include") - set(_LPNG_LIBDIR "${_LPNG_ROOT}/lib") - - # Cross‑platform library detection - set(_LPNG_LIB "") - - if(WIN32) - if(EXISTS "${_LPNG_LIBDIR}/lodepngd.lib") - set(_LPNG_LIB "${_LPNG_LIBDIR}/lodepngd.lib") - elseif(EXISTS "${_LPNG_LIBDIR}/lodepng.lib") - set(_LPNG_LIB "${_LPNG_LIBDIR}/lodepng.lib") - endif() - elseif(APPLE) - # macOS: static or shared - if(EXISTS "${_LPNG_LIBDIR}/liblodepng.a") - set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.a") - elseif(EXISTS "${_LPNG_LIBDIR}/liblodepng.dylib") - set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.dylib") - endif() - else() - # Linux: static or shared - if(EXISTS "${_LPNG_LIBDIR}/liblodepng.a") - set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.a") - elseif(EXISTS "${_LPNG_LIBDIR}/liblodepng.so") - set(_LPNG_LIB "${_LPNG_LIBDIR}/liblodepng.so") - endif() - endif() - - if(_LPNG_LIB) - add_library(LodePNG::lodepng UNKNOWN IMPORTED) - - set_target_properties(LodePNG::lodepng PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_LPNG_INC}" - IMPORTED_LOCATION "${_LPNG_LIB}" - ) - - message(STATUS - "[SCIRun] LodePNG::lodepng imported:" - " inc='${_LPNG_INC}', lib='${_LPNG_LIB}'" - ) - else() - message(WARNING - "[SCIRun] LodePNG not found under '${_LPNG_LIBDIR}'. " - "Build LodePng_external first." - ) - endif() -endif() - ############################################################################### # Don't allow the user to build in the src directory... # + IF(${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR}) MESSAGE( "" ) MESSAGE( "Building SCIRun in the source directory is not allowed." ) @@ -414,6 +103,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules/Version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/Core/Application/Version.cc) set(version_file "${CMAKE_CURRENT_BINARY_DIR}/Core/Application/Version.cc") + ######################################################################## # SCIRUN version number. @@ -423,6 +113,7 @@ SET(SCIRUN_VERSION_PATCH "${VERSION_PATCH}") SET(SCIRUN_VERSION_STRING "${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}") + ######################################################################## # APPLICATION Information (used by CPack) # @@ -436,7 +127,7 @@ SET(APPLICATION_EXTENSION ".srn5" CACHE INTERNAL "Network file extension" FORCE) SET(APPLICATION_URL "www.scirun.org" CACHE INTERNAL "Project URL" FORCE) SET(APPLICATION_VENDOR "SCI" CACHE INTERNAL "Vendor information" FORCE) SET(APPLICATION_CONTACT "scirun-users@sci.utah.edu" CACHE INTERNAL "Contact information" FORCE) -SET(APPLICATION_WINDOWS_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\scirun5_32.ico" CACHE INTERNAL "Windows icon" FORCE) +SET(APPLICATION_WINDOWS_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\\\scirun5_32.ico" CACHE INTERNAL "Windows icon" FORCE) SET(APPLICATION_WINDOWS_RC "${CMAKE_SOURCE_DIR}/Resources/Icons/SCIRun.rc" CACHE INTERNAL "Windows icon" FORCE) SET(APPLICATION_OSX_ICON_FULL_PATH "${CMAKE_SOURCE_DIR}/Resources/Icons/scirun5.icns" CACHE INTERNAL "OSX icon" FORCE) @@ -508,470 +199,125 @@ else() endif() ######################################################################### -# External projects (configure-time discovery of externals) -# -# Robust keyword-based macro + calls with clear diagnostics. -######################################################################### - -# --- Keyword-based CONFIG_STANDARD_EXTERNAL macro --- -include(CMakeParseArguments) - -# Initialize global summary storage once (safe to include multiple times) -get_property(_sum_init GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY SET) -if(NOT _sum_init) - set_property(GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY "") -endif() -unset(_sum_init) - -# CONFIG_STANDARD_EXTERNAL(name [DIR ] [ROOT ] [CFG ] [CFGS ...] -# [CONFIG_ONLY] [REQUIRED] [QUIET] [VERBOSE]) -# -# - name: CMake package name (e.g., ZLIB, Freetype, Boost). -# - DIR: Either an exact config directory (contains *Config.cmake) OR a prefix to probe. -# - ROOT: Install prefix to probe (lib/cmake/*, lib64/cmake/*, share//cmake, etc). -# - CFG: Primary config filename to look for (e.g., ZLIBConfig.cmake). -# - CFGS: Alternative config filenames to try if CFG not present (case variants). -# - CONFIG_ONLY: Prefer config packages (sets CMAKE_FIND_PACKAGE_PREFER_CONFIG ON during the call). -# - REQUIRED: Fail configure if not found (but optionally gated when in superbuild mode). -# - QUIET: Less chatter. -# - VERBOSE: Print every probed path when not found. -# -macro(CONFIG_STANDARD_EXTERNAL name) - # Parse keywords - set(_cse_one DIR ROOT CFG) - set(_cse_multi CFGS) - set(_cse_bool REQUIRED CONFIG_ONLY QUIET VERBOSE) - cmake_parse_arguments(_CSE "${_cse_bool}" "" "${_cse_one};${_cse_multi}" ${ARGN}) - - # Derive case variants - set(_cse_name "${name}") - string(TOUPPER "${_cse_name}" _cse_UP) - string(TOLOWER "${_cse_name}" _cse_LOW) - - # Build candidate config filename list - set(_cse_cfgs "") - if(_CSE_CFG) - list(APPEND _cse_cfgs "${_CSE_CFG}") - endif() - if(_CSE_CFGS) - list(APPEND _cse_cfgs ${_CSE_CFGS}) - endif() - if(NOT _cse_cfgs) - list(APPEND _cse_cfgs - "${_cse_name}Config.cmake" - "${_cse_UP}Config.cmake" - "${_cse_LOW}Config.cmake" - "${_cse_LOW}-config.cmake" - "${_cse_UP}-config.cmake" - ) - endif() - - # Normalized hints - set(_cse_dir "${_CSE_DIR}") - set(_cse_root "${_CSE_ROOT}") - - # For diagnostics - unset(_cse_pkg_dir) - set(_cse_tried_dirs "") - - # Detect superbuild mode heuristically if not already set by the project - if(NOT DEFINED SCIRUN_SUPERBUILD_MODE) - string(FIND "${CMAKE_PREFIX_PATH}" "Externals/Install" _cse_sb_idx) - if(_cse_sb_idx GREATER -1) - set(SCIRUN_SUPERBUILD_MODE ON) - else() - set(SCIRUN_SUPERBUILD_MODE OFF) - endif() - unset(_cse_sb_idx) - endif() - - # Helpers - macro(_cse_mark _dir) - if(NOT _dir) - # skip - else() - set(_hit "") - foreach(_cfg IN LISTS _cse_cfgs) - if(EXISTS "${_dir}/${_cfg}") - set(_hit "✓") - break() - endif() - endforeach() - if(_hit) - list(APPEND _cse_tried_dirs " ✓ ${_dir} (${_cse_cfgs})") - set(_cse_pkg_dir "${_dir}") - else() - list(APPEND _cse_tried_dirs " ${_dir} (${_cse_cfgs})") - endif() - endif() - endmacro() - - function(_cse_probe_prefix _prefix) - if(NOT _prefix) - return() - endif() - - # Common locations (with lib64, cmake/CMake, share) - set(_cse_candidate_dirs - "${_prefix}/lib/cmake/${_cse_name}" - "${_prefix}/lib/cmake/${_cse_UP}" - "${_prefix}/lib64/cmake/${_cse_name}" - "${_prefix}/lib64/cmake/${_cse_UP}" - "${_prefix}/cmake/${_cse_name}" - "${_prefix}/cmake/${_cse_UP}" - "${_prefix}/CMake/${_cse_name}" - "${_prefix}/CMake/${_cse_UP}" - "${_prefix}/share/${_cse_name}/cmake" - "${_prefix}/share/${_cse_UP}/cmake" - "${_prefix}/share/${_cse_name}" - "${_prefix}/share/${_cse_UP}" - ) - - # Versioned siblings under lib/cmake and lib64/cmake - foreach(_base IN ITEMS - "${_prefix}/lib/cmake/${_cse_name}" - "${_prefix}/lib/cmake/${_cse_UP}" - "${_prefix}/lib64/cmake/${_cse_name}" - "${_prefix}/lib64/cmake/${_cse_UP}" - ) - if(EXISTS "${_base}") - _cse_mark("${_base}") - if(DEFINED _cse_pkg_dir) - set(_cse_pkg_dir "${_cse_pkg_dir}" PARENT_SCOPE) - return() - endif() - endif() - - file(GLOB _sib "${_base}-*") - foreach(_cand IN LISTS _sib) - _cse_mark("${_cand}") - if(DEFINED _cse_pkg_dir) - set(_cse_pkg_dir "${_cse_pkg_dir}" PARENT_SCOPE) - return() - endif() - endforeach() - endforeach() - - foreach(_cand IN LISTS _cse_candidate_dirs) - _cse_mark("${_cand}") - if(DEFINED _cse_pkg_dir) - set(_cse_pkg_dir "${_cse_pkg_dir}" PARENT_SCOPE) - return() - endif() - endforeach() - endfunction() - - # Banner - if(NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Probing ${_cse_name} (" - "DIR='${_cse_dir}', ROOT='${_cse_root}', " - "${_cse_name}_DIR='${${_cse_name}_DIR}', ${_cse_UP}_DIR='${${_cse_UP}_DIR}', " - "${_cse_name}_ROOT='${${_cse_name}_ROOT}', ${_cse_UP}_ROOT='${${_cse_UP}_ROOT}')") - endif() - - # 0) Pre-set *_DIR - if(DEFINED ${_cse_name}_DIR) - _cse_mark("${${_cse_name}_DIR}") - endif() - if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_UP}_DIR) - _cse_mark("${${_cse_UP}_DIR}") - endif() - - # 1) *_ROOT and explicit ROOT= - if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_name}_ROOT) - _cse_probe_prefix("${${_cse_name}_ROOT}") - endif() - if(NOT DEFINED _cse_pkg_dir AND DEFINED ${_cse_UP}_ROOT) - _cse_probe_prefix("${${_cse_UP}_ROOT}") - endif() - if(NOT DEFINED _cse_pkg_dir AND _cse_root) - _cse_probe_prefix("${_cse_root}") - endif() - - # 2) Interpret DIR as exact config dir, then as prefix - if(NOT DEFINED _cse_pkg_dir AND _cse_dir) - _cse_mark("${_cse_dir}") - - if(NOT DEFINED _cse_pkg_dir) - if("${_cse_dir}" MATCHES "/lib64?/cmake/${_cse_name}$" - OR "${_cse_dir}" MATCHES "/lib64?/cmake/${_cse_UP}$") - file(GLOB _sib_dir "${_cse_dir}-*") - foreach(_cand IN LISTS _sib_dir) - _cse_mark("${_cand}") - if(DEFINED _cse_pkg_dir) - break() - endif() - endforeach() - endif() - endif() - - if(NOT DEFINED _cse_pkg_dir) - _cse_probe_prefix("${_cse_dir}") - endif() - endif() - - # 3) CMAKE_PREFIX_PATH - if(NOT DEFINED _cse_pkg_dir AND CMAKE_PREFIX_PATH) - foreach(_cpp IN LISTS CMAKE_PREFIX_PATH) - _cse_probe_prefix("${_cpp}") - if(DEFINED _cse_pkg_dir) - break() - endif() - endforeach() - endif() - - # CONFIG_ONLY → prefer config packages during this call - if(_CSE_CONFIG_ONLY) - set(_cse_prev_pref "${CMAKE_FIND_PACKAGE_PREFER_CONFIG}") - set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) - endif() - - # 4) Always attempt find_package() (even if _cse_pkg_dir wasn't detected). - # Assemble HINTS list from detected dir + all available hints. - set(_cse_hints "") - if(DEFINED _cse_pkg_dir) - list(APPEND _cse_hints "${_cse_pkg_dir}") - # Cache *_DIR to stabilize subsequent configures - set(${_cse_name}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory" FORCE) - set(${_cse_UP}_DIR "${_cse_pkg_dir}" CACHE PATH "${_cse_name} package directory (upper)" FORCE) - if(NOT _CSE_QUIET) - list(JOIN _cse_cfgs ", " _cfgs_join) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name}: using '${_cfgs_join}' in '${_cse_pkg_dir}'") - endif() - endif() - if(_cse_dir) - list(APPEND _cse_hints "${_cse_dir}") - endif() - if(DEFINED ${_cse_name}_DIR) - list(APPEND _cse_hints "${${_cse_name}_DIR}") - endif() - if(DEFINED ${_cse_UP}_DIR) - list(APPEND _cse_hints "${${_cse_UP}_DIR}") - endif() - if(DEFINED ${_cse_name}_ROOT) - list(APPEND _cse_hints "${${_cse_name}_ROOT}") - endif() - if(DEFINED ${_cse_UP}_ROOT) - list(APPEND _cse_hints "${${_cse_UP}_ROOT}") - endif() - if(_cse_root) - list(APPEND _cse_hints "${_cse_root}") - endif() - foreach(_cpp IN LISTS CMAKE_PREFIX_PATH) - list(APPEND _cse_hints "${_cpp}") - endforeach() - if(_cse_hints) - list(REMOVE_DUPLICATES _cse_hints) - endif() +# External projects - # Call find_package() in CONFIG mode quietly and let defaults work (no NO_DEFAULT_PATH). - if(_cse_hints) - find_package(${_cse_name} CONFIG QUIET HINTS ${_cse_hints}) - else() - find_package(${_cse_name} CONFIG QUIET) - endif() - - # Determine FOUND state robustly - set(_cse_found FALSE) - if(DEFINED ${_cse_name}_FOUND AND ${_cse_name}_FOUND) - set(_cse_found TRUE) - elseif(DEFINED ${_cse_UP}_FOUND AND ${_cse_UP}_FOUND) - set(_cse_found TRUE) - else() - # Fallback for well-known packages: check imported targets - if("${_cse_name}" STREQUAL "Boost") - if(TARGET Boost::headers OR TARGET Boost::boost) - set(_cse_found TRUE) - endif() - endif() - endif() - - # Update summary (GLOBAL property to avoid parent-scope warnings) - get_property(_sum GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY) - if(NOT _sum) - set(_sum "") - endif() +MACRO(CONFIG_STANDARD_EXTERNAL name config_file directory) + FIND_PACKAGE(${name} CONFIGS ${config_file} HINTS ${directory} NO_SYSTEM_ENVIRONMENT_PATH) + IF(NOT ${name}_FOUND) + MESSAGE(FATAL_ERROR "${name} library not found in ${directory}") + ENDIF() +ENDMACRO() - if(_cse_found) - if(NOT _CSE_QUIET) - if(DEFINED _cse_pkg_dir) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} at '${_cse_pkg_dir}'") - else() - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Found ${_cse_name} (via CMake search paths)") - endif() - endif() - if(DEFINED _cse_pkg_dir) - string(APPEND _sum " ${_cse_name}: FOUND at '${_cse_pkg_dir}'\n") - else() - string(APPEND _sum " ${_cse_name}: FOUND\n") - endif() - else() - # Not found → decide whether to fail - if(_CSE_REQUIRED AND NOT SCIRUN_SUPERBUILD_MODE) - if(NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") - endif() - set_property(GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY "${_sum}") - # Fatal error for non-superbuild REQUIRED case - message(FATAL_ERROR - "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found.\n" - " Tried locations for (${_cse_cfgs}):\n${_cse_tried_dirs}\n" - " Hints:\n" - " - ${_cse_name}_DIR='${${_cse_name}_DIR}'\n" - " - ${_cse_UP}_DIR='${${_cse_UP}_DIR}'\n" - " - ${_cse_name}_ROOT='${${_cse_name}_ROOT}'\n" - " - ${_cse_UP}_ROOT='${${_cse_UP}_ROOT}'\n" - " - DIR='${_cse_dir}'\n" - " - ROOT='${_cse_root}'\n" - " - CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" - " Hint: ensure the external is built/installed and re-run CMake." - ) - else() - if(_CSE_VERBOSE AND NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found. Probed:\n${_cse_tried_dirs}") - elseif(NOT _CSE_QUIET) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] ${_cse_name} not found yet. This can be expected before externals are built.") - endif() - string(APPEND _sum " ${_cse_name}: NOT FOUND\n") - endif() - endif() +CONFIG_STANDARD_EXTERNAL( Zlib ZlibConfig.cmake ${Zlib_DIR} ) +INCLUDE(${ZLIB_USE_FILE}) - set_property(GLOBAL PROPERTY SCIRUN_CONFIG_STD_SUMMARY "${_sum}") - unset(_sum) +CONFIG_STANDARD_EXTERNAL( SQLite SQLiteConfig.cmake ${SQLite_DIR} ) +INCLUDE(${SQLITE_USE_FILE}) - # Restore prefer-config policy if we changed it - if(_CSE_CONFIG_ONLY) - set(CMAKE_FIND_PACKAGE_PREFER_CONFIG "${_cse_prev_pref}") - unset(_cse_prev_pref) - endif() +CONFIG_STANDARD_EXTERNAL( Teem TeemConfig.cmake ${Teem_DIR} ) +INCLUDE(${Teem_USE_FILE}) - # Cleanup - unset(_cse_pkg_dir) - unset(_cse_tried_dirs) - unset(_cse_hints) -endmacro() +CONFIG_STANDARD_EXTERNAL( Freetype FreetypeConfig.cmake ${Freetype_DIR} ) +INCLUDE(${FREETYPE_USE_FILE}) -# --- Calls for each external --- +CONFIG_STANDARD_EXTERNAL( Cleaver2 Cleaver2Config.cmake ${CLEAVER2_DIR} ) +INCLUDE(${CLEAVER2_USE_FILE}) -# ZLIB -CONFIG_STANDARD_EXTERNAL(ZLIB - ROOT "${ZLIB_ROOT}" - DIR "${ZLIB_DIR}" - CFGS "ZLIBConfig.cmake;zlibConfig.cmake;zlib-config.cmake" - # VERBOSE -) +IF(BUILD_WITH_PYTHON) + CONFIG_STANDARD_EXTERNAL( Python PythonConfig.cmake ${Python_DIR} ) + INCLUDE(${SCI_PYTHON_USE_FILE}) +ENDIF() -# SQLite (SQLite vs SQLite3) -CONFIG_STANDARD_EXTERNAL(SQLite - DIR "${SQLite_DIR}" - CFGS "SQLite3Config.cmake;SQLiteConfig.cmake" +# Disable Boost MSVC auto-linking globally +# (prevents Boost headers from injecting -gd / -mt / etc. library names) +add_compile_definitions( + BOOST_ALL_NO_LIB + BOOST_FILESYSTEM_NO_LIB + BOOST_SYSTEM_NO_LIB ) - -# Teem (if a config is exported by your superbuild) -CONFIG_STANDARD_EXTERNAL(Teem - DIR "${Teem_DIR}" - CFG "TeemConfig.cmake" +set(_scirun_boost_components + atomic + chrono + filesystem + program_options + regex + serialization + thread ) -# FreeType (case varies) -CONFIG_STANDARD_EXTERNAL(Freetype - DIR "${Freetype_DIR}" - CFGS "FreetypeConfig.cmake;FreeTypeConfig.cmake" -) +if(BUILD_WITH_PYTHON) + list(APPEND _scirun_boost_components + python${SCI_PYTHON_VERSION_SHORT_WIN32}) +endif() -# Cleaver2 -CONFIG_STANDARD_EXTERNAL(Cleaver2 - DIR "${CLEAVER2_DIR}" - CFG "Cleaver2Config.cmake" +find_package(Boost CONFIG REQUIRED COMPONENTS + ${_scirun_boost_components} ) -# Boost — REQUIRED on non-Windows (prefer config package). -# On Windows with b2-built Boost, skip CONFIG mode: rely on auto-link + link_directories above. -if(WIN32) - if(SCIRUN_EXPLICIT_BOOST_LINK) - message(STATUS "[SCIRun] Boost: explicit component linking (BOOST_ALL_NO_LIB) with b2 versioned libs.") - else() - message(STATUS "[SCIRun] Boost: MSVC autolink enabled with b2 versioned libs.") +# --------------------------------------------------------------------------- +# Ensure BOOST_ALL_NO_LIB propagates to EVERY consumer of Boost +# by attaching it to the imported Boost targets as INTERFACE +# --------------------------------------------------------------------------- +foreach(_boost_comp ${_scirun_boost_components}) + if(TARGET Boost::${_boost_comp}) + target_compile_definitions(Boost::${_boost_comp} + INTERFACE BOOST_ALL_NO_LIB + ) endif() -else() - CONFIG_STANDARD_EXTERNAL(Boost - ROOT "${SCI_BOOST_PREFIX}" - DIR "${Boost_DIR}" - CFG "BoostConfig.cmake" - CONFIG_ONLY - REQUIRED +endforeach() + +if(TARGET Boost::filesystem) + target_compile_definitions(Boost::filesystem + INTERFACE + BOOST_FILESYSTEM_NO_LIB + BOOST_SYSTEM_NO_LIB + BOOST_FILESYSTEM_STATIC_LINK ) endif() -# Tiny (Tny) -CONFIG_STANDARD_EXTERNAL(Tny - DIR "${TNY_DIR}" - CFG "TnyConfig.cmake" -) +# --------------------------------------------------------------------------- +# Diagnostics +# --------------------------------------------------------------------------- +get_property(_allTargets GLOBAL PROPERTY TARGETS) -# LodePNG -CONFIG_STANDARD_EXTERNAL(LodePNG - DIR "${LodePNG_DIR}" - CFGS "LodePNGConfig.cmake" -) +message(STATUS "==== Boost-related targets ====") +foreach(t ${_allTargets}) + if(t MATCHES "^Boost::") + message(STATUS " ${t}") + endif() +endforeach() -# Tetgen (optional) -if(WITH_TETGEN) - # Try package config first (does nothing if no TetgenConfig.cmake in CMAKE_PREFIX_PATH) - #CONFIG_STANDARD_EXTERNAL(Tetgen - # DIR "${Tetgen_DIR}" - # CFG "TetgenConfig.cmake" - #) - - # --- Fallback when Tetgen doesn't export a CMake package --- - # Create an imported target from superbuild-provided cache hints. - if(NOT TARGET Tetgen::Tetgen) - # Heal include dir: if it doesn't contain tetgen.h, try '/src' - set(_TETGEN_INC "${TETGEN_INCLUDE_DIR}") - if(_TETGEN_INC AND NOT EXISTS "${_TETGEN_INC}/tetgen.h" AND EXISTS "${_TETGEN_INC}/src/tetgen.h") - set(_TETGEN_INC "${_TETGEN_INC}/src") - endif() +message(STATUS "Boost_FOUND = ${Boost_FOUND}") +message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}") +message(STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}") - # Create imported target if we have a real library file and a valid include dir - if(TETGEN_LIBRARY AND EXISTS "${TETGEN_LIBRARY}" AND _TETGEN_INC AND EXISTS "${_TETGEN_INC}/tetgen.h") - add_library(Tetgen::Tetgen UNKNOWN IMPORTED) - set_target_properties(Tetgen::Tetgen PROPERTIES - IMPORTED_LOCATION "${TETGEN_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${_TETGEN_INC}" - # Define TETLIBRARY for all consumers (TetGen's header expects this when used as a lib) - INTERFACE_COMPILE_DEFINITIONS "TETLIBRARY" - ) - message(STATUS "[SCIRun] Created imported target Tetgen::Tetgen (LIB='${TETGEN_LIBRARY}', INC='${_TETGEN_INC}')") - else() - message(STATUS "[SCIRun] Tetgen package not found and cache hints insufficient yet. " - "TETGEN_LIBRARY='${TETGEN_LIBRARY}', TETGEN_INCLUDE_DIR='${TETGEN_INCLUDE_DIR}'") - endif() - endif() -endif() +CONFIG_STANDARD_EXTERNAL( Tny TnyConfig.cmake ${TNY_DIR} ) +INCLUDE(${TNY_USE_FILE}) -# GLEW (Windows) -if(WIN32) - CONFIG_STANDARD_EXTERNAL(GLEW - DIR "${GLEW_DIR}" - CFGS "GLEWConfig.cmake;GlewConfig.cmake" - ) -endif() +CONFIG_STANDARD_EXTERNAL( LodePng LodePngConfig.cmake ${LODEPNG_DIR} ) +INCLUDE(${LODEPNG_USE_FILE}) -# Qwt (unless headless) - prefer config packages and fail (outside superbuild) if missing -if(NOT BUILD_HEADLESS) - CONFIG_STANDARD_EXTERNAL(Qwt - DIR "${QWT_DIR}" - CFG "QwtConfig.cmake" - CONFIG_ONLY # prefer config packages - REQUIRED # outside superbuild, error out if missing - ) -endif() +IF(WITH_TETGEN) + CONFIG_STANDARD_EXTERNAL( Tetgen TetgenConfig.cmake ${Tetgen_DIR} ) + INCLUDE(${TETGEN_USE_FILE}) +ENDIF() -# One-shot summary (nice in CI logs) -if(DEFINED _CONFIG_STANDARD_SUMMARY) - message(STATUS "[CONFIG_STANDARD_EXTERNAL] Summary:\n${_CONFIG_STANDARD_SUMMARY}") - unset(_CONFIG_STANDARD_SUMMARY) -endif() +IF(WITH_OSPRAY) + set(ospray_DIR ${Ospray_External_Dir}/install/ospray/lib/cmake/ospray-2.0.1) + find_package(ospray 2.0.0 REQUIRED HINTS ${Ospray_External_Dir}/install/ospray) +ENDIF() + +IF(WIN32) + CONFIG_STANDARD_EXTERNAL( Glew GlewConfig.cmake ${GLEW_DIR} ) + INCLUDE(${GLEW_USE_FILE}) +ENDIF() + +IF(NOT BUILD_HEADLESS) +# QWT variables come directly from superbuild + set(SCI_QWT_INCLUDE "${QWT_INCLUDE}") + set(SCI_QWT_LIBRARY_DIR "${QWT_LIBRARY_DIR}") + set(SCI_QWT_LIBRARY "${QWT_LIBRARY}") +ENDIF() ######################################################################## # Custom compiler flags and definitions @@ -1021,21 +367,6 @@ IF(APPLE) MARK_AS_ADVANCED(AWK) ENDIF() -# 1) Real interface target -add_library(SCIRunCompileConfig INTERFACE) - -# 2) Namespaced alias (optional, for nice linking syntax) -add_library(SCIRun::CompileConfig ALIAS SCIRunCompileConfig) - -# 3) Put your global compile definitions here -# (Use your authoritative Qt selector: SCIRUN_QT_MAJOR is already in your top-level) -if (SCIRUN_QT_MAJOR STREQUAL "6") - target_compile_definitions(SCIRunCompileConfig INTERFACE SCIRUN_QT6_ENABLED) -endif() - -# You also set QT_NO_KEYWORDS globally in a few places—centralize it here: -target_compile_definitions(SCIRunCompileConfig INTERFACE QT_NO_KEYWORDS) - ######################################################################## # Configure documentation @@ -1141,60 +472,67 @@ FIND_PACKAGE(OpenGL REQUIRED) # Find and configure Qt IF(NOT BUILD_HEADLESS) - - if (SCIRUN_QT_MAJOR STREQUAL "6") - find_package(Qt6 REQUIRED COMPONENTS - DBus Core Gui Widgets Network OpenGL Concurrent - PrintSupport Svg OpenGLWidgets - HINTS ${Qt_PATH}) - elseif (SCIRUN_QT_MAJOR STREQUAL "5") - find_package(Qt5 REQUIRED COMPONENTS - Core Gui Widgets Network OpenGL Concurrent - PrintSupport Svg - HINTS ${Qt_PATH}) + if (${QT_VERSION_MAJOR} STREQUAL "6") + FIND_PACKAGE(Qt${QT_VERSION_MAJOR} COMPONENTS DBus DBusTools Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg CoreTools GuiTools WidgetsTools OpenGLWidgets REQUIRED HINTS ${Qt_PATH}) else() - message(FATAL_ERROR "Unsupported Qt major version: ${SCIRUN_QT_MAJOR}") + FIND_PACKAGE(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network OpenGL Concurrent PrintSupport Svg REQUIRED HINTS ${Qt_PATH}) endif() - if (Qt6_FOUND OR Qt5_FOUND) - message(STATUS "Found Qt version: ${Qt${QT_VERSION_MAJOR}_VERSION}") - else() - message(FATAL_ERROR "Qt is required for building the SCIRun GUI") - endif() + IF(Qt${QT_VERSION_MAJOR}Core_FOUND) + MESSAGE(STATUS "Found Qt version: ${Qt${QT_VERSION_MAJOR}Core_VERSION_STRING}") + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Network_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}OpenGL_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Concurrent_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}PrintSupport_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}Svg_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES(${Qt${QT_VERSION_MAJOR}DBus_INCLUDE_DIRS}) + ELSE() + MESSAGE(FATAL_ERROR "Qt is required for building the SCIRun GUI") + ENDIF() + + IF(Qt${QT_VERSION_MAJOR}Core_FOUND) + INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) + ADD_DEFINITIONS(${QT_DEFINITIONS}) + ELSE() + MESSAGE(FATAL_ERROR "Qt 5.13 or greater is required to build SCIRun") + ENDIF() + + ADD_DEFINITIONS(-DQT_NO_KEYWORDS) - add_definitions(-DQT_NO_KEYWORDS) + if (${QT_VERSION_MAJOR} STREQUAL "6") + ADD_DEFINITIONS(-DSCIRUN_QT6_ENABLED) + endif() - if (QT_VERSION_MAJOR EQUAL 5) - macro(QT_WRAP_UI arg1 arg2) - qt5_wrap_ui(${arg1} ${arg2}) - endmacro() + if (${QT_VERSION_MAJOR} STREQUAL "5") + MACRO(QT_WRAP_UI arg1 arg2) + QT5_WRAP_UI(${arg1} ${arg2}) + ENDMACRO(QT_WRAP_UI) - macro(QT_WRAP_CPP arg1 arg2) - qt5_wrap_cpp(${arg1} ${arg2}) - endmacro() + MACRO(QT_WRAP_CPP arg1 arg2) + QT5_WRAP_CPP(${arg1} ${arg2}) + ENDMACRO(QT_WRAP_CPP) - macro(QT_ADD_RESOURCES arg1 arg2) - qt5_add_resources(${arg1} ${arg2}) - endmacro() + MACRO(QT_ADD_RESOURCES arg1 arg2) + QT5_ADD_RESOURCES(${arg1} ${arg2}) + ENDMACRO(QT_ADD_RESOURCES) - set(QT_GRAPHICS_LIBRARIES Qt5::OpenGL) - set(QT_NETWORK_LIBRARIES Qt5::Network) - set(QT_LIBRARIES Qt5::Widgets) + SET(QT_GRAPHICS_LIBRARIES Qt5::OpenGL) + SET(QT_NETWORK_LIBRARIES Qt5::Network) + SET(QT_LIBRARIES Qt5::Widgets) else() - set(QT_GRAPHICS_LIBRARIES Qt::OpenGL Qt::OpenGLWidgets) - set(QT_NETWORK_LIBRARIES Qt::Network) - set(QT_LIBRARIES Qt::Widgets) + SET(QT_GRAPHICS_LIBRARIES Qt::OpenGL Qt::OpenGLWidgets) + SET(QT_NETWORK_LIBRARIES Qt::Network) + SET(QT_LIBRARIES Qt::Widgets) endif() ENDIF() -if (QT_VERSION_MAJOR EQUAL 6) - add_compile_definitions(SCIRUN_QT6_ENABLED) -endif() - -if (QT_VERSION_MAJOR EQUAL 5 AND Qt5Widgets_VERSION VERSION_LESS 5.13.0) - add_definitions(-DOLDER_QT_SUPPORT_NEEDED) -endif() +IF(Qt${QT_VERSION_MAJOR}Widgets_VERSION VERSION_LESS 5.13.0) + ADD_DEFINITIONS(-DOLDER_QT_SUPPORT_NEEDED) +ENDIF() ######################################################################## # Find and configure dl library @@ -1203,392 +541,16 @@ IF(UNIX) FIND_LIBRARY(DL_LIBRARY dl) ENDIF() + ######################################################################## # Includes SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) -# ---------- Diagnostics + robust include discovery ---------- - -# Normalize superbuild-provided names to what SCIRun uses internally -if(DEFINED LodePng_INCLUDE_DIR AND NOT DEFINED LODEPNG_INCLUDE_DIR) - set(LODEPNG_INCLUDE_DIR "${LodePng_INCLUDE_DIR}") -endif() -if(DEFINED Tny_INCLUDE_DIR AND NOT DEFINED TNY_INCLUDE_DIR) - set(TNY_INCLUDE_DIR "${Tny_INCLUDE_DIR}") -endif() -if(DEFINED Teem_INCLUDE_DIR AND NOT DEFINED SCI_TEEM_INCLUDE) - set(SCI_TEEM_INCLUDE "${Teem_INCLUDE_DIR}") -endif() -if(DEFINED TEEM_INCLUDE AND NOT DEFINED SCI_TEEM_INCLUDE) - set(SCI_TEEM_INCLUDE "${TEEM_INCLUDE}") -endif() -if(DEFINED SCIRUN_EIGEN_INCLUDE AND NOT DEFINED Eigen_INCLUDE_DIR) - set(Eigen_INCLUDE_DIR "${SCIRUN_EIGEN_INCLUDE}") -endif() - -# Helper: validate a cached include dir (VAR) by checking it contains REL_HEADER. -# If empty or incorrect, auto-derive from CMAKE_PREFIX_PATH and cache the fix. -function(_ensure_header _var_name _rel_header) - set(_val "${${_var_name}}") - set(_valid FALSE) - if(_val AND EXISTS "${_val}/${_rel_header}") - set(_valid TRUE) - endif() - - if(NOT _valid) - # Try to derive from CMAKE_PREFIX_PATH by probing /include - set(_candidates) - if(CMAKE_PREFIX_PATH) - foreach(_p IN LISTS CMAKE_PREFIX_PATH) - list(APPEND _candidates "${_p}/include") - endforeach() - endif() - set(_found "") - foreach(_inc IN LISTS _candidates) - if(EXISTS "${_inc}/${_rel_header}") - set(_found "${_inc}") - break() - endif() - endforeach() - - if(_found) - set(${_var_name} "${_found}" CACHE PATH "${_var_name}" FORCE) - message(STATUS "[SCIRun] Fixed ${_var_name} -> '${_found}' (found '${_rel_header}')") - else() - if(_val) - message(WARNING "[SCIRun] ${_var_name} ('${_val}') does not contain '${_rel_header}'. Clearing.") - endif() - unset(${_var_name} CACHE) - unset(${_var_name}) - endif() - else() - set(${_var_name} "${_val}" CACHE PATH "${_var_name}" FORCE) - endif() -endfunction() - -# Validate / auto-fix externals we depend on: -# GLEW: GL/glew.h -# LodePNG: lodepng/lodepng.h -# SQLite3: sqlite3.h -# Tny: tny/tny.hpp -# Spdlog: spdlog/spdlog.h -# GLM: glm/glm.hpp -# If the package created the imported target, prefer it and sync the include var -# --- GLEW include discovery (target-first, robust fallback) --- -set(_SCIRUN_USE_GLEW_TARGET FALSE) -set(_glew_inc_from_target "") -find_package(GLEW REQUIRED) -# 1) If the package created GLEW::GLEW, prefer its include path -if(TARGET GLEW::GLEW) - get_target_property(_glew_inc_from_target GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES) - if(_glew_inc_from_target) - list(GET _glew_inc_from_target 0 _glew_inc_from_target) # first entry if it's a list - endif() -endif() - -# 2) If the target had a valid include and the header exists there, use it -if(_glew_inc_from_target AND EXISTS "${_glew_inc_from_target}/GL/glew.h") - set(GLEW_INCLUDE_DIR "${_glew_inc_from_target}" CACHE PATH "GLEW include dir (from imported target)" FORCE) - set(_SCIRUN_USE_GLEW_TARGET TRUE) -else() - # 3) Fallback: try to derive from CMAKE_PREFIX_PATH - _ensure_header(GLEW_INCLUDE_DIR "GL/glew.h") - - # 4) Last-resort: force the well-known superbuild path - if(NOT GLEW_INCLUDE_DIR) - set(_sb_glew_inc "${CMAKE_BINARY_DIR}/Externals/Install/Glew_external/include") - if(EXISTS "${_sb_glew_inc}/GL/glew.h") - set(GLEW_INCLUDE_DIR "${_sb_glew_inc}" CACHE PATH "GLEW include dir (superbuild)" FORCE) - endif() - endif() -endif() - -message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") -if(TARGET GLEW::GLEW) - message(STATUS "GLEW::GLEW INTERFACE_INCLUDE_DIRECTORIES='${_glew_inc_from_target}'") -endif() - -# --- Freetype imported target (robust on Windows) --- -# 1) Try a config package (superbuild may have installed one) -find_package(Freetype QUIET CONFIG) - -if(NOT TARGET Freetype::Freetype) - # 2) Synthesize if config not available - if(DEFINED Freetype_LIB_DIR AND IS_DIRECTORY "${Freetype_LIB_DIR}") - set(_ft_rel "") - set(_ft_dbg "") - - file(GLOB _cand_rel - "${Freetype_LIB_DIR}/freetype.lib" "${Freetype_LIB_DIR}/libfreetype.lib") - file(GLOB _cand_dbg - "${Freetype_LIB_DIR}/freetyped.lib" "${Freetype_LIB_DIR}/libfreetyped.lib") - - if(_cand_rel) - list(SORT _cand_rel) - list(GET _cand_rel 0 _ft_rel) - endif() - if(_cand_dbg) - list(SORT _cand_dbg) - list(GET _cand_dbg 0 _ft_dbg) - endif() - - if(NOT _ft_rel AND _ft_dbg) - set(_ft_rel "${_ft_dbg}") - endif() - if(NOT _ft_dbg AND _ft_rel) - set(_ft_dbg "${_ft_rel}") - endif() - - if(_ft_rel OR _ft_dbg) - add_library(Freetype::Freetype UNKNOWN IMPORTED) - # FreeType expects both roots: ft2build.h and freetype2 headers - set_property(TARGET Freetype::Freetype PROPERTY - INTERFACE_INCLUDE_DIRECTORIES - "${Freetype_INCLUDE_DIR};${FREETYPE_INCLUDE_DIR2}" - ) - if(_ft_rel) - set_property(TARGET Freetype::Freetype PROPERTY IMPORTED_LOCATION_RELEASE "${_ft_rel}") - endif() - if(_ft_dbg) - set_property(TARGET Freetype::Freetype PROPERTY IMPORTED_LOCATION_DEBUG "${_ft_dbg}") - endif() - - message(STATUS "[SCIRun] Freetype::Freetype: rel='${_ft_rel}' dbg='${_ft_dbg}' " - "inc1='${Freetype_INCLUDE_DIR}' inc2='${FREETYPE_INCLUDE_DIR2}'") - else() - message(WARNING "[SCIRun] Could not find freetype{,d}.lib in '${Freetype_LIB_DIR}'") - endif() - else() - message(WARNING "[SCIRun] Freetype_LIB_DIR not set or invalid; cannot synthesize Freetype::Freetype") - endif() -endif() - -_ensure_header(LODEPNG_INCLUDE_DIR "lodepng/lodepng.h") -_ensure_header(SQLite3_INCLUDE_DIR "sqlite3.h") -_ensure_header(TNY_INCLUDE_DIR "tny/tny.h") -if(NOT TNY_INCLUDE_DIR) - _ensure_header(TNY_INCLUDE_DIR "tny/tny.hpp") -endif() -_ensure_header(SpdLog_INCLUDE_DIR "spdlog/spdlog.h") -_ensure_header(GLM_INCLUDE_DIR "glm/glm.hpp") -_ensure_header(SCI_TEEM_INCLUDE "teem/ten.h") -_ensure_header(Freetype_INCLUDE_DIR "ft2build.h") - -# --- Robust Eigen include discovery (handles eigen3 layout and unsupported) --- -# Try to honor a pre-set Eigen_INCLUDE_DIR first -set(_eigen_ok FALSE) -if(Eigen_INCLUDE_DIR) - if(EXISTS "${Eigen_INCLUDE_DIR}/Eigen/Dense" AND EXISTS "${Eigen_INCLUDE_DIR}/unsupported/Eigen/CXX11/Tensor") - set(_eigen_ok TRUE) - endif() -endif() - -# If not OK, auto-probe from CMAKE_PREFIX_PATH (prefer eigen3 layout) -if(NOT _eigen_ok) - set(_candidates "") - foreach(_p IN LISTS CMAKE_PREFIX_PATH) - list(APPEND _candidates - "${_p}/include/eigen3" - "${_p}/include" # legacy fallback - ) - endforeach() - - set(_found "") - foreach(_inc IN LISTS _candidates) - if(EXISTS "${_inc}/Eigen/Dense" AND EXISTS "${_inc}/unsupported/Eigen/CXX11/Tensor") - set(_found "${_inc}") - break() - endif() - endforeach() - - if(_found) - set(Eigen_INCLUDE_DIR "${_found}" CACHE PATH "Eigen include root (expects Eigen/ and unsupported/)" FORCE) - message(STATUS "[SCIRun] Eigen_INCLUDE_DIR -> '${Eigen_INCLUDE_DIR}' (contains Eigen and unsupported)") - set(_eigen_ok TRUE) - endif() -endif() +#message("SCI_CTK_INCLUDE") +#message(${SCI_CTK_INCLUDE}) -# If we still don’t have unsupported, warn loudly (this will cause compile errors later) -if(NOT _eigen_ok) - # Try to at least find Eigen/Dense to help with diagnostics - set(_fallback "") - foreach(_p IN LISTS CMAKE_PREFIX_PATH) - foreach(_inc IN ITEMS "${_p}/include/eigen3" "${_p}/include") - if(EXISTS "${_inc}/Eigen/Dense") - set(_fallback "${_inc}") - break() - endif() - endforeach() - if(_fallback) - break() - endif() - endforeach() - - if(_fallback) - set(Eigen_INCLUDE_DIR "${_fallback}" CACHE PATH "Eigen include root (no unsupported found)" FORCE) - message(WARNING - "[SCIRun] Found Eigen at '${Eigen_INCLUDE_DIR}', but 'unsupported/Eigen/CXX11/Tensor' is missing.\n" - " Ensure the Eigen external installs the 'unsupported' directory (Eigen 3.4 install puts both under include/eigen3).") - else() - # Clear incorrect cache if present - if(Eigen_INCLUDE_DIR) - message(WARNING "[SCIRun] Eigen_INCLUDE_DIR='${Eigen_INCLUDE_DIR}' does not contain Eigen/Dense. Clearing.") - unset(Eigen_INCLUDE_DIR CACHE) - unset(Eigen_INCLUDE_DIR) - endif() - endif() -endif() - -# ---- Cleaver2 normalization + validation ---- -# Superbuild exports one of: -# Cleaver2_INCLUDE_DIR / Cleaver2_LIB_DIR -# CLEAVER2_INCLUDE / CLEAVER2_INCLUDE_DIR / CLEAVER2_LIBRARY_DIR -# Normalize to SCIRun’s internal names for consistency. -if(DEFINED Cleaver2_INCLUDE_DIR AND NOT DEFINED CLEAVER2_INCLUDE) - set(CLEAVER2_INCLUDE "${Cleaver2_INCLUDE_DIR}") -endif() -if(DEFINED Cleaver2_LIB_DIR AND NOT DEFINED CLEAVER2_LIBRARY_DIR) - set(CLEAVER2_LIBRARY_DIR "${Cleaver2_LIB_DIR}") -endif() -_ensure_header(CLEAVER2_INCLUDE "cleaver2/vec3.h") -# Create easy-to-use internal aliases (like you do for other externals) -if(DEFINED CLEAVER2_INCLUDE) - set(SCI_CLEAVER2_INCLUDE "${CLEAVER2_INCLUDE}" CACHE PATH "Cleaver2 include root (contains 'cleaver2/')" FORCE) -endif() -if(DEFINED CLEAVER2_LIBRARY_DIR) - set(SCI_CLEAVER2_LIBRARY_DIR "${CLEAVER2_LIBRARY_DIR}" CACHE PATH "Cleaver2 library directory" FORCE) -endif() - -# Print diagnostics -message(STATUS "CLEAVER2_INCLUDE='${CLEAVER2_INCLUDE}'") -message(STATUS "CLEAVER2_LIBRARY_DIR='${CLEAVER2_LIBRARY_DIR}'") -message(STATUS "Boost_INCLUDE_DIR='${Boost_INCLUDE_DIR}'") -message(STATUS "GLEW_INCLUDE_DIR='${GLEW_INCLUDE_DIR}'") -message(STATUS "LODEPNG_INCLUDE_DIR='${LODEPNG_INCLUDE_DIR}'") -message(STATUS "SQLite3_INCLUDE_DIR='${SQLite3_INCLUDE_DIR}'") -message(STATUS "TNY_INCLUDE_DIR='${TNY_INCLUDE_DIR}'") -message(STATUS "SpdLog_INCLUDE_DIR='${SpdLog_INCLUDE_DIR}'") -message(STATUS "GLM_INCLUDE_DIR='${GLM_INCLUDE_DIR}'") -message(STATUS "Eigen_INCLUDE_DIR='${Eigen_INCLUDE_DIR}'") - -# Quick existence confirmations -if(GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") - message(STATUS "GLEW header OK: ${GLEW_INCLUDE_DIR}/GL/glew.h") -endif() -if(LODEPNG_INCLUDE_DIR AND EXISTS "${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") - message(STATUS "LodePNG header OK: ${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") -endif() -if(SQLite3_INCLUDE_DIR AND EXISTS "${SQLite3_INCLUDE_DIR}/sqlite3.h") - message(STATUS "SQLite3 header OK: ${SQLite3_INCLUDE_DIR}/sqlite3.h") -endif() -if(TNY_INCLUDE_DIR AND EXISTS "${TNY_INCLUDE_DIR}/tny/tny.hpp") - message(STATUS "TNY header OK: ${TNY_INCLUDE_DIR}/tny/tny.hpp") -endif() -if(SpdLog_INCLUDE_DIR AND EXISTS "${SpdLog_INCLUDE_DIR}/spdlog/spdlog.h") - message(STATUS "Spdlog header OK: ${SpdLog_INCLUDE_DIR}/spdlog/spdlog.h") -endif() -if(GLM_INCLUDE_DIR AND EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp") - message(STATUS "GLM header OK: ${GLM_INCLUDE_DIR}/glm/glm.hpp") -endif() - -# ---- Qwt (STATIC) detection + imported target (place before _SCIRUN_INCLUDE_DIRS) ---- -if(NOT BUILD_HEADLESS) - # 1) Include dir: prefer install/include/qwt so '#include ' works directly - if(NOT DEFINED SCI_QWT_INCLUDE OR NOT EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") - if(DEFINED QWT_INSTALL_DIR AND EXISTS "${QWT_INSTALL_DIR}/include/qwt/qwt_plot.h") - set(SCI_QWT_INCLUDE "${QWT_INSTALL_DIR}/include/qwt" CACHE PATH "Qwt include dir" FORCE) - elseif(DEFINED QWT_INCLUDE_DIR) - if(EXISTS "${QWT_INCLUDE_DIR}/qwt/qwt_plot.h") - set(SCI_QWT_INCLUDE "${QWT_INCLUDE_DIR}/qwt" CACHE PATH "Qwt include dir" FORCE) - elseif(EXISTS "${QWT_INCLUDE_DIR}/qwt_plot.h") - set(SCI_QWT_INCLUDE "${QWT_INCLUDE_DIR}" CACHE PATH "Qwt include dir" FORCE) - endif() - else() - # Probe from prefix path - foreach(_p IN LISTS CMAKE_PREFIX_PATH) - if(EXISTS "${_p}/include/qwt/qwt_plot.h") - set(SCI_QWT_INCLUDE "${_p}/include/qwt" CACHE PATH "Qwt include dir" FORCE) - break() - endif() - endforeach() - endif() - endif() - - # 2) Library dir (from superbuild) + locate static libs - if(NOT DEFINED QWT_LIBRARY_DIR AND DEFINED QWT_INSTALL_DIR) - if(EXISTS "${QWT_INSTALL_DIR}/lib64") - set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib64") - else() - set(QWT_LIBRARY_DIR "${QWT_INSTALL_DIR}/lib") - endif() - endif() - - set(_qwt_rel_lib "") - set(_qwt_dbg_lib "") - if(DEFINED QWT_LIBRARY_DIR AND IS_DIRECTORY "${QWT_LIBRARY_DIR}") - # Typical MSVC names for Qwt static (or single-config import lib when DLLs are absent) - file(GLOB _rel_cands "${QWT_LIBRARY_DIR}/qwt.lib" "${QWT_LIBRARY_DIR}/libqwt.lib") - file(GLOB _dbg_cands "${QWT_LIBRARY_DIR}/qwtd.lib" "${QWT_LIBRARY_DIR}/libqwtd.lib") - - if(_rel_cands) - list(SORT _rel_cands) - list(GET _rel_cands 0 _qwt_rel_lib) # safe: list is non-empty - endif() - - if(_dbg_cands) - list(SORT _dbg_cands) - list(GET _dbg_cands 0 _qwt_dbg_lib) # safe: list is non-empty - endif() - - # If only one variant exists, use it for both configs (common in static-only installs) - if(NOT _qwt_rel_lib AND _qwt_dbg_lib) - set(_qwt_rel_lib "${_qwt_dbg_lib}") - endif() - if(NOT _qwt_dbg_lib AND _qwt_rel_lib) - set(_qwt_dbg_lib "${_qwt_rel_lib}") - endif() - endif() - - # 3) Imported STATIC target (preferred) - if(NOT TARGET Qwt::Qwt - AND ( _qwt_rel_lib OR _qwt_dbg_lib ) - AND DEFINED SCI_QWT_INCLUDE AND EXISTS "${SCI_QWT_INCLUDE}/qwt_plot.h") - - add_library(Qwt::Qwt STATIC IMPORTED) - set_property(TARGET Qwt::Qwt PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SCI_QWT_INCLUDE}") - if(_qwt_rel_lib) - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_RELEASE "${_qwt_rel_lib}") - endif() - if(_qwt_dbg_lib) - set_property(TARGET Qwt::Qwt PROPERTY IMPORTED_LOCATION_DEBUG "${_qwt_dbg_lib}") - endif() - - # Consumers of static Qwt: do NOT define QWT_DLL; define QWT_STATIC if Qwt headers look for it. - target_compile_definitions(Qwt::Qwt INTERFACE QWT_STATIC) - - message(STATUS "[SCIRun] Qwt::Qwt (static): rel='${_qwt_rel_lib}', dbg='${_qwt_dbg_lib}', inc='${SCI_QWT_INCLUDE}'") - endif() - - # 4) Legacy variable for modules that still link ${SCI_QWT_LIBRARY} - # Provide an optimized/debug list mapped to the same static libraries. - set(SCI_QWT_LIBRARY "" CACHE STRING "Qwt libraries (optimized/debug)" FORCE) - if(_qwt_rel_lib OR _qwt_dbg_lib) - set(_pair "") - if(_qwt_rel_lib) - list(APPEND _pair optimized "${_qwt_rel_lib}") - endif() - if(_qwt_dbg_lib) - list(APPEND _pair debug "${_qwt_dbg_lib}") - endif() - set(SCI_QWT_LIBRARY "${_pair}" CACHE STRING "Qwt libraries (optimized/debug)" FORCE) - unset(_pair) - endif() -endif() - -# ---------- Build include list with guards to avoid stray '/include' ---------- - -set(_SCIRUN_INCLUDE_DIRS +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${SCIRun_SOURCE_DIR}/ ${SCIRun_SOURCE_DIR}/include @@ -1602,77 +564,15 @@ set(_SCIRUN_INCLUDE_DIRS ${SCIRun_BINARY_DIR}/include ${SCI_TEEM_INCLUDE} ${SCI_ZLIB_INCLUDE} + ${GLM_DIR} + ${SPDLOG_DIR}/include + ${Eigen_DIR} + ${SCI_TNY_INCLUDE} + ${SCI_LODEPNG_INCLUDE} ${SCI_QWT_INCLUDE} ${SCI_CLEAVER2_INCLUDE} ) -# If the second include dir wasn't set, derive it from the first -if(NOT FREETYPE_INCLUDE_DIR2 OR NOT EXISTS "${FREETYPE_INCLUDE_DIR2}/freetype/config/ftheader.h") - if(Freetype_INCLUDE_DIR AND EXISTS "${Freetype_INCLUDE_DIR}/freetype2/freetype/config/ftheader.h") - set(FREETYPE_INCLUDE_DIR2 "${Freetype_INCLUDE_DIR}/freetype2" CACHE PATH "FREETYPE_INCLUDE_DIR2" FORCE) - endif() -endif() - -# Append both include roots (only if they exist) -if(Freetype_INCLUDE_DIR AND EXISTS "${Freetype_INCLUDE_DIR}/ft2build.h") - list(APPEND _SCIRUN_INCLUDE_DIRS "${Freetype_INCLUDE_DIR}") -endif() -if(FREETYPE_INCLUDE_DIR2 AND EXISTS "${FREETYPE_INCLUDE_DIR2}/freetype/config/ftheader.h") - list(APPEND _SCIRUN_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR2}") -endif() - -# Boost (legacy var) -if(Boost_INCLUDE_DIR AND EXISTS "${Boost_INCLUDE_DIR}/boost") - list(APPEND _SCIRUN_INCLUDE_DIRS "${Boost_INCLUDE_DIR}") -endif() - -# GLEW -if(GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") - list(APPEND _SCIRUN_INCLUDE_DIRS "${GLEW_INCLUDE_DIR}") -endif() - -# SQLite -if(SQLite3_INCLUDE_DIR AND EXISTS "${SQLite3_INCLUDE_DIR}/sqlite3.h") - list(APPEND _SCIRUN_INCLUDE_DIRS "${SQLite3_INCLUDE_DIR}") -endif() - -# Spdlog (IMPORTANT: do NOT append '/include'; var already points to include dir) -if(SpdLog_INCLUDE_DIR AND EXISTS "${SpdLog_INCLUDE_DIR}/spdlog/spdlog.h") - list(APPEND _SCIRUN_INCLUDE_DIRS "${SpdLog_INCLUDE_DIR}") -endif() - -# GLM -if(GLM_INCLUDE_DIR AND EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp") - list(APPEND _SCIRUN_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") -endif() - -# Tny -if(TNY_INCLUDE_DIR AND EXISTS "${TNY_INCLUDE_DIR}/tny/tny.hpp") - list(APPEND _SCIRUN_INCLUDE_DIRS "${TNY_INCLUDE_DIR}") -endif() - -# LodePNG -if(LODEPNG_INCLUDE_DIR AND EXISTS "${LODEPNG_INCLUDE_DIR}/lodepng/lodepng.h") - list(APPEND _SCIRUN_INCLUDE_DIRS "${LODEPNG_INCLUDE_DIR}") -endif() - -# Eigen: add only if the directory contains Eigen/Dense -if(Eigen_INCLUDE_DIR AND EXISTS "${Eigen_INCLUDE_DIR}/Eigen/Dense") - list(APPEND _SCIRUN_INCLUDE_DIRS "${Eigen_INCLUDE_DIR}") -endif() - -# De-duplicate & print for visibility -list(REMOVE_DUPLICATES _SCIRUN_INCLUDE_DIRS) - -function(print_list name) - message(STATUS "${name}:") - foreach(item IN LISTS ${name}) - message(STATUS " - ${item}") - endforeach() -endfunction() -print_list("_SCIRUN_INCLUDE_DIRS") - -include_directories(${_SCIRUN_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(SYSTEM ${SCI_BOOST_INCLUDE}) ADD_DEFINITIONS(-DQT_NO_KEYWORDS) @@ -1698,12 +598,6 @@ ENDMACRO() MACRO(SCIRUN_ADD_LIBRARY library) ADD_LIBRARY(${library} ${ARGN}) - # Attach global compile definitions (Qt6, QT_NO_KEYWORDS, etc.) - if (SCIRUN_QT_MAJOR STREQUAL "6") - target_compile_definitions(${library} PUBLIC SCIRUN_QT6_ENABLED) - endif() - target_compile_definitions(${library} PUBLIC QT_NO_KEYWORDS) - if(MSVC) # TODO: # target_compile_options(${library} PRIVATE /W4 /WX) @@ -1748,6 +642,7 @@ ADD_SUBDIRECTORY(Graphics) ADD_SUBDIRECTORY(Main) + ADD_SUBDIRECTORY(Testing) ######################################################################## @@ -1932,9 +827,9 @@ SET_PROPERTY(TARGET pugixml PROPERTY FOLDER "Externals") IF(BUILD_TESTING) SET_PROPERTY(TARGET gmock PROPERTY FOLDER "Testing Support") - SET_PROPERTY(TARGET gmock_main PROPERTY FOLDER "Testing Support") + SET_PROPERTY(TARGET gmock_main PROPERTY FOLDER "Testing Support") SET_PROPERTY(TARGET gtest PROPERTY FOLDER "Testing Support") - SET_PROPERTY(TARGET gtest_main PROPERTY FOLDER "Testing Support") + SET_PROPERTY(TARGET gtest_main PROPERTY FOLDER "Testing Support") SET_PROPERTY(TARGET Testing_Utils PROPERTY FOLDER "Testing Support") SET_PROPERTY(TARGET Testing_ModuleTestBase PROPERTY FOLDER "Testing Support") ENDIF() @@ -1999,12 +894,12 @@ IF(BUILD_TESTING) IF(NOT BUILD_HEADLESS) SET_PROPERTY(TARGET Interface_Modules_Render_Tests PROPERTY FOLDER "Interface/Tests") - SET_PROPERTY(TARGET Modules_Dialog_Factory_Tests PROPERTY FOLDER "Interface/Tests") + SET_PROPERTY(TARGET Modules_Dialog_Factory_Tests PROPERTY FOLDER "Interface/Tests") ENDIF() IF(BUILD_WITH_PYTHON) SET_PROPERTY(TARGET Core_Python_Tests PROPERTY FOLDER "Core/Tests") SET_PROPERTY(TARGET Engine_Python_Tests PROPERTY FOLDER "Dataflow/Engine/Tests") - SET_PROPERTY(TARGET Modules_Python_Tests PROPERTY FOLDER "Modules/Python") + SET_PROPERTY(TARGET Modules_Python_Tests PROPERTY FOLDER "Modules/Python") ENDIF() ENDIF() @@ -2012,10 +907,10 @@ SET_PROPERTY(TARGET xml2 PROPERTY FOLDER "Externals") IF(BUILD_WITH_PYTHON) SET_PROPERTY(TARGET Core_Python PROPERTY FOLDER "Core") - SET_PROPERTY(TARGET SCIRunPythonAPI PROPERTY FOLDER "Dataflow/Engine") - SET_PROPERTY(TARGET Modules_Python PROPERTY FOLDER "Modules/Python") + SET_PROPERTY(TARGET SCIRunPythonAPI PROPERTY FOLDER "Dataflow/Engine") + SET_PROPERTY(TARGET Modules_Python PROPERTY FOLDER "Modules/Python") IF(NOT BUILD_HEADLESS) - SET_PROPERTY(TARGET Interface_Modules_Python PROPERTY FOLDER "Interface/Modules") + SET_PROPERTY(TARGET Interface_Modules_Python PROPERTY FOLDER "Interface/Modules") ENDIF() ENDIF() @@ -2037,7 +932,7 @@ SET(PACKAGING_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Welcome.txt" CACHE INTE # TODO: need release notes #SET(PACKAGING_RELEASENOTES "${CMAKE_CURRENT_SOURCE_DIR}/ReleaseNotes.txt" CACHE INTERNAL "Where to find the releasenotes file." FORCE ) -SET(PACKAGING_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\scirun5_256.png" CACHE INTERNAL "Packing icon." FORCE ) +SET(PACKAGING_ICON "${CMAKE_SOURCE_DIR}/Resources/Icons\\\\scirun5_256.png" CACHE INTERNAL "Packing icon." FORCE ) MESSAGE(STATUS "Configuring SCIRun packaging") @@ -2064,6 +959,7 @@ SET(CPACK_PACKAGE_VERSION "${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}.${SCI SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${APPLICATION_NAME}_${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}") + # other platform settings will be built up from here IF(APPLE) SET(CPACK_GENERATOR "productbuild;TGZ") @@ -2106,20 +1002,21 @@ ELSEIF(WIN32 AND NOT UNIX) SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8) - SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\${APPLICATION_NAME}") + SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${APPLICATION_NAME}") SET(CPACK_NSIS_MUI_ICON "${APPLICATION_WINDOWS_ICON}") SET(CPACK_NSIS_DISPLAY_NAME "${APPLICATION_NAME} ${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}") - SET(CPACK_NSIS_HELP_LINK "http:\\\\${APPLICATION_URL}") - SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\${APPLICATION_URL}") + SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\${APPLICATION_URL}") + SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\${APPLICATION_URL}") SET(CPACK_NSIS_CONTACT ${APPLICATION_CONTACT} ) SET(CPACK_NSIS_MODIFY_PATH ON) SET(CPACK_PACKAGE_EXECUTABLES "${APPLICATION_NAME}" "${APPLICATION_NAME}") SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " WriteRegStr HKCR '${APPLICATION_EXTENSION}' '' '${APPLICATION_NAME}' - WriteRegStr HKCR '${APPLICATION_NAME}\\shell' '' 'open' - WriteRegStr HKCR '${APPLICATION_NAME}\\DefaultIcon' '' '$INSTDIR\\bin\\${APPLICATION_NAME}.exe,0' - WriteRegStr HKCR '${APPLICATION_NAME}\\shell\\open\\command' '' '$INSTDIR\\bin\\${APPLICATION_NAME}.exe \\\"%1\\\"' - WriteRegStr HKCR '${APPLICATION_NAME}\\shell\\edit\\command' '' '$INSTDIR\\bin\\${APPLICATION_NAME}.exe \\\"%1\\\"' + WriteRegStr HKCR '${APPLICATION_NAME}' '' '${APPLICATION_NAME} Network File' + WriteRegStr HKCR '${APPLICATION_NAME}\\\\shell' '' 'open' + WriteRegStr HKCR '${APPLICATION_NAME}\\\\DefaultIcon' '' '$INSTDIR\\\\bin\\\\${APPLICATION_NAME}.exe,0' + WriteRegStr HKCR '${APPLICATION_NAME}\\\\shell\\\\open\\\\command' '' '$INSTDIR\\\\bin\\\\${APPLICATION_NAME}.exe \\\"%1\\\"' + WriteRegStr HKCR '${APPLICATION_NAME}\\\\shell\\\\edit\\\\command' '' '$INSTDIR\\\\bin\\\\${APPLICATION_NAME}.exe \\\"%1\\\"' System::Call 'Shell32::SHChangeNotify( i 0x800000, i 0, i 0, i 0)' ") SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " @@ -2140,4 +1037,4 @@ MARK_AS_ADVANCED(ENABLE_GCOV_DATAFILES) IF(ENABLE_GCOV_DATA_FILES) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") -ENDIF() \ No newline at end of file +ENDIF() diff --git a/src/Core/Algorithms/BrainStimulator/CMakeLists.txt b/src/Core/Algorithms/BrainStimulator/CMakeLists.txt index 1724ecde6c..227e34cf58 100644 --- a/src/Core/Algorithms/BrainStimulator/CMakeLists.txt +++ b/src/Core/Algorithms/BrainStimulator/CMakeLists.txt @@ -60,7 +60,6 @@ TARGET_LINK_LIBRARIES(Algorithms_BrainStimulator Core_Algorithms_Legacy_Fields # Core_Datatypes_Legacy_BrainStimulator Algorithms_Base - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/DataIO/CMakeLists.txt b/src/Core/Algorithms/DataIO/CMakeLists.txt index 2ed1adcd93..e4e83b2c57 100644 --- a/src/Core/Algorithms/DataIO/CMakeLists.txt +++ b/src/Core/Algorithms/DataIO/CMakeLists.txt @@ -50,7 +50,6 @@ TARGET_LINK_LIBRARIES(Algorithms_DataIO Core_Datatypes_Mesh Algorithms_Base Core_Datatypes_Legacy_Field - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Describe/CMakeLists.txt b/src/Core/Algorithms/Describe/CMakeLists.txt index cc1fa4f7ca..25f0133130 100644 --- a/src/Core/Algorithms/Describe/CMakeLists.txt +++ b/src/Core/Algorithms/Describe/CMakeLists.txt @@ -43,10 +43,8 @@ SCIRUN_ADD_LIBRARY(Algorithms_Describe TARGET_LINK_LIBRARIES(Algorithms_Describe Core_Datatypes Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Bundle Algorithms_Field Algorithms_Math - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Factory/CMakeLists.txt b/src/Core/Algorithms/Factory/CMakeLists.txt index 2412f10d31..02d5031675 100644 --- a/src/Core/Algorithms/Factory/CMakeLists.txt +++ b/src/Core/Algorithms/Factory/CMakeLists.txt @@ -41,8 +41,7 @@ IF(GENERATE_MODULE_FACTORY_CODE) MESSAGE(STATUS "Setting up algorithm factory generator") ADD_EXECUTABLE(MakeAlgorithmFactory Generator/MakeAlgorithmFactory.h Generator/MakeAlgorithmFactory.cc) TARGET_LINK_LIBRARIES(MakeAlgorithmFactory - Modules_Factory_Generator - ${SCI_BOOST_LIBRARY}) + Modules_Factory_Generator) SET_PROPERTY(TARGET MakeAlgorithmFactory PROPERTY FOLDER "Modules") # add the command to generate the source code @@ -79,7 +78,6 @@ TARGET_LINK_LIBRARIES(Algorithms_Factory Core_Algorithms_Visualization Core_Algorithms_Legacy_FiniteElements Core_Algorithms_Legacy_Converter - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Factory/Tests/CMakeLists.txt b/src/Core/Algorithms/Factory/Tests/CMakeLists.txt index 45a50e5097..c455da45a9 100644 --- a/src/Core/Algorithms/Factory/Tests/CMakeLists.txt +++ b/src/Core/Algorithms/Factory/Tests/CMakeLists.txt @@ -48,5 +48,4 @@ TARGET_LINK_LIBRARIES(Algorithm_Layer_Test Engine_Network gtest_main gtest - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Core/Algorithms/Field/CMakeLists.txt b/src/Core/Algorithms/Field/CMakeLists.txt index 9b90dd91b3..163729e3a3 100644 --- a/src/Core/Algorithms/Field/CMakeLists.txt +++ b/src/Core/Algorithms/Field/CMakeLists.txt @@ -25,16 +25,15 @@ # DEALINGS IN THE SOFTWARE. # -# ---- Algorithms_Field ---- -set(Algorithms_Field_SRCS +SET(Algorithms_Field_SRCS ReportFieldInfoAlgorithm.cc InterfaceWithCleaver2Algorithm.cc CalculateNodeLocationFrequencyAlgorithm.cc RefineTetMeshLocallyAlgorithm.cc ) -set(Algorithms_Field_HEADERS +SET(Algorithms_Field_HEADERS ReportFieldInfoAlgorithm.h InterfaceWithCleaver2Algorithm.h CalculateNodeLocationFrequencyAlgorithm.h @@ -47,94 +46,16 @@ SCIRUN_ADD_LIBRARY(Algorithms_Field ${Algorithms_Field_SRCS} ) -# Keep original shared define behavior -target_compile_definitions(Algorithms_Field - PRIVATE $<$:BUILD_Algorithms_Field> +TARGET_LINK_LIBRARIES(Algorithms_Field + Core_Datatypes + Core_Datatypes_Legacy_Field + Algorithms_Base + Core_Algorithms_Legacy_Fields + ${SCI_CLEAVER2_LIBRARY} ) -# ----------------------------------------------------------------------------------- -# Cleaver2 consumption via superbuild-exported paths (no find_package needed) -# Expected variables (from superbuild -> top-level normalization): -# CLEAVER2_INCLUDE - parent that contains 'cleaver2/vec3.h' (e.g. .../Install/Cleaver2_external/include) -# CLEAVER2_LIBRARY_DIR - directory with the Cleaver2 library file -# (Optional aliases: SCI_CLEAVER2_INCLUDE, SCI_CLEAVER2_LIBRARY_DIR) -# ----------------------------------------------------------------------------------- +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Algorithms_Field) +ENDIF(BUILD_SHARED_LIBS) -# Prefer normalized aliases if defined -if(DEFINED SCI_CLEAVER2_INCLUDE) - set(_c2_inc "${SCI_CLEAVER2_INCLUDE}") -else() - set(_c2_inc "${CLEAVER2_INCLUDE}") -endif() -if(DEFINED SCI_CLEAVER2_LIBRARY_DIR) - set(_c2_libdir "${SCI_CLEAVER2_LIBRARY_DIR}") -else() - set(_c2_libdir "${CLEAVER2_LIBRARY_DIR}") -endif() - -# Validate presence -if(NOT _c2_inc OR NOT EXISTS "${_c2_inc}/cleaver2/vec3.h") - message(FATAL_ERROR - "Cleaver2 include directory is missing or invalid.\n" - " CLEAVER2_INCLUDE='${CLEAVER2_INCLUDE}' ; SCI_CLEAVER2_INCLUDE='${SCI_CLEAVER2_INCLUDE}'\n" - " Expected: '/cleaver2/vec3.h'.") -endif() - -if(NOT _c2_libdir OR NOT EXISTS "${_c2_libdir}") - message(FATAL_ERROR - "Cleaver2 library directory missing.\n" - " CLEAVER2_LIBRARY_DIR='${CLEAVER2_LIBRARY_DIR}' ; SCI_CLEAVER2_LIBRARY_DIR='${SCI_CLEAVER2_LIBRARY_DIR}'") -endif() - -# Locate the library file inside the provided lib dir -set(_c2_libpath "") -if(WIN32) - # Windows import/static lib - foreach(_cand IN ITEMS "cleaver2.lib" "libcleaver2.lib") - if(EXISTS "${_c2_libdir}/${_cand}") - set(_c2_libpath "${_c2_libdir}/${_cand}") - break() - endif() - endforeach() -elseif(APPLE) - foreach(_cand IN ITEMS "libcleaver2.dylib" "libcleaver2.a") - if(EXISTS "${_c2_libdir}/${_cand}") - set(_c2_libpath "${_c2_libdir}/${_cand}") - break() - endif() - endforeach() -else() - foreach(_cand IN ITEMS "libcleaver2.so" "libcleaver2.a") - if(EXISTS "${_c2_libdir}/${_cand}") - set(_c2_libpath "${_c2_libdir}/${_cand}") - break() - endif() - endforeach() -endif() - -if(NOT _c2_libpath) - message(FATAL_ERROR - "Could not find Cleaver2 library under '${_c2_libdir}'.\n" - "Expected one of: cleaver2(.lib|.so|.dylib|.a)") -endif() - -# Define a private imported target so include usage is target-scoped and modern -add_library(Cleaver2::cleaver2 UNKNOWN IMPORTED) -set_target_properties(Cleaver2::cleaver2 PROPERTIES - IMPORTED_LOCATION "${_c2_libpath}" - INTERFACE_INCLUDE_DIRECTORIES "${_c2_inc}" -) - -# Link everything -target_link_libraries(Algorithms_Field - PRIVATE - Core_Datatypes - Core_Datatypes_Legacy_Field - Algorithms_Base - Core_Algorithms_Legacy_Fields - ${SCI_BOOST_LIBRARY} - Cleaver2::cleaver2 -) - -# Tests -SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file +SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt b/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt index 04672a5a56..b19e2fbe89 100644 --- a/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Converter/CMakeLists.txt @@ -26,9 +26,9 @@ # -# Sources of Core/Algorithms/Legacy/Converter classes +# Sources of Core/Algorithms/Converter classes -set(Core_Algorithms_Legacy_Converter_SRCS +SET(Core_Algorithms_Legacy_Converter_SRCS ConverterAlgo.cc #MatrixToField.cc NrrdToField.cc @@ -39,7 +39,7 @@ set(Core_Algorithms_Legacy_Converter_SRCS ConvertMatrixToString.cc ) -set(Core_Algorithms_Legacy_Converter_HEADERS +SET(Core_Algorithms_Legacy_Converter_HEADERS ConverterAlgo.h NrrdToField.h FieldToNrrd.h @@ -51,95 +51,16 @@ set(Core_Algorithms_Legacy_Converter_HEADERS SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_Converter ${Core_Algorithms_Legacy_Converter_SRCS} - ${Core_Algorithms_Legacy_Converter_HEADERS} + ${Core_Algorithms_Legacy_Converter_HEADERS}) + +TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Converter + Algorithms_Base + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + Core_Datatypes_Legacy_Bundle ) -# Export macro for this shared library (existing behavior) -if(BUILD_SHARED_LIBS) - target_compile_definitions(Core_Algorithms_Legacy_Converter PRIVATE BUILD_Core_Algorithms_Legacy_Converter) -endif() - -# ========================================================== -# Teem discovery (same pattern as Core_Geometry_Primitives) -# ========================================================== -# Prefer a config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback to superbuild exports - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -target_compile_definitions(Core_Algorithms_Legacy_Converter PRIVATE TEEM_STATIC) - -# Existing internal deps -target_link_libraries(Core_Algorithms_Legacy_Converter - PRIVATE - Algorithms_Base - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - Core_Datatypes_Legacy_Bundle - ${_teem_target} -) - -# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: -if(TARGET ZLIB::ZLIB) - target_link_libraries(Core_Algorithms_Legacy_Converter PRIVATE ZLIB::ZLIB) -endif() \ No newline at end of file +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_Converter) +ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt b/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt index d0614afe56..f82185da84 100644 --- a/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/DataIO/CMakeLists.txt @@ -25,9 +25,10 @@ # DEALINGS IN THE SOFTWARE. # -# Sources of Core/Algorithms/Legacy/DataIO classes -set(Core_Algorithms_Legacy_DataIO_SRCS +# Sources of Core/Algorithms/DataIO classes + +SET(Core_Algorithms_Legacy_DataIO_SRCS DataIOAlgo.cc #G3DToFieldReader.cc ObjToFieldReader.cc @@ -37,7 +38,7 @@ set(Core_Algorithms_Legacy_DataIO_SRCS STLUtils.cc ) -set(Core_Algorithms_Legacy_DataIO_HEADERS +SET(Core_Algorithms_Legacy_DataIO_HEADERS #G3DToFieldReader.h ObjToFieldReader.h VTKToTriSurfReader.h @@ -53,97 +54,17 @@ SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_DataIO ${Core_Algorithms_Legacy_DataIO_HEADERS} ) -# Export macro for this shared library (existing behavior) -if(BUILD_SHARED_LIBS) - target_compile_definitions(Core_Algorithms_Legacy_DataIO PRIVATE BUILD_Core_Algorithms_Legacy_DataIO) -endif() - -# ========================================================== -# Teem discovery (same pattern as Core_Algorithms_Legacy_Converter) -# ========================================================== -# Prefer a config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback to superbuild exports - # Expect these to be set by the superbuild toolchain or cache - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - # Try to resolve the actual library file - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -# If you are using shared Teem (DLL), comment this line out. -target_compile_definitions(Core_Algorithms_Legacy_DataIO PRIVATE TEEM_STATIC) +TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_DataIO + Algorithms_Base + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd -# Existing internal deps + Teem -target_link_libraries(Core_Algorithms_Legacy_DataIO - PRIVATE - Algorithms_Base - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - Core_Math - Core_Persistent - Core_ImportExport - ${_teem_target} + Core_Math + Core_Persistent + Core_ImportExport ) -# If Teem was built with zlib (very common for NRRD), static Teem needs zlib symbols too: -if(TARGET ZLIB::ZLIB) - target_link_libraries(Core_Algorithms_Legacy_DataIO PRIVATE ZLIB::ZLIB) -endif() \ No newline at end of file +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_DataIO) +ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt index b49ab98391..542aff02ea 100644 --- a/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Fields/CMakeLists.txt @@ -229,174 +229,19 @@ SCIRUN_ADD_LIBRARY(Core_Algorithms_Legacy_Fields ${Core_Algorithms_Legacy_Fields_SRCS} ) -# ========================================================== -# Teem discovery (prefer config, fallback to superbuild vars) -# Static consumption: ensure headers do NOT use dllimport. -# ========================================================== -# Expect these from superbuild: -# Teem_INCLUDE_DIR -> <.../Externals/Install/Teem_external>/include -# Teem_LIB_DIR -> <.../Externals/Install/Teem_external>/lib - -# Prefer a config package if available (uncommon for Teem, but harmless): -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - # If this comes from a config that exported a SHARED target, - # force static-consumer macros at call sites: - set_property(TARGET Teem::teem APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS "TEEM_STATIC" - ) - # If your Teem was built with zlib and the config exposes it, link transitively. - # Otherwise we’ll add Zlib explicitly below when we link this target. - set(_teem_target Teem::teem) -else() - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - # Resolve static library for each config - set(_TEEM_LIB_RELEASE "") - set(_TEEM_LIB_DEBUG "") - - if(WIN32) - # Common names used by Teem on Windows - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.lib") - endif() - - # Debug may use the same name or have a trailing 'd' - if(EXISTS "${Teem_LIB_DIR}/teemd.lib") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/teemd.lib") - elseif(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteemd.lib") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteemd.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - # Prefer static if available - if(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.a") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.a") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - # Shared exists but we still treat consumer as static (headers need static defines) - set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.dylib") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.dylib") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.a") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.a") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_TEEM_LIB_RELEASE "${Teem_LIB_DIR}/libteem.so") - set(_TEEM_LIB_DEBUG "${Teem_LIB_DIR}/libteem.so") - endif() - endif() - - # Last-resort search - if(NOT _TEEM_LIB_RELEASE) - find_library(TEEM_LIBRARY_RELEASE - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY_RELEASE) - set(_TEEM_LIB_RELEASE "${TEEM_LIBRARY_RELEASE}") - set(_TEEM_LIB_DEBUG "${TEEM_LIBRARY_RELEASE}") - endif() - endif() - - if(NOT _TEEM_LIB_RELEASE OR NOT EXISTS "${_TEEM_LIB_RELEASE}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs a static lib (teem.lib/libteem.a).") - endif() - - # Create imported STATIC target and propagate include paths and *static* defines - add_library(Teem::teem STATIC IMPORTED GLOBAL) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION_RELEASE "${_TEEM_LIB_RELEASE}" - IMPORTED_LOCATION_DEBUG "${_TEEM_LIB_DEBUG}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - # This disables __declspec(dllimport) in Teem headers for static consumption. - # If you still see __imp_* after a clean rebuild, replace with TEEM_STATIC_DEFINE - # or add module-level defines like AIR_STATIC;NRRD_STATIC, depending on your Teem version. - INTERFACE_COMPILE_DEFINITIONS "TEEM_STATIC" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ---- Link this library ---- -# Convert your legacy link line to target-based + PRIVATE for clarity. -target_link_libraries(Core_Algorithms_Legacy_Fields - PRIVATE - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - Core_Datatypes_Legacy_Bundle - Algorithms_Base - Core_Exceptions_Legacy - Core_Thread - Core_Geometry_Primitives - Core_Basis - Algorithms_Math - ${_teem_target} +TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_Fields + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + Core_Datatypes_Legacy_Bundle + Algorithms_Base + Core_Exceptions_Legacy + Core_Thread + Core_Geometry_Primitives + Core_Basis + Algorithms_Math ) -# ========================================================== -# Zlib is REQUIRED because Teem's gzio uses it (deflate/inflate/crc32). -# Use modern imported target; fall back to variables from the superbuild. -# ========================================================== -set(_zlib_target "") - -# Prefer an existing target if the top-level already created it. -if(TARGET ZLIB::ZLIB) - set(_zlib_target ZLIB::ZLIB) -else() - # Try module find (honors ZLIB_ROOT and CMAKE_PREFIX_PATH). - find_package(ZLIB QUIET) - - if(TARGET ZLIB::ZLIB) - set(_zlib_target ZLIB::ZLIB) - else() - # Fallbacks to superbuild-provided variables. - # Newer CMake may expose ZLIB_LIBRARIES/ZLIB_INCLUDE_DIRS; - # older uses ZLIB_LIBRARY/ZLIB_INCLUDE_DIR. - if(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) - add_library(ZLIB::ZLIB UNKNOWN IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" - ) - set(_zlib_target ZLIB::ZLIB) - elseif(ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS) - add_library(ZLIB::ZLIB UNKNOWN IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${ZLIB_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}" - ) - set(_zlib_target ZLIB::ZLIB) - else() - message(FATAL_ERROR - "Zlib not found. SCIRun needs it to link Teem (gzio).\n" - "Provide ZLIB_ROOT or ZLIB_LIBRARY/ZLIB_INCLUDE_DIR from the superbuild.\n" - "ZLIB_LIBRARY='${ZLIB_LIBRARY}' ZLIB_LIBRARIES='${ZLIB_LIBRARIES}'\n" - "ZLIB_INCLUDE_DIR='${ZLIB_INCLUDE_DIR}' ZLIB_INCLUDE_DIRS='${ZLIB_INCLUDE_DIRS}'") - endif() - endif() -endif() - -# Link zlib unconditionally (Teem uses it) -target_link_libraries(Core_Algorithms_Legacy_Fields PRIVATE ${_zlib_target}) - -# Export macro for this DLL, unchanged -if(BUILD_SHARED_LIBS) - target_compile_definitions(Core_Algorithms_Legacy_Fields PRIVATE BUILD_Core_Algorithms_Legacy_Fields) -endif() \ No newline at end of file +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Algorithms_Legacy_Fields) +ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt b/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt index e7e422f925..7cc15cd70f 100644 --- a/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/FiniteElements/CMakeLists.txt @@ -65,6 +65,7 @@ TARGET_LINK_LIBRARIES(Core_Algorithms_Legacy_FiniteElements # Core_Persistent # Core_Basis Core_Datatypes_Legacy_Field +# ${SCI_TEEM_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Legacy/Inverse/CMakeLists.txt b/src/Core/Algorithms/Legacy/Inverse/CMakeLists.txt index b562705869..7293735f88 100644 --- a/src/Core/Algorithms/Legacy/Inverse/CMakeLists.txt +++ b/src/Core/Algorithms/Legacy/Inverse/CMakeLists.txt @@ -56,7 +56,6 @@ TARGET_LINK_LIBRARIES(Algorithms_Legacy_Inverse Core_Basis #field basis Core_Algorithms_Legacy_Fields Algorithms_Base - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Math/CMakeLists.txt b/src/Core/Algorithms/Math/CMakeLists.txt index c12c958250..5c4c93e86d 100644 --- a/src/Core/Algorithms/Math/CMakeLists.txt +++ b/src/Core/Algorithms/Math/CMakeLists.txt @@ -84,13 +84,9 @@ SCIRUN_ADD_LIBRARY(Algorithms_Math TARGET_LINK_LIBRARIES(Algorithms_Math Core_Datatypes - Core_Datatypes_Legacy_Base - Core_Datatypes_Legacy_Field - Core_Math Core_Thread Algorithms_Base Core_Parser - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Algorithms/Visualization/CMakeLists.txt b/src/Core/Algorithms/Visualization/CMakeLists.txt index 9c37997e8b..1236e17462 100644 --- a/src/Core/Algorithms/Visualization/CMakeLists.txt +++ b/src/Core/Algorithms/Visualization/CMakeLists.txt @@ -44,7 +44,6 @@ TARGET_LINK_LIBRARIES(Core_Algorithms_Visualization Core_Datatypes_Legacy_Field Graphics_Glyphs Algorithms_Base - ${SCI_BOOST_LIBRARY} ) IF(WITH_OSPRAY) diff --git a/src/Core/Application/CMakeLists.txt b/src/Core/Application/CMakeLists.txt index 616c39a939..d443c794c5 100644 --- a/src/Core/Application/CMakeLists.txt +++ b/src/Core/Application/CMakeLists.txt @@ -42,38 +42,9 @@ SCIRUN_ADD_LIBRARY(Core_Application ${Core_Application_SRCS} ) -# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h -if (BUILD_WITH_PYTHON) - set(_PY_INCLUDES "") - if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") - endif() - if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") - endif() - if (MSVC AND NOT _PY_INCLUDES) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if (EXISTS "${_py_src}/Include") - list(APPEND _PY_INCLUDES "${_py_src}/Include") - endif() - if (EXISTS "${_py_src}/PC") - list(APPEND _PY_INCLUDES "${_py_src}/PC") - endif() - endif() - if (_PY_INCLUDES) - list(REMOVE_DUPLICATES _PY_INCLUDES) - target_include_directories(Core_Application PRIVATE ${_PY_INCLUDES}) - message(STATUS "[Core/Application] Added Python includes: ${_PY_INCLUDES}") - else() - message(WARNING "[Core/Application] Python includes not found at configure time; Boost.Python compilation may fail.") - endif() -endif() - TARGET_LINK_LIBRARIES(Core_Application - Core_Command Core_CommandLine Engine_Network - Engine_Scheduler Modules_Factory Algorithms_Factory Dataflow_State @@ -81,7 +52,6 @@ TARGET_LINK_LIBRARIES(Core_Application Core_IEPlugin Core_Application_Session Core_Application_Preferences - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Application/Preferences/CMakeLists.txt b/src/Core/Application/Preferences/CMakeLists.txt index eed6832e5c..5b782564eb 100644 --- a/src/Core/Application/Preferences/CMakeLists.txt +++ b/src/Core/Application/Preferences/CMakeLists.txt @@ -43,7 +43,6 @@ SCIRUN_ADD_LIBRARY(Core_Application_Preferences TARGET_LINK_LIBRARIES(Core_Application_Preferences Core_Logging Algorithms_Base - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Application/Session/CMakeLists.txt b/src/Core/Application/Session/CMakeLists.txt index b7991b164a..4d2d04f4c6 100644 --- a/src/Core/Application/Session/CMakeLists.txt +++ b/src/Core/Application/Session/CMakeLists.txt @@ -44,7 +44,6 @@ TARGET_LINK_LIBRARIES(Core_Application_Session Core_Logging Algorithms_Base Core_DatabaseManager - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Basis/CMakeLists.txt b/src/Core/Basis/CMakeLists.txt index a722b29709..0d700a3cff 100644 --- a/src/Core/Basis/CMakeLists.txt +++ b/src/Core/Basis/CMakeLists.txt @@ -95,6 +95,10 @@ SCIRUN_ADD_LIBRARY(Core_Basis ${Core_Basis_SRCS} ) +target_link_libraries(Core_Basis + Boost::headers +) + IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Core_Basis) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Core/Command/CMakeLists.txt b/src/Core/Command/CMakeLists.txt index 9222492ebf..e27f314031 100644 --- a/src/Core/Command/CMakeLists.txt +++ b/src/Core/Command/CMakeLists.txt @@ -50,7 +50,6 @@ TARGET_LINK_LIBRARIES(Core_Command Core_CommandLine Core_Utils Algorithms_Base - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/CommandLine/CMakeLists.txt b/src/Core/CommandLine/CMakeLists.txt index b85afba336..8f4e64acea 100644 --- a/src/Core/CommandLine/CMakeLists.txt +++ b/src/Core/CommandLine/CMakeLists.txt @@ -41,8 +41,8 @@ SCIRUN_ADD_LIBRARY(Core_CommandLine ) TARGET_LINK_LIBRARIES(Core_CommandLine - PRIVATE - ${SCI_BOOST_LIBRARY} + Boost::filesystem + Boost::program_options ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/ConsoleApplication/CMakeLists.txt b/src/Core/ConsoleApplication/CMakeLists.txt index 6bb2145aca..44f46d796d 100644 --- a/src/Core/ConsoleApplication/CMakeLists.txt +++ b/src/Core/ConsoleApplication/CMakeLists.txt @@ -25,185 +25,37 @@ # DEALINGS IN THE SOFTWARE. # -# Optional: make CMake report condition errors clearly (silences the dev warning) -if (POLICY CMP0130) - cmake_policy(SET CMP0130 NEW) -endif() -# ---- Sources ---- -set(Core_ConsoleApplication_SRCS +SET(Core_ConsoleApplication_SRCS ConsoleApplication.cc ConsoleCommandFactory.cc ConsoleCommands.cc ) -set(Core_ConsoleApplication_HEADERS +SET(Core_ConsoleApplication_HEADERS ConsoleApplication.h ConsoleCommandFactory.h ConsoleCommands.h share.h ) -# ---- Target ---- SCIRUN_ADD_LIBRARY(Core_ConsoleApplication ${Core_ConsoleApplication_HEADERS} ${Core_ConsoleApplication_SRCS} ) -# Disable Boost header auto-linking on this target (prevents implicit /DEFAULTLIB from headers) -target_compile_definitions(Core_ConsoleApplication PRIVATE - BOOST_ALL_NO_LIB BOOST_PYTHON_NO_LIB -) - -# ---- Build a local Boost list WITHOUT Boost.Python, preserving debug/optimized pairs ---- -set(_src_boost_list "${SCI_BOOST_LIBRARY}") -set(_boost_libs_filtered "") - -# Match any Boost.Python library variant -set(_boost_python_rx ".*[Bb]oost[_-]python.*\\.lib$") - -list(LENGTH _src_boost_list _n) -set(_i 0) -while(_i LESS _n) - list(GET _src_boost_list ${_i} _item) - - if((_item STREQUAL "debug") OR (_item STREQUAL "optimized")) - # Ensure there is a following library for the keyword - math(EXPR _j "${_i} + 1") - if(_j LESS _n) - list(GET _src_boost_list ${_j} _lib) - if(_lib MATCHES "${_boost_python_rx}") - # Skip the pair (keyword + python lib) - math(EXPR _i "${_i} + 2") - continue() - else() - # Keep both keyword and library - list(APPEND _boost_libs_filtered "${_item}" "${_lib}") - math(EXPR _i "${_i} + 2") - continue() - endif() - else() - # Dangling keyword (defensive) - math(EXPR _i "${_i} + 1") - continue() - endif() - else() - # Non-keyword item - if(_item MATCHES "${_boost_python_rx}") - # Skip unqualified python lib - math(EXPR _i "${_i} + 1") - continue() - else() - list(APPEND _boost_libs_filtered "${_item}") - math(EXPR _i "${_i} + 1") - continue() - endif() - endif() -endwhile() - -# Optional diagnostics -message(STATUS "[Core/ConsoleApplication] Boost libs after filtering: ${_boost_libs_filtered}") - -# ---- Link base deps + filtered Boost (no Boost.Python) ---- -# Use keyword form consistently to avoid the mixed-signature error -target_link_libraries(Core_ConsoleApplication PRIVATE +TARGET_LINK_LIBRARIES(Core_ConsoleApplication Core_Application Core_Command - ${_boost_libs_filtered} - LodePNG::lodepng ) -# ---- Python includes (unchanged from your version) ---- -if (BUILD_WITH_PYTHON) - set(_PY_INCLUDES "") - if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") - endif() - if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") - endif() - if (MSVC AND NOT _PY_INCLUDES) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if (EXISTS "${_py_src}/Include") - list(APPEND _PY_INCLUDES "${_py_src}/Include") - endif() - if (EXISTS "${_py_src}/PC") - list(APPEND _PY_INCLUDES "${_py_src}/PC") - endif() - endif() - if (_PY_INCLUDES) - list(REMOVE_DUPLICATES _PY_INCLUDES) - target_include_directories(Core_ConsoleApplication PRIVATE ${_PY_INCLUDES}) - message(STATUS "[Core/ConsoleApplication] Added Python includes: ${_PY_INCLUDES}") - else() - message(WARNING "[Core/ConsoleApplication] Python includes not found at configure time; Boost.Python compilation may fail.") - endif() -endif() - -# ---- Link Core_Python if requested (your curated aggregation) ---- -if (BUILD_WITH_PYTHON) - target_link_libraries(Core_ConsoleApplication PRIVATE Core_Python) -endif() - -# ---- Force the correct Python import lib per configuration & ignore wrong defaultlibs ---- -if (MSVC AND BUILD_WITH_PYTHON) - # Neutralize wrong defaultlibs embedded by dependent .libs (e.g., Boost.Python) - target_link_options(Core_ConsoleApplication PRIVATE - $<$:/NODEFAULTLIB:python313.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - ) - - # Prefer your imported Python target (from superbuild helper) - if (TARGET SCIRunPython::Python) - target_link_libraries(Core_ConsoleApplication PRIVATE - $<$:SCIRunPython::Python> - $<$>:SCIRunPython::Python> - ) - elseif (TARGET Python::Python) - target_link_libraries(Core_ConsoleApplication PRIVATE - $<$:Python::Python> - $<$>:Python::Python> - ) - else() - # Fallback to explicit path probing for python313[_d].lib within superbuild - set(_PY_DBG "") - set(_PY_REL "") - foreach(dir - "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/libs" - "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/lib" - "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64" - ) - if (EXISTS "${dir}/python313_d.lib" AND NOT _PY_DBG) - set(_PY_DBG "${dir}/python313_d.lib") - endif() - if (EXISTS "${dir}/python313.lib" AND NOT _PY_REL) - set(_PY_REL "${dir}/python313.lib") - endif() - endforeach() - - if (_PY_DBG) - target_link_libraries(Core_ConsoleApplication PRIVATE - $<$:${_PY_DBG}> - ) - message(STATUS "[Core/ConsoleApplication] Using ${_PY_DBG} for Debug") - else() - message(WARNING "[Core/ConsoleApplication] Could not locate python313_d.lib; Debug link may still fail.") - endif() +IF(BUILD_WITH_PYTHON) +TARGET_LINK_LIBRARIES(Core_ConsoleApplication + Core_Python) +ENDIF() - if (_PY_REL) - target_link_libraries(Core_ConsoleApplication PRIVATE - $<$>:${_PY_REL}> - ) - message(STATUS "[Core/ConsoleApplication] Using ${_PY_REL} for non-Debug") - else() - message(WARNING "[Core/ConsoleApplication] Could not locate python313.lib; non-Debug link may fail.") - endif() - endif() -endif() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_ConsoleApplication) +ENDIF(BUILD_SHARED_LIBS) -# ---- Shared libs define ---- -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Core_ConsoleApplication) -endif() \ No newline at end of file +#SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Core/DatabaseManager/CMakeLists.txt b/src/Core/DatabaseManager/CMakeLists.txt index 7f35048984..f37de690b5 100644 --- a/src/Core/DatabaseManager/CMakeLists.txt +++ b/src/Core/DatabaseManager/CMakeLists.txt @@ -25,12 +25,12 @@ # DEALINGS IN THE SOFTWARE. # -# --- Sources --- -set(Core_DatabaseManager_SRCS + +SET(Core_DatabaseManager_SRCS DatabaseManager.cc ) -set(Core_DatabaseManager_HEADERS +SET(Core_DatabaseManager_HEADERS DatabaseManager.h share.h ) @@ -40,91 +40,14 @@ SCIRUN_ADD_LIBRARY(Core_DatabaseManager ${Core_DatabaseManager_SRCS} ) -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Core_DatabaseManager) -endif() - -# ========================= -# SQLite3 discovery -# ========================= -# 1) Try config package -find_package(SQLite3 CONFIG QUIET) -if(TARGET SQLite::SQLite3) - set(_sqlite_target SQLite::SQLite3) -else() - # 2) If superbuild passed an exact library file, use it - if(SQLite3_LIBRARY AND EXISTS "${SQLite3_LIBRARY}") - add_library(SQLite::SQLite3 UNKNOWN IMPORTED) - set_target_properties(SQLite::SQLite3 PROPERTIES - IMPORTED_LOCATION "${SQLite3_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}" - ) - set(_sqlite_target SQLite::SQLite3) - else() - # 3) Build from hints: include dir and lib dir - if(NOT SQLite3_INCLUDE_DIR) - message(FATAL_ERROR "SQLite3_INCLUDE_DIR not set; superbuild should pass it (path to folder with sqlite3.h).") - endif() - - # Try to locate the library: - # 3a) If SQLite_LIB_DIR is provided, compute the canonical name(s) - set(_sqlite_lib "") - if(SQLite_LIB_DIR) - if(WIN32) - foreach(_cand sqlite3.lib libsqlite3.lib) - if(EXISTS "${SQLite_LIB_DIR}/${_cand}") - set(_sqlite_lib "${SQLite_LIB_DIR}/${_cand}") - break() - endif() - endforeach() - elseif(APPLE) - if(EXISTS "${SQLite_LIB_DIR}/libsqlite3.dylib") - set(_sqlite_lib "${SQLite_LIB_DIR}/libsqlite3.dylib") - endif() - else() - if(EXISTS "${SQLite_LIB_DIR}/libsqlite3.so") - set(_sqlite_lib "${SQLite_LIB_DIR}/libsqlite3.so") - endif() - endif() - endif() - - # 3b) If still not found, fall back to find_library with hints - if(NOT _sqlite_lib) - find_library(SQLite3_LIBRARY - NAMES sqlite3 libsqlite3 - HINTS "${SQLite_LIB_DIR}" - "${CMAKE_PREFIX_PATH}" - "${CMAKE_PREFIX_PATH}/lib" - "${CMAKE_PREFIX_PATH}/lib64" - ) - if(SQLite3_LIBRARY) - set(_sqlite_lib "${SQLite3_LIBRARY}") - endif() - endif() - - if(NOT _sqlite_lib OR NOT EXISTS "${_sqlite_lib}") - message(FATAL_ERROR - "SQLite3 library not found.\n" - " SQLite3_INCLUDE_DIR='${SQLite3_INCLUDE_DIR}'\n" - " SQLite_LIB_DIR='${SQLite_LIB_DIR}'\n" - " CMAKE_PREFIX_PATH='${CMAKE_PREFIX_PATH}'\n" - "Ensure the SQLite external installs a library (sqlite3.lib/.so/.dylib).") - endif() - - add_library(SQLite::SQLite3 UNKNOWN IMPORTED) - set_target_properties(SQLite::SQLite3 PROPERTIES - IMPORTED_LOCATION "${_sqlite_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}" - ) - set(_sqlite_target SQLite::SQLite3) - endif() -endif() - -target_link_libraries(Core_DatabaseManager - PRIVATE - ${_sqlite_target} - ${SCI_BOOST_LIBRARY} +TARGET_LINK_LIBRARIES(Core_DatabaseManager + ${SCI_SQLITE_LIBRARY} + Boost::atomic + Boost::filesystem ) -# Tests -SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_DatabaseManager) +ENDIF(BUILD_SHARED_LIBS) + +SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Core/Datatypes/CMakeLists.txt b/src/Core/Datatypes/CMakeLists.txt index 5fdadc25d0..c11b7a8023 100644 --- a/src/Core/Datatypes/CMakeLists.txt +++ b/src/Core/Datatypes/CMakeLists.txt @@ -26,12 +26,7 @@ # -# ====================================== -# Core/Datatypes - modern CMake (target-based) -# ====================================== - -# ---- Sources & headers ---- -set(Core_Datatypes_SRCS +SET(Core_Datatypes_SRCS BlockMatrix.cc Color.cc ColorMap.cc @@ -49,7 +44,7 @@ set(Core_Datatypes_SRCS Feedback.cc ) -set(Core_Datatypes_HEADERS +SET(Core_Datatypes_HEADERS BlockMatrix.h Color.h ColorMap.h @@ -79,62 +74,23 @@ set(Core_Datatypes_HEADERS SparseRowMatrixFromMap.h String.h Feedback.h -) + ) -# ---- Library target ---- SCIRUN_ADD_LIBRARY(Core_Datatypes ${Core_Datatypes_HEADERS} ${Core_Datatypes_SRCS} ) -# Shared lib export define (kept behavior) -if(BUILD_SHARED_LIBS) - target_compile_definitions(Core_Datatypes PRIVATE BUILD_Core_Datatypes) -endif() - -# ---- Dependencies (existing) ---- -target_link_libraries(Core_Datatypes - PRIVATE - Core_Persistent - Core_Datatypes_Legacy_Base - Core_Geometry_Primitives +TARGET_LINK_LIBRARIES(Core_Datatypes + Core_Persistent + Core_Datatypes_Legacy_Base + Core_Geometry_Primitives ) -# ========================================================== -# Eigen (header-only): consume superbuild-exported include dir -# ========================================================== - -# Prefer superbuild's direct export -set(_eigen_inc "") -if(DEFINED Eigen_INCLUDE_DIR AND EXISTS "${Eigen_INCLUDE_DIR}/Eigen/Dense") - set(_eigen_inc "${Eigen_INCLUDE_DIR}") -elseif(DEFINED SCIRUN_EIGEN_INCLUDE AND EXISTS "${SCIRUN_EIGEN_INCLUDE}/Eigen/Dense") - set(_eigen_inc "${SCIRUN_EIGEN_INCLUDE}") -endif() - -# Final check -if(NOT _eigen_inc) - message(FATAL_ERROR - "Eigen headers not found. Provide one of:\n" - " -DEigen_INCLUDE_DIR=E:/PROJECTS/SCIRun/build/Externals/Install/Eigen_external/include\n" - " -DSCIRUN_EIGEN_INCLUDE=E:/PROJECTS/SCIRun/build/Externals/Install/Eigen_external/include\n" - "Or adjust to match your superbuild output.") -endif() - -# Create a simple header-only target that mirrors Eigen3::Eigen semantics -if(NOT TARGET Eigen3::Eigen) - add_library(Eigen3::Eigen INTERFACE IMPORTED) - set_target_properties(Eigen3::Eigen PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_eigen_inc}" - ) -endif() - -# Attach to this target (and any others that include ) -target_link_libraries(Core_Datatypes PRIVATE Eigen3::Eigen) +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Datatypes) +ENDIF(BUILD_SHARED_LIBS) -# =========================== -# Tests and subdirectories -# =========================== SCIRUN_ADD_TEST_DIR(Tests) -add_subdirectory(Mesh) -add_subdirectory(Legacy) \ No newline at end of file +ADD_SUBDIRECTORY(Mesh) +ADD_SUBDIRECTORY(Legacy) diff --git a/src/Core/Datatypes/Legacy/Field/CMakeLists.txt b/src/Core/Datatypes/Legacy/Field/CMakeLists.txt index c3aaa8fbd0..9a77f38d19 100644 --- a/src/Core/Datatypes/Legacy/Field/CMakeLists.txt +++ b/src/Core/Datatypes/Legacy/Field/CMakeLists.txt @@ -115,7 +115,6 @@ TARGET_LINK_LIBRARIES(Core_Datatypes_Legacy_Field Core_Util_Legacy Core_Datatypes Core_Datatypes_Legacy_Base - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt b/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt index 2e9e7bc2df..00fe16f9dc 100644 --- a/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt +++ b/src/Core/Datatypes/Legacy/Nrrd/CMakeLists.txt @@ -25,16 +25,13 @@ # DEALINGS IN THE SOFTWARE. # -# ================================ -# Core/Datatypes/Legacy/Nrrd -# ================================ -set(Core_Datatypes_Legacy_Nrrd_HEADERS +SET(Core_Datatypes_Legacy_Nrrd_HEADERS NrrdData.h share.h ) -set(Core_Datatypes_Legacy_Nrrd_SRCS +SET(Core_Datatypes_Legacy_Nrrd_SRCS NrrdData.cc ) @@ -43,99 +40,22 @@ SCIRUN_ADD_LIBRARY(Core_Datatypes_Legacy_Nrrd ${Core_Datatypes_Legacy_Nrrd_HEADERS} ) -# Export macro for this shared lib (kept behavior) -if(BUILD_SHARED_LIBS) - target_compile_definitions(Core_Datatypes_Legacy_Nrrd PRIVATE BUILD_Core_Datatypes_Legacy_Nrrd) -endif() - -# ========================================== -# Teem discovery (same pattern as Geometry) -# ========================================== -# Preferred: Teem config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback: Use superbuild hints Teem_INCLUDE_DIR / Teem_LIB_DIR - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - # Try canonical filenames first by platform - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - # Fallback: search by name with hints - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" # static C lib; helps some generators - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -target_compile_definitions(Core_Datatypes_Legacy_Nrrd PRIVATE TEEM_STATIC) - -# Existing internal deps -target_link_libraries(Core_Datatypes_Legacy_Nrrd - PRIVATE - Core_Exceptions_Legacy - Core_Geometry_Primitives - Core_Math - Core_Thread - Core_Utils - Core_Util_Legacy - Core_Datatypes - Core_Datatypes_Legacy_Base - ${_teem_target} +TARGET_LINK_LIBRARIES(Core_Datatypes_Legacy_Nrrd + Core_Exceptions_Legacy + Core_Geometry_Primitives + Core_Math + #Core_Persistent + Core_Thread + #Core_Thread_Legacy + Core_Utils + Core_Util_Legacy + Core_Datatypes + Core_Datatypes_Legacy_Base + ${SCI_TEEM_LIBRARY} ) -# If zlib was enabled in Teem (common for NRRD), static Teem needs zlib symbols -if(TARGET ZLIB::ZLIB) - target_link_libraries(Core_Datatypes_Legacy_Nrrd PRIVATE ZLIB::ZLIB) -endif() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Datatypes_Legacy_Nrrd) +ENDIF(BUILD_SHARED_LIBS) -#SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file +#SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Core/Datatypes/Mesh/CMakeLists.txt b/src/Core/Datatypes/Mesh/CMakeLists.txt index dc8d459173..f4306e6187 100644 --- a/src/Core/Datatypes/Mesh/CMakeLists.txt +++ b/src/Core/Datatypes/Mesh/CMakeLists.txt @@ -51,7 +51,6 @@ TARGET_LINK_LIBRARIES(Core_Datatypes_Mesh Core_Basis Core_Utils Core_Util_Legacy - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Exceptions/CMakeLists.txt b/src/Core/Exceptions/CMakeLists.txt index 8064f13967..79f2df3fa5 100644 --- a/src/Core/Exceptions/CMakeLists.txt +++ b/src/Core/Exceptions/CMakeLists.txt @@ -61,4 +61,5 @@ SCIRUN_ADD_LIBRARY(Core_Exceptions_Legacy TARGET_LINK_LIBRARIES(Core_Exceptions_Legacy ${DL_LIBRARY} + Boost::headers ) diff --git a/src/Core/GeometryPrimitives/CMakeLists.txt b/src/Core/GeometryPrimitives/CMakeLists.txt index bf1226917b..a627e3790b 100644 --- a/src/Core/GeometryPrimitives/CMakeLists.txt +++ b/src/Core/GeometryPrimitives/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,12 +25,8 @@ # DEALINGS IN THE SOFTWARE. # -# ================================ -# Core/GeometryPrimitives CMake -# ================================ -# --- Sources & headers --- -set(Core_GeometryPrimitives_SRCS +SET(Core_GeometryPrimitives_SRCS BBoxBase.cc BBox.cc OrientedBBox.cc @@ -43,7 +39,7 @@ set(Core_GeometryPrimitives_SRCS Vector.cc ) -set(Core_GeometryPrimitives_HEADERS +SET(Core_GeometryPrimitives_HEADERS BBoxBase.h BBox.h OrientedBBox.h @@ -64,167 +60,16 @@ SCIRUN_ADD_LIBRARY(Core_Geometry_Primitives ${Core_GeometryPrimitives_SRCS} ) -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Core_Geometry_Primitives) -endif() - -# ---------------------------------------------------------- -# Teem is currently built as a *static* library in your superbuild -# (you only have teem.lib, no teem.dll). On Windows, Teem headers -# would otherwise mark APIs as __declspec(dllimport), which produces -# __imp_* references and triggers LNK2019 when linking to a static lib. -# Defining TEEM_STATIC disables dllimport in Teem's TEN_EXPORT macros. ⟶ -# See Microsoft docs on dllexport/dllimport and Teem's export macros. ⟶ -# ---------------------------------------------------------- -# References: -# - Microsoft Learn on dllexport/dllimport (__imp_ import thunks) ⟶ https://learn.microsoft.com/ ... (dllexport, dllimport) -# - Teem Windows export macros recommending TEEM_STATIC for static link ⟶ SourceForge mailing list thread -# (Cited below in the chat text for traceability.) -target_compile_definitions(Core_Geometry_Primitives - PRIVATE TEEM_STATIC) - -# ========================================================== -# Teem discovery (provides tenEigensolve_f used by Tensor.cc) -# ========================================================== - -# Preferred: Teem config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback: Use superbuild hints Teem_INCLUDE_DIR / Teem_LIB_DIR - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - # Try canonical filenames first by platform - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - # Fallback: search by name with hints - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" # static C lib; helps some generators - ) - - set(_teem_target Teem::teem) -endif() - -# ============================================ -# ZLIB (useful when Teem was built with zlib) -# ============================================ -find_package(ZLIB QUIET) - -if(NOT TARGET ZLIB::ZLIB) - if(NOT ZLIB_INCLUDE_DIR AND DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/include") - set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT}/include") - endif() - - set(_zlib_lib "") - if(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib64") - set(_zlib_libdir "${ZLIB_ROOT}/lib64") - elseif(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib") - set(_zlib_libdir "${ZLIB_ROOT}/lib") - endif() - - if(_zlib_libdir) - if(WIN32) - if(EXISTS "${_zlib_libdir}/zlib.lib") - set(_zlib_lib "${_zlib_libdir}/zlib.lib") - elseif(EXISTS "${_zlib_libdir}/zlibstatic.lib") - set(_zlib_lib "${_zlib_libdir}/zlibstatic.lib") - endif() - elseif(APPLE) - if(EXISTS "${_zlib_libdir}/libz.dylib") - set(_zlib_lib "${_zlib_libdir}/libz.dylib") - elseif(EXISTS "${_zlib_libdir}/libz.a") - set(_zlib_lib "${_zlib_libdir}/libz.a") - endif() - else() - if(EXISTS "${_zlib_libdir}/libz.so") - set(_zlib_lib "${_zlib_libdir}/libz.so") - elseif(EXISTS "${_zlib_libdir}/libz.a") - set(_zlib_lib "${_zlib_libdir}/libz.a") - endif() - endif() - endif() - - if(NOT _zlib_lib) - find_library(ZLIB_LIBRARY - NAMES z zlib zlibstatic - HINTS "${_zlib_libdir}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(ZLIB_LIBRARY) - set(_zlib_lib "${ZLIB_LIBRARY}") - endif() - endif() - - if(_zlib_lib AND ZLIB_INCLUDE_DIR) - add_library(ZLIB::ZLIB UNKNOWN IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${_zlib_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" - ) - endif() -endif() - -# =========================== -# Link libraries for this lib -# =========================== -target_link_libraries(Core_Geometry_Primitives - PRIVATE - Core_Math - Core_Util_Legacy - Core_Persistent - ${_teem_target} +TARGET_LINK_LIBRARIES(Core_Geometry_Primitives + Core_Math + Core_Util_Legacy + Core_Persistent + ${SCI_ZLIB_LIBRARY} + ${SCI_TEEM_LIBRARY} ) -# If ZLIB::ZLIB exists, add it (helpful when Teem static needs zlib symbols) -if(TARGET ZLIB::ZLIB) - target_link_libraries(Core_Geometry_Primitives PRIVATE ZLIB::ZLIB) -endif() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Geometry_Primitives) +ENDIF(BUILD_SHARED_LIBS) -# =========================== -# Tests -# =========================== -SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file +SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Core/ImportExport/GenericIEPlugin.h b/src/Core/ImportExport/GenericIEPlugin.h index 9d397e491a..ff4cf31505 100644 --- a/src/Core/ImportExport/GenericIEPlugin.h +++ b/src/Core/ImportExport/GenericIEPlugin.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/src/Core/Logging/CMakeLists.txt b/src/Core/Logging/CMakeLists.txt index 089cb35b18..bcfff312af 100644 --- a/src/Core/Logging/CMakeLists.txt +++ b/src/Core/Logging/CMakeLists.txt @@ -51,6 +51,7 @@ SCIRUN_ADD_LIBRARY(Core_Logging TARGET_LINK_LIBRARIES(Core_Logging Core_Utils + Boost::filesystem ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Logging/LoggerFwd.h b/src/Core/Logging/LoggerFwd.h index 45b9d21f4c..98e75aa5e7 100644 --- a/src/Core/Logging/LoggerFwd.h +++ b/src/Core/Logging/LoggerFwd.h @@ -50,7 +50,7 @@ namespace SCIRun } } -#ifdef _WIN32 +#ifdef WIN32 #define LOG_FUNC __FUNCSIG__ #else #define LOG_FUNC __PRETTY_FUNCTION__ diff --git a/src/Core/Matlab/CMakeLists.txt b/src/Core/Matlab/CMakeLists.txt index 278016aa05..0bfbf74772 100644 --- a/src/Core/Matlab/CMakeLists.txt +++ b/src/Core/Matlab/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,9 +25,10 @@ # DEALINGS IN THE SOFTWARE. # + # CMakeLists.txt for Core/Matlab -set(Core_Matlab_SRCS +SET(Core_Matlab_SRCS fieldtomatlab.cc matfile.cc matfiledata.cc @@ -37,7 +38,7 @@ set(Core_Matlab_SRCS matlabtofield.cc ) -set(Core_Matlab_HEADERS +SET(Core_Matlab_HEADERS fieldtomatlab.h matfile.h matfilebase.h @@ -51,154 +52,26 @@ set(Core_Matlab_HEADERS share.h ) -SCIRUN_ADD_LIBRARY(Core_Matlab - ${Core_Matlab_SRCS} - ${Core_Matlab_HEADERS} +SCIRUN_ADD_LIBRARY(Core_Matlab ${Core_Matlab_SRCS} ${Core_Matlab_HEADERS}) + +TARGET_LINK_LIBRARIES(Core_Matlab + Core_Datatypes + Core_Datatypes_Legacy_Field + Core_Datatypes_Legacy_Nrrd + #Core_Exceptions + #Core_Thread + Core_Geometry_Primitives + #Core_Util + Core_Math + Core_Logging + ${SCI_ZLIB_LIBRARY} + ${SCI_TEEM_LIBRARY} ) -if(BUILD_SHARED_LIBS) - target_compile_definitions(Core_Matlab PRIVATE BUILD_Core_Matlab) -endif() - -# ============================================ -# ZLIB (useful when Teem was built with zlib) -# -- Reused verbatim from your working modules -# ============================================ -find_package(ZLIB QUIET) - -if(NOT TARGET ZLIB::ZLIB) - if(NOT ZLIB_INCLUDE_DIR AND DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/include") - set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT}/include") - endif() - - set(_zlib_lib "") - if(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib64") - set(_zlib_libdir "${ZLIB_ROOT}/lib64") - elseif(DEFINED ZLIB_ROOT AND EXISTS "${ZLIB_ROOT}/lib") - set(_zlib_libdir "${ZLIB_ROOT}/lib") - endif() - - if(_zlib_libdir) - if(WIN32) - if(EXISTS "${_zlib_libdir}/zlib.lib") - set(_zlib_lib "${_zlib_libdir}/zlib.lib") - elseif(EXISTS "${_zlib_libdir}/zlibstatic.lib") - set(_zlib_lib "${_zlib_libdir}/zlibstatic.lib") - endif() - elseif(APPLE) - if(EXISTS "${_zlib_libdir}/libz.dylib") - set(_zlib_lib "${_zlib_libdir}/libz.dylib") - elseif(EXISTS "${_zlib_libdir}/libz.a") - set(_zlib_lib "${_zlib_libdir}/libz.a") - endif() - else() - if(EXISTS "${_zlib_libdir}/libz.so") - set(_zlib_lib "${_zlib_libdir}/libz.so") - elseif(EXISTS "${_zlib_libdir}/libz.a") - set(_zlib_lib "${_zlib_libdir}/libz.a") - endif() - endif() - endif() - - if(NOT _zlib_lib) - find_library(ZLIB_LIBRARY - NAMES z zlib zlibstatic - HINTS "${_zlib_libdir}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(ZLIB_LIBRARY) - set(_zlib_lib "${ZLIB_LIBRARY}") - endif() - endif() - - if(_zlib_lib AND ZLIB_INCLUDE_DIR) - add_library(ZLIB::ZLIB UNKNOWN IMPORTED) - set_target_properties(ZLIB::ZLIB PROPERTIES - IMPORTED_LOCATION "${_zlib_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}" - ) - endif() -endif() - -# ========================================================== -# Teem: (match the pattern you used in other fixed modules) -# ========================================================== -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - set(_teem_target Teem::teem) -endif() - -# Teem is static in your build → prevent dllimport (__imp_*) -target_compile_definitions(Core_Matlab PRIVATE TEEM_STATIC) - -# ----------------------------- -# Link libraries for this module -# ----------------------------- -target_link_libraries(Core_Matlab - PRIVATE - Core_Datatypes - Core_Datatypes_Legacy_Field - Core_Datatypes_Legacy_Nrrd - Core_Geometry_Primitives - Core_Math - Core_Logging - ${_teem_target} -) +IF(MATLAB_STRING_OUTPUT_SIGNED_TYPE_FIX_FOR_SCIPY) + ADD_DEFINITIONS(-DMATLAB_STRING_OUTPUT_SIGNED_TYPE_FIX_FOR_SCIPY) +ENDIF() -# Zlib: prefer imported target; otherwise keep legacy variable -if(TARGET ZLIB::ZLIB) - target_link_libraries(Core_Matlab PRIVATE ZLIB::ZLIB) -elseif(DEFINED SCI_ZLIB_LIBRARY) - target_link_libraries(Core_Matlab PRIVATE "${SCI_ZLIB_LIBRARY}") -endif() \ No newline at end of file +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Matlab) +ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Core/Parser/ArrayMathInterpreter.cc b/src/Core/Parser/ArrayMathInterpreter.cc index 8a1f5640d6..f98374244d 100644 --- a/src/Core/Parser/ArrayMathInterpreter.cc +++ b/src/Core/Parser/ArrayMathInterpreter.cc @@ -1569,7 +1569,7 @@ ArrayMathProgram::run_parallel(int proc) void ArrayMathProgramCode::print() const { - std::cout << "function_ = " << static_cast(&function_) << "\n"; + std::cout << "function_ = "<<&function_<<"\n"; for (size_t j=0;j .../Python_external/Include -# PYTHON_PC_INCLUDE_DIR -> .../Python_external/PC -# PYTHON_LIBRARY_RELEASE -> .../PCbuild/amd64/python313.lib -# PYTHON_LIBRARY_DEBUG -> .../PCbuild/amd64/python313_d.lib -# PYTHON_RUNTIME_DIR -> .../PCbuild/amd64 (optional) -# PYTHON_EXECUTABLE -> .../PCbuild/amd64/python.exe (optional) -# ==================================================================================== - -set(_SCIRUN_PY_OK FALSE) -set(_PY_INCLUDE_DIRS "") -set(_PY_EXECUTABLE "") -set(_PY_LIB_DBG "") -set(_PY_LIB_REL "") - -# ---- Path-first: use explicit superbuild variables if provided ---- -# Accept include dir + at least one of debug/release libs. -if(PYTHON_INCLUDE_DIR AND (PYTHON_LIBRARY_DEBUG OR PYTHON_LIBRARY_RELEASE)) - # Build a proper list of checks; skip empties so foreach doesn't see blank items. - set(_py_checks) - if(PYTHON_LIBRARY_DEBUG) - list(APPEND _py_checks "${PYTHON_LIBRARY_DEBUG}") - endif() - if(PYTHON_LIBRARY_RELEASE) - list(APPEND _py_checks "${PYTHON_LIBRARY_RELEASE}") - endif() - list(APPEND _py_checks "${PYTHON_INCLUDE_DIR}") - - foreach(_check IN LISTS _py_checks) - if(_check AND NOT EXISTS "${_check}") - message(FATAL_ERROR "Python superbuild hint does not exist: ${_check}") - endif() - endforeach() - - # Remember which ones we actually have - set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") - set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") - - # Includes: Include (always), PC (optional on Windows for pyconfig.h) - set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") - if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") - endif() - - set(_SCIRUN_PY_OK TRUE) -endif() - -# ---- Fallback: try modern FindPython / FindPython3 (hinted to superbuild root if provided) ---- -if(NOT _SCIRUN_PY_OK) - if(DEFINED PYTHON_ROOT_DIR AND EXISTS "${PYTHON_ROOT_DIR}") - set(_PY_HINTS ROOT_DIR "${PYTHON_ROOT_DIR}") - elseif(DEFINED PYTHON_HOME_DIR AND EXISTS "${PYTHON_HOME_DIR}") - set(_PY_HINTS ROOT_DIR "${PYTHON_HOME_DIR}") - else() - set(_PY_HINTS) - endif() - - find_package(Python QUIET COMPONENTS Interpreter Development ${_PY_HINTS}) - if(Python_Interpreter_FOUND AND Python_Development_FOUND AND TARGET Python::Python) - set(_SCIRUN_PY_OK TRUE) - set(_PY_EXECUTABLE "${Python_EXECUTABLE}") - set(_PY_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") - endif() -endif() - -# ---- Legacy fallback (really old CMake) ---- -if(NOT _SCIRUN_PY_OK) - find_package(PythonInterp REQUIRED) - find_package(PythonLibs REQUIRED) - set(_SCIRUN_PY_OK TRUE) - set(_PY_EXECUTABLE "${PYTHON_EXECUTABLE}") - set(_PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIRS}") - # Legacy variables (PYTHON_LIBRARIES) exist, but we will still build our own imported target below. - if(PYTHON_DEBUG_LIBRARY AND EXISTS "${PYTHON_DEBUG_LIBRARY}") - set(_PY_LIB_DBG "${PYTHON_DEBUG_LIBRARY}") - endif() - if(PYTHON_LIBRARY AND EXISTS "${PYTHON_LIBRARY}") - set(_PY_LIB_REL "${PYTHON_LIBRARY}") - endif() -endif() - -if(NOT _SCIRUN_PY_OK) - message(FATAL_ERROR "Python (Interpreter + Development) not found; cannot build Core_Python.") -endif() - -# ==================================================================================== -# Imported alias target that points directly to the Python import libs on MSVC -# (Avoids any ambiguity with Python::Python in VS generators) -# ==================================================================================== - -# Create or reuse a global imported target for our Python import library -if(NOT TARGET SCIRunPython) - add_library(SCIRunPython STATIC IMPORTED GLOBAL) -endif() - -# Provide include dirs for consumers (Core_Python and friends) -if(_PY_INCLUDE_DIRS) - list(REMOVE_DUPLICATES _PY_INCLUDE_DIRS) - set_target_properties(SCIRunPython PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" +# --- MSVC Debug-only Python ABI enforcement --- +if (MSVC) + target_compile_definitions(Core_Python PRIVATE + $<$:Py_DEBUG> + $<$:Py_TRACE_REFS> ) -endif() -# Configure config-specific locations to the *import libraries* (.lib) on Windows -# For non-MSVC platforms, your existing logic will take over (link to the real .so/.dylib) -if(MSVC) - # Recognize all common configs - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" + # Defensive: prevent accidental linkage to release Python + target_link_options(Core_Python PRIVATE + $<$:/NODEFAULTLIB:python313.lib> ) - - # Assign debug/release import libs if they were found - if(_PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" - ) - endif() - if(_PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" - ) - endif() - - # Map missing variants so the generator never sees NOTFOUND - if(NOT _PY_LIB_DBG AND _PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_REL}" - MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" - ) - endif() - if(NOT _PY_LIB_REL AND _PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_DBG}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_DBG}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_DBG}" - MAP_IMPORTED_CONFIG_RELEASE "Debug" - MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" - MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" - ) - endif() -endif() - -# Helpful diagnostics (ensure we actually set something) -message(STATUS "[Diag/Core_Python] _PY_LIB_DBG='${_PY_LIB_DBG}' _PY_LIB_REL='${_PY_LIB_REL}'") - -# For the alias imported target we created -get_target_property(_py_imp_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) -get_target_property(_py_imp_rel SCIRunPython IMPORTED_LOCATION_RELEASE) -message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_DEBUG='${_py_imp_dbg}'") -message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_RELEASE='${_py_imp_rel}'") - -# ==================================================================================== -# Platform-specific compile definitions (PYTHONPATH, etc.) -# ==================================================================================== - -# Compute python name like python313 for macros/diagnostics -set(_PYTHON_NAME "") -set(_SCIRUN_PY_DIGITS "") # "313" form - -if(NOT _SCIRUN_PY_DIGITS) - foreach(_cand "${_PY_LIB_DBG}" "${_PY_LIB_REL}") - if(_cand) - get_filename_component(_cand_name "${_cand}" NAME) - if(_cand_name MATCHES "python([0-9]+)(_d)?\\.lib$") - set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") - break() - endif() - endif() - endforeach() -endif() -if(NOT _SCIRUN_PY_DIGITS AND DEFINED Python_VERSION_MAJOR AND DEFINED Python_VERSION_MINOR) - string(CONCAT _SCIRUN_PY_DIGITS "${Python_VERSION_MAJOR}" "${Python_VERSION_MINOR}") -endif() -if(_SCIRUN_PY_DIGITS) - set(_PYTHON_NAME "python${_SCIRUN_PY_DIGITS}") endif() -# Try to compute parent of site-packages using Python (optional) -set(_PYTHON_MODULE_SEARCH_PARENT "") -if(PYTHON_EXECUTABLE AND EXISTS "${PYTHON_EXECUTABLE}") - set(_SCIRUN_PY_QUERY - "import sysconfig; p=sysconfig.get_paths(); print((p.get('purelib') or p.get('platlib') or ''))" - ) - execute_process( - COMMAND "${PYTHON_EXECUTABLE}" -c "${_SCIRUN_PY_QUERY}" - OUTPUT_VARIABLE _PY_SITE - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(_PY_SITE) - get_filename_component(_PYTHON_MODULE_SEARCH_PARENT "${_PY_SITE}" DIRECTORY) - file(TO_CMAKE_PATH "${_PYTHON_MODULE_SEARCH_PARENT}" _PYTHON_MODULE_SEARCH_PARENT) - endif() -endif() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Core_Python) +ENDIF(BUILD_SHARED_LIBS) -# Apply includes + macros -target_include_directories(Core_Python PRIVATE ${_PY_INCLUDE_DIRS}) -if(WIN32) - target_compile_definitions(Core_Python PRIVATE - "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" - "PYTHONNAME=L\"${_PYTHON_NAME}\"" - ) -elseif(APPLE) - target_compile_definitions(Core_Python PRIVATE - "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" - "PYTHONLIBDIR=L\"\"" - "PYTHONLIB=L\"\"" - ) -else() - target_compile_definitions(Core_Python PRIVATE - "PYTHONPATH=L\"${_PYTHON_MODULE_SEARCH_PARENT}\"" - ) -endif() +SCIRUN_ADD_TEST_DIR(Tests) -# ==================================================================================== -# Link dependencies (all PRIVATE to avoid leaking third-party includes to dependents) -# ==================================================================================== -target_link_libraries(Core_Python - PRIVATE - SCIRunPython - SCIRunPythonAPI - ${SCI_BOOST_LIBRARY} - Core_Matlab - Core_Datatypes - Core_Datatypes_Legacy_Field +IF(WIN32) + ADD_DEFINITIONS(-DPYTHONPATH=L"${SCI_PYTHON_MODULE_PARENT_PATH}" + -DPYTHONNAME=L"${SCI_PYTHON_NAME}") +ELSEIF(APPLE) + ADD_DEFINITIONS(-DPYTHONPATH=L"${PYTHON_MODULE_SEARCH_PATH}" + -DPYTHONLIBDIR=L"${SCI_PYTHON_LIBRARY_DIR}" + -DPYTHONLIB=L"${SCI_PYTHON_LIBRARY}") +ELSE() + ADD_DEFINITIONS(-DPYTHONPATH=L"${PYTHON_MODULE_SEARCH_PATH}") +ENDIF() + +TARGET_LINK_LIBRARIES(Core_Python + ${SCI_PYTHON_LIBRARIES} + SCIRunPythonAPI + Core_Matlab + Core_Datatypes + Core_Datatypes_Legacy_Field ) -# --- Debug-only: ignore autolinked *release* python import lib (e.g., from Boost.Python) --- -if(MSVC) - if(_SCIRUN_PY_DIGITS) - set(_SCIRUN_PY_RELEASE_NAME "python${_SCIRUN_PY_DIGITS}.lib") - target_link_options(Core_Python PRIVATE - $<$:/NODEFAULTLIB:${_SCIRUN_PY_RELEASE_NAME}> - ) - else() - target_link_options(Core_Python PRIVATE - $<$:/NODEFAULTLIB:python3.lib> - ) - endif() -endif() - -# ==================================================================================== -# Boost.Python handling -# ==================================================================================== -option(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK "Explicitly link Boost.Python on MSVC; otherwise rely on autolink" OFF) -set(_SCIRUN_PY_M "${_SCIRUN_PY_DIGITS}") - -if(MSVC) - if(SCIRUN_EXPLICIT_BOOST_PYTHON_LINK) - target_compile_definitions(Core_Python PRIVATE BOOST_PYTHON_NO_LIB BOOST_PYTHON_STATIC_LIB) - if (NOT DEFINED SCI_BOOST_LIBRARY_DIR OR NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") - message(FATAL_ERROR "SCI_BOOST_LIBRARY_DIR is not set or does not exist. Pass it from the superbuild.") - endif() - file(GLOB _bp_dbg_candidates - "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_M}-vc*-mt-gd-*.lib" - ) - file(GLOB _bp_rel_candidates_all - "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_M}-vc*-mt-*.lib" - ) - set(_bp_rel_candidates "") - foreach(_cand IN LISTS _bp_rel_candidates_all) - if(NOT _cand MATCHES "-gd-") - list(APPEND _bp_rel_candidates "${_cand}") - endif() - endforeach() - if(_bp_dbg_candidates) - list(SORT _bp_dbg_candidates) - list(REVERSE _bp_dbg_candidates) - list(GET _bp_dbg_candidates 0 SCI_BOOST_PYTHON_LIB_DEBUG) - endif() - if(_bp_rel_candidates) - list(SORT _bp_rel_candidates) - list(REVERSE _bp_rel_candidates) - list(GET _bp_rel_candidates 0 SCI_BOOST_PYTHON_LIB_RELEASE) - endif() - if(NOT EXISTS "${SCI_BOOST_PYTHON_LIB_DEBUG}" OR NOT EXISTS "${SCI_BOOST_PYTHON_LIB_RELEASE}") - message(FATAL_ERROR "Boost.Python libs not found under '${SCI_BOOST_LIBRARY_DIR}'.") - endif() - target_link_libraries(Core_Python PRIVATE - debug "${SCI_BOOST_PYTHON_LIB_DEBUG}" - optimized "${SCI_BOOST_PYTHON_LIB_RELEASE}" - ) - else() - if (DEFINED SCI_BOOST_LIBRARY_DIR AND EXISTS "${SCI_BOOST_LIBRARY_DIR}") - target_link_directories(Core_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") - endif() - message(STATUS "[Core/Python] Using MSVC autolink for Boost.Python (ensure lib names match).") - endif() -else() - set(_bp_names "boost_python${_SCIRUN_PY_M}" "boost_python3" "boost_python") - find_library(BOOST_PYTHON_LIB NAMES ${_bp_names} PATHS "${SCI_BOOST_LIBRARY_DIR}" "${SCI_BOOST_PREFIX}/lib" "${SCI_BOOST_PREFIX}/lib64" NO_DEFAULT_PATH) - if(NOT BOOST_PYTHON_LIB) - find_library(BOOST_PYTHON_LIB NAMES ${_bp_names}) - endif() - if(BOOST_PYTHON_LIB) - target_link_libraries(Core_Python PRIVATE "${BOOST_PYTHON_LIB}") - message(STATUS "[Core/Python] Linking Boost.Python: ${BOOST_PYTHON_LIB}") - else() - message(WARNING "[Core/Python] Boost.Python library not found on this platform.") - endif() -endif() - -# Debug-only macro (matches your previous behavior) -set_target_properties(Core_Python PROPERTIES COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON") - -# ---- Helpful diagnostics (actual evaluated properties) ---- -get_target_property(_py_imp_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) -get_target_property(_py_imp_rel SCIRunPython IMPORTED_LOCATION_RELEASE) -get_target_property(_cp_links2 Core_Python LINK_LIBRARIES) - -message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_DEBUG='${_py_imp_dbg}'") -message(STATUS "[Diag/Core_Python] SCIRunPython IMPORTED_LOCATION_RELEASE='${_py_imp_rel}'") -message(STATUS "[Diag/Core_Python] LINK_LIBRARIES=${_cp_links2}") \ No newline at end of file +SET_TARGET_PROPERTIES(Core_Python + PROPERTIES + COMPILE_DEFINITIONS_DEBUG "BOOST_DEBUG_PYTHON" +) diff --git a/src/Core/Thread/CMakeLists.txt b/src/Core/Thread/CMakeLists.txt index 645a4ec206..685747a6ef 100644 --- a/src/Core/Thread/CMakeLists.txt +++ b/src/Core/Thread/CMakeLists.txt @@ -48,7 +48,7 @@ SCIRUN_ADD_LIBRARY(Core_Thread TARGET_LINK_LIBRARIES(Core_Thread Core_Logging - ${SCI_BOOST_LIBRARY} + Boost::thread ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Utils/CMakeLists.txt b/src/Core/Utils/CMakeLists.txt index d7150ba837..518a47793c 100644 --- a/src/Core/Utils/CMakeLists.txt +++ b/src/Core/Utils/CMakeLists.txt @@ -53,7 +53,7 @@ SCIRUN_ADD_LIBRARY(Core_Utils ) TARGET_LINK_LIBRARIES(Core_Utils - ${SCI_BOOST_LIBRARY} + Boost::atomic ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Utils/Legacy/CMakeLists.txt b/src/Core/Utils/Legacy/CMakeLists.txt index f5828d0afc..aa5ce6e68b 100644 --- a/src/Core/Utils/Legacy/CMakeLists.txt +++ b/src/Core/Utils/Legacy/CMakeLists.txt @@ -60,7 +60,6 @@ TARGET_LINK_LIBRARIES(Core_Util_Legacy Core_Exceptions_Legacy Core_Thread Core_Utils - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Core/Utils/Legacy/FileUtils.cc b/src/Core/Utils/Legacy/FileUtils.cc index 314bb914a3..a26d34159e 100644 --- a/src/Core/Utils/Legacy/FileUtils.cc +++ b/src/Core/Utils/Legacy/FileUtils.cc @@ -52,7 +52,6 @@ #include #include -#include #include #include @@ -443,57 +442,24 @@ convertToWindowsPath( std::string & unixPath ) } } - int copyFile(const bfs::path& src, const bfs::path& dest) { int code = -1; try { bsys::error_code ec; - - // Ensure destination directory exists - if (!dest.parent_path().empty()) - { - bfs::create_directories(dest.parent_path(), ec); - ec.clear(); - } - - // If src and dest are the same, nothing to do - if (bfs::exists(src) && bfs::exists(dest)) - { - bsys::error_code eqec; - if (bfs::equivalent(src, dest, eqec)) - { - return 0; - } - } - - // Emulate "overwrite": remove destination if present - if (bfs::exists(dest)) - { - bfs::remove(dest, ec); - ec.clear(); - } - - // Copy without options - bfs::copy_file(src, dest, ec); + bfs::copy_file(src, dest, bfs::copy_options::overwrite_existing, ec); code = ec.value(); - -#if defined(_DEBUG) || !defined(NDEBUG) +#if DEBUG if (code != bsys::errc::success) { std::cerr << "error " << ec.value() << ": " << ec.message() << std::endl; } #endif } - catch (const std::exception& e) - { - std::cerr << "Error copying " << src.string() << " to " << dest.string() - << ": " << e.what() << std::endl; - } catch (...) { - std::cerr << "Error copying " << src.string() << " to " << dest.string() << std::endl; + std::cerr << "Error copying " << src.c_str() << " to " << dest.c_str() << std::endl; } return code; } diff --git a/src/Dataflow/Engine/Controller/CMakeLists.txt b/src/Dataflow/Engine/Controller/CMakeLists.txt index 5aa3b8bb48..fadc96e9ce 100644 --- a/src/Dataflow/Engine/Controller/CMakeLists.txt +++ b/src/Dataflow/Engine/Controller/CMakeLists.txt @@ -26,11 +26,7 @@ # -# ========================= -# Dataflow/Engine/Network -# ========================= - -set(Engine_Network_SRCS +SET(Engine_Network_SRCS DynamicPortManager.cc NetworkEditorController.cc NetworkCommands.cc @@ -41,7 +37,7 @@ set(Engine_Network_SRCS PythonImpl.cc ) -set(Engine_Network_HEADERS +SET(Engine_Network_HEADERS ControllerInterfaces.h DynamicPortManager.h NetworkEditorController.h @@ -59,7 +55,7 @@ SCIRUN_ADD_LIBRARY(Engine_Network ${Engine_Network_SRCS} ) -set(Engine_Network_NonPythonDependentLibs +SET(Engine_Network_NonPythonDependentLibs Dataflow_Network Core_Serialization_Network Core_Command @@ -68,74 +64,28 @@ set(Engine_Network_NonPythonDependentLibs Core_Matlab ) -# -------------------------------------------------------------------- -# Python includes (needed for Boost.Python headers -> pyconfig.h on Win) -# -------------------------------------------------------------------- -if (BUILD_WITH_PYTHON) - set(_PY_INCLUDES "") +IF(BUILD_WITH_PYTHON) - if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") - endif() - if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") - endif() + TARGET_LINK_LIBRARIES(Engine_Network + ${Engine_Network_NonPythonDependentLibs} + SCIRunPythonAPI + Core_Python + ) - # Fallback to PCbuild layout if cache vars aren’t present - if (MSVC AND NOT _PY_INCLUDES) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if (EXISTS "${_py_src}/Include") - list(APPEND _PY_INCLUDES "${_py_src}/Include") - endif() - if (EXISTS "${_py_src}/PC") - list(APPEND _PY_INCLUDES "${_py_src}/PC") - endif() - endif() + INCLUDE_DIRECTORIES( + ${PYTHON_INCLUDE_DIR} + ) - if (_PY_INCLUDES) - list(REMOVE_DUPLICATES _PY_INCLUDES) - target_include_directories(Engine_Network PRIVATE ${_PY_INCLUDES}) - message(STATUS "[Engine/Network] Added Python includes: ${_PY_INCLUDES}") - else() - message(WARNING "[Engine/Network] Python includes not found at configure time; Boost.Python compilation may fail.") - endif() -endif() +ELSE() -# --------------------------------------------------------- -# Link libraries (use targets, not file paths; keep PRIVATE) -# --------------------------------------------------------- -if (BUILD_WITH_PYTHON) - target_link_libraries(Engine_Network - PRIVATE - ${Engine_Network_NonPythonDependentLibs} - # Python bits - Core_Python # SCIRun's Python core (brings Python usage + policies) - SCIRunPythonAPI # link to the target; CMake will use the import .lib, not the .pyd - SCIRunPython # ensure the CPython import libs (python313[_d].lib) are available + TARGET_LINK_LIBRARIES(Engine_Network + ${Engine_Network_NonPythonDependentLibs} ) - target_compile_definitions(Engine_Network PRIVATE BOOST_PYTHON_NO_LIB BOOST_PYTHON_STATIC_LIB) -else() - target_link_libraries(Engine_Network - PRIVATE - ${Engine_Network_NonPythonDependentLibs} - ) -endif() -# ------------------------------------------------------------------------- -# Debug-only: block autolink of release python313.lib (e.g., Boost.Python) -# ------------------------------------------------------------------------- -if (BUILD_WITH_PYTHON) - # If you want to derive digits programmatically, you can, but 313 is fine here. - target_link_options(Engine_Network PRIVATE - $<$:/NODEFAULTLIB:python313.lib> - ) -endif() +ENDIF() -# ----------------------------------- -# DLL build define (preserve behavior) -# ----------------------------------- -if (BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Engine_Network) -endif() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Engine_Network) +ENDIF(BUILD_SHARED_LIBS) -SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file +SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Dataflow/Engine/Python/CMakeLists.txt b/src/Dataflow/Engine/Python/CMakeLists.txt index 993bd0f65f..2120648ca8 100644 --- a/src/Dataflow/Engine/Python/CMakeLists.txt +++ b/src/Dataflow/Engine/Python/CMakeLists.txt @@ -25,247 +25,44 @@ # DEALINGS IN THE SOFTWARE. # -# ========================================== -# Dataflow/Engine/Python CMakeLists.txt -# ========================================== -cmake_minimum_required(VERSION 3.16) - -if(NOT BUILD_WITH_PYTHON) - message(STATUS "[Dataflow/Engine/Python] Skipping SCIRunPythonAPI (BUILD_WITH_PYTHON=OFF)") - return() -endif() - -# --- Sources & headers --- -set(SCIRunPythonAPI_SRCS +SET(SCIRunPythonAPI_SRCS NetworkEditorPythonAPI.cc ) -set(SCIRunPythonAPI_HEADERS +SET(SCIRunPythonAPI_HEADERS NetworkEditorPythonAPI.h NetworkEditorPythonInterface.h SCIRunPythonModule.h share.h ) -# --- Library target --- SCIRUN_ADD_LIBRARY(SCIRunPythonAPI ${SCIRunPythonAPI_HEADERS} ${SCIRunPythonAPI_SRCS} ) -# ==================================================================================== -# Ensure an alias imported target 'SCIRunPython' exists and points to the CPython -# import libraries (Windows/MSVC) or the shared/static python lib on other platforms. -# Prefer the alias from Core/Python; if missing, create a compatible one here. -# ==================================================================================== - -set(_PY_INCLUDE_DIRS "") -set(_PY_LIB_REL "") -set(_PY_LIB_DBG "") - -# Prefer superbuild hints (typical when using PCbuild layout on Windows) -if(PYTHON_LIBRARY_RELEASE) - set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") -endif() -if(PYTHON_LIBRARY_DEBUG) - set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") -endif() - -# Also accept short names (if provided) -if(NOT _PY_LIB_REL AND DEFINED PY_EXT_LIB_DIR) - if(EXISTS "${PY_EXT_LIB_DIR}/python313.lib") - set(_PY_LIB_REL "${PY_EXT_LIB_DIR}/python313.lib") - endif() -endif() -if(NOT _PY_LIB_DBG AND DEFINED PY_EXT_LIB_DIR) - if(EXISTS "${PY_EXT_LIB_DIR}/python313_d.lib") - set(_PY_LIB_DBG "${PY_EXT_LIB_DIR}/python313_d.lib") - endif() -endif() - -# Includes: prefer superbuild variables -if(PYTHON_INCLUDE_DIR) - list(APPEND _PY_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") -endif() -if(PY_INCLUDE_DIR) - list(APPEND _PY_INCLUDE_DIRS "${PY_INCLUDE_DIR}") -endif() -if(PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDE_DIRS "${PYTHON_PC_INCLUDE_DIR}") -endif() - -# If still incomplete, try modern FindPython to harvest includes/libs -if((NOT _PY_INCLUDE_DIRS) OR (NOT _PY_LIB_REL AND NOT _PY_LIB_DBG)) - find_package(Python QUIET COMPONENTS Interpreter Development) - if(Python_Development_FOUND AND TARGET Python::Python) - if(NOT _PY_INCLUDE_DIRS AND Python_INCLUDE_DIRS) - set(_PY_INCLUDE_DIRS "${Python_INCLUDE_DIRS}") - endif() - # Harvest import libs if present (MSVC) - get_target_property(_try_rel Python::Python IMPORTED_IMPLIB_RELEASE) - get_target_property(_try_dbg Python::Python IMPORTED_IMPLIB_DEBUG) - if(NOT _PY_LIB_REL AND _try_rel) - set(_PY_LIB_REL "${_try_rel}") - endif() - if(NOT _PY_LIB_DBG AND _try_dbg) - set(_PY_LIB_DBG "${_try_dbg}") - endif() - # Non-MSVC: fall back to IMPORTED_LOCATION_* (shared/static) - if(NOT MSVC) - if(NOT _PY_LIB_REL) - get_target_property(_try_loc_rel Python::Python IMPORTED_LOCATION_RELEASE) - if(_try_loc_rel) - set(_PY_LIB_REL "${_try_loc_rel}") - endif() - endif() - if(NOT _PY_LIB_DBG) - get_target_property(_try_loc_dbg Python::Python IMPORTED_LOCATION_DEBUG) - if(_try_loc_dbg) - set(_PY_LIB_DBG "${_try_loc_dbg}") - endif() - endif() - endif() - endif() -endif() - -# If Core/Python has already created SCIRunPython, reuse it. -if(NOT TARGET SCIRunPython) - # Create a compatible alias imported target locally - add_library(SCIRunPython STATIC IMPORTED GLOBAL) - - if(_PY_INCLUDE_DIRS) - list(REMOVE_DUPLICATES _PY_INCLUDE_DIRS) - set_target_properties(SCIRunPython PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_PY_INCLUDE_DIRS}" - ) - endif() - - if(MSVC) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" - ) - if(_PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" - ) - endif() - if(_PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" - ) - endif() - # Map missing variants so the generator never sees NOTFOUND - if(NOT _PY_LIB_DBG AND _PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_REL}" - MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" - ) - endif() - if(NOT _PY_LIB_REL AND _PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_DBG}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_DBG}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_DBG}" - MAP_IMPORTED_CONFIG_RELEASE "Debug" - MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" - MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" - ) - endif() - else() - # Non-MSVC: the Python library may be a shared/static real library - if(_PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" - ) - endif() - if(_PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" - ) - endif() - endif() -endif() - -# ==================================================================================== -# Compile definitions -# ==================================================================================== -if(MSVC) - # This target does not use Boost.Python symbols directly; static lib define is harmless. - target_compile_definitions(SCIRunPythonAPI PRIVATE BOOST_PYTHON_STATIC_LIB) -endif() -target_compile_definitions(SCIRunPythonAPI PRIVATE BUILD_WITH_PYTHON) - -# ==================================================================================== -# Link dependencies (Python via SCIRunPython alias; PRIVATE to avoid leaking) -# ==================================================================================== -target_link_libraries(SCIRunPythonAPI - PRIVATE - Core_Thread - Core_Datatypes_Legacy_Base - Core_Persistent - SCIRunPython - ${SCI_BOOST_LIBRARY} +TARGET_LINK_LIBRARIES(SCIRunPythonAPI + Core_Thread + Core_Datatypes_Legacy_Base + Core_Persistent + ${SCI_PYTHON_LIBRARIES} + Boost::python313 ) -# ------------------------------------------------------------------------------------ -# Debug-only insurance: ignore any autolinked *release* python import lib -# (e.g., if a third-party .lib contains /DEFAULTLIB:python313.lib directives). -# ------------------------------------------------------------------------------------ -# Derive python digits (e.g. "313") from the selected import libraries -set(_SCIRUN_PY_DIGITS "") -foreach(_cand "${_PY_LIB_DBG}" "${_PY_LIB_REL}") - if(_cand) - get_filename_component(_cand_name "${_cand}" NAME) - if(_cand_name MATCHES "python([0-9]+)(_d)?\\.lib$") - set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") - break() - endif() - endif() -endforeach() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_SCIRunPythonAPI) -if(MSVC) - if(_SCIRUN_PY_DIGITS) - target_link_options(SCIRunPythonAPI PRIVATE - $<$:/NODEFAULTLIB:python${_SCIRUN_PY_DIGITS}.lib> - ) - else() - target_link_options(SCIRunPythonAPI PRIVATE - $<$:/NODEFAULTLIB:python3.lib> - ) - endif() -endif() +IF(WIN32) + SET_TARGET_PROPERTIES(SCIRunPythonAPI + PROPERTIES + IMPORT_SUFFIX ".pyd" + IMPORT_PREFIX "" + PREFIX "" + SUFFIX ".pyd" + ) +ENDIF() -# ==================================================================================== -# Shared build: Windows .pyd properties (kept) -# ==================================================================================== -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_SCIRunPythonAPI) - if(WIN32) - set_target_properties(SCIRunPythonAPI - PROPERTIES - IMPORT_SUFFIX ".pyd" - IMPORT_PREFIX "" - PREFIX "" - SUFFIX ".pyd" - ) - endif() -endif() +ENDIF(BUILD_SHARED_LIBS) -# ==================================================================================== -# Tests -# ==================================================================================== SCIRUN_ADD_TEST_DIR(Tests) - -# ==================================================================================== -# Diagnostics (show what the alias imported target is actually using) -# ==================================================================================== -get_target_property(_api_py_inc SCIRunPython INTERFACE_INCLUDE_DIRECTORIES) -get_target_property(_api_py_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) -get_target_property(_api_py_rel SCIRunPython IMPORTED_LOCATION_RELEASE) -message(STATUS "[SCIRunPythonAPI] Python include(s) : ${_api_py_inc}") -message(STATUS "[SCIRunPythonAPI] Python importlib : Debug='${_api_py_dbg}' Release='${_api_py_rel}'") \ No newline at end of file diff --git a/src/Dataflow/Engine/Scheduler/Tests/CMakeLists.txt b/src/Dataflow/Engine/Scheduler/Tests/CMakeLists.txt index 758ff33e22..6b66556a9b 100644 --- a/src/Dataflow/Engine/Scheduler/Tests/CMakeLists.txt +++ b/src/Dataflow/Engine/Scheduler/Tests/CMakeLists.txt @@ -56,5 +56,4 @@ TARGET_LINK_LIBRARIES(Engine_Scheduler_Tests gtest_main gtest gmock - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Dataflow/Network/CMakeLists.txt b/src/Dataflow/Network/CMakeLists.txt index 76e51cc67f..902dca1aeb 100644 --- a/src/Dataflow/Network/CMakeLists.txt +++ b/src/Dataflow/Network/CMakeLists.txt @@ -94,5 +94,4 @@ TARGET_LINK_LIBRARIES(Dataflow_Network Core_Logging Algorithms_Base Algorithms_Describe - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Dataflow/Serialization/Network/CMakeLists.txt b/src/Dataflow/Serialization/Network/CMakeLists.txt index dbfc56741d..fcf18aa732 100644 --- a/src/Dataflow/Serialization/Network/CMakeLists.txt +++ b/src/Dataflow/Serialization/Network/CMakeLists.txt @@ -58,7 +58,7 @@ TARGET_LINK_LIBRARIES(Core_Serialization_Network Dataflow_Network Core_Datatypes Dataflow_State - ${SCI_BOOST_LIBRARY} + Boost::serialization ) ADD_SUBDIRECTORY(Importer) diff --git a/src/Dataflow/Serialization/Network/Importer/CMakeLists.txt b/src/Dataflow/Serialization/Network/Importer/CMakeLists.txt index 20c273d49d..28951351de 100644 --- a/src/Dataflow/Serialization/Network/Importer/CMakeLists.txt +++ b/src/Dataflow/Serialization/Network/Importer/CMakeLists.txt @@ -53,5 +53,4 @@ TARGET_LINK_LIBRARIES(Core_Serialization_Network_Importer Dataflow_State Core_XMLUtil ${SCI_LIBXML2_LIBRARY} - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc b/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc index 1fe74479fb..0ff18be829 100644 --- a/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc +++ b/src/Dataflow/Serialization/Network/NetworkDescriptionSerialization.cc @@ -27,11 +27,12 @@ #include + +#include #include #include #include #include -#include using namespace SCIRun::Dataflow::Networks; using namespace SCIRun::Dataflow::State; @@ -60,31 +61,19 @@ namespace return fullBasePath; } - fs::path diffPath(const fs::path& basePath, const fs::path& newPath) { - // Make sure base has a trailing separator (by your rule) - const fs::path fullBasePath = addSlash(basePath); - - fs::path tmpPath = newPath; - fs::path diffpath; // will accumulate the relative pieces without extension - - // Build the relative (stem-only) path from newPath up to fullBasePath + auto fullBasePath = addSlash(basePath); + auto tmpPath = newPath; + fs::path diffpath; while (addSlash(tmpPath) != fullBasePath) { - // Prepend stem (filename without extension) to diffpath diffpath = tmpPath.stem() / diffpath; tmpPath = tmpPath.parent_path(); } - // Take the last component (currently stem-only) and replace its extension - fs::path filename = diffpath.filename(); // e.g. "foo" - filename.replace_extension(newPath.extension()); // becomes "foo.ext" - - // Move diffpath to its parent and append the updated filename - diffpath.remove_filename(); // modern replacement for remove_leaf() - diffpath /= filename; - + auto filename = diffpath.filename().string() + newPath.extension().string(); + diffpath.remove_filename() /= filename; return diffpath; } } diff --git a/src/Dataflow/Serialization/Network/Tools/CMakeLists.txt b/src/Dataflow/Serialization/Network/Tools/CMakeLists.txt index 04514df2ed..4bd3e15eb0 100644 --- a/src/Dataflow/Serialization/Network/Tools/CMakeLists.txt +++ b/src/Dataflow/Serialization/Network/Tools/CMakeLists.txt @@ -38,5 +38,4 @@ ADD_EXECUTABLE(bundle_toolkit TARGET_LINK_LIBRARIES(bundle_toolkit Core_Serialization_Network - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Externals/spire/CMakeLists.txt b/src/Externals/spire/CMakeLists.txt index 0754d0e52d..31f0b31dd9 100644 --- a/src/Externals/spire/CMakeLists.txt +++ b/src/Externals/spire/CMakeLists.txt @@ -218,10 +218,9 @@ ADD_LIBRARY ( ${SCI_SPIRE_LIBRARY} ) target_link_libraries(${SCI_SPIRE_LIBRARY} - LodePNG::lodepng - Tny::tny - ${OPENGL_LIBRARIES} - GLEW::GLEW) + ${SCI_LODEPNG_LIBRARY} + ${SCI_TNY_LIBRARY} + ${OPENGL_LIBRARIES}) IF(WIN32) target_link_libraries(${SCI_SPIRE_LIBRARY} ${SCI_GLEW_LIBRARY}) diff --git a/src/Externals/submodules/googletest b/src/Externals/submodules/googletest index f8d7d77c06..8dfcda943f 160000 --- a/src/Externals/submodules/googletest +++ b/src/Externals/submodules/googletest @@ -1 +1 @@ -Subproject commit f8d7d77c06936315286eb55f8de22cd23c188571 +Subproject commit 8dfcda943f63c174945775b622c3a89a73173d37 diff --git a/src/Graphics/Datatypes/CMakeLists.txt b/src/Graphics/Datatypes/CMakeLists.txt index 9358921dc5..e345c037c3 100644 --- a/src/Graphics/Datatypes/CMakeLists.txt +++ b/src/Graphics/Datatypes/CMakeLists.txt @@ -46,7 +46,6 @@ SCIRUN_ADD_LIBRARY(Graphics_Datatypes TARGET_LINK_LIBRARIES(Graphics_Datatypes Core_Datatypes Core_Geometry_Primitives - Core_Persistent ) IF(BUILD_SHARED_LIBS) diff --git a/src/Graphics/Glyphs/CMakeLists.txt b/src/Graphics/Glyphs/CMakeLists.txt index e2bd64d91b..8406020723 100644 --- a/src/Graphics/Glyphs/CMakeLists.txt +++ b/src/Graphics/Glyphs/CMakeLists.txt @@ -52,12 +52,9 @@ TARGET_LINK_LIBRARIES(Graphics_Glyphs Core_Math Core_Datatypes Core_Geometry_Primitives - Core_Utils Graphics_Datatypes ${OPENGL_LIBRARIES} - GLEW::GLEW ${SCI_SPIRE_LIBRARY} - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Graphics/Widgets/CMakeLists.txt b/src/Graphics/Widgets/CMakeLists.txt index 2269d12051..f278ccab0b 100644 --- a/src/Graphics/Widgets/CMakeLists.txt +++ b/src/Graphics/Widgets/CMakeLists.txt @@ -65,12 +65,9 @@ TARGET_LINK_LIBRARIES(Graphics_Widgets Core_Math Core_Datatypes Core_Geometry_Primitives - Core_Persistent Graphics_Glyphs Graphics_Datatypes ${OPENGL_LIBRARIES} - GLEW::GLEW - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Interface/Application/CMakeLists.txt b/src/Interface/Application/CMakeLists.txt index 2ece153acf..fb215a213f 100644 --- a/src/Interface/Application/CMakeLists.txt +++ b/src/Interface/Application/CMakeLists.txt @@ -25,15 +25,8 @@ # DEALINGS IN THE SOFTWARE. # -# ========================= -# Interface_Application -# ========================= -# Allow building the GUI app without Python even if global BUILD_WITH_PYTHON=ON -# Set to OFF in the superbuild cache to remove all Python linkage from this app. -option(BUILD_INTERFACE_APPLICATION_WITH_PYTHON "Enable Python console in Interface_Application" ON) - -set(Interface_Application_SOURCES +SET(Interface_Application_SOURCES ClosestPortFinder.cc DeveloperConsole.cc GuiApplication.cc @@ -56,6 +49,7 @@ set(Interface_Application_SOURCES NoteEditor.cc Port.cc PreferencesWindow.cc + PythonConsoleWidget.cc Settings.cc ShortcutsInterface.cc TagManagerWindow.cc @@ -71,7 +65,7 @@ set(Interface_Application_SOURCES ModuleOptionsDialogConfiguration.cc ) -set(Interface_Application_HEADERS +SET(Interface_Application_HEADERS ClosestPortFinder.h DeveloperConsole.h GuiApplication.h @@ -93,6 +87,7 @@ set(Interface_Application_HEADERS Port.h PositionProvider.h PreferencesWindow.h + PythonConsoleWidget.h TagManagerWindow.h NetworkEditor.h NetworkEditorControllerGuiProxy.h @@ -106,7 +101,7 @@ set(Interface_Application_HEADERS ModuleOptionsDialogConfiguration.h ) -set(Interface_Application_FORMS +SET(Interface_Application_FORMS DeveloperConsole.ui Module.ui ConnectionStyleWizardPage.ui @@ -115,6 +110,9 @@ set(Interface_Application_FORMS NoteEditor.ui Preferences.ui ProvenanceWindow.ui + PythonWizardPage.ui + PythonWizardCodePage.ui + IntWithPythonPage.ui SCIRunMainWindow.ui ShortcutsInterface.ui SubnetEditor.ui @@ -126,34 +124,17 @@ set(Interface_Application_FORMS StateViewer.ui ) -# ---- Python-specific sources/UI (conditionally included) ---- -set(Interface_Application_PY_SOURCES - PythonConsoleWidget.cc +SET(Interface_Application_RESOURCES +scirun5.qrc ) -set(Interface_Application_PY_HEADERS - PythonConsoleWidget.h -) -set(Interface_Application_PY_FORMS - PythonWizardPage.ui - PythonWizardCodePage.ui - IntWithPythonPage.ui -) - -if (BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) - list(APPEND Interface_Application_SOURCES ${Interface_Application_PY_SOURCES}) - list(APPEND Interface_Application_HEADERS ${Interface_Application_PY_HEADERS}) - list(APPEND Interface_Application_FORMS ${Interface_Application_PY_FORMS}) -endif() - -set(Interface_Application_RESOURCES scirun5.qrc) -qt_wrap_ui(Interface_Application_FORMS_HEADERS "${Interface_Application_FORMS}") -qt_wrap_cpp(Interface_Application_HEADERS_MOC "${Interface_Application_HEADERS}") -qt_add_resources(Interface_Application_RESOURCES_RCC "${Interface_Application_RESOURCES}") +QT_WRAP_UI(Interface_Application_FORMS_HEADERS "${Interface_Application_FORMS}") +QT_WRAP_CPP(Interface_Application_HEADERS_MOC "${Interface_Application_HEADERS}") +QT_ADD_RESOURCES(Interface_Application_RESOURCES_RCC "${Interface_Application_RESOURCES}") -if (BUILD_BUNDLE) - add_definitions(-DBUILD_BUNDLE) -endif() +IF(BUILD_BUNDLE) + ADD_DEFINITIONS(-DBUILD_BUNDLE) +ENDIF() SCIRUN_ADD_LIBRARY(Interface_Application ${Interface_Application_SOURCES} @@ -163,35 +144,7 @@ SCIRUN_ADD_LIBRARY(Interface_Application ${Interface_Application_RESOURCES_RCC} ) -# ---- Add Python include dirs *only if this app builds with Python* ---- -if (BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) - set(_PY_INCLUDES "") - if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") - endif() - if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") - endif() - if (MSVC AND NOT _PY_INCLUDES) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if (EXISTS "${_py_src}/Include") - list(APPEND _PY_INCLUDES "${_py_src}/Include") - endif() - if (EXISTS "${_py_src}/PC") - list(APPEND _PY_INCLUDES "${_py_src}/PC") - endif() - endif() - if (_PY_INCLUDES) - list(REMOVE_DUPLICATES _PY_INCLUDES) - target_include_directories(Interface_Application PRIVATE ${_PY_INCLUDES}) - message(STATUS "[Interface/Application] Added Python includes: ${_PY_INCLUDES}") - else() - message(WARNING "[Interface/Application] Python includes not found at configure time; Boost.Python compilation may fail.") - endif() -endif() - -# ---- Link libraries ---- -set(NonPythonInterface_ApplicationLinkLibraries +SET(NonPythonInterface_ApplicationLinkLibraries Dataflow_Network Core_Serialization_Network_Importer Core_Application @@ -201,102 +154,31 @@ set(NonPythonInterface_ApplicationLinkLibraries Interface_Modules_Base Interface_Modules_Factory Core_Application_Preferences - ${SCI_BOOST_LIBRARY} # Ensure this doesn't include Boost.Python for this app ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS} ) -if (BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) - target_link_libraries(Interface_Application - PUBLIC - ${NonPythonInterface_ApplicationLinkLibraries} - Core_Python - SCIRunPythonAPI - ) -else() - target_link_libraries(Interface_Application - PUBLIC - ${NonPythonInterface_ApplicationLinkLibraries} - ) -endif() - -target_link_libraries(Interface_Application PUBLIC ${QT_NETWORK_LIBRARIES}) +IF(BUILD_WITH_PYTHON) -if (BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Interface_Application) -endif() +TARGET_LINK_LIBRARIES(Interface_Application + ${NonPythonInterface_ApplicationLinkLibraries} + Core_Python + SCIRunPythonAPI +) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +ELSE() -# ------------------------------------------------------------- -# ---- Force the correct Python import lib per configuration -# & ignore wrong defaultlibs (MSVC only), like in Core_ConsoleApplication -# ------------------------------------------------------------- -if (MSVC AND BUILD_WITH_PYTHON AND BUILD_INTERFACE_APPLICATION_WITH_PYTHON) - # Neutralize wrong defaultlibs embedded by dependent .libs (e.g., Boost.Python) - target_link_options(Interface_Application PRIVATE - $<$:/NODEFAULTLIB:python313.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - ) +TARGET_LINK_LIBRARIES(Interface_Application + ${NonPythonInterface_ApplicationLinkLibraries} +) - # Prefer the imported Python target from superbuild helpers - if (TARGET SCIRunPython::Python) - target_link_libraries(Interface_Application PRIVATE - $<$:SCIRunPython::Python> - $<$>:SCIRunPython::Python> - ) - elseif (TARGET Python::Python) - target_link_libraries(Interface_Application PRIVATE - $<$:Python::Python> - $<$>:Python::Python> - ) - else() - # Fallback to explicit path probing for python313[_d].lib within superbuild - set(_PY_DBG "") - set(_PY_REL "") - foreach(dir - "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/libs" - "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/lib" - "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64" - ) - if (EXISTS "${dir}/python313_d.lib" AND NOT _PY_DBG) - set(_PY_DBG "${dir}/python313_d.lib") - endif() - if (EXISTS "${dir}/python313.lib" AND NOT _PY_REL) - set(_PY_REL "${dir}/python313.lib") - endif() - endforeach() +ENDIF() - if (_PY_DBG) - target_link_libraries(Interface_Application PRIVATE - $<$:${_PY_DBG}> - ) - message(STATUS "[Interface/Application] Using ${_PY_DBG} for Debug") - else() - message(WARNING "[Interface/Application] Could not locate python313_d.lib; Debug link may still fail.") - endif() +TARGET_LINK_LIBRARIES(Interface_Application + ${QT_NETWORK_LIBRARIES}) - if (_PY_REL) - target_link_libraries(Interface_Application PRIVATE - $<$>:${_PY_REL}> - ) - message(STATUS "[Interface/Application] Using ${_PY_REL} for non-Debug") - else() - message(WARNING "[Interface/Application] Could not locate python313.lib; non-Debug link may fail.") - endif() - endif() -endif() +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Interface_Application) +ENDIF(BUILD_SHARED_LIBS) -# ------------------------------------------------------------- -# Hard-kill any stray literal python313 libs if they leaked in -# (e.g., via LINK_LIBRARIES property). This is a safety net. -# ------------------------------------------------------------- -if (MSVC) - get_target_property(_ia_link_libs Interface_Application LINK_LIBRARIES) - if (_ia_link_libs) - list(FILTER _ia_link_libs EXCLUDE REGEX ".*python313(_d)?\\.lib$") - set_property(TARGET Interface_Application PROPERTY LINK_LIBRARIES "${_ia_link_libs}") - endif() -endif() \ No newline at end of file +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/Interface/Application/NetworkExecutionProgressBar.cc b/src/Interface/Application/NetworkExecutionProgressBar.cc index 82fb1bdb76..1824c167d5 100644 --- a/src/Interface/Application/NetworkExecutionProgressBar.cc +++ b/src/Interface/Application/NetworkExecutionProgressBar.cc @@ -151,33 +151,22 @@ void SCIRunProgressBar::paintEvent(QPaintEvent*) QPainter p(this); { - // done modules: either green (good) or red (errored) - // qDebug() << "done modules: green" << status_->finished() << "red" << status_->errored(); - const int finished = status_->finished(); - const int errored = status_->errored(); - const int doneTotal = finished + errored; - - // Avoid 0/0 => NaN, and keep geometry as ints in [0, pos]. - int wFinished = 0; - if (pos > 0 && doneTotal > 0) - { - const double frac = static_cast(finished) / static_cast(doneTotal); - // Round to reduce visual bias; clamp to [0, pos]. - wFinished = static_cast(std::round(frac * pos)); - if (wFinished < 0) wFinished = 0; - if (wFinished > pos) wFinished = pos; - } + //done modules: either green (good) or red (errored) + //qDebug() << "done modules: green" << status_->finished() << "red" << status_->errored(); + auto finished = status_->finished(); + auto errored = status_->errored(); + + auto fracFinished = (static_cast(finished) / (finished + errored)) * pos; p.setPen(Qt::green); p.setBrush(QBrush(Qt::green)); - if (wFinished > 0) p.drawRect(0, 0, wFinished, height()); + p.drawRect(0, 0, std::min((int)fracFinished, pos), height()); - const int wErrored = pos - wFinished; - if (errored > 0 && wErrored > 0) + if (errored > 0) { p.setPen(Qt::red); p.setBrush(QBrush(Qt::red)); - p.drawRect(wFinished, 0, wErrored, height()); + p.drawRect(fracFinished, 0, pos - fracFinished, height()); } } @@ -195,55 +184,26 @@ void SCIRunProgressBar::paintEvent(QPaintEvent*) if (totalNotDone > 0) { - if (leftToFill < 0) leftToFill = 0; - auto fracExecuting = (static_cast(executing) / static_cast(totalNotDone)) * leftToFill; + auto fracExecuting = (static_cast(executing) / totalNotDone) * leftToFill; p.setPen(Qt::blue); p.setBrush(QBrush(Qt::blue)); - { - int wExec = static_cast(std::floor(fracExecuting)); - if (wExec < 0) wExec = 0; - if (wExec > leftToFill) wExec = leftToFill; - if (wExec > 0) - p.drawRect(pos, 0, wExec, height()); - // reuse wExec below - auto fracWaiting = (static_cast(waiting) / static_cast(totalNotDone)) * leftToFill; - p.setPen(Qt::lightGray); - p.setBrush(QBrush(Qt::lightGray)); - int wWait = static_cast(std::floor(fracWaiting)); - if (wWait < 0) wWait = 0; - if (wWait > leftToFill - wExec) wWait = leftToFill - wExec; - if (wWait > 0) - p.drawRect(pos + wExec, 0, wWait, height()); - - auto fracUnexecuted = (static_cast(unexecuted) / static_cast(totalNotDone)) * leftToFill; - p.setPen(Qt::darkYellow); - p.setBrush(QBrush(Qt::darkYellow, Qt::BDiagPattern)); - int used = wExec + wWait; - int wUnex = leftToFill - used; - // In case of rounding loss, prefer to fill remaining space rather than leave gaps. - if (wUnex < 0) wUnex = 0; - if (wUnex > 0) - p.drawRect(pos + used, 0, wUnex, height()); - } - - //auto fracWaiting = (static_cast(waiting) / totalNotDone) * leftToFill; - //p.setPen(Qt::lightGray); - //p.setBrush(QBrush(Qt::lightGray)); - //p.drawRect(pos + fracExecuting, 0, fracWaiting, height()); - - //auto fracUnexecuted = (static_cast(unexecuted) / totalNotDone) * leftToFill; - //p.setPen(Qt::darkYellow); - //p.setBrush(QBrush(Qt::darkYellow, Qt::BDiagPattern)); - //p.drawRect(pos + fracExecuting + fracWaiting, 0, fracUnexecuted, height()); + p.drawRect(pos, 0, fracExecuting, height()); + + auto fracWaiting = (static_cast(waiting) / totalNotDone) * leftToFill; + p.setPen(Qt::lightGray); + p.setBrush(QBrush(Qt::lightGray)); + p.drawRect(pos + fracExecuting, 0, fracWaiting, height()); + + auto fracUnexecuted = (static_cast(unexecuted) / totalNotDone) * leftToFill; + p.setPen(Qt::darkYellow); + p.setBrush(QBrush(Qt::darkYellow, Qt::BDiagPattern)); + p.drawRect(pos + fracExecuting + fracWaiting, 0, fracUnexecuted, height()); } else { p.setPen(Qt::lightGray); p.setBrush(QBrush(Qt::lightGray)); - int rem = width() - pos; - if (rem < 0) rem = 0; - if (rem > 0) - p.drawRect(pos, 0, rem, height()); + p.drawRect(pos, 0, width(), height()); } } diff --git a/src/Interface/Modules/Base/CMakeLists.txt b/src/Interface/Modules/Base/CMakeLists.txt index 9587c9fef7..5ed41e5a10 100644 --- a/src/Interface/Modules/Base/CMakeLists.txt +++ b/src/Interface/Modules/Base/CMakeLists.txt @@ -105,7 +105,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Base Core_Datatypes Dataflow_State Core_Application_Preferences - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp index ed52de8277..85304b2bae 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp @@ -834,15 +834,3 @@ void ctkBasePopupWidget::setEffectGeometry(QRect newGeometry) d->PopupPixmapWidget->setGeometry(newGeometry); d->PopupPixmapWidget->repaint(); } - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -void ctkBasePopupWidget::enterEvent(QEnterEvent* event) -{ - QFrame::enterEvent(event); -} -#else -void ctkBasePopupWidget::enterEvent(QEvent* event) -{ - QFrame::enterEvent(event); -} -#endif diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h index f7b7d7c398..c8ea58d300 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h @@ -29,10 +29,6 @@ // CTK includes #include -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - #include // Needed for QEnterEvent in Qt6 -#endif - class ctkBasePopupWidgetPrivate; /// \ingroup Widgets @@ -199,12 +195,6 @@ public Q_SLOTS: virtual bool event(QEvent* event); virtual void paintEvent(QPaintEvent*); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - void enterEvent(QEnterEvent* event) override; -#else - void enterEvent(QEvent* event) override; -#endif - protected Q_SLOTS: virtual void onEffectFinished(); void setEffectAlpha(double alpha); diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp index f373d18293..75d75610ae 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.cpp @@ -428,23 +428,13 @@ void ctkPopupWidget::leaveEvent(QEvent* event) } // -------------------------------------------------------------------------- -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -void ctkPopupWidget::enterEvent(QEnterEvent* event) +void ctkPopupWidget::enterEvent(Q_ENTER_EVENT_CLASS* event) { Q_D(ctkPopupWidget); //qDebug() << __FUNCTION__ << __LINE__ << layout()->itemAt(0)->widget(); QTimer::singleShot(d->ShowDelay, this, &ctkPopupWidget::updatePopup); this->Superclass::enterEvent(event); } -#else -void ctkPopupWidget::enterEvent(QEvent* event) -{ - Q_D(ctkPopupWidget); - //qDebug() << __FUNCTION__ << __LINE__ << layout()->itemAt(0)->widget(); - QTimer::singleShot(d->ShowDelay, this, &ctkPopupWidget::updatePopup); - this->Superclass::enterEvent(event); -} -#endif // -------------------------------------------------------------------------- bool ctkPopupWidget::eventFilter(QObject* obj, QEvent* event) diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h index 56fda9f808..b9b1263de7 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkPopupWidget.h @@ -25,10 +25,6 @@ #include "ctkBasePopupWidget.h" #include -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - #include // Ensure this is included for Qt6 -#endif - class ctkPopupWidgetPrivate; /// \ingroup Widgets @@ -118,12 +114,7 @@ public Q_SLOTS: protected: void leaveEvent(QEvent* event) override; - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - void enterEvent(QEnterEvent* event) override; -#else - void enterEvent(QEvent* event) override; -#endif + void enterEvent(Q_ENTER_EVENT_CLASS* event) override; bool eventFilter(QObject* obj, QEvent* event) override; /// Widget the popup is attached to. It opens right under \a baseWidget diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc index 47010b08a1..ab7864c147 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.cc @@ -28,9 +28,6 @@ #include #include -#include -#include -#include using namespace SCIRun::Gui; using namespace SCIRun::Core::Algorithms::Python; @@ -46,7 +43,7 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) updateLineNumberAreaWidth(0); highlightCurrentLine(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#ifndef SCIRUN_QT6_ENABLED highlighter_ = new CodeEditorHighlighter(document()); #endif @@ -226,110 +223,73 @@ CodeEditorHighlighter::CodeEditorHighlighter(QTextDocument *parent) << "\\bTrue\\b" << "\\bFalse\\b" << "\\bNone\\b"; for (const auto& pattern : keywordPatterns) { - rule.pattern = QRegularExpression(pattern); + rule.pattern = QRegExp(pattern); rule.format = keywordFormat; highlightingRules.append(rule); } classFormat.setFontWeight(QFont::Bold); classFormat.setForeground(Qt::darkMagenta); - rule.pattern = QRegularExpression("\\bQ[A-Za-z]+\\b"); + rule.pattern = QRegExp("\\bQ[A-Za-z]+\\b"); rule.format = classFormat; highlightingRules.append(rule); quotationFormat.setForeground(Qt::darkGreen); - rule.pattern = QRegularExpression("\".*\""); + rule.pattern = QRegExp("\".*\""); rule.format = quotationFormat; highlightingRules.append(rule); functionFormat.setFontItalic(true); functionFormat.setForeground(Qt::cyan); - rule.pattern = QRegularExpression("\\b[A-Za-z0-9_]+(?=\\()"); + rule.pattern = QRegExp("\\b[A-Za-z0-9_]+(?=\\()"); rule.format = functionFormat; highlightingRules.append(rule); singleLineCommentFormat.setForeground(Qt::yellow); - rule.pattern = QRegularExpression("#[^\n]*"); + rule.pattern = QRegExp("#[^\n]*"); rule.format = singleLineCommentFormat; highlightingRules.append(rule); multiLineCommentFormat.setForeground(QColor(255,105,180)); - commentStartExpression = QRegularExpression(matlabDelimiter); - commentEndExpression = QRegularExpression(matlabDelimiter); + commentStartExpression = QRegExp(matlabDelimiter); + commentEndExpression = QRegExp(matlabDelimiter); } void CodeEditorHighlighter::highlightBlock(const QString &text) { - // Keep whatever you do here highlightBlockParens(text); - - // --- 1) Per-rule highlighting (QRegularExpression replaces QRegExp) --- for (const auto& rule : highlightingRules) { - // rule.pattern is already a QRegularExpression - QRegularExpressionMatchIterator it = rule.pattern.globalMatch(text); - while (it.hasNext()) + QRegExp expression(rule.pattern); + int index = expression.indexIn(text); + while (index >= 0) { - const QRegularExpressionMatch m = it.next(); - if (!m.hasMatch()) continue; - - const int index = m.capturedStart(); - const int length = m.capturedLength(); - if (index >= 0 && length > 0) - setFormat(index, length, rule.format); + int length = expression.matchedLength(); + setFormat(index, length, rule.format); + index = expression.indexIn(text, index + length); } } - // --- 2) Multi-line comments with block states --- setCurrentBlockState(0); - - // commentStartExpression/commentEndExpression must be QRegularExpression - // e.g., commentStartExpression = QRegularExpression("/\\*"); - // commentEndExpression = QRegularExpression("\\*/"); - int startIndex = 0; if (previousBlockState() != 1) - { - // First occurrence of start delimiter in this block - QRegularExpressionMatch startMatch = commentStartExpression.match(text); - startIndex = startMatch.hasMatch() ? startMatch.capturedStart() : -1; - } - else - { - // We are *inside* a multi-line comment from the previous block - startIndex = 0; - } + startIndex = commentStartExpression.indexIn(text); while (startIndex >= 0) { - // Search for the end delimiter *after* startIndex - QRegularExpressionMatch endMatch = - commentEndExpression.match(text, startIndex); - - int commentLength = 0; - if (!endMatch.hasMatch()) + int endIndex = commentEndExpression.indexIn(text, startIndex); + int commentLength; + if (endIndex == -1) { - // Not closed in this block: color till end and keep state "inside comment" setCurrentBlockState(1); commentLength = text.length() - startIndex; - setFormat(startIndex, commentLength, multiLineCommentFormat); - break; // no more to find in this block } else { - // Found the end; include the end delimiter - const int endIndex = endMatch.capturedStart(); - const int endLength = endMatch.capturedLength(); // replaces matchedLength() - commentLength = (endIndex - startIndex) + endLength; - - setFormat(startIndex, commentLength, multiLineCommentFormat); - - // Look for next start after this comment - const int nextSearchPos = startIndex + commentLength; - QRegularExpressionMatch nextStart = - commentStartExpression.match(text, nextSearchPos); - startIndex = nextStart.hasMatch() ? nextStart.capturedStart() : -1; + commentLength = endIndex - startIndex + commentEndExpression.matchedLength(); } + setFormat(startIndex, commentLength, multiLineCommentFormat); + startIndex = commentStartExpression.indexIn(text, startIndex + commentLength); } } diff --git a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h index 44d57d001c..f9129c12e8 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h +++ b/src/Interface/Modules/Base/CustomWidgets/CodeEditorWidgets.h @@ -31,7 +31,6 @@ #include #include -#include namespace SCIRun { namespace Gui { @@ -64,9 +63,7 @@ private Q_SLOTS: private: QWidget* lineNumberArea_; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) class CodeEditorHighlighter* highlighter_ {nullptr}; -#endif void createParenthesisSelection(int pos, const QColor& color); bool matchLeftParenthesis(const MatchingPair& type, QTextBlock currentBlock, int index, int numRightParentheses); bool matchRightParenthesis(const MatchingPair& type, QTextBlock currentBlock, int index, int numLeftParentheses); @@ -95,7 +92,7 @@ class LineNumberArea : public QWidget CodeEditor *codeEditor; }; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#ifndef SCIRUN_QT6_ENABLED class CodeEditorHighlighter : public QSyntaxHighlighter { Q_OBJECT @@ -109,13 +106,13 @@ class CodeEditorHighlighter : public QSyntaxHighlighter private: struct HighlightingRule { - QRegularExpression pattern; + QRegExp pattern; QTextCharFormat format; }; QVector highlightingRules; - QRegularExpression commentStartExpression; - QRegularExpression commentEndExpression; + QRegExp commentStartExpression; + QRegExp commentEndExpression; QTextCharFormat keywordFormat; QTextCharFormat classFormat; diff --git a/src/Interface/Modules/BrainStimulator/CMakeLists.txt b/src/Interface/Modules/BrainStimulator/CMakeLists.txt index 1792891ed9..9a52700383 100644 --- a/src/Interface/Modules/BrainStimulator/CMakeLists.txt +++ b/src/Interface/Modules/BrainStimulator/CMakeLists.txt @@ -65,7 +65,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_BrainStimulator Algorithms_Field Modules_BrainStimulator Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Bundle/CMakeLists.txt b/src/Interface/Modules/Bundle/CMakeLists.txt index f71de916a8..765f9d9359 100644 --- a/src/Interface/Modules/Bundle/CMakeLists.txt +++ b/src/Interface/Modules/Bundle/CMakeLists.txt @@ -76,9 +76,7 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Bundle TARGET_LINK_LIBRARIES(Interface_Modules_Bundle Modules_Legacy_Bundle Core_Algorithms_Legacy_Converter - Core_Algorithms_Legacy_Fields Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES}) IF(BUILD_SHARED_LIBS) diff --git a/src/Interface/Modules/DataIO/CMakeLists.txt b/src/Interface/Modules/DataIO/CMakeLists.txt index 7f1859eb24..93c5a9a974 100644 --- a/src/Interface/Modules/DataIO/CMakeLists.txt +++ b/src/Interface/Modules/DataIO/CMakeLists.txt @@ -78,7 +78,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_DataIO Modules_DataIO Modules_Legacy_Teem_DataIO Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES}) IF(BUILD_SHARED_LIBS) diff --git a/src/Interface/Modules/Factory/CMakeLists.txt b/src/Interface/Modules/Factory/CMakeLists.txt index bb4a3b0c8b..b2182c9b1a 100644 --- a/src/Interface/Modules/Factory/CMakeLists.txt +++ b/src/Interface/Modules/Factory/CMakeLists.txt @@ -43,7 +43,6 @@ IF(GENERATE_MODULE_FACTORY_CODE) ADD_EXECUTABLE(MakeDialogFactory Generator/MakeDialogFactory.h Generator/MakeDialogFactory.cc) TARGET_LINK_LIBRARIES(MakeDialogFactory Modules_Factory_Generator - ${SCI_BOOST_LIBRARY} ) SET_PROPERTY(TARGET MakeDialogFactory PROPERTY FOLDER "Interface") @@ -88,7 +87,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Factory Interface_Modules_Teem Interface_Modules_Visualization Interface_Modules_Python - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Fields/CMakeLists.txt b/src/Interface/Modules/Fields/CMakeLists.txt index cef8a4b059..9ea797d55b 100644 --- a/src/Interface/Modules/Fields/CMakeLists.txt +++ b/src/Interface/Modules/Fields/CMakeLists.txt @@ -213,12 +213,10 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Fields TARGET_LINK_LIBRARIES(Interface_Modules_Fields Algorithms_Field - Core_Algorithms_Legacy_Fields Modules_Fields Interface_Modules_Base Modules_Legacy_Fields Modules_Basic - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/FiniteElements/CMakeLists.txt b/src/Interface/Modules/FiniteElements/CMakeLists.txt index 36d276daf7..0d80821d1b 100644 --- a/src/Interface/Modules/FiniteElements/CMakeLists.txt +++ b/src/Interface/Modules/FiniteElements/CMakeLists.txt @@ -59,7 +59,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_FiniteElements Algorithms_Field Interface_Modules_Base Modules_Legacy_FiniteElements - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Forward/CMakeLists.txt b/src/Interface/Modules/Forward/CMakeLists.txt index 9e5bab4c3a..ba5143e77d 100644 --- a/src/Interface/Modules/Forward/CMakeLists.txt +++ b/src/Interface/Modules/Forward/CMakeLists.txt @@ -55,7 +55,6 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Forward TARGET_LINK_LIBRARIES(Interface_Modules_Forward Modules_Legacy_Forward Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Inverse/CMakeLists.txt b/src/Interface/Modules/Inverse/CMakeLists.txt index 6c6455e743..3694d60974 100644 --- a/src/Interface/Modules/Inverse/CMakeLists.txt +++ b/src/Interface/Modules/Inverse/CMakeLists.txt @@ -58,13 +58,15 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Inverse TARGET_LINK_LIBRARIES(Interface_Modules_Inverse Modules_Legacy_Inverse Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} - Qwt::Qwt - #${SCI_QWT_LIBRARY} + ${SCI_QWT_LIBRARY} ) -add_compile_definitions(QWT_STATIC) +if (QT_VERSION_MAJOR EQUAL 6) + TARGET_LINK_LIBRARIES(Interface_Modules_Inverse Qt6::Svg) +elseif(QT_VERSION_MAJOR EQUAL 5) + TARGET_LINK_LIBRARIES(Interface_Modules_Inverse Qt5::Svg) +endif() IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Interface_Modules_Inverse) diff --git a/src/Interface/Modules/Inverse/SolveInverseProblemWithTikhonovDialog.cc b/src/Interface/Modules/Inverse/SolveInverseProblemWithTikhonovDialog.cc index 59494d8933..d1e2950ecf 100644 --- a/src/Interface/Modules/Inverse/SolveInverseProblemWithTikhonovDialog.cc +++ b/src/Interface/Modules/Inverse/SolveInverseProblemWithTikhonovDialog.cc @@ -30,11 +30,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include using namespace SCIRun::Gui; using namespace SCIRun::Dataflow::Networks; diff --git a/src/Interface/Modules/Math/CMakeLists.txt b/src/Interface/Modules/Math/CMakeLists.txt index 43a892022f..1ceef444a6 100644 --- a/src/Interface/Modules/Math/CMakeLists.txt +++ b/src/Interface/Modules/Math/CMakeLists.txt @@ -128,18 +128,33 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Math ${Interface_Modules_Math_SOURCES} ) +#target_compile_definitions(Interface_Modules_Math +# PRIVATE +# QWT_STATIC +# QWT_NO_DLL +#) + TARGET_LINK_LIBRARIES(Interface_Modules_Math Algorithms_Math Modules_Math Modules_Legacy_Math Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} - Qwt::Qwt - #${SCI_QWT_LIBRARY} + ${SCI_QWT_LIBRARY} + ) + +if (QT_VERSION_MAJOR EQUAL 6) + TARGET_LINK_LIBRARIES(Interface_Modules_Math + Qt6::Svg + Qt6::PrintSupport + ) +elseif(QT_VERSION_MAJOR EQUAL 5) + TARGET_LINK_LIBRARIES(Interface_Modules_Math + Qt5::Svg + Qt5::PrintSupport ) +endif() -add_compile_definitions(QWT_STATIC) #ADD_DEFINITIONS(-DQWT_DLL) IF(BUILD_SHARED_LIBS) diff --git a/src/Interface/Modules/Math/PlotDialog.cc b/src/Interface/Modules/Math/PlotDialog.cc index be0c9de005..66e108022d 100644 --- a/src/Interface/Modules/Math/PlotDialog.cc +++ b/src/Interface/Modules/Math/PlotDialog.cc @@ -28,17 +28,17 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef Q_MOC_RUN #include #endif diff --git a/src/Interface/Modules/Math/PlotDialog.h b/src/Interface/Modules/Math/PlotDialog.h index fed93d531b..90c0cbc273 100644 --- a/src/Interface/Modules/Math/PlotDialog.h +++ b/src/Interface/Modules/Math/PlotDialog.h @@ -30,8 +30,8 @@ #define INTERFACE_MODULES_MATH_PLOTDIALOG_H #include -#include -#include +#include +#include #include class QwtPlotMarker; diff --git a/src/Interface/Modules/Matlab/CMakeLists.txt b/src/Interface/Modules/Matlab/CMakeLists.txt index a2c509a131..afa7429a48 100644 --- a/src/Interface/Modules/Matlab/CMakeLists.txt +++ b/src/Interface/Modules/Matlab/CMakeLists.txt @@ -64,7 +64,6 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Matlab TARGET_LINK_LIBRARIES(Interface_Modules_Matlab Modules_Legacy_Matlab_DataIO Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES}) IF(BUILD_SHARED_LIBS) diff --git a/src/Interface/Modules/Python/CMakeLists.txt b/src/Interface/Modules/Python/CMakeLists.txt index cf0810d1d0..8019bf2a48 100644 --- a/src/Interface/Modules/Python/CMakeLists.txt +++ b/src/Interface/Modules/Python/CMakeLists.txt @@ -26,17 +26,7 @@ # -# ========================================== -# Interface/Modules/Python CMakeLists.txt -# ========================================== - -# Only build this UI module when Python support is enabled -if(NOT BUILD_WITH_PYTHON) - message(STATUS "[Interface/Modules/Python] Skipping (BUILD_WITH_PYTHON=OFF)") - return() -endif() - -set(Interface_Modules_Python_FORMS +SET(Interface_Modules_Python_FORMS PythonObjectForwarder.ui InterfaceWithPython.ui ModuleStateModifierTester.ui @@ -46,7 +36,7 @@ set(Interface_Modules_Python_FORMS CompositeModule.ui ) -set(Interface_Modules_Python_HEADERS +SET(Interface_Modules_Python_HEADERS PythonObjectForwarderDialog.h InterfaceWithPythonDialog.h ModuleStateModifierTesterDialog.h @@ -57,7 +47,7 @@ set(Interface_Modules_Python_HEADERS share.h ) -set(Interface_Modules_Python_SOURCES +SET(Interface_Modules_Python_SOURCES PythonObjectForwarderDialog.cc InterfaceWithPythonDialog.cc ModuleStateModifierTesterDialog.cc @@ -67,13 +57,9 @@ set(Interface_Modules_Python_SOURCES CompositeModuleDialog.cc ) -# ---- Qt UI/MOC generation ---- -# Top-level already sets SCIRUN_QT_MAJOR and finds Qt5/Qt6 + defines -# helper macros QT_WRAP_UI / QT_WRAP_CPP accordingly. QT_WRAP_UI(Interface_Modules_Python_FORMS_HEADERS "${Interface_Modules_Python_FORMS}") -QT_WRAP_CPP(Interface_Modules_Python_HEADERS_MOC "${Interface_Modules_Python_HEADERS}") +QT_WRAP_CPP(Interface_Modules_Python_HEADERS_MOC "${Interface_Modules_Python_HEADERS}") -# ---- Library target ---- SCIRUN_ADD_LIBRARY(Interface_Modules_Python ${Interface_Modules_Python_HEADERS} ${Interface_Modules_Python_FORMS_HEADERS} @@ -81,24 +67,15 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Python ${Interface_Modules_Python_SOURCES} ) -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Interface_Modules_Python) -endif() - -# ---- Include current binary dir for generated moc/ui headers ---- -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# ---- Link dependencies ---- -# No direct Python headers here; Python is pulled in by Modules_Python. -# Qt variables are set by the top-level (Qt5 or Qt6). -target_link_libraries(Interface_Modules_Python - PRIVATE - Modules_Python - Modules_Basic - Interface_Modules_Base - ${SCI_BOOST_LIBRARY} - ${QT_LIBRARIES} +TARGET_LINK_LIBRARIES(Interface_Modules_Python + Modules_Python + Modules_Basic + Interface_Modules_Base + ${QT_LIBRARIES} ) -# Optional: nice status line during configure -message(STATUS "[Interface/Modules/Python] Configured (Qt ${QT_VERSION_MAJOR}, BUILD_WITH_PYTHON=ON)") +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Interface_Modules_Python) +ENDIF(BUILD_SHARED_LIBS) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/Interface/Modules/Render/CMakeLists.txt b/src/Interface/Modules/Render/CMakeLists.txt index ae9ae015db..a0e18a25e3 100644 --- a/src/Interface/Modules/Render/CMakeLists.txt +++ b/src/Interface/Modules/Render/CMakeLists.txt @@ -132,21 +132,21 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render Core_Application_Preferences Core_Application ${OPENGL_LIBRARIES} - GLEW::GLEW ${QT_OPENGL_LIBRARY} ${SCI_SPIRE_LIBRARY} - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} - Freetype::Freetype - LodePNG::lodepng - Tny::tny - Qwt::Qwt - #${SCI_QWT_LIBRARY} + ${SCI_FREETYPE_LIBRARY} + ${SCI_LODEPNG_LIBRARY} + ${SCI_TNY_LIBRARY} + ${SCI_QWT_LIBRARY} ) -add_compile_definitions(QWT_STATIC) - TARGET_LINK_LIBRARIES(Interface_Modules_Render ${QT_GRAPHICS_LIBRARIES}) +if (QT_VERSION_MAJOR EQUAL 6) + TARGET_LINK_LIBRARIES(Interface_Modules_Render Qt6::Svg) +elseif(QT_VERSION_MAJOR EQUAL 5) + TARGET_LINK_LIBRARIES(Interface_Modules_Render Qt5::Svg) +endif() IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Interface_Modules_Render) diff --git a/src/Interface/Modules/Render/Tests/CMakeLists.txt b/src/Interface/Modules/Render/Tests/CMakeLists.txt index 7bcd86358d..59bbe9bbfb 100644 --- a/src/Interface/Modules/Render/Tests/CMakeLists.txt +++ b/src/Interface/Modules/Render/Tests/CMakeLists.txt @@ -42,7 +42,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render_Tests Interface_Modules_Render ${OPENGL_LIBRARIES} ${QT_OPENGL_LIBRARY} - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} Testing_Utils Testing_ModuleTestBase diff --git a/src/Interface/Modules/Render/ViewSceneControlsDock.cc b/src/Interface/Modules/Render/ViewSceneControlsDock.cc index bd47edd226..cc4026aff9 100644 --- a/src/Interface/Modules/Render/ViewSceneControlsDock.cc +++ b/src/Interface/Modules/Render/ViewSceneControlsDock.cc @@ -35,8 +35,8 @@ #include #include -#include -#include +#include +#include using namespace SCIRun; using namespace SCIRun::Core; diff --git a/src/Interface/Modules/String/CMakeLists.txt b/src/Interface/Modules/String/CMakeLists.txt index 7f7367b032..0ee39aefcf 100644 --- a/src/Interface/Modules/String/CMakeLists.txt +++ b/src/Interface/Modules/String/CMakeLists.txt @@ -73,7 +73,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_String Modules_Legacy_String Interface_Modules_Base Modules_Legacy_Bundle - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Teem/CMakeLists.txt b/src/Interface/Modules/Teem/CMakeLists.txt index a1b2d1a728..114f66450f 100644 --- a/src/Interface/Modules/Teem/CMakeLists.txt +++ b/src/Interface/Modules/Teem/CMakeLists.txt @@ -65,13 +65,10 @@ SCIRUN_ADD_LIBRARY(Interface_Modules_Teem ) TARGET_LINK_LIBRARIES(Interface_Modules_Teem - Core_Algorithms_Legacy_Fields - Core_Algorithms_Legacy_Converter Modules_Legacy_Teem_Misc Modules_Legacy_Teem_Tend Modules_Legacy_Teem_Converters Interface_Modules_Base - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/Interface/Modules/Visualization/CMakeLists.txt b/src/Interface/Modules/Visualization/CMakeLists.txt index a3585302bf..3ee54b54e3 100644 --- a/src/Interface/Modules/Visualization/CMakeLists.txt +++ b/src/Interface/Modules/Visualization/CMakeLists.txt @@ -93,7 +93,6 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Visualization Core_Algorithms_Legacy_Fields Interface_Modules_Base Core_Application - ${SCI_BOOST_LIBRARY} ${QT_LIBRARIES} ) diff --git a/src/LATEST_TAG.txt b/src/LATEST_TAG.txt index 7c345cdeb0..432eed450c 100644 --- a/src/LATEST_TAG.txt +++ b/src/LATEST_TAG.txt @@ -1 +1 @@ -v5.0-beta.2023 +v5.0-beta.2026 diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 3a0d13676d..dca07858bd 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -76,6 +76,30 @@ ELSEIF(WIN32) ADD_EXECUTABLE(${APPLICATION_NAME} WIN32 ${SCIRunMain_SOURCES}) + # Windows + MSVC + non-headless: enable Qt runtime for VS debugging + IF(WIN32 AND MSVC AND NOT BUILD_HEADLESS) + + # Detect Qt version (Qt6 preferred, fallback to Qt5) + IF(TARGET Qt6::qmake) + SET(_qt_qmake_target Qt6::qmake) + ELSEIF(TARGET Qt5::qmake) + SET(_qt_qmake_target Qt5::qmake) + ELSE() + SET(_qt_qmake_target "") + ENDIF() + + IF(_qt_qmake_target) + get_target_property(_qt_qmake_exe ${_qt_qmake_target} LOCATION) + get_filename_component(_qt_bin_dir "${_qt_qmake_exe}" DIRECTORY) + + set_property(TARGET ${APPLICATION_NAME} PROPERTY + VS_DEBUGGER_ENVIRONMENT + "PATH=${_qt_bin_dir};%PATH%" + ) + ENDIF() + + ENDIF() + # TODO: probably need this for Xcode IF(WIN32 AND MSVC) # TODO: more build types to be supported? @@ -101,7 +125,7 @@ ELSEIF(WIN32) ${SCIRun_BINARY_DIR}/Assets ${SCIRun_BINARY_DIR}/$/Assets ) -ENDIF() + ENDIF() ELSE() ADD_EXECUTABLE(${APPLICATION_NAME} ${SCIRunMain_SOURCES}) @@ -118,96 +142,127 @@ ENDIF() FOREACH(app ${APPS}) TARGET_LINK_LIBRARIES(${app} - PRIVATE Core_Util_Legacy ) IF(BUILD_HEADLESS) TARGET_LINK_LIBRARIES(${app} - PRIVATE Core_ConsoleApplication ) ELSE() TARGET_LINK_LIBRARIES(${app} - PRIVATE Interface_Application ) ENDIF() - # ---- Only add Python linkage when requested ---- IF(BUILD_WITH_PYTHON) TARGET_LINK_LIBRARIES(${app} - PRIVATE Core_Python - SCIRunPython - SCIRunPythonAPI ) + ENDIF() +ENDFOREACH() - # ---- MSVC: Neutralize wrong defaultlibs and force correct python import lib ---- - if (MSVC) - # Ignore the wrong defaultlib per configuration - target_link_options(${app} PRIVATE - $<$:/NODEFAULTLIB:python313.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - $<$:/NODEFAULTLIB:python313_d.lib> - ) - # Prefer imported python target from superbuild/helpers - if (TARGET SCIRunPython::Python) - target_link_libraries(${app} PRIVATE - $<$:SCIRunPython::Python> - $<$>:SCIRunPython::Python> - ) - elseif (TARGET Python::Python) - target_link_libraries(${app} PRIVATE - $<$:Python::Python> - $<$>:Python::Python> - ) - else() - # Fallback: probe superbuild locations for python313[_d].lib - set(_PY_DBG "") - set(_PY_REL "") - foreach(dir - "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/libs" - "${CMAKE_BINARY_DIR}/../Externals/Install/Python_external/lib" - "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external/PCbuild/amd64" - ) - if (EXISTS "${dir}/python313_d.lib" AND NOT _PY_DBG) - set(_PY_DBG "${dir}/python313_d.lib") - endif() - if (EXISTS "${dir}/python313.lib" AND NOT _PY_REL) - set(_PY_REL "${dir}/python313.lib") - endif() - endforeach() - - if (_PY_DBG) - target_link_libraries(${app} PRIVATE - $<$:${_PY_DBG}> - ) - message(STATUS "[${app}] Using ${_PY_DBG} for Debug") - else() - message(WARNING "[${app}] Could not locate python313_d.lib; Debug link may still fail.") - endif() - - if (_PY_REL) - target_link_libraries(${app} PRIVATE - $<$>:${_PY_REL}> - ) - message(STATUS "[${app}] Using ${_PY_REL} for non-Debug") - else() - message(WARNING "[${app}] Could not locate python313.lib; non-Debug link may fail.") - endif() - endif() +IF(APPLE) + IF(${CMAKE_GENERATOR} MATCHES "Xcode") + SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib/$) + ELSE() + SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib) + ENDIF() +ENDIF() + - # Safety net: strip any literal python313 libs that leaked in via LINK_LIBRARIES - get_target_property(_app_link_libs ${app} LINK_LIBRARIES) - if (_app_link_libs) - list(FILTER _app_link_libs EXCLUDE REGEX ".*python313(_d)?\\.lib$") - set_property(TARGET ${app} PROPERTY LINK_LIBRARIES "${_app_link_libs}") +IF(APPLE) + +ELSE() + IF(WIN32) + IF(BUILD_WITH_PYTHON) + # TODO: change $ to $ when upgrading to cmake 3 + # TODO: copy python dll + ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory $/${PYTHON_MODULE_SEARCH_PATH} + COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCI_PYTHON_MODULE_LIBRARY_PATH} $/${PYTHON_MODULE_SEARCH_PATH} + WORKING_DIRECTORY ${SCIRun_BINARY_DIR}) + ENDIF() + + IF(NOT BUILD_HEADLESS) + # Note: installer is created from Release build only! + GET_TARGET_PROPERTY(QTCORENAME Qt${QT_VERSION_MAJOR}::Core LOCATION) + GET_TARGET_PROPERTY(QTGUINAME Qt${QT_VERSION_MAJOR}::Gui LOCATION) + GET_TARGET_PROPERTY(QTOPENGLNAME Qt${QT_VERSION_MAJOR}::OpenGL LOCATION) + if (QT_VERSION_MAJOR VERSION_GREATER 5) + GET_TARGET_PROPERTY(QTOPENGLWIDGETSNAME Qt${QT_VERSION_MAJOR}::OpenGLWidgets LOCATION) endif() - endif() # MSVC - ENDIF() # BUILD_WITH_PYTHON -ENDFOREACH() + GET_TARGET_PROPERTY(QTWIDGETSNAME Qt${QT_VERSION_MAJOR}::Widgets LOCATION) + GET_TARGET_PROPERTY(QTNETWORKNAME Qt${QT_VERSION_MAJOR}::Network LOCATION) + GET_TARGET_PROPERTY(QTCONCURRENTNAME Qt${QT_VERSION_MAJOR}::Concurrent LOCATION) + GET_TARGET_PROPERTY(QTSVGNAME Qt${QT_VERSION_MAJOR}::Svg LOCATION) + GET_TARGET_PROPERTY(QTPRINTSUPPORTNAME Qt${QT_VERSION_MAJOR}::PrintSupport LOCATION) + ENDIF() + INSTALL(TARGETS ${APPLICATION_NAME} RUNTIME DESTINATION bin) + IF(NOT BUILD_HEADLESS) + INSTALL(PROGRAMS + ${QTCORENAME} + ${QTGUINAME} + ${QTOPENGLNAME} + ${QTNETWORKNAME} + ${QTWIDGETSNAME} + ${QTCONCURRENTNAME} + ${QTSVGNAME} + ${QTPRINTSUPPORTNAME} + DESTINATION bin) + if (QT_VERSION_MAJOR VERSION_GREATER 5) + INSTALL(PROGRAMS + ${QTOPENGLWIDGETSNAME} + DESTINATION bin) + endif() + INSTALL(PROGRAMS "${SCI_QWT_LIBRARY_DIR}/Release/${SCI_QWT_LIBRARY}.dll" DESTINATION bin CONFIGURATIONS Release) + INSTALL(PROGRAMS "${Qt_PATH}/plugins/platforms/qwindows.dll" DESTINATION bin/platforms CONFIGURATIONS Release) + ENDIF() + IF(BUILD_WITH_PYTHON) + INSTALL(PROGRAMS + ${SCI_PYTHON_DLL_PATH} + DESTINATION bin) + INSTALL(DIRECTORY "${SCI_PYTHON_MODULE_LIBRARY_PATH}/" DESTINATION bin/${PYTHON_MODULE_SEARCH_PATH}) + ENDIF() + + IF(BUILD_WITH_PYTHON) + INSTALL(PROGRAMS + ${SCI_PYTHON_DLL_PATH} + DESTINATION bin) + INSTALL(DIRECTORY "${SCI_PYTHON_MODULE_LIBRARY_PATH}/" DESTINATION bin/${PYTHON_MODULE_SEARCH_PATH}) + ENDIF() + + INSTALL(DIRECTORY "${SCIRun_BINARY_DIR}/Shaders" DESTINATION bin USE_SOURCE_PERMISSIONS) + INSTALL(DIRECTORY "${SCIRun_BINARY_DIR}/Assets" DESTINATION bin USE_SOURCE_PERMISSIONS) + INSTALL(DIRECTORY "${SCIRun_BINARY_DIR}/Fonts" DESTINATION bin USE_SOURCE_PERMISSIONS) + ELSE() + IF(BUILD_HEADLESS) + MESSAGE(STATUS "Building headless SCIRun") + ENDIF() + + IF(BUILD_WITH_PYTHON) + ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${PYTHON_MODULE_SEARCH_PATH} + COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCI_PYTHON_MODULE_LIBRARY_PATH} ${PYTHON_MODULE_SEARCH_PATH} + WORKING_DIRECTORY ${SCIRun_BINARY_DIR}) + IF(SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH AND EXISTS ${SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH}) + ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCI_PYTHON_64BIT_MODULE_LIBRARY_PATH} ${PYTHON_MODULE_SEARCH_PATH} + WORKING_DIRECTORY ${SCIRun_BINARY_DIR}) + ENDIF() + ENDIF() + ENDIF() +ENDIF() + +SET(NETWORKS_DESTINATION_DIR "./SCIRunNetworks") + +# TODO: be careful of SCIRun network file extension +# TODO: refactor when networks are reorganized +INSTALL(DIRECTORY "${SCIRun_SOURCE_DIR}/ExampleNets/regression" DESTINATION ${NETWORKS_DESTINATION_DIR} + USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*.srn5") -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/Modules/DataIO/CMakeLists.txt b/src/Modules/DataIO/CMakeLists.txt index 3dd871b301..20619f85cc 100644 --- a/src/Modules/DataIO/CMakeLists.txt +++ b/src/Modules/DataIO/CMakeLists.txt @@ -65,7 +65,6 @@ TARGET_LINK_LIBRARIES(Modules_DataIO Algorithms_DataIO Core_Algorithms_Legacy_DataIO Core_ImportExport - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Modules/DataIO/ReadField.cc b/src/Modules/DataIO/ReadField.cc index e06668a46b..fc3382b5b5 100644 --- a/src/Modules/DataIO/ReadField.cc +++ b/src/Modules/DataIO/ReadField.cc @@ -99,5 +99,5 @@ ReadField::execute() bool ReadField::useCustomImporter(const std::string& filename) const { - return boost::filesystem::path(filename).extension() != ".fld"; + return boost::filesystem::path(filename).extension().string() != ".fld"; } diff --git a/src/Modules/DataIO/Tests/CMakeLists.txt b/src/Modules/DataIO/Tests/CMakeLists.txt index 86d88ae9af..921780184d 100644 --- a/src/Modules/DataIO/Tests/CMakeLists.txt +++ b/src/Modules/DataIO/Tests/CMakeLists.txt @@ -50,5 +50,4 @@ TARGET_LINK_LIBRARIES(Modules_DataIO_Tests gtest_main gtest gmock - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Modules/DataIO/WriteField.cc b/src/Modules/DataIO/WriteField.cc index 5fafe90531..05404b6022 100644 --- a/src/Modules/DataIO/WriteField.cc +++ b/src/Modules/DataIO/WriteField.cc @@ -121,7 +121,7 @@ bool WriteField::useCustomExporter(const std::string& filename) const { auto ft = cstate()->getValue(Variables::FileTypeName).toString(); LOG_DEBUG("WriteField with filetype {}", ft); - auto ret = boost::filesystem::path(filename).extension() != ".fld"; + auto ret = boost::filesystem::path(filename).extension().string() != ".fld"; filetype_ = ft.find("SCIRun Field ASCII") != std::string::npos ? "ASCII" : "Binary"; diff --git a/src/Modules/Factory/CMakeLists.txt b/src/Modules/Factory/CMakeLists.txt index b97fbca393..5dd8a2a62d 100644 --- a/src/Modules/Factory/CMakeLists.txt +++ b/src/Modules/Factory/CMakeLists.txt @@ -60,33 +60,6 @@ SCIRUN_ADD_LIBRARY(Modules_Factory ${ModuleFactoryImpl_Generated} ) -# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h -if (BUILD_WITH_PYTHON) - set(_PY_INCLUDES "") - if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") - endif() - if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") - endif() - if (MSVC AND NOT _PY_INCLUDES) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if (EXISTS "${_py_src}/Include") - list(APPEND _PY_INCLUDES "${_py_src}/Include") - endif() - if (EXISTS "${_py_src}/PC") - list(APPEND _PY_INCLUDES "${_py_src}/PC") - endif() - endif() - if (_PY_INCLUDES) - list(REMOVE_DUPLICATES _PY_INCLUDES) - target_include_directories(Modules_Factory PRIVATE ${_PY_INCLUDES}) - message(STATUS "[Modules/Factory] Added Python includes: ${_PY_INCLUDES}") - else() - message(WARNING "[Modules/Factory] Python includes not found at configure time; Boost.Python compilation may fail.") - endif() -endif() - IF(GENERATE_MODULE_FACTORY_CODE AND REGENERATE_MODULE_FACTORY_CODE) ADD_CUSTOM_COMMAND( TARGET Modules_Factory diff --git a/src/Modules/Factory/Generator/CMakeLists.txt b/src/Modules/Factory/Generator/CMakeLists.txt index 644f5e7f19..1c213a6c8d 100644 --- a/src/Modules/Factory/Generator/CMakeLists.txt +++ b/src/Modules/Factory/Generator/CMakeLists.txt @@ -41,14 +41,14 @@ SCIRUN_ADD_LIBRARY(Modules_Factory_Generator ) TARGET_LINK_LIBRARIES(Modules_Factory_Generator - ${SCI_BOOST_LIBRARY} + Boost::filesystem ) SET_PROPERTY(TARGET Modules_Factory_Generator PROPERTY FOLDER "Modules") IF(GENERATE_MODULE_FACTORY_CODE) ADD_EXECUTABLE(MakeModuleFactory MakeModuleFactory.h MakeModuleFactory.cc) - TARGET_LINK_LIBRARIES(MakeModuleFactory Modules_Factory_Generator ${SCI_BOOST_LIBRARY}) + TARGET_LINK_LIBRARIES(MakeModuleFactory Modules_Factory_Generator) SET_PROPERTY(TARGET MakeModuleFactory PROPERTY FOLDER "Modules") ENDIF() diff --git a/src/Modules/Fields/CMakeLists.txt b/src/Modules/Fields/CMakeLists.txt index 854abacd30..c2e625d62a 100644 --- a/src/Modules/Fields/CMakeLists.txt +++ b/src/Modules/Fields/CMakeLists.txt @@ -60,7 +60,6 @@ TARGET_LINK_LIBRARIES(Modules_Fields Graphics_Datatypes Graphics_Widgets ${OPENGL_LIBRARIES} - GLEW::GLEW ) IF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Fields/CMakeLists.txt b/src/Modules/Legacy/Fields/CMakeLists.txt index a402943178..e8b50e076f 100644 --- a/src/Modules/Legacy/Fields/CMakeLists.txt +++ b/src/Modules/Legacy/Fields/CMakeLists.txt @@ -232,60 +232,33 @@ IF(WITH_TETGEN) ADD_DEFINITIONS(-DWITH_TETGEN) ENDIF() -# Create the target (unchanged) SCIRUN_ADD_LIBRARY(Modules_Legacy_Fields ${Modules_Legacy_Fields_HEADERS} ${Modules_Legacy_Fields_SRCS} ) -# ---- Convert to keyword signature and keep all links here ---- -target_link_libraries(Modules_Legacy_Fields - PRIVATE - Dataflow_Network - # TODO: remove - Core_Serialization_Network - Core_Algorithms_Legacy_Fields - Algorithms_Base - Core_Basis - Core_Datatypes - Core_Datatypes_Legacy_Bundle - Core_Exceptions_Legacy - Core_Geometry_Primitives - Core_Math - Core_Parser - Core_Util_Legacy - Graphics_Widgets - Graphics_Datatypes +TARGET_LINK_LIBRARIES(Modules_Legacy_Fields + Dataflow_Network + #TODO: remove + Core_Serialization_Network + Core_Algorithms_Legacy_Fields + Algorithms_Base + Core_Basis + Core_Datatypes + Core_Datatypes_Legacy_Bundle + Core_Exceptions_Legacy + Core_Geometry_Primitives + Core_Math + Core_Parser + Core_Util_Legacy + Graphics_Widgets + Graphics_Datatypes ) -# ---- TetGen wiring (include + link + define) ---- -if(WITH_TETGEN) - message(STATUS "[Diag/Tetgen/Fields] WITH_TETGEN='${WITH_TETGEN}'") - message(STATUS "[Diag/Tetgen/Fields] TETGEN_INCLUDE_DIR='${TETGEN_INCLUDE_DIR}'") - message(STATUS "[Diag/Tetgen/Fields] TETGEN_LIB_DIR='${TETGEN_LIB_DIR}'") - message(STATUS "[Diag/Tetgen/Fields] TETGEN_LIBRARY='${TETGEN_LIBRARY}'") - if(TARGET Tetgen::Tetgen) - message(STATUS "[Diag/Tetgen/Fields] TARGET Tetgen::Tetgen is visible here") - endif() - # Add the include directory so 'tetgen.h' is found - if(DEFINED TETGEN_INCLUDE_DIR AND EXISTS "${TETGEN_INCLUDE_DIR}") - target_include_directories(Modules_Legacy_Fields PRIVATE "${TETGEN_INCLUDE_DIR}") - else() - message(FATAL_ERROR "WITH_TETGEN=ON but TETGEN_INCLUDE_DIR is not set or does not exist.") - endif() - - # Link the TetGen library passed from superbuild - if(DEFINED TETGEN_LIBRARY AND EXISTS "${TETGEN_LIBRARY}") - target_link_libraries(Modules_Legacy_Fields PRIVATE "${TETGEN_LIBRARY}") - else() - message(FATAL_ERROR "WITH_TETGEN=ON but TETGEN_LIBRARY is not set or does not exist.") - endif() - - # Define TETLIBRARY when consuming TetGen as a library - target_compile_definitions(Modules_Legacy_Fields PRIVATE TETLIBRARY) -endif() +IF(WITH_TETGEN) + TARGET_LINK_LIBRARIES(Modules_Legacy_Fields ${TETGEN_LIBRARY}) +ENDIF() -# Shared library define (unchanged) -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Modules_Legacy_Fields) -endif() \ No newline at end of file +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Fields) +ENDIF() diff --git a/src/Modules/Legacy/Fields/InterfaceWithTetGen.h b/src/Modules/Legacy/Fields/InterfaceWithTetGen.h index 0417993f09..14ce6e64d1 100644 --- a/src/Modules/Legacy/Fields/InterfaceWithTetGen.h +++ b/src/Modules/Legacy/Fields/InterfaceWithTetGen.h @@ -68,8 +68,6 @@ namespace SCIRun { #ifndef WITH_TETGEN DISABLED_WITHOUT_ABOVE_COMPILE_FLAG - #else - public: bool isImplementationDisabled() const override { return false; } #endif INPUT_PORT(0, Main, Field); diff --git a/src/Modules/Legacy/Matlab/DataIO/Tests/CMakeLists.txt b/src/Modules/Legacy/Matlab/DataIO/Tests/CMakeLists.txt index 671c8cde78..c749c8e989 100644 --- a/src/Modules/Legacy/Matlab/DataIO/Tests/CMakeLists.txt +++ b/src/Modules/Legacy/Matlab/DataIO/Tests/CMakeLists.txt @@ -49,5 +49,4 @@ TARGET_LINK_LIBRARIES(Modules_Legacy_Matlab_DataIO_Tests gtest_main gtest gmock - ${SCI_BOOST_LIBRARY} ) diff --git a/src/Modules/Legacy/Teem/Converters/CMakeLists.txt b/src/Modules/Legacy/Teem/Converters/CMakeLists.txt index b701d83647..24935468ae 100644 --- a/src/Modules/Legacy/Teem/Converters/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/Converters/CMakeLists.txt @@ -46,89 +46,14 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_Converters ${Modules_Legacy_Teem_Converters_HEADERS} ) -# ========================================================== -# Teem discovery (same pattern as Core_Geometry_Primitives) -# ========================================================== -# Prefer a config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback to superbuild exports - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -target_compile_definitions(Modules_Legacy_Teem_Converters PRIVATE TEEM_STATIC) - -target_link_libraries(Modules_Legacy_Teem_Converters - PRIVATE +TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_Converters Dataflow_Network Core_Datatypes Core_Datatypes_Legacy_Nrrd Core_Algorithms_Legacy_Converter #TODO: remove link - ${_teem_target} + ${SCI_TEEM_LIBRARY} ) -# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: -if(TARGET ZLIB::ZLIB) - target_link_libraries(Modules_Legacy_Teem_Converters PRIVATE ZLIB::ZLIB) -endif() - IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Teem_Converters) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt b/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt index 7ea0060641..e17aa1a407 100644 --- a/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/DataIO/CMakeLists.txt @@ -40,81 +40,12 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_DataIO ${Modules_Legacy_Teem_DataIO_SRCS} ) -# ========================================================== -# Teem discovery (same pattern as Core_Geometry_Primitives) -# ========================================================== -# Prefer a config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback to superbuild exports - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -target_compile_definitions(Modules_Legacy_Teem_DataIO PRIVATE TEEM_STATIC) - TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_DataIO Dataflow_Network Core_Datatypes Core_Datatypes_Legacy_Nrrd Core_ImportExport - ${_teem_target} + ${SCI_TEEM_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Teem/Misc/CMakeLists.txt b/src/Modules/Legacy/Teem/Misc/CMakeLists.txt index ea019d42f6..aea2492f86 100644 --- a/src/Modules/Legacy/Teem/Misc/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/Misc/CMakeLists.txt @@ -50,88 +50,13 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_Misc ${Modules_Legacy_Teem_Misc_HEADERS} ) -# ========================================================== -# Teem discovery (same pattern as Core_Geometry_Primitives) -# ========================================================== -# Prefer a config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback to superbuild exports - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -target_compile_definitions(Modules_Legacy_Teem_Misc PRIVATE TEEM_STATIC) - -target_link_libraries(Modules_Legacy_Teem_Misc - PRIVATE +TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_Misc Dataflow_Network Core_Datatypes Core_Datatypes_Legacy_Nrrd - ${_teem_target} + ${SCI_TEEM_LIBRARY} ) -# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: -if(TARGET ZLIB::ZLIB) - target_link_libraries(Modules_Legacy_Teem_Misc PRIVATE ZLIB::ZLIB) -endif() - IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Teem_Misc) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Legacy/Teem/Tend/CMakeLists.txt b/src/Modules/Legacy/Teem/Tend/CMakeLists.txt index 08feca1827..0fad81d329 100644 --- a/src/Modules/Legacy/Teem/Tend/CMakeLists.txt +++ b/src/Modules/Legacy/Teem/Tend/CMakeLists.txt @@ -65,92 +65,17 @@ SCIRUN_ADD_LIBRARY(Modules_Legacy_Teem_Tend ${Modules_Legacy_Teem_Tend_HEADERS} ) -# ========================================================== -# Teem discovery (same pattern as Core_Geometry_Primitives) -# ========================================================== -# Prefer a config package if available -find_package(Teem CONFIG QUIET) - -if(TARGET Teem::teem) - set(_teem_target Teem::teem) -else() - # Fallback to superbuild exports - if(NOT Teem_INCLUDE_DIR OR NOT Teem_LIB_DIR) - message(FATAL_ERROR - "Teem not configured: need Teem_INCLUDE_DIR and Teem_LIB_DIR from the superbuild.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'") - endif() - - set(_teem_lib "") - if(WIN32) - if(EXISTS "${Teem_LIB_DIR}/teem.lib") - set(_teem_lib "${Teem_LIB_DIR}/teem.lib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.lib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.lib") - endif() - elseif(APPLE) - if(EXISTS "${Teem_LIB_DIR}/libteem.dylib") - set(_teem_lib "${Teem_LIB_DIR}/libteem.dylib") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - else() - if(EXISTS "${Teem_LIB_DIR}/libteem.so") - set(_teem_lib "${Teem_LIB_DIR}/libteem.so") - elseif(EXISTS "${Teem_LIB_DIR}/libteem.a") - set(_teem_lib "${Teem_LIB_DIR}/libteem.a") - endif() - endif() - - if(NOT _teem_lib) - find_library(TEEM_LIBRARY - NAMES teem libteem - HINTS "${Teem_LIB_DIR}" "${CMAKE_PREFIX_PATH}" "${CMAKE_PREFIX_PATH}/lib" "${CMAKE_PREFIX_PATH}/lib64" - ) - if(TEEM_LIBRARY) - set(_teem_lib "${TEEM_LIBRARY}") - endif() - endif() - - if(NOT _teem_lib OR NOT EXISTS "${_teem_lib}") - message(FATAL_ERROR - "Teem library not found. Looked under '${Teem_LIB_DIR}'.\n" - "Teem_INCLUDE_DIR='${Teem_INCLUDE_DIR}' Teem_LIB_DIR='${Teem_LIB_DIR}'\n" - "Ensure the Teem external installs libteem/teem.") - endif() - - add_library(Teem::teem UNKNOWN IMPORTED) - set_target_properties(Teem::teem PROPERTIES - IMPORTED_LOCATION "${_teem_lib}" - INTERFACE_INCLUDE_DIRECTORIES "${Teem_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - ) - - set(_teem_target Teem::teem) -endif() - -# ------------------------------------------ -# Static Teem consumption: avoid dllimport -# ------------------------------------------ -target_compile_definitions(Core_Algorithms_Legacy_Converter PRIVATE TEEM_STATIC) - TARGET_LINK_LIBRARIES(Modules_Legacy_Teem_Tend - PRIVATE Core_Datatypes Core_Datatypes_Legacy_Nrrd Core_Geometry_Primitives Core_Persistent Dataflow_Network - ${_teem_target} + ${SCI_TEEM_LIBRARY} #${SCI_PNG_LIBRARY} #${SCI_ZLIB_LIBRARY} ) -# If Teem was built with zlib (common for NRRD), static Teem needs zlib symbols: -if(TARGET ZLIB::ZLIB) - target_link_libraries(Modules_Legacy_Teem_Tend PRIVATE ZLIB::ZLIB) -endif() - IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Legacy_Teem_Tend) ENDIF(BUILD_SHARED_LIBS) diff --git a/src/Modules/Math/CMakeLists.txt b/src/Modules/Math/CMakeLists.txt index 8bb9fdfd85..bee677dd68 100644 --- a/src/Modules/Math/CMakeLists.txt +++ b/src/Modules/Math/CMakeLists.txt @@ -92,53 +92,20 @@ SCIRUN_ADD_LIBRARY(Modules_Math ${Modules_Math_SRCS} ) -# Add Python include dirs so Boost.Python's wrap_python.hpp sees pyconfig.h - -if (BUILD_WITH_PYTHON) - set(_PY_INCLUDES "") - if (DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_INCLUDE_DIR}") - endif() - if (DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INCLUDES "${PYTHON_PC_INCLUDE_DIR}") - endif() - if (MSVC AND NOT _PY_INCLUDES) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if (EXISTS "${_py_src}/Include") - list(APPEND _PY_INCLUDES "${_py_src}/Include") - endif() - if (EXISTS "${_py_src}/PC") - list(APPEND _PY_INCLUDES "${_py_src}/PC") - endif() - endif() - if (_PY_INCLUDES) - list(REMOVE_DUPLICATES _PY_INCLUDES) - target_include_directories(Modules_Math PRIVATE ${_PY_INCLUDES}) - message(STATUS "[Modules/Math] Added Python includes: ${_PY_INCLUDES}") - else() - message(WARNING "[Modules/Math] Python includes not found at configure time; Boost.Python compilation may fail.") - endif() - - # Disable Boost.Python autolink so this target doesn't try to link Boost/Python - target_compile_definitions(Modules_Math PRIVATE BOOST_PYTHON_NO_LIB) # <-- add this - - # Debug-only: ignore any release python import lib autolink attempts - if(MSVC) - target_link_options(Modules_Math PRIVATE - $<$:/NODEFAULTLIB:python313.lib> - ) - endif() -endif() - TARGET_LINK_LIBRARIES(Modules_Math Dataflow_Network Core_Datatypes - Core_Datatypes_Legacy_Field Algorithms_Math ) +IF(BUILD_WITH_PYTHON) + TARGET_LINK_LIBRARIES(Modules_Math + Core_Python + ) +ENDIF() + IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Modules_Math) -ENDIF() +ENDIF(BUILD_SHARED_LIBS) -SCIRUN_ADD_TEST_DIR(Tests) \ No newline at end of file +SCIRUN_ADD_TEST_DIR(Tests) diff --git a/src/Modules/Python/CMakeLists.txt b/src/Modules/Python/CMakeLists.txt index 9b0b374ee9..4153d09f3c 100644 --- a/src/Modules/Python/CMakeLists.txt +++ b/src/Modules/Python/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # For more information, please see: http://software.sci.utah.edu # # The MIT License @@ -25,12 +25,8 @@ # DEALINGS IN THE SOFTWARE. # -# ========================= -# Modules/Python CMake file -# ========================= -# --- Sources & headers --- -set(Modules_Python_SRCS +SET(Modules_Python_SRCS PythonObjectForwarder.cc InterfaceWithPython.cc PythonInterfaceParser.cc @@ -40,7 +36,7 @@ set(Modules_Python_SRCS #LoopIncrement.cc ) -set(Modules_Python_HEADERS +SET(Modules_Python_HEADERS PythonObjectForwarder.h InterfaceWithPython.h PythonInterfaceParser.h @@ -51,240 +47,28 @@ set(Modules_Python_HEADERS share.h ) -# --- Library target --- SCIRUN_ADD_LIBRARY(Modules_Python ${Modules_Python_HEADERS} ${Modules_Python_SRCS} ) -if(BUILD_SHARED_LIBS) - add_definitions(-DBUILD_Modules_Python) -endif() - -# ==================================================================================== -# Python wiring: -# - Reuse alias imported target SCIRunPython (created in Core/Python) that points -# to .../PCbuild/amd64/python313[_d].lib and exports Python include dirs. -# - If it does not exist (edge case), create a compatible local alias. -# ==================================================================================== -if(BUILD_WITH_PYTHON) - if(NOT TARGET SCIRunPython) - # Minimal local alias (fallback) — prefer superbuild hints if available - add_library(SCIRunPython STATIC IMPORTED GLOBAL) - - # Includes: prefer superbuild vars - set(_PY_INC_DIRS "") - if(DEFINED PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}") - list(APPEND _PY_INC_DIRS "${PYTHON_INCLUDE_DIR}") - endif() - if(DEFINED PYTHON_PC_INCLUDE_DIR AND EXISTS "${PYTHON_PC_INCLUDE_DIR}") - list(APPEND _PY_INC_DIRS "${PYTHON_PC_INCLUDE_DIR}") - endif() - if(MSVC AND NOT _PY_INC_DIRS) - set(_py_src "${CMAKE_BINARY_DIR}/../Externals/Source/Python_external") - if(EXISTS "${_py_src}/Include") - list(APPEND _PY_INC_DIRS "${_py_src}/Include") - endif() - if(EXISTS "${_py_src}/PC") - list(APPEND _PY_INC_DIRS "${_py_src}/PC") - endif() - endif() - if(_PY_INC_DIRS) - list(REMOVE_DUPLICATES _PY_INC_DIRS) - set_target_properties(SCIRunPython PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_PY_INC_DIRS}" - ) - endif() - - # Point to import libs on MSVC - if(MSVC) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel" - ) - set(_PY_LIB_REL "") - set(_PY_LIB_DBG "") - if(PYTHON_LIBRARY_RELEASE AND EXISTS "${PYTHON_LIBRARY_RELEASE}") - set(_PY_LIB_REL "${PYTHON_LIBRARY_RELEASE}") - elseif(DEFINED PY_EXT_LIB_DIR AND EXISTS "${PY_EXT_LIB_DIR}/python313.lib") - set(_PY_LIB_REL "${PY_EXT_LIB_DIR}/python313.lib") - endif() - if(PYTHON_LIBRARY_DEBUG AND EXISTS "${PYTHON_LIBRARY_DEBUG}") - set(_PY_LIB_DBG "${PYTHON_LIBRARY_DEBUG}") - elseif(DEFINED PY_EXT_LIB_DIR AND EXISTS "${PY_EXT_LIB_DIR}/python313_d.lib") - set(_PY_LIB_DBG "${PY_EXT_LIB_DIR}/python313_d.lib") - endif() - - if(_PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_REL}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_REL}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_REL}" - ) - endif() - if(_PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_DBG}" - ) - endif() - - # Map if only one variant exists - if(NOT _PY_LIB_DBG AND _PY_LIB_REL) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_DEBUG "${_PY_LIB_REL}" - MAP_IMPORTED_CONFIG_DEBUG "Release;RelWithDebInfo" - ) - endif() - if(NOT _PY_LIB_REL AND _PY_LIB_DBG) - set_target_properties(SCIRunPython PROPERTIES - IMPORTED_LOCATION_RELEASE "${_PY_LIB_DBG}" - IMPORTED_LOCATION_RELWITHDEBINFO "${_PY_LIB_DBG}" - IMPORTED_LOCATION_MINSIZEREL "${_PY_LIB_DBG}" - MAP_IMPORTED_CONFIG_RELEASE "Debug" - MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug" - MAP_IMPORTED_CONFIG_MINSIZEREL "Debug" - ) - endif() - endif() - endif() -endif() # BUILD_WITH_PYTHON - -# ==================================================================================== -# Link dependencies -# ==================================================================================== -target_link_libraries(Modules_Python - PRIVATE - Dataflow_Network - Core_Datatypes - Algorithms_Base - Core_Thread +TARGET_LINK_LIBRARIES(Modules_Python + Dataflow_Network + Core_Datatypes + Algorithms_Base + Core_Thread ) -if(BUILD_WITH_PYTHON) - # Pull in Python headers + import libs (per-config) via the alias - target_link_libraries(Modules_Python PRIVATE SCIRunPython Core_Python SCIRunPythonAPI) - - # ================================================================================== - # Boost.Python: disable autolink and link the correct libraries explicitly on MSVC. - # Fixes LNK1104 asking for 'boost_python...' (no 'lib' prefix) when your files are - # named 'libboost_python...'. - # ================================================================================== - if(MSVC) - target_compile_definitions(Modules_Python PRIVATE BOOST_PYTHON_NO_LIB BOOST_PYTHON_STATIC_LIB) - - # Locate Boost.Python libraries in SCI_BOOST_LIBRARY_DIR (passed from superbuild) - if (NOT DEFINED SCI_BOOST_LIBRARY_DIR OR NOT EXISTS "${SCI_BOOST_LIBRARY_DIR}") - message(FATAL_ERROR - "[Modules/Python] SCI_BOOST_LIBRARY_DIR is not set or does not exist; " - "cannot link Boost.Python explicitly." - ) - endif() - - # Try to infer python digits (e.g., 313) from the CPython import libs we are using - set(_SCIRUN_PY_DIGITS "") - if(TARGET SCIRunPython) - get_target_property(_py_dbg SCIRunPython IMPORTED_LOCATION_DEBUG) - get_target_property(_py_rel SCIRunPython IMPORTED_LOCATION_RELEASE) - foreach(_cand "${_py_dbg}" "${_py_rel}") - if(_cand) - get_filename_component(_bn "${_cand}" NAME) - if(_bn MATCHES "python([0-9]+)(_d)?\\.lib$") - set(_SCIRUN_PY_DIGITS "${CMAKE_MATCH_1}") - break() - endif() - endif() - endforeach() - endif() - - # Build candidate patterns (both with/without 'lib' prefix) - if(_SCIRUN_PY_DIGITS) - set(_bp_dbg_patterns - "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_DIGITS}-vc*-mt-gd-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_DIGITS}-vc*-mt-gd-*.lib" - ) - set(_bp_rel_patterns_all - "${SCI_BOOST_LIBRARY_DIR}/libboost_python${_SCIRUN_PY_DIGITS}-vc*-mt-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_python${_SCIRUN_PY_DIGITS}-vc*-mt-*.lib" - ) - else() - # Fallback: any 3.x debug/release variants - set(_bp_dbg_patterns - "${SCI_BOOST_LIBRARY_DIR}/libboost_python3*-vc*-mt-gd-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_python3*-vc*-mt-gd-*.lib" - ) - set(_bp_rel_patterns_all - "${SCI_BOOST_LIBRARY_DIR}/libboost_python3*-vc*-mt-*.lib" - "${SCI_BOOST_LIBRARY_DIR}/boost_python3*-vc*-mt-*.lib" - ) - endif() - - # Collect and pick best (latest) debug candidate - set(_bp_dbg_candidates "") - foreach(_pat IN LISTS _bp_dbg_patterns) - file(GLOB _hits "${_pat}") - if(_hits) - list(APPEND _bp_dbg_candidates ${_hits}) - endif() - endforeach() - if(_bp_dbg_candidates) - list(SORT _bp_dbg_candidates) - list(REVERSE _bp_dbg_candidates) - list(GET _bp_dbg_candidates 0 _BP_PY_LIB_DEBUG) - endif() - - # Collect and pick best (latest) release candidate, but filter out "-gd-" - set(_bp_rel_candidates "") - foreach(_pat IN LISTS _bp_rel_patterns_all) - file(GLOB _hits "${_pat}") - foreach(_h IN LISTS _hits) - if(NOT _h MATCHES "-gd-") # exclude debug variants - list(APPEND _bp_rel_candidates "${_h}") - endif() - endforeach() - endforeach() - if(_bp_rel_candidates) - list(SORT _bp_rel_candidates) - list(REVERSE _bp_rel_candidates) - list(GET _bp_rel_candidates 0 _BP_PY_LIB_RELEASE) - endif() - - if(NOT (EXISTS "${_BP_PY_LIB_DEBUG}" AND EXISTS "${_BP_PY_LIB_RELEASE}")) - message(FATAL_ERROR - "[Modules/Python] Could not locate Boost.Python libs under '${SCI_BOOST_LIBRARY_DIR}'.\n" - "Debug candidate='${_BP_PY_LIB_DEBUG}'\nRelease candidate='${_BP_PY_LIB_RELEASE}'" - ) - endif() - - # Ensure the directory is on the link path - target_link_directories(Modules_Python PRIVATE "${SCI_BOOST_LIBRARY_DIR}") - - # Explicitly link Boost.Python (eliminates autolink name mismatch) - target_link_libraries(Modules_Python PRIVATE - debug "${_BP_PY_LIB_DEBUG}" - optimized "${_BP_PY_LIB_RELEASE}" +IF(BUILD_WITH_PYTHON) + TARGET_LINK_LIBRARIES(Modules_Python + Core_Python ) +ENDIF() - # Debug-only: ignore any attempt to autolink the *release* python313.lib - if(_SCIRUN_PY_DIGITS) - target_link_options(Modules_Python PRIVATE - $<$:/NODEFAULTLIB:python${_SCIRUN_PY_DIGITS}.lib> - ) - else() - target_link_options(Modules_Python PRIVATE - $<$:/NODEFAULTLIB:python3.lib> - ) - endif() - - # Diagnostics - message(STATUS "[Modules/Python] Boost.Python (debug) : ${_BP_PY_LIB_DEBUG}") - message(STATUS "[Modules/Python] Boost.Python (release) : ${_BP_PY_LIB_RELEASE}") - endif() # MSVC - - target_compile_definitions(Modules_Python PRIVATE BUILD_WITH_PYTHON) -endif() # BUILD_WITH_PYTHON +IF(BUILD_SHARED_LIBS) + ADD_DEFINITIONS(-DBUILD_Modules_Python) +ENDIF(BUILD_SHARED_LIBS) -# ==================================================================================== -# Tests -# ==================================================================================== -if(BUILD_WITH_PYTHON) +IF(BUILD_WITH_PYTHON) SCIRUN_ADD_TEST_DIR(Tests) -endif() \ No newline at end of file +ENDIF() diff --git a/src/Modules/Python/InterfaceWithPython.h b/src/Modules/Python/InterfaceWithPython.h index f850229e48..8d60d22374 100644 --- a/src/Modules/Python/InterfaceWithPython.h +++ b/src/Modules/Python/InterfaceWithPython.h @@ -93,8 +93,6 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG - #else - public: bool isImplementationDisabled() const override { return false; } #endif private: static Core::Thread::Mutex lock_; diff --git a/src/Modules/Python/LoopEnd.h b/src/Modules/Python/LoopEnd.h index 10f415950e..ea8800b8d6 100644 --- a/src/Modules/Python/LoopEnd.h +++ b/src/Modules/Python/LoopEnd.h @@ -73,8 +73,6 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG - #else - public: bool isImplementationDisabled() const override { return false; } #endif private: SharedPointer translator_; diff --git a/src/Modules/Python/LoopStart.h b/src/Modules/Python/LoopStart.h index 0c97bf6409..01c5a51ec2 100644 --- a/src/Modules/Python/LoopStart.h +++ b/src/Modules/Python/LoopStart.h @@ -76,8 +76,6 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG - #else - public: bool isImplementationDisabled() const override { return false; } #endif private: SharedPointer translator_; diff --git a/src/Modules/Python/ModuleStateModifierTester.h b/src/Modules/Python/ModuleStateModifierTester.h index dd856ac939..0cbcd845b4 100644 --- a/src/Modules/Python/ModuleStateModifierTester.h +++ b/src/Modules/Python/ModuleStateModifierTester.h @@ -77,8 +77,6 @@ namespace SCIRun NEW_HELP_WEBPAGE_ONLY #ifndef BUILD_WITH_PYTHON DISABLED_WITHOUT_ABOVE_COMPILE_FLAG - #else - public: bool isImplementationDisabled() const override { return false; } #endif private: //void runTopLevelCode() const; diff --git a/src/Modules/Visualization/CMakeLists.txt b/src/Modules/Visualization/CMakeLists.txt index b88a7c985d..8475206447 100644 --- a/src/Modules/Visualization/CMakeLists.txt +++ b/src/Modules/Visualization/CMakeLists.txt @@ -77,7 +77,7 @@ TARGET_LINK_LIBRARIES(Modules_Visualization Graphics_Glyphs Graphics_Datatypes Graphics_Widgets - Freetype::Freetype + ${SCI_FREETYPE_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Testing/ModuleTestBase/CMakeLists.txt b/src/Testing/ModuleTestBase/CMakeLists.txt index c01c01e36b..b4811d4829 100644 --- a/src/Testing/ModuleTestBase/CMakeLists.txt +++ b/src/Testing/ModuleTestBase/CMakeLists.txt @@ -49,7 +49,6 @@ TARGET_LINK_LIBRARIES(Testing_ModuleTestBase Dataflow_State gtest gmock - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) diff --git a/src/Testing/Utils/CMakeLists.txt b/src/Testing/Utils/CMakeLists.txt index f41c087f49..92336f0b3f 100644 --- a/src/Testing/Utils/CMakeLists.txt +++ b/src/Testing/Utils/CMakeLists.txt @@ -50,7 +50,6 @@ TARGET_LINK_LIBRARIES(Testing_Utils Core_Algorithms_Legacy_Fields gtest gmock - ${SCI_BOOST_LIBRARY} ) IF(BUILD_SHARED_LIBS) From 1b432c9f1506a18770412dd12a3fed6776709424 Mon Sep 17 00:00:00 2001 From: Wan Date: Tue, 21 Apr 2026 16:59:44 -0600 Subject: [PATCH 100/140] Update BoostExternal.cmake --- Superbuild/BoostExternal.cmake | 125 ++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 42 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index f4225648a2..fe059de635 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -118,6 +118,58 @@ if(WIN32) else() set(_SCIRUN_ENV_PATH_CMAKE "$ENV{PATH}") endif() +# ------------------------------------------------------------------------------ +# ExternalProject_Add: Boost +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ +# Compute Python-related CMake cache arguments for Boost +# ------------------------------------------------------------------------------ +if(BUILD_WITH_PYTHON) + if(WIN32 AND MSVC) + set(_BOOST_PYTHON_CACHE_ARGS + -DPython3_FIND_FRAMEWORK:STRING=NEVER + -DPython3_FIND_STRATEGY:STRING=LOCATION + -DPython3_FIND_REQUIRED:BOOL=ON + -DPython3_ROOT_DIR:PATH=${SCI_PYTHON_ROOT_DIR} + -DPython3_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE} + -DPython3_INCLUDE_DIR:PATH=${SCI_PYTHON_INCLUDE} + -DPython3_LIBRARY_DEBUG:FILEPATH=${SCI_PYTHON_LIBRARY_FILE_DEBUG} + -DPython3_LIBRARY_RELEASE:FILEPATH=${SCI_PYTHON_LIBRARY_FILE_RELEASE} + ) + else() + set(_BOOST_PYTHON_CACHE_ARGS + -DPython3_FIND_FRAMEWORK:STRING=NEVER + -DPython3_FIND_STRATEGY:STRING=LOCATION + -DPython3_FIND_REQUIRED:BOOL=ON + -DPython3_ROOT_DIR:PATH=${SCI_PYTHON_ROOT_DIR} + -DPython3_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE} + -DPython3_INCLUDE_DIR:PATH=${SCI_PYTHON_INCLUDE} + -DPython3_LIBRARY:FILEPATH=${SCI_PYTHON_LIBRARY_FILE} + ) + endif() +else() + # Python completely disabled: do not expose Python in any form + set(_BOOST_PYTHON_CACHE_ARGS + -DPython3_FIND_REQUIRED:BOOL=OFF + ) +endif() + +# ------------------------------------------------------------------------------ +# Compute Python-related environment variables for Boost/b2 +# ------------------------------------------------------------------------------ +if(BUILD_WITH_PYTHON) + set(_BOOST_PYTHON_ENV + "PYTHONHOME=${SCI_PYTHON_ROOT_DIR}" + "PYTHONPATH=" + "PATH=${SCI_PYTHON_ROOT_DIR}/bin:${_SCIRUN_ENV_PATH_CMAKE}" + ) +else() + set(_BOOST_PYTHON_ENV + "PYTHONPATH=" + "PATH=${_SCIRUN_ENV_PATH_CMAKE}" + ) +endif() + # ------------------------------------------------------------------------------ # ExternalProject_Add: Boost # ------------------------------------------------------------------------------ @@ -130,38 +182,20 @@ ExternalProject_Add(Boost_external INSTALL_COMMAND "" CMAKE_CACHE_ARGS - -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DFORCE_64BIT_BUILD:BOOL=${FORCE_64BIT_BUILD} + -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DFORCE_64BIT_BUILD:BOOL=${FORCE_64BIT_BUILD} - # ---------- Python ON/OFF controlled by SCIRun option ---------- - -DBUILD_PYTHON:BOOL=${BUILD_WITH_PYTHON} - #-DBOOST_ENABLE_PYTHON:BOOL=${BUILD_WITH_PYTHON} + # ---------- Python strictly controlled by SCIRun option ---------- + -DBUILD_PYTHON:BOOL=${BUILD_WITH_PYTHON} - # ---------- FORCE FindPython3 to use SCIRun Python, not Xcode ---------- - -DPython3_FIND_FRAMEWORK:STRING=NEVER - -DPython3_FIND_STRATEGY:STRING=LOCATION - -DPython3_FIND_REQUIRED:BOOL=${BUILD_WITH_PYTHON} - -DPython3_ROOT_DIR:PATH=${SCI_PYTHON_ROOT_DIR} - -DPython3_EXECUTABLE:FILEPATH=${SCI_PYTHON_EXE} - -DPython3_INCLUDE_DIR:PATH=${SCI_PYTHON_INCLUDE} - if(WIN32 AND MSVC) - -DPython3_LIBRARY_DEBUG:FILEPATH=${SCI_PYTHON_LIBRARY_FILE_DEBUG} - -DPython3_LIBRARY_RELEASE:FILEPATH=${SCI_PYTHON_LIBRARY_FILE_RELEASE} - else() - -DPython3_LIBRARY:FILEPATH=${SCI_PYTHON_LIBRARY_FILE} - endif() + ${_BOOST_PYTHON_CACHE_ARGS} CMAKE_COMMAND_ENV - "PYTHONHOME=${SCI_PYTHON_ROOT_DIR}" - "PYTHONPATH=" - "PATH=${SCI_PYTHON_ROOT_DIR}/bin:${_SCIRUN_ENV_PATH_CMAKE}" - "CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=FALSE" - "CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=FALSE" - "CMAKE_FIND_FRAMEWORK=NEVER" - "Python3_FIND_FRAMEWORK=NEVER" - "Python3_FIND_STRATEGY=LOCATION" + ${_BOOST_PYTHON_ENV} + "CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=FALSE" + "CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=FALSE" ) # ------------------------------------------------------------------------------ @@ -192,20 +226,27 @@ ExternalProject_Add_Step(Boost_external bootstrap_b2 # -------------------------------------------------------------- # Step: write project-config.jam (AFTER bootstrap) # -------------------------------------------------------------- -ExternalProject_Add_Step(Boost_external write_project_config - COMMAND ${CMAKE_COMMAND} - -DOUTPUT_FILE=${SOURCE_DIR}/project-config.jam - -DVERSION=${SCI_PYTHON_VERSION_SHORT} - -DEXE=${SCI_PYTHON_EXE} - -DINCLUDE=${SCI_PYTHON_INCLUDE} - -DLIB_RELEASE=${SCI_PYTHON_LIBRARY_RELEASE} - -DLIB_DEBUG=${SCI_PYTHON_LIBRARY_DEBUG} - -P ${SUPERBUILD_DIR}/WriteProjectConfigJam.cmake - DEPENDEES bootstrap_b2 - INDEPENDENT 1 - - COMMENT "Overwriting project-config.jam with Python toolset AFTER bootstrap" -) +if(BUILD_WITH_PYTHON) + ExternalProject_Add_Step(Boost_external write_project_config + COMMAND ${CMAKE_COMMAND} + -DOUTPUT_FILE=${SOURCE_DIR}/project-config.jam + -DVERSION=${SCI_PYTHON_VERSION_SHORT} + -DEXE=${SCI_PYTHON_EXE} + -DINCLUDE=${SCI_PYTHON_INCLUDE} + -DLIB_RELEASE=${SCI_PYTHON_LIBRARY_RELEASE} + -DLIB_DEBUG=${SCI_PYTHON_LIBRARY_DEBUG} + -P ${SUPERBUILD_DIR}/WriteProjectConfigJam.cmake + DEPENDEES bootstrap_b2 + INDEPENDENT 1 + COMMENT "Overwriting project-config.jam with Python toolset AFTER bootstrap" + ) +else() + ExternalProject_Add_Step(Boost_external write_project_config + COMMAND ${CMAKE_COMMAND} -E echo "Python disabled: project-config.jam not modified" + DEPENDEES bootstrap_b2 + INDEPENDENT 1 + ) +endif() # -------------------------------------------------------------- # Step: verify project-config.jam From 0f9b0b3c16185bba96f85308cd8e7cac2ee215f8 Mon Sep 17 00:00:00 2001 From: Wan Date: Wed, 22 Apr 2026 11:43:37 -0600 Subject: [PATCH 101/140] removed without python flag for b2 --- Superbuild/BoostExternal.cmake | 2 +- Superbuild/WriteProjectConfigJam.cmake | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index fe059de635..d34ee85973 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -106,7 +106,7 @@ IF(BUILD_WITH_PYTHON) #SET(BOOST_PYTHON_LIB_FLAG library-path=${SCI_PYTHON_LIBRARY_DIR}) SET(BOOST_PYTHON_VERSION_FLAG python-version=${SCI_PYTHON_VERSION_SHORT}) ELSE() - SET(BOOST_PYTHON_WITH_FLAG --without-python) + SET(BOOST_PYTHON_WITH_FLAG "") SET(BOOST_PYTHON_EXE_FLAG "") SET(BOOST_PYTHON_INC_FLAG "") SET(BOOST_PYTHON_LIB_FLAG "") diff --git a/Superbuild/WriteProjectConfigJam.cmake b/Superbuild/WriteProjectConfigJam.cmake index 27cc404780..a962251a0f 100644 --- a/Superbuild/WriteProjectConfigJam.cmake +++ b/Superbuild/WriteProjectConfigJam.cmake @@ -1,3 +1,9 @@ -file(WRITE "${OUTPUT_FILE}" +if(DEFINED EXE AND EXE AND DEFINED VERSION AND VERSION) + file(WRITE "${OUTPUT_FILE}" "using python : ${VERSION} : ${EXE} : ${INCLUDE} : ${LIBDIR} ; ") +else() + # Explicitly write an empty or comment-only config + file(WRITE "${OUTPUT_FILE}" +"# Python disabled — no python toolset configured\n") +endif() \ No newline at end of file From 31d81ffb14b79a0d82c9d31039d61d565f0b0a31 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 23 Apr 2026 15:32:20 -0600 Subject: [PATCH 102/140] diagnosis for testing is on --- src/CMakeLists.txt | 2 +- src/Core/Containers/CMakeLists.txt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c28df374f4..b7307ec364 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -573,7 +573,7 @@ INCLUDE_DIRECTORIES( ${SCI_CLEAVER2_INCLUDE} ) -INCLUDE_DIRECTORIES(SYSTEM ${SCI_BOOST_INCLUDE}) +#INCLUDE_DIRECTORIES(SYSTEM ${SCI_BOOST_INCLUDE}) ADD_DEFINITIONS(-DQT_NO_KEYWORDS) diff --git a/src/Core/Containers/CMakeLists.txt b/src/Core/Containers/CMakeLists.txt index a906868f69..985d78fb21 100644 --- a/src/Core/Containers/CMakeLists.txt +++ b/src/Core/Containers/CMakeLists.txt @@ -48,8 +48,11 @@ SCIRUN_ADD_LIBRARY(Core_Containers ) TARGET_LINK_LIBRARIES(Core_Containers - Core_Persistent - Core_Exceptions_Legacy + PUBLIC + Boost::headers + PRIVATE + Core_Persistent + Core_Exceptions_Legacy ) IF(BUILD_SHARED_LIBS) From 2361cbf9191c81a6ccbc762935e728559b76cd52 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 23 Apr 2026 15:58:42 -0600 Subject: [PATCH 103/140] added boost to container test via container --- src/Core/Containers/Tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Containers/Tests/CMakeLists.txt b/src/Core/Containers/Tests/CMakeLists.txt index 213f1ed779..e16a81195d 100644 --- a/src/Core/Containers/Tests/CMakeLists.txt +++ b/src/Core/Containers/Tests/CMakeLists.txt @@ -35,7 +35,7 @@ SCIRUN_ADD_UNIT_TEST(Core_Containers_Tests ) TARGET_LINK_LIBRARIES(Core_Containers_Tests - #Core_Containers + Core_Containers gtest_main gtest gmock From 300841654b37d3e9673c9caa3e0784f1628c19e1 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 23 Apr 2026 16:26:29 -0600 Subject: [PATCH 104/140] added boost to core_math for graphics datatypes test --- src/Core/Math/CMakeLists.txt | 5 ++++- src/Graphics/Datatypes/Tests/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Core/Math/CMakeLists.txt b/src/Core/Math/CMakeLists.txt index 9de79ed5d9..d2122ace5b 100644 --- a/src/Core/Math/CMakeLists.txt +++ b/src/Core/Math/CMakeLists.txt @@ -65,7 +65,10 @@ SCIRUN_ADD_LIBRARY(Core_Math ) TARGET_LINK_LIBRARIES(Core_Math - Core_Exceptions_Legacy + PUBLIC + Boost::headers + PRIVATE + Core_Exceptions_Legacy ) IF(BUILD_SHARED_LIBS) diff --git a/src/Graphics/Datatypes/Tests/CMakeLists.txt b/src/Graphics/Datatypes/Tests/CMakeLists.txt index 98f67c0a11..39fc453eff 100644 --- a/src/Graphics/Datatypes/Tests/CMakeLists.txt +++ b/src/Graphics/Datatypes/Tests/CMakeLists.txt @@ -35,6 +35,7 @@ SCIRUN_ADD_UNIT_TEST(Graphics_Datatypes_Tests ) TARGET_LINK_LIBRARIES(Graphics_Datatypes_Tests + Core_Math gtest_main gtest gmock From 810286b6e68412e0ddc22cc73f2d41235da8192c Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 23 Apr 2026 16:53:16 -0600 Subject: [PATCH 105/140] made core_exception_legacy public in core_math --- src/Core/Math/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Core/Math/CMakeLists.txt b/src/Core/Math/CMakeLists.txt index d2122ace5b..a760c3bedf 100644 --- a/src/Core/Math/CMakeLists.txt +++ b/src/Core/Math/CMakeLists.txt @@ -67,7 +67,6 @@ SCIRUN_ADD_LIBRARY(Core_Math TARGET_LINK_LIBRARIES(Core_Math PUBLIC Boost::headers - PRIVATE Core_Exceptions_Legacy ) From b14d0c6770481850d5a5758d9055c47281e7dba5 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 24 Apr 2026 15:05:19 -0600 Subject: [PATCH 106/140] upated github action workflows to use vs2022 mostly --- .github/workflows/windows.yml | 51 +++++++++-------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 34ed686378..da1e8ab0aa 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -9,31 +9,6 @@ on: - 'docs/**' jobs: - windows-build-headless: - runs-on: windows-2019 - - steps: - - - name: Checkout - uses: actions/checkout@v6 - - - name: Configure - working-directory: bin - shell: cmd - run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" -Ax64 -DBUILD_HEADLESS:BOOL=ON -DBUILD_WITH_PYTHON:BOOL=OFF -DBUILD_TESTING:BOOL=ON - - - name: Compile - working-directory: bin - shell: cmd - run: cmake --build . --config Release -j 5 - - - name: Test - working-directory: bin/SCIRun - continue-on-error: true - shell: cmd - run: cmake --build . --target RUN_TESTS --config Release - windows-build-headless-2022: runs-on: windows-2022 @@ -85,7 +60,7 @@ jobs: run: cmake --build . --target RUN_TESTS --config Release windows-build-gui-qt5: - runs-on: windows-2019 + runs-on: windows-2022 steps: @@ -102,7 +77,7 @@ jobs: version: 5.15.2 target: desktop host: windows - arch: win64_msvc2019_64 + arch: win64_msvc2022_64 setup-python: 'true' install-deps: true @@ -112,7 +87,7 @@ jobs: - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" -DBUILD_WITH_PYTHON:BOOL=OFF + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" -DBUILD_WITH_PYTHON:BOOL=OFF - name: Compile working-directory: bin @@ -133,7 +108,7 @@ jobs: path: bin/SCIRun/SCIRun-5.0.*.exe windows-build-gui-qt6: - runs-on: windows-2019 + runs-on: windows-2022 steps: @@ -150,7 +125,7 @@ jobs: version: 6.3.* target: desktop host: windows - arch: win64_msvc2019_64 + arch: win64_msvc2022_64 setup-python: 'true' install-deps: true @@ -160,7 +135,7 @@ jobs: - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" -Ax64 -DSCIRUN_QT_MIN_VERSION:STRING="6.3.1" -DQt_PATH:PATH="$env:QT_ROOT_DIR" -DBUILD_WITH_PYTHON:BOOL=OFF + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DSCIRUN_QT_MIN_VERSION:STRING="6.3.1" -DQt_PATH:PATH="$env:QT_ROOT_DIR" -DBUILD_WITH_PYTHON:BOOL=OFF - name: Compile working-directory: bin @@ -181,7 +156,7 @@ jobs: path: bin/SCIRun/SCIRun-5.0.*.exe windows-build-gui-python: - runs-on: windows-2019 + runs-on: windows-2022 steps: @@ -198,14 +173,14 @@ jobs: version: 5.15.2 target: desktop host: windows - arch: win64_msvc2019_64 + arch: win64_msvc2022_64 setup-python: 'true' install-deps: true - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" - name: Compile working-directory: bin @@ -237,7 +212,7 @@ jobs: # bin/SCIRun/SCIRun-5.0.beta.*-win64.exe windows-build-gui-python-ospray: - runs-on: windows-2019 + runs-on: windows-2022 steps: @@ -254,14 +229,14 @@ jobs: version: 5.15.2 target: desktop host: windows - arch: win64_msvc2019_64 + arch: win64_msvc2022_64 setup-python: 'true' install-deps: true - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" -DWITH_OSPRAY:BOOL=ON + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" -DWITH_OSPRAY:BOOL=ON - name: Compile working-directory: bin @@ -297,7 +272,7 @@ jobs: # runs-on: ${{ matrix.os }} # strategy: # matrix: - # os: [windows-2022, windows-2019] + # os: [windows-2022, windows-2022] # qt: ["5.15.2", "6.3.1"] # hl: ["ON", "OFF"] # py: ["ON", "OFF"] From dd0301855a8696f71c20a7446713100d78c4ec8c Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 27 Apr 2026 12:07:17 -0600 Subject: [PATCH 107/140] updated ospray --- Superbuild/OsprayExternal.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 75ebb751c3..94337a5d8b 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -25,7 +25,7 @@ # DEALINGS IN THE SOFTWARE. SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(ospray_GIT_TAG "origin/scirun-build-2.10") +SET(ospray_GIT_TAG "scirun-ospray-v3.2.0-1") set(ospray_DEPENDENCIES) LIST(APPEND ospray_DEPENDENCIES GLM_external) From fbe37e0adddc5d05e44e7882be4ecdd73938794d Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 27 Apr 2026 14:03:04 -0600 Subject: [PATCH 108/140] updated opsray cmake --- Superbuild/OsprayExternal.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 94337a5d8b..18c69fe466 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -25,7 +25,7 @@ # DEALINGS IN THE SOFTWARE. SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(ospray_GIT_TAG "scirun-ospray-v3.2.0-1") +SET(ospray_GIT_TAG "v2.10.1") set(ospray_DEPENDENCIES) LIST(APPEND ospray_DEPENDENCIES GLM_external) From 6db5ddf070c5b666a78e0609e0fae726f65d1463 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 27 Apr 2026 16:37:00 -0600 Subject: [PATCH 109/140] python version on linux --- Superbuild/Superbuild.cmake | 45 ++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 0b6ea6b20d..5ca9ae734f 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -29,6 +29,32 @@ SET(compress_type "GIT" CACHE INTERNAL "") SET(ep_base "${CMAKE_BINARY_DIR}/Externals" CACHE INTERNAL "") +########################################### +# Force superbuild Python, prevent system Python binding +########################################### + +if(BUILD_WITH_PYTHON) + + # This is where PythonExternal.cmake will install Python + set(_SB_PYTHON_PREFIX "${ep_base}/Python_external") + + # Prevent CMake from picking up /usr/bin/python3.x + set(Python3_FIND_SYSTEM_ONLY OFF CACHE BOOL "" FORCE) + set(Python3_FIND_REGISTRY NEVER CACHE STRING "" FORCE) + set(Python3_FIND_UNVERSIONED_NAMES NEVER CACHE STRING "" FORCE) + set(Python3_FIND_STRATEGY LOCATION CACHE STRING "" FORCE) + + # Predeclare Python location (even before it exists) + set(Python3_ROOT_DIR "${_SB_PYTHON_PREFIX}" CACHE PATH "" FORCE) + + # These stop FindPython / FindPython3 from falling back + set(Python_ROOT_DIR "${_SB_PYTHON_PREFIX}" CACHE PATH "" FORCE) + + # Do NOT set Python3_EXECUTABLE yet — it doesn't exist during first configure + # We only block system discovery here. + +endif() + ########################################### # Set default CMAKE_BUILD_TYPE # if empty for Unix Makefile builds @@ -112,15 +138,16 @@ IF(NOT BUILD_HEADLESS) # ------------------------------------------------------------ # Platform-specific Qt auto-detection # ------------------------------------------------------------ - if(APPLE OR WIN32) + if(APPLE OR WIN32 OR (UNIX AND NOT APPLE)) - # If user did NOT set Qt_PATH or path is invalid → try auto-detect if(NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") if(APPLE) set(_qt_default "/Users/basisunus/Qt/6.10.2/macos") elseif(WIN32) set(_qt_default "C:/Qt/6.10.1/msvc2022_64") + elseif(UNIX) + set(_qt_default "$ENV{HOME}/Qt/6.11.0/gcc_64") endif() if(IS_DIRECTORY "${_qt_default}") @@ -128,16 +155,9 @@ IF(NOT BUILD_HEADLESS) "Qt_PATH not set or invalid — using auto-detected Qt: ${_qt_default}" ) - # Force-set Qt_PATH set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) - # -------------------------------------------------------- - # Auto-detect Qt version from directory structure - # - # Examples: - # macOS : /Users/.../Qt/6.10.2/macos - # Windows: C:/Qt/6.10.1/msvc2022_64 - # -------------------------------------------------------- + # Auto-detect Qt version from path get_filename_component(_qt_parent "${_qt_default}" DIRECTORY) get_filename_component(_qt_version "${_qt_parent}" NAME) @@ -146,19 +166,18 @@ IF(NOT BUILD_HEADLESS) CACHE STRING "Qt version" FORCE) string(REPLACE "." ";" SCIRUN_QT_MIN_VERSION_LIST - ${SCIRUN_QT_MIN_VERSION}) + ${SCIRUN_QT_MIN_VERSION}) list(GET SCIRUN_QT_MIN_VERSION_LIST 0 QT_VERSION_MAJOR) list(GET SCIRUN_QT_MIN_VERSION_LIST 1 QT_VERSION_MINOR) list(GET SCIRUN_QT_MIN_VERSION_LIST 2 QT_VERSION_PATCH) endif() - else() message(STATUS "Using user-provided Qt_PATH: ${Qt_PATH}") endif() - endif() # APPLE OR WIN32 + endif() # ------------------------------------------------------------ # Qt package discovery From e572b94dcef16a9541f354b7d193737ef32580bb Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 28 Apr 2026 12:40:42 -0600 Subject: [PATCH 110/140] ospray doc is private --- Superbuild/OsprayExternal.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 18c69fe466..602d79d3cd 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -36,6 +36,9 @@ ExternalProject_Add(Ospray_external DEPENDS ${ospray_DEPENDENCIES} GIT_REPOSITORY "https://github.com/CIBC-Internal/ospray.git" GIT_TAG ${ospray_GIT_TAG} + GIT_SUBMODULES "" + GIT_SUBMODULES_RECURSE OFF + PATCH_COMMAND "" INSTALL_DIR "" INSTALL_COMMAND "" @@ -44,6 +47,7 @@ ExternalProject_Add(Ospray_external -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DENABLE_OSPRAY_SUPERBUILD:BOOL=ON + -DOSPRAY_BUILD_DOCS:BOOL=OFF -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm -DBUILD_ISA_AVX512:BOOL=OFF ) From e434b86e4c054b92e0bd36dc7ba55388e6ec548f Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 28 Apr 2026 13:05:37 -0600 Subject: [PATCH 111/140] added rkcommon, which is needed by ospray --- Superbuild/OsprayExternal.cmake | 18 ++++++---- Superbuild/RKCommonExternal.cmake.txt | 47 +++++++++++++++++++++++++++ Superbuild/Superbuild.cmake | 3 +- 3 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 Superbuild/RKCommonExternal.cmake.txt diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 602d79d3cd..1df6497a73 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -28,7 +28,14 @@ SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) SET(ospray_GIT_TAG "v2.10.1") set(ospray_DEPENDENCIES) -LIST(APPEND ospray_DEPENDENCIES GLM_external) +set(ospray_DEPENDENCIES) +LIST(APPEND ospray_DEPENDENCIES + GLM_external + rkcommon_external +) + +ExternalProject_Get_Property(rkcommon_external INSTALL_DIR) +SET(RKCOMMON_INSTALL_DIR ${INSTALL_DIR}) # If CMake ever allows overriding the checkout command or adding flags, # git checkout -q will silence message about detached head (harmless). @@ -36,20 +43,19 @@ ExternalProject_Add(Ospray_external DEPENDS ${ospray_DEPENDENCIES} GIT_REPOSITORY "https://github.com/CIBC-Internal/ospray.git" GIT_TAG ${ospray_GIT_TAG} + GIT_SUBMODULES "" GIT_SUBMODULES_RECURSE OFF - PATCH_COMMAND "" - INSTALL_DIR "" - INSTALL_COMMAND "" CMAKE_CACHE_ARGS -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DENABLE_OSPRAY_SUPERBUILD:BOOL=ON - -DOSPRAY_BUILD_DOCS:BOOL=OFF - -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm -DBUILD_ISA_AVX512:BOOL=OFF + + -Drkcommon_DIR:PATH=${RKCOMMON_INSTALL_DIR}/lib/cmake/rkcommon + -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm ) ExternalProject_Get_Property(Ospray_external BINARY_DIR) diff --git a/Superbuild/RKCommonExternal.cmake.txt b/Superbuild/RKCommonExternal.cmake.txt new file mode 100644 index 0000000000..acad90f1c6 --- /dev/null +++ b/Superbuild/RKCommonExternal.cmake.txt @@ -0,0 +1,47 @@ +# For more information, please see: http://software.sci.utah.edu +# +# The MIT License +# +# Copyright (c) 2026 Scientific Computing and Imaging Institute, +# University of Utah. +# +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Superbuild/RKCommonExternal.cmake + +SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) + +SET(rkcommon_GIT_REPOSITORY + "https://github.com/ospray/rkcommon.git") +SET(rkcommon_GIT_TAG "v1.11.0") + +ExternalProject_Add(rkcommon_external + GIT_REPOSITORY ${rkcommon_GIT_REPOSITORY} + GIT_TAG ${rkcommon_GIT_TAG} + + UPDATE_COMMAND "" + PATCH_COMMAND "" + + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DBUILD_TESTING:BOOL=OFF +) +`` \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 5ca9ae734f..2154103d62 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -281,7 +281,8 @@ IF(WITH_TETGEN) ENDIF() IF(WITH_OSPRAY) - ADD_EXTERNAL( ${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external ) + INCLUDE(${SUPERBUILD_DIR}/RKCommonExternal.cmake) + ADD_EXTERNAL(${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external) ENDIF() IF(NOT BUILD_HEADLESS) From 5db225470e8e9fd413a045a481f9560c75792f07 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 28 Apr 2026 13:07:13 -0600 Subject: [PATCH 112/140] file name typo --- Superbuild/{RKCommonExternal.cmake.txt => RKCommonExternal.cmake} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Superbuild/{RKCommonExternal.cmake.txt => RKCommonExternal.cmake} (100%) diff --git a/Superbuild/RKCommonExternal.cmake.txt b/Superbuild/RKCommonExternal.cmake similarity index 100% rename from Superbuild/RKCommonExternal.cmake.txt rename to Superbuild/RKCommonExternal.cmake From 3737b552b4edc8a6a2aef8af4284147a3a53f6ed Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 28 Apr 2026 13:09:14 -0600 Subject: [PATCH 113/140] more typo --- Superbuild/RKCommonExternal.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/Superbuild/RKCommonExternal.cmake b/Superbuild/RKCommonExternal.cmake index acad90f1c6..fceb071329 100644 --- a/Superbuild/RKCommonExternal.cmake +++ b/Superbuild/RKCommonExternal.cmake @@ -44,4 +44,3 @@ ExternalProject_Add(rkcommon_external -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DBUILD_TESTING:BOOL=OFF ) -`` \ No newline at end of file From 972bba2733e6370afdd874023e1710e509ea7ac2 Mon Sep 17 00:00:00 2001 From: Wan Date: Tue, 28 Apr 2026 16:05:36 -0600 Subject: [PATCH 114/140] fixing ospray build --- Superbuild/EmbreeExternal.cmake | 59 +++++++++++++++++++ Superbuild/OsprayExternal.cmake | 15 ++++- Superbuild/RKCommonExternal.cmake | 15 +++-- Superbuild/Superbuild.cmake | 2 + Superbuild/TBBExternal.cmake | 47 +++++++++++++++ .../patches/embree-macos-bezier-fix.patch | 24 ++++++++ 6 files changed, 155 insertions(+), 7 deletions(-) create mode 100644 Superbuild/EmbreeExternal.cmake create mode 100644 Superbuild/TBBExternal.cmake create mode 100644 Superbuild/patches/embree-macos-bezier-fix.patch diff --git a/Superbuild/EmbreeExternal.cmake b/Superbuild/EmbreeExternal.cmake new file mode 100644 index 0000000000..a1d884bc8f --- /dev/null +++ b/Superbuild/EmbreeExternal.cmake @@ -0,0 +1,59 @@ +# For more information, please see: http://software.sci.utah.edu +# +# The MIT License +# +# Copyright (c) 2026 Scientific Computing and Imaging Institute, +# University of Utah. +# +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Superbuild/EmbreeExternal.cmake + +SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) + +set(EMBREE_GIT_REPOSITORY https://github.com/embree/embree.git) +set(EMBREE_GIT_TAG v3.13.4) # >= 4.0.0, stable + +ExternalProject_Add(Embree_external + DEPENDS TBB_external + + GIT_REPOSITORY ${EMBREE_GIT_REPOSITORY} + GIT_TAG ${EMBREE_GIT_TAG} + + UPDATE_COMMAND "" + PATCH_COMMAND + ${CMAKE_COMMAND} -E echo "Patching Embree for macOS Clang" && + git apply ${SUPERBUILD_DIR}/patches/embree-macos-bezier-fix.patch + + + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 + + -DEMBREE_TUTORIALS:BOOL=OFF + -DEMBREE_EXAMPLES:BOOL=OFF + -DEMBREE_TESTING:BOOL=OFF + -DEMBREE_ISPC_SUPPORT:BOOL=OFF + -DEMBREE_GEOMETRY_CURVE:BOOL=OFF + -DEMBREE_GEOMETRY_SUBDIVISION:BOOL=OFF + + -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} +) \ No newline at end of file diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 1df6497a73..410e4c4255 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -32,10 +32,17 @@ set(ospray_DEPENDENCIES) LIST(APPEND ospray_DEPENDENCIES GLM_external rkcommon_external + Embree_external ) ExternalProject_Get_Property(rkcommon_external INSTALL_DIR) -SET(RKCOMMON_INSTALL_DIR ${INSTALL_DIR}) +set(RKCOMMON_INSTALL_DIR ${INSTALL_DIR}) + +ExternalProject_Get_Property(TBB_external INSTALL_DIR) +set(TBB_INSTALL_DIR ${INSTALL_DIR}) + +ExternalProject_Get_Property(Embree_external INSTALL_DIR) +set(EMBREE_INSTALL_DIR ${INSTALL_DIR}) # If CMake ever allows overriding the checkout command or adding flags, # git checkout -q will silence message about detached head (harmless). @@ -53,8 +60,10 @@ ExternalProject_Add(Ospray_external -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DENABLE_OSPRAY_SUPERBUILD:BOOL=ON -DBUILD_ISA_AVX512:BOOL=OFF - - -Drkcommon_DIR:PATH=${RKCOMMON_INSTALL_DIR}/lib/cmake/rkcommon + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 + -Drkcommon_DIR:PATH=${RKCOMMON_INSTALL_DIR}/lib/cmake/rkcommon-1.11.0 + -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} + -Dembree_DIR:PATH=${EMBREE_INSTALL_DIR}/lib/cmake/embree-3.13.4 -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm ) diff --git a/Superbuild/RKCommonExternal.cmake b/Superbuild/RKCommonExternal.cmake index fceb071329..8326b7e26c 100644 --- a/Superbuild/RKCommonExternal.cmake +++ b/Superbuild/RKCommonExternal.cmake @@ -32,15 +32,22 @@ SET(rkcommon_GIT_REPOSITORY "https://github.com/ospray/rkcommon.git") SET(rkcommon_GIT_TAG "v1.11.0") +ExternalProject_Get_Property(TBB_external INSTALL_DIR) +set(TBB_INSTALL_DIR ${INSTALL_DIR}) + ExternalProject_Add(rkcommon_external - GIT_REPOSITORY ${rkcommon_GIT_REPOSITORY} - GIT_TAG ${rkcommon_GIT_TAG} + DEPENDS TBB_external + GIT_REPOSITORY https://github.com/ospray/rkcommon.git + GIT_TAG v1.11.0 UPDATE_COMMAND "" - PATCH_COMMAND "" + PATCH_COMMAND "" CMAKE_CACHE_ARGS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DBUILD_TESTING:BOOL=OFF -) + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 + -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} +) \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 2154103d62..322ed167ce 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -281,7 +281,9 @@ IF(WITH_TETGEN) ENDIF() IF(WITH_OSPRAY) + INCLUDE(${SUPERBUILD_DIR}/TBBExternal.cmake) INCLUDE(${SUPERBUILD_DIR}/RKCommonExternal.cmake) + INCLUDE(${SUPERBUILD_DIR}/EmbreeExternal.cmake) ADD_EXTERNAL(${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external) ENDIF() diff --git a/Superbuild/TBBExternal.cmake b/Superbuild/TBBExternal.cmake new file mode 100644 index 0000000000..610f4fa2f3 --- /dev/null +++ b/Superbuild/TBBExternal.cmake @@ -0,0 +1,47 @@ +# For more information, please see: http://software.sci.utah.edu +# +# The MIT License +# +# Copyright (c) 2026 Scientific Computing and Imaging Institute, +# University of Utah. +# +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +# Superbuild/TBBExternal.cmake + +SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) + +set(TBB_GIT_REPOSITORY "https://github.com/oneapi-src/oneTBB.git") +set(TBB_GIT_TAG "v2021.11.0") # Known-compatible with rkcommon 1.11 + +ExternalProject_Add(TBB_external + GIT_REPOSITORY ${TBB_GIT_REPOSITORY} + GIT_TAG ${TBB_GIT_TAG} + + UPDATE_COMMAND "" + PATCH_COMMAND "" + + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH= + -DTBB_TEST:BOOL=OFF + -DTBB_STRICT:BOOL=OFF + -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 +) \ No newline at end of file diff --git a/Superbuild/patches/embree-macos-bezier-fix.patch b/Superbuild/patches/embree-macos-bezier-fix.patch new file mode 100644 index 0000000000..bdbbd62feb --- /dev/null +++ b/Superbuild/patches/embree-macos-bezier-fix.patch @@ -0,0 +1,24 @@ +diff --git a/kernels/subdiv/bezier_curve.h b/kernels/subdiv/bezier_curve.h +index a5adad5cc..40a0f29ee 100644 +--- a/kernels/subdiv/bezier_curve.h ++++ b/kernels/subdiv/bezier_curve.h +@@ -134,8 +134,17 @@ namespace embree + return merge(BBox(v0),BBox(v1),BBox(v2)); + } + +- friend embree_ostream operator<<(embree_ostream cout, const QuadraticBezierCurve& a) { +- return cout << "QuadraticBezierCurve ( (" << a.u.lower << ", " << a.u.upper << "), " << a.v0 << ", " << a.v1 << ", " << a.v2 << ")"; ++ friend embree_ostream operator<<(embree_ostream cout, ++ const QuadraticBezierCurve& a) ++ { ++ #if defined(__APPLE__) ++ (void)a; ++ return cout; ++ #else ++ return cout << "QuadraticBezierCurve ( (" ++ << a.u.lower << ", " << a.u.upper << "), " ++ << a.v0 << ", " << a.v1 << ", " << a.v2 << ")"; ++ #endif + } + }; + From b13731967afc4be549c02b935e9711af0c544e16 Mon Sep 17 00:00:00 2001 From: Wan Date: Wed, 29 Apr 2026 11:54:59 -0600 Subject: [PATCH 115/140] embree not working with ospray --- Superbuild/EmbreeExternal.cmake | 5 +- Superbuild/OsprayExternal.cmake | 1 + .../patches/embree-macos-bezier-fix.patch | 24 - .../embree-macos-disable-debug-streams.patch | 460 ++++++++++++++++++ 4 files changed, 464 insertions(+), 26 deletions(-) delete mode 100644 Superbuild/patches/embree-macos-bezier-fix.patch create mode 100644 Superbuild/patches/embree-macos-disable-debug-streams.patch diff --git a/Superbuild/EmbreeExternal.cmake b/Superbuild/EmbreeExternal.cmake index a1d884bc8f..9e6ae3a9b5 100644 --- a/Superbuild/EmbreeExternal.cmake +++ b/Superbuild/EmbreeExternal.cmake @@ -39,8 +39,8 @@ ExternalProject_Add(Embree_external UPDATE_COMMAND "" PATCH_COMMAND - ${CMAKE_COMMAND} -E echo "Patching Embree for macOS Clang" && - git apply ${SUPERBUILD_DIR}/patches/embree-macos-bezier-fix.patch + git apply ${SUPERBUILD_DIR}/patches/embree-macos-disable-debug-streams.patch + CMAKE_CACHE_ARGS @@ -54,6 +54,7 @@ ExternalProject_Add(Embree_external -DEMBREE_ISPC_SUPPORT:BOOL=OFF -DEMBREE_GEOMETRY_CURVE:BOOL=OFF -DEMBREE_GEOMETRY_SUBDIVISION:BOOL=OFF + -DCMAKE_CXX_FLAGS=-DEMBREE_DISABLE_STREAM -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} ) \ No newline at end of file diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 410e4c4255..112d049cdb 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -64,6 +64,7 @@ ExternalProject_Add(Ospray_external -Drkcommon_DIR:PATH=${RKCOMMON_INSTALL_DIR}/lib/cmake/rkcommon-1.11.0 -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} -Dembree_DIR:PATH=${EMBREE_INSTALL_DIR}/lib/cmake/embree-3.13.4 + -DEMBREE_VERSION_REQUIRED:STRING=3.13.0 -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm ) diff --git a/Superbuild/patches/embree-macos-bezier-fix.patch b/Superbuild/patches/embree-macos-bezier-fix.patch deleted file mode 100644 index bdbbd62feb..0000000000 --- a/Superbuild/patches/embree-macos-bezier-fix.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/kernels/subdiv/bezier_curve.h b/kernels/subdiv/bezier_curve.h -index a5adad5cc..40a0f29ee 100644 ---- a/kernels/subdiv/bezier_curve.h -+++ b/kernels/subdiv/bezier_curve.h -@@ -134,8 +134,17 @@ namespace embree - return merge(BBox(v0),BBox(v1),BBox(v2)); - } - -- friend embree_ostream operator<<(embree_ostream cout, const QuadraticBezierCurve& a) { -- return cout << "QuadraticBezierCurve ( (" << a.u.lower << ", " << a.u.upper << "), " << a.v0 << ", " << a.v1 << ", " << a.v2 << ")"; -+ friend embree_ostream operator<<(embree_ostream cout, -+ const QuadraticBezierCurve& a) -+ { -+ #if defined(__APPLE__) -+ (void)a; -+ return cout; -+ #else -+ return cout << "QuadraticBezierCurve ( (" -+ << a.u.lower << ", " << a.u.upper << "), " -+ << a.v0 << ", " << a.v1 << ", " << a.v2 << ")"; -+ #endif - } - }; - diff --git a/Superbuild/patches/embree-macos-disable-debug-streams.patch b/Superbuild/patches/embree-macos-disable-debug-streams.patch new file mode 100644 index 0000000000..9c818ff0b6 --- /dev/null +++ b/Superbuild/patches/embree-macos-disable-debug-streams.patch @@ -0,0 +1,460 @@ +diff --git a/common/math/interval.h b/common/math/interval.h +index 310add212..81d8c453e 100644 +--- a/common/math/interval.h ++++ b/common/math/interval.h +@@ -70,10 +70,12 @@ namespace embree + __forceinline friend const Interval intersect( const Interval& a, const Interval& b ) { return Interval(max(a.lower, b.lower), min(a.upper, b.upper)); } + __forceinline friend const Interval intersect( const Interval& a, const Interval& b, const Interval& c ) { return intersect(a,intersect(b,c)); } + __forceinline friend const Interval intersect( const Interval& a, const Interval& b, const Interval& c, const Interval& d ) { return intersect(intersect(a,b),intersect(c,d)); } +- ++ ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const Interval& a) { + return cout << "[" << a.lower << ", " << a.upper << "]"; + } ++ #endif + + //////////////////////////////////////////////////////////////////////////////// + /// Constants +diff --git a/common/math/obbox.h b/common/math/obbox.h +index 2fe8bbf07..b27ba7a49 100644 +--- a/common/math/obbox.h ++++ b/common/math/obbox.h +@@ -25,9 +25,11 @@ namespace embree + __forceinline OBBox (const LinearSpace3& space, const BBox& bounds) + : space(space), bounds(bounds) {} + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const OBBox& p) { + return cout << "{ space = " << p.space << ", bounds = " << p.bounds << "}"; + } ++ #endif + + public: + LinearSpace3 space; //!< orthonormal transformation +diff --git a/common/math/range.h b/common/math/range.h +index 909fadb99..d65908c34 100644 +--- a/common/math/range.h ++++ b/common/math/range.h +@@ -74,9 +74,11 @@ namespace embree + return r0.size() < r1.size(); + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const range& r) { + return cout << "range [" << r.begin() << ", " << r.end() << "]"; + } ++ #endif + + Ty _begin, _end; + }; +@@ -128,9 +130,11 @@ namespace embree + _ext_end += plus; + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const extended_range& r) { + return cout << "extended_range [" << r.begin() << ", " << r.end() << " (" << r.ext_end() << ")]"; + } ++ #endif + + Ty _ext_end; + }; +diff --git a/kernels/builders/heuristic_binning.h b/kernels/builders/heuristic_binning.h +index 41be6183b..950fdf627 100644 +--- a/kernels/builders/heuristic_binning.h ++++ b/kernels/builders/heuristic_binning.h +@@ -99,10 +99,12 @@ namespace embree + return scale[dim] == 0.0f; + } + ++ #if !defined(__APPLE__) + /*! stream output */ + friend embree_ostream operator<<(embree_ostream cout, const BinMapping& mapping) { + return cout << "BinMapping { num = " << mapping.num << ", ofs = " << mapping.ofs << ", scale = " << mapping.scale << "}"; + } ++ #endif + + public: + size_t num; +@@ -140,9 +142,11 @@ namespace embree + __forceinline float splitSAH() const { return sah; } + + /*! stream output */ ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const BinSplit& split) { + return cout << "BinSplit { sah = " << split.sah << ", dim = " << split.dim << ", pos = " << split.pos << "}"; + } ++ #endif + + public: + float sah; //!< SAH cost of the split +diff --git a/kernels/builders/heuristic_spatial.h b/kernels/builders/heuristic_spatial.h +index 8b3499ac8..839db11e2 100644 +--- a/kernels/builders/heuristic_spatial.h ++++ b/kernels/builders/heuristic_spatial.h +@@ -100,9 +100,11 @@ namespace embree + __forceinline float splitSAH() const { return sah; } + + /*! stream output */ ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const SpatialBinSplit& split) { + return cout << "SpatialBinSplit { sah = " << split.sah << ", dim = " << split.dim << ", pos = " << split.pos << ", left = " << split.left << ", right = " << split.right << ", factor = " << split.factor << "}"; + } ++ #endif + + public: + float sah; //!< SAH cost of the split +diff --git a/kernels/builders/priminfo.h b/kernels/builders/priminfo.h +index fee515247..d4ca2d61b 100644 +--- a/kernels/builders/priminfo.h ++++ b/kernels/builders/priminfo.h +@@ -148,9 +148,11 @@ namespace embree + } + + /*! stream output */ ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const PrimInfoT& pinfo) { + return cout << "PrimInfo { begin = " << pinfo.begin << ", end = " << pinfo.end << ", geomBounds = " << pinfo.geomBounds << ", centBounds = " << pinfo.centBounds << "}"; + } ++ #endif + + public: + size_t begin,end; //!< number of primitives +@@ -240,6 +242,7 @@ namespace embree + } + + /*! stream output */ ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const PrimInfoMBT& pinfo) + { + return cout << "PrimInfo { " << +@@ -250,6 +253,7 @@ namespace embree + ", centBounds = " << pinfo.centBounds << + "}"; + } ++ #endif + + public: + range object_range; //!< primitive range +diff --git a/kernels/bvh/bvh_node_aabb.h b/kernels/bvh/bvh_node_aabb.h +index 3fd9fc7d1..dc7e8e82d 100644 +--- a/kernels/bvh/bvh_node_aabb.h ++++ b/kernels/bvh/bvh_node_aabb.h +@@ -196,6 +196,7 @@ namespace embree + __forceinline const NodeRef& child(size_t i) const { assert(i lower_x; //!< X dimension of lower bounds of all N children. +diff --git a/kernels/bvh/bvh_node_aabb_mb.h b/kernels/bvh/bvh_node_aabb_mb.h +index 001f526c2..b436580e6 100644 +--- a/kernels/bvh/bvh_node_aabb_mb.h ++++ b/kernels/bvh/bvh_node_aabb_mb.h +@@ -221,6 +221,7 @@ namespace embree + __forceinline const NodeRef& child(size_t i) const { assert(i lower_x; //!< X dimension of lower bounds of all N children. +diff --git a/kernels/bvh/bvh_node_aabb_mb4d.h b/kernels/bvh/bvh_node_aabb_mb4d.h +index 3b966fd05..6b946e50c 100644 +--- a/kernels/bvh/bvh_node_aabb_mb4d.h ++++ b/kernels/bvh/bvh_node_aabb_mb4d.h +@@ -91,6 +91,7 @@ namespace embree + } + + /*! stream output operator */ ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const AABBNodeMB4D_t& n) + { + cout << "AABBNodeMB4D {" << embree_endl; +@@ -107,6 +108,7 @@ namespace embree + cout << "}"; + return cout; + } ++ #endif + + public: + vfloat lower_t; //!< time dimension of lower bounds of all N children +diff --git a/kernels/bvh/bvh_node_obb.h b/kernels/bvh/bvh_node_obb.h +index e6b500691..770b9a8b5 100644 +--- a/kernels/bvh/bvh_node_obb.h ++++ b/kernels/bvh/bvh_node_obb.h +@@ -86,11 +86,13 @@ namespace embree + __forceinline const NodeRef& child(size_t i) const { assert(i naabb; //!< non-axis aligned bounding boxes (bounds are [0,1] in specified space) +diff --git a/kernels/bvh/bvh_node_qaabb.h b/kernels/bvh/bvh_node_qaabb.h +index 99671ddc5..b1c87756e 100644 +--- a/kernels/bvh/bvh_node_qaabb.h ++++ b/kernels/bvh/bvh_node_qaabb.h +@@ -132,6 +132,7 @@ namespace embree + Vec3f start; + Vec3f scale; + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream o, const QuantizedBaseNode_t& n) + { + o << "QuantizedBaseNode { " << embree_endl; +@@ -146,6 +147,7 @@ namespace embree + o << "}" << embree_endl; + return o; + } ++ #endif + + }; + +diff --git a/kernels/common/scene_grid_mesh.h b/kernels/common/scene_grid_mesh.h +index fb6fed445..61078d370 100644 +--- a/kernels/common/scene_grid_mesh.h ++++ b/kernels/common/scene_grid_mesh.h +@@ -34,9 +34,11 @@ namespace embree + } + + /*! outputs grid structure */ ++ #if !defined(__APPLE__) + __forceinline friend embree_ostream operator<<(embree_ostream cout, const Grid& t) { + return cout << "Grid { startVtxID " << t.startVtxID << ", lineVtxOffset " << t.lineVtxOffset << ", resX " << t.resX << ", resY " << t.resY << " }"; + } ++ #endif + }; + + public: +diff --git a/kernels/common/scene_quad_mesh.h b/kernels/common/scene_quad_mesh.h +index bd8eeaaeb..296d6c2f3 100644 +--- a/kernels/common/scene_quad_mesh.h ++++ b/kernels/common/scene_quad_mesh.h +@@ -20,9 +20,11 @@ namespace embree + uint32_t v[4]; + + /*! outputs triangle indices */ ++ #if !defined(__APPLE__) + __forceinline friend embree_ostream operator<<(embree_ostream cout, const Quad& q) { + return cout << "Quad {" << q.v[0] << ", " << q.v[1] << ", " << q.v[2] << ", " << q.v[3] << " }"; + } ++ #endif + }; + + public: +diff --git a/kernels/common/scene_triangle_mesh.h b/kernels/common/scene_triangle_mesh.h +index ad3f602fd..3524466cd 100644 +--- a/kernels/common/scene_triangle_mesh.h ++++ b/kernels/common/scene_triangle_mesh.h +@@ -20,9 +20,11 @@ namespace embree + uint32_t v[3]; + + /*! outputs triangle indices */ ++ #if !defined(__APPLE__) + __forceinline friend embree_ostream operator<<(embree_ostream cout, const Triangle& t) { + return cout << "Triangle { " << t.v[0] << ", " << t.v[1] << ", " << t.v[2] << " }"; + } ++ #endif + }; + + public: +diff --git a/kernels/geometry/pointi.h b/kernels/geometry/pointi.h +index bed04116b..ce49d6565 100644 +--- a/kernels/geometry/pointi.h ++++ b/kernels/geometry/pointi.h +@@ -210,10 +210,12 @@ namespace embree + }; + + /*! output operator */ ++ #if !defined(__APPLE__) + friend __forceinline embree_ostream operator<<(embree_ostream cout, const PointMi& line) + { + return cout << "Line" << M << "i {" << line.v0 << ", " << line.geomID() << ", " << line.primID() << "}"; + } ++ #endif + + public: + unsigned char gtype; +diff --git a/kernels/geometry/quadi.h b/kernels/geometry/quadi.h +index 70a7bdf15..f2a5e4261 100644 +--- a/kernels/geometry/quadi.h ++++ b/kernels/geometry/quadi.h +@@ -159,6 +159,7 @@ namespace embree + return linearBounds(scene, time_range); + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const QuadMi& quad) { + return cout << "QuadMi<" << M << ">( " + #if !defined(EMBREE_COMPACT_POLYS) +@@ -166,6 +167,7 @@ namespace embree + #endif + << "geomID = " << quad.geomIDs << ", primID = " << quad.primIDs << " )"; + } ++ #endif + + protected: + #if !defined(EMBREE_COMPACT_POLYS) +diff --git a/kernels/geometry/subgrid.h b/kernels/geometry/subgrid.h +index ce54421ca..ed5b98333 100644 +--- a/kernels/geometry/subgrid.h ++++ b/kernels/geometry/subgrid.h +@@ -281,11 +281,11 @@ namespace embree + return allBounds; + } + +- ++#if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const SubGrid& sg) { + return cout << "SubGrid " << " ( x " << sg.x() << ", y = " << sg.y() << ", geomID = " << sg.geomID() << ", primID = " << sg.primID() << " )"; + } +- ++#endif + __forceinline unsigned int geomID() const { return _geomID; } + __forceinline unsigned int primID() const { return _primID; } + __forceinline unsigned int x() const { return (unsigned int)_x & 0x7fff; } +@@ -379,7 +379,7 @@ namespace embree + + unsigned int _geomID; // geometry ID of mesh + +- ++#if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const SubGridQBVHN& sg) { + cout << "SubGridQBVHN " << embree_endl; + for (size_t i=0;i +@@ -489,7 +489,7 @@ namespace embree + float time_scale; + unsigned int _geomID; // geometry ID of mesh + +- ++#if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const SubGridMBQBVHN& sg) { + cout << "SubGridMBQBVHN " << embree_endl; + for (size_t i=0;i __forceinline bool LinearBezierCurve::hasRoot() const { +@@ -134,9 +136,11 @@ namespace embree + return merge(BBox(v0),BBox(v1),BBox(v2)); + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const QuadraticBezierCurve& a) { + return cout << "QuadraticBezierCurve ( (" << a.u.lower << ", " << a.u.upper << "), " << a.v0 << ", " << a.v1 << ", " << a.v2 << ")"; + } ++ #endif + }; + + +diff --git a/kernels/subdiv/gregory_patch.h b/kernels/subdiv/gregory_patch.h +index 9026d5c40..757ad5d9f 100644 +--- a/kernels/subdiv/gregory_patch.h ++++ b/kernels/subdiv/gregory_patch.h +@@ -841,6 +841,7 @@ namespace embree + return bounds; + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream o, const GregoryPatchT& p) + { + for (size_t y=0; y<4; y++) +@@ -852,6 +853,7 @@ namespace embree + o << "f[" << y << "][" << x << "] " << p.f[y][x] << embree_endl; + return o; + } ++ #endif + }; + + typedef GregoryPatchT GregoryPatch3fa; +diff --git a/kernels/subdiv/linear_bezier_patch.h b/kernels/subdiv/linear_bezier_patch.h +index dcdb101d7..a3d48cee6 100644 +--- a/kernels/subdiv/linear_bezier_patch.h ++++ b/kernels/subdiv/linear_bezier_patch.h +@@ -231,6 +231,7 @@ namespace embree + return (R.begin()-L.begin())+(R.end()-L.end()); + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const TensorLinearCubicBezierSurface& a) + { + return cout << "TensorLinearCubicBezierSurface" << embree_endl +@@ -239,6 +240,7 @@ namespace embree + << " R = " << a.R << embree_endl + << "}"; + } ++ #endif + + friend __forceinline TensorLinearCubicBezierSurface clerp(const TensorLinearCubicBezierSurface& a, const TensorLinearCubicBezierSurface& b, const float t) { + return TensorLinearCubicBezierSurface(clerp(a.L,b.L,V(t)), clerp(a.R,b.R,V(t))); +@@ -386,6 +388,7 @@ namespace embree + return (R.begin()-L.begin())+(R.end()-L.end()); + } + ++ #if !defined(__APPLE__) + friend embree_ostream operator<<(embree_ostream cout, const TensorLinearCubicBezierSurface& a) + { + return cout << "TensorLinearCubicBezierSurface" << embree_endl +@@ -394,6 +397,7 @@ namespace embree + << " R = " << a.getR() << embree_endl + << "}"; + } ++ #endif + }; + + typedef TensorLinearCubicBezierSurface TensorLinearCubicBezierSurface1f; From 2f9b61b376b624aae93d6ec42f9b5be5c898084e Mon Sep 17 00:00:00 2001 From: Wan Date: Wed, 29 Apr 2026 12:09:26 -0600 Subject: [PATCH 116/140] ospary patch --- Superbuild/OsprayExternal.cmake | 3 ++ .../patches/ospray-macos-allow-embree3.patch | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Superbuild/patches/ospray-macos-allow-embree3.patch diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index 112d049cdb..c8b4aa8181 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -51,6 +51,9 @@ ExternalProject_Add(Ospray_external GIT_REPOSITORY "https://github.com/CIBC-Internal/ospray.git" GIT_TAG ${ospray_GIT_TAG} + PATCH_COMMAND + git apply ${SUPERBUILD_DIR}/patches/ospray-macos-allow-embree3.patch + GIT_SUBMODULES "" GIT_SUBMODULES_RECURSE OFF diff --git a/Superbuild/patches/ospray-macos-allow-embree3.patch b/Superbuild/patches/ospray-macos-allow-embree3.patch new file mode 100644 index 0000000000..9565518d18 --- /dev/null +++ b/Superbuild/patches/ospray-macos-allow-embree3.patch @@ -0,0 +1,31 @@ +diff --git a/cmake/ospray_macros.cmake b/cmake/ospray_macros.cmake +index f581f3ecf..d93c00f1d 100644 +--- a/cmake/ospray_macros.cmake ++++ b/cmake/ospray_macros.cmake +@@ -422,12 +422,20 @@ macro(ospray_find_embree EMBREE_VERSION_REQUIRED FIND_AS_DEPENDENCY) + find_package(embree ${EMBREE_VERSION_REQUIRED}) + endif() + if (NOT embree_FOUND) +- message(FATAL_ERROR +- "We did not find Embree installed on your system. OSPRay requires" +- " an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please" +- " download and extract Embree (or compile Embree from source), then" +- " set the 'embree_DIR' variable to the installation (or build)" +- " directory.") ++ if (APPLE) ++ message(WARNING ++ "Using Embree < v${EMBREE_VERSION_REQUIRED} on macOS. " ++ "OSPRay upstream requires Embree >= v${EMBREE_VERSION_REQUIRED}, " ++ "but Embree 4.x is unstable with Apple Clang. " ++ "Proceeding with the provided Embree installation.") ++ else() ++ message(FATAL_ERROR ++ "We did not find Embree installed on your system. OSPRay requires" ++ " an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please" ++ " download and extract Embree (or compile Embree from source), then" ++ " set the 'embree_DIR' variable to the installation (or build)" ++ " directory.") ++ endif() + endif() + # Get Embree CPU info + get_target_property(EMBREE_INCLUDE_DIRS embree From b68d9fb0f91550a642bdf6ce5b622000f32aaee6 Mon Sep 17 00:00:00 2001 From: Wan Date: Wed, 29 Apr 2026 13:24:24 -0600 Subject: [PATCH 117/140] ospray not building --- Superbuild/OsprayExternal.cmake | 5 +- .../patches/ospray-macos-allow-embree3.patch | 31 ----- .../patches/ospray-macos-embree-policy.patch | 108 ++++++++++++++++++ 3 files changed, 111 insertions(+), 33 deletions(-) delete mode 100644 Superbuild/patches/ospray-macos-allow-embree3.patch create mode 100644 Superbuild/patches/ospray-macos-embree-policy.patch diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index c8b4aa8181..a2798f3171 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -52,8 +52,8 @@ ExternalProject_Add(Ospray_external GIT_TAG ${ospray_GIT_TAG} PATCH_COMMAND - git apply ${SUPERBUILD_DIR}/patches/ospray-macos-allow-embree3.patch - + git apply ${SUPERBUILD_DIR}/patches/ospray-macos-embree-policy.patch + GIT_SUBMODULES "" GIT_SUBMODULES_RECURSE OFF @@ -68,6 +68,7 @@ ExternalProject_Add(Ospray_external -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} -Dembree_DIR:PATH=${EMBREE_INSTALL_DIR}/lib/cmake/embree-3.13.4 -DEMBREE_VERSION_REQUIRED:STRING=3.13.0 + -DOSPRAY_ENABLE_ISPC:BOOL=OFF -Dglm_DIR:PATH=${GLM_DIR}/cmake/glm ) diff --git a/Superbuild/patches/ospray-macos-allow-embree3.patch b/Superbuild/patches/ospray-macos-allow-embree3.patch deleted file mode 100644 index 9565518d18..0000000000 --- a/Superbuild/patches/ospray-macos-allow-embree3.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/cmake/ospray_macros.cmake b/cmake/ospray_macros.cmake -index f581f3ecf..d93c00f1d 100644 ---- a/cmake/ospray_macros.cmake -+++ b/cmake/ospray_macros.cmake -@@ -422,12 +422,20 @@ macro(ospray_find_embree EMBREE_VERSION_REQUIRED FIND_AS_DEPENDENCY) - find_package(embree ${EMBREE_VERSION_REQUIRED}) - endif() - if (NOT embree_FOUND) -- message(FATAL_ERROR -- "We did not find Embree installed on your system. OSPRay requires" -- " an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please" -- " download and extract Embree (or compile Embree from source), then" -- " set the 'embree_DIR' variable to the installation (or build)" -- " directory.") -+ if (APPLE) -+ message(WARNING -+ "Using Embree < v${EMBREE_VERSION_REQUIRED} on macOS. " -+ "OSPRay upstream requires Embree >= v${EMBREE_VERSION_REQUIRED}, " -+ "but Embree 4.x is unstable with Apple Clang. " -+ "Proceeding with the provided Embree installation.") -+ else() -+ message(FATAL_ERROR -+ "We did not find Embree installed on your system. OSPRay requires" -+ " an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please" -+ " download and extract Embree (or compile Embree from source), then" -+ " set the 'embree_DIR' variable to the installation (or build)" -+ " directory.") -+ endif() - endif() - # Get Embree CPU info - get_target_property(EMBREE_INCLUDE_DIRS embree diff --git a/Superbuild/patches/ospray-macos-embree-policy.patch b/Superbuild/patches/ospray-macos-embree-policy.patch new file mode 100644 index 0000000000..0b24b15e5e --- /dev/null +++ b/Superbuild/patches/ospray-macos-embree-policy.patch @@ -0,0 +1,108 @@ +diff --git a/cmake/ospray_macros.cmake b/cmake/ospray_macros.cmake +index f581f3ecf..a452f6eb6 100644 +--- a/cmake/ospray_macros.cmake ++++ b/cmake/ospray_macros.cmake +@@ -389,15 +389,34 @@ endmacro() + + function(ospray_check_embree_feature FEATURE DESCRIPTION) + set(FEATURE EMBREE_${FEATURE}) +- if(NOT ${ARGN}) ++ ++ if (NOT ${ARGN}) ++ # Require FEATURE = OFF + if (${FEATURE}) +- message(FATAL_ERROR "OSPRay requires Embree to be compiled " +- "without ${DESCRIPTION} (${FEATURE}=OFF).") ++ if (APPLE) ++ message(WARNING ++ "Embree feature ${FEATURE} is enabled on macOS, " ++ "but OSPRay upstream expects it to be OFF. " ++ "Proceeding on macOS.") ++ else() ++ message(FATAL_ERROR ++ "OSPRay requires Embree to be compiled without " ++ "${DESCRIPTION} (${FEATURE}=OFF).") ++ endif() + endif() + else() ++ # Require FEATURE = ON + if (NOT ${FEATURE}) +- message(FATAL_ERROR "OSPRay requires Embree to be compiled " +- "with support for ${DESCRIPTION} (${FEATURE}=ON).") ++ if (APPLE) ++ message(WARNING ++ "Embree was built without support for ${DESCRIPTION} " ++ "(${FEATURE}=OFF) on macOS. " ++ "Proceeding without this feature.") ++ else() ++ message(FATAL_ERROR ++ "OSPRay requires Embree to be compiled with support for " ++ "${DESCRIPTION} (${FEATURE}=ON).") ++ endif() + endif() + endif() + endfunction() +@@ -416,34 +435,55 @@ function(ospray_verify_embree_features) + endfunction() + + macro(ospray_find_embree EMBREE_VERSION_REQUIRED FIND_AS_DEPENDENCY) ++ ++ # Find Embree + if (${FIND_AS_DEPENDENCY}) + find_dependency(embree ${EMBREE_VERSION_REQUIRED}) + else() + find_package(embree ${EMBREE_VERSION_REQUIRED}) + endif() ++ ++ # Handle missing / unsupported Embree + if (NOT embree_FOUND) +- message(FATAL_ERROR +- "We did not find Embree installed on your system. OSPRay requires" +- " an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please" +- " download and extract Embree (or compile Embree from source), then" +- " set the 'embree_DIR' variable to the installation (or build)" +- " directory.") ++ if (APPLE) ++ message(WARNING ++ "Using Embree < v${EMBREE_VERSION_REQUIRED} on macOS. " ++ "OSPRay upstream requires Embree >= v${EMBREE_VERSION_REQUIRED}, " ++ "but Embree 4.x is unstable with Apple Clang. " ++ "Proceeding with the provided Embree installation.") ++ return() # ✅ CRITICAL: stop before touching 'embree' target ++ else() ++ message(FATAL_ERROR ++ "We did not find Embree installed on your system. OSPRay requires " ++ "an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please " ++ "download and extract Embree (or compile Embree from source), then " ++ "set the 'embree_DIR' variable to the installation (or build) " ++ "directory.") ++ endif() + endif() ++ ++ # ------------------------------- ++ # From here on, the 'embree' target EXISTS ++ # ------------------------------- ++ + # Get Embree CPU info + get_target_property(EMBREE_INCLUDE_DIRS embree + INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(CONFIGURATIONS embree IMPORTED_CONFIGURATIONS) + list(GET CONFIGURATIONS 0 CONFIGURATION) + get_target_property(EMBREE_LIBRARY embree +- IMPORTED_LOCATION_${CONFIGURATION}) +- # Get Embree SYCL info if DPCPP was enabled ++ IMPORTED_LOCATION_${CONFIGURATION}) ++ ++ # Get Embree SYCL info if enabled + if (EMBREE_SYCL_SUPPORT) + get_target_property(CONFIGURATIONS embree_sycl IMPORTED_CONFIGURATIONS) + list(GET CONFIGURATIONS 0 CONFIGURATION) + get_target_property(EMBREE_SYCL_LIBRARY embree_sycl + IMPORTED_LOCATION_${CONFIGURATION}) + endif() ++ + message(STATUS "Found Embree v${embree_VERSION}: ${EMBREE_LIBRARY}") ++ + endmacro() + + macro(ospray_determine_embree_isa_support) From b0c40e88239b6bddfda92db1fca061ddddbd50a8 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 29 Apr 2026 14:34:43 -0600 Subject: [PATCH 118/140] windows github workflows updates --- .github/workflows/windows.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index da1e8ab0aa..d9777dfc89 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -78,7 +78,7 @@ jobs: target: desktop host: windows arch: win64_msvc2022_64 - setup-python: 'true' + setup-python: 'false' install-deps: true - name: Print out Qt directory @@ -122,11 +122,11 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' with: - version: 6.3.* + version: 6.10.0 target: desktop host: windows arch: win64_msvc2022_64 - setup-python: 'true' + setup-python: 'false' install-deps: true - name: Print out Qt directory @@ -170,17 +170,17 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' with: - version: 5.15.2 + version: 6.10.0 target: desktop host: windows arch: win64_msvc2022_64 - setup-python: 'true' + setup-python: 'false' install-deps: true - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt6_Dir" - name: Compile working-directory: bin @@ -226,17 +226,17 @@ jobs: env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' with: - version: 5.15.2 + version: 6.10.0 target: desktop host: windows arch: win64_msvc2022_64 - setup-python: 'true' + setup-python: 'false' install-deps: true - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt5_Dir" -DWITH_OSPRAY:BOOL=ON + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt6_Dir" -DWITH_OSPRAY:BOOL=ON - name: Compile working-directory: bin From c962db97a61fe8458b001f1b7cd9f1cf1c863b6f Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 29 Apr 2026 14:41:31 -0600 Subject: [PATCH 119/140] windows workflow --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d9777dfc89..a05314d210 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -180,7 +180,7 @@ jobs: - name: Configure working-directory: bin run: | - cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DQt_PATH:PATH="$env:Qt6_Dir" + cmake ..\Superbuild -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 17 2022" -Ax64 -DSCIRUN_QT_MIN_VERSION:STRING="6.3.1" -DQt_PATH:PATH="$env:QT_ROOT_DIR" - name: Compile working-directory: bin From 249b818c944293e605926865cdf0e6a60f380cb0 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 29 Apr 2026 15:26:45 -0600 Subject: [PATCH 120/140] fixed python path on linux --- Superbuild/PythonExternal.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Superbuild/PythonExternal.cmake b/Superbuild/PythonExternal.cmake index 9eac14c6ef..5a644ddc01 100644 --- a/Superbuild/PythonExternal.cmake +++ b/Superbuild/PythonExternal.cmake @@ -67,6 +67,7 @@ IF(UNIX) SET(python_CONFIGURE_FLAGS "--prefix=" "--with-ensurepip=no" + "LDFLAGS=-Wl,-rpath,'$$ORIGIN/../lib'" ) IF(APPLE) # framework contains *.dylib From 5f5f0247ab06461a5a0c34a2321e987c524ddce2 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 30 Apr 2026 11:15:31 -0600 Subject: [PATCH 121/140] linux linking flag for boost python --- Superbuild/BoostExternal.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Superbuild/BoostExternal.cmake b/Superbuild/BoostExternal.cmake index d34ee85973..ad01ff08b5 100644 --- a/Superbuild/BoostExternal.cmake +++ b/Superbuild/BoostExternal.cmake @@ -305,6 +305,8 @@ else() endif() set(_BOOST_B2_ARGS + ${_BOOST_CXXFLAGS} + --with-atomic --with-chrono --with-date_time From c91b183269db797a25f1216f951c45acb9c2971d Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 30 Apr 2026 14:56:32 -0600 Subject: [PATCH 122/140] windows test failure on core_containers because it doesn't export symbols. solution is to force it. --- src/Core/Containers/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Core/Containers/CMakeLists.txt b/src/Core/Containers/CMakeLists.txt index 985d78fb21..25b49432a2 100644 --- a/src/Core/Containers/CMakeLists.txt +++ b/src/Core/Containers/CMakeLists.txt @@ -47,6 +47,13 @@ SCIRUN_ADD_LIBRARY(Core_Containers ${Core_Containers_HEADERS} ) +if(WIN32 AND BUILD_SHARED_LIBS) + set_target_properties(Core_Containers + PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS ON + ) +endif(WIN32) + TARGET_LINK_LIBRARIES(Core_Containers PUBLIC Boost::headers From b506234cc36f78bf21810395770e6a33b3b26e47 Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 30 Apr 2026 15:31:24 -0600 Subject: [PATCH 123/140] typo --- src/Core/Containers/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Containers/CMakeLists.txt b/src/Core/Containers/CMakeLists.txt index 25b49432a2..9d2c889a60 100644 --- a/src/Core/Containers/CMakeLists.txt +++ b/src/Core/Containers/CMakeLists.txt @@ -52,7 +52,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) -endif(WIN32) +endif(WIN32 AND BUILD_SHARED_LIBS) TARGET_LINK_LIBRARIES(Core_Containers PUBLIC From c0c8b9e4b82412877660ae36641a27faf641e8fa Mon Sep 17 00:00:00 2001 From: basisunus Date: Thu, 30 Apr 2026 15:32:26 -0600 Subject: [PATCH 124/140] cmake --- src/Core/Containers/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Containers/CMakeLists.txt b/src/Core/Containers/CMakeLists.txt index 9d2c889a60..51983aff94 100644 --- a/src/Core/Containers/CMakeLists.txt +++ b/src/Core/Containers/CMakeLists.txt @@ -52,7 +52,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON ) -endif(WIN32 AND BUILD_SHARED_LIBS) +endif() TARGET_LINK_LIBRARIES(Core_Containers PUBLIC From ffc3c793cf7471978f4615378c8647c97bed532a Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 1 May 2026 12:11:07 -0600 Subject: [PATCH 125/140] disabled tests for core logging similar to applications because of the link errors of unexported symbols (singlton::instance_) in dlls --- src/Core/Logging/Tests/Log4cppWrapperTests.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Core/Logging/Tests/Log4cppWrapperTests.cc b/src/Core/Logging/Tests/Log4cppWrapperTests.cc index 717eb8dedc..3ef814c562 100644 --- a/src/Core/Logging/Tests/Log4cppWrapperTests.cc +++ b/src/Core/Logging/Tests/Log4cppWrapperTests.cc @@ -28,6 +28,8 @@ #include +/// @todo: this won't link in debug mode due to Logging::Instance impl +#if NDEBUG #include #include #include @@ -198,3 +200,4 @@ void err_handler_example() }); // (or logger->set_error_handler(..) to set for specific logger) } +#endif From f4fbadde1c3f4a0182fbfba10e6d481da3d0ee53 Mon Sep 17 00:00:00 2001 From: basisunus Date: Fri, 1 May 2026 15:27:32 -0600 Subject: [PATCH 126/140] removed qwt from cpack install because it's built static --- src/Main/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index dca07858bd..46c98a695d 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -217,7 +217,7 @@ ELSE() ${QTOPENGLWIDGETSNAME} DESTINATION bin) endif() - INSTALL(PROGRAMS "${SCI_QWT_LIBRARY_DIR}/Release/${SCI_QWT_LIBRARY}.dll" DESTINATION bin CONFIGURATIONS Release) + #INSTALL(PROGRAMS "${SCI_QWT_LIBRARY_DIR}/Release/${SCI_QWT_LIBRARY}.dll" DESTINATION bin CONFIGURATIONS Release) INSTALL(PROGRAMS "${Qt_PATH}/plugins/platforms/qwindows.dll" DESTINATION bin/platforms CONFIGURATIONS Release) ENDIF() IF(BUILD_WITH_PYTHON) From f84b512c110757db909c4dc27a0835b88afcdc08 Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 4 May 2026 12:35:54 -0600 Subject: [PATCH 127/140] division by zero at drawing progress bar --- src/Interface/Application/NetworkExecutionProgressBar.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Interface/Application/NetworkExecutionProgressBar.cc b/src/Interface/Application/NetworkExecutionProgressBar.cc index 1824c167d5..0788f17868 100644 --- a/src/Interface/Application/NetworkExecutionProgressBar.cc +++ b/src/Interface/Application/NetworkExecutionProgressBar.cc @@ -155,8 +155,12 @@ void SCIRunProgressBar::paintEvent(QPaintEvent*) //qDebug() << "done modules: green" << status_->finished() << "red" << status_->errored(); auto finished = status_->finished(); auto errored = status_->errored(); + auto totalDone = finished + errored; - auto fracFinished = (static_cast(finished) / (finished + errored)) * pos; + auto fracFinished = 0.0; + + if (totalDone > 0) + fracFinished = (static_cast(finished) / totalDone) * pos; p.setPen(Qt::green); p.setBrush(QBrush(Qt::green)); From 929c65719868015c899c9db59a286b3af7e521fd Mon Sep 17 00:00:00 2001 From: basisunus Date: Mon, 4 May 2026 13:15:44 -0600 Subject: [PATCH 128/140] scale bar crash --- src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc | 3 +++ src/Interface/Modules/Render/ES/SRInterface.cc | 1 + 2 files changed, 4 insertions(+) diff --git a/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc b/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc index 00bc1c0398..2013045218 100644 --- a/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc +++ b/src/Interface/Application/SCIRunMainWindowSlotsPrivate.cc @@ -416,6 +416,9 @@ void SCIRunMainWindow::handleCheckedModuleEntry(QTreeWidgetItem* item, int colum { if (item && 0 == column) { + Q_ASSERT(moduleSelectorTreeWidget_); + Q_ASSERT(item); + moduleSelectorTreeWidget_->setCurrentItem(item); auto faves = item->foreground(0) == CLIPBOARD_COLOR ? getSavedSubnetworksMenu() : getFavoriteMenu(); diff --git a/src/Interface/Modules/Render/ES/SRInterface.cc b/src/Interface/Modules/Render/ES/SRInterface.cc index efe87e2e1e..86042141a2 100644 --- a/src/Interface/Modules/Render/ES/SRInterface.cc +++ b/src/Interface/Modules/Render/ES/SRInterface.cc @@ -1214,6 +1214,7 @@ glm::vec2 ScreenParams::positionFromClick(int x, int y) const void SRInterface::addTextToEntity(uint64_t entityID, const SpireText& text) { if (text.name.empty()) return; + if (text.width == 0 || text.height == 0 || text.bitmap.empty()) return; std::weak_ptr tm = mCore.getStaticComponent()->instance_; std::shared_ptr textureMan = tm.lock(); if (!textureMan) return; From a844a8e639a17056248616467722f8a52df7c5a8 Mon Sep 17 00:00:00 2001 From: basisunus Date: Tue, 5 May 2026 15:27:42 -0600 Subject: [PATCH 129/140] updated based on dan's comments --- Superbuild/BoostConfig.cmake.in | 2 +- Superbuild/EmbreeExternal.cmake | 60 --- Superbuild/OsprayExternal.cmake | 5 +- Superbuild/RKCommonExternal.cmake | 53 -- Superbuild/Superbuild.cmake | 86 ++-- Superbuild/TBBExternal.cmake | 47 -- Superbuild/TnyWriteConfig.cmake | 4 - .../embree-macos-disable-debug-streams.patch | 460 ------------------ .../patches/ospray-macos-embree-policy.patch | 108 ---- scripts/clean-boost-only.ps1 | 16 - scripts/clean-build.ps1 | 54 -- src/Interface/Modules/Math/CMakeLists.txt | 15 +- src/Interface/Modules/Render/CMakeLists.txt | 6 +- src/Main/CMakeLists.txt | 12 +- 14 files changed, 55 insertions(+), 873 deletions(-) delete mode 100644 Superbuild/EmbreeExternal.cmake delete mode 100644 Superbuild/RKCommonExternal.cmake delete mode 100644 Superbuild/TBBExternal.cmake delete mode 100644 Superbuild/TnyWriteConfig.cmake delete mode 100644 Superbuild/patches/embree-macos-disable-debug-streams.patch delete mode 100644 Superbuild/patches/ospray-macos-embree-policy.patch delete mode 100644 scripts/clean-boost-only.ps1 delete mode 100644 scripts/clean-build.ps1 diff --git a/Superbuild/BoostConfig.cmake.in b/Superbuild/BoostConfig.cmake.in index 37be542103..2623d5acc4 100644 --- a/Superbuild/BoostConfig.cmake.in +++ b/Superbuild/BoostConfig.cmake.in @@ -1,5 +1,5 @@ # ============================================================================ -# BoostConfig.cmake - generated by SCIRun superbuild +# BoostConfig.cmake - template for SCIRun superbuild to generate a CMake config file for Boost # ============================================================================ @PACKAGE_INIT@ diff --git a/Superbuild/EmbreeExternal.cmake b/Superbuild/EmbreeExternal.cmake deleted file mode 100644 index 9e6ae3a9b5..0000000000 --- a/Superbuild/EmbreeExternal.cmake +++ /dev/null @@ -1,60 +0,0 @@ -# For more information, please see: http://software.sci.utah.edu -# -# The MIT License -# -# Copyright (c) 2026 Scientific Computing and Imaging Institute, -# University of Utah. -# -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -# Superbuild/EmbreeExternal.cmake - -SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) - -set(EMBREE_GIT_REPOSITORY https://github.com/embree/embree.git) -set(EMBREE_GIT_TAG v3.13.4) # >= 4.0.0, stable - -ExternalProject_Add(Embree_external - DEPENDS TBB_external - - GIT_REPOSITORY ${EMBREE_GIT_REPOSITORY} - GIT_TAG ${EMBREE_GIT_TAG} - - UPDATE_COMMAND "" - PATCH_COMMAND - git apply ${SUPERBUILD_DIR}/patches/embree-macos-disable-debug-streams.patch - - - - CMAKE_CACHE_ARGS - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - - -DEMBREE_TUTORIALS:BOOL=OFF - -DEMBREE_EXAMPLES:BOOL=OFF - -DEMBREE_TESTING:BOOL=OFF - -DEMBREE_ISPC_SUPPORT:BOOL=OFF - -DEMBREE_GEOMETRY_CURVE:BOOL=OFF - -DEMBREE_GEOMETRY_SUBDIVISION:BOOL=OFF - -DCMAKE_CXX_FLAGS=-DEMBREE_DISABLE_STREAM - - -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} -) \ No newline at end of file diff --git a/Superbuild/OsprayExternal.cmake b/Superbuild/OsprayExternal.cmake index a2798f3171..6bd1ad2703 100644 --- a/Superbuild/OsprayExternal.cmake +++ b/Superbuild/OsprayExternal.cmake @@ -25,7 +25,7 @@ # DEALINGS IN THE SOFTWARE. SET_PROPERTY(DIRECTORY PROPERTY "EP_BASE" ${ep_base}) -SET(ospray_GIT_TAG "v2.10.1") +SET(ospray_GIT_TAG "origin/scirun-build-2.10") set(ospray_DEPENDENCIES) set(ospray_DEPENDENCIES) @@ -51,9 +51,6 @@ ExternalProject_Add(Ospray_external GIT_REPOSITORY "https://github.com/CIBC-Internal/ospray.git" GIT_TAG ${ospray_GIT_TAG} - PATCH_COMMAND - git apply ${SUPERBUILD_DIR}/patches/ospray-macos-embree-policy.patch - GIT_SUBMODULES "" GIT_SUBMODULES_RECURSE OFF diff --git a/Superbuild/RKCommonExternal.cmake b/Superbuild/RKCommonExternal.cmake deleted file mode 100644 index 8326b7e26c..0000000000 --- a/Superbuild/RKCommonExternal.cmake +++ /dev/null @@ -1,53 +0,0 @@ -# For more information, please see: http://software.sci.utah.edu -# -# The MIT License -# -# Copyright (c) 2026 Scientific Computing and Imaging Institute, -# University of Utah. -# -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -# Superbuild/RKCommonExternal.cmake - -SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) - -SET(rkcommon_GIT_REPOSITORY - "https://github.com/ospray/rkcommon.git") -SET(rkcommon_GIT_TAG "v1.11.0") - -ExternalProject_Get_Property(TBB_external INSTALL_DIR) -set(TBB_INSTALL_DIR ${INSTALL_DIR}) - -ExternalProject_Add(rkcommon_external - DEPENDS TBB_external - GIT_REPOSITORY https://github.com/ospray/rkcommon.git - GIT_TAG v1.11.0 - - UPDATE_COMMAND "" - PATCH_COMMAND "" - - CMAKE_CACHE_ARGS - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX:PATH= - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON - -DBUILD_TESTING:BOOL=OFF - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 - -DTBB_ROOT:PATH=${TBB_INSTALL_DIR} -) \ No newline at end of file diff --git a/Superbuild/Superbuild.cmake b/Superbuild/Superbuild.cmake index 322ed167ce..71e560d0b1 100644 --- a/Superbuild/Superbuild.cmake +++ b/Superbuild/Superbuild.cmake @@ -138,46 +138,46 @@ IF(NOT BUILD_HEADLESS) # ------------------------------------------------------------ # Platform-specific Qt auto-detection # ------------------------------------------------------------ - if(APPLE OR WIN32 OR (UNIX AND NOT APPLE)) - - if(NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") - - if(APPLE) - set(_qt_default "/Users/basisunus/Qt/6.10.2/macos") - elseif(WIN32) - set(_qt_default "C:/Qt/6.10.1/msvc2022_64") - elseif(UNIX) - set(_qt_default "$ENV{HOME}/Qt/6.11.0/gcc_64") - endif() - - if(IS_DIRECTORY "${_qt_default}") - message(STATUS - "Qt_PATH not set or invalid — using auto-detected Qt: ${_qt_default}" - ) - - set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) - - # Auto-detect Qt version from path - get_filename_component(_qt_parent "${_qt_default}" DIRECTORY) - get_filename_component(_qt_version "${_qt_parent}" NAME) - - set(SCIRUN_QT_MIN_VERSION - "${_qt_version}" - CACHE STRING "Qt version" FORCE) - - string(REPLACE "." ";" SCIRUN_QT_MIN_VERSION_LIST - ${SCIRUN_QT_MIN_VERSION}) - - list(GET SCIRUN_QT_MIN_VERSION_LIST 0 QT_VERSION_MAJOR) - list(GET SCIRUN_QT_MIN_VERSION_LIST 1 QT_VERSION_MINOR) - list(GET SCIRUN_QT_MIN_VERSION_LIST 2 QT_VERSION_PATCH) - - endif() - else() - message(STATUS "Using user-provided Qt_PATH: ${Qt_PATH}") - endif() - - endif() + #if(APPLE OR WIN32 OR (UNIX AND NOT APPLE)) + # + # if(NOT Qt_PATH OR NOT IS_DIRECTORY "${Qt_PATH}") + # + # if(APPLE) + # set(_qt_default "/Users/basisunus/Qt/6.10.2/macos") + # elseif(WIN32) + # set(_qt_default "C:/Qt/6.10.1/msvc2022_64") + # elseif(UNIX) + # set(_qt_default "$ENV{HOME}/Qt/6.11.0/gcc_64") + # endif() + # + # if(IS_DIRECTORY "${_qt_default}") + # message(STATUS + # "Qt_PATH not set or invalid — using auto-detected Qt: ${_qt_default}" + # ) + # + # set(Qt_PATH "${_qt_default}" CACHE PATH "Qt install prefix" FORCE) + # + # # Auto-detect Qt version from path + # get_filename_component(_qt_parent "${_qt_default}" DIRECTORY) + # get_filename_component(_qt_version "${_qt_parent}" NAME) + # + # set(SCIRUN_QT_MIN_VERSION + # "${_qt_version}" + # CACHE STRING "Qt version" FORCE) + # + # string(REPLACE "." ";" SCIRUN_QT_MIN_VERSION_LIST + # ${SCIRUN_QT_MIN_VERSION}) + # + # list(GET SCIRUN_QT_MIN_VERSION_LIST 0 QT_VERSION_MAJOR) + # list(GET SCIRUN_QT_MIN_VERSION_LIST 1 QT_VERSION_MINOR) + # list(GET SCIRUN_QT_MIN_VERSION_LIST 2 QT_VERSION_PATCH) + # + # endif() + # else() + # message(STATUS "Using user-provided Qt_PATH: ${Qt_PATH}") + # endif() + # + #endif() # ------------------------------------------------------------ # Qt package discovery @@ -281,9 +281,9 @@ IF(WITH_TETGEN) ENDIF() IF(WITH_OSPRAY) - INCLUDE(${SUPERBUILD_DIR}/TBBExternal.cmake) - INCLUDE(${SUPERBUILD_DIR}/RKCommonExternal.cmake) - INCLUDE(${SUPERBUILD_DIR}/EmbreeExternal.cmake) + #INCLUDE(${SUPERBUILD_DIR}/TBBExternal.cmake) + #INCLUDE(${SUPERBUILD_DIR}/RKCommonExternal.cmake) + #INCLUDE(${SUPERBUILD_DIR}/EmbreeExternal.cmake) ADD_EXTERNAL(${SUPERBUILD_DIR}/OsprayExternal.cmake Ospray_external) ENDIF() diff --git a/Superbuild/TBBExternal.cmake b/Superbuild/TBBExternal.cmake deleted file mode 100644 index 610f4fa2f3..0000000000 --- a/Superbuild/TBBExternal.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# For more information, please see: http://software.sci.utah.edu -# -# The MIT License -# -# Copyright (c) 2026 Scientific Computing and Imaging Institute, -# University of Utah. -# -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -# Superbuild/TBBExternal.cmake - -SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${ep_base}) - -set(TBB_GIT_REPOSITORY "https://github.com/oneapi-src/oneTBB.git") -set(TBB_GIT_TAG "v2021.11.0") # Known-compatible with rkcommon 1.11 - -ExternalProject_Add(TBB_external - GIT_REPOSITORY ${TBB_GIT_REPOSITORY} - GIT_TAG ${TBB_GIT_TAG} - - UPDATE_COMMAND "" - PATCH_COMMAND "" - - CMAKE_CACHE_ARGS - -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX:PATH= - -DTBB_TEST:BOOL=OFF - -DTBB_STRICT:BOOL=OFF - -DCMAKE_POLICY_VERSION_MINIMUM:STRING=3.5 -) \ No newline at end of file diff --git a/Superbuild/TnyWriteConfig.cmake b/Superbuild/TnyWriteConfig.cmake deleted file mode 100644 index c6093e1c77..0000000000 --- a/Superbuild/TnyWriteConfig.cmake +++ /dev/null @@ -1,4 +0,0 @@ - -set(_cfg_dir "C:/Users/Yong/Documents/SCIRun/build/Externals/Install/Tny_external/lib/cmake/Tny") -file(MAKE_DIRECTORY "${_cfg_dir}") -configure_file("C:/Users/Yong/Documents/SCIRun/Superbuild/TnyConfig.cmake.in" "${_cfg_dir}/TnyConfig.cmake" @ONLY) diff --git a/Superbuild/patches/embree-macos-disable-debug-streams.patch b/Superbuild/patches/embree-macos-disable-debug-streams.patch deleted file mode 100644 index 9c818ff0b6..0000000000 --- a/Superbuild/patches/embree-macos-disable-debug-streams.patch +++ /dev/null @@ -1,460 +0,0 @@ -diff --git a/common/math/interval.h b/common/math/interval.h -index 310add212..81d8c453e 100644 ---- a/common/math/interval.h -+++ b/common/math/interval.h -@@ -70,10 +70,12 @@ namespace embree - __forceinline friend const Interval intersect( const Interval& a, const Interval& b ) { return Interval(max(a.lower, b.lower), min(a.upper, b.upper)); } - __forceinline friend const Interval intersect( const Interval& a, const Interval& b, const Interval& c ) { return intersect(a,intersect(b,c)); } - __forceinline friend const Interval intersect( const Interval& a, const Interval& b, const Interval& c, const Interval& d ) { return intersect(intersect(a,b),intersect(c,d)); } -- -+ -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const Interval& a) { - return cout << "[" << a.lower << ", " << a.upper << "]"; - } -+ #endif - - //////////////////////////////////////////////////////////////////////////////// - /// Constants -diff --git a/common/math/obbox.h b/common/math/obbox.h -index 2fe8bbf07..b27ba7a49 100644 ---- a/common/math/obbox.h -+++ b/common/math/obbox.h -@@ -25,9 +25,11 @@ namespace embree - __forceinline OBBox (const LinearSpace3& space, const BBox& bounds) - : space(space), bounds(bounds) {} - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const OBBox& p) { - return cout << "{ space = " << p.space << ", bounds = " << p.bounds << "}"; - } -+ #endif - - public: - LinearSpace3 space; //!< orthonormal transformation -diff --git a/common/math/range.h b/common/math/range.h -index 909fadb99..d65908c34 100644 ---- a/common/math/range.h -+++ b/common/math/range.h -@@ -74,9 +74,11 @@ namespace embree - return r0.size() < r1.size(); - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const range& r) { - return cout << "range [" << r.begin() << ", " << r.end() << "]"; - } -+ #endif - - Ty _begin, _end; - }; -@@ -128,9 +130,11 @@ namespace embree - _ext_end += plus; - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const extended_range& r) { - return cout << "extended_range [" << r.begin() << ", " << r.end() << " (" << r.ext_end() << ")]"; - } -+ #endif - - Ty _ext_end; - }; -diff --git a/kernels/builders/heuristic_binning.h b/kernels/builders/heuristic_binning.h -index 41be6183b..950fdf627 100644 ---- a/kernels/builders/heuristic_binning.h -+++ b/kernels/builders/heuristic_binning.h -@@ -99,10 +99,12 @@ namespace embree - return scale[dim] == 0.0f; - } - -+ #if !defined(__APPLE__) - /*! stream output */ - friend embree_ostream operator<<(embree_ostream cout, const BinMapping& mapping) { - return cout << "BinMapping { num = " << mapping.num << ", ofs = " << mapping.ofs << ", scale = " << mapping.scale << "}"; - } -+ #endif - - public: - size_t num; -@@ -140,9 +142,11 @@ namespace embree - __forceinline float splitSAH() const { return sah; } - - /*! stream output */ -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const BinSplit& split) { - return cout << "BinSplit { sah = " << split.sah << ", dim = " << split.dim << ", pos = " << split.pos << "}"; - } -+ #endif - - public: - float sah; //!< SAH cost of the split -diff --git a/kernels/builders/heuristic_spatial.h b/kernels/builders/heuristic_spatial.h -index 8b3499ac8..839db11e2 100644 ---- a/kernels/builders/heuristic_spatial.h -+++ b/kernels/builders/heuristic_spatial.h -@@ -100,9 +100,11 @@ namespace embree - __forceinline float splitSAH() const { return sah; } - - /*! stream output */ -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const SpatialBinSplit& split) { - return cout << "SpatialBinSplit { sah = " << split.sah << ", dim = " << split.dim << ", pos = " << split.pos << ", left = " << split.left << ", right = " << split.right << ", factor = " << split.factor << "}"; - } -+ #endif - - public: - float sah; //!< SAH cost of the split -diff --git a/kernels/builders/priminfo.h b/kernels/builders/priminfo.h -index fee515247..d4ca2d61b 100644 ---- a/kernels/builders/priminfo.h -+++ b/kernels/builders/priminfo.h -@@ -148,9 +148,11 @@ namespace embree - } - - /*! stream output */ -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const PrimInfoT& pinfo) { - return cout << "PrimInfo { begin = " << pinfo.begin << ", end = " << pinfo.end << ", geomBounds = " << pinfo.geomBounds << ", centBounds = " << pinfo.centBounds << "}"; - } -+ #endif - - public: - size_t begin,end; //!< number of primitives -@@ -240,6 +242,7 @@ namespace embree - } - - /*! stream output */ -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const PrimInfoMBT& pinfo) - { - return cout << "PrimInfo { " << -@@ -250,6 +253,7 @@ namespace embree - ", centBounds = " << pinfo.centBounds << - "}"; - } -+ #endif - - public: - range object_range; //!< primitive range -diff --git a/kernels/bvh/bvh_node_aabb.h b/kernels/bvh/bvh_node_aabb.h -index 3fd9fc7d1..dc7e8e82d 100644 ---- a/kernels/bvh/bvh_node_aabb.h -+++ b/kernels/bvh/bvh_node_aabb.h -@@ -196,6 +196,7 @@ namespace embree - __forceinline const NodeRef& child(size_t i) const { assert(i lower_x; //!< X dimension of lower bounds of all N children. -diff --git a/kernels/bvh/bvh_node_aabb_mb.h b/kernels/bvh/bvh_node_aabb_mb.h -index 001f526c2..b436580e6 100644 ---- a/kernels/bvh/bvh_node_aabb_mb.h -+++ b/kernels/bvh/bvh_node_aabb_mb.h -@@ -221,6 +221,7 @@ namespace embree - __forceinline const NodeRef& child(size_t i) const { assert(i lower_x; //!< X dimension of lower bounds of all N children. -diff --git a/kernels/bvh/bvh_node_aabb_mb4d.h b/kernels/bvh/bvh_node_aabb_mb4d.h -index 3b966fd05..6b946e50c 100644 ---- a/kernels/bvh/bvh_node_aabb_mb4d.h -+++ b/kernels/bvh/bvh_node_aabb_mb4d.h -@@ -91,6 +91,7 @@ namespace embree - } - - /*! stream output operator */ -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const AABBNodeMB4D_t& n) - { - cout << "AABBNodeMB4D {" << embree_endl; -@@ -107,6 +108,7 @@ namespace embree - cout << "}"; - return cout; - } -+ #endif - - public: - vfloat lower_t; //!< time dimension of lower bounds of all N children -diff --git a/kernels/bvh/bvh_node_obb.h b/kernels/bvh/bvh_node_obb.h -index e6b500691..770b9a8b5 100644 ---- a/kernels/bvh/bvh_node_obb.h -+++ b/kernels/bvh/bvh_node_obb.h -@@ -86,11 +86,13 @@ namespace embree - __forceinline const NodeRef& child(size_t i) const { assert(i naabb; //!< non-axis aligned bounding boxes (bounds are [0,1] in specified space) -diff --git a/kernels/bvh/bvh_node_qaabb.h b/kernels/bvh/bvh_node_qaabb.h -index 99671ddc5..b1c87756e 100644 ---- a/kernels/bvh/bvh_node_qaabb.h -+++ b/kernels/bvh/bvh_node_qaabb.h -@@ -132,6 +132,7 @@ namespace embree - Vec3f start; - Vec3f scale; - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream o, const QuantizedBaseNode_t& n) - { - o << "QuantizedBaseNode { " << embree_endl; -@@ -146,6 +147,7 @@ namespace embree - o << "}" << embree_endl; - return o; - } -+ #endif - - }; - -diff --git a/kernels/common/scene_grid_mesh.h b/kernels/common/scene_grid_mesh.h -index fb6fed445..61078d370 100644 ---- a/kernels/common/scene_grid_mesh.h -+++ b/kernels/common/scene_grid_mesh.h -@@ -34,9 +34,11 @@ namespace embree - } - - /*! outputs grid structure */ -+ #if !defined(__APPLE__) - __forceinline friend embree_ostream operator<<(embree_ostream cout, const Grid& t) { - return cout << "Grid { startVtxID " << t.startVtxID << ", lineVtxOffset " << t.lineVtxOffset << ", resX " << t.resX << ", resY " << t.resY << " }"; - } -+ #endif - }; - - public: -diff --git a/kernels/common/scene_quad_mesh.h b/kernels/common/scene_quad_mesh.h -index bd8eeaaeb..296d6c2f3 100644 ---- a/kernels/common/scene_quad_mesh.h -+++ b/kernels/common/scene_quad_mesh.h -@@ -20,9 +20,11 @@ namespace embree - uint32_t v[4]; - - /*! outputs triangle indices */ -+ #if !defined(__APPLE__) - __forceinline friend embree_ostream operator<<(embree_ostream cout, const Quad& q) { - return cout << "Quad {" << q.v[0] << ", " << q.v[1] << ", " << q.v[2] << ", " << q.v[3] << " }"; - } -+ #endif - }; - - public: -diff --git a/kernels/common/scene_triangle_mesh.h b/kernels/common/scene_triangle_mesh.h -index ad3f602fd..3524466cd 100644 ---- a/kernels/common/scene_triangle_mesh.h -+++ b/kernels/common/scene_triangle_mesh.h -@@ -20,9 +20,11 @@ namespace embree - uint32_t v[3]; - - /*! outputs triangle indices */ -+ #if !defined(__APPLE__) - __forceinline friend embree_ostream operator<<(embree_ostream cout, const Triangle& t) { - return cout << "Triangle { " << t.v[0] << ", " << t.v[1] << ", " << t.v[2] << " }"; - } -+ #endif - }; - - public: -diff --git a/kernels/geometry/pointi.h b/kernels/geometry/pointi.h -index bed04116b..ce49d6565 100644 ---- a/kernels/geometry/pointi.h -+++ b/kernels/geometry/pointi.h -@@ -210,10 +210,12 @@ namespace embree - }; - - /*! output operator */ -+ #if !defined(__APPLE__) - friend __forceinline embree_ostream operator<<(embree_ostream cout, const PointMi& line) - { - return cout << "Line" << M << "i {" << line.v0 << ", " << line.geomID() << ", " << line.primID() << "}"; - } -+ #endif - - public: - unsigned char gtype; -diff --git a/kernels/geometry/quadi.h b/kernels/geometry/quadi.h -index 70a7bdf15..f2a5e4261 100644 ---- a/kernels/geometry/quadi.h -+++ b/kernels/geometry/quadi.h -@@ -159,6 +159,7 @@ namespace embree - return linearBounds(scene, time_range); - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const QuadMi& quad) { - return cout << "QuadMi<" << M << ">( " - #if !defined(EMBREE_COMPACT_POLYS) -@@ -166,6 +167,7 @@ namespace embree - #endif - << "geomID = " << quad.geomIDs << ", primID = " << quad.primIDs << " )"; - } -+ #endif - - protected: - #if !defined(EMBREE_COMPACT_POLYS) -diff --git a/kernels/geometry/subgrid.h b/kernels/geometry/subgrid.h -index ce54421ca..ed5b98333 100644 ---- a/kernels/geometry/subgrid.h -+++ b/kernels/geometry/subgrid.h -@@ -281,11 +281,11 @@ namespace embree - return allBounds; - } - -- -+#if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const SubGrid& sg) { - return cout << "SubGrid " << " ( x " << sg.x() << ", y = " << sg.y() << ", geomID = " << sg.geomID() << ", primID = " << sg.primID() << " )"; - } -- -+#endif - __forceinline unsigned int geomID() const { return _geomID; } - __forceinline unsigned int primID() const { return _primID; } - __forceinline unsigned int x() const { return (unsigned int)_x & 0x7fff; } -@@ -379,7 +379,7 @@ namespace embree - - unsigned int _geomID; // geometry ID of mesh - -- -+#if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const SubGridQBVHN& sg) { - cout << "SubGridQBVHN " << embree_endl; - for (size_t i=0;i -@@ -489,7 +489,7 @@ namespace embree - float time_scale; - unsigned int _geomID; // geometry ID of mesh - -- -+#if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const SubGridMBQBVHN& sg) { - cout << "SubGridMBQBVHN " << embree_endl; - for (size_t i=0;i __forceinline bool LinearBezierCurve::hasRoot() const { -@@ -134,9 +136,11 @@ namespace embree - return merge(BBox(v0),BBox(v1),BBox(v2)); - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const QuadraticBezierCurve& a) { - return cout << "QuadraticBezierCurve ( (" << a.u.lower << ", " << a.u.upper << "), " << a.v0 << ", " << a.v1 << ", " << a.v2 << ")"; - } -+ #endif - }; - - -diff --git a/kernels/subdiv/gregory_patch.h b/kernels/subdiv/gregory_patch.h -index 9026d5c40..757ad5d9f 100644 ---- a/kernels/subdiv/gregory_patch.h -+++ b/kernels/subdiv/gregory_patch.h -@@ -841,6 +841,7 @@ namespace embree - return bounds; - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream o, const GregoryPatchT& p) - { - for (size_t y=0; y<4; y++) -@@ -852,6 +853,7 @@ namespace embree - o << "f[" << y << "][" << x << "] " << p.f[y][x] << embree_endl; - return o; - } -+ #endif - }; - - typedef GregoryPatchT GregoryPatch3fa; -diff --git a/kernels/subdiv/linear_bezier_patch.h b/kernels/subdiv/linear_bezier_patch.h -index dcdb101d7..a3d48cee6 100644 ---- a/kernels/subdiv/linear_bezier_patch.h -+++ b/kernels/subdiv/linear_bezier_patch.h -@@ -231,6 +231,7 @@ namespace embree - return (R.begin()-L.begin())+(R.end()-L.end()); - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const TensorLinearCubicBezierSurface& a) - { - return cout << "TensorLinearCubicBezierSurface" << embree_endl -@@ -239,6 +240,7 @@ namespace embree - << " R = " << a.R << embree_endl - << "}"; - } -+ #endif - - friend __forceinline TensorLinearCubicBezierSurface clerp(const TensorLinearCubicBezierSurface& a, const TensorLinearCubicBezierSurface& b, const float t) { - return TensorLinearCubicBezierSurface(clerp(a.L,b.L,V(t)), clerp(a.R,b.R,V(t))); -@@ -386,6 +388,7 @@ namespace embree - return (R.begin()-L.begin())+(R.end()-L.end()); - } - -+ #if !defined(__APPLE__) - friend embree_ostream operator<<(embree_ostream cout, const TensorLinearCubicBezierSurface& a) - { - return cout << "TensorLinearCubicBezierSurface" << embree_endl -@@ -394,6 +397,7 @@ namespace embree - << " R = " << a.getR() << embree_endl - << "}"; - } -+ #endif - }; - - typedef TensorLinearCubicBezierSurface TensorLinearCubicBezierSurface1f; diff --git a/Superbuild/patches/ospray-macos-embree-policy.patch b/Superbuild/patches/ospray-macos-embree-policy.patch deleted file mode 100644 index 0b24b15e5e..0000000000 --- a/Superbuild/patches/ospray-macos-embree-policy.patch +++ /dev/null @@ -1,108 +0,0 @@ -diff --git a/cmake/ospray_macros.cmake b/cmake/ospray_macros.cmake -index f581f3ecf..a452f6eb6 100644 ---- a/cmake/ospray_macros.cmake -+++ b/cmake/ospray_macros.cmake -@@ -389,15 +389,34 @@ endmacro() - - function(ospray_check_embree_feature FEATURE DESCRIPTION) - set(FEATURE EMBREE_${FEATURE}) -- if(NOT ${ARGN}) -+ -+ if (NOT ${ARGN}) -+ # Require FEATURE = OFF - if (${FEATURE}) -- message(FATAL_ERROR "OSPRay requires Embree to be compiled " -- "without ${DESCRIPTION} (${FEATURE}=OFF).") -+ if (APPLE) -+ message(WARNING -+ "Embree feature ${FEATURE} is enabled on macOS, " -+ "but OSPRay upstream expects it to be OFF. " -+ "Proceeding on macOS.") -+ else() -+ message(FATAL_ERROR -+ "OSPRay requires Embree to be compiled without " -+ "${DESCRIPTION} (${FEATURE}=OFF).") -+ endif() - endif() - else() -+ # Require FEATURE = ON - if (NOT ${FEATURE}) -- message(FATAL_ERROR "OSPRay requires Embree to be compiled " -- "with support for ${DESCRIPTION} (${FEATURE}=ON).") -+ if (APPLE) -+ message(WARNING -+ "Embree was built without support for ${DESCRIPTION} " -+ "(${FEATURE}=OFF) on macOS. " -+ "Proceeding without this feature.") -+ else() -+ message(FATAL_ERROR -+ "OSPRay requires Embree to be compiled with support for " -+ "${DESCRIPTION} (${FEATURE}=ON).") -+ endif() - endif() - endif() - endfunction() -@@ -416,34 +435,55 @@ function(ospray_verify_embree_features) - endfunction() - - macro(ospray_find_embree EMBREE_VERSION_REQUIRED FIND_AS_DEPENDENCY) -+ -+ # Find Embree - if (${FIND_AS_DEPENDENCY}) - find_dependency(embree ${EMBREE_VERSION_REQUIRED}) - else() - find_package(embree ${EMBREE_VERSION_REQUIRED}) - endif() -+ -+ # Handle missing / unsupported Embree - if (NOT embree_FOUND) -- message(FATAL_ERROR -- "We did not find Embree installed on your system. OSPRay requires" -- " an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please" -- " download and extract Embree (or compile Embree from source), then" -- " set the 'embree_DIR' variable to the installation (or build)" -- " directory.") -+ if (APPLE) -+ message(WARNING -+ "Using Embree < v${EMBREE_VERSION_REQUIRED} on macOS. " -+ "OSPRay upstream requires Embree >= v${EMBREE_VERSION_REQUIRED}, " -+ "but Embree 4.x is unstable with Apple Clang. " -+ "Proceeding with the provided Embree installation.") -+ return() # ✅ CRITICAL: stop before touching 'embree' target -+ else() -+ message(FATAL_ERROR -+ "We did not find Embree installed on your system. OSPRay requires " -+ "an Embree installation >= v${EMBREE_VERSION_REQUIRED}, please " -+ "download and extract Embree (or compile Embree from source), then " -+ "set the 'embree_DIR' variable to the installation (or build) " -+ "directory.") -+ endif() - endif() -+ -+ # ------------------------------- -+ # From here on, the 'embree' target EXISTS -+ # ------------------------------- -+ - # Get Embree CPU info - get_target_property(EMBREE_INCLUDE_DIRS embree - INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(CONFIGURATIONS embree IMPORTED_CONFIGURATIONS) - list(GET CONFIGURATIONS 0 CONFIGURATION) - get_target_property(EMBREE_LIBRARY embree -- IMPORTED_LOCATION_${CONFIGURATION}) -- # Get Embree SYCL info if DPCPP was enabled -+ IMPORTED_LOCATION_${CONFIGURATION}) -+ -+ # Get Embree SYCL info if enabled - if (EMBREE_SYCL_SUPPORT) - get_target_property(CONFIGURATIONS embree_sycl IMPORTED_CONFIGURATIONS) - list(GET CONFIGURATIONS 0 CONFIGURATION) - get_target_property(EMBREE_SYCL_LIBRARY embree_sycl - IMPORTED_LOCATION_${CONFIGURATION}) - endif() -+ - message(STATUS "Found Embree v${embree_VERSION}: ${EMBREE_LIBRARY}") -+ - endmacro() - - macro(ospray_determine_embree_isa_support) diff --git a/scripts/clean-boost-only.ps1 b/scripts/clean-boost-only.ps1 deleted file mode 100644 index 674b6f1ad1..0000000000 --- a/scripts/clean-boost-only.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -$BuildDir = "C:\Users\Yong\Documents\SCIRun\build" -$BoostDirs = @( - "Boost_external", - "boost", - "_deps" -) - -foreach ($name in $BoostDirs) { - $path = Join-Path $BuildDir $name - if (Test-Path $path) { - Write-Host "Removing $path" - Remove-Item -Recurse -Force $path - } -} - -Write-Host "? Boost-related directories removed." \ No newline at end of file diff --git a/scripts/clean-build.ps1 b/scripts/clean-build.ps1 deleted file mode 100644 index 82d30cc642..0000000000 --- a/scripts/clean-build.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -# ============================================================ -# Safe SCIRun build directory cleanup -# ============================================================ - -$ExpectedBuildDir = "C:\Users\Yong\Documents\SCIRun\build" - -Write-Host "SCIRun safe cleanup script" -Write-Host "Target directory:" -Write-Host " $ExpectedBuildDir" -Write-Host "" - -# Resolve actual path -try { - $Resolved = (Resolve-Path $ExpectedBuildDir).Path -} catch { - Write-Error "ERROR: Build directory does not exist." - exit 1 -} - -# Safety checks -if ($Resolved -ne $ExpectedBuildDir) { - Write-Error "ERROR: Resolved path mismatch." - Write-Error "Resolved: $Resolved" - exit 1 -} - -if ($Resolved -match "^C:\\Users\\Yong\\?$") { - Write-Error "ERROR: Refusing to operate on user directory." - exit 1 -} - -if ($Resolved -ne "C:\Users\Yong\Documents\SCIRun\build") { - Write-Error "ERROR: Refusing to clean unexpected path: $Resolved" - exit 1 -} - -Write-Host "? Safety checks passed." -Write-Host "" - -# Confirmation -$answer = Read-Host "Type 'DELETE BUILD DIR' to continue" -if ($answer -ne "DELETE BUILD DIR") { - Write-Host "Aborted." - exit 0 -} - -Write-Host "" -Write-Host "Cleaning build contents (directory preserved)..." -Write-Host "" - -Get-ChildItem -Path $Resolved -Force | - Remove-Item -Recurse -Force -ErrorAction Stop - -Write-Host "? Build directory cleaned safely." diff --git a/src/Interface/Modules/Math/CMakeLists.txt b/src/Interface/Modules/Math/CMakeLists.txt index 1ceef444a6..e26e980849 100644 --- a/src/Interface/Modules/Math/CMakeLists.txt +++ b/src/Interface/Modules/Math/CMakeLists.txt @@ -143,17 +143,10 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Math ${SCI_QWT_LIBRARY} ) -if (QT_VERSION_MAJOR EQUAL 6) - TARGET_LINK_LIBRARIES(Interface_Modules_Math - Qt6::Svg - Qt6::PrintSupport - ) -elseif(QT_VERSION_MAJOR EQUAL 5) - TARGET_LINK_LIBRARIES(Interface_Modules_Math - Qt5::Svg - Qt5::PrintSupport - ) -endif() +TARGET_LINK_LIBRARIES(Interface_Modules_Math + Qt::Svg + Qt::PrintSupport +) #ADD_DEFINITIONS(-DQWT_DLL) diff --git a/src/Interface/Modules/Render/CMakeLists.txt b/src/Interface/Modules/Render/CMakeLists.txt index a0e18a25e3..90e3874575 100644 --- a/src/Interface/Modules/Render/CMakeLists.txt +++ b/src/Interface/Modules/Render/CMakeLists.txt @@ -142,11 +142,7 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Render ) TARGET_LINK_LIBRARIES(Interface_Modules_Render ${QT_GRAPHICS_LIBRARIES}) -if (QT_VERSION_MAJOR EQUAL 6) - TARGET_LINK_LIBRARIES(Interface_Modules_Render Qt6::Svg) -elseif(QT_VERSION_MAJOR EQUAL 5) - TARGET_LINK_LIBRARIES(Interface_Modules_Render Qt5::Svg) -endif() +TARGET_LINK_LIBRARIES(Interface_Modules_Render Qt::Svg) IF(BUILD_SHARED_LIBS) ADD_DEFINITIONS(-DBUILD_Interface_Modules_Render) diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 46c98a695d..3859543721 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -80,13 +80,11 @@ ELSEIF(WIN32) IF(WIN32 AND MSVC AND NOT BUILD_HEADLESS) # Detect Qt version (Qt6 preferred, fallback to Qt5) - IF(TARGET Qt6::qmake) - SET(_qt_qmake_target Qt6::qmake) - ELSEIF(TARGET Qt5::qmake) - SET(_qt_qmake_target Qt5::qmake) - ELSE() - SET(_qt_qmake_target "") - ENDIF() + if(TARGET Qt::qmake) + set(_qt_qmake_target Qt::qmake) + else() + set(_qt_qmake_target "") + endif() IF(_qt_qmake_target) get_target_property(_qt_qmake_exe ${_qt_qmake_target} LOCATION) From e87d416ca19b4357f843b447328016244962a506 Mon Sep 17 00:00:00 2001 From: basisunus Date: Wed, 6 May 2026 15:57:25 -0600 Subject: [PATCH 130/140] python --- src/Core/Python/PythonInterpreter.cc | 930 ++++++++++++++------------- src/Core/Python/PythonInterpreter.h | 1 + 2 files changed, 472 insertions(+), 459 deletions(-) diff --git a/src/Core/Python/PythonInterpreter.cc b/src/Core/Python/PythonInterpreter.cc index bdcebe410d..345afb23c8 100644 --- a/src/Core/Python/PythonInterpreter.cc +++ b/src/Core/Python/PythonInterpreter.cc @@ -25,213 +25,200 @@ DEALINGS IN THE SOFTWARE. */ - /// @todo Documentation Core/Python/PythonInterpreter.cc #ifdef BUILD_WITH_PYTHON #ifdef _MSC_VER -//#pragma warning( push ) -#pragma warning( disable: 4244 ) +// #pragma warning( push ) +#pragma warning(disable : 4244) #endif #include -#include +#include +#include #include -#include #include +#include +#include +#include #include #include -#include -#include -#include - -//#include -#include -#include -#include +// #include +#include #include - +#include +#include +#include #include -#include using namespace SCIRun::Core; -namespace SCIRun -{ -namespace Core -{ +namespace SCIRun { +namespace Core { -class PythonInterpreterPrivate : public Lockable -{ -public: - typedef std::pair< std::string, PyObject* ( * )( void ) > module_entry_type; - typedef std::list< module_entry_type > module_list_type; - - std::string read_from_console( const int bytes = -1 ); - - const wchar_t* programName() const { return !program_name_.empty() ? &program_name_[0] : L""; } - void setProgramName(const std::vector& name) - { - program_name_ = name; - //std::wcout << "PROGRAM NAME SET TO: " << programName() << std::endl; - } - - // A list of Python extension modules that need to be initialized - module_list_type modules_; - // An instance of python CommandCompiler object (defined in codeop.py) - boost::python::object compiler_; - // The context of the Python main module. - boost::python::object globals_; - // Whether the Python interpreter has been initialized. - bool initialized_; - bool terminal_running_; - // The input buffer - std::string input_buffer_; - // Whether the interpreter is waiting for input - bool waiting_for_input_; - // The command buffer (for Python statements that span over multiple lines) - std::string command_buffer_; - // Python sys.ps1 - std::string prompt1_; - // Python sys.ps2 - std::string prompt2_; - - // Condition variable to make sure the PythonInterpreter thread has - // completed initialization before continuing the main thread. - std::condition_variable thread_condition_variable_; -private: - // The name of the executable - std::vector< wchar_t > program_name_; -}; + class PythonInterpreterPrivate : public Lockable + { + public: + typedef std::pair module_entry_type; + typedef std::list module_list_type; -std::string PythonInterpreterPrivate::read_from_console( const int bytes /*= -1 */ ) -{ - lock_type lock( this->get_mutex() ); - - std::string result; - if ( !input_buffer_.empty() ) - { - if ( bytes <= 0 ) - { - result = input_buffer_; - input_buffer_.clear(); - } - else - { - result = input_buffer_.substr( 0, bytes ); - if ( bytes < static_cast< int >( input_buffer_.size() ) ) - { - input_buffer_ = input_buffer_.substr( bytes ); - } - else - { - input_buffer_.clear(); - } - } - } - - int more_bytes = bytes - static_cast< int >( result.size() ); - while ( ( bytes <= 0 && result.empty() ) || - ( bytes > 0 && more_bytes > 0 ) ) - { - this->waiting_for_input_ = true; - this->thread_condition_variable_.wait( lock ); - - // Abort reading if an interrupt signal has been received. - if ( PyErr_CheckSignals() != 0 ) break; - - if ( bytes <= 0 ) - { - result = input_buffer_; - input_buffer_.clear(); - } - else - { - result += input_buffer_.substr( 0, more_bytes ); - if ( more_bytes < static_cast< int >( input_buffer_.size() ) ) - { - input_buffer_ = input_buffer_.substr( more_bytes ); - } - else - { - input_buffer_.clear(); - } - } - - more_bytes = bytes - static_cast< int >( result.size() ); - } - - this->waiting_for_input_ = false; - return result; -} + std::string read_from_console(const int bytes = -1); + + const wchar_t* programName() const { return !program_name_.empty() ? &program_name_[0] : L""; } + void setProgramName(const std::vector& name) + { + program_name_ = name; + // std::wcout << "PROGRAM NAME SET TO: " << programName() << std::endl; + } + + // A list of Python extension modules that need to be initialized + module_list_type modules_; + // An instance of python CommandCompiler object (defined in codeop.py) + boost::python::object compiler_; + // The context of the Python main module. + boost::python::object globals_; + // Whether the Python interpreter has been initialized. + bool initialized_; + bool terminal_running_; + // The input buffer + std::string input_buffer_; + // Whether the interpreter is waiting for input + bool waiting_for_input_; + // The command buffer (for Python statements that span over multiple lines) + std::string command_buffer_; + // Python sys.ps1 + std::string prompt1_; + // Python sys.ps2 + std::string prompt2_; + + // Condition variable to make sure the PythonInterpreter thread has + // completed initialization before continuing the main thread. + std::condition_variable thread_condition_variable_; + + private: + // The name of the executable + std::vector program_name_; + }; + + std::string PythonInterpreterPrivate::read_from_console(const int bytes /*= -1 */) + { + lock_type lock(this->get_mutex()); + + std::string result; + if (!input_buffer_.empty()) + { + if (bytes <= 0) + { + result = input_buffer_; + input_buffer_.clear(); + } + else + { + result = input_buffer_.substr(0, bytes); + if (bytes < static_cast(input_buffer_.size())) + { + input_buffer_ = input_buffer_.substr(bytes); + } + else + { + input_buffer_.clear(); + } + } + } + + int more_bytes = bytes - static_cast(result.size()); + while ((bytes <= 0 && result.empty()) || (bytes > 0 && more_bytes > 0)) + { + this->waiting_for_input_ = true; + this->thread_condition_variable_.wait(lock); + + // Abort reading if an interrupt signal has been received. + if (PyErr_CheckSignals() != 0) break; + + if (bytes <= 0) + { + result = input_buffer_; + input_buffer_.clear(); + } + else + { + result += input_buffer_.substr(0, more_bytes); + if (more_bytes < static_cast(input_buffer_.size())) + { + input_buffer_ = input_buffer_.substr(more_bytes); + } + else + { + input_buffer_.clear(); + } + } -}} + more_bytes = bytes - static_cast(result.size()); + } + + this->waiting_for_input_ = false; + return result; + } +} +} ////////////////////////////////////////////////////////////////////////// // Class PythonTerminal ////////////////////////////////////////////////////////////////////////// class PythonStdIO { -public: - boost::python::object read( int n ) - { - std::string data = PythonInterpreter::Instance().private_->read_from_console( n ); - boost::python::str pystr( data.c_str() ); - return pystr.encode(); - } - - std::string readline() - { - return PythonInterpreter::Instance().private_->read_from_console(); - } - - int write( const std::string& data ) - { - PythonInterpreter::Instance().output_signal_( data ); - return static_cast< int >( data.size() ); - } + public: + boost::python::object read(int n) + { + std::string data = PythonInterpreter::Instance().private_->read_from_console(n); + boost::python::str pystr(data.c_str()); + return pystr.encode(); + } + + std::string readline() { return PythonInterpreter::Instance().private_->read_from_console(); } + + int write(const std::string& data) + { + PythonInterpreter::Instance().output_signal_(data); + return static_cast(data.size()); + } }; class PythonStdErr { -public: - int write( const std::string& data ) - { - PythonInterpreter::Instance().error_signal_( data ); - return static_cast< int >( data.size() ); - } + public: + int write(const std::string& data) + { + PythonInterpreter::Instance().error_signal_(data); + return static_cast(data.size()); + } }; -BOOST_PYTHON_MODULE( interpreter ) +BOOST_PYTHON_MODULE(interpreter) { - boost::python::class_< PythonStdIO >( "terminalio" ) - .def( "read", &PythonStdIO::read ) - .def( "readline", &PythonStdIO::readline ) - .def( "write", &PythonStdIO::write ); + boost::python::class_("terminalio").def("read", &PythonStdIO::read).def("readline", &PythonStdIO::readline).def("write", &PythonStdIO::write); - boost::python::class_< PythonStdErr >( "terminalerr" ) - .def( "write", &PythonStdErr::write ); + boost::python::class_("terminalerr").def("write", &PythonStdErr::write); } -CORE_SINGLETON_IMPLEMENTATION( PythonInterpreter ); +CORE_SINGLETON_IMPLEMENTATION(PythonInterpreter); -PythonInterpreter::PythonInterpreter() : - private_( new PythonInterpreterPrivate ) +PythonInterpreter::PythonInterpreter() : private_(new PythonInterpreterPrivate) { - this->private_->initialized_ = false; - this->private_->terminal_running_ = false; - this->private_->waiting_for_input_ = false; + this->private_->initialized_ = false; + this->private_->terminal_running_ = false; + this->private_->waiting_for_input_ = false; } PythonInterpreter::~PythonInterpreter() { - // NOTE: Boost.Python requires that we don't call Py_Finalize - //Py_Finalize(); + // NOTE: Boost.Python requires that we don't call Py_Finalize + // Py_Finalize(); } -//#define PRINT_PY_INIT_DEBUG(n) std::cout << "ev " << (n) << std::endl; +// #define PRINT_PY_INIT_DEBUG(n) std::cout << "ev " << (n) << std::endl; #define PRINT_PY_INIT_DEBUG(n) bool needsSpecialPythonPathTreatment(const std::string& commandLine) @@ -242,16 +229,14 @@ bool needsSpecialPythonPathTreatment(const std::string& commandLine) #else const std::string TEST_EXECUTABLE_NAME = "SCIRun_test"; const std::string UNIT_TEST_EXECUTABLE_NAME = "Engine_Python_Tests"; - return commandLine.find(TEST_EXECUTABLE_NAME) != std::string::npos - || commandLine.find(UNIT_TEST_EXECUTABLE_NAME) != std::string::npos; - //TODO: this version is bugged if the test network name starts with a relative path: stem() returns the network name, not the executable name. - //the full command line isn't normally a valid path object anyway. - // return 0 == boost::filesystem::path(commandLine).stem().string().compare(0, TEST_EXECUTABLE_NAME.size(), TEST_EXECUTABLE_NAME); + return commandLine.find(TEST_EXECUTABLE_NAME) != std::string::npos || commandLine.find(UNIT_TEST_EXECUTABLE_NAME) != std::string::npos; + // TODO: this version is bugged if the test network name starts with a relative path: stem() returns the network name, not the executable name. + // the full command line isn't normally a valid path object anyway. + // return 0 == boost::filesystem::path(commandLine).stem().string().compare(0, TEST_EXECUTABLE_NAME.size(), TEST_EXECUTABLE_NAME); #endif } -void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreatment, - const boost::filesystem::path& libPath) +void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreatment, const boost::filesystem::path& libPath) { PRINT_PY_INIT_DEBUG(1); using namespace boost::python; @@ -260,10 +245,9 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat PRINT_PY_INIT_DEBUG(2); // Register built-in extension modules BEFORE initialization (still allowed) - PyImport_AppendInittab("interpreter", PyInit_interpreter); - PyImport_AppendInittab("SCIRunPythonAPI", PyInit_SCIRunPythonAPI); - for (module_list_type::iterator it = this->private_->modules_.begin(); - it != this->private_->modules_.end(); ++it) + PyImport_AppendInittab("interpreter", PyInit_interpreter); + PyImport_AppendInittab("SCIRunPythonAPI", PyInit_SCIRunPythonAPI); + for (module_list_type::iterator it = this->private_->modules_.begin(); it != this->private_->modules_.end(); ++it) { PyImport_AppendInittab((*it).first.c_str(), (*it).second); } @@ -277,18 +261,18 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat std::vector search_paths; #if defined(_WIN32) - const std::wstring PATH_SEP(L";"); // not used in PyConfig, but kept for clarity + const std::wstring PATH_SEP(L";"); // not used in PyConfig, but kept for clarity boost::filesystem::path lib_path = libPath; - boost::filesystem::path top_lib_path = lib_path / PYTHONPATH / PYTHONNAME; + boost::filesystem::path top_lib_path = lib_path / PYTHONPATH / PYTHONNAME; boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; - boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; + boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; // Historically you only used top + site on Windows. search_paths.push_back(top_lib_path.wstring()); search_paths.push_back(site_lib_path.wstring()); #elif defined(__APPLE__) - const std::wstring PATH_SEP(L":"); // not used in PyConfig, but kept for clarity + const std::wstring PATH_SEP(L":"); // not used in PyConfig, but kept for clarity boost::filesystem::path lib_path = libPath.parent_path(); std::vector lib_path_list; @@ -306,9 +290,9 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat for (size_t i = 0; i < lib_path_list.size(); ++i) { const auto& path = lib_path_list[i]; - boost::filesystem::path plat_lib_path = path / "plat-darwin"; // keep legacy layout if present - boost::filesystem::path dynload_lib_path= path / "lib-dynload"; - boost::filesystem::path site_lib_path = path / "site-packages"; + boost::filesystem::path plat_lib_path = path / "plat-darwin"; // keep legacy layout if present + boost::filesystem::path dynload_lib_path = path / "lib-dynload"; + boost::filesystem::path site_lib_path = path / "site-packages"; search_paths.push_back(path.wstring()); search_paths.push_back(plat_lib_path.wstring()); @@ -318,12 +302,12 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat #else // Linux and other Unix - const std::wstring PATH_SEP(L":"); // not used in PyConfig, but kept for clarity - boost::filesystem::path lib_path = libPath; + const std::wstring PATH_SEP(L":"); // not used in PyConfig, but kept for clarity + boost::filesystem::path lib_path = libPath; boost::filesystem::path top_lib_path = lib_path / PYTHONPATH; boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; - boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; - boost::filesystem::path plat_lib_path = top_lib_path / "plat-linux"; + boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; + boost::filesystem::path plat_lib_path = top_lib_path / "plat-linux"; search_paths.push_back(top_lib_path.wstring()); search_paths.push_back(plat_lib_path.wstring()); @@ -341,8 +325,9 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat // If you previously set Py_IgnoreEnvironmentFlag = 1, use "isolated" preinit. PyPreConfig_InitIsolatedConfig(&preconfig); status = Py_PreInitialize(&preconfig); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); // exits with message + if (PyStatus_Exception(status)) + { + Py_ExitStatusException(status); // exits with message } // Start from isolated defaults (equivalent to ignoring env, no signal handlers, etc.) @@ -353,7 +338,8 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat { const wchar_t* prog = this->private_->programName(); status = PyConfig_SetString(&config, &config.program_name, prog); - if (PyStatus_Exception(status)) { + if (PyStatus_Exception(status)) + { PyConfig_Clear(&config); Py_ExitStatusException(status); } @@ -364,23 +350,25 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat // Py_InspectFlag = 1 -> config.inspect = 1 // Py_OptimizeFlag = 2 -> config.optimization_level = 2 // Py_NoSiteFlag = 1 (non-Windows)-> config.site_import = 0 - config.use_environment = 0; - config.inspect = 1; + config.use_environment = 0; + config.inspect = 1; config.optimization_level = 2; #if !defined(_WIN32) - config.site_import = 0; + config.site_import = 0; #endif // Populate module_search_paths (replacement for Py_SetPath) // NOTE: PyConfig expects absolute, existing directories; add only those that exist. for (const auto& wpath : search_paths) { - if (!wpath.empty()) { + if (!wpath.empty()) + { // Optional: skip non-existing paths to avoid warnings // (Converting back to narrow only for filesystem exists check if needed) // Here we trust the layout and append directly: status = PyWideStringList_Append(&config.module_search_paths, wpath.c_str()); - if (PyStatus_Exception(status)) { + if (PyStatus_Exception(status)) + { PyConfig_Clear(&config); Py_ExitStatusException(status); } @@ -390,26 +378,29 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat // Finalize initialization status = Py_InitializeFromConfig(&config); PyConfig_Clear(&config); - if (PyStatus_Exception(status)) { + if (PyStatus_Exception(status)) + { Py_ExitStatusException(status); } + this->main_thread_state_ = PyEval_SaveThread(); + PRINT_PY_INIT_DEBUG(8); #else // ------------------------------- - // Legacy fallback (Python < 3.8) + // Legacy fallback (Python < 3.8) // ------------------------------- Py_SetProgramName(const_cast(this->private_->programName())); std::wstringstream lib_paths; -# if defined(_WIN32) +#if defined(_WIN32) const std::wstring PATH_SEP(L";"); -# else +#else const std::wstring PATH_SEP(L":"); -# endif +#endif -# if defined(__APPLE__) +#if defined(__APPLE__) boost::filesystem::path lib_path = libPath.parent_path(); std::vector lib_path_list; lib_path_list.push_back(lib_path.parent_path() / boost::filesystem::path("Frameworks") / PYTHONPATH); @@ -430,67 +421,60 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat boost::filesystem::path dynload_lib_path = path / "lib-dynload"; boost::filesystem::path site_lib_path = path / "site-packages"; if (i > 0) lib_paths << PATH_SEP; - lib_paths << path.wstring() << PATH_SEP - << plat_lib_path.wstring() << PATH_SEP - << dynload_lib_path.wstring() << PATH_SEP - << site_lib_path.wstring(); + lib_paths << path.wstring() << PATH_SEP << plat_lib_path.wstring() << PATH_SEP << dynload_lib_path.wstring() << PATH_SEP << site_lib_path.wstring(); } Py_SetPath(lib_paths.str().c_str()); -# elif defined(_WIN32) +#elif defined(_WIN32) { boost::filesystem::path lib_path = libPath; boost::filesystem::path top_lib_path = lib_path / PYTHONPATH / PYTHONNAME; boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; - lib_paths << top_lib_path.wstring() << PATH_SEP - << site_lib_path.wstring(); + lib_paths << top_lib_path.wstring() << PATH_SEP << site_lib_path.wstring(); Py_SetPath(lib_paths.str().c_str()); } -# else +#else { boost::filesystem::path lib_path = libPath; boost::filesystem::path top_lib_path = lib_path / PYTHONPATH; boost::filesystem::path dynload_lib_path = top_lib_path / "lib-dynload"; boost::filesystem::path site_lib_path = top_lib_path / "site-packages"; boost::filesystem::path plat_lib_path = top_lib_path / "plat-linux"; - lib_paths << top_lib_path.wstring() << PATH_SEP - << plat_lib_path.wstring() << PATH_SEP - << dynload_lib_path.wstring() << PATH_SEP - << site_lib_path.wstring(); + lib_paths << top_lib_path.wstring() << PATH_SEP << plat_lib_path.wstring() << PATH_SEP << dynload_lib_path.wstring() << PATH_SEP << site_lib_path.wstring(); Py_SetPath(lib_paths.str().c_str()); } -# endif +#endif Py_IgnoreEnvironmentFlag = 1; Py_InspectFlag = 1; Py_OptimizeFlag = 2; -# if !defined(_WIN32) +#if !defined(_WIN32) Py_NoSiteFlag = 1; -# endif +#endif Py_Initialize(); PRINT_PY_INIT_DEBUG(8); -#endif // PY_VERSION_HEX >= 0x03080000 +#endif // PY_VERSION_HEX >= 0x03080000 PyRun_SimpleString( - "from codeop import CommandCompiler\n" - "__internal_compiler = CommandCompiler()\n" ); + "from codeop import CommandCompiler\n" + "__internal_compiler = CommandCompiler()\n"); boost::python::object main_module = boost::python::import("__main__"); boost::python::object main_namespace = main_module.attr("__dict__"); this->private_->compiler_ = main_namespace["__internal_compiler"]; - this->private_->globals_ = main_namespace; + this->private_->globals_ = main_namespace; PyRun_SimpleString( - "import sys\n" - "try:\n" - "\tsys.ps1\n" - "except AttributeError:\n" - "\tsys.ps1 = \">>> \"\n" - "try:\n" - "\tsys.ps2\n" - "except AttributeError:\n" - "\tsys.ps2 = \"... \"\n"); + "import sys\n" + "try:\n" + "\tsys.ps1\n" + "except AttributeError:\n" + "\tsys.ps1 = \">>> \"\n" + "try:\n" + "\tsys.ps2\n" + "except AttributeError:\n" + "\tsys.ps2 = \"... \"\n"); boost::python::object sys_module = main_namespace["sys"]; boost::python::object sys_namespace = sys_module.attr("__dict__"); @@ -498,18 +482,17 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat this->private_->prompt2_ = boost::python::extract(sys_namespace["ps2"]); PyRun_SimpleString( - "import interpreter\n" - "__term_io = interpreter.terminalio()\n" - "__term_err = interpreter.terminalerr()\n" - "import sys\n" - "sys.stdin = __term_io\n" - "sys.stdout = __term_io\n" - "sys.stderr = __term_err\n" - "import atexit\n" - "def quit_gracefully():\n" - "\tprint('Goodbye!')\n" - "atexit.register(quit_gracefully)\n" - ); + "import interpreter\n" + "__term_io = interpreter.terminalio()\n" + "__term_err = interpreter.terminalerr()\n" + "import sys\n" + "sys.stdin = __term_io\n" + "sys.stdout = __term_io\n" + "sys.stderr = __term_err\n" + "import atexit\n" + "def quit_gracefully():\n" + "\tprint('Goodbye!')\n" + "atexit.register(quit_gracefully)\n"); PyRun_SimpleString("del (interpreter, __internal_compiler, __term_io, __term_err)\n"); @@ -517,64 +500,62 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat PRINT_PY_INIT_DEBUG(999); } -namespace +namespace { +std::vector argvFromFullString(const std::string& commandLine) { - std::vector argvFromFullString(const std::string& commandLine) - { - using namespace boost::algorithm; - std::string cmdline = commandLine; - trim_all(cmdline); - std::vector argv; - split(argv, cmdline, is_any_of(" ")); - return argv; - } + using namespace boost::algorithm; + std::string cmdline = commandLine; + trim_all(cmdline); + std::vector argv; + split(argv, cmdline, is_any_of(" ")); + return argv; +} - std::vector> wideArgvFromArgv(const std::vector& argv) - { - std::vector> wideArgv(argv.size()); - std::transform(argv.begin(), argv.end(), wideArgv.begin(), [](const std::string& arg) - { - std::vector wide(arg.size() + 1); - mbstowcs(&wide[0], arg.c_str(), wide.size() + 1); - return wide; - }); - return wideArgv; - } +std::vector> wideArgvFromArgv(const std::vector& argv) +{ + std::vector> wideArgv(argv.size()); + std::transform(argv.begin(), argv.end(), wideArgv.begin(), [](const std::string& arg) { + std::vector wide(arg.size() + 1); + mbstowcs(&wide[0], arg.c_str(), wide.size() + 1); + return wide; + }); + return wideArgv; +} - std::vector wideArgvPtrsFromWideArgv(std::vector>& wideArgv) - { - std::vector wideArgvPtrs(wideArgv.size()); - std::transform(wideArgv.begin(), wideArgv.end(), wideArgvPtrs.begin(), [](std::vector& wide) { return &wide[0]; }); - return wideArgvPtrs; - } +std::vector wideArgvPtrsFromWideArgv(std::vector>& wideArgv) +{ + std::vector wideArgvPtrs(wideArgv.size()); + std::transform(wideArgv.begin(), wideArgv.end(), wideArgvPtrs.begin(), [](std::vector& wide) { return &wide[0]; }); + return wideArgvPtrs; +} - std::vector getProgramName(const std::vector& argv) +std::vector getProgramName(const std::vector& argv) +{ + size_t name_len = argv[0].size(); + std::vector program_name(name_len + 1); + mbstowcs(&program_name[0], argv[0].c_str(), name_len + 1); + return program_name; +} + +void setPythonArgv(const std::vector& argv) +{ + auto wideArgv = wideArgvFromArgv(argv); + auto wideArgvPtrs = wideArgvPtrsFromWideArgv(wideArgv); + + int argsOffset = 0; + auto scriptFlag1 = std::find(argv.begin(), argv.end(), "-s"); + auto scriptFlag2 = std::find(argv.begin(), argv.end(), "--script"); + if (scriptFlag1 != argv.end()) { - size_t name_len = argv[0].size(); - std::vector program_name(name_len + 1); - mbstowcs(&program_name[0], argv[0].c_str(), name_len + 1); - return program_name; + argsOffset = scriptFlag1 - argv.begin() + 1; } - - void setPythonArgv(const std::vector& argv) + else if (scriptFlag2 != argv.end()) { - auto wideArgv = wideArgvFromArgv(argv); - auto wideArgvPtrs = wideArgvPtrsFromWideArgv(wideArgv); - - int argsOffset = 0; - auto scriptFlag1 = std::find(argv.begin(), argv.end(), "-s"); - auto scriptFlag2 = std::find(argv.begin(), argv.end(), "--script"); - if (scriptFlag1 != argv.end()) - { - argsOffset = scriptFlag1 - argv.begin() + 1; - } - else if (scriptFlag2 != argv.end()) - { - argsOffset = scriptFlag2 - argv.begin() + 1; - } - - PySys_SetArgv(wideArgvPtrs.size() - argsOffset, &wideArgvPtrs[argsOffset]); + argsOffset = scriptFlag2 - argv.begin() + 1; } + + PySys_SetArgv(wideArgvPtrs.size() - argsOffset, &wideArgvPtrs[argsOffset]); +} } void PythonInterpreter::initialize(bool needProgramName, const std::string& commandLine, const boost::filesystem::path& libPath) @@ -585,7 +566,7 @@ void PythonInterpreter::initialize(bool needProgramName, const std::string& comm { this->private_->setProgramName(getProgramName(argv)); // TODO: remove debug print when confident python initialization is stable - //std::wcerr << "initialize program name=" << this->private_->programName() << std::endl; + // std::wcerr << "initialize program name=" << this->private_->programName() << std::endl; } initialize_eventhandler(needsSpecialPythonPathTreatment(commandLine), libPath); @@ -593,10 +574,8 @@ void PythonInterpreter::initialize(bool needProgramName, const std::string& comm setPythonArgv(argv); { - auto out = [](const std::string& s) - { - if (!std::all_of(s.begin(), s.end(), isspace)) - std::cout << "[PYTHON] " << s << std::endl; + auto out = [](const std::string& s) { + if (!std::all_of(s.begin(), s.end(), isspace)) std::cout << "[PYTHON] " << s << std::endl; }; auto error = [](const std::string& s) { std::cerr << "[PYTHON ERROR] " << s << std::endl; }; output_signal_.connect(out); @@ -608,201 +587,234 @@ void PythonInterpreter::initialize(bool needProgramName, const std::string& comm void PythonInterpreter::print_banner() { - PyRun_SimpleString( "print('Python %s on %s' % (sys.version, sys.platform))\n" ); - this->prompt_signal_( this->private_->prompt1_ ); + PyRun_SimpleString("print('Python %s on %s' % (sys.version, sys.platform))\n"); + this->prompt_signal_(this->private_->prompt1_); } -bool PythonInterpreter::run_string( const std::string& command ) +bool PythonInterpreter::run_string(const std::string& command) { LOG_DEBUG("Python::run_string( {} )", command); - { - PythonInterpreterPrivate::lock_type lock( this->private_->get_mutex() ); - if ( !this->private_->initialized_ ) - { - throw std::invalid_argument( "The python interpreter hasn't been initialized!" ); - } - } - - // Clear any previous Python errors. - PyErr_Clear(); - - // Append the command to the current command buffer - if ( this->private_->command_buffer_.empty() ) - { - this->private_->command_buffer_ = command; - } - else - { - if ( *this->private_->command_buffer_.rbegin() != '\n' ) - { - this->private_->command_buffer_ += "\n"; - } - this->private_->command_buffer_ += command; - } - - // Compile the statement in the buffer - boost::python::object code_obj; - try - { - code_obj = this->private_->compiler_( this->private_->command_buffer_ ); - } - catch ( ... ) {} - - // If an error happened during compilation, print the error message - if ( PyErr_Occurred() ) - { - PyErr_Print(); - } - // If compilation succeeded and the code object is not Py_None - else if ( code_obj ) - { - try - { - auto result = PyEval_EvalCode( code_obj.ptr(), this->private_->globals_.ptr(), nullptr ); - Py_XDECREF( result ); - } - catch ( ... ) {} - - if ( PyErr_Occurred() ) - { - if ( PyErr_ExceptionMatches( PyExc_EOFError ) ) - { - this->error_signal_( "\nKeyboardInterrupt\n" ); - PyErr_Clear(); + { + PythonInterpreterPrivate::lock_type lock(this->private_->get_mutex()); + if (!this->private_->initialized_) + { + throw std::invalid_argument("The python interpreter hasn't been initialized!"); + } + } + + // Append the command to the current command buffer + if (this->private_->command_buffer_.empty()) + { + this->private_->command_buffer_ = command; + } + else + { + if (*this->private_->command_buffer_.rbegin() != '\n') + { + this->private_->command_buffer_ += "\n"; + } + this->private_->command_buffer_ += command; + } + + // ENTER PYTHON (GIL) + PyEval_RestoreThread(this->main_thread_state_); + + // Compile the statement in the buffer + boost::python::object code_obj; + + // Clear any previous Python errors. + PyErr_Clear(); + + try + { + code_obj = this->private_->compiler_(this->private_->command_buffer_); + } + catch (...) + {} + + // If an error happened during compilation, print the error message + if (PyErr_Occurred()) + { + PyErr_Print(); + } + // If compilation succeeded and the code object is not Py_None + else if (code_obj) + { + try + { + auto result = PyEval_EvalCode(code_obj.ptr(), this->private_->globals_.ptr(), nullptr); + Py_XDECREF(result); + } + catch (...) + {} + + if (PyErr_Occurred()) + { + if (PyErr_ExceptionMatches(PyExc_EOFError)) + { + this->error_signal_("\nKeyboardInterrupt\n"); + PyErr_Clear(); + + // EXIT PYTHON before return + this->main_thread_state_ = PyEval_SaveThread(); return false; - } - else - { - PyErr_Print(); - } - } - } - // If the code object is Py_None, prompt for more input - else - { - this->prompt_signal_( this->private_->prompt2_ ); - } - - this->private_->command_buffer_.clear(); - this->prompt_signal_( this->private_->prompt1_ ); + } + else + { + PyErr_Print(); + } + } + } + // If the code object is Py_None, prompt for more input + else + { + this->prompt_signal_(this->private_->prompt2_); + } + + // EXIT PYTHON + this->main_thread_state_ = PyEval_SaveThread(); + + this->private_->command_buffer_.clear(); + this->prompt_signal_(this->private_->prompt1_); return true; } -void PythonInterpreter::run_script( const std::string& script ) +void PythonInterpreter::run_script(const std::string& script) { LOG_DEBUG("Python::run_script( {} )", script); - { - PythonInterpreterPrivate::lock_type lock( this->private_->get_mutex() ); - if ( !this->private_->initialized_ ) - { - throw std::logic_error( "The python interpreter hasn't been initialized!" ); - } - } - - // Output the script to the console - //this->output_signal_( "Running script ...\n" ); - - // Clear any previous Python errors. - PyErr_Clear(); - - // Compile the script - boost::python::object code_obj; - try - { - code_obj = this->private_->compiler_( script, "