code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>GoogleTest — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="InstallRequiredSystemLibraries" href="InstallRequiredSystemLibraries.html" />
    <link rel="prev" title="GNUInstallDirs" href="GNUInstallDirs.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

GoogleTest

GoogleTest¶

New in version 3.9.

This module defines functions to help use the Google Test infrastructure.  Two
mechanisms for adding tests are provided. gtest_add_tests() has been
around for some time, originally via find_package(GTest).
gtest_discover_tests() was introduced in CMake 3.10.

The (older) gtest_add_tests() scans source files to identify tests.
This is usually effective, with some caveats, including in cross-compiling
environments, and makes setting additional properties on tests more convenient.
However, its handling of parameterized tests is less comprehensive, and it
requires re-running CMake to detect changes to the list of tests.

The (newer) gtest_discover_tests() discovers tests by asking the
compiled test executable to enumerate its tests.  This is more robust and
provides better handling of parameterized tests, and does not require CMake
to be re-run when tests change.  However, it may not work in a cross-compiling
environment, and setting test properties is less convenient.

More details can be found in the documentation of the respective functions.

Both commands are intended to replace use of add_test() to register
tests, and will create a separate CTest test for each Google Test test case.
Note that this is in some cases less efficient, as common set-up and tear-down
logic cannot be shared by multiple test cases executing in the same instance.
However, it provides more fine-grained pass/fail information to CTest, which is
usually considered as more beneficial.  By default, the CTest test name is the
same as the Google Test name (i.e. suite.testcase); see also
TEST_PREFIX and TEST_SUFFIX.

gtest_add_tests¶

Automatically add tests with CTest by scanning source code for Google Test
macros:

gtest_add_tests(TARGET target
                [SOURCES src1...]
                [EXTRA_ARGS arg1...]
                [WORKING_DIRECTORY dir]
                [TEST_PREFIX prefix]
                [TEST_SUFFIX suffix]
                [SKIP_DEPENDENCY]
                [TEST_LIST outVar]
)

gtest_add_tests attempts to identify tests by scanning source files.
Although this is generally effective, it uses only a basic regular expression
match, which can be defeated by atypical test declarations, and is unable to
fully "split" parameterized tests.  Additionally, it requires that CMake be
re-run to discover any newly added, removed or renamed tests (by default,
this means that CMake is re-run when any test source file is changed, but see
SKIP_DEPENDENCY).  However, it has the advantage of declaring tests at
CMake time, which somewhat simplifies setting additional properties on tests,
and always works in a cross-compiling environment.

The options are:

TARGET target

Specifies the Google Test executable, which must be a known CMake
executable target.  CMake will substitute the location of the built
executable when running the test.

SOURCES src1...

When provided, only the listed files will be scanned for test cases.  If
this option is not given, the SOURCES property of the
specified target will be used to obtain the list of sources.

EXTRA_ARGS arg1...

Any extra arguments to pass on the command line to each test case.

WORKING_DIRECTORY dir

Specifies the directory in which to run the discovered test cases.  If this
option is not provided, the current binary directory is used.

TEST_PREFIX prefix

Specifies a prefix to be prepended to the name of each discovered test
case.  This can be useful when the same source files are being used in
multiple calls to gtest_add_test() but with different EXTRA_ARGS.

TEST_SUFFIX suffix

Similar to TEST_PREFIX except the suffix is appended to the name of
every discovered test case.  Both TEST_PREFIX and TEST_SUFFIX may
be specified.

SKIP_DEPENDENCY

Normally, the function creates a dependency which will cause CMake to be
re-run if any of the sources being scanned are changed.  This is to ensure
that the list of discovered tests is updated.  If this behavior is not
desired (as may be the case while actually writing the test cases), this
option can be used to prevent the dependency from being added.

TEST_LIST outVar

The variable named by outVar will be populated in the calling scope
with the list of discovered test cases.  This allows the caller to do
things like manipulate test properties of the discovered tests.

Usage example:

include(GoogleTest)
add_executable(FooTest FooUnitTest.cxx)
gtest_add_tests(TARGET      FooTest
                TEST_SUFFIX .noArgs
                TEST_LIST   noArgsTests
)
gtest_add_tests(TARGET      FooTest
                EXTRA_ARGS  --someArg someValue
                TEST_SUFFIX .withArgs
                TEST_LIST   withArgsTests
)
set_tests_properties(${noArgsTests}   PROPERTIES TIMEOUT 10)
set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)

For backward compatibility, the following form is also supported:

gtest_add_tests(exe args files...)

exe

The path to the test executable or the name of a CMake target.

args

A ;-list of extra arguments to be passed to executable.  The entire
list must be passed as a single argument.  Enclose it in quotes,
or pass "" for no arguments.

files...

A list of source files to search for tests and test fixtures.
Alternatively, use AUTO to specify that exe is the name
of a CMake executable target whose sources should be scanned.

include(GoogleTest)
set(FooTestArgs --foo 1 --bar 2)
add_executable(FooTest FooUnitTest.cxx)
gtest_add_tests(FooTest "${FooTestArgs}" AUTO)

gtest_discover_tests¶

Automatically add tests with CTest by querying the compiled test executable
for available tests:

