[Cmake] cmSourceFilesCommand : SOURCE_FILES NAME file AS target
Sebastien BARRE
sebastien at barre.nom.fr
Sun May 13 13:48:31 EDT 2001
Hi
I'd like to enhance the SOURCE_FILES syntax from :
SOURCE_FILES(NAME file1 file2 ...)
to :
SOURCE_FILES(NAME file1 [AS target1] file2 [AS target2] ...)
Meaning : the source file file1 would be compiled to a target file named
target1 (optionally).
Here is the reason. I'd like to achieve this :
IF (VTK_WRAP_TCL)
SOURCE_FILES(RenderingTCL_SRCS
vtkTkRenderWidget AS vtkTkRenderWidgetTcl
vtkTkImageViewerWidget AS vtkTkImageViewerWidgetTcl
vtkTkImageWindowWidget AS vtkTkImageWindowWidgetTcl)
[...]
ENDIF (VTK_WRAP_TCL)
IF (VTK_WRAP_PYTHON)
ADD_DEFINITIONS(-DVTK_PYTHON_BUILD)
SOURCE_FILES(RenderingPython_SRCS
vtkTkRenderWidget AS vtkTkRenderWidgetPython
vtkTkImageViewerWidget AS vtkTkImageViewerWidgetPython
vtkTkImageWindowWidget AS vtkTkImageWindowWidgetPython)
ENDIF (VTK_WRAP_PYTHON)
In VTK, the vtkTkRenderWidget files are compiled two times : one to build a
DLL for the Tcl interpreter, one other to build another DLL for the Tk
widgets to be used within the Python Interpreter (with the define flag
VTK_PYTHON_BUILD).
This was not a problem in the old tree, because the .obj files were
separated on a *language* basis (i.e. all .obj belonging to the Tcl-build
were in vtktcl/, and these belonging to the Python-build were in vtkpython/).
This is no more the case in the new tree : all .obj are in the same
directory, on a component basis (Common, Rendering, etc.). This means that
there is already a vtkTkRenderWidget.obj in the directory when the
vtkTkRenderWidget file has to be compiled a second time (for Python) : clash !
I guess we could also use a copy command or another solution (any
suggestion is welcome), but this enhancement to SOURCE_FILES adds a feature
that might be useful in some other cases.
This change would require :
- add a new private member to the cmSourceFile class :
std::string m_TargetName;
- add 2 new public members to the cmSourceFile class :
std::string GetTargetName() const (returns target name if not empty,
otherwise source name)
void SetTargetName(const char *name) {m_TargetName = name;}
- track every use of GetSourceName() in the CMake distrib and check if
it has to be changed to GetTargetName()
What do you think folks ?
More information about the CMake
mailing list