Cmake: Best Practices

Total Page:16

File Type:pdf, Size:1020Kb

Cmake: Best Practices CMake: Best Practices Henry Schreiner Software & Computing Roundtable 2021-2-2 launch binder Links: The book: cliutils.gitlab.io/modern-cmake My blog: iscinumpy.gitlab.io The workshop: hsf-training.github.io/hsf-training-cmake-webpage This talk: gitlab.com/CLIUtils/modern-cmake-interactive-talk Intro to CMake In [ ]: cmake --version What is CMake? Is it a build system? Build system example (Rake): # 01-rake/Rakefile task default: [:hello_world] do # hello_world.c puts 'All built' # ↓ end # hello_world # ↓ file hello_world: ['hello_world.c'] do |t| # default task sh "gcc #{t.prerequisites.join(' ')} -o #{t.name}" end In [ ]: (cd 01-rake && rake) Features: Understands when to build/rebuild Doesn't understand how to build Generic; can be used for anything Examples make : Classic, custom syntax rake : Ruby make ninja : Google's entry, not designed to be hand written Build system generator Understands the files you are building System independent You give relationships Can find libraries, etc CMake is two-stage; the configuration step runs CMake, the build step runs a build-system ( make , ninja , IDE, etc). Aside: Modern CMake can run the install step directly without invoking the build system agian. Build system generator example (CMake): # 01-rake/CMakeLists.txt cmake_minimum_required(VERSION 3.11) project(HelloWorld) add_executable(hello_world hello_world.c) In [ ]: cmake -S 01-rake -B 01-build cmake --build 01-build C/C++ Examples cmake : Cross-platform Make (also Fortran, CUDA, C#, Swift) scons : Software Carpentry Construction (Python) meson : Newer Python entry basel : Google's build system Other languages often have their own build system (Rust, Go, Python, ...) We will follow common convention and call these "build- systems" for short from now on Why CMake? It has become a standard Approximately all IDEs support it Many libraries have built-in support Integrates with almost everything Custom Buildsystems are going away Qt 6 dropped QMake for CMake (note: C++17 only too) Boost is starting to support CMake at a reasonable level along with BJam Standout: Google is dual supporting Bazel and CMake Custom Buildsystems are going away Qt 6 dropped QMake for CMake (note: C++17 only too) Boost is starting to support CMake at a reasonable level along with BJam Standout: Google is dual supporting Bazel and CMake Recent highlights Thrust just received a major CMake overhaul TBB / Intel PSTL nicely support CMake in recent years Pybind11's CMake support was ramped up in 2.6 (More) Modern CMake CMake is a new language to learn (and is a bit odd) Classic CMake (CMake 2.8, from 2009) was ugly and had problems, but that's not Modern CMake! Modern CMake and More Modern CMake! CMake 3.0 in 2014: Modern CMake begins CMake 3.1-3.4 had important additions/fixes CMake 3.12 in mid 2018 completed the "More Modern CMake" phase Current CMake is 3.19 (2.20 in rc2 phase) Eras of CMake Classic CMake: Directory based Modern CMake: Target based More Modern CMake: Unified target behavior CURRENT: Powerful CLI Best Practice: Minimum Version is important! CMake has a (AFAIK) unique version system. If a file start with this: cmake_minimum_required(VERSION 3.0) Then CMake will set all policies (which cover all behavior changes) to their 3.0 settings. This in theory means it is extremely backward compatible; upgrading CMake will not break or change anything at all. In practice, all the behavior changes had very good reasons to change, so this will be much buggier and less useful than if you set it higher! You can also do this: cmake_minimum_required(VERSION 3.4...3.14) Then CMake < 3.4 will be an error CMake 3.4 -- 3.11 will set 3.4 policies (feature was introduced in 3.12, but syntax is valid) CMake 3.12 -- 3.14 will set current policies CMake 3.15+ will set 3.14 policies Don't: set this low without a range - it will harm users. Setting < 3.9 will break IPO, for example. Often in a way that can't be fixed by superprojects. Do: set the highest minimum you can (build systems are hard/ugly enough as it is) Do: test with the lowest version version you support in at least one job. Don't: expect a CMake version significanly older than your compiler to work with it (expecially macOS/Windows, or CUDA). What minimum to choose - OS support: 3.4: The bare minimum. Never set less. 3.7: Debian old-stable. 3.10: Ubuntu 18.04. 3.11: CentOS 8 (use EPEL or AppSteams, though) 3.13: Debian stable. 3.16: Ubuntu 20.04. 3.18: pip 3.19: conda-forge/chocolaty/direct download, etc. First to support Apple Silicon. What minimum to choose - Features: 3.8: C++ meta features, CUDA, lots more 3.11: IMPORTED INTERFACE setting, faster, FetchContent, COMPILE_LANGUAGE in IDEs 3.12: C++20, cmake --build build -j N , SHELL: , FindPython 3.14/3.15: CLI, FindPython updates 3.16: Unity builds / precompiled headers, CUDA meta features 3.17/3.18: Lots more CUDA, metaprogramming Best Practice: Running CMake The classic method: mkdir build cd build cmake .. make The modern method is cleaner and more cross-platform-friendly: cmake -S . -B build cmake --build build (CMake 3.14/3.15) supports -v (verbose), -j N (threads), -t target , and more Example options: In [ ]: cmake --build 01-build -v Public Library Private Library Best Practice: Use Targets PUBLIC PRIVATE Excutables and libraries are targets Interface Library PUBLIC Main Library INTERFACE Target: mylibrary Target: myprogram Properties include: Header include directories Compile flags and definitions Link flags C++ standard and/or compiler features required Linked libraries Note that other things include properties, like files (such as LANGUAGE), directories, and global Tips for packaging Do: use targets. Don't: use common names for targets if you want to be used in subdirectory mode. Don't: write a FindPackage for your own package. Always provide a PackageConfig instead. Export your targets to create a PackageTargets.cmake file. You can write a PackageConfig.cmake.in ; you can recreate / reimport package there (generally use a shared X.cmake file instead of doing it twice). Don't: hardcode any system/compiler/config details into exported targets. Only from shared code in Config, or use Generator expressions. Never allow your package to be distributed without the config files! Using other projects 1. See if the project provides a <name>Config.cmake file. If it does, you are good to go! 2. If not, see if CMake provides a Find package for it built-in. If it does, you are good to go! 3. If not, see if the authors provide a Find<name>.cmake file. If they do, complain loudly that they don't follow CMake best practices. 4. Write your own Find<name>.cmake and include in in a helper directory. You'll need to build IMPORTED targets and all that. 5. You can also use FindPkgConfig to piggy back on classic pkg-config. Best Practice: Handling remote dependencies CMake can download your dependencies for you, and can integrate with files. It supports composable (sub-)projects: One project can include another Does not have namespaces, can cause target collisions! Build time data and project downloads: ExternalProject (classic) Configure time downloads FetchContent (new in 3.11+) You can also use submodules (one of my favorite methods, but use with care) You can also use Conan.io's CMake integration FetchContent FetchContent 02-fetch/hello_fmt.cpp #include <fmt/format.h> int main() { fmt::print("The answer is {}\n", 42); return 0; } 02-fetch/CMakeLists.txt cmake_minimum_required(VERSION 3.14) project(HelloWorld LANGUAGES CXX) include(FetchContent) FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 5.3.0) FetchContent_MakeAvailable(fmt) # Shortcut from CMake 3.14 add_executable(hello_world hello_fmt.cpp) target_link_libraries(hello_world PRIVATE fmt::fmt) target_compile_features(hello_world PRIVATE cxx_std_11) In [ ]: cmake -S 02-fetch -B 02-build cmake --build 02-build Conan.io's conan-cmake Conan.io has a nice CMake integration tool. It should support binaries too, since Conan.io supports them! You must have conan installed, though - I'm using conan from conda-forge. It works with old versions of CMake, as well. cmake_minimum_required(VERSION 3.14) project(HelloWorld LANGUAGES CXX) # Conan bootstrap if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") message( STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.16.1/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake") endif() include("${CMAKE_BINARY_DIR}/conan.cmake") conan_check(REQUIRED) conan_cmake_run( REQUIRES fmt/6.1.2 BASIC_SETUP CMAKE_TARGETS BUILD missing) add_executable(hello_world hello_fmt.cpp) target_link_libraries(hello_world PRIVATE CONAN_PKG::fmt) target_compile_features(hello_world PRIVATE cxx_std_11) You can also make a conanfile.txt and manage all your dependencies there. In [ ]: cmake -S 02b-conan -B 02b-build -DCMAKE_BUILD_TYPE=Release cmake --build 02b-build Best Practice: Use IMPORTED targets for things you don't build Now (3.11+) can be built with standard CMake commands! Can now be global with IMPORTED_GLOBAL You'll need to set them back up in your Config file (place in one common location for both CMakeLists and Config). add_library(ExternLib IMPORTED INTERFACE) # Classic # Modern set_property( target_include_directories( TARGET ExternLib INTERFACE /my/inc ExternLib ) APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES /my/inc ) Best Practice: Use CUDA as a language Cuda is now a first-class language in CMake! (3.9+) Replaces FindCuda. project(MY_PROJECT LANGUAGES CUDA CXX) # Super project might need matching? (3.14 at least) # Or for optional CUDA support project(MY_PROJECT LANGUAGES CXX) include(CheckLanguage) check_language(CUDA) if(CMAKE_CUDA_COMPILER) enable_language(CUDA) endif() Much like you can set C++ standards, you can set CUDA standards too: if(NOT DEFINED CMAKE_CUDA_STANDARD) set(CMAKE_CUDA_STANDARD 11) # Probably should be cached! set(CMAKE_CUDA_STANDARD_REQUIRED ON) endif() Much like you can set C++ standards, you can set CUDA standards too: if(NOT DEFINED CMAKE_CUDA_STANDARD) set(CMAKE_CUDA_STANDARD 11) # Probably should be cached! set(CMAKE_CUDA_STANDARD_REQUIRED ON) endif() You can add files with .cu extensions and they compile with nvcc.
Recommended publications
  • C/C++ Programming with Qt 5.12.6 and Opencv 4.2.0
    C/C++ programming with Qt 5.12.6 and OpenCV 4.2.0 Preparation of the computer • Download http://download.qt.io/archive/qt/5.12/5.12.6/qt-opensource-windows- x86-5.12.6.exe and http://www.ensta-bretagne.fr/lebars/Share/OpenCV4.2.0.zip (contains OpenCV with extra modules built for Visual Studio 2015, 2017, 2019, MinGW Qt 5.12.6 x86, MinGW 8 x64), run Qt installer and select Qt\Qt 5.12.6\MinGW 7.3.0 32 bit and Qt\Tools\MinGW 7.3.0 32 bit options and extract OpenCV4.2.0.zip in C:\ (check that the extraction did not create an additional parent folder (we need to get only C:\OpenCV4.2.0\ instead of C:\OpenCV4.2.0\OpenCV4.2.0\), right-click and choose Run as administrator if needed). For Linux or macOS, additional/different steps might be necessary depending on the specific versions (and the provided .pro might need to be tweaked), see https://www.ensta-bretagne.fr/lebars/Share/setup_opencv_Ubuntu.pdf ; corresponding OpenCV sources : https://github.com/opencv/opencv/archive/4.2.0.zip and https://github.com/opencv/opencv_contrib/archive/4.2.0.zip ; Qt Linux 64 bit : https://download.qt.io/archive/qt/5.12/5.12.6/qt-opensource-linux-x64-5.12.6.run (for Ubuntu you can try sudo apt install qtcreator qt5-default build-essential but the version will probably not be the same); Qt macOS : https://download.qt.io/archive/qt/5.12/5.12.6/qt-opensource-mac-x64-5.12.6.dmg .
    [Show full text]
  • Eclipse Webinar
    Scientific Software Development with Eclipse A Best Practices for HPC Developers Webinar Gregory R. Watson ORNL is managed by UT-Battelle for the US Department of Energy Contents • Downloading and Installing Eclipse • C/C++ Development Features • Fortran Development Features • Real-life Development Scenarios – Local development – Using Git for remote development – Using synchronized projects for remote development • Features for Utilizing HPC Facilities 2 Best Practices for HPC Software Developers webinar series What is Eclipse? • An integrated development environment (IDE) • A platform for developing tools and applications • An ecosystem for collaborative software development 3 Best Practices for HPC Software Developers webinar series Getting Started 4 Best Practices for HPC Software Developers webinar series Downloading and Installing Eclipse • Eclipse comes in a variety of packages – Any package can be used as a starting point – May require additional components installed • Packages that are best for scientific computing: – Eclipse for Parallel Application Developers – Eclipse IDE for C/C++ Developers • Main download site – https://www.eclipse.org/downloads 5 Best Practices for HPC Software Developers webinar series Eclipse IDE for C/C++ Developers • C/C++ development tools • Git Integration • Linux tools – Libhover – Gcov – RPM – Valgrind • Tracecompass 6 Best Practices for HPC Software Developers webinar series Eclipse for Parallel Application Developers • Eclipse IDE for C/C++ Developers, plus: – Synchronized projects – Fortran development
    [Show full text]
  • Linux from Scratch 版本 R11.0-36-中⽂翻译版 发布于 2021 年 9 ⽉ 21 ⽇
    Linux From Scratch 版本 r11.0-36-中⽂翻译版 发布于 2021 年 9 ⽉ 21 ⽇ 由 Gerard Beekmans 原著 总编辑:Bruce Dubbs Linux From Scratch: 版本 r11.0-36-中⽂翻译版 : 发布于 2021 年 9 ⽉ 21 ⽇ 由 由 Gerard Beekmans 原著和总编辑:Bruce Dubbs 版权所有 © 1999-2021 Gerard Beekmans 版权所有 © 1999-2021, Gerard Beekmans 保留所有权利。 本书依照 Creative Commons License 许可证发布。 从本书中提取的计算机命令依照 MIT License 许可证发布。 Linux® 是Linus Torvalds 的注册商标。 Linux From Scratch - 版本 r11.0-36-中⽂翻译版 ⽬录 序⾔ .................................................................................................................................... viii i. 前⾔ ............................................................................................................................ viii ii. 本书⾯向的读者 ............................................................................................................ viii iii. LFS 的⽬标架构 ............................................................................................................ ix iv. 阅读本书需要的背景知识 ................................................................................................. ix v. LFS 和标准 ..................................................................................................................... x vi. 本书选择软件包的逻辑 .................................................................................................... xi vii. 排版约定 .................................................................................................................... xvi viii. 本书结构 .................................................................................................................
    [Show full text]
  • The WAF Build System
    The WAF build system The WAF build system Sebastian Jeltsch Electronic Vision(s) Kirchhoff Institute for Physics Ruprecht-Karls-Universität Heidelberg 31. August 2010 Sebastian Jeltsch The WAF build system 31. August 2010 1 / 19 The WAF build system Introduction WorkBuildflow Sebastian Jeltsch The WAF build system 31. August 2010 2 / 19 make = major pain What we expect from our build system: flexibility integration of existing workflows access to well established libraries extensibility power usability The WAF build system Introduction WorkBuildflow For us: low-level code many many layers Sebastian Jeltsch The WAF build system 31. August 2010 3 / 19 What we expect from our build system: flexibility integration of existing workflows access to well established libraries extensibility power usability The WAF build system Introduction WorkBuildflow For us: low-level code many many layers make = major pain Sebastian Jeltsch The WAF build system 31. August 2010 3 / 19 The WAF build system Introduction WorkBuildflow For us: low-level code many many layers make = major pain What we expect from our build system: flexibility integration of existing workflows access to well established libraries extensibility power usability Sebastian Jeltsch The WAF build system 31. August 2010 3 / 19 The WAF build system Introduction Autotools (GNU Build System) GNU Build System + few dependencies on user side (shell scripts) developer autoscan ed + generates standard make files + widely used configure.ac Makefile.am – platform dependent (bash aclocal autoheader automake scripts) aclocal.m4 config.h.in Makefile.in – autoconf-configure is slow autoconf Often: tconfigure >> tmake. – another scripting language configure Makefile make user Sebastian Jeltsch The WAF build system 31.
    [Show full text]
  • Project Skeleton for Scientific Software
    Computational Photonics Group Department of Electrical and Computer Engineering Technical University of Munich bertha: Project Skeleton for Scientific Software Michael Riesch , Tien Dat Nguyen , and Christian Jirauschek Department of Electrical and Computer Engineering, Technical University of Munich, Arcisstr. 21, 80333 Munich, Germany [email protected] Received: 10 December 2019 / Accepted: 04 March 2020 / Published: 23 March 2020 * Abstract — Science depends heavily on reliable and easy-to-use software packages, such as mathematical libraries or data analysis tools. Developing such packages requires a lot of effort, which is too often avoided due to the lack of funding or recognition. In order to reduce the efforts required to create sustainable software packages, we present a project skeleton that ensures the best software engineering practices from the start of a project, or serves as reference for existing projects. 1 Introduction In a recent essay in Nature [1], a familiar dilemma in science was addressed. On the one hand, science relies heavily on open-source software packages, such as libraries for mathematical operations, implementations of numerical methods, or data analysis tools. As a consequence, those software packages need to work reliably and should be easy to use. On the other hand, scientific software is notoriously underfunded and the required efforts are achieved as side projects or by the scientists working in their spare time. Indeed, a lot of effort has to be invested beyond the work on the actual implementation – which is typically a formidable challenge on its own. This becomes apparent from literature on software engineering in general (such as the influential “Pragmatic Programmer” [2]), and in scientific contexts in particular (e.g., [3–6]).
    [Show full text]
  • Kdesrc-Build Script Manual
    kdesrc-build Script Manual Michael Pyne Carlos Woelz kdesrc-build Script Manual 2 Contents 1 Introduction 8 1.1 A brief introduction to kdesrc-build . .8 1.1.1 What is kdesrc-build? . .8 1.1.2 kdesrc-build operation ‘in a nutshell’ . .8 1.2 Documentation Overview . .9 2 Getting Started 10 2.1 Preparing the System to Build KDE . 10 2.1.1 Setup a new user account . 10 2.1.2 Ensure your system is ready to build KDE software . 10 2.1.3 Setup kdesrc-build . 12 2.1.3.1 Install kdesrc-build . 12 2.1.3.2 Prepare the configuration file . 12 2.1.3.2.1 Manual setup of configuration file . 12 2.2 Setting the Configuration Data . 13 2.3 Using the kdesrc-build script . 14 2.3.1 Loading project metadata . 14 2.3.2 Previewing what will happen when kdesrc-build runs . 14 2.3.3 Resolving build failures . 15 2.4 Building specific modules . 16 2.5 Setting the Environment to Run Your KDEPlasma Desktop . 17 2.5.1 Automatically installing a login driver . 18 2.5.1.1 Adding xsession support for distributions . 18 2.5.1.2 Manually adding support for xsession . 18 2.5.2 Setting up the environment manually . 19 2.6 Module Organization and selection . 19 2.6.1 KDE Software Organization . 19 2.6.2 Selecting modules to build . 19 2.6.3 Module Sets . 20 2.6.3.1 The basic module set concept . 20 2.6.3.2 Special Support for KDE module sets .
    [Show full text]
  • 1. Install Homebrew 2. Install Cmake 3. Build and Run the Opengl Program
    NYU Tandon School of Engineering CS6533/CS4533 Zebin Xu [email protected] Compiling OpenGL Programs on macOS or Linux using CMake This tutorial explains how to compile OpenGL programs on macOS using CMake – a cross-platform tool for managing the build process of software using a compiler- independent method. On macOS, OpenGL and GLUT are preinstalled; GLEW is not needed as we will use the core profile of OpenGL 3.2 later when we use shaders; Xcode is not required unless you prefer programming in an IDE. At the end we also discuss how to compile on Linux. Contents/Steps: 1. Install Homebrew 2. Install CMake via Homebrew 3. Build and run the OpenGL program 3.1 Build via the command line by generating Unix Makefiles (without Xcode) 3.2 Build via the Xcode IDE by generating an Xcode project (so that you can write your code in Xcode if you have it installed) 4. Compilation on Linux 5. Notes 1. Install Homebrew Homebrew is a pacKage manager for macOS. If you have installed Homebrew before, sKip this step. To install Homebrew, simply paste the command from https://brew.sh into your terminal and run. Once you have installed Homebrew, type “brew” in your terminal to checK if it’s installed. We will use Homebrew to install CMake. 2. Install CMaKe I strongly suggest installing CMake via Homebrew as it will also picK up any related missing pacKages during installation (such as installing a needed command line tool for Xcode even if you don’t have Xcode). If you have installed CMake, just sKip this step.
    [Show full text]
  • Builder Documentation Release 3.26.0
    Builder Documentation Release 3.26.0 Christian Hergert, et al. Sep 13, 2017 Contents 1 Contents 3 1.1 Installation................................................3 1.1.1 via Flatpak...........................................3 1.1.1.1 Command Line....................................3 1.1.2 Local Flatpak Builds......................................4 1.1.3 via JHBuild...........................................4 1.1.3.1 Command Line....................................4 1.1.4 via Release Tarball.......................................5 1.1.5 Troubleshooting.........................................5 1.2 Exploring the Interface..........................................5 1.2.1 Project Greeter.........................................6 1.2.2 Workbench Window......................................6 1.2.3 Header Bar...........................................7 1.2.4 Switching Perspectives.....................................7 1.2.5 Showing and Hiding Panels...................................7 1.2.6 Build your Project........................................7 1.2.7 Editor..............................................9 1.2.8 Autocompletion......................................... 11 1.2.9 Documentation......................................... 11 1.2.10 Splitting Windows....................................... 12 1.2.11 Searching............................................ 14 1.2.12 Preferences........................................... 15 1.2.13 Command Bar.......................................... 16 1.2.14 Transfers...........................................
    [Show full text]
  • Cmake / Ctest / Cpack
    Building, Testing, and Deploying Software in a Cross-Platform Development Environment Julien Jomier [email protected] About Kitware • Software Development Company • Founded in 1998 • 110+ employees and growing • Focus in – Scientific computing – Large data visualization – Medical image processing – Informatics – Computer vision – Scientific data publishing – Quality software processes • Primarily work in Open Source About Kitware • Provide training and support • Do custom development • Sell technical books • Host and maintain projects including: VTK The Visualization Toolkit CMake A platform agnostic build system ITK Insight Segmentation and Registration Toolkit ParaView A parallel visualization application • Primary (but not sole) developers of each project Kitware: Core Technologies Overview • What is CMake? • Building with CMake • Testing with CTest/CDash • Packaging with CPack What is CMake? • CMake is the cross-platform, open-source build system that lets you use the native development tools you love the most. • It’s a build system generator • It takes plain text files as input that describe your project and produces project files or make files for use with a wide variety of native development tools. • Family of Software Development Tools – Build – CMake – Test – CTest/CDash – Package – CPack CMake: History • Built for the Insight Segmentation and Registration Toolkit (ITK) http://www.itk.org • Funded by National Library of Medicine (NLM): part of the Visible Human Project • Release-1-0 branch created in late 2001 • Other
    [Show full text]
  • Oracle Communications Policy Management Licensing Information User Manual Release 12.5 Copyright © 2011, 2019, Oracle And/Or Its Affiliates
    Oracle® Communications Policy Management Licensing Information User Manual Release 12.5.1 F16918-02 October 2019 Oracle Communications Policy Management Licensing Information User Manual Release 12.5 Copyright © 2011, 2019, Oracle and/or its affiliates. All rights reserved. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are “commercial computer software” pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.
    [Show full text]
  • Cmake Build System Distribute Your Software Easily
    CMake build system Distribute your software easily Cédric Castagnède Mars 2016 engineer innovate integrate Outline 1. Motivations of a build system 2. CMake build system 3. Test integration 4. Packaging an application 5. Automation of all steps 6. Conclusions and opened discussion engineer innovate integrate Motivations of a build system engineer innovate integrate What problems do build system solve? For a developer: • reduce the time spent in the cycle “edit / compile / test” cycle • compile only what is necessary in the source code For a development team: • generate packages • run tests • generate documentation For a user: • install software easily • have understandable error during install phase • tune installation engineer innovate integrate Build a software: a lot of evil ways Examples: • “I will do a script to launch all my command and it will be ok” • system-dependent, all path dependent, etc. • high cost for developers and users • “I will do a makefile with a make.inc, my software earns portability” • costly for the user: manual configuration • portable ≠ customizable • “I will do a makefile with several make.inc, my software covers all software stacks” • costly for everyone: any make.inc won’t fit the situation • examples ≠ software stack supports • software stack supports = test expected behavior • Etc. engineer innovate integrate Features of a build system (1) automatic dependency management of source code • compile only the modified sources files and tiers dependencies software portability • use native build environment • determine available OS/compiler features : foo.h, libbar, strndup, -Wall, etc. • name correctly the library: .so / .dylib / .dll adaptability according user environment • auto-configuration of the project • determine the availability and location of libraries, commands, etc… engineer innovate integrate Features of a build system (2) customize installation • cross-compiling • give some information: --help • possibility to set information: --prefix, --libdir, --disable-shared, etc.
    [Show full text]
  • Conan Documentation Release 1.3.3
    conan Documentation Release 1.3.3 conan Sep 24, 2021 CONTENTS 1 Upgrading to conan 1.0 3 1.1 Command line changes..........................................3 1.2 Deprecations/removals..........................................3 1.3 Settings and profiles. Gcc/CLang versioning..............................4 1.4 New features...............................................4 2 Introduction 5 2.1 Open Source...............................................5 2.2 Decentralized package manager.....................................5 2.3 Binary management...........................................6 2.4 Cross platform, build system agnostic..................................6 2.5 Stable...................................................7 3 Install 9 3.1 Install with pip (recommended).....................................9 3.2 Install from brew (OSX)......................................... 10 3.3 Install from AUR (Arch Linux)..................................... 10 3.4 Install the binaries............................................ 10 3.5 Initial configuration........................................... 10 3.6 Install from source............................................ 11 4 Getting started 13 4.1 A Timer using POCO libraries...................................... 13 4.2 Installing dependencies......................................... 14 4.3 Building the timer example....................................... 16 4.4 Inspecting dependencies......................................... 16 4.5 Searching packages........................................... 17 4.6 Building
    [Show full text]