gtest_discover_tests(target
                     [EXTRA_ARGS arg1...]
                     [WORKING_DIRECTORY dir]
                     [TEST_PREFIX prefix]
                     [TEST_SUFFIX suffix]
                     [TEST_FILTER expr]
                     [NO_PRETTY_TYPES] [NO_PRETTY_VALUES]
                     [PROPERTIES name1 value1...]
                     [TEST_LIST var]
                     [DISCOVERY_TIMEOUT seconds]
                     [XML_OUTPUT_DIR dir]
                     [DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
)

New in version 3.10.

gtest_discover_tests() sets up a post-build command on the test executable
that generates the list of tests by parsing the output from running the test
with the --gtest_list_tests argument.  Compared to the source parsing
approach of gtest_add_tests(), this ensures that the full list of
tests, including instantiations of parameterized tests, is obtained.  Since
test discovery occurs at build time, it is not necessary to re-run CMake when
the list of tests changes.
However, it requires that CROSSCOMPILING_EMULATOR is properly set
in order to function in a cross-compiling environment.

Additionally, setting properties on tests is somewhat less convenient, since
the tests are not available at CMake time.  Additional test properties may be
assigned to the set of tests as a whole using the PROPERTIES option.  If
more fine-grained test control is needed, custom content may be provided
through an external CTest script using the TEST_INCLUDE_FILES
directory property.  The set of discovered tests is made accessible to such a
script via the <target>_TESTS variable.

The options are:

target

Specifies the Google Test executable, which must be a known CMake
executable target.  CMake will substitute the location of the built
executable when running the test.

EXTRA_ARGS arg1...

Any extra arguments to pass on the command line to each test case.

WORKING_DIRECTORY dir

Specifies the directory in which to run the discovered test cases.  If this
option is not provided, the current binary directory is used.

TEST_PREFIX prefix

Specifies a prefix to be prepended to the name of each discovered test
case.  This can be useful when the same test executable is being used in
multiple calls to gtest_discover_tests() but with different
EXTRA_ARGS.

TEST_SUFFIX suffix

Similar to TEST_PREFIX except the suffix is appended to the name of
every discovered test case.  Both TEST_PREFIX and TEST_SUFFIX may
be specified.

TEST_FILTER expr

New in version 3.22.

Filter expression to pass as a --gtest_filter argument during test
discovery.  Note that the expression is a wildcard-based format that
matches against the original test names as used by gtest.  For type or
value-parameterized tests, these names may be different to the potentially
pretty-printed test names that ctest uses.

NO_PRETTY_TYPES

By default, the type index of type-parameterized tests is replaced by the
actual type name in the CTest test name.  If this behavior is undesirable
(e.g. because the type names are unwieldy), this option will suppress this
behavior.

NO_PRETTY_VALUES

By default, the value index of value-parameterized tests is replaced by the
actual value in the CTest test name.  If this behavior is undesirable
(e.g. because the value strings are unwieldy), this option will suppress
this behavior.

PROPERTIES name1 value1...

Specifies additional properties to be set on all tests discovered by this
invocation of gtest_discover_tests().

TEST_LIST var

Make the list of tests available in the variable var, rather than the
default <target>_TESTS.  This can be useful when the same test
executable is being used in multiple calls to gtest_discover_tests().
Note that this variable is only available in CTest.

DISCOVERY_TIMEOUT num

New in version 3.10.3.

Specifies how long (in seconds) CMake will wait for the test to enumerate
available tests.  If the test takes longer than this, discovery (and your
build) will fail.  Most test executables will enumerate their tests very
quickly, but under some exceptional circumstances, a test may require a
longer timeout.  The default is 5.  See also the TIMEOUT option of
execute_process().

Note

In CMake versions 3.10.1 and 3.10.2, this option was called TIMEOUT.
This clashed with the TIMEOUT test property, which is one of the
common properties that would be set with the PROPERTIES keyword,
usually leading to legal but unintended behavior.  The keyword was
changed to DISCOVERY_TIMEOUT in CMake 3.10.3 to address this
problem.  The ambiguous behavior of the TIMEOUT keyword in 3.10.1
and 3.10.2 has not been preserved.

XML_OUTPUT_DIR dir

New in version 3.18.

If specified, the parameter is passed along with --gtest_output=xml:
to test executable. The actual file name is the same as the test target,
including prefix and suffix. This should be used instead of
EXTRA_ARGS --gtest_output=xml to avoid race conditions writing the
XML result output when using parallel test execution.

DISCOVERY_MODE

New in version 3.18.

Provides greater control over when gtest_discover_tests() performs test
discovery. By default, POST_BUILD sets up a post-build command
to perform test discovery at build time. In certain scenarios, like
cross-compiling, this POST_BUILD behavior is not desirable.
By contrast, PRE_TEST delays test discovery until just prior to test
execution. This way test discovery occurs in the target environment
where the test has a better chance at finding appropriate runtime
dependencies.

DISCOVERY_MODE defaults to the value of the
CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE variable if it is not
passed when calling gtest_discover_tests(). This provides a mechanism
for globally selecting a preferred test discovery behavior without having
to modify each call site.

Previous topic

GNUInstallDirs

Next topic

InstallRequiredSystemLibraries

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

GoogleTest

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>InstallRequiredSystemLibraries — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="ProcessorCount" href="ProcessorCount.html" />
    <link rel="prev" title="GoogleTest" href="GoogleTest.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

InstallRequiredSystemLibraries

InstallRequiredSystemLibraries¶

Include this module to search for compiler-provided system runtime
libraries and add install rules for them.  Some optional variables
may be set prior to including the module to adjust behavior:

CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS

Specify additional runtime libraries that may not be detected.
After inclusion any detected libraries will be appended to this.

CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP

Set to TRUE to skip calling the install(PROGRAMS) command to
allow the includer to specify its own install rule, using the value of
CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS to get the list of libraries.

CMAKE_INSTALL_DEBUG_LIBRARIES

Set to TRUE to install the debug runtime libraries when available
with MSVC tools.

CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY

Set to TRUE to install only the debug runtime libraries with MSVC
tools even if the release runtime libraries are also available.

CMAKE_INSTALL_UCRT_LIBRARIES

New in version 3.6.

Set to TRUE to install the Windows Universal CRT libraries for
app-local deployment (e.g. to Windows XP).  This is meaningful
only with MSVC from Visual Studio 2015 or higher.

New in version 3.9: One may set a CMAKE_WINDOWS_KITS_10_DIR environment variable
to an absolute path to tell CMake to look for Windows 10 SDKs in
a custom location.  The specified directory is expected to contain
Redist/ucrt/DLLs/* directories.

CMAKE_INSTALL_MFC_LIBRARIES

Set to TRUE to install the MSVC MFC runtime libraries.

CMAKE_INSTALL_OPENMP_LIBRARIES

Set to TRUE to install the MSVC OpenMP runtime libraries

CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION

Specify the install(PROGRAMS) command DESTINATION
option.  If not specified, the default is bin on Windows
and lib elsewhere.

CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS

Set to TRUE to disable warnings about required library files that
do not exist.  (For example, Visual Studio Express editions may
not provide the redistributable files.)

CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT

New in version 3.3.

Specify the install(PROGRAMS) command COMPONENT
option.  If not specified, no such option will be used.

New in version 3.10: Support for installing Intel compiler runtimes.

Previous topic

GoogleTest

Next topic

ProcessorCount

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

InstallRequiredSystemLibraries

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.

repo_name: lazytadpole/codenamesilverfish

license: mit


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>MacroAddFileDependencies — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TestBigEndian" href="TestBigEndian.html" />
    <link rel="prev" title="GetPrerequisites" href="GetPrerequisites.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

MacroAddFileDependencies

MacroAddFileDependencies¶

Deprecated since version 3.14.

MACRO_ADD_FILE_DEPENDENCIES(<source> <files>...)

Do not use this command in new code.  It is just a wrapper around:

set_property(SOURCE <source> APPEND PROPERTY OBJECT_DEPENDS <files>...)

Instead use the set_property() command to append to the
OBJECT_DEPENDS source file property directly.

Previous topic

GetPrerequisites

Next topic

TestBigEndian

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

MacroAddFileDependencies

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>ProcessorCount — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="SelectLibraryConfigurations" href="SelectLibraryConfigurations.html" />
    <link rel="prev" title="InstallRequiredSystemLibraries" href="InstallRequiredSystemLibraries.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

ProcessorCount

ProcessorCount¶

ProcessorCount(var)

Determine the number of processors/cores and save value in ${var}

Sets the variable named ${var} to the number of physical cores
available on the machine if the information can be determined.
Otherwise it is set to 0.  Currently this functionality is implemented
for AIX, cygwin, FreeBSD, HPUX, Linux, macOS, QNX, Sun and
Windows.

Changed in version 3.15: On Linux, returns the container CPU count instead of the host CPU count.

This function is guaranteed to return a positive integer (>=1) if it
succeeds.  It returns 0 if there's a problem determining the processor
count.

More generally accurate physical CPU count can be obtained via
cmake_host_system_information():

cmake_host_system_information(RESULT N
                              QUERY NUMBER_OF_PHYSICAL_CORES)

Example use, in a ctest -S dashboard script:

include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
  set(CTEST_BUILD_FLAGS -j${N})
  set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
endif()

This function is intended to offer an approximation of the value of
the number of compute cores available on the current machine, such
that you may use that value for parallel building and parallel
testing.  It is meant to help utilize as much of the machine as seems
reasonable.  Of course, knowledge of what else might be running on the
machine simultaneously should be used when deciding whether to request
a machine's full capacity all for yourself.

Previous topic

InstallRequiredSystemLibraries

Next topic

SelectLibraryConfigurations

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

ProcessorCount

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>SelectLibraryConfigurations — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="SquishTestScript" href="SquishTestScript.html" />
    <link rel="prev" title="ProcessorCount" href="ProcessorCount.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

SelectLibraryConfigurations

SelectLibraryConfigurations¶

select_library_configurations(basename)

This macro takes a library base name as an argument, and will choose
good values for the variables

basename_LIBRARY
basename_LIBRARIES
basename_LIBRARY_DEBUG
basename_LIBRARY_RELEASE

depending on what has been found and set.

If only basename_LIBRARY_RELEASE is defined, basename_LIBRARY will
be set to the release value, and basename_LIBRARY_DEBUG will be set
to basename_LIBRARY_DEBUG-NOTFOUND.  If only basename_LIBRARY_DEBUG
is defined, then basename_LIBRARY will take the debug value, and
basename_LIBRARY_RELEASE will be set to basename_LIBRARY_RELEASE-NOTFOUND.

If the generator supports configuration types, then basename_LIBRARY
and basename_LIBRARIES will be set with debug and optimized flags
specifying the library to be used for the given configuration.  If no
build type has been set or the generator in use does not support
configuration types, then basename_LIBRARY and basename_LIBRARIES
will take only the release value, or the debug value if the release one
is not set.

Previous topic

ProcessorCount

Next topic

SquishTestScript

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

SelectLibraryConfigurations

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>SquishTestScript — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TestForANSIForScope" href="TestForANSIForScope.html" />
    <link rel="prev" title="SelectLibraryConfigurations" href="SelectLibraryConfigurations.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

SquishTestScript

SquishTestScript¶

This script launches a GUI test using Squish.  You should not call the
script directly; instead, you should access it via the SQUISH_ADD_TEST
macro that is defined in FindSquish.cmake.

This script starts the Squish server, launches the test on the client,
and finally stops the squish server.  If any of these steps fail
(including if the tests do not pass) then a fatal error is raised.

Previous topic

SelectLibraryConfigurations

Next topic

TestForANSIForScope

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

SquishTestScript

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>TestBigEndian — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TestCXXAcceptsFlag" href="TestCXXAcceptsFlag.html" />
    <link rel="prev" title="MacroAddFileDependencies" href="MacroAddFileDependencies.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestBigEndian

TestBigEndian¶

Deprecated since version 3.20: Supserseded by the CMAKE_<LANG>_BYTE_ORDER variable.

Check if the target architecture is big endian or little endian.

test_big_endian¶

test_big_endian(<var>)

Stores in variable <var> either 1 or 0 indicating whether the
target architecture is big or little endian.

Previous topic

MacroAddFileDependencies

Next topic

TestCXXAcceptsFlag

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestBigEndian

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>TestCXXAcceptsFlag — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UseJavaClassFilelist" href="UseJavaClassFilelist.html" />
    <link rel="prev" title="TestBigEndian" href="TestBigEndian.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestCXXAcceptsFlag

TestCXXAcceptsFlag¶

Deprecated since version 3.0: See CheckCXXCompilerFlag.

Check if the CXX compiler accepts a flag.

CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)

<flags>

the flags to try

<variable>

variable to store the result

Previous topic

TestBigEndian

Next topic

UseJavaClassFilelist

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestCXXAcceptsFlag

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>TestForANSIForScope — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TestForANSIStreamHeaders" href="TestForANSIStreamHeaders.html" />
    <link rel="prev" title="SquishTestScript" href="SquishTestScript.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForANSIForScope

TestForANSIForScope¶

Check for ANSI for scope support

Check if the compiler restricts the scope of variables declared in a
for-init-statement to the loop body.

CMAKE_NO_ANSI_FOR_SCOPE - holds result

Previous topic

SquishTestScript

Next topic

TestForANSIStreamHeaders

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForANSIForScope

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>TestForANSIStreamHeaders — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TestForSSTREAM" href="TestForSSTREAM.html" />
    <link rel="prev" title="TestForANSIForScope" href="TestForANSIForScope.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForANSIStreamHeaders

TestForANSIStreamHeaders¶

Test for compiler support of ANSI stream headers iostream, etc.

check if the compiler supports the standard ANSI iostream header
(without the .h)

CMAKE_NO_ANSI_STREAM_HEADERS - defined by the results

Previous topic

TestForANSIForScope

Next topic

TestForSSTREAM

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForANSIStreamHeaders

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>TestForSSTREAM — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="TestForSTDNamespace" href="TestForSTDNamespace.html" />
    <link rel="prev" title="TestForANSIStreamHeaders" href="TestForANSIStreamHeaders.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForSSTREAM

TestForSSTREAM¶

Test for compiler support of ANSI sstream header

check if the compiler supports the standard ANSI sstream header

CMAKE_NO_ANSI_STRING_STREAM - defined by the results

Previous topic

TestForANSIStreamHeaders

Next topic

TestForSTDNamespace

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForSSTREAM

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>TestForSTDNamespace — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UseEcos" href="UseEcos.html" />
    <link rel="prev" title="TestForSSTREAM" href="TestForSSTREAM.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForSTDNamespace

TestForSTDNamespace¶

Test for std:: namespace support

check if the compiler supports std:: on stl classes

CMAKE_NO_STD_NAMESPACE - defined by the results

Previous topic

TestForSSTREAM

Next topic

UseEcos

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

TestForSTDNamespace

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UseEcos — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UseJava" href="UseJava.html" />
    <link rel="prev" title="TestForSTDNamespace" href="TestForSTDNamespace.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseEcos

UseEcos¶

This module defines variables and macros required to build eCos application.

This file contains the following macros:

ECOS_ADD_INCLUDE_DIRECTORIES()

add the eCos include dirs

ECOS_ADD_EXECUTABLE(name source1 ...  sourceN )

create an eCos executable

ECOS_ADJUST_DIRECTORY(VAR source1 ...  sourceN )

adjusts the path of the source files and puts the result into VAR

Macros for selecting the toolchain:

ECOS_USE_ARM_ELF_TOOLS()

enable the ARM ELF toolchain for the directory where it is called

ECOS_USE_I386_ELF_TOOLS()

enable the i386 ELF toolchain for the directory where it is called

ECOS_USE_PPC_EABI_TOOLS()

enable the PowerPC toolchain for the directory where it is called

It contains the following variables:

ECOS_DEFINITIONS

ECOSCONFIG_EXECUTABLE

ECOS_CONFIG_FILE

defaults to ecos.ecc, if your eCos configuration file has a different name, adjust this variable for internal use only:

ECOS_ADD_TARGET_LIB

Previous topic

TestForSTDNamespace

Next topic

UseJava

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseEcos

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UseJava — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UseSWIG" href="UseSWIG.html" />
    <link rel="prev" title="UseEcos" href="UseEcos.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseJava

UseJava¶

This file provides support for Java.  It is assumed that
FindJava has already been loaded.  See FindJava for
information on how to load Java into your CMake project.

Synopsis¶

Creating and Installing JARS
  add_jar (<target_name> [SOURCES] <source1> [<source2>...] ...)
  install_jar (<target_name> DESTINATION <destination> [COMPONENT <component>])
  install_jni_symlink (<target_name> DESTINATION <destination> [COMPONENT <component>])

Header Generation
  create_javah ((TARGET <target> | GENERATED_FILES <VAR>) CLASSES <class>... ...)

Exporting JAR Targets
  install_jar_exports (TARGETS <jars>... FILE <filename> DESTINATION <destination> ...)
  export_jars (TARGETS <jars>... [NAMESPACE <namespace>] FILE <filename>)

Finding JARs
  find_jar (<VAR> NAMES <name1> [<name2>...] [PATHS <path1> [<path2>... ENV <var>]] ...)

Creating Java Documentation
  create_javadoc (<VAR> (PACKAGES <pkg1> [<pkg2>...] | FILES <file1> [<file2>...]) ...)

Creating And Installing JARs¶

add_jar¶

Creates a jar file containing java objects and, optionally, resources:

add_jar(<target_name>
        [SOURCES] <source1> [<source2>...] [<resource1>...]
        [RESOURCES NAMESPACE <ns1> <resource1>... [NAMESPACE <nsX> <resourceX>...]... ]
        [INCLUDE_JARS <jar1> [<jar2>...]]
        [ENTRY_POINT <entry>]
        [VERSION <version>]
        [MANIFEST <manifest>]
        [OUTPUT_NAME <name>]
        [OUTPUT_DIR <dir>]
        [GENERATE_NATIVE_HEADERS <target>
                                 [DESTINATION (<dir>|INSTALL <dir> [BUILD <dir>])]]
        )

This command creates a <target_name>.jar.  It compiles the given
<source> files and adds the given <resource> files to
the jar file.  Source files can be java files or listing files
(prefixed by @).  If only resource files are given then just a jar file
is created.

SOURCES

Compiles the specified source files and adds the result in the jar file.

New in version 3.4: Support for response files, prefixed by @.

RESOURCES

New in version 3.21.

Adds the named <resource> files to the jar by stripping the source file
path and placing the file beneath <ns> within the jar.

For example:

RESOURCES NAMESPACE "/com/my/namespace" "a/path/to/resource.txt"

results in a resource accessible via /com/my/namespace/resource.txt
within the jar.

Resources may be added without adjusting the namespace by adding them to
the list of SOURCES (original behavior), in this case, resource
paths must be relative to CMAKE_CURRENT_SOURCE_DIR.  Adding resources
without using the RESOURCES parameter in out of source builds will
almost certainly result in confusion.

Note

Adding resources via the SOURCES parameter relies upon a hard-coded
list of file extensions which are tested to determine whether they
compile (e.g. File.java). SOURCES files which match the extensions
are compiled. Files which do not match are treated as resources. To
include uncompiled resources matching those file extensions use
the RESOURCES parameter.

INCLUDE_JARS

The list of jars are added to the classpath when compiling the java sources
and also to the dependencies of the target. INCLUDE_JARS also accepts
other target names created by add_jar(). For backwards compatibility,
jar files listed as sources are ignored (as they have been since the first
version of this module).

ENTRY_POINT

Defines an entry point in the jar file.

VERSION

Adds a version to the target output name.

The following example will create a jar file with the name
shibboleet-1.2.0.jar and will create a symlink shibboleet.jar
pointing to the jar with the version information.

add_jar(shibboleet shibbotleet.java VERSION 1.2.0)

MANIFEST

Defines a custom manifest for the jar.

OUTPUT_NAME

Specify a different output name for the target.

OUTPUT_DIR

Sets the directory where the jar file will be generated. If not specified,
CMAKE_CURRENT_BINARY_DIR is used as the output directory.

GENERATE_NATIVE_HEADERS

New in version 3.11.

Generates native header files for methods declared as native. These files
provide the connective glue that allow your Java and C code to interact.
An INTERFACE target will be created for an easy usage of generated files.
Sub-option DESTINATION can be used to specify the output directory for
generated header files.

This option requires, at least, version 1.8 of the JDK.

For an optimum usage of this option, it is recommended to include module
JNI before any call to add_jar(). The produced target for native
headers can then be used to compile C/C++ sources with the
target_link_libraries() command.

find_package(JNI)
add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native)
add_library(bar bar.cpp)
target_link_libraries(bar PRIVATE foo-native)

New in version 3.20: DESTINATION sub-option now supports the possibility to specify
different output directories for BUILD and INSTALL steps. If
BUILD directory is not specified, a default directory will be used.

To export the interface target generated by GENERATE_NATIVE_HEADERS
option, sub-option INSTALL of DESTINATION is required:

add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native
                     DESTINATION INSTALL include)
install(TARGETS foo-native EXPORT native)
install(DIRECTORY "$<TARGET_PROPERTY:foo-native,NATIVE_HEADERS_DIRECTORY>/"
        DESTINATION include)
install(EXPORT native DESTINATION /to/export NAMESPACE foo)

Some variables can be set to customize the behavior of add_jar() as well
as the java compiler:

CMAKE_JAVA_COMPILE_FLAGS

Specify additional flags to java compiler.

CMAKE_JAVA_INCLUDE_PATH

Specify additional paths to the class path.

CMAKE_JNI_TARGET

If the target is a JNI library, sets this boolean variable to TRUE to
enable creation of a JNI symbolic link (see also
install_jni_symlink()).

CMAKE_JAR_CLASSES_PREFIX

If multiple jars should be produced from the same java source filetree,
to prevent the accumulation of duplicate class files in subsequent jars,
set/reset CMAKE_JAR_CLASSES_PREFIX prior to calling the add_jar():

set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
add_jar(foo foo.java)

set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
add_jar(bar bar.java)

The add_jar() function sets the following target properties on
<target_name>:

INSTALL_FILES

The files which should be installed.  This is used by
install_jar().

JNI_SYMLINK

The JNI symlink which should be installed.  This is used by
install_jni_symlink().

JAR_FILE

The location of the jar file so that you can include it.

CLASSDIR

The directory where the class files can be found.  For example to use them
with javah.

NATIVE_HEADERS_DIRECTORY

New in version 3.20.

The directory where native headers are generated. Defined when option
GENERATE_NATIVE_HEADERS is specified.

install_jar¶

This command installs the jar file to the given destination:

install_jar(<target_name> <destination>)
install_jar(<target_name> DESTINATION <destination> [COMPONENT <component>])

This command installs the <target_name> file to the given
<destination>.  It should be called in the same scope as
add_jar() or it will fail.

New in version 3.4: The second signature with DESTINATION and COMPONENT options.

DESTINATION

Specify the directory on disk to which a file will be installed.

COMPONENT

Specify an installation component name with which the install rule is
associated, such as "runtime" or "development".

The install_jar() command sets the following target properties
on <target_name>:

INSTALL_DESTINATION

Holds the <destination> as described above, and is used by
install_jar_exports().

install_jni_symlink¶

Installs JNI symlinks for target generated by add_jar():

install_jni_symlink(<target_name> <destination>)
install_jni_symlink(<target_name> DESTINATION <destination> [COMPONENT <component>])

This command installs the <target_name> JNI symlinks to the given
<destination>.  It should be called in the same scope as
add_jar() or it will fail.

New in version 3.4: The second signature with DESTINATION and COMPONENT options.

DESTINATION

Specify the directory on disk to which a file will be installed.

COMPONENT

Specify an installation component name with which the install rule is
associated, such as "runtime" or "development".

Utilize the following commands to create a JNI symbolic link:

set(CMAKE_JNI_TARGET TRUE)
add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})

Header Generation¶

create_javah¶

New in version 3.4.

Generates C header files for java classes:

create_javah(TARGET <target> | GENERATED_FILES <VAR>
             CLASSES <class>...
             [CLASSPATH <classpath>...]
             [DEPENDS <depend>...]
             [OUTPUT_NAME <path>|OUTPUT_DIR <path>]
             )

Deprecated since version 3.11: This command will no longer be supported starting with version 10 of the JDK
due to the suppression of javah tool.
The add_jar(GENERATE_NATIVE_HEADERS) command should be
used instead.

Create C header files from java classes. These files provide the connective
glue that allow your Java and C code to interact.

There are two main signatures for create_javah().  The first signature
returns generated files through variable specified by the GENERATED_FILES
option.  For example:

create_javah(GENERATED_FILES files_headers
  CLASSES org.cmake.HelloWorld
  CLASSPATH hello.jar
)

The second signature for create_javah() creates a target which
encapsulates header files generation. E.g.

create_javah(TARGET target_headers
  CLASSES org.cmake.HelloWorld
  CLASSPATH hello.jar
)

Both signatures share same options.

CLASSES

Specifies Java classes used to generate headers.

CLASSPATH

Specifies various paths to look up classes. Here .class files, jar
files or targets created by command add_jar can be used.

DEPENDS

Targets on which the javah target depends.

OUTPUT_NAME

Concatenates the resulting header files for all the classes listed by
option CLASSES into <path>.  Same behavior as option -o of
javah tool.

OUTPUT_DIR

Sets the directory where the header files will be generated.  Same behavior
as option -d of javah tool.  If not specified,
CMAKE_CURRENT_BINARY_DIR is used as the output directory.

Exporting JAR Targets¶

install_jar_exports¶

New in version 3.7.

Installs a target export file:

install_jar_exports(TARGETS <jars>...
                    [NAMESPACE <namespace>]
                    FILE <filename>
                    DESTINATION <destination> [COMPONENT <component>])

This command installs a target export file <filename> for the named jar
targets to the given <destination> directory.  Its function is similar to
that of install(EXPORT).

TARGETS

List of targets created by add_jar() command.

NAMESPACE

New in version 3.9.

The <namespace> value will be prepend to the target names as they are
written to the import file.

FILE

Specify name of the export file.

DESTINATION

Specify the directory on disk to which a file will be installed.

COMPONENT

Specify an installation component name with which the install rule is
associated, such as "runtime" or "development".

export_jars¶

New in version 3.7.

Writes a target export file:

export_jars(TARGETS <jars>...
            [NAMESPACE <namespace>]
            FILE <filename>)

This command writes a target export file <filename> for the named <jars>
targets.  Its function is similar to that of export().

TARGETS

List of targets created by add_jar() command.

NAMESPACE

New in version 3.9.

The <namespace> value will be prepend to the target names as they are
written to the import file.

FILE

Specify name of the export file.

Finding JARs¶

find_jar¶

Finds the specified jar file:

find_jar(<VAR>
         <name> | NAMES <name1> [<name2>...]
         [PATHS <path1> [<path2>... ENV <var>]]
         [VERSIONS <version1> [<version2>]]
         [DOC "cache documentation string"]
        )

This command is used to find a full path to the named jar.  A cache
entry named by <VAR> is created to store the result of this command.
If the full path to a jar is found the result is stored in the
variable and the search will not repeated unless the variable is
cleared.  If nothing is found, the result will be <VAR>-NOTFOUND, and
the search will be attempted again next time find_jar() is invoked with
the same variable.

NAMES

Specify one or more possible names for the jar file.

PATHS

Specify directories to search in addition to the default locations.
The ENV var sub-option reads paths from a system environment variable.

VERSIONS

Specify jar versions.

DOC

Specify the documentation string for the <VAR> cache entry.

Creating Java Documentation¶

create_javadoc¶

Creates java documentation based on files and packages:

create_javadoc(<VAR>
               (PACKAGES <pkg1> [<pkg2>...] | FILES <file1> [<file2>...])
               [SOURCEPATH <sourcepath>]
               [CLASSPATH <classpath>]
               [INSTALLPATH <install path>]
               [DOCTITLE <the documentation title>]
               [WINDOWTITLE <the title of the document>]
               [AUTHOR (TRUE|FALSE)]
               [USE (TRUE|FALSE)]
               [VERSION (TRUE|FALSE)]
               )

The create_javadoc() command can be used to create java documentation.
There are two main signatures for create_javadoc().

The first signature works with package names on a path with source files:

create_javadoc(my_example_doc
               PACKAGES com.example.foo com.example.bar
               SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
               CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
               WINDOWTITLE "My example"
               DOCTITLE "<h1>My example</h1>"
               AUTHOR TRUE
               USE TRUE
               VERSION TRUE
              )

The second signature for create_javadoc() works on a given list of files:

create_javadoc(my_example_doc
               FILES java/A.java java/B.java
               CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
               WINDOWTITLE "My example"
               DOCTITLE "<h1>My example</h1>"
               AUTHOR TRUE
               USE TRUE
               VERSION TRUE
              )

Both signatures share most of the options. For more details please read the
javadoc manpage.

PACKAGES

Specify java packages.

FILES

Specify java source files. If relative paths are specified, they are
relative to CMAKE_CURRENT_SOURCE_DIR.

SOURCEPATH

Specify the directory where to look for packages. By default,
CMAKE_CURRENT_SOURCE_DIR directory is used.

CLASSPATH

Specify where to find user class files. Same behavior as option
-classpath of javadoc tool.

INSTALLPATH

Specify where to install the java documentation. If you specified, the
documentation will be installed to
${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>.

DOCTITLE

Specify the title to place near the top of the overview summary file.
Same behavior as option -doctitle of javadoc tool.

WINDOWTITLE

Specify the title to be placed in the HTML <title> tag. Same behavior
as option -windowtitle of javadoc tool.

AUTHOR

When value TRUE is specified, includes the @author text in the
generated docs. Same behavior as option  -author of javadoc tool.

USE

When value TRUE is specified, creates class and package usage pages.
Includes one Use page for each documented class and package. Same behavior
as option -use of javadoc tool.

VERSION

When value TRUE is specified, includes the version text in the
generated docs. Same behavior as option -version of javadoc tool.

Table of Contents

UseJava

Synopsis

Creating And Installing JARs

Header Generation

Exporting JAR Targets

Finding JARs

Creating Java Documentation

Previous topic

UseEcos

Next topic

UseSWIG

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseJava

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UseJavaClassFilelist — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UseJavaSymlinks" href="UseJavaSymlinks.html" />
    <link rel="prev" title="TestCXXAcceptsFlag" href="TestCXXAcceptsFlag.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseJavaClassFilelist

UseJavaClassFilelist¶

Changed in version 3.20: This module was previously documented by mistake and was never meant for
direct inclusion by project code.  See the UseJava module.

Previous topic

TestCXXAcceptsFlag

Next topic

UseJavaSymlinks

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseJavaClassFilelist

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UseJavaSymlinks — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UsePkgConfig" href="UsePkgConfig.html" />
    <link rel="prev" title="UseJavaClassFilelist" href="UseJavaClassFilelist.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseJavaSymlinks

UseJavaSymlinks¶

Changed in version 3.20: This module was previously documented by mistake and was never meant for
direct inclusion by project code.  See the UseJava module.

Previous topic

UseJavaClassFilelist

Next topic

UsePkgConfig

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseJavaSymlinks

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UsePkgConfig — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Use_wxWindows" href="Use_wxWindows.html" />
    <link rel="prev" title="UseJavaSymlinks" href="UseJavaSymlinks.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UsePkgConfig

UsePkgConfig¶

Obsolete pkg-config module for CMake, use FindPkgConfig instead.

This module defines the following macro:

PKGCONFIG(package includedir libdir linkflags cflags)

Calling PKGCONFIG will fill the desired information into the 4 given
arguments, e.g.  PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR
LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) if pkg-config was NOT
found or the specified software package doesn't exist, the variable
will be empty when the function returns, otherwise they will contain
the respective information

Previous topic

UseJavaSymlinks

Next topic

Use_wxWindows

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UsePkgConfig

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UseSWIG — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="UsewxWidgets" href="UsewxWidgets.html" />
    <link rel="prev" title="UseJava" href="UseJava.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseSWIG

UseSWIG¶

This file provides support for SWIG. It is assumed that FindSWIG
module has already been loaded.

Contents

UseSWIG

CMake Commands

Properties on Source Files

Properties on Targets

Read-only Target Properties

CMake Variables

Deprecated Commands

CMake Commands¶

The following command is defined for use with SWIG:

swig_add_library¶

New in version 3.8.

Define swig module with given name and specified language:

swig_add_library(<name>
                 [TYPE <SHARED|MODULE|STATIC|USE_BUILD_SHARED_LIBS>]
                 LANGUAGE <language>
                 [NO_PROXY]
                 [OUTPUT_DIR <directory>]
                 [OUTFILE_DIR <directory>]
                 SOURCES <file>...
                )

Targets created with the swig_add_library command have the same
capabilities as targets created with the add_library() command, so
those targets can be used with any command expecting a target (e.g.
target_link_libraries()).

Changed in version 3.13: This command creates a target with the specified <name> when
policy CMP0078 is set to NEW.  Otherwise, the legacy
behavior will choose a different target name and store it in the
SWIG_MODULE_<name>_REAL_NAME variable.

Changed in version 3.15: Alternate library name (set with the OUTPUT_NAME property,
for example) will be passed on to Python and CSharp wrapper
libraries.

Changed in version 3.21: Generated library use standard naming conventions for CSharp language
when policy CMP0122 is set to NEW. Otherwise, the legacy
behavior is applied.

Note

For multi-config generators, this module does not support
configuration-specific files generated by SWIG. All build
configurations must result in the same generated source file.

Note

For Makefile Generators, if, for some sources, the
USE_SWIG_DEPENDENCIES property is FALSE, swig_add_library does
not track file dependencies, so depending on the <name>_swig_compilation
custom target is required for targets which require the swig-generated
files to exist. Other generators may depend on the source files that would
be generated by SWIG.

TYPE

SHARED, MODULE and STATIC have the same semantic as for the
add_library() command. If USE_BUILD_SHARED_LIBS is specified,
the library type will be STATIC or SHARED based on whether the
current value of the BUILD_SHARED_LIBS variable is ON. If
no type is specified, MODULE will be used.

LANGUAGE

Specify the target language.

New in version 3.1: Go and Lua language support.

New in version 3.2: R language support.

New in version 3.18: Fortran language support.

NO_PROXY

New in version 3.12.

Prevent the generation of the wrapper layer (swig -noproxy option).

OUTPUT_DIR

New in version 3.12.

Specify where to write the language specific files (swig -outdir
option). If not given, the CMAKE_SWIG_OUTDIR variable will be used.
If neither is specified, the default depends on the value of the
UseSWIG_MODULE_VERSION variable as follows:

If UseSWIG_MODULE_VERSION is 1 or is undefined, output is written to
the CMAKE_CURRENT_BINARY_DIR directory.

If UseSWIG_MODULE_VERSION is 2, a dedicated directory will be used.
The path of this directory can be retrieved from the
SWIG_SUPPORT_FILES_DIRECTORY target property.

OUTFILE_DIR

New in version 3.12.

Specify an output directory name where the generated source file will be
placed (swig -o option). If not specified, the SWIG_OUTFILE_DIR
variable will be used. If neither is specified, OUTPUT_DIR or
CMAKE_SWIG_OUTDIR is used instead.

SOURCES

List of sources for the library. Files with extension .i will be
identified as sources for the SWIG tool. Other files will be handled in
the standard way.

New in version 3.14: This behavior can be overridden by specifying the variable
SWIG_SOURCE_FILE_EXTENSIONS.

Note

If UseSWIG_MODULE_VERSION is set to 2, it is strongly recommended
to use a dedicated directory unique to the target when either the
OUTPUT_DIR option or the CMAKE_SWIG_OUTDIR variable are specified.
The output directory contents are erased as part of the target build, so
to prevent interference between targets or losing other important files,
each target should have its own dedicated output directory.

Properties on Source Files¶

Source file properties on module files must be set before the invocation
of the swig_add_library command to specify special behavior of SWIG and
ensure generated files will receive the required settings.

CPLUSPLUS

Call SWIG in c++ mode.  For example:

set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)

SWIG_FLAGS

Deprecated since version 3.12: Replaced with the fine-grained properties that follow.

Pass custom flags to the SWIG executable.

INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS and COMPILE_OPTIONS

New in version 3.12.

Add custom flags to SWIG compiler and have same semantic as properties
INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS and
COMPILE_OPTIONS.

USE_TARGET_INCLUDE_DIRECTORIES

New in version 3.13.

If set to TRUE, contents of target property
INCLUDE_DIRECTORIES will be forwarded to SWIG compiler.
If set to FALSE target property INCLUDE_DIRECTORIES will be
ignored. If not set, target property SWIG_USE_TARGET_INCLUDE_DIRECTORIES
will be considered.

GENERATED_INCLUDE_DIRECTORIES, GENERATED_COMPILE_DEFINITIONS and GENERATED_COMPILE_OPTIONS

New in version 3.12.

Add custom flags to the C/C++ generated source. They will fill, respectively,
properties INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS and
COMPILE_OPTIONS of generated C/C++ file.

DEPENDS

New in version 3.12.

Specify additional dependencies to the source file.

USE_SWIG_DEPENDENCIES

New in version 3.20.

If set to TRUE, implicit dependencies are generated by the swig tool
itself. This property is only meaningful for
Makefile,
Ninja, Xcode, and
Visual Studio
(Visual Studio 12 2013 and above) generators. Default value is
FALSE.

New in version 3.21: Added the support of Xcode generator.

New in version 3.22: Added the support of Visual Studio Generators.

SWIG_MODULE_NAME

Specify the actual import name of the module in the target language.
This is required if it cannot be scanned automatically from source
or different from the module file basename.  For example:

set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)

Changed in version 3.14: If policy CMP0086 is set to NEW, -module <module_name>
is passed to SWIG compiler.

OUTPUT_DIR

New in version 3.19.

Specify where to write the language specific files (swig -outdir option)
for the considered source file. If not specified, the other ways to define
the output directory applies (see OUTPUT_DIR option of
swig_add_library() command).

OUTFILE_DIR

New in version 3.19.

Specify an output directory where the generated source file will be placed
(swig -o option) for the considered source file. If not specified,
OUTPUT_DIR source property will be used. If neither are specified, the
other ways to define output file directory applies (see OUTFILE_DIR
option of swig_add_library() command).

Properties on Targets¶

Target library properties can be set to apply same configuration to all SWIG
input files.

SWIG_INCLUDE_DIRECTORIES, SWIG_COMPILE_DEFINITIONS and SWIG_COMPILE_OPTIONS

New in version 3.12.

These properties will be applied to all SWIG input files and have same
semantic as target properties INCLUDE_DIRECTORIES,
COMPILE_DEFINITIONS and COMPILE_OPTIONS.

set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2)
set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb)

SWIG_USE_TARGET_INCLUDE_DIRECTORIES

New in version 3.13.

If set to TRUE, contents of target property
INCLUDE_DIRECTORIES will be forwarded to SWIG compiler.
If set to FALSE or not defined, target property
INCLUDE_DIRECTORIES will be ignored. This behavior can be
overridden by specifying source property USE_TARGET_INCLUDE_DIRECTORIES.

SWIG_GENERATED_INCLUDE_DIRECTORIES, SWIG_GENERATED_COMPILE_DEFINITIONS and SWIG_GENERATED_COMPILE_OPTIONS

New in version 3.12.

These properties will populate, respectively, properties
INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS and
COMPILE_FLAGS of all generated C/C++ files.

SWIG_DEPENDS

New in version 3.12.

Add dependencies to all SWIG input files.

Read-only Target Properties¶

The following target properties are output properties and can be used to get
information about support files generated by SWIG interface compilation.

SWIG_SUPPORT_FILES

New in version 3.12.

This output property list of wrapper files generated during SWIG compilation.

set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
get_property(support_files TARGET mymod PROPERTY SWIG_SUPPORT_FILES)

Note

Only most principal support files are listed. In case some advanced
features of SWIG are used (for example %template), associated
support files may not be listed. Prefer to use the
SWIG_SUPPORT_FILES_DIRECTORY property to handle support files.

SWIG_SUPPORT_FILES_DIRECTORY

New in version 3.12.

This output property specifies the directory where support files will be
generated.

Note

When source property OUTPUT_DIR is defined, multiple directories can be
specified as part of SWIG_SUPPORT_FILES_DIRECTORY.

CMake Variables¶

Some variables can be set to customize the behavior of swig_add_library
as well as SWIG:

UseSWIG_MODULE_VERSION

New in version 3.12.

Specify different behaviors for UseSWIG module.

Set to 1 or undefined: Legacy behavior is applied.

Set to 2: A new strategy is applied regarding support files: the output
directory of support files is erased before SWIG interface compilation.

CMAKE_SWIG_FLAGS

Add flags to all swig calls.

CMAKE_SWIG_OUTDIR

Specify where to write the language specific files (swig -outdir option).

SWIG_OUTFILE_DIR

New in version 3.8.

Specify an output directory name where the generated source file will be
placed.  If not specified, CMAKE_SWIG_OUTDIR is used.

SWIG_MODULE_<name>_EXTRA_DEPS

Specify extra dependencies for the generated module for <name>.

SWIG_SOURCE_FILE_EXTENSIONS

New in version 3.14.

Specify a list of source file extensions to override the default
behavior of considering only .i files as sources for the SWIG
tool. For example:

set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swg")

SWIG_USE_SWIG_DEPENDENCIES

New in version 3.20.

If set to TRUE, implicit dependencies are generated by the swig tool
itself. This variable is only meaningful for
Makefile,
Ninja, Xcode, and
Visual Studio
(Visual Studio 12 2013 and above) generators. Default value is
FALSE.

Source file property USE_SWIG_DEPENDENCIES, if not defined, will be
initialized with the value of this variable.

New in version 3.21: Added the support of Xcode generator.

New in version 3.22: Added the support of Visual Studio Generators.

Deprecated Commands¶

swig_link_libraries¶

Deprecated since version 3.13: Use target_link_libraries() with the standard target name,
or with ${SWIG_MODULE_<name>_REAL_NAME} for legacy target naming.

Link libraries to swig module:

swig_link_libraries(<name> <item>...)

This command has same capabilities as target_link_libraries()
command.

Note

When policy CMP0078 is set to NEW,
swig_add_library() creates a standard target with the
specified <name> and target_link_libraries() must be used
instead of this command.

With the legacy behavior (when CMP0078 is set to OLD and
the UseSWIG_TARGET_NAME_PREFERENCE variable is set to "LEGACY",
or in CMake versions prior to 3.12), it is preferable to use
target_link_libraries(${SWIG_MODULE_<name>_REAL_NAME} ...)
instead of this command.

Table of Contents

UseSWIG

CMake Commands

Properties on Source Files

Properties on Targets

Read-only Target Properties

CMake Variables

Deprecated Commands

Previous topic

UseJava

Next topic

UsewxWidgets

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UseSWIG

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>Use_wxWindows — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="WriteBasicConfigVersionFile" href="WriteBasicConfigVersionFile.html" />
    <link rel="prev" title="UsePkgConfig" href="UsePkgConfig.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

Use_wxWindows

Use_wxWindows¶

Deprecated since version 2.8.10: Use find_package(wxWidgets) and include(${wxWidgets_USE_FILE}) instead.

This convenience include finds if wxWindows is installed and set the
appropriate libs, incdirs, flags etc.  author Jan Woetzel <jw -at-
mip.informatik.uni-kiel.de> (07/2003)

USAGE:

just include Use_wxWindows.cmake
in your projects CMakeLists.txt

include( ${CMAKE_MODULE_PATH}/Use_wxWindows.cmake)

if you are sure you need GL then

set(WXWINDOWS_USE_GL 1)

*before* you include this file.

Previous topic

UsePkgConfig

Next topic

WriteBasicConfigVersionFile

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

Use_wxWindows

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>UsewxWidgets — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindALSA" href="FindALSA.html" />
    <link rel="prev" title="UseSWIG" href="UseSWIG.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UsewxWidgets

UsewxWidgets¶

Convenience include for using wxWidgets library.

Determines if wxWidgets was FOUND and sets the appropriate libs,
incdirs, flags, etc.  INCLUDE_DIRECTORIES and LINK_DIRECTORIES are
called.

USAGE

# Note that for MinGW users the order of libs is important!
find_package(wxWidgets REQUIRED net gl core base)
include(${wxWidgets_USE_FILE})
# and for each of your dependent executable/library targets:
target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})

DEPRECATED

LINK_LIBRARIES is not called in favor of adding dependencies per target.

AUTHOR

Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>

Previous topic

UseSWIG

Next topic

FindALSA

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

UsewxWidgets

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>WriteBasicConfigVersionFile — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="WriteCompilerDetectionHeader" href="WriteCompilerDetectionHeader.html" />
    <link rel="prev" title="Use_wxWindows" href="Use_wxWindows.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

WriteBasicConfigVersionFile

WriteBasicConfigVersionFile¶

Deprecated since version 3.0: Use the identical command write_basic_package_version_file()
from module CMakePackageConfigHelpers.

WRITE_BASIC_CONFIG_VERSION_FILE( filename
  [VERSION major.minor.patch]
  COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion)
  [ARCH_INDEPENDENT]
  )

Previous topic

Use_wxWindows

Next topic

WriteCompilerDetectionHeader

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

WriteBasicConfigVersionFile

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>WriteCompilerDetectionHeader — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindCUDA" href="FindCUDA.html" />
    <link rel="prev" title="WriteBasicConfigVersionFile" href="WriteBasicConfigVersionFile.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

WriteCompilerDetectionHeader

WriteCompilerDetectionHeader¶

Deprecated since version 3.20: This module is available only if policy CMP0120
is not set to NEW.  Do not use it in new code.

New in version 3.1.

This module provides the function write_compiler_detection_header().

This function can be used to generate a file suitable for preprocessor
inclusion which contains macros to be used in source code:

write_compiler_detection_header(
          FILE <file>
          PREFIX <prefix>
          [OUTPUT_FILES_VAR <output_files_var> OUTPUT_DIR <output_dir>]
          COMPILERS <compiler> [...]
          FEATURES <feature> [...]
          [BARE_FEATURES <feature> [...]]
          [VERSION <version>]
          [PROLOG <prolog>]
          [EPILOG <epilog>]
          [ALLOW_UNKNOWN_COMPILERS]
          [ALLOW_UNKNOWN_COMPILER_VERSIONS]
)

This generates the file <file> with macros which all have the prefix
<prefix>.

By default, all content is written directly to the <file>.  The
OUTPUT_FILES_VAR may be specified to cause the compiler-specific
content to be written to separate files.  The separate files are then
available in the <output_files_var> and may be consumed by the caller
for installation for example.  The OUTPUT_DIR specifies a relative
path from the main <file> to the compiler-specific files. For example:

write_compiler_detection_header(
  FILE climbingstats_compiler_detection.h
  PREFIX ClimbingStats
  OUTPUT_FILES_VAR support_files
  OUTPUT_DIR compilers
  COMPILERS GNU Clang MSVC Intel
  FEATURES cxx_variadic_templates
)
install(FILES
  ${CMAKE_CURRENT_BINARY_DIR}/climbingstats_compiler_detection.h
  DESTINATION include
)
install(FILES
  ${support_files}
  DESTINATION include/compilers
)

VERSION may be used to specify the API version to be generated.
Future versions of CMake may introduce alternative APIs.  A given
API is selected by any <version> value greater than or equal
to the version of CMake that introduced the given API and less
than the version of CMake that introduced its succeeding API.
The value of the CMAKE_MINIMUM_REQUIRED_VERSION
variable is used if no explicit version is specified.
(As of CMake version 3.29.0-rc3 there is only one API version.)

PROLOG may be specified as text content to write at the start of the
header. EPILOG may be specified as text content to write at the end
of the header

At least one <compiler> and one <feature> must be listed.  Compilers
which are known to CMake, but not specified are detected and a preprocessor
#error is generated for them.  A preprocessor macro matching
<PREFIX>_COMPILER_IS_<compiler> is generated for each compiler
known to CMake to contain the value 0 or 1.

Possible compiler identifiers are documented with the
CMAKE_<LANG>_COMPILER_ID variable.
Available features in this version of CMake are listed in the
CMAKE_C_KNOWN_FEATURES and
CMAKE_CXX_KNOWN_FEATURES global properties.
See the cmake-compile-features(7) manual for information on
compile features.

New in version 3.2: Added MSVC and AppleClang compiler support.

New in version 3.6: Added Intel compiler support.

Changed in version 3.8: The {c,cxx}_std_* meta-features are ignored if requested.

New in version 3.8: ALLOW_UNKNOWN_COMPILERS and ALLOW_UNKNOWN_COMPILER_VERSIONS cause
the module to generate conditions that treat unknown compilers as simply
lacking all features.  Without these options the default behavior is to
generate a #error for unknown compilers and versions.

New in version 3.12: BARE_FEATURES will define the compatibility macros with the name used in
newer versions of the language standard, so the code can use the new feature
name unconditionally.

Feature Test Macros¶

For each compiler, a preprocessor macro is generated matching
<PREFIX>_COMPILER_IS_<compiler> which has the content either 0
or 1, depending on the compiler in use. Preprocessor macros for
compiler version components are generated matching
<PREFIX>_COMPILER_VERSION_MAJOR <PREFIX>_COMPILER_VERSION_MINOR
and <PREFIX>_COMPILER_VERSION_PATCH containing decimal values
for the corresponding compiler version components, if defined.

A preprocessor test is generated based on the compiler version
denoting whether each feature is enabled.  A preprocessor macro
matching <PREFIX>_COMPILER_<FEATURE>, where <FEATURE> is the
upper-case <feature> name, is generated to contain the value
0 or 1 depending on whether the compiler in use supports the
feature:

write_compiler_detection_header(
  FILE climbingstats_compiler_detection.h
  PREFIX ClimbingStats
  COMPILERS GNU Clang AppleClang MSVC Intel
  FEATURES cxx_variadic_templates
)

#if ClimbingStats_COMPILER_CXX_VARIADIC_TEMPLATES
template<typename... T>
void someInterface(T t...) { /* ... */ }
#else
// Compatibility versions
template<typename T1>
void someInterface(T1 t1) { /* ... */ }
template<typename T1, typename T2>
void someInterface(T1 t1, T2 t2) { /* ... */ }
template<typename T1, typename T2, typename T3>
void someInterface(T1 t1, T2 t2, T3 t3) { /* ... */ }
#endif

