Commit bc51f8e3 authored by Dave DeMarle's avatar Dave DeMarle
Browse files

fix and restore example of external module

Install more cmake infrastructure to build external modules
from install tree.
Update vtkLocal example to modular VTK mechanics.
Note:
  wrapped modules still have problems

Change-Id: I2a46fc2f3ec32e05c986fa4cc92f3ad35ee7c12a
parent 7d82f600
......@@ -329,6 +329,8 @@ if (NOT VTK_INSTALL_NO_DEVELOPMENT)
CMake/GenerateExportHeader.cmake
CMake/pythonmodules.h.in
CMake/UseVTK.cmake
CMake/FindTCL.cmake
CMake/vtkTclTkMacros.cmake
CMake/vtk-forward.c.in
CMake/vtkForwardingExecutable.cmake
CMake/vtkJavaWrapping.cmake
......@@ -336,6 +338,7 @@ if (NOT VTK_INSTALL_NO_DEVELOPMENT)
CMake/vtkModuleHeaders.cmake.in
CMake/vtkModuleInfo.cmake.in
CMake/vtkModuleMacros.cmake
CMake/vtkExternalModuleMacros.cmake
CMake/vtkObjectFactory.cxx.in
CMake/vtkObjectFactory.h.in
CMake/vtkPythonWrapping.cmake
......
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
# Set the project/library name here. Classes should be declared as
# "class vtkLocal_EXPORT vtkFoo", where vtkLocal is the name of the
# project set here.
PROJECT(vtkLocal)
# Set your list of sources here. Do not change the name of the
# vtkLocal_SRCS variable.
SET(vtkLocal_SRCS
vtkLocalExample.cxx
)
# List the kits from VTK that are needed by this project.
SET(vtkLocal_LIBS
vtkCommon
)
#-----------------------------------------------------------------------------
# Most users should not need to change anything below this line.
# Need to include class headers and the configuration header.
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
# Setup output paths.
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH
"Single output directory for building all libraries.")
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH
"Single output directory for building all executables.")
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
project(vtkLocalExample)
cmake_minimum_required(VERSION 2.8)
# Find and load VTK settings.
IF(NOT VTK_BINARY_DIR)
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
ENDIF(NOT VTK_BINARY_DIR)
# Give user option of building shared or static libraries. Default to
# the choice made for VTK.
OPTION(BUILD_SHARED_LIBS "Build with shared libraries."
${VTK_BUILD_SHARED_LIBS})
# Set VTKLOCAL_BUILD_SHARED_LIBS to 1 or 0 for use in creating the
# configuration header.
IF(BUILD_SHARED_LIBS)
SET(VTKLOCAL_BUILD_SHARED_LIBS_CONFIG 1)
ELSE(BUILD_SHARED_LIBS)
SET(VTKLOCAL_BUILD_SHARED_LIBS_CONFIG 0)
ENDIF(BUILD_SHARED_LIBS)
if(NOT VTK_BINARY_DIR)
find_package(VTK 6.0 REQUIRED NO_MODULE)
include(${VTK_USE_FILE})
endif()
IF(VTK_FOUND)
# If this is a build tree, provide an option for putting this
# project's executables and libraries in with VTK's.
IF (EXISTS ${VTK_DIR}/bin)
OPTION(USE_VTK_OUTPUT_PATHS
"Use VTK's output directory for this project's executables and libraries."
OFF)
MARK_AS_ADVANCED (USE_VTK_OUTPUT_PATHS)
IF (USE_VTK_OUTPUT_PATHS)
SET (LIBRARY_OUTPUT_PATH ${VTK_DIR}/bin)
SET (EXECUTABLE_OUTPUT_PATH ${VTK_DIR}/bin)
ENDIF (USE_VTK_OUTPUT_PATHS)
ENDIF (EXISTS ${VTK_DIR}/bin)
include(${VTK_CMAKE_DIR}/vtkExternalModuleMacros.cmake)
# Create the header to configure the classes.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/vtkLocalConfigure.h.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Configure.h
@ONLY IMMEDIATE)
# Use wrapping hints for this project.
SET(VTK_WRAP_HINTS "${PROJECT_SOURCE_DIR}/hints")
# Create the instantiator for these classes.
SET(VTK_USE_INSTANTIATOR_NEW 1)
VTK_MAKE_INSTANTIATOR3("${PROJECT_NAME}Instantiator"
vtkLocalInstantiator_SRCS
"${vtkLocal_SRCS}"
"VTK_${PROJECT_NAME}_EXPORT"
${PROJECT_BINARY_DIR}
"${PROJECT_NAME}Configure.h")
# Create the library.
ADD_LIBRARY(${PROJECT_NAME} ${vtkLocal_SRCS} ${vtkLocalInstantiator_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${vtkLocal_LIBS})
# Create Tcl wrappers if VTK is wrapped in Tcl.
IF(VTK_WRAP_TCL)
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapTcl.cmake)
VTK_WRAP_TCL3(${PROJECT_NAME}TCL vtkLocalTCL_SRCS "${vtkLocal_SRCS}" "")
ADD_LIBRARY(${PROJECT_NAME}TCL ${vtkLocalTCL_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}TCL ${PROJECT_NAME})
FOREACH(c ${vtkLocal_LIBS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}TCL ${c}TCL)
ENDFOREACH(c)
# Create the list of kits that are required.
SET(VTKLOCAL_KITS "")
FOREACH(c ${vtkLocal_LIBS})
SET(VTKLOCAL_KITS "${VTKLOCAL_KITS} ${c}")
ENDFOREACH(c)
FOREACH(c ${vtkLocal_SRCS})
GET_FILENAME_COMPONENT(VTKLOCAL_LAST_CLASS ${c} NAME_WE)
ENDFOREACH(c)
IF(CMAKE_CONFIGURATION_TYPES)
FOREACH(config ${CMAKE_CONFIGURATION_TYPES})
SET(VTKLOCAL_TCL_LIBRARY_DIR "${LIBRARY_OUTPUT_PATH}/${config}")
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pkgIndex.tcl.in
${PROJECT_BINARY_DIR}/${config}/pkgIndex.tcl
@ONLY IMMEDIATE)
ENDFOREACH(config)
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(VTKLOCAL_TCL_LIBRARY_DIR "${LIBRARY_OUTPUT_PATH}")
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pkgIndex.tcl.in
${PROJECT_BINARY_DIR}/pkgIndex.tcl
@ONLY IMMEDIATE)
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(VTK_WRAP_TCL)
vtk_module(vtkLocalExample
DEPENDS
vtkCommonCore
)
# Create Python wrappers if VTK is wrapped in Python.
IF(VTK_WRAP_PYTHON)
SET(VTK_WRAP_PYTHON_FIND_LIBS ON)
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_PATH}")
VTK_WRAP_PYTHON3(${PROJECT_NAME}Python vtkLocalPYTHON_SRCS "${vtkLocal_SRCS}")
ADD_LIBRARY(${PROJECT_NAME}PythonD ${vtkLocalPYTHON_SRCS})
ADD_LIBRARY(${PROJECT_NAME}Python MODULE ${PROJECT_NAME}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}PythonD ${PROJECT_NAME})
FOREACH(c ${vtkLocal_LIBS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}Python ${PROJECT_NAME}PythonD)
SET_TARGET_PROPERTIES(${PROJECT_NAME}Python PROPERTIES PREFIX "")
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${PROJECT_NAME}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
ENDIF(VTK_WRAP_PYTHON)
include_directories(SYSTEM
${VTK_INCLUDE_DIRS}
)
# Create Java wrappers if VTK is wrapped in Java.
IF(VTK_WRAP_JAVA)
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapJava.cmake)
SET(VTK_WRAP_JAVA3_INIT_DIR "${PROJECT_SOURCE_DIR}")
SET(VTK_JAVA_HOME ${PROJECT_BINARY_DIR}/java/${PROJECT_NAME})
FILE(MAKE_DIRECTORY ${VTK_JAVA_HOME})
VTK_WRAP_JAVA3(${PROJECT_NAME}Java vtkLocalJAVA_SRCS "${vtkLocal_SRCS}")
ADD_LIBRARY(${PROJECT_NAME}Java ${vtkLocalJAVA_SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}Java ${PROJECT_NAME})
FOREACH(c ${vtkLocal_LIBS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME}Java ${c}Java)
ENDFOREACH(c)
ENDIF(VTK_WRAP_JAVA)
# Source files.
set(vtkLOCAL_SRCS
vtkLocalExample.cxx
)
ADD_SUBDIRECTORY(Testing)
ENDIF(VTK_FOUND)
# Build and link library.
vtk_module_library(vtkLocalExample ${vtkLOCAL_SRCS})
......@@ -10,13 +10,11 @@ build is wrapped.
What you should do:
-------------------
- Copy this vtkLocal directory to a different out-of-source place, and
remove all CVS subdirs to avoid any accidental commit to the main
VTK CVS.
- Copy this vtkLocal directory to a different out-of-source place.
- Edit the CMakeLists.txt file and add your classes to the vtkLocal_SRCS
list. Also add any VTK kits used by your classes to the vtkLocal_LIBS
list. You can also change the project name, but "vtkLocal" is fine
list. Also add any VTK modules used by your classes to the modules.cmake
dependency list. You can also change the project name, but "vtkLocal" is fine
for most users unless you wish to distribute the library.
Your classes should #include "vtkLocalConfigure.h", or
"<project-name>Configure.h" if you changed the project name. They
......
ADD_SUBDIRECTORY(Cxx)
\ No newline at end of file
ADD_EXECUTABLE(vtkLocalTest vtkLocalTest.cxx)
TARGET_LINK_LIBRARIES(vtkLocalTest vtkLocal)
ADD_TEST(vtkLocalTest ${EXECUTABLE_OUTPUT_PATH}/vtkLocalTest)
#include "vtkLocalExample.h"
int main()
{
vtkLocalExample* l = vtkLocalExample::New();
l->Print(cout);
l->Delete();
return 0;
}
package ifneeded {@PROJECT_NAME@TCL} {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@} {
if {@VTKLOCAL_BUILD_SHARED_LIBS_CONFIG@} {
package require -exact vtkinit {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
foreach kit {@VTKLOCAL_KITS@} {
package require -exact "${kit}TCL" {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
}
::vtk::init::load_library_package {@PROJECT_NAME@TCL} {@VTKLOCAL_TCL_LIBRARY_DIR@}
} else {
error {Error loading @PROJECT_NAME@TCL. @PROJECT_NAME@ must be built\
with shared libraries for loading as a Tcl package.}
}
}
/*=========================================================================
This source has no copyright. It is intended to be copied by users
wishing to create their own VTK classes locally.
=========================================================================*/
#ifndef __@PROJECT_NAME@Configure_h
#define __@PROJECT_NAME@Configure_h
// Define @PROJECT_NAME@_SHARED if the library was built shared.
#if @VTKLOCAL_BUILD_SHARED_LIBS_CONFIG@
# define @PROJECT_NAME@_SHARED
#endif
// Disable warning caused from static VTK and shared @PROJECT_NAME@.
#if defined(_MSC_VER) && defined(@PROJECT_NAME@_SHARED)
# pragma warning (disable: 4275) /* non-DLL-interface base class used */
#endif
// Setup export/import macro for DLL. The symbol
// "@PROJECT_NAME@_EXPORTS" is defined by CMake when building source
// files for a shared library named "@PROJECT_NAME@". For these
// sources we should export if building a shared library. For other
// sources we should import if using a shared library.
#if defined(_WIN32) && defined(@PROJECT_NAME@_SHARED)
# if defined(@PROJECT_NAME@_EXPORTS)
# define VTK_@PROJECT_NAME@_EXPORT __declspec(dllexport)
# else
# define VTK_@PROJECT_NAME@_EXPORT __declspec(dllimport)
# endif
#else
# define VTK_@PROJECT_NAME@_EXPORT
#endif
#endif // __@PROJECT_NAME@Configure_h
......@@ -10,10 +10,10 @@ wishing to create their own VTK classes locally.
#ifndef __vtkLocalExample_h
#define __vtkLocalExample_h
#include "vtkLocalConfigure.h" // Include configuration header.
#include "vtkLocalExampleModule.h" // export macro
#include "vtkObject.h"
class VTK_vtkLocal_EXPORT vtkLocalExample : public vtkObject
class VTKLOCALEXAMPLE_EXPORT vtkLocalExample : public vtkObject
{
public:
static vtkLocalExample* New();
......
......@@ -34,7 +34,7 @@ else()
add_subdirectory(VisualizationAlgorithms/Cxx)
add_subdirectory(VolumeRendering/Cxx)
add_subdirectory(Widgets/Cxx)
# add_subdirectory(Build/vtkLocal)
add_subdirectory(Build/vtkLocal)
# add_subdirectory(Build/vtkMy)
# add_subdirectory(GUI/Motif)
# IF(VTK_USE_PARALLEL)
......
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