Autotools-style configure script wrapper around CMake

Overview

configure-cmake

configure-cmake is an autotools-style configure script for CMake-based projects.

People building software on Linux or BSD generally expect to be able to ./configure && make && make install, but projects using CMake don't provide a configure script. To make matters worse, the syntax for invoking CMake is awkward and has issues with discoverability.

configure-cmake provides an easy way for people accustomed to autotools-based projects to build your CMake-based project. Just drop the configure script into your project; it will accept most of the standard autotools arguments (such as --prefix and --libdir), as well as custom arguments you can specify, and map them to the correct CMake definitions.

It it as permissively licensed as I can make it (CC0 is basically an attempt to put something in the public domain), so please feel free to copy it into your project—users accustomed to autotools will thank you! You only need the configure script—you shouldn't have to worry about the LICENSE or README files.

Customizing

You can add --enable-, --disable-, and --with-* parameters without modifying the configure script itself. Instead, you only need to create a .configure-custom.sh file next to your configure script. configure will then source .configure-custom.sh and use the variables it finds to integrate the parameters.

The main variables you can set in .configure-custom.sh are:

  • ENABLE_VARS
  • DISABLE_VARS
  • WITH_VARS

Each of these a space separated list of values. Each value is a '|' separated list of up to 3 values, though the first two are optional. The syntax is:

name[|value[|transformed-name]]

The name will be be the name of the argument passed to configure—for enable it will be --enable-name, for disable it will be --disable-name, and for with it will be --with-name.

The optional value is the value passed to CMake, which defaults to "yes".

The optional transformed-name is the key passed to CMake, which defaults to name uppercased and all non-alpha-numeric characters replaced with underscores. For example:

ENABLE_VARS="foo|bar|BAZ"

Will create a --enable-foo parameter for people to pass to configure. If passed, configure will then pass -DBAZ=bar to CMake.

Additionally, if you would like to supply a custom documentation string for parameters (which is displayed in the output of ./configure --help), you can create an additional variable called ENABLE/DISABLE/WITH_transformed-name_DOC. Continuing or previous example:

ENABLE_BAZ_DOC="enable integration with foo"

Will result in the output of ./configure --help displaying

  --enable-foo            enable integration with foo

If you would like to see an example of how this works, you can use the .configure-custom.sh from Squash.

Note that you can also use --pass-thru -DBAZ=bar to achieve the same result.

Comments
  • Don't use bash arrays

    Don't use bash arrays

    FreeBSD apparently doesn't even have bash as an option by default (though it is available in ports), so it looks like I should figure out how to make csh/tcsh work.

    opened by nemequ 8
  • Pass in build directory

    Pass in build directory

    Would it be possible, or perhaps is it possible, to have the script output to a build directory instead the project's root directory? I really like the script; I have even included it in my project, but testing with it clogs up my git staging area. Which in turn drives me bonkers.

    opened by steveno 7
  • "--pass-thru -GNinja .." results in error "shift: can't shift that many"

    This is a brilliant script and while I have got it working in general, it uses the default of "Unix Makefiles" on UNIX-like platforms, which is understandable for traditional compatibility reasons.

    I attempted to use the very common but different generator, Ninja, by using the "--pass-thru" option like so (sitting in the 'build' sub-directory of a project with CMakeLists.txt and configure script parent directory):

    ../configure --pass-thru -GNinja

    and it failed with the error

    ../configure: 303: shift: can't shift that many

    Am I using the wrong syntax?

    opened by sqz 3
  • Out-of-source build doesn't work out of box

    Out-of-source build doesn't work out of box

    [at least for brotli] current directory is not used as a destination of generated build files. Scenario like this won't work as expected: mkdir out && cd out && ../configure A hack is required to fix behaviour: mkdir out && cd out && ../configure--pass-thru -B.

    opened by eustas 3
  • Drop bash dependency

    Drop bash dependency

    Drop bash requirement. Real configure scripts do not require extra dependencies, and bash is not available out of box in many environments including *BSD systems. This should be fairly easy, the only real bash feature used is CMAKE_ARGS array, which could be replaces with three plain variables (which will make the code cleaner as well).

    opened by AMDmi3 3
  • Feature Request: --enable-<something> and --with-<something> support

    Feature Request: --enable- and --with- support

    translate --enable-<something> to -DENABLE_<SOMETHING>=ON and --disable-<something> to -DENABLE_<SOMETHING>=OFF (notice uppercase here). I think this will be useful for many CMake projects. For non-binary options it can be: --with-<something>=a to -DSOMETHING=a

    What do you think about this?

    opened by rilian-la-te 1
  • Fix environment handling

    Fix environment handling

    configure-cmake seem to parse CC/CXX/CFLAGS/CXXFLAGS from arguments, while they should be parsed from environment instead (see real configure help). You should also support CPPFLAGS (may either append to CFLAGS/CXXFLAGS or parse into CMAKE_INCLUDE_PATH) and LDFLAGS (may parse into CMAKE_EXE_LINKER_FLAGS + CMAKE_SHARED_LINKER_FLAGS).

    opened by AMDmi3 5
Owner
Evan Nemerson
Evan Nemerson
📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Setup-free CMake dependency management CPM.cmake is a CMake script that adds dependency management capabilities to CMake. It's built as a thin wrapper

CPM.cmake 1.5k Nov 25, 2022
Check for coding style issues in CMake files

cmakelint parses CMake files and reports style issues. cmakelint requires Python. Installation sudo pip install cmakelint Usage Syntax: cmakelint [--c

Richard Quirk 98 Oct 13, 2022
CMake wrapper for Xrepo C and C++ package manager

xrepo-cmake CMake wrapper for Xrepo C and C++ package manager. Supporting the project Support this project by becoming a sponsor. Your logo will show

xmake-io 22 Nov 7, 2022
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 64 Nov 18, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 393 Nov 18, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 39 Oct 2, 2022
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 162 Oct 24, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 107 Sep 1, 2022
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 82 Oct 25, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 72 Apr 14, 2022
[CMake] [BSD-2] CMake module to find ICU

FindICU.cmake A CMake module to find International Components for Unicode (ICU) Library Note that CMake, since its version 3.7.0, includes a FindICU m

julp 29 Nov 2, 2022
A versatile script engine abstraction layer.

ScriptX A versatile script engine abstraction layer ScriptX is a script engine abstraction layer. A variety of script engines are encapsulated on the

Tencent 373 Nov 22, 2022
CMake project for BL602 RISC-V processor

bl602_cmake_base CMake project for BL602 RISC-V processor How to build NOTE : This project uses a pre-compiled version of the Buffalo SDK (bl_iot_sdk)

null 9 Jan 6, 2022
A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

Alexander Widerberg 1.4k Nov 17, 2022
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
NeoWorld is a resampler using the CMake build system

NeoWorld is a resampler using the CMake build system. It's designed for utsu, OpenUTAU, and UTAU.

null 4 Jun 24, 2022
A CMake addon that avoids you writing boilerplate code for resource management.

SHader INJ(I)ector SHINJI (originally SHader INJector) is a CMake addon that avoids you writing boilerplate code for resource management and exposes s

Lorenzo Rutayisire 6 Mar 21, 2022
A CMake starter template using CPM

Cmake Starter About A lightweight Cmake project meant for a binary application (not a shared library), tests with catch2 are configured, CPM is the pa

Matt Williams 1 Jul 14, 2022
Non-intrusive CMake dependency management

cmodule Non-intrusive CMake dependency management. Normally CMake's find_package() looks for packages installed on host system (and compiled for host

scapix.com 14 Sep 29, 2022