Symbol Macros¶

Some additional symbol-defines are created for particular features for
use as symbols which may be conditionally defined empty:

class MyClass ClimbingStats_FINAL
{
    ClimbingStats_CONSTEXPR int someInterface() { return 42; }
};

The ClimbingStats_FINAL macro will expand to final if the
compiler (and its flags) support the cxx_final feature, and the
ClimbingStats_CONSTEXPR macro will expand to constexpr
if cxx_constexpr is supported.

If BARE_FEATURES cxx_final was given as argument the final keyword
will be defined for old compilers, too.

The following features generate corresponding symbol defines and if they
are available as BARE_FEATURES:

Feature

Define

Symbol

bare

c_restrict

<PREFIX>_RESTRICT

restrict

yes

cxx_constexpr

<PREFIX>_CONSTEXPR

constexpr

yes

cxx_deleted_functions

<PREFIX>_DELETED_FUNCTION

= delete

cxx_extern_templates

<PREFIX>_EXTERN_TEMPLATE

extern

cxx_final

<PREFIX>_FINAL

final

yes

cxx_noexcept

<PREFIX>_NOEXCEPT

noexcept

yes

cxx_noexcept

<PREFIX>_NOEXCEPT_EXPR(X)

noexcept(X)

cxx_override

<PREFIX>_OVERRIDE

