=============== CMake functions =============== .. highlight:: cmake ``Brainvisa-cmake`` provides a set of CMake functions which help configuring Brainbisa-cmake projects. They can (should) be used within ``CMakeLists.txt`` files of peojects. brainvisa_add_command_help -------------------------- Add target to generate command help files :: BRAINVISA_ADD_COMMAND_HELP( name [COMPONENT ] [HELP_COMMAND ] [HELP_DEPENDS ] ) brainvisa_add_executable ------------------------ Add executable target and reference executable for the component. Executables added with ``BRAINVISA_ADD_EXECUTABLE`` are referenced a cache variable named ``${component}-commands``. :: BRAINVISA_ADD_EXECUTABLE( [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] source1 ... sourceN [COMPONENT ] [IS_SCRIPT] [HELP_COMMAND arg1 ... argN] [HELP_GENERATE On/Off] [OUTPUT_NAME commandname] ) if ``OUTPUT_NAME`` is set, ``set_property( TARGET PROPERTY OUTPUT_NAME )`` is called, and the command help is set with the name ```` instead of ````. brainvisa_add_sip_python_module ------------------------------- :: BRAINVISA_ADD_SIP_PYTHON_MODULE( [ SIP_SOURCES ... ] [ SIP_INCLUDE ... ] [ SIP_INSTALL ] ) brainvisa_add_pytranslation --------------------------- Search recursively PyQt linguist source files (``*.ts``) generated from python (PyQt) sources, in the directory source share directory and generates the commands to create the associated ``*.qm`` files in the build share directory and creates associated install rules. :: BRAINVISA_ADD_PYTRANSLATION( [source directory to search python files] ) brainvisa_add_translation ------------------------- Search recursively qt linguist source files (``*.ts``) in the directory source share directory and generates the commands to create the associated ``*.qm`` files in the build share directory and creates associated install rules. :: BRAINVISA_ADD_TRANSLATION( [source directory to search c++ files] ) .. _brainvisa_add_test: brainvisa_add_test ------------------ :: BRAINVISA_ADD_TEST( NAME [CONFIGURATIONS [Debug|Release|...]] [WORKING_DIRECTORY dir] COMMAND [arg1 [arg2 ...]] [TYPE Exe|Python] ) Add a test to the project with the specified arguments. brainvisa_add_test(testname Exename arg1 arg2 ... ) If ``TYPE Python`` is given, the appropriate python interpreter is used to start the test (i.e.: target python for cross compiling case). Test command is also launched through bv_env_test command. ex: .. code-block:: cmake brainvisa_add_test( axon-tests "${PYTHON_EXECUTABLE_NAME}" -m brainvisa.tests.test_axon ) brainvisa_copy_and_install_headers ---------------------------------- :: BRAINVISA_COPY_AND_INSTALL_HEADERS( [NO_SYMLINKS] ) brainvisa_copy_directory ------------------------ Recursively copy and install all files in except files named ``CMakeLists.txt``, ``*~`` or ``*/.svn/*``. :: BRAINVISA_COPY_DIRECTORY( [IMMEDIATE] [GET_TARGET ] [NO_SYMLINKS] ) brainvisa_copy_files -------------------- :: BRAINVISA_COPY_FILES( [SOURCE_DIRECTORY ] DESTINATION [IMMEDIATE] [GET_TARGET ] [TARGET ] [GET_OUTPUT_FILES ] [NO_SYMLINKS] ) brainvisa_copy_python_directory ------------------------------- Create targets to copy, byte compile and install all Python code contained in a directory. :: BRAINVISA_COPY_PYTHON_DIRECTORY( [NO_SYMLINKS] [INSTALL_ONLY] ) ```` python directory to copy ```` name of the component passed to ``BRAINVISA_INSTALL``. ```` directory where the wiles will be copied (relative to build directory). :: BRAINVISA_COPY_PYTHON_DIRECTORY( ) ```` is set to the right most directory name in ```` Example: :: BRAINVISA_COPY_PYTHON_DIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/python brainvisa_python ) brainvisa_dependency -------------------- :: BRAINVISA_DEPENDENCY( [ ] [BINARY_INDEPENDENT] ) Examples: .. code-block:: cmake BRAINVISA_DEPENDENCY( RUN DEPENDS libblitz RUN "2.0.3-4" ) BRAINVISA_DEPENDENCY( DEV DEPENDS libblitz DEV ">= 2.0" ) BRAINVISA_DEPENDENCY( RUN RECOMMENDS dcmtk RUN "3.1.2" ) BRAINVISA_DEPENDENCY( DEV RECOMMENDS dcmtk DEV ) BRAINVISA_DEPENDENCY( RUN DEPENDS soma-io RUN "3.2.4-20100908" ) BRAINVISA_DEPENDENCY( DEV DEPENDS soma-io DEV ">= 3.2.0;<< 3.3.0" ) BRAINVISA_DEPENDENCY( RUN DEPENDS soma-base RUN ">= 3.2.0;<< 3.3.0" BINARY_INDEPENDENT ) BRAINVISA_DEPENDENCY( DEV DEPENDS soma-base DEV ">= 3.2.0;<< 3.3.0" ) brainvisa_find_fsentry ---------------------- Find file system entries from PATHS using search PATTERNS. :: BRAINVISA_FIND_FSENTRY( output_variable PATTERNS [ ... ] PATHS [ ... ] ) Example: :: BRAINVISA_FIND_FSENTRY( real_files PATTERNS *.so PATHS /usr/lib/ ) foreach( file ${real_files} ) message( "${file}" ) endforeach() brainvisa_generate_commands_help -------------------------------- Add targets to generate commands help :: BRAINVISA_GENERATE_COMMANDS_HELP( [COMPONENT] ... ) brainvisa_generate_commands_help_index -------------------------------------- Add target to generate command help index :: BRAINVISA_GENERATE_COMMANDS_HELP_INDEX( COMPONENT ) brainvisa_generate_docbook_doc ------------------------------ Add rules to generate docbook documentation with ``make doc`` or ``make -doc`` or ``make usrdoc`` or ``make -usrdoc`` if it a user manual or tutorial or ``make devdoc`` or ``make -devdoc`` if it is developer manual. :: BRAINVISA_GENERATE_DOCBOOK_DOC( [EXCLUDE docbook_project_name] ) .. note:: Docbook support has been deprecated in brainvisa-cmake, Sphinx is now much preferred. .. _brainvisa_generate_doxygen_doc: brainvisa_generate_doxygen_doc ------------------------------ Add rules to generate doxygen documentation with "make doc" or "make devdoc". :: BRAINVISA_GENERATE_DOXYGEN_DOC( [ ...] [INPUT_PREFIX ] [COMPONENT ] ) ```` variable containing a string or a list of input sources. Its content will be copied in the ``INPUT`` field of the Doxygen configuration file. ```` file (relative to ``${CMAKE_CURRENT_SOURCE_DIR}``) to copy in the build tree. Files are copied in ``${DOXYGEN_BINARY_DIR}`` if defined, otherwise they are copied in ``${PROJECT_BINARY_DIR}/doxygen``. The doxygen configuration file is generated in the same directory. ``INPUT_PREFIX`` directory where to find input files ``COMPONENT`` component name for this doxygen documentation. it is used to create the output directory and the tag file name. By default it is the ``PROJECT_NAME``. but it is useful to give an alternative name when there are several libraries documented with doxygen in the same project. Before calling this macro, it is possible to specify values that are going to be written in doxygen configuration file by setting variable names ``DOXYFILE_``. For instance, in order to set project name in Doxygen, one should use: .. code-block:: cmake set( DOXYFILE_PROJECT_NAME, "My wonderful project" ). Example: .. code-block:: cmake find_package( Doxygen ) if( DOXYGEN_FOUND ) set( component_name "cartodata" ) set( DOXYFILE_PREDEFINED "${AIMS_DEFINITIONS}" ) set( DOXYFILE_TAGFILES "cartobase.tag=../../cartobase-${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}/doxygen" ) BRAINVISA_GENERATE_DOXYGEN_DOC( _headers INPUT_PREFIX "${CMAKE_BINARY_DIR}/include/${component_name}" COMPONENT "${component_name}" ) endif( DOXYGEN_FOUND ) brainvisa_generate_epydoc_doc ----------------------------- Add rules to generate epydoc documentation with ``make doc`` or ``make -doc`` or ``make devdoc`` or ``make -devdoc``. :: BRAINVISA_GENERATE_EPYDOC_DOC( [ ... ] [ EXCLUDE ] ) .. note:: Epydoc has been deprecated in brainvisa-cmake, Shinx is now much preferred. Example: :: BRAINVISA_GENERATE_EPYDOC_DOC( "${CMAKE_BINARY_DIR}/python/soma" "share/doc/${PROJECT_NAME}-${BRAINVISA_PACKAGE_VERSION_MAJOR}.${BRAINVISA_PACKAGE_VERSION_MINOR}/epydoc/html" EXCLUDE soma.aims* ) .. _brainvisa_generate_sphinx_doc: brainvisa_generate_sphinx_doc ----------------------------- Add rules to generate sphinx documentation with ``make doc`` or ``make -doc`` or ``make devdoc`` or ``make -devdoc``. :: BRAINVISA_GENERATE_SPHINX_DOC( [TARGET ] [USER] ) Example: .. code-block:: cmake BRAINVISA_GENERATE_SPHINX_DOC( "doc/source" "share/doc/soma-workflow-${BRAINVISA_PACKAGE_VERSION_MAJOR}.${BRAINVISA_PACKAGE_VERSION_MINOR}" ) if ``TARGET`` argument is not specified, the target name defaults to ``${PROJECT_NAME}-sphinx`` if ``USER`` is specified, the generated doc will be part of the usrdoc (user documentation) global target, and included in user docs packages. Otherwise, by default, sphinx docs are considered developer docs (devdoc) brainvisa_generate_target_name ------------------------------ :: BRAINVISA_GENERATE_TARGET_NAME _variableName brainvisa_get_file_list_from_pro -------------------------------- Retrieve one (or more) list of file names from a ``.pro`` file. This macro exists for backward compatibility with the older ``build-config`` tool (now abandoned). :: BRAINVISA_GET_FILE_LIST_FROM_PRO( [ ...] ) Example: .. code-block:: cmake BRAINVISA_GET_FILE_LIST_FROM_PRO( ${CMAKE_CURRENT_SOURCE_DIR}/libvip.pro "HEADERS" _h "SOURCES" _s ) brainvisa_get_spaced_quoted_list -------------------------------- Transform a list into a string containing space separated items. Each item is surounded by double quotes. :: BRAINVISA_GET_SPACED_QUOTED_LIST( ) Example: :: set( _list a b "c d" ) BRAINVISA_GET_SPACED_QUOTED_LIST( _list _quotedList ) # equivalent to SET( _quotedList "\"a\" \"b\" \"c d\"" ) brainvisa_install ----------------- brainvisa_install_directory --------------------------- Install a directory without copying it into the build tree. :: BRAINVISA_INSTALL_DIRECTORY( ) Example: :: BRAINVISA_INSTALL_DIRECTORY( "/usr/lib/python2.7" "python" "brainvisa-python" ) brainvisa_install_runtime_libraries ----------------------------------- Checks and creates install rules for the libraries of the given component. A list of library files is given in parameter, and the function gets the absolute path of these files, check existance, and check that it is a dynamic library. The library files are set in an install rule for the component. The symlinks that point to the library are found and created in the install directory via a custom command attached to the install target of the component. :: BRAINVISA_INSTALL_RUNTIME_LIBRARIES( ) Example: :: find_package(LibXml2) BRAINVISA_INSTALL_RUNTIME_LIBRARIES( libxml2 ${LIBXML2_LIBRARIES} ) brainvisa_project ----------------- brainvisa_pyuic --------------- Run ``pyside-uic`` / ``pyuic4`` / ``pyuic`` on a ``.ui`` file to generate the corresponding ``.py`` module :: BRAINVISA_PYUIC( ) brainvisa_qt_wrap_ui -------------------- Works like ``QT4_WRAP_UI``, but in addition, the directory of generated files is user-defined (````). :: BRAINVISA_QT_WRAP_UI( ) brainvisa_real_paths -------------------- Remove all symlinks from a list of paths by applying ``get_filename_component( ... REALPATH )`` to each element of the list. :: BRAINVISA_REAL_PATHS( output_variable [ ... ] ) Example: :: file( GLOB glob_result /usr/lib/*.so ) BRAINVISA_REAL_PATHS( real_files ${glob_result} ) foreach( file ${real_files} ) message( "${file}" ) endforeach() brainvisa_resolve_symbol_libraries ---------------------------------- Resolve symbol library pathes. A list of library or symbol files is given in parameter, and the function gets the absolute path of these files, check existance, and check that it is a symbol for dynamic library. If the file is a symbol file for dynamic library, try to find the matching library file. :: BRAINVISA_RESOLVE_SYMBOL_LIBRARIES( PATHS ) Example: :: find_package(LibXml2) BRAINVISA_RESOLVE_SYMBOL_LIBRARIES( libxml2 ${LIBXML2_LIBRARIES} ) brainvisa_thirdparty_dependency ------------------------------- :: BRAINVISA_THIRDPARTY_DEPENDENCY( [ ] [BINARY_INDEPENDENT] ) Examples: .. code-block:: cmake BRAINVISA_THIRDPARTY_DEPENDENCY( libqtgui4 RUN DEPENDS libqtcore4 RUN ) BRAINVISA_THIRDPARTY_DEPENDENCY( libqtgui4 DEV DEPENDS libqtcore4 DEV ) brainvisa_version_convert ------------------------- Convert version number either to hexadecimal version either to string version. :: BRAINVISA_VERSION_CONVERT( version [HEX] [STR] [BYTES ] ) Example: .. code-block:: cmake BRAINVISA_VERSION_CONVERT( result "0x30206" STR ) BRAINVISA_VERSION_CONVERT( result "3.2.6" HEX BYTES 2 )