Changes between Initial Version and Version 1 of CMakeAddExecutable


Ignore:
Timestamp:
Jun 18, 2007, 11:32:37 AM (15 years ago)
Author:
Douglas Gregor
Comment:

Iniitial documentation

Legend:

Unmodified
Added
Removed
Modified
  • CMakeAddExecutable

    v1 v1  
     1= CMake Macro Reference: `boost_add_executable` =
     2
     3Creates a new executable from source files.
     4
     5{{{
     6boost_add_executable(exename
     7                     source1 source2 ...
     8                     [COMPILE_FLAGS compileflags]
     9                     [feature_COMPILE_FLAGS compileflags]
     10                     [LINK_FLAGS linkflags]
     11                     [feature_LINK_FLAGS linkflags]
     12                     [LINK_LIBS linklibs]
     13                     [feature_LINK_LIBS linklibs]
     14                     [DEPENDS libdepend1 libdepend2 ...]
     15                     [feature]
     16                     [NO_INSTALL])
     17}}}
     18
     19where {{{exename}}} is the name of the executable (e.g., "wave"). {{{source1}}},
     20{{{source2}}}, etc. are the source files used to build the executable, e.g.,
     21cpp.cpp. If no source files are provided, "{{{exename.cpp}}}" will be
     22used.
     23
     24This macro has a variety of options that affect its behavior. In
     25several cases, we use the placeholder "feature" in the option name to
     26indicate that there are actually several different kinds of options,
     27each referring to a different build feature, e.g., shared libraries,
     28multi-threaded, debug build, etc. For a complete listing of these
     29features, please refer to the page on [wiki:CMakeBuildFeatures CMake
     30Build Features].
     31
     32The options that affect this macro's behavior are:
     33
     34  COMPILE_FLAGS::
     35  Provides additional compilation flags that will be
     36  used when building the executable.
     37
     38  feature_COMPILE_FLAGS::
     39  Provides additional compilation flags that
     40  will be used only when building the executable with the given
     41  feature (e.g., {{{SHARED_COMPILE_FLAGS}}} when we're linking against
     42  shared libraries). Note that the set of features used to build the
     43  executable depends both on the arguments given to
     44  {{{boost_add_executable}}} (see the "feature" argument description,
     45  below) and on the user's choice of variants to build.
     46
     47  LINK_FLAGS::
     48   Provides additional flags that will be passed to the
     49  linker when linking the executable. This option should not be used
     50  to link in additional libraries; see {{{LINK_LIBS}}} and {{{DEPENDS}}}.
     51
     52  feature_LINK_FLAGS::
     53  Provides additional flags that will be passed
     54  to the linker when linking the executable with the given feature
     55  (e.g., {{{MULTI_THREADED_LINK_FLAGS}}} when we're linking a
     56  multi-threaded executable).
     57
     58  LINK_LIBS::
     59  Provides additional libraries against which the
     60  executable will be linked. For example, one might provide "expat"
     61  as options to LINK_LIBS, to state that the executable will link
     62  against the expat library binary. Use LINK_LIBS for libraries
     63  external to Boost; for Boost libraries, use DEPENDS.
     64
     65  feature_LINK_LIBS::
     66  Provides additional libraries to link against
     67  when linking an executable built with the given feature.
     68
     69  DEPENDS::
     70  States that this executable depends on and links against
     71  a Boostlibrary. The arguments to DEPENDS should be the unversioned
     72  name of the Boost library, such as "boost_filesystem". Like
     73  LINK_LIBS, this option states that the executable will link
     74  against the stated libraries. Unlike LINK_LIBS, however, DEPENDS
     75  takes particular library variants into account, always linking to
     76  the appropriate variant of a Boost library. For example, if the
     77  {{{MULTI_THREADED}}} feature was requested in the call to
     78  boost_add_executable, DEPENDS will ensure that we only link
     79  against multi-threaded libraries.
     80
     81  feature::
     82  States that the executable should always be built using a
     83  given feature, e.g., SHARED linking (against its libraries) or
     84  MULTI_THREADED (for multi-threaded builds). If that feature has
     85  been turned off by the user, the executable will not build.
     86
     87  NO_INSTALL::
     88  Don't install this executable with the rest of Boost.
     89
     90  OUTPUT_NAME::
     91  If you want the executable to be generated somewhere
     92  other than the binary directory, pass the path (including
     93  directory and file name) via the OUTPUT_NAME parameter.
     94
     95== Example ==
     96
     97The Boost.Wave library also includes the {{{wave}}} tool, which
     98provides a complete C89/C99/C++ preprocessor. It uses the Wave,
     99Program Options, Filesystem, and Serialization libraries in Boost and
     100is built with the following invocation of {{{boost_add_executable}}}:
     101
     102{{{
     103boost_add_executable(wave cpp.cpp
     104  DEPENDS boost_wave boost_program_options boost_filesystem boost_serialization
     105  )
     106}}}
     107
     108This example is from [http://svn.boost.org/svn/boost/sandbox-branches/boost-cmake/boost_1_34_0/tools/wave/CMakeLists.txt tools/wave/CMakeLists.txt].
     109
     110== Where Defined ==
     111This macro is defined in the Boost Core module in [http://svn.boost.org/svn/boost/sandbox-branches/boost-cmake/boost_1_34_0/tools/build/CMake/BoostCore.cmake tools/build/CMake/BoostCore.cmake]