override

yes

Compatibility Implementation Macros¶

Some features are suitable for wrapping in a macro with a backward
compatibility implementation if the compiler does not support the feature.

When the cxx_static_assert feature is not provided by the compiler,
a compatibility implementation is available via the
<PREFIX>_STATIC_ASSERT(COND) and
<PREFIX>_STATIC_ASSERT_MSG(COND, MSG) function-like macros. The macros
expand to static_assert where that compiler feature is available, and
to a compatibility implementation otherwise. In the first form, the
condition is stringified in the message field of static_assert.  In
the second form, the message MSG is passed to the message field of
static_assert, or ignored if using the backward compatibility
implementation.

The cxx_attribute_deprecated feature provides a macro definition
<PREFIX>_DEPRECATED, which expands to either the standard
[[deprecated]] attribute or a compiler-specific decorator such
as __attribute__((__deprecated__)) used by GNU compilers.

The cxx_alignas feature provides a macro definition
<PREFIX>_ALIGNAS which expands to either the standard alignas
decorator or a compiler-specific decorator such as
__attribute__ ((__aligned__)) used by GNU compilers.

The cxx_alignof feature provides a macro definition
<PREFIX>_ALIGNOF which expands to either the standard alignof
decorator or a compiler-specific decorator such as __alignof__
used by GNU compilers.

