Alan W. Irwin wrote:
>
> Hi Hazen:
>
> I am glad you put the question on list since these build system details
> concerning add_custom_command (and add_custom_target) are important for all
> PLplot developers if they want to understand or modify our build system
>
> Here is what you have now:
>
> file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.py.in "")
> add_custom_command(
> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/
> COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/config.py
> WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> )
>
> That is close, but here
> is how I would replace that:
>
> add_custom_command(
> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/config.py.in
> COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/config.py.in
> COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/config.py
> WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> DEPENDS
> ${CMAKE_CURRENT_SOURCE_DIR}/config.py
> ${CMAKE_CURRENT_SOURCE_DIR}/plplot_pyqt.sip
> )
>
> add_custom_target(generate_pyqt_source
> DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/config.py.in
> )
>
> Note the first COMMAND uses cmake -E touch to create an empty file in a
> cross-platform way or, if that file exists already, update its create time.
> (Your file command creates the file once at cmake time and never updates its
> creation time again so I prefer to use cmake -E at _make_ time whenever
> possible to keep dependencies working correctly.)
>
> Note, I have changed OUTPUT from a directory (which I don't think will work)
> to a representative file created by the combination of COMMANDS. I chose
> config.py.in, but it could have also been one of the other generated files
> such as sipplplot_pyqtQtExtWidget.cpp. I have also added some file DEPENDS
> so that this custom command will get re-executed whenever one of these
> DEPENDS files is updated to a later date (say through editing) then the
> create date of the config.py.in that was created the last time the custom
> command is run.
>
> Finally, no add_custom_command runs by itself. It must be depended on
> (as in generate_pyqt_source above) by a custom target.
>
>> Do I understand correctly that
>> source_dir/bindings/python/pyqt4/CMakeLists.txt is used by cmake to create
>> the Makefile in binary_dir/bindings/python/pyqt4?
>
> CMake creates a huge web of Makefiles that interact with each other. It takes
> a lot of effort to figure out that web, but the bottom line is you can execute
> any custom target by
>
> make target_name
>
> run from either the top-level build directory or the appropriate sub_directory
> (bindings/python/pyqt4 in this case) of that top-level directory.
>
> Run "make help" in any build-tree directory to see the list of targets that
> are accessible from there. After you make the above change,
> generate_pyqt_source should be available, and if you run
>
> make VERBOSE=1 generate_pyqt_source
>
> you should see all the commands in the custom_command run as a dependency of
> that target. Furthermore, if you repeat the make command, the
> custom_command will not be run if you haven't updated either config.py or
> plplot_pyqt.sip since their dates are less than the date of the config.py.in
> file. IOW, it does the right thing with regard to file dependencies.
>
> Once you confirm that the above works, then the next thing is to collect all
> the names of the generated *.cpp files as a CMake list, and (a) use
> set_source_files_properties to set GENERATED to ON for all those files and
> (b) build the extension module using the add_library(library_name MODULE
> ...) command, and (c) install that created module in the correct position
> (following what is done in bindings/python/CMakeLists.txt for installing the
> extension modules created there). That should finish the new binding.
>
> The only thing left to do after that is to change your pyqt_test.py example
> to access the installed extension module location by importing the installed
> examples/python/plplot_python_start.py and install pyqt_test.py into
> examples/python/ (unless you have a number of pyqt4 examples in mind that
> you want to install in their own subdirectory of the installed
> examples/python).
>
> The above is pretty long because I think I have covered all the steps
> necessary to finish everything with your new pyqt4 bindings and your new
> pyqt4 example. Anyhow, good luck, and if you have any further questions, I
> would be happy to answer them.
Hi Alan,
I'm getting closer, but I can see that there is at least one missing
dependency. I need to link to the qt.so library that is generated by our
Qt bindings, but I can't figure out what its name is in our build
system. At present I have this:
target_link_libraries(
plplot_pyqt
plplot${LIB_TAG}
${QT_LIBRARIES}
)
And I think I need something like this:
target_link_libraries(
plplot_pyqt
${PLPLOT_QT_LIBRARY}
plplot${LIB_TAG}
${QT_LIBRARIES}
)
A side question, is it possible to wildcard for generated files, i.e.
instead of:
set_source_files_properties(
${PYQT4_CONFIG_DIRECTORY}/sipAPIplplot_pyqt.h
${PYQT4_CONFIG_DIRECTORY}/sipplplot_pyqtcmodule.cpp
${PYQT4_CONFIG_DIRECTORY}/sipplplot_pyqtQtExtWidget.cpp
${PYQT4_CONFIG_DIRECTORY}/sipplplot_pyqtQtPLDriver.cpp
${PYQT4_CONFIG_DIRECTORY}/sipplplot_pyqtQtPLWidget.cpp
PROPERTIES GENERATED ON
)
Something like:
set_source_files_properties(
${PYQT4_CONFIG_DIRECTORY}/*.h
${PYQT4_CONFIG_DIRECTORY}/*.cpp
PROPERTIES GENERATED ON
)
thanks!
-Hazen
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel