Commit b929bb08 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Adding mechanisms to deal with compile-tools.

* Added new macros to vtkModuleMacros.cmake to add targets for build-tools. Now
  any component/module creating a tool that's used at compile time should use
  the vtk_compile_tools_target() macro.
* vtk_compile_tools_target(), besides ensuring that the target properties are
  setup properly, adds the target to the VTK_COMPILETOOLS_TARGETS list.
* As a last step, VTK_COMPILETOOLS_TARGETS are exported to both VTKTargets.cmake
  and VTKCompileToolsConfig.cmake.
* When cross compiling VTKCompileToolsConfig.cmake is imported to load
  information about all the build tools.
* vtkCompileTools is a new virtual target that can be used to build host-tools.
  It includes all the targets exported using vtk_compile_tools_target() or
  vtk_compile_tools_target_export() macros.
* For projects, like ParaView, that contain VTK, added a mechanism for the
  parent project to manage importing of the compile tools when cross compiling.

Change-Id: Ibf38868d8ea5f562c7c2682936c72bc11208c5c9
parent 01bac397
......@@ -272,9 +272,7 @@ macro(vtk_target_name _name)
endmacro()
macro(vtk_target_export _name)
if(NOT VTK_INSTALL_NO_LIBRARIES)
set_property(GLOBAL APPEND PROPERTY VTK_TARGETS ${_name})
endif()
set_property(GLOBAL APPEND PROPERTY VTK_TARGETS ${_name})
endmacro()
macro(vtk_target_install _name)
......@@ -305,6 +303,55 @@ macro(vtk_target _name)
endif()
endmacro()
#------------------------------------------------------------------------------
# Export a target for a tool that used during the compilation process.
# This is called by vtk_compile_tools_target().
macro(vtk_compile_tools_target_export _name)
set_property(GLOBAL APPEND PROPERTY VTK_COMPILETOOLS_TARGETS ${_name})
endmacro()
#------------------------------------------------------------------------------
macro(vtk_compile_tools_target_install _name)
if(NOT VTK_INSTALL_NO_DEVELOPMENT)
install(TARGETS ${_name}
EXPORT ${VTK_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${VTK_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${VTK_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${VTK_INSTALL_ARCHIVE_DIR} COMPONENT Development
)
endif()
endmacro()
#------------------------------------------------------------------------------
# vtk_compile_tools_target() is used to declare a target that builds a tool that
# is used during the building process. This macro ensures that the target is
# added to VTK_COMPILETOOLS_TARGETS global property. This also adds install
# rules for the target unless NO_INSTALL argument is specified or
# VTK_INSTALL_NO_DEVELOPMENT variable is set.
macro(vtk_compile_tools_target _name)
if (CMAKE_CROSSCOMPILING)
message(AUTHOR_WARNING
"vtk_compile_tools_target is being called when CMAKE_CROSSCOMPILING is true. "
"This generally signifies a script issue. compile-tools are not expected "
"to built, but rather imported when CMAKE_CROSSCOMPILING is ON")
endif (CMAKE_CROSSCOMPILING)
set(_install 1)
foreach(arg ${ARGN})
if("${arg}" MATCHES "^(NO_INSTALL)$")
set(_install 0)
else()
message(FATAL_ERROR "Unknown argument [${arg}]")
endif()
endforeach()
vtk_target_name(${_name})
vtk_target_label(${_name})
vtk_compile_tools_target_export(${_name})
if(_install)
vtk_compile_tools_target_install(${_name})
endif()
endmacro()
#------------------------------------------------------------------------------
function(vtk_add_library name)
add_library(${name} ${ARGN} ${headers})
vtk_target(${name})
......
......@@ -84,20 +84,11 @@ if(NOT VTK_MODULES_DIR)
set(VTK_MODULES_DIR "${VTK_BINARY_DIR}/${VTK_INSTALL_PACKAGE_DIR}/Modules")
endif()
# FIXME: Used by HashSource
# the following lines are for cross compiling support
# we may get here also from ParaView, in this case don't change the filename
IF(NOT EXPORT_EXECUTABLES_FILE)
# the generators which are needed during the build have to be imported
# from a native build, which exports them, requires cmake cvs or 2.6
IF(CMAKE_CROSSCOMPILING)
FIND_PACKAGE(VTKCompileTools REQUIRED)
ENDIF(CMAKE_CROSSCOMPILING)
SET(EXPORT_EXECUTABLES_FILE "${CMAKE_BINARY_DIR}/VTKCompileToolsConfig.cmake")
SET(EXPORT_EXECUTABLES_NAMESPACE "")
FILE(WRITE "${EXPORT_EXECUTABLES_FILE}" "#generated by VTK, do not edit\n")
ENDIF(NOT EXPORT_EXECUTABLES_FILE)
if (CMAKE_CROSSCOMPILING AND NOT COMPILE_TOOLS_IMPORTED)
# if CMAKE_CROSSCOMPILING is true, we need to import build-tools targets.
find_package(VTKCompileTools REQUIRED)
set (COMPILE_TOOLS_IMPORTED TRUE)
endif()
# FIXME: These will be removed, used by vtkzlib etc
set(VTK_INSTALL_BIN_DIR_CM24 ${VTK_INSTALL_RUNTIME_DIR})
......@@ -369,5 +360,21 @@ configure_file("${VTK_CMAKE_DIR}/CTestCustom.cmake.in"
#-----------------------------------------------------------------------------
# Export all targets at once from the build tree in their final configuration.
get_property(VTK_TARGETS GLOBAL PROPERTY VTK_TARGETS)
export(TARGETS ${VTK_TARGETS} FILE ${VTK_BINARY_DIR}/VTKTargets.cmake)
get_property(_vtk_targets GLOBAL PROPERTY VTK_TARGETS)
get_property(_vtk_compiletools_targets GLOBAL PROPERTY VTK_COMPILETOOLS_TARGETS)
set (_vtk_all_targets ${_vtk_targets} ${_vtk_compiletools_targets})
if (_vtk_all_targets)
list(REMOVE_DUPLICATES _vtk_all_targets)
export(TARGETS ${_vtk_all_targets} FILE ${VTK_BINARY_DIR}/VTKTargets.cmake)
endif()
# Add a virtual target that can be used to build all compile tools.
add_custom_target(vtkCompileTools)
if (_vtk_compiletools_targets)
list(REMOVE_DUPLICATES _vtk_compiletools_targets)
export(TARGETS ${_vtk_compiletools_targets}
FILE ${VTK_BINARY_DIR}/VTKCompileToolsConfig.cmake)
add_dependencies(vtkCompileTools ${_vtk_compiletools_targets})
endif()
unset(_vtk_targets)
unset(_vtk_compiletools_targets)
unset(_vtk_all_targets)
......@@ -42,10 +42,7 @@ ELSE (NOT UNIX)
SET(common_SRCS ${common_SRCS} tif_unix.c tif_fax3sm.c)
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(vtkmkg3states mkg3states.c)
EXPORT(TARGETS vtkmkg3states FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
IF(COMPILE_TOOLS_TARGET)
ADD_DEPENDENCIES(${COMPILE_TOOLS_TARGET} vtkmkg3states)
ENDIF(COMPILE_TOOLS_TARGET)
vtk_compile_tools_target(vtkmkg3states)
ENDIF(NOT CMAKE_CROSSCOMPILING)
ADD_CUSTOM_COMMAND(
......
......@@ -11,16 +11,5 @@ vtk_module_export_info()
IF(NOT CMAKE_CROSSCOMPILING)
INCLUDE_DIRECTORIES(${VTK_SOURCE_DIR}/Common/Core ${VTK_BINARY_DIR}/Common/Core)
VTK_ADD_EXECUTABLE(vtkEncodeString vtkEncodeString.cxx)
EXPORT(TARGETS vtkEncodeString FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
IF(COMPILE_TOOLS_TARGET)
ADD_DEPENDENCIES(${COMPILE_TOOLS_TARGET} vtkEncodeString)
ENDIF(COMPILE_TOOLS_TARGET)
IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
INSTALL(TARGETS vtkEncodeString
EXPORT ${VTK_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${VTK_INSTALL_RUNTIME_DIR} COMPONENT Development
)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
vtk_compile_tools_target(vtkEncodeString)
ENDIF(NOT CMAKE_CROSSCOMPILING)
SET(ENCODESTRING_EXE vtkEncodeString)
......@@ -15,9 +15,5 @@ SET(CMAKE_SKIP_RPATH 0)
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(vtkHashSource vtkHashSource.cxx)
TARGET_LINK_LIBRARIES(vtkHashSource vtksys)
EXPORT(TARGETS vtkHashSource FILE ${EXPORT_EXECUTABLES_FILE}
NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
IF(COMPILE_TOOLS_TARGET)
ADD_DEPENDENCIES(${COMPILE_TOOLS_TARGET} vtkHashSource)
ENDIF(COMPILE_TOOLS_TARGET)
vtk_compile_tools_target(vtkHashSource)
ENDIF(NOT CMAKE_CROSSCOMPILING)
......@@ -16,44 +16,12 @@ mark_as_advanced(VTK_MATERIALS_DIRS)
include_directories("${VTK_SOURCE_DIR}/Common/Core"
"${VTK_BINARY_DIR}/Common/Core")
# Enable shared link forwarding support it needed.
SET (ML_EXE_SUFFIX)
SET (ML_EXE_INSTALL ${VTK_INSTALL_BIN_DIR})
IF(BUILD_SHARED_LIBS AND CMAKE_SKIP_RPATH AND NOT WIN32)
SET (NEED_SHARED_FORWARD 1)
SET (ML_EXE_SUFFIX -real)
SET (ML_EXE_INSTALL ${VTK_INSTALL_LIB_DIR})
SET (ML_FORWARD_DIR_BUILD "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
SET (ML_FORWARD_DIR_INSTALL "..${ML_EXE_INSTALL}")
SET (ML_FORWARD_PATH_BUILD "\"${ML_FORWARD_DIR_BUILD}\"")
SET (ML_FORWARD_PATH_INSTALL "\"${ML_FORWARD_DIR_INSTALL}\"")
ENDIF(BUILD_SHARED_LIBS AND CMAKE_SKIP_RPATH AND NOT WIN32)
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(ProcessShader${ML_EXE_SUFFIX} ProcessShader.cxx)
TARGET_LINK_LIBRARIES(ProcessShader${ML_EXE_SUFFIX} vtksys)
EXPORT(TARGETS ProcessShader${ML_EXE_SUFFIX} FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
IF(COMPILE_TOOLS_TARGET)
ADD_DEPENDENCIES(${COMPILE_TOOLS_TARGET} ProcessShader${ML_EXE_SUFFIX})
ENDIF(COMPILE_TOOLS_TARGET)
# Add shared link forwarding executable if necessary.
IF (NEED_SHARED_FORWARD)
SET (ML_FORWARD_EXE ProcessShader${ML_EXE_SUFFIX})
CONFIGURE_FILE(
${MaterialLibrary_SOURCE_DIR}/vtk-forward.c.in
${MaterialLibrary_BINARY_DIR}/ProcessShader-forward.c
@ONLY IMMEDIATE)
ADD_EXECUTABLE(ProcessShader ${MaterialLibrary_BINARY_DIR}/ProcessShader-forward.c)
ADD_DEPENDENCIES(ProcessShader ProcessShader${ML_EXE_SUFFIX})
EXPORT(TARGETS ProcessShader FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
IF(COMPILE_TOOLS_TARGET)
ADD_DEPENDENCIES(${COMPILE_TOOLS_TARGET} ProcessShader)
ENDIF(COMPILE_TOOLS_TARGET)
ENDIF (NEED_SHARED_FORWARD)
ADD_EXECUTABLE(ProcessShader ProcessShader.cxx)
TARGET_LINK_LIBRARIES(ProcessShader vtksys)
vtk_compile_tools_target(ProcessShader)
ENDIF(NOT CMAKE_CROSSCOMPILING)
# Macro to obtain the relative path of a file.
MACRO(GET_RELATIVE_PATH __path __file __result)
STRING(REGEX REPLACE "/" ";" __dirfilelist "${__file}")
......
......@@ -28,10 +28,7 @@ include_directories(${VTK_SOURCE_DIR}/Common/Core
IF(NOT CMAKE_CROSSCOMPILING)
ADD_EXECUTABLE(vtkParseOGLExt Tokenizer.cxx ParseOGLExt.cxx)
EXPORT(TARGETS vtkParseOGLExt FILE ${EXPORT_EXECUTABLES_FILE} NAMESPACE "${EXPORT_EXECUTABLES_NAMESPACE}" APPEND)
IF(COMPILE_TOOLS_TARGET)
ADD_DEPENDENCIES(${COMPILE_TOOLS_TARGET} vtkParseOGLExt)
ENDIF(COMPILE_TOOLS_TARGET)
vtk_compile_tools_target(vtkParseOGLExt)
ENDIF(NOT CMAKE_CROSSCOMPILING)
SET(PARSEOGLEXT_EXE vtkParseOGLExt)
......
......@@ -22,21 +22,15 @@ if(NOT CMAKE_CROSSCOMPILING)
if(VTK_WRAP_TCL OR VTK_WRAP_PYTHON OR VTK_WRAP_JAVA)
add_executable(vtkWrapHierarchy vtkParse.tab.c vtkParsePreprocess.c
vtkParseExtras.c vtkWrapHierarchy.c)
vtk_target(vtkWrapHierarchy)
if(COMPILE_TOOLS_TARGET)
add_dependencies(${COMPILE_TOOLS_TARGET} vtkWrapHierarchy)
endif()
vtk_compile_tools_target(vtkWrapHierarchy)
endif()
if(VTK_WRAP_TCL)
add_executable(vtkWrapTcl vtkWrapTcl.c vtkParseMain.c vtkParse.tab.c
vtkParsePreprocess.c vtkParseExtras.c vtkParseHierarchy.c)
add_executable(vtkWrapTclInit vtkWrapTclInit.c)
vtk_target(vtkWrapTcl)
vtk_target(vtkWrapTclInit)
if(COMPILE_TOOLS_TARGET)
add_dependencies(${COMPILE_TOOLS_TARGET} vtkWrapTcl vtkWrapTclInit)
endif()
vtk_compile_tools_target(vtkWrapTcl)
vtk_compile_tools_target(vtkWrapTclInit)
endif()
if(VTK_WRAP_PYTHON)
......@@ -51,11 +45,8 @@ if(NOT CMAKE_CROSSCOMPILING)
vtkParseExtras.c vtkParseHierarchy.c)
add_executable(vtkWrapPythonInit vtkWrapPythonInit.c)
target_link_libraries(vtkWrapPython ${VTK_PYTHON_LIBRARIES})
vtk_target(vtkWrapPython)
vtk_target(vtkWrapPythonInit)
if(COMPILE_TOOLS_TARGET)
add_dependencies(${COMPILE_TOOLS_TARGET} vtkWrapPython vtkWrapPythonInit)
endif()
vtk_compile_tools_target(vtkWrapPython)
vtk_compile_tools_target(vtkWrapPythonInit)
endif()
if(VTK_WRAP_JAVA)
......@@ -63,11 +54,8 @@ if(NOT CMAKE_CROSSCOMPILING)
vtkParsePreprocess.c vtkParseExtras.c vtkParseHierarchy.c)
add_executable(vtkWrapJava vtkWrapJava.c vtkParseMain.c vtkParse.tab.c
vtkParsePreprocess.c vtkParseExtras.c vtkParseHierarchy.c)
vtk_target(vtkParseJava)
vtk_target(vtkWrapJava)
if(COMPILE_TOOLS_TARGET)
add_dependencies(${COMPILE_TOOLS_TARGET} vtkParseJava vtkWrapJava)
endif()
vtk_compile_tools_target(vtkParseJava)
vtk_compile_tools_target(vtkWrapJava)
endif()
endif()
......
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