Feature

Define

Symbol

bare

cxx_alignas

<PREFIX>_ALIGNAS

alignas

cxx_alignof

<PREFIX>_ALIGNOF

alignof

cxx_nullptr

<PREFIX>_NULLPTR

nullptr

yes

cxx_static_assert

<PREFIX>_STATIC_ASSERT

static_assert

cxx_static_assert

<PREFIX>_STATIC_ASSERT_MSG

static_assert

cxx_attribute_deprecated

<PREFIX>_DEPRECATED

[[deprecated]]

cxx_attribute_deprecated

<PREFIX>_DEPRECATED_MSG

[[deprecated]]

cxx_thread_local

<PREFIX>_THREAD_LOCAL

thread_local

A use-case which arises with such deprecation macros is the deprecation
of an entire library.  In that case, all public API in the library may
be decorated with the <PREFIX>_DEPRECATED macro.  This results in
very noisy build output when building the library itself, so the macro
may be may be defined to empty in that case when building the deprecated
library:

add_library(compat_support ${srcs})
target_compile_definitions(compat_support
  PRIVATE
    CompatSupport_DEPRECATED=
)

Example Usage¶

Note

This section was migrated from the cmake-compile-features(7)
manual since it relies on the WriteCompilerDetectionHeader module
which is removed by policy CMP0120.

