Commit 557a980c authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

ENH: Cleaning up shared forwarding. Adding a new cmake-function to

ParaViewMacros "add_executable_with_forwarding" which can be used directly in
place of add_executable to handle shared forwarding. This will make it cleaner
when writing custom applications.
parent 1fd83292
......@@ -225,24 +225,29 @@ FUNCTION(build_paraview_client BPC_NAME)
SET (PV_EXE_LIST ${BPC_NAME})
# needed to set up shared forwarding correctly.
ADD_EXECUTABLE(${pv_exe_name} WIN32 ${MAKE_BUNDLE}
add_executable_with_forwarding(pv_exe_suffix
${BPC_NAME} WIN32 ${MAKE_BUNDLE}
${BPC_NAME}_main.cxx
${exe_icon}
${apple_bundle_sources}
${EXE_SRCS}
)
SET (pv_exe_name ${BPC_NAME}${pv_exe_suffix})
TARGET_LINK_LIBRARIES(${pv_exe_name}
pqApplicationComponents
${QT_QTMAIN_LIBRARY}
${BPC_EXTRA_DEPENDENCIES}
)
IF (PV_EXE_INSTALL)
# PV_EXE_INSTALL is set to lib-dir when shared forwarding is enabled.
INSTALL(TARGETS ${BPC_NAME}
DESTINATION ${PV_INSTALL_BIN_DIR}
COMPONENT BrandedRuntime)
IF (pv_exe_suffix)
# Shared forwarding enabled.
INSTALL(TARGETS ${pv_exe_name}
DESTINATION ${PV_EXE_INSTALL}
DESTINATION ${PV_INSTALL_LIB_DIR}
COMPONENT BrandedRuntime)
ENDIF (PV_EXE_INSTALL)
ENDIF (pv_exe_suffix)
IF (BPC_MAKE_INITIALIZER_LIBRARY)
TARGET_LINK_LIBRARIES(${pv_exe_name}
......@@ -257,23 +262,4 @@ FUNCTION(build_paraview_client BPC_NAME)
SET_TARGET_PROPERTIES(${pv_exe_name} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${BPC_APPLICATION_NAME}")
ENDIF (APPLE)
# Add shared link forwarding executables if necessary.
IF(PV_NEED_SHARED_FORWARD)
FOREACH(pvexe ${PV_EXE_LIST})
SET(PV_FORWARD_EXE ${pvexe}${PV_EXE_SUFFIX})
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/Servers/Executables/pv-forward.c.in
${CMAKE_CURRENT_BINARY_DIR}/${pvexe}-forward.c
@ONLY IMMEDIATE)
ADD_EXECUTABLE(${pvexe} ${CMAKE_CURRENT_BINARY_DIR}/${pvexe}-forward.c)
ADD_DEPENDENCIES(${pvexe} ${pvexe}${PV_EXE_SUFFIX})
IF (PV_INSTALL_BIN_DIR)
INSTALL(TARGETS ${pvexe}
DESTINATION ${PV_INSTALL_BIN_DIR}
COMPONENT BrandedRuntime)
ENDIF (PV_INSTALL_BIN_DIR)
ENDFOREACH(pvexe)
ENDIF(PV_NEED_SHARED_FORWARD)
ENDFUNCTION(build_paraview_client)
......@@ -120,25 +120,6 @@ IF(NOT PV_INSTALL_DATA_DIR)
ENDIF(NOT PV_INSTALL_DATA_DIR)
#########################################################################
# Enable shared link forwarding support if needed.
SET(PV_EXE_SUFFIX)
SET(PV_EXE_INSTALL ${PV_INSTALL_BIN_DIR})
IF(BUILD_SHARED_LIBS AND CMAKE_SKIP_RPATH)
IF(NOT WIN32)
SET(PV_NEED_SHARED_FORWARD 1)
SET(PV_EXE_SUFFIX -real)
SET(PV_EXE_INSTALL ${PV_INSTALL_LIB_DIR})
SET(PV_FORWARD_DIR_BUILD "${EXECUTABLE_OUTPUT_PATH}")
SET(PV_FORWARD_DIR_INSTALL "../${PV_EXE_INSTALL}")
SET(PV_FORWARD_PATH_BUILD "\"${PV_FORWARD_DIR_BUILD}\"")
SET(PV_FORWARD_PATH_INSTALL "\"${PV_FORWARD_DIR_INSTALL}\"")
FOREACH(ldir ${PARAVIEW_EXTRA_LINK_DIRECTORIES})
SET(PV_FORWARD_PATH_BUILD "${PV_FORWARD_PATH_BUILD}, \"${ldir}\"")
SET(PV_FORWARD_PATH_INSTALL "${PV_FORWARD_PATH_INSTALL}, \"${ldir}\"")
ENDFOREACH(ldir)
ENDIF(NOT WIN32)
ENDIF(BUILD_SHARED_LIBS AND CMAKE_SKIP_RPATH)
# Install no development files by default, but allow the user to get
# them installed by setting PV_INSTALL_DEVELOPMENT to true.
OPTION(PARAVIEW_INSTALL_DEVELOPMENT "Install ParaView plugin development files." OFF)
......
......@@ -70,3 +70,69 @@ MACRO(pv_set_if_not_set name value)
SET(${name} "${value}")
ENDIF(NOT DEFINED "${name}")
ENDMACRO(pv_set_if_not_set)
#----------------------------------------------------------------------------
# Function for adding an executable with support for shared forwarding.
# Typically, one just uses ADD_EXECUTABLE to add an executable target. However
# on linuxes when rpath is off, and shared libararies are on, to over come the
# need for setting the LD_LIBRARY_PATH, we use shared-forwarding. This macro
# makes it easier to employ shared forwarding if needed.
# ARGUMENTS:
# out_real_exe_suffix -- (out) suffix to be added to the exe-target to locate the
# real executable target when shared forwarding is employed.
# This is empty when shared forwarding is not needed.
# exe_name -- (in) exe target name i.e. the first argument to
# ADD_EXECUTABLE.
# Any remaining arguments are simply passed on to the ADD_EXECUTABLE call.
# While writing install rules for this executable. One typically does the
# following.
# INSTALL(TARGETS exe_name
# DESTINATION "bin"
# COMPONENT Runtime)
# IF (pv_exe_suffix)
# # Shared forwarding enabled.
# INSTALL(TARGETS exe_name${out_real_exe_suffix}
# DESTINATION "lib"
# COMPONENT Runtime)
# ENDIF (pv_exe_suffix)
#----------------------------------------------------------------------------
FUNCTION (add_executable_with_forwarding
out_real_exe_suffix
exe_name)
if (NOT DEFINED PV_INSTALL_LIB_DIR)
MESSAGE(FATAL_ERROR
"PV_INSTALL_LIB_DIR variable must be set before calling add_executable_with_forwarding"
)
endif (NOT DEFINED PV_INSTALL_LIB_DIR)
if (NOT DEFINED PV_INSTALL_BIN_DIR)
MESSAGE(FATAL_ERROR
"PV_INSTALL_BIN_DIR variable must be set before calling add_executable_with_forwarding"
)
endif (NOT DEFINED PV_INSTALL_BIN_DIR)
SET(PV_EXE_SUFFIX)
IF (BUILD_SHARED_LIBS AND CMAKE_SKIP_RPATH)
IF(NOT WIN32)
SET(PV_EXE_SUFFIX -real)
SET(PV_FORWARD_DIR_BUILD "${EXECUTABLE_OUTPUT_PATH}")
SET(PV_FORWARD_DIR_INSTALL "../${PV_INSTALL_LIB_DIR}")
SET(PV_FORWARD_PATH_BUILD "\"${PV_FORWARD_DIR_BUILD}\"")
SET(PV_FORWARD_PATH_INSTALL "\"${PV_FORWARD_DIR_INSTALL}\"")
SET(PV_FORWARD_EXE ${exe_name}${PV_EXE_SUFFIX})
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/Servers/Executables/pv-forward.c.in
${CMAKE_CURRENT_BINARY_DIR}/${exe_name}-forward.c
@ONLY IMMEDIATE)
add_executable(${exe_name}
${CMAKE_CURRENT_BINARY_DIR}/${exe_name}-forward.c)
ADD_DEPENDENCIES(${exe_name} ${exe_name}${PV_EXE_SUFFIX})
ENDIF(NOT WIN32)
ENDIF (BUILD_SHARED_LIBS AND CMAKE_SKIP_RPATH)
add_executable(${exe_name}${PV_EXE_SUFFIX} ${ARGN})
set (${out_real_exe_suffix} "${PV_EXE_SUFFIX}" PARENT_SCOPE)
ENDFUNCTION (add_executable_with_forwarding)
......@@ -21,13 +21,20 @@ ENDIF(VTK_WRAP_TCL)
# Add main server executables.
SET(PV_EXE_LIST pvserver pvrenderserver pvdataserver)
FOREACH(pvexe ${PV_EXE_LIST})
ADD_EXECUTABLE(${pvexe}${PV_EXE_SUFFIX} ${pvexe}.cxx)
TARGET_LINK_LIBRARIES(${pvexe}${PV_EXE_SUFFIX} ${LIBS})
add_executable_with_forwarding(pv_exe_suffix
${pvexe} ${pvexe}.cxx)
TARGET_LINK_LIBRARIES(${pvexe}${pv_exe_suffix} ${LIBS})
# Install exe
IF(NOT PV_INSTALL_NO_RUNTIME)
INSTALL(TARGETS ${pvexe}${PV_EXE_SUFFIX}
DESTINATION ${PV_EXE_INSTALL}
COMPONENT Runtime)
INSTALL(TARGETS ${pvexe}
DESTINATION ${PV_INSTALL_BIN_DIR}
COMPONENT Runtime)
IF (pv_exe_suffix)
# Shared forwarding enabled.
INSTALL(TARGETS ${pvexe}${pv_exe_suffix}
DESTINATION ${PV_INSTALL_LIB_DIR}
COMPONENT Runtime)
ENDIF (pv_exe_suffix)
ENDIF(NOT PV_INSTALL_NO_RUNTIME)
ENDFOREACH(pvexe)
......@@ -49,30 +56,18 @@ MARK_AS_ADVANCED(PV_TEST_CLIENT)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/vtkSMTestDriverConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/vtkSMTestDriverConfig.h @ONLY ESCAPE_QUOTES)
ADD_EXECUTABLE(smTestDriver${PV_EXE_SUFFIX} vtkSMTestDriver.cxx)
TARGET_LINK_LIBRARIES(smTestDriver${PV_EXE_SUFFIX} vtksys)
IF (NOT PV_INSTALL_NO_RUNTIME)
INSTALL(TARGETS smTestDriver${PV_EXE_SUFFIX}
DESTINATION ${PV_EXE_INSTALL}
COMPONENT Runtime)
ENDIF (NOT PV_INSTALL_NO_RUNTIME)
SET (PV_EXE_LIST ${PV_EXE_LIST} smTestDriver)
add_executable_with_forwarding(pv_exe_suffix smTestDriver vtkSMTestDriver.cxx)
TARGET_LINK_LIBRARIES(smTestDriver${pv_exe_suffix} vtksys)
# Add shared link forwarding executables if necessary.
IF(PV_NEED_SHARED_FORWARD)
FOREACH(pvexe ${PV_EXE_LIST})
SET(PV_FORWARD_EXE ${pvexe}${PV_EXE_SUFFIX})
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/Servers/Executables/pv-forward.c.in
${CMAKE_CURRENT_BINARY_DIR}/${pvexe}-forward.c
@ONLY IMMEDIATE)
ADD_EXECUTABLE(${pvexe} ${CMAKE_CURRENT_BINARY_DIR}/${pvexe}-forward.c)
ADD_DEPENDENCIES(${pvexe} ${pvexe}${PV_EXE_SUFFIX})
IF(NOT PV_INSTALL_NO_RUNTIME)
# Install
INSTALL(TARGETS ${pvexe}
IF (NOT PV_INSTALL_NO_RUNTIME)
INSTALL(TARGETS smTestDriver
DESTINATION ${PV_INSTALL_BIN_DIR}
COMPONENT Runtime)
ENDIF(NOT PV_INSTALL_NO_RUNTIME)
ENDFOREACH(pvexe)
ENDIF(PV_NEED_SHARED_FORWARD)
IF (pv_exe_suffix)
# Shared forwarding enabled.
INSTALL(TARGETS smTestDriver${pv_exe_suffix}
DESTINATION ${PV_INSTALL_LIB_DIR}
COMPONENT Runtime)
ENDIF (pv_exe_suffix)
ENDIF (NOT PV_INSTALL_NO_RUNTIME)
......@@ -444,23 +444,10 @@ SET(GUI_CONFIG_FILES
)
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(vtkSMExtractDocumentation${PV_EXE_SUFFIX} vtkSMExtractDocumentation.cxx)
add_executable_with_forwarding(PV_EXE_SUFFIX
vtkSMExtractDocumentation vtkSMExtractDocumentation.cxx)
TARGET_LINK_LIBRARIES(vtkSMExtractDocumentation${PV_EXE_SUFFIX} vtkPVServerManager)
EXPORT(TARGETS vtkSMExtractDocumentation${PV_EXE_SUFFIX} FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
# Add shared link forwarding executables if necessary.
IF(PV_NEED_SHARED_FORWARD)
SET(edexe vtkSMExtractDocumentation)
SET(PV_FORWARD_EXE ${edexe}${PV_EXE_SUFFIX})
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/Servers/Executables/pv-forward.c.in
${CMAKE_CURRENT_BINARY_DIR}/${edexe}-forward.c
@ONLY IMMEDIATE)
ADD_EXECUTABLE(${edexe} ${CMAKE_CURRENT_BINARY_DIR}/${edexe}-forward.c)
ADD_DEPENDENCIES(${edexe} ${edexe}${PV_EXE_SUFFIX})
INSTALL(TARGETS ${edexe} DESTINATION ${PV_INSTALL_BIN_DIR} COMPONENT Runtime)
ENDIF(PV_NEED_SHARED_FORWARD)
ENDIF(NOT CMAKE_CROSSCOMPILING)
IF(CMAKE_CROSSCOMPILING)
......
......@@ -32,10 +32,12 @@ ADD_LIBRARY(vtkPVPython
vtkPVPythonOptions.cxx
vtkPVProcessModulePythonHelper.cxx)
ADD_EXECUTABLE(pvpython${PV_EXE_SUFFIX}
add_executable_with_forwarding(PV_EXE_SUFFIX
pvpython
pvpython.cxx)
ADD_EXECUTABLE(pvbatch${PV_EXE_SUFFIX}
add_executable_with_forwarding(PV_EXE_SUFFIX
pvbatch
pvbatch.cxx)
IF(CMAKE_SYSTEM_NAME MATCHES "AIX")
......@@ -147,9 +149,15 @@ INSTALL(TARGETS vtkPVPythonInterpretor vtkPVPython
SET(PV_EXE_LIST pvpython pvbatch)
FOREACH(pvexe ${PV_EXE_LIST})
IF(NOT PV_INSTALL_NO_RUNTIME)
INSTALL(TARGETS ${pvexe}
DESTINATION ${PV_INSTALL_BIN_DIR}
COMPONENT Runtime)
IF (PV_EXE_SUFFIX)
# Shared forwarding enabled.
INSTALL(TARGETS ${pvexe}${PV_EXE_SUFFIX}
DESTINATION ${PV_EXE_INSTALL}
DESTINATION ${PV_INSTALL_LIB_DIR}
COMPONENT Runtime)
ENDIF (PV_EXE_SUFFIX)
ENDIF(NOT PV_INSTALL_NO_RUNTIME)
ENDFOREACH(pvexe)
......@@ -158,20 +166,3 @@ ENDFOREACH(pvexe)
INCLUDE (${VTK_BINARY_DIR}/Wrapping/Tcl/LocalUserOptions.cmake OPTIONAL)
INCLUDE (${VTK_SOURCE_DIR}/Wrapping/Tcl/LocalUserOptions.cmake OPTIONAL)
# Add shared link forwarding executables if necessary.
IF(PV_NEED_SHARED_FORWARD)
FOREACH(pvexe ${PV_EXE_LIST})
SET(PV_FORWARD_EXE ${pvexe}${PV_EXE_SUFFIX})
CONFIGURE_FILE(
${ParaView_SOURCE_DIR}/Servers/Executables/pv-forward.c.in
${CMAKE_CURRENT_BINARY_DIR}/${pvexe}-forward.c
@ONLY IMMEDIATE)
ADD_EXECUTABLE(${pvexe} ${CMAKE_CURRENT_BINARY_DIR}/${pvexe}-forward.c)
ADD_DEPENDENCIES(${pvexe} ${pvexe}${PV_EXE_SUFFIX})
IF(NOT PV_INSTALL_NO_RUNTIME)
INSTALL(TARGETS ${pvexe}
DESTINATION ${PV_INSTALL_BIN_DIR}
COMPONENT Runtime)
ENDIF(NOT PV_INSTALL_NO_RUNTIME)
ENDFOREACH(pvexe)
ENDIF(PV_NEED_SHARED_FORWARD)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment