Change wording to "linked or installed"
[cabal.git] / doc / cabal-project-description-file.rst
bloba787a221f583545d7efdb267c73b7256d5efcdea
1 Project Description — cabal.project File
2 ========================================
4 ``cabal.project`` files support a variety of options which configure the
5 details of your build. The general syntax of a ``cabal.project`` file is
6 similar to that of a Cabal file: there are a number of fields, some of
7 which live inside stanzas (groups of fields that apply to only part of a
8 project or can be referenced as a unit):
12     packages: */*.cabal
13     with-compiler: /opt/ghc/8.0.1/bin/ghc
15     package cryptohash
16       optimization: False
18 In general, the accepted field names coincide with the accepted command
19 line flags that ``cabal install`` and other commands take. For example,
20 ``cabal configure --enable-profiling`` will write out a project
21 file with ``profiling: True``.
23 The full configuration of a project is determined by combining the
24 following sources (later entries override earlier ones, except for appendable
25 options):
27 1. :ref:`The user-wide global configuration <config-file-discovery>` (default: ``~/.config/cabal/config``)
29 2. ``cabal.project`` (the project configuration)
31 3. ``cabal.project.freeze`` (the output of ``cabal freeze``)
33 4. ``cabal.project.local`` (the output of ``cabal configure``)
35 Any call to ``cabal build`` will consider ``cabal.project*`` files from parent
36 directories when there is none in the current directory.
38 .. _conditionals and imports:
40 Conditionals and imports
41 ------------------------
43 As of ``cabal-install`` version 3.8, cabal supports conditional logic and
44 imports in ``cabal.project`` files.
46     .. warning::
48       While :ref:`conditional blocks<conditional-blocks>` can appear anywhere
49       within component or common sections of a package, their placement within a
50       project is restricted.  Conditions may only be introduced at the top level
51       of a project.
53       Of the :ref:`condition tests<conditions>`, only packages can test for
54       flags. Projects can test for operating system, architecture, compiler and
55       the boolean constants.
57       - :samp:`os({name})`
58       - :samp:`arch({name})`
59       - :samp:`impl({compiler})`
60       - ``true``
61       - ``false``
63 Imports may specify local filepaths or remote urls, and may reference either
64 cabal.project files or v1-style cabal.config freeze files. As a usage example:
68     if(os(darwin))
69       optimization: False
70     elif(os(freebsd))
71       packages: freebsd/*.cabal
72     else
73       optimization: True
75     import: https://some.remote.source/subdir/cabal.config
77     import: relativepath/extra-project.project
79     import: /absolutepath/some-project.project
81 Using conditionals will force cabal to find a ghc to derive
82 architecture and version information from, which will force some
83 commands (update, sdist) to require ghc present where otherwise it
84 would not be necessitated.
86 Specifying the local packages
87 -----------------------------
89 The following top-level options specify what the local packages of a
90 project are:
92 .. cfg-field:: packages: package location list (space or comma separated)
93     :synopsis: Project packages.
95     :default: ``./*.cabal``
97     .. warning::
99       The default value ``./*.cabal`` only takes effect if there is no explicit
100       ``cabal.project`` file.
101       If you use such explicit file you *must* fill the field.
103     Specifies the list of package locations which contain the local
104     packages to be built by this project. Package locations can take the
105     following forms:
107     1. They can specify a Cabal file, or a directory containing a Cabal
108        file, e.g., ``packages: Cabal cabal-install/cabal-install.cabal``.
110     2. They can specify glob-style wildcards, which must match one or
111        more (a) directories containing a (single) Cabal file, (b) Cabal
112        files (extension ``.cabal``), or (c) tarballs which contain Cabal
113        packages (extension ``.tar.gz``).
114        For example, to match all Cabal files in all
115        subdirectories, as well as the Cabal projects in the parent
116        directories ``foo`` and ``bar``, use
117        ``packages: */*.cabal ../{foo,bar}/``
119     3. They can specify an ``http``, ``https`` or ``file``
120        URL, representing the path to a remote tarball to be downloaded
121        and built.
123     There is no command line variant of this field; see :issue:`3585`.
124     Note that the default value is only included if there is no
125     ``cabal.project`` file. The field is appendable which means there would be
126     no way to drop the default value if it was included.
128 .. cfg-field:: optional-packages: package location list (space or comma-separated)
129     :synopsis: Optional project packages.
131     :default: empty
133     Like :cfg-field:`packages`, specifies a list of package locations
134     containing local packages to be built. Unlike :cfg-field:`packages`,
135     if we glob for a package, it is permissible for the glob to match against
136     zero packages. The intended use-case for :cfg-field:`optional-packages`
137     is to make it so that vendored packages can be automatically picked up if
138     they are placed in a subdirectory, but not error if there aren't any.
140     There is no command line variant of this field.
142 .. cfg-field:: extra-packages: package list with version bounds (comma separated)
143     :synopsis: Adds external packages as local
145     Specifies a list of external packages from Hackage, which
146     should be considered local packages. The motivation for
147     :cfg-field:`extra-packages` is making libraries that are not
148     dependencies of any package in the project available for use in ghci.
150     There is no command line variant of this field.
154 All local packages are *vendored*, in the sense that if other packages
155 (including external ones from Hackage) depend on a package with the name
156 of a local package, the local package is preferentially used.
157 For subdirectories to be considered local packages, the following setting
158 can be used::
160     packages: ./*.cabal
161     optional-packages: ./*/*.cabal
163 ...then any package can be vendored simply by making a checkout in the
164 top-level project directory, as might be seen in this hypothetical
165 directory layout::
167     foo.cabal
168     foo-helper/     # local package
169     unix/           # vendored external package
171 All of these options support globs. ``cabal build`` has its own glob
172 format:
174 -  Anywhere in a path, as many times as you like, you can specify an
175    asterisk ``*`` wildcard. E.g., ``*/*.cabal`` matches all ``.cabal``
176    files in all immediate subdirectories. Like in glob(7), asterisks do
177    not match hidden files unless there is an explicit period, e.g.,
178    ``.*/foo.cabal`` will match ``.private/foo.cabal`` (but
179    ``*/foo.cabal`` will not).
181 -  You can use braces to specify specific directories; e.g.,
182    ``{vendor,pkgs}/*.cabal`` matches all Cabal files in the ``vendor``
183    and ``pkgs`` subdirectories.
185 Formally, the format is described by the following BNF:
187 .. todo::
188     convert globbing grammar to proper ABNF_ syntax
190 .. code-block:: abnf
192     FilePathGlob    ::= FilePathRoot FilePathGlobRel
193     FilePathRoot    ::= {- empty -}        # relative to cabal.project
194                       | "/"                # Unix root
195                       | [a-zA-Z] ":" [/\\] # Windows root
196                       | "~"                # home directory
197     FilePathGlobRel ::= Glob "/"  FilePathGlobRel # Unix directory
198                       | Glob "\\" FilePathGlobRel # Windows directory
199                       | Glob         # file
200                       | {- empty -}  # trailing slash
201     Glob      ::= GlobPiece *
202     GlobPiece ::= "*"            # wildcard
203                 | [^*{},/\\] *   # literal string
204                 | "\\" [*{},]    # escaped reserved character
205                 | "{" Glob "," ... "," Glob "}" # union (match any of these)
208 Specifying Packages from Remote Version Control Locations
209 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
211 Since version 2.4, the ``source-repository-package`` stanza allows for
212 specifying packages in a remote version control system that cabal should
213 consider during package retrieval. This allows use of a package from a
214 remote version control system, rather than looking for that package in
215 Hackage.
217 .. code-block:: cabal
219     packages: .
221     source-repository-package
222         type: git
223         location: https://github.com/hvr/HsYAML.git
224         tag: e70cf0c171c9a586b62b3f75d72f1591e4e6aaa1
226     source-repository-package
227         type: git
228         location: https://github.com/well-typed/cborg
229         tag: 3d274c14ca3077c3a081ba7ad57c5182da65c8c1
230         subdir: cborg
232     source-repository-package
233         type: git
234         location: https://github.com/haskell/network.git
235         tag: e76fdc753e660dfa615af6c8b6a2ad9ddf6afe70
236         post-checkout-command: autoreconf -i
238 Since version 3.4, cabal-install creates tarballs for each package coming
239 from a ``source-repository-package`` stanza (effectively applying cabal
240 sdists to such packages). It gathers the names of the packages from the
241 appropriate .cabal file in the version control repository, and allows
242 their use just like Hackage or locally defined packages.
244 .. cfg-field:: type: VCS kind
246 .. cfg-field:: location: VCS location (usually URL)
248 .. cfg-field:: tag: VCS tag
250 .. cfg-field:: subdir: subdirectory list
252     Look in one or more subdirectories of the repository for cabal files, rather than the root.
254 .. cfg-field:: post-checkout-command: command
256     Run command in the checked out repository, prior sdisting.
258 Global configuration options
259 ----------------------------
261 The following top-level configuration options are not specific to any
262 package, and thus apply globally:
265 .. cfg-field:: verbose: nat
266                -v[n], --verbose[=n]
267     :synopsis: Build verbosity level.
269     :default: 1
271     Control the verbosity of ``cabal`` commands, valid values are from 0
272     to 3.
274     The command line variant of this field is ``--verbose=2``; a short
275     form ``-v2`` is also supported.
277 .. cfg-field:: jobs: nat or $ncpus
278                -j[NUM], --jobs[=NUM], --jobs=$ncpus
279     :synopsis: Number of builds running in parallel.
281     :default: 1
283     Run *nat* jobs simultaneously when building. If ``$ncpus`` is
284     specified, run the number of jobs equal to the number of CPUs.
285     Package building is often quite parallel, so turning on parallelism
286     can speed up build times quite a bit!
288     The command line variant of this field is ``--jobs=2``; a short form
289     ``-j2`` is also supported; a bare ``--jobs`` or ``-j`` is equivalent
290     to ``--jobs=$ncpus``.
292 .. cfg-field::  semaphore: boolean
293                 --semaphore
294                 --no-semaphore
295     :synopsis: Use GHC's support for semaphore based parallelism.
297     :default: False
299     This option instructs cabal to control parallelism by creating a new system semaphore,
300     whose number of tokens is specified by ``--jobs`` (or ``-j``).
301     This semaphore is passed to GHC, which allows it to use any leftover parallelism
302     that ``cabal-install`` is not using.
304     Requires ``ghc >= 9.8``.
306     The command line variant of this field is ``--semaphore``.
308 .. cfg-field::  keep-going: boolean
309                 --keep-going
310     :synopsis: Try to continue building on failure.
312     :default: False
314     If true, after a build failure, continue to build other unaffected
315     packages.
317     The command line variant of this field is ``--keep-going``.
319 .. option:: --builddir=DIR
321     Specifies the name of the directory where build products for
322     build will be stored; defaults to ``dist-newstyle``.  If a
323     relative name is specified, this directory is resolved relative
324     to the root of the project (i.e., where the ``cabal.project``
325     file lives.)
327     This option can only be specified from the command line.
329 .. _cmdoption-project-dir:
330 .. option:: --project-dir=DIR
332     Specifies the path of the project directory. If a relative
333     :ref:`project-file<cmdoption-project-file>` path is also specified,
334     it will be resolved relative to this directory.
336     The project directory does not need to contain a ``cabal.project`` file.
338     This option can only be specified from the command line.
340 .. _cmdoption-project-file:
341 .. option:: --project-file=FILE
343     Specifies the path and name of the project file used to specify the
344     rest of the top-level configuration; defaults to ``cabal.project``.
345     This name not only specifies the name of the main project file,
346     but also the auxiliary project files ``cabal.project.freeze``
347     and ``cabal.project.local``; for example, if you specify
348     ``--project-file=my.project``, then the other files that will
349     be probed are ``my.project.freeze`` and ``my.project.local``.
351     If :ref:`project-dir<cmdoption-project-dir>` is not specified,
352     and the path is relative, we will
353     look for the file relative to the current working directory,
354     and then for the parent directory, until the project file is
355     found or we have hit the top of the user's home directory.
357     This option can only be specified from the command line.
359 .. option:: -z, --ignore-project
361     Ignores the local ``cabal.project`` file and uses the default
362     configuration with the local ``foo.cabal`` file. Note that
363     this flag will be ignored if either of the ``--project-dir`` or
364     ``--project-file`` flags are also set.
366 .. option:: --store-dir=DIR
368     Specifies the name of the directory of the global package store.
370 .. cfg-field:: package-dbs: package DB stack (comma separated)
371                --package-db=[clear, global, user, PATH]
372     :synopsis: PackageDB stack manipulation
373     :since: 3.7
375     There are three package databases involved with most builds:
377     global
378         Compiler installation of rts, base, etc.
379     store
380         Nix-style local build cache
381     in-place
382         Project-specific build directory
384     By default, the package stack you will have with v2 commands is:
386     ::
388         -- [global, store]
390     So all remote packages required by your project will be
391     registered in the store package db (because it is last).
393     When cabal starts building your local projects, it appends the in-place db
394     to the end:
396     ::
398         -- [global, store, in-place]
400     So your local packages get put in ``dist-newstyle`` instead of the store.
402     This flag manipulates the default prefix: ``[global, store]`` and accepts
403     paths, the special value ``global`` referring to the global package db, and
404     ``clear`` which removes all prior entries. For example,
406     ::
408         -- [global, store, foo]
409         package-dbs: foo
411         -- [foo]
412         package-dbs: clear, foo
414         -- [bar, baz]
415         package-dbs: clear, foo, clear, bar, baz
417     The command line variant of this flag is ``--package-db=DB`` which can be
418     specified multiple times.
420 Phase control
421 -------------
423 The following settings apply to commands that result in build actions
424 (``build``, ``run``, ``repl``, ``test``...), and control which phases of the
425 build are executed.
427 .. option:: --dry-run
429     Do not download, build, or install anything, only print what would happen.
431 .. option:: --only-configure
433     Instead of performing a full build just run the configure step.
434     Only accepted by the ``build`` command.
436 .. option:: --only-download
438     Do not build anything, only fetch the packages.
440 .. option:: --only-dependencies
442     Install only the dependencies necessary to build the given packages.
443     Not accepted by the ``repl`` command.
445 Solver configuration options
446 ----------------------------
448 The following settings control the behavior of the dependency solver:
450 .. cfg-field:: constraints: CONSTRAINT (comma separated list)
451                -c CONSTRAINT or -cCONSTRAINT, --constraint=CONSTRAINT
452                --constraint="pkg >= 2.0", -c "pkg >= 2.0"
453     :synopsis: Extra dependencies constraints.
455     Add extra constraints to the version bounds, flag settings,
456     and other properties a solver can pick for a
457     package. For example:
459     ::
461         constraints: bar == 2.1
463     A package can be specified multiple times in ``constraints``, in
464     which case the specified constraints are intersected. This is
465     useful, since the syntax does not allow you to specify multiple
466     constraints at once. For example, to specify both version bounds and
467     flag assignments, you would write:
469     ::
471         constraints:
472             bar == 2.1
473           , bar +foo -baz
475     This is equivalent to writing constraints and :cfg-field:`flags` separately:
477     ::
479         constraints: bar == 2.1
480         package bar
481           flags: +foo -baz
483     Valid constraints take the same form as for the
484     :option:`runhaskell Setup.hs configure --constraint`
485     command line option.
487 .. cfg-field:: preferences: CONSTRAINT (comma separated list)
488                --preference=CONSTRAINT
489                --preference="pkg >= 2.0"
490     :synopsis: Preferred dependency versions.
492     Like :cfg-field:`constraints`, but the solver will attempt to satisfy
493     these preferences on a best-effort basis. The resulting install is locally
494     optimal with respect to preferences; specifically, no single package
495     could be replaced with a more preferred version that still satisfies
496     the hard constraints.
498     Operationally, preferences can cause the solver to attempt certain
499     version choices of a package before others, which can improve
500     dependency solver runtime.
502     One way to use :cfg-field:`preferences` is to take a known working set of
503     constraints (e.g., via ``cabal freeze``) and record them as
504     preferences. In this case, the solver will first attempt to use this
505     configuration, and if this violates hard constraints, it will try to
506     find the minimal number of upgrades to satisfy the hard constraints
507     again.
509     The command line variant of this field is
510     ``--preference="pkg >= 2.0"``; to specify multiple preferences, pass
511     the flag multiple times.
513 .. cfg-field:: allow-newer: none, all or list of scoped package names (space or comma separated)
514                --allow-newer, --allow-newer=[none,all,[scope:][^]pkg]
515     :synopsis: Lift dependencies upper bound constraints.
517     :default: ``none``
519     Allow the solver to pick more recent version of some packages than
520     would normally be permitted by the :pkg-field:`build-depends` bounds
521     of packages in the install plan. This option may be useful if the
522     dependency solver cannot otherwise find a valid install plan.
524     For example, to relax ``pkg``\ s :pkg-field:`build-depends` upper bound on
525     ``dep-pkg``, write a scoped package name of the form:
527     ::
529         allow-newer: pkg:dep-pkg
531     If the scope shall be limited to specific releases of ``pkg``, the
532     extended form as in
534     ::
536         allow-newer: pkg-1.2.3:dep-pkg, pkg-1.1.2:dep-pkg
538     can be used to limit the relaxation of dependencies on
539     ``dep-pkg`` by the ``pkg-1.2.3`` and ``pkg-1.1.2`` releases only.
541     The scoped syntax is recommended, as it is often only a single package
542     whose upper bound is misbehaving. In this case, the upper bounds of
543     other packages should still be respected; indeed, relaxing the bound
544     can break some packages which test the selected version of packages.
546     The syntax also allows to prefix the dependee package with a
547     modifier symbol to modify the scope/semantic of the relaxation
548     transformation in a additional ways. Currently only one modifier
549     symbol is defined, i.e. ``^`` (i.e. caret) which causes the
550     relaxation to be applied only to ``^>=`` operators and leave all other
551     version operators untouched.
553     However, in some situations (e.g., when attempting to build packages
554     on a new version of GHC), it is useful to disregard *all*
555     upper-bounds, with respect to a package or all packages. This can be
556     done by specifying just a package name, or using the keyword ``all``
557     to specify all packages:
559     ::
561         -- Disregard upper bounds involving the dependencies on
562         -- packages bar, baz. For quux only, relax
563         -- 'quux ^>= ...'-style constraints only.
564         allow-newer: bar, baz, ^quux
566         -- Disregard all upper bounds when dependency solving
567         allow-newer: all
569         -- Disregard all `^>=`-style upper bounds when dependency solving
570         allow-newer: ^all
573     For consistency, there is also the explicit wildcard scope syntax
574     ``*`` (or its alphabetic synonym ``all``). Consequently, the
575     examples above are equivalent to the explicitly scoped variants:
577     ::
579         allow-newer: all:bar, *:baz, *:^quux
581         allow-newer: *:*
582         allow-newer: all:all
584         allow-newer: *:^*
585         allow-newer: all:^all
587     In order to ignore all bounds specified by a package ``pkg-1.2.3``
588     you can combine scoping with a right-hand-side wildcard like so
590     ::
592         -- Disregard any upper bounds specified by pkg-1.2.3
593         allow-newer: pkg-1.2.3:*
595         -- Disregard only `^>=`-style upper bounds in pkg-1.2.3
596         allow-newer: pkg-1.2.3:^*
599     :cfg-field:`allow-newer` is often used in conjunction with a constraint
600     (in the :cfg-field:`constraints` field) forcing the usage of a specific,
601     newer version of a package.
603     The command line variant of this field is e.g. ``--allow-newer=bar``. A
604     bare ``--allow-newer`` is equivalent to ``--allow-newer=all``.
606 .. cfg-field:: allow-older: none, all, list of scoped package names (space or comma separated)
607                --allow-older, --allow-older=[none,all,[scope:][^]pkg]
608     :synopsis: Lift dependency lower bound constraints.
609     :since: 2.0
611     :default: ``none``
613     Like :cfg-field:`allow-newer`, but applied to lower bounds rather than
614     upper bounds.
616     The command line variant of this field is ``--allow-older=all``. A
617     bare ``--allow-older`` is equivalent to ``--allow-older=all``.
620 .. cfg-field:: index-state: HEAD, unix-timestamp, ISO8601 UTC timestamp.
621    :synopsis: Use source package index state as it existed at a previous time.
622    :since: 2.0
624    :default: ``HEAD``
626    This allows to change the source package index state the solver uses
627    to compute install-plans. This is particularly useful in
628    combination with freeze-files in order to also freeze the state the
629    package index was in at the time the install-plan was frozen.
631    ::
633       -- UNIX timestamp format example
634       index-state: @1474739268
636       -- ISO8601 UTC timestamp format example
637       -- This format is used by 'cabal configure'
638       -- for storing `--index-state` values.
639       index-state: 2016-09-24T17:47:48Z
641       -- Specify different index-states per package repository
642       -- Supported since 3.4
643       index-state:
644         , hackage.haskell.org 2020-05-06T22:33:27Z
645         , head.hackage 2020-04-29T04:11:05Z
647 .. cfg-field:: active-repositories: reponame1, reponame2
649     :synopsis: Specify active package repositories
650     :since: 3.4
652     :default: ``:rest``
654     Specifies which of the package repositories defined in the configuration
655     should be active. It's also useful for specifying the order and the way
656     active repositories are merged.
658     When searching for a certain version of a certain package name, the list of
659     active repositories is searched last-to-first.
661     For example, suppose hackage.haskell.org has versions 1.0 and 2.0 of
662     package X, and my-repository has version 2.0 of a similarly named package.
663     Then, with the following configuration:
665     ::
667       -- Force my-repository to be the first repository considered
668       active-repositories:
669         , hackage.haskell.org
670         , my-repository
672     version 2.0 of X will come from my-repository, and version 1.0 will come
673     from hackage.haskell.org.
675     If we want to make a repository the sole provider of certain packages, we
676     can put it last in the active repositories list, and add the :override
677     modifier.
679     For example, if we modify the previous example like this:
681     ::
683       active-repositories:
684         , hackage.haskell.org
685         , my-repository:override
687     then version 1.0 of package X won't be found in any case, because X is
688     present in my-repository only in version 2.0, and the :override forbids
689     searching for other versions of X further up the list.
691     :override has no effect for package names that aren't present in the
692     overriding repository.
694     The special repository reference :rest stands for "all the other repositories"
695     and can be useful to avoid lengthy lists of repository names:
697     ::
699       -- Force my-repository to be the first repository considered
700       active-repositories: :rest, my-repository
702     The special repository reference :none disables all repositories, effectively
703     putting cabal in "offline" mode:
705     ::
707       active-repositories: :none
710 .. cfg-field:: reject-unconstrained-dependencies: all, none
711                --reject-unconstrained-dependencies=[all|none]
712    :synopsis: Restrict the solver to packages that have constraints on them.
714    :default: none
715    :since: 2.6
717    By default, the dependency solver can include any package that it's
718    aware of in a build plan. If you wish to restrict the build plan to
719    a closed set of packages (e.g., from a freeze file), use this flag.
721    When set to `all`, all non-local packages that aren't goals must be
722    explicitly constrained. When set to `none`, the solver will
723    consider all packages.
726 Package configuration options
727 -----------------------------
729 Package options affect the building of specific packages. There are three
730 ways a package option can be specified:
732 -  They can be specified at the top-level, in which case they apply only
733    to **local package**, or
735 -  They can be specified inside a ``package`` stanza, in which case they
736    apply to the build of the package, whether or not it is local or
737    external.
739 -  They can be specified inside an ``package *`` stanza, in which case they
740    apply to all packages, local ones from the project and also external
741    dependencies.
744 For example, the following options specify that :cfg-field:`optimization`
745 should be turned off for all local packages, and that ``bytestring`` (possibly
746 an external dependency) should be built with ``-fno-state-hack``::
748     optimization: False
750     package bytestring
751         ghc-options: -fno-state-hack
753 ``ghc-options`` is not specifically described in this documentation, but is one
754 of many fields for configuring programs.  They take the form
755 ``progname-options`` and ``progname-location``, and can be set for all local
756 packages in a ``program-options`` stanza or under a package stanza.
758 On the command line, these options are applied to all local packages.
759 There is no per-package command line interface.
761 Some flags were added by more recent versions of the Cabal library. This
762 means that they are NOT supported by packages which use Custom setup
763 scripts that require a version of the Cabal library older than when the
764 feature was added.
766 .. cfg-field:: flags: list of +flagname or -flagname (space separated)
767                -f FLAGS or -fFLAGS, --flags=FLAGS
768                --flags="+foo -bar", -ffoo, -f-bar
769     :synopsis: Enable or disable package flags.
771     Force all flags specified as ``+flagname`` to be true, and all flags
772     specified as ``-flagname`` to be false. For example, to enable the
773     flag ``foo`` and disable ``bar``, set:
775     ::
777         flags: +foo -bar
779     Exactly one of + or - is required before each flag.
781     Flags are *per-package*, so it doesn't make much sense to specify
782     flags at the top-level, unless you happen to know that *all* of your
783     local packages support the same named flags. If a flag is not
784     supported by a package, it is ignored.
786     The command line variant of this flag is ``--flags``. There is also
787     a shortened form ``-ffoo -f-bar``.
789     A common mistake is to say ``cabal build -fhans``, where
790     ``hans`` is a flag for a transitive dependency that is not in the
791     local package; in this case, the flag will be silently ignored. If
792     ``haskell-tor`` is the package you want this flag to apply to, try
793     ``--constraint="haskell-tor +hans"`` instead. Flags can be specified as
794     package :cfg-field:`constraints`.
796 .. cfg-field:: with-compiler: PATH
797                -w PATH or -wPATH, --with-compiler=PATH
798     :synopsis: Path to compiler executable.
800     Specify the path to a particular compiler to be used. If not an
801     absolute path, it will be resolved according to the ``PATH``
802     environment. The type of the compiler (GHC, GHCJS, etc) must be
803     consistent with the setting of the :cfg-field:`compiler` field.
805     The most common use of this option is to specify a different version
806     of your compiler to be used; e.g., if you have ``ghc-7.8`` in your
807     path, you can specify ``with-compiler: ghc-7.8`` to use it.
809     This flag also sets the default value of :cfg-field:`with-hc-pkg`, using
810     the heuristic that it is named ``ghc-pkg-7.8`` (if your executable name
811     is suffixed with a version number), or is the executable named
812     ``ghc-pkg`` in the same directory as the ``ghc`` directory. If this
813     heuristic does not work, set :cfg-field:`with-hc-pkg` explicitly.
815     For inplace packages, ``cabal build`` maintains a separate build
816     directory for each version of GHC, so you can maintain multiple
817     build trees for different versions of GHC without clobbering each
818     other.
820     It's not possible to set :cfg-field:`with-compiler` on a
821     per-package basis.
823     The command line variant of this flag is
824     ``--with-compiler=ghc-7.8``; there is also a short version
825     ``-w ghc-7.8``.
827 .. cfg-field:: with-hc-pkg: PATH
828                --with-hc-pkg=PATH
829     :synopsis: Path to package tool.
831     Specify the path to the package tool, e.g., ``ghc-pkg``. This
832     package tool must be compatible with the compiler specified by
833     :cfg-field:`with-compiler` (generally speaking, it should be precisely
834     the tool that was distributed with the compiler). If this option is
835     omitted, the default value is determined from :cfg-field:`with-compiler`.
837     The command line variant of this flag is
838     ``--with-hc-pkg=ghc-pkg-7.8``.
840 .. cfg-field:: optimization: nat
841                -O[n], --enable-optimization[=n]
842                --disable-optimization
843     :synopsis: Build with optimization.
845     :default: ``1``
847     Build with optimization. This is appropriate for production use,
848     taking more time to build faster libraries and programs.
850     The optional *nat* value is the optimisation level. Some compilers
851     support multiple optimisation levels. The range is 0 to 2. Level 0
852     disables optimization, level 1 is the default. Level 2 is higher
853     optimisation if the compiler supports it. Level 2 is likely to lead
854     to longer compile times and bigger generated code. If you are not
855     planning to run code, turning off optimization will lead to better
856     build times and less code to be rebuilt when a module changes.
858     When optimizations are enabled, Cabal passes ``-O2`` to the C compiler.
860     We also accept ``True`` (equivalent to 1) and ``False`` (equivalent
861     to 0).
863     Note that as of GHC 8.0, GHC does not recompile when optimization
864     levels change (see :ghc-ticket:`10923`), so if
865     you change the optimization level for a local package you may need
866     to blow away your old build products in order to rebuild with the
867     new optimization level.
869     The command line variant of this flag is ``-O2`` (with ``-O1``
870     equivalent to ``-O``). There are also long-form variants
871     ``--enable-optimization`` and ``--disable-optimization``.
873 .. cfg-field:: configure-options: OPT (space separated list)
874                --configure-option=OPT
875     :synopsis: Options to pass to configure script.
877     A list of extra arguments to pass to the external ``./configure``
878     script, if one is used. This is only useful for packages which have
879     the ``Configure`` build type. See also the section on
880     :ref:`system-dependent parameters`.
882     The command line variant of this flag is ``--configure-option=arg``,
883     which can be specified multiple times to pass multiple options.
885 .. cfg-field:: compiler: ghc, ghcjs, jhc, lhc, uhc or haskell-suite
886                --compiler=compiler
887     :synopsis: Compiler to build with.
889     :default: ``ghc``
891     Specify the compiler toolchain to be used. This is independent of
892     ``with-compiler``, because the choice of toolchain affects Cabal's
893     build logic.
895     The command line variant of this flag is ``--compiler=ghc``.
897     It's not possible to set :cfg-field:`compiler` on a
898     per-package basis.
900 .. cfg-field:: tests: boolean
901                --enable-tests
902                --disable-tests
903     :synopsis: Build tests.
905     :default: ``False``
907     Force test suites to be enabled. For most users this should not be
908     needed, as we always attempt to solve for test suite dependencies,
909     even when this value is ``False``; furthermore, test suites are
910     automatically enabled if they are requested as a built target.
912     The command line variant of this flag is ``--enable-tests`` and
913     ``--disable-tests``.
915 .. cfg-field:: benchmarks: boolean
916                --enable-benchmarks
917                --disable-benchmarks
918     :synopsis: Build benchmarks.
920     :default: ``False``
922     Force benchmarks to be enabled. For most users this should not be
923     needed, as we always attempt to solve for benchmark dependencies,
924     even when this value is ``False``; furthermore, benchmarks are
925     automatically enabled if they are requested as a built target.
927     The command line variant of this flag is ``--enable-benchmarks`` and
928     ``--disable-benchmarks``.
930 .. _cmdoption-extra-prog-path:
931 .. cfg-field:: extra-prog-path: PATH (newline or comma separated list)
932                --extra-prog-path=PATH
933     :synopsis: Add directories to program search path.
934     :since: 1.18
936     A list of directories to search for extra required programs. Most
937     users should not need this, as programs like ``happy`` and ``alex``
938     will automatically be installed and added to the path. This can be
939     useful if a ``Custom`` setup script relies on an exotic extra
940     program.
942     The command line variant of this flag is ``--extra-prog-path=PATH``,
943     which can be specified multiple times.
945     When specifying :ref:`--http-transport<cmdoption-http-transport>` from the
946     command line, only extra-prog-path from the command line are added to the
947     program search path.
949 .. cfg-field:: run-tests: boolean
950                --run-tests
951     :synopsis: Run package test suite during installation.
953     :default: ``False``
955     Run the package test suite during installation. This is useful for
956     saying "When this package is installed, check that the test suite
957     passes, terminating the rest of the build if it is broken."
959     .. warning::
961       One deficiency: the :cfg-field:`run-tests` setting of a package is NOT
962       recorded as part of the hash, so if you install something without
963       :cfg-field:`run-tests` and then turn on ``run-tests``, we won't
964       subsequently test the package. If this is causing you problems, give
965       us a shout.
967     The command line variant of this flag is ``--run-tests``.
969 Object code options
970 ^^^^^^^^^^^^^^^^^^^
972 .. cfg-field:: debug-info: integer
973                --enable-debug-info[=n]
974                --disable-debug-info
975     :synopsis: Build with debug info enabled.
976     :since: 1.22
978     :default: False
980     If the compiler (e.g., GHC 7.10 and later) supports outputting OS
981     native debug info (e.g., DWARF), setting ``debug-info: True`` will
982     instruct it to do so. See the GHC wiki page on :ghc-wiki:`DWARF`
983     for more information about this feature.
985     (This field also accepts numeric syntax, but until GHC 8.2 this didn't
986     do anything.)
988     The command line variant of this flag is ``--enable-debug-info`` and
989     ``--disable-debug-info``.
991 .. cfg-field:: split-sections: boolean
992                --enable-split-sections
993                --disable-split-sections
994     :synopsis: Use GHC's split sections feature.
995     :since: 2.2
997     :default: False
999     Use the GHC ``-split-sections`` feature when building the library. This
1000     reduces the final size of the executables that use the library by
1001     allowing them to link with only the bits that they use rather than
1002     the entire library. The downside is that building the library takes
1003     longer and uses a bit more memory.
1005     This feature is supported by GHC 8.0 and later.
1007     The command line variant of this flag is ``--enable-split-sections`` and
1008     ``--disable-split-sections``.
1010 .. cfg-field:: split-objs: boolean
1011                --enable-split-objs
1012                --disable-split-objs
1013     :synopsis: Use GHC's split objects feature.
1015     :default: False
1017     Use the GHC ``-split-objs`` feature when building the library. This
1018     reduces the final size of the executables that use the library by
1019     allowing them to link with only the bits that they use rather than
1020     the entire library. The downside is that building the library takes
1021     longer and uses considerably more memory.
1023     It is generally recommend that you use ``split-sections`` instead
1024     of ``split-objs`` where possible.
1026     The command line variant of this flag is ``--enable-split-objs`` and
1027     ``--disable-split-objs``.
1029 .. cfg-field:: executable-stripping: boolean
1030                --enable-executable-stripping
1031                --disable-executable-stripping
1032     :synopsis: Strip installed programs.
1034     :default: True
1036     When installing binary executable programs, run the ``strip``
1037     program on the binary. This can considerably reduce the size of the
1038     executable binary file. It does this by removing debugging
1039     information and symbols.
1041     Not all Haskell implementations generate native binaries. For such
1042     implementations this option has no effect.
1044     If ``debug-info`` is set explicitly then ``executable-stripping`` is set
1045     to ``False`` as otherwise all the debug symbols will be stripped.
1047     The command line variant of this flag is
1048     ``--enable-executable-stripping`` and
1049     ``--disable-executable-stripping``.
1051 .. cfg-field:: library-stripping: boolean
1052                --enable-library-stripping
1053                --disable-library-stripping
1054     :synopsis: Strip installed libraries.
1055     :since: 1.20
1057     When installing binary libraries, run the ``strip`` program on the
1058     binary, saving space on the file system. See also
1059     ``executable-stripping``.
1061     If ``debug-info`` is set explicitly then ``library-stripping`` is set
1062     to ``False`` as otherwise all the debug symbols will be stripped.
1064     The command line variant of this flag is
1065     ``--enable-library-stripping`` and ``--disable-library-stripping``.
1067 Executable options
1068 ^^^^^^^^^^^^^^^^^^
1070 .. cfg-field:: program-prefix: PREFIX
1071                --program-prefix=PREFIX
1072     :synopsis: Prepend prefix to program names.
1074     :strike:`Prepend *prefix* to installed program names.` (Currently
1075     implemented in a silly and not useful way. If you need this to work
1076     give us a shout.)
1078     *prefix* may contain the following path variables: ``$pkgid``,
1079     ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
1080     ``$abitag``
1082     The command line variant of this flag is ``--program-prefix=foo-``.
1084 .. cfg-field:: program-suffix: SUFFIX
1085                --program-suffix=SUFFIX
1086     :synopsis: Append refix to program names.
1088     :strike:`Append *suffix* to installed program names.` (Currently
1089     implemented in a silly and not useful way. If you need this to work
1090     give us a shout.)
1092     The most obvious use for this is to append the program's version
1093     number to make it possible to install several versions of a program
1094     at once: ``program-suffix: $version``.
1096     *suffix* may contain the following path variables: ``$pkgid``,
1097     ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
1098     ``$abitag``
1100     The command line variant of this flag is
1101     ``--program-suffix='$version'``.
1103 Dynamic linking options
1104 ^^^^^^^^^^^^^^^^^^^^^^^
1106 .. cfg-field:: shared: boolean
1107                --enable-shared
1108                --disable-shared
1109     :synopsis: Build shared library.
1111     :default: False
1113     Build shared library. This implies a separate compiler run to
1114     generate position independent code as required on most platforms.
1116     The command line variant of this flag is ``--enable-shared`` and
1117     ``--disable-shared``.
1119 .. cfg-field:: executable-dynamic: boolean
1120                --enable-executable-dynamic
1121                --disable-executable-dynamic
1122     :synopsis: Link executables dynamically.
1124     :default: False
1126     Link executables dynamically. The executable's library dependencies
1127     should be built as shared objects. This implies ``shared: True``
1128     unless ``shared: False`` is explicitly specified.
1130     The command line variant of this flag is
1131     ``--enable-executable-dynamic`` and
1132     ``--disable-executable-dynamic``.
1134 .. cfg-field:: library-for-ghci: boolean
1135                --enable-library-for-ghci
1136                --disable-library-for-ghci
1137     :synopsis: Build libraries suitable for use with GHCi.
1139     :default: True
1141     Build libraries suitable for use with GHCi. This involves an extra
1142     linking step after the build.
1144     Not all platforms support GHCi and indeed on some platforms, trying
1145     to build GHCi libs fails. In such cases, consider setting
1146     ``library-for-ghci: False``.
1148     The command line variant of this flag is
1149     ``--enable-library-for-ghci`` and ``--disable-library-for-ghci``.
1151 .. cfg-field:: relocatable:
1152                --relocatable
1153     :synopsis: Build relocatable package.
1154     :since: 1.22
1156     :default: False
1158     :strike:`Build a package which is relocatable.` (TODO: It is not
1159     clear what this actually does, or if it works at all.)
1161     The command line variant of this flag is ``--relocatable``.
1163 Static linking options
1164 ^^^^^^^^^^^^^^^^^^^^^^
1166 .. cfg-field:: static: boolean
1167                --enable-static
1168                --disable-static
1169     :synopsis: Build static library.
1172     :default: False
1174     Roll this and all dependent libraries into a combined ``.a`` archive.
1175     This uses GHCs ``-staticlib`` flag, which is available for iOS and with
1176     GHC 8.4 and later for other platforms as well.
1178 .. cfg-field:: executable-static: boolean
1179                --enable-executable-static
1180                --disable-executable-static
1181     :synopsis: Build fully static executables.
1184     :default: False
1186     Build fully static executables.
1187     This links all dependent libraries into executables statically,
1188     including libc.
1189     This passes ``-static`` and ``-optl=-static`` to GHC.
1191 Foreign function interface options
1192 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1194 .. cfg-field:: extra-include-dirs: directories (comma or newline separated list)
1195                --extra-include-dirs=DIR
1196     :synopsis: Adds C header search path.
1198     An extra directory to search for C header files. You can use this
1199     flag multiple times to get a list of directories.
1201     You might need to use this flag if you have standard system header
1202     files in a non-standard location that is not mentioned in the
1203     package's ``.cabal`` file. Using this option has the same affect as
1204     appending the directory *dir* to the :pkg-field:`include-dirs` field in each
1205     library and executable in the package's ``.cabal`` file. The
1206     advantage of course is that you do not have to modify the package at
1207     all. These extra directories will be used while building the package
1208     and for libraries it is also saved in the package registration
1209     information and used when compiling modules that use the library.
1211     The command line variant of this flag is
1212     ``--extra-include-dirs=DIR``, which can be specified multiple times.
1214 .. cfg-field:: extra-lib-dirs: directories (comma or newline separated list)
1215                --extra-lib-dirs=DIR
1216     :synopsis: Adds library search directory.
1218     An extra directory to search for system libraries files.
1220     The command line variant of this flag is ``--extra-lib-dirs=DIR``,
1221     which can be specified multiple times.
1223 .. cfg-field:: extra-framework-dirs: directories (comma or newline separated list)
1224                --extra-framework-dirs=DIR
1225     :synopsis: Adds framework search directory (OS X only).
1227     An extra directory to search for frameworks (OS X only).
1229     You might need to use this flag if you have standard system
1230     libraries in a non-standard location that is not mentioned in the
1231     package's ``.cabal`` file. Using this option has the same affect as
1232     appending the directory *dir* to the :cfg-field:`extra-lib-dirs` field in
1233     each library and executable in the package's ``.cabal`` file. The
1234     advantage of course is that you do not have to modify the package at
1235     all. These extra directories will be used while building the package
1236     and for libraries it is also saved in the package registration
1237     information and used when compiling modules that use the library.
1239     The command line variant of this flag is
1240     ``--extra-framework-dirs=DIR``, which can be specified multiple
1241     times.
1243 Profiling options
1244 ^^^^^^^^^^^^^^^^^
1246 .. cfg-field:: profiling: boolean
1247                --enable-profiling
1248                --disable-profiling
1249     :synopsis: Enable profiling builds.
1250     :since: 1.22
1252     :default: False
1254     Build libraries and executables with profiling enabled (for
1255     compilers that support profiling as a separate mode). It is only
1256     necessary to specify :cfg-field:`profiling` for the specific package you
1257     want to profile; ``cabal build`` will ensure that all of its
1258     transitive dependencies are built with profiling enabled.
1260     To enable profiling for only libraries or executables, see
1261     :cfg-field:`library-profiling` and :cfg-field:`executable-profiling`.
1263     For useful profiling, it can be important to control precisely what
1264     cost centers are allocated; see :cfg-field:`profiling-detail`.
1266     The command line variant of this flag is ``--enable-profiling`` and
1267     ``--disable-profiling``.
1269 .. cfg-field:: profiling-detail: level
1270                --profiling-detail=level
1271     :synopsis: Profiling detail level.
1272     :since: 1.24
1274     Some compilers that support profiling, notably GHC, can allocate
1275     costs to different parts of the program and there are different
1276     levels of granularity or detail with which this can be done. In
1277     particular for GHC this concept is called "cost centers", and GHC
1278     can automatically add cost centers, and can do so in different ways.
1280     This flag covers both libraries and executables, but can be
1281     overridden by the ``library-profiling-detail`` field.
1283     Currently this setting is ignored for compilers other than GHC. The
1284     levels that cabal currently supports are:
1286     default
1287         For GHC this uses ``exported-functions`` for libraries and
1288         ``toplevel-functions`` for executables.
1289     none
1290         No costs will be assigned to any code within this component.
1291     exported-functions
1292         Costs will be assigned at the granularity of all top level
1293         functions exported from each module. In GHC, this
1294         is for non-inline functions.  Corresponds to ``-fprof-auto-exported``.
1295     toplevel-functions
1296         Costs will be assigned at the granularity of all top level
1297         functions in each module, whether they are exported from the
1298         module or not. In GHC specifically, this is for non-inline
1299         functions.  Corresponds to ``-fprof-auto-top``.
1300     all-functions
1301         Costs will be assigned at the granularity of all functions in
1302         each module, whether top level or local. In GHC specifically,
1303         this is for non-inline toplevel or where-bound functions or
1304         values.  Corresponds to ``-fprof-auto``.
1305     late-toplevel
1306         Like top-level but costs will be assigned to top level definitions after
1307         optimization. This lowers profiling overhead massively while giving similar
1308         levels of detail as toplevle-functions. However it means functions introduced
1309         by GHC during optimization will show up in profiles as well.
1310         Corresponds to ``-fprof-late`` if supported and ``-fprof-auto-top`` otherwise.
1311     late
1312         Currently an alias for late-toplevel
1314     The command line variant of this flag is
1315     ``--profiling-detail=none``.
1317 .. cfg-field:: library-profiling-detail: level
1318                --library-profiling-detail=level
1319     :synopsis: Libraries profiling detail level.
1320     :since: 1.24
1322     Like :cfg-field:`profiling-detail`, but applied only to libraries
1324     The command line variant of this flag is
1325     ``--library-profiling-detail=none``.
1327 .. cfg-field:: library-vanilla: boolean
1328                --enable-library-vanilla
1329                --disable-library-vanilla
1330     :synopsis: Build libraries without profiling.
1332     :default: True
1334     Build ordinary libraries (as opposed to profiling libraries).
1335     Mostly, you can set this to False to avoid building ordinary
1336     libraries when you are profiling.
1338     The command line variant of this flag is
1339     ``--enable-library-vanilla`` and ``--disable-library-vanilla``.
1341 .. cfg-field:: library-profiling: boolean
1342                --enable-library-profiling
1343                --disable-library-profiling
1344     :synopsis: Build libraries with profiling enabled.
1345     :since: 1.22
1347     :default: False
1349     Build libraries with profiling enabled.  You probably want
1350     to use :cfg-field:`profiling` instead.
1352     The command line variant of this flag is
1353     ``--enable-library-profiling`` and ``--disable-library-profiling``.
1355 .. cfg-field:: executable-profiling: boolean
1356                --enable-executable-profiling
1357                --disable-executable-profiling
1358     :synopsis: Build executables with profiling enabled.
1359     :since: 1.22
1361     :default: False
1363     Build executables with profiling enabled. You probably want
1364     to use :cfg-field:`profiling` instead.
1366     The command line variant of this flag is
1367     ``--enable-executable-profiling`` and
1368     ``--disable-executable-profiling``.
1370 Coverage options
1371 ^^^^^^^^^^^^^^^^
1373 .. cfg-field:: coverage: boolean
1374                --enable-coverage
1375                --disable-coverage
1376     :synopsis: Build with coverage enabled.
1377     :since: 1.22
1379     :default: False
1381     Build libraries and executables (including test suites) with Haskell
1382     Program Coverage enabled. Running the test suites will automatically
1383     generate coverage reports with HPC.
1385     The command line variant of this flag is ``--enable-coverage`` and
1386     ``--disable-coverage``.
1388 .. cfg-field:: library-coverage: boolean
1389                --enable-library-coverage
1390                --disable-library-coverage
1391     :since: 1.22
1392     :deprecated:
1394     :default: False
1396     Deprecated, use :cfg-field:`coverage`.
1398     The command line variant of this flag is
1399     ``--enable-library-coverage`` and ``--disable-library-coverage``.
1401 Haddock options
1402 ^^^^^^^^^^^^^^^
1404 .. cfg-field:: documentation: boolean
1405                --enable-documentation
1406                --disable-documentation
1407     :synopsis: Enable building of documentation.
1409     :default: False
1411     Enables building of Haddock documentation.
1412     Implied when calling ``cabal haddock``.
1414     The command line variant of this flag is ``--enable-documentation``
1415     and ``--disable-documentation``.
1417     ``documentation: true`` does not imply
1418     :cfg-field:`haddock-all`,
1419     :cfg-field:`haddock-benchmarks`,
1420     :cfg-field:`haddock-executables`,
1421     :cfg-field:`haddock-internal` or
1422     :cfg-field:`haddock-tests`.
1423     These need to be enabled separately if desired.
1425 .. cfg-field:: doc-index-file: templated path
1426                --doc-index-file=TEMPLATE
1427     :synopsis: Path to haddock templates.
1429     A central index of Haddock API documentation (template cannot use
1430     ``$pkgid``), which should be updated as documentation is built.
1432 The following commands are equivalent to ones that would be passed when
1433 running ``setup haddock``.
1435 .. cfg-field:: haddock-hoogle: boolean
1436                --haddock-hoogle
1437     :synopsis: Generate Hoogle file.
1439     :default: False
1441     Generate a text file which can be converted by Hoogle_
1442     into a database for searching.
1443     This is equivalent to running ``haddock`` with the ``--hoogle`` flag.
1445 .. cfg-field:: haddock-html: boolean
1446                --haddock-html
1447     :synopsis: Build HTML documentation.
1449     :default: True
1451     Build HTML documentation.
1453 .. cfg-field:: haddock-quickjump: boolean
1454                --haddock-quickjump
1455     :synopsis: Generate Quickjump file.
1457     :default: False
1459     Generate an index for interactive documentation navigation.
1460     This is equivalent to running ``haddock`` with the ``--quickjump`` flag.
1462 .. cfg-field:: haddock-html-location: URL (templated path)
1463                --haddock-html-location=URL
1464     :synopsis: Location of HTML documentation for prerequisite packages.
1466     Specify a template for the location of HTML documentation for
1467     prerequisite packages. The substitutions are applied to the template
1468     to obtain a location for each package, which will be used by
1469     hyperlinks in the generated documentation. For example, the
1470     following command generates links pointing at Hackage pages:
1472     ::
1474         html-location: http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html
1476     If passed on the command line,
1477     the argument may be quoted to prevent substitution by the shell.
1479     ::
1481         --html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html'
1483     If this option is omitted, the location for each package is obtained
1484     using the package tool (e.g. ``ghc-pkg``).
1486 .. cfg-field:: haddock-executables: boolean
1487                --haddock-executables
1488     :synopsis: Generate documentation for executables.
1490     :default: False
1492     Run haddock on all executable programs.
1494 .. cfg-field:: haddock-tests: boolean
1495                --haddock-tests
1496     :synopsis: Generate documentation for tests.
1498     :default: False
1500     Run haddock on all test suites.
1502 .. cfg-field:: haddock-benchmarks: boolean
1503                --haddock-benchmarks
1504     :synopsis: Generate documentation for benchmarks.
1506     :default: False
1508     Run haddock on all benchmarks.
1510 .. cfg-field:: haddock-internal: boolean
1511                --haddock-internal
1512     :synopsis: Generate documentation for internal modules
1514     :default: False
1516     Build haddock documentation which includes unexposed modules and
1517     symbols.
1519 .. cfg-field:: haddock-all: boolean
1520                --haddock-all
1521     :synopsis: Generate documentation for everything
1523     :default: False
1525     Run haddock on all components.
1527 .. cfg-field:: haddock-css: PATH
1528                --haddock-css=PATH
1529     :synopsis: Location of Haddock CSS file.
1531     The CSS file that should be used to style the generated
1532     documentation (overriding haddock's default).
1534 .. cfg-field:: haddock-hyperlink-source: boolean
1535                --haddock-hyperlink-source
1536     :synopsis: Generate hyperlinked source code for documentation
1538     :default: False
1540     Generated hyperlinked source code using `HsColour`_, and have
1541     Haddock documentation link to it.
1542     This is equivalent to running ``haddock`` with the ``--hyperlinked-source`` flag.
1544 .. cfg-field:: haddock-hscolour-css: PATH
1545                --haddock-hscolour-css=PATH
1546     :synopsis: Location of CSS file for HsColour
1548     The CSS file that should be used to style the generated hyperlinked
1549     source code (from `HsColour`_).
1551 .. cfg-field:: haddock-contents-location: URL
1552                --haddock-contents-location=URL
1553     :synopsis: URL for contents page.
1555     A baked-in URL to be used as the location for the contents page.
1557 .. cfg-field:: haddock-keep-temp-files: boolean
1558     :synopsis: Keep temporary Haddock files.
1560     Keep temporary files.
1562     There is no command line variant of this flag.
1564 .. cfg-field:: haddock-output-dir: DIR
1565                --haddock-output-dir=DIR
1566     :synopsis: Generate haddock documentation into this directory.
1568     Generate haddock documentation into this directory instead of the default
1569     location next to other build products.
1571     This flag is provided as a technology preview and is subject to change in the
1572     next releases.
1574 .. cfg-field:: open: boolean
1575                --open
1576     :synopsis: Open generated documentation in-browser.
1578     When generating HTML documentation, attempt to open it in a browser
1579     when complete. This will use ``xdg-open`` on Linux and BSD systems,
1580     ``open`` on macOS, and ``start`` on Windows.
1582 Advanced global configuration options
1583 -------------------------------------
1585 .. cfg-field:: write-ghc-environment-files: always, never, or ghc8.4.4+
1586                --write-ghc-environment-files=always\|never\|ghc8.4.4+
1587     :synopsis: Whether a ``.ghc.environment`` should be created after a successful build.
1589     :default: ``never``
1591     Whether a `GHC package environment file <https://downloads.haskell.org/~ghc/master/users-guide/packages.html#package-environments>`_
1592     should be created after a successful build.
1594     Since Cabal 3.0, defaults to ``never``. Before that, defaulted to
1595     creating them only when compiling with GHC 8.4.4 and older (GHC
1596     8.4.4 `is the first version
1597     <https://gitlab.haskell.org/ghc/ghc/-/issues/13753>`_ that supports
1598     the ``-package-env -`` option that allows ignoring the package
1599     environment files).
1601 .. cfg-field:: build-info: True, False
1602                --enable-build-info
1603                --disable-build-info
1604     :synopsis: Whether build information for each individual component should be
1605                written in a machine readable format.
1607     :default: ``False``
1609     Enable generation of build information for Cabal components. Contains very
1610     detailed information on how to build an individual component, such as
1611     compiler version, modules of a component and how to compile the component.
1613     The output format is in json, and the exact location can be discovered from
1614     ``plan.json``, where it is identified by ``build-info`` within the items in
1615     the ``install-plan``.
1616     Note, that this field in ``plan.json`` can be ``null``, if and only if
1617     ``build-type: Custom`` is set, and the ``Cabal`` version is too
1618     old (i.e. ``< 3.7``).
1619     If the field is missing entirely, the component is not a local one, thus,
1620     no ``build-info`` exists for that particular component within the
1621     ``install-plan``.
1623     .. note::
1624         The format and fields of the generated build information is currently experimental,
1625         in the future we might add or remove fields, depending on the needs of other tooling.
1627 .. _cmdoption-http-transport:
1628 .. cfg-field:: http-transport: curl, wget, powershell, or plain-http
1629                --http-transport=transport
1630     :synopsis: Transport to use with http(s) requests.
1632     :default: ``curl``
1634     Set a transport to be used when making http(s) requests.
1636     The command line variant of this field is ``--http-transport=curl``.
1638     If the project configuration imports remote urls, the user can only specify
1639     the http-transport option from the command line.
1641     When specifying the http-transport from the command line, the program
1642     search path can only be influenced using :ref:`--extra-prog-path<cmdoption-extra-prog-path>`.
1644 .. cfg-field:: ignore-expiry: boolean
1645                --ignore-expiry
1646     :synopsis: Ignore Hackage expiration dates.
1648     :default: False
1650     If ``True``, we will ignore expiry dates on metadata from Hackage.
1652     In general, you should not set this to ``True`` as it will leave you
1653     vulnerable to stale cache attacks. However, it may be temporarily
1654     useful if the main Hackage server is down, and we need to rely on
1655     mirrors which have not been updated for longer than the expiry
1656     period on the timestamp.
1658     The command line variant of this field is ``--ignore-expiry``.
1660 .. cfg-field:: remote-repo-cache: directory
1661                --remote-repo-cache=DIR
1662     :synopsis: Location of packages cache.
1664     :default: ``~/.cabal/packages``
1666     The location where packages downloaded from remote repositories will be
1667     cached.
1669     The command line variant of this flag is
1670     ``--remote-repo-cache=DIR``.
1672 .. cfg-field:: logs-dir: directory
1673                --logs-dir=DIR
1674     :synopsis: Directory to store build logs.
1676     :default: ``~/.cabal/logs``
1678     :strike:`The location where build logs for packages are stored.`
1679     Not implemented yet.
1681     The command line variant of this flag is ``--logs-dir=DIR``.
1683 .. cfg-field:: build-summary: template filepath
1684                --build-summary=TEMPLATE
1685     :synopsis: Build summaries location.
1687     :default: ``~/.cabal/logs/build.log``
1689     :strike:`The file to save build summaries.` Not implemented yet.
1691     Valid variables which can be used in the path are ``$pkgid``,
1692     ``$compiler``, ``$os`` and ``$arch``.
1694     The command line variant of this flag is
1695     ``--build-summary=TEMPLATE``.
1697 Undocumented fields: ``root-cmd``, ``symlink-bindir``, ``build-log``,
1698 ``remote-build-reporting``, ``report-planned-failure``, ``offline``.
1700 Advanced solver options
1701 ^^^^^^^^^^^^^^^^^^^^^^^
1703 Most users generally won't need these.
1705 .. cfg-field:: solver: SOLVER
1706                --solver=SOLVER
1707     :synopsis: Which solver to use.
1709     This field is reserved to allow the specification of alternative
1710     dependency solvers. At the moment, the only accepted option is
1711     ``modular``.
1713     The command line variant of this field is ``--solver=modular``.
1715 .. cfg-field:: max-backjumps: nat
1716                --max-backjumps=N
1717     :synopsis: Maximum number of solver backjumps.
1719     :default: 4000
1721     Maximum number of backjumps (backtracking multiple steps) allowed
1722     while solving. Set -1 to allow unlimited backtracking, and 0 to
1723     disable backtracking completely.
1725     The command line variant of this field is ``--max-backjumps=4000``.
1727 .. cfg-field:: reorder-goals: boolean
1728                --reorder-goals
1729                --no-reorder-goals
1730     :synopsis: Allow solver to reorder goals.
1732     :default: False
1734     When enabled, the solver will reorder goals according to certain
1735     heuristics. Slows things down on average, but may make backtracking
1736     faster for some packages. It's unlikely to help for small projects,
1737     but for big install plans it may help you find a plan when otherwise
1738     this is not possible. See :issue:`1780` for more commentary.
1740     The command line variant of this field is ``--(no-)reorder-goals``.
1742 .. cfg-field:: count-conflicts: boolean
1743                --count-conflicts
1744                --no-count-conflicts
1745     :synopsis: Solver prefers versions with less conflicts.
1747     :default: True
1749     Try to speed up solving by preferring goals that are involved in a
1750     lot of conflicts.
1752     The command line variant of this field is
1753     ``--(no-)count-conflicts``.
1755 .. cfg-field:: fine-grained-conflicts: boolean
1756                --fine-grained-conflicts
1757                --no-fine-grained-conflicts
1758     :synopsis: Skip a version of a package if it does not resolve any conflicts
1759                encountered in the last version (solver optimization).
1761     :default: True
1763     When enabled, the solver will skip a version of a package if it does not
1764     resolve any of the conflicts encountered in the last version of that
1765     package. For example, if ``foo-1.2`` depended on ``bar``, and the solver
1766     couldn't find consistent versions for ``bar``'s dependencies, then the
1767     solver would skip ``foo-1.1`` if it also depended on ``bar``.
1769     The command line variant of this field is
1770     ``--(no-)fine-grained-conflicts``.
1772 .. cfg-field:: minimize-conflict-set: boolean
1773                --minimize-conflict-set
1774                --no-minimize-conflict-set
1775     :synopsis: Try to improve the solver error message when there is no
1776                solution.
1778     :default: False
1780     When there is no solution, try to improve the solver error message
1781     by finding a minimal conflict set. This option may increase run
1782     time significantly, so it is off by default.
1784     The command line variant of this field is
1785     ``--(no-)minimize-conflict-set``.
1787 .. cfg-field:: strong-flags: boolean
1788                --strong-flags
1789                --no-strong-flags
1790     :synopsis: Do not defer flag choices when solving.
1792     :default: False
1794     Do not defer flag choices. (TODO: Better documentation.)
1796     The command line variant of this field is ``--(no-)strong-flags``.
1798 .. cfg-field:: allow-boot-library-installs: boolean
1799                --allow-boot-library-installs
1800                --no-allow-boot-library-installs
1801     :synopsis: Allow cabal to install or upgrade any package.
1803     :default: False
1805     By default, the dependency solver doesn't allow ``base``,
1806     ``ghc-prim``, ``integer-simple``, ``integer-gmp``, and
1807     ``template-haskell`` to be installed or upgraded. This flag
1808     removes the restriction.
1810     The command line variant of this field is
1811     ``--(no-)allow-boot-library-installs``.
1813 .. cfg-field:: cabal-lib-version: VERSION
1814                --cabal-lib-version=VERSION
1815     :synopsis: Version of Cabal library used to build package.
1817     This field selects the version of the Cabal library which should be
1818     used to build packages. This option is intended primarily for
1819     internal development use (e.g., forcing a package to build with a
1820     newer version of Cabal, to test a new version of Cabal.) (TODO:
1821     Specify its semantics more clearly.)
1823     The command line variant of this field is
1824     ``--cabal-lib-version=1.24.0.1``.
1826 .. cfg-field:: prefer-oldest: boolean
1827                --prefer-oldest
1828                --no-prefer-oldest
1829     :synopsis: Prefer the oldest versions of packages available.
1830     :since:    3.10
1832     :default:  False
1834     By default, when solver has a choice of multiple versions of the same
1835     package, it will first try to derive a build plan with the latest
1836     version. This flag switches the behaviour, making the solver
1837     to prefer the oldest packages available.
1839     The primary use case is to help users in establishing lower bounds
1840     of upstream dependencies.
1842     The command line variant of this field is ``--(no-)prefer-oldest``.
1844 .. include:: references.inc