Compile features may be preferred if available, without creating a hard
requirement.  For example, a library may provide alternative
implementations depending on whether the cxx_variadic_templates
feature is available:

#if Foo_COMPILER_CXX_VARIADIC_TEMPLATES
template<int I, int... Is>
struct Interface;

template<int I>
struct Interface<I>
{
  static int accumulate()
  {
    return I;
  }
};

template<int I, int... Is>
struct Interface
{
  static int accumulate()
  {
    return I + Interface<Is...>::accumulate();
  }
};
#else
template<int I1, int I2 = 0, int I3 = 0, int I4 = 0>
struct Interface
{
  static int accumulate() { return I1 + I2 + I3 + I4; }
};
#endif

Such an interface depends on using the correct preprocessor defines for the
compiler features.  CMake can generate a header file containing such
defines using the WriteCompilerDetectionHeader module.  The
module contains the write_compiler_detection_header function which
accepts parameters to control the content of the generated header file:

write_compiler_detection_header(
  FILE "${CMAKE_CURRENT_BINARY_DIR}/foo_compiler_detection.h"
  PREFIX Foo
  COMPILERS GNU
  FEATURES
    cxx_variadic_templates
)

Such a header file may be used internally in the source code of a project,
and it may be installed and used in the interface of library code.

For each feature listed in FEATURES, a preprocessor definition
is created in the header file, and defined to either 1 or 0.

Additionally, some features call for additional defines, such as the
cxx_final and cxx_override features. Rather than being used in
#ifdef code, the final keyword is abstracted by a symbol
which is defined to either final, a compiler-specific equivalent, or
to empty.  That way, C++ code can be written to unconditionally use the
symbol, and compiler support determines what it is expanded to:

struct Interface {
  virtual void Execute() = 0;
};

struct Concrete Foo_FINAL {
  void Execute() Foo_OVERRIDE;
};

In this case, Foo_FINAL will expand to final if the
compiler supports the keyword, or to empty otherwise.

In this use-case, the project code may wish to enable a particular language
standard if available from the compiler. The CXX_STANDARD
target property may be set to the desired language standard for a particular
target, and the CMAKE_CXX_STANDARD variable may be set to
influence all following targets:

write_compiler_detection_header(
  FILE "${CMAKE_CURRENT_BINARY_DIR}/foo_compiler_detection.h"
  PREFIX Foo
  COMPILERS GNU
  FEATURES
    cxx_final cxx_override
)

# Includes foo_compiler_detection.h and uses the Foo_FINAL symbol
# which will expand to 'final' if the compiler supports the requested
# CXX_STANDARD.
add_library(foo foo.cpp)
set_property(TARGET foo PROPERTY CXX_STANDARD 11)

# Includes foo_compiler_detection.h and uses the Foo_FINAL symbol
# which will expand to 'final' if the compiler supports the feature,
# even though CXX_STANDARD is not set explicitly.  The requirement of
# cxx_constexpr causes CMake to set CXX_STANDARD internally, which
# affects the compile flags.
add_library(foo_impl foo_impl.cpp)
target_compile_features(foo_impl PRIVATE cxx_constexpr)

The write_compiler_detection_header function also creates compatibility
code for other features which have standard equivalents.  For example, the
cxx_static_assert feature is emulated with a template and abstracted
via the <PREFIX>_STATIC_ASSERT and <PREFIX>_STATIC_ASSERT_MSG
function-macros.

Table of Contents

WriteCompilerDetectionHeader

Feature Test Macros

Symbol Macros

Compatibility Implementation Macros

Example Usage

Previous topic

WriteBasicConfigVersionFile

Next topic

FindCUDA

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-modules(7) »

WriteCompilerDetectionHeader

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.


code:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <title>CMP0000 — CMake 3.29.0-rc3 Documentation</title>

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/cmake.css" />

    <link rel="icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="cmake-presets(7)" href="../manual/cmake-presets.7.html" />
    <link rel="prev" title="CMP0001" href="CMP0001.html" />

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-policies(7) »

CMP0000

CMP0000¶

A minimum required CMake version must be specified.

CMake requires that projects specify the version of CMake to which
they have been written.  This policy has been put in place so users
trying to build the project may be told when they need to update their
CMake.  Specifying a version also helps the project build with CMake
versions newer than that specified.  Use the cmake_minimum_required()
command at the top of your main CMakeLists.txt file:

cmake_minimum_required(VERSION <major>.<minor>)

where <major>.<minor> is the version of CMake you want to support
(such as 3.14).  The command will ensure that at least the given
version of CMake is running and help newer versions be compatible with
the project.  See documentation of cmake_minimum_required() for
details.

Note that the command invocation must appear in the CMakeLists.txt
file itself; a call in an included file is not sufficient.  However,
the  cmake_policy() command may be called to set policy CMP0000
to OLD or NEW behavior explicitly.  The OLD behavior is to
silently ignore the missing invocation.  The NEW behavior is to issue
an error instead of a warning.  An included file may set CMP0000
explicitly to affect how this policy is enforced for the main
CMakeLists.txt file.

This policy was introduced in CMake version 2.6.0.

Note

The OLD behavior of a policy is
deprecated by definition
and may be removed in a future version of CMake.

Previous topic

CMP0001

Next topic

cmake-presets(7)

This Page

Show Source

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>

Navigation

          index

          next |

          previous |

    CMake »

    3.29.0-rc3 Documentation »

cmake-policies(7) »

CMP0000

        © Copyright 2000-2024 Kitware, Inc. and Contributors.
      Created using Sphinx 6.2.1.