diff --git a/CMake/ctkMacroSimpleTest.cmake b/CMake/ctkMacroSimpleTest.cmake index bfb9d5a42a..67dcf6b2dd 100644 --- a/CMake/ctkMacroSimpleTest.cmake +++ b/CMake/ctkMacroSimpleTest.cmake @@ -30,5 +30,8 @@ macro(SIMPLE_TEST testname) add_test(NAME ${testname} COMMAND $ ${testname} ${ARGN}) set_property(TEST ${testname} PROPERTY LABELS ${KIT}) + + set_property(TEST ${testname} PROPERTY ENVIRONMENT "${CTK_TEST_LAUNCH_BUILD_ENVIRONMENT}") + endmacro() diff --git a/CMake/ctkMacroSimpleTestWithData.cmake b/CMake/ctkMacroSimpleTestWithData.cmake index 4e7dcc1bc3..373656760e 100644 --- a/CMake/ctkMacroSimpleTestWithData.cmake +++ b/CMake/ctkMacroSimpleTestWithData.cmake @@ -60,5 +60,7 @@ macro(SIMPLE_TEST_WITH_DATA testname baseline_relative_location) ${ARGN} ) set_property(TEST ${testname} PROPERTY LABELS ${KIT}) + + set_property(TEST ${testname} PROPERTY ENVIRONMENT "${CTK_TEST_LAUNCH_BUILD_ENVIRONMENT}") endmacro() diff --git a/CMakeExternals/DCMTK.cmake b/CMakeExternals/DCMTK.cmake index c9421a3a06..19ba5878a3 100644 --- a/CMakeExternals/DCMTK.cmake +++ b/CMakeExternals/DCMTK.cmake @@ -100,6 +100,33 @@ if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) ) set(DCMTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + set(_lib_subdir lib) + if(WIN32) + set(_lib_subdir bin) + endif() + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${DCMTK_DIR}/${_lib_subdir}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + # paths + set(${proj}_PATHS_LAUNCHER_BUILD ${DCMTK_DIR}/bin/) + mark_as_superbuild( + VARS ${proj}_PATHS_LAUNCHER_BUILD + LABELS "PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/ITK.cmake b/CMakeExternals/ITK.cmake index b40d1deb86..6b9df9e27c 100644 --- a/CMakeExternals/ITK.cmake +++ b/CMakeExternals/ITK.cmake @@ -67,6 +67,26 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) ) set(ITK_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + set(_lib_subdir lib) + if(WIN32) + set(_lib_subdir bin) + endif() + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${ITK_DIR}/${_lib_subdir}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/Log4Qt.cmake b/CMakeExternals/Log4Qt.cmake index 492d9646b7..34ae9fcf40 100644 --- a/CMakeExternals/Log4Qt.cmake +++ b/CMakeExternals/Log4Qt.cmake @@ -77,6 +77,23 @@ if(NOT DEFINED Log4Qt_DIR) set(Log4Qt_INSTALL_DIR ${ep_install_dir}) set(Log4Qt_DIR ${Log4Qt_INSTALL_DIR}/lib/cmake/Log4Qt/) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + set(_lib_subdir bin) + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${CMAKE_BINARY_DIR}/${proj}-build/${_lib_subdir}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/PythonQt.cmake b/CMakeExternals/PythonQt.cmake index 1989e44f51..cb372cb664 100644 --- a/CMakeExternals/PythonQt.cmake +++ b/CMakeExternals/PythonQt.cmake @@ -121,6 +121,21 @@ if(NOT DEFINED PYTHONQT_INSTALL_DIR) ) set(PYTHONQT_INSTALL_DIR ${ep_install_dir}) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${CMAKE_BINARY_DIR}/${proj}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/QtSOAP.cmake b/CMakeExternals/QtSOAP.cmake index 7866953a4a..547c0d7845 100644 --- a/CMakeExternals/QtSOAP.cmake +++ b/CMakeExternals/QtSOAP.cmake @@ -77,6 +77,23 @@ if(NOT DEFINED QtSOAP_DIR) ) set(QtSOAP_DIR "${CMAKE_BINARY_DIR}/${proj}-build") + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + set(_lib_subdir bin) + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${QtSOAP_DIR}/${_lib_subdir}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/QtTesting.cmake b/CMakeExternals/QtTesting.cmake index ba6b7e498e..e52c556dab 100644 --- a/CMakeExternals/QtTesting.cmake +++ b/CMakeExternals/QtTesting.cmake @@ -90,6 +90,21 @@ if(NOT DEFINED QtTesting_DIR) set(QtTesting_INSTALL_DIR ${ep_install_dir}) set(QtTesting_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${QtTesting_DIR}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/VTK.cmake b/CMakeExternals/VTK.cmake index aab93a92d4..b2a31913e0 100644 --- a/CMakeExternals/VTK.cmake +++ b/CMakeExternals/VTK.cmake @@ -187,6 +187,25 @@ if(NOT DEFINED VTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) ) set(VTK_DIR ${CMAKE_BINARY_DIR}/${proj}-build) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + # library paths + set(_library_output_subdir bin) + if(UNIX) + set(_library_output_subdir lib) + endif() + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${VTK_DIR}/${_library_output_subdir}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeExternals/qRestAPI.cmake b/CMakeExternals/qRestAPI.cmake index c5fd0b0cdf..c94010b8f0 100644 --- a/CMakeExternals/qRestAPI.cmake +++ b/CMakeExternals/qRestAPI.cmake @@ -75,6 +75,21 @@ if(NOT DEFINED ${proj}_DIR) ) set(qRestAPI_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) + #----------------------------------------------------------------------------- + # Launcher setting specific to build tree + + # library paths + set(${proj}_LIBRARY_PATHS_LAUNCHER_BUILD ${qRestAPI_DIR}/) + mark_as_superbuild( + VARS ${proj}_LIBRARY_PATHS_LAUNCHER_BUILD + LABELS "LIBRARY_PATHS_LAUNCHER_BUILD" + ) + + #----------------------------------------------------------------------------- + # Launcher setting specific to install tree + + # NA + else() ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES}) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index a2777f6a52..59141ac790 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1058,6 +1058,73 @@ if(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR) set(CTK_SUPERBUILD_BINARY_DIR ${CTK_BINARY_DIR}) endif() +#----------------------------------------------------------------------------- +# Configure test launcher environment variables for the build tree + +set(CTK_PATHS_LAUNCHER_BUILD ) +set(CTK_LIBRARY_PATHS_LAUNCHER_BUILD ) +set(CTK_TEST_LAUNCH_BUILD_ENVIRONMENT ) + +if(${CMAKE_VERSION} VERSION_EQUAL "3.9" OR ${CMAKE_VERSION} VERSION_GREATER "3.9") + + # CMake 3.9 introduces support for "$" generator expression + # and GENERATOR_IS_MULTI_CONFIG property. + + # Generate expression evaluating to the current build configuration or "." + # for single configuration generator + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + set(_cfg_intdir $,.>) + + # Collect "library paths" and "paths" defined in external projects. + # Values for each are retrieved based on the label associated with the + # corresponding `mark_as_superbuild()` call used in each external project. + + # Library paths + set(CTK_LIBRARY_PATHS_LAUNCHER_BUILD + ${QT_INSTALLED_LIBRARY_DIR} + ) + foreach(varname IN LISTS CTK_EP_LABEL_LIBRARY_PATHS_LAUNCHER_BUILD) + set(value ${${varname}}) + list(TRANSFORM value REPLACE "" "${_cfg_intdir}") + list(APPEND CTK_LIBRARY_PATHS_LAUNCHER_BUILD ${value}) + endforeach() + + # Paths + set(CTK_PATHS_LAUNCHER_BUILD) + foreach(varname IN LISTS CTK_EP_LABEL_PATHS_LAUNCHER_BUILD) + set(value ${${varname}}) + list(TRANSFORM value REPLACE "" "${_cfg_intdir}") + list(APPEND CTK_PATHS_LAUNCHER_BUILD ${value}) + endforeach() + + # Set test launch environment specific to the build tree + if(WIN32) + # On Windows, concatenate the build and library paths directly since a list in CMake + # is a ; separated group of strings. + set(separator ";") + set(env_paths "${CTK_PATHS_LAUNCHER_BUILD};${CTK_LIBRARY_PATHS_LAUNCHER_BUILD}") + + set(CTK_TEST_LAUNCH_BUILD_ENVIRONMENT + "PATH=${env_paths}${separator}$ENV{PATH}" + ) + else() + # On UNIX-like systems, create colon-separated strings for paths and library paths + set(separator ":") + ctk_list_to_string(${separator} "${CTK_PATHS_LAUNCHER_BUILD}" env_paths) + ctk_list_to_string(${separator} "${CTK_LIBRARY_PATHS_LAUNCHER_BUILD}" env_library_paths) + + set(variable_name "LD_LIBRARY_PATH") + if(APPLE) + set(variable_name "DYLD_LIBRARY_PATH") + endif() + + set(CTK_TEST_LAUNCH_BUILD_ENVIRONMENT + "PATH=${env_paths}${separator}$ENV{PATH}" + "${variable_name}=${env_library_paths}${separator}$ENV{${variable_name}}" + ) + endif() +endif() + #----------------------------------------------------------------------------- # Configure files with settings # diff --git a/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt b/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt index 8434d43437..15da9b683d 100644 --- a/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt +++ b/Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt @@ -67,7 +67,7 @@ SIMPLE_TEST(ctkDICOMThumbnailListWidgetTest1 if(EXISTS "${CTKData_DIR}") SIMPLE_TEST(ctkDICOMAppWidgetTest1 ${CTKData_DIR}/Data/DICOM/MRHEAD) SIMPLE_TEST(ctkDICOMBrowserTest) - set_property(TEST ctkDICOMBrowserTest PROPERTY ENVIRONMENT "CTKData_DIR=${CTKData_DIR}") + set_property(TEST ctkDICOMBrowserTest PROPERTY ENVIRONMENT "CTKData_DIR=${CTKData_DIR}" APPEND) SIMPLE_TEST(ctkDICOMBrowserTest1 ${CTKData_DIR}/Data/DICOM/MRHEAD) SIMPLE_TEST(ctkDICOMItemViewTest1 ${CTKData_DIR}/Data/DICOM/MRHEAD/000055.IMA) SIMPLE_TEST(ctkDICOMImageTest1 ${CTKData_DIR}/Data/DICOM/MRHEAD/000055.IMA)