Transcript Cmake For Linux - The Florida Linux User Exchange
Presentation by: Mihir Sevak
Software Life cycle
Foundation Phase
1. Planning
Building Phase
5. Implementation (tools) 2. Gathering requirements 6. Testing (tools) 3. Analysis 4. Design/Architecture 7. Deployment (tools) 8. Maintenance
What is cmake ?
Family of tool set Open Source build system Building tool – cmake Testing tool – ctest (Automating) Packaging tool – cpack
What cmake is not?
Not a compiler Not an editor Not a scripting language Not a compressing tool like Tar or zip Not a package management system like rpm or deb Not a test automation system But it is a tool which interact with all of the above
cmake as a building tool
Generates makefiles and workspaces to be used by compiler environment Same version of CmakeLists.txt can work across different platforms Easy to use Can inspect the system which it is running on and make its intelligent decisions
cmake some syntax
cmake_minimum_required ( VERSION 2.x ) project ( project_name ) include_directories( list of directories ) this is just like – I option in make link_directories ( list of directories ) this is just like – L option in make add_executable ( name of binary - target ) add_library ( name of library – target )
cmake other nice things
target_link_libraries (list of libraries) Define project_major_version (xxx) Define project_minor_version (xxx) Code generation support Exectuting custom commands Optional settings Platform based settings (Windows, Linux, mac)
cmake commands
cmake –options -to –specify
Packaging - cpack
can be used with cmake can be used without cmake can be used to package binary package can be used to package source pacakge can generate rpm, deb, stgz packages for linux can generate windows installers can generate mac os packages
cpack command usage
To build package Make package Cpack –G RPM Cpack –G DEB Cpack –G TGZ;STGZ Cpack –G NSIS (null soft installer for windows) Cpack –G zip (f0r windows) Some other options –C for configuration file –D define
cpack configuration
Set package description Set package version Set package generator Set OS specifics Set install directives Set output directives
cpack - example
SET(CPACK_CMAKE_GENERATOR "Unix Makefiles") SET(CPACK_GENERATOR "STGZ;TGZ;TZ") SET(CPACK_INSTALL_CMAKE_PROJECTS "/home/andy/vtk/CMake-bin;CMake;ALL;/") SET(CPACK_NSIS_DISPLAY_NAME "CMake 2.5") SET(CPACK_OUTPUT_CONFIG_FILE "/home/andy/vtk/CMake-bin/CPackConfig.cmake") SET(CPACK_PACKAGE_DESCRIPTION_FILE "/home/andy/vtk/CMake/Copyright.txt") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool") SET(CPACK_PACKAGE_EXECUTABLES "ccmake;CMake") SET(CPACK_PACKAGE_FILE_NAME "cmake-2.5.0-Linux-i686") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake 2.5") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "CMake 2.5.0") SET(CPACK_PACKAGE_NAME "CMake") SET(CPACK_PACKAGE_VENDOR "Kitware") SET(CPACK_PACKAGE_VERSION "2.5.0") SET(CPACK_PACKAGE_VERSION_MAJOR "2") SET(CPACK_PACKAGE_VERSION_MINOR "5") SET(CPACK_PACKAGE_VERSION_PATCH "0") SET(CPACK_RESOURCE_FILE_LICENSE "/home/andy/vtk/CMake/Copyright.txt") SET(CPACK_RESOURCE_FILE_README "/home/andy/vtk/CMake/Templates/CPack.GenericDescription.txt") SET(CPACK_RESOURCE_FILE_WELCOME "/home/andy/vtk/CMake/Templates/CPack.GenericWelcome.txt") SET(CPACK_SOURCE_GENERATOR "TGZ;TZ") SET(CPACK_SOURCE_OUTPUT_CONFIG_FILE "/home/andy/vtk/CMake-bin/CPackSourceConfig.cmake") SET(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-2.5.0") SET(CPACK_SOURCE_STRIP_FILES "") SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest") SET(CPACK_SYSTEM_NAME "Linux-i686") SET(CPACK_TOPLEVEL_TAG "Linux-i686")
ctest
ENABLE_TESTING() ADD_TEST() Do_test()
Some of the Projects with Cmake
KDE MySql Compiz – opengl compositing window manager Vispack – C++ library for processing images and surfaces BIAS – Basic Image AlgorithmS –in C++ GoLib – general C++ library XDMG – eXtensible Data Model and Format
Interested to know more
Download and start using http://www.cmake.org/cmake/resources/software.html
Reference places www.cmake.org/cmake/help/documentation.html
Kitware wiki for related topics Scribus.net wiki pages Google.com
Support Request
I am developing a perl utility to convert a make system to cmake system Need Support People who can use it in their environments People who can extend the utility People who can do code reviews and help better it