Previous: Using and writing loadable modules
We showed you in the previous example how to write a simple native module, but we failed to mention exactly how to compile it. If you use CMake, its not all that hard:
# Place this in CMakeLists.txt cmake_minimum_required(VERSION 2.6.4) execute_process( COMMAND flusspferd --cmake OUTPUT_VARIABLE hippo_cmake) include("${hippo_cmake}") FILE(GLOB_RECURSE sources "${CMAKE_SOURCE_DIR}/src/*.cpp" "${CMAKE_SOURCE_DIR}/src/*.hpp") add_definitions("-Wall") flusspferd_plugin( "dummy_module" SOURCES ${sources})
help/examples/dummy_module.cmake.Simple create a file called CMakeLists.txt containing the above and place it in your the directory of your project. Don't forget to correct the list of source files appropriately. If you also need to install .js files to go with the native module, you can pass a list of files in the JS named argument to flusspferd_plugin.
Then simply configure and make it using CMake - it will get installed to the right place automatically.
The output should look something like this:
$ cmake . ... -- -- Installing into /Users/ash/.flusspferd/modules -- -- Bulding dummy-module plugin -- Configuring done -- Generating done -- Build files have been written to: /Users/ash/code/js/dummy-module $ make install Scanning dependencies of target dummy-module_PLUGIN [ 1%] Building CXX object CMakeFiles/dummy-module_PLUGIN.dir/src/dummy-module.cpp.o ...
Thats all there is to it. The module will automatically be installed into the right directory by make install.
Contact us at team -AT- flusspferd -DOT- org or as described on our homepage.
Generated on Thu Feb 4 23:05:12 2010 for Flusspferd by
1.6.1