.\" Man page generated from reStructuredText. . .TH "CMAKE-MODULES" "7" "August 09, 2019" "3.15.2" "CMake" .SH NAME cmake-modules \- CMake Modules Reference . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .sp The modules listed here are part of the CMake distribution. Projects may provide further modules; their location(s) can be specified in the \fBCMAKE_MODULE_PATH\fP variable. .SH UTILITY MODULES .sp These modules are loaded using the \fBinclude()\fP command. .SS AddFileDependencies .sp Add dependencies to a source file. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ADD_FILE_DEPENDENCIES( ) .ft P .fi .UNINDENT .UNINDENT .sp Adds the given \fB\fP to the dependencies of file \fB\fP\&. .SS AndroidTestUtilities .sp Create a test that automatically loads specified data onto an Android device. .SS Introduction .sp Use this module to push data needed for testing an Android device behavior onto a connected Android device. The module will accept files and libraries as well as separate destinations for each. It will create a test that loads the files into a device object store and link to them from the specified destination. The files are only uploaded if they are not already in the object store. .sp For example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include(AndroidTestUtilities) android_add_test_data( example_setup_test FILES ... LIBS ... DEVICE_TEST_DIR "/data/local/tests/example" DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA" ) .ft P .fi .UNINDENT .UNINDENT .sp At build time a test named "example_setup_test" will be created. Run this test on the command line with \fBctest(1)\fP to load the data onto the Android device. .SS Module Functions .INDENT 0.0 .TP .B android_add_test_data .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C android_add_test_data( [FILES ...] [FILES_DEST ] [LIBS ...] [LIBS_DEST ] [DEVICE_OBJECT_STORE ] [DEVICE_TEST_DIR ] [NO_LINK_REGEX ...] ) .ft P .fi .UNINDENT .UNINDENT .sp The \fBandroid_add_test_data\fP function is used to copy files and libraries needed to run project\-specific tests. On the host operating system, this is done at build time. For on\-device testing, the files are loaded onto the device by the manufactured test at run time. .sp This function accepts the following named parameters: .INDENT 7.0 .TP .B \fBFILES ...\fP zero or more files needed for testing .TP .B \fBLIBS ...\fP zero or more libraries needed for testing .TP .B \fBFILES_DEST \fP absolute path where the data files are expected to be .TP .B \fBLIBS_DEST \fP absolute path where the libraries are expected to be .TP .B \fBDEVICE_OBJECT_STORE \fP absolute path to the location where the data is stored on\-device .TP .B \fBDEVICE_TEST_DIR \fP absolute path to the root directory of the on\-device test location .TP .B \fBNO_LINK_REGEX ...\fP list of regex strings matching the names of files that should be copied from the object store to the testing directory .UNINDENT .UNINDENT .SS BundleUtilities .sp Functions to help assemble a standalone bundle application. .sp A collection of CMake utility functions useful for dealing with \fB\&.app\fP bundles on the Mac and bundle\-like directories on any OS. .sp The following functions are provided by this module: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C fixup_bundle copy_and_fixup_bundle verify_app get_bundle_main_executable get_dotapp_dir get_bundle_and_executable get_bundle_all_executables get_item_key get_item_rpaths clear_bundle_keys set_bundle_key_values get_bundle_keys copy_resolved_item_into_bundle copy_resolved_framework_into_bundle fixup_bundle_item verify_bundle_prerequisites verify_bundle_symlinks .ft P .fi .UNINDENT .UNINDENT .sp Requires CMake 2.6 or greater because it uses function, break and \fBPARENT_SCOPE\fP\&. Also depends on \fBGetPrerequisites.cmake\fP\&. .sp DO NOT USE THESE FUNCTIONS AT CONFIGURE TIME (from \fBCMakeLists.txt\fP)! Instead, invoke them from an \fBinstall(CODE)\fP or \fBinstall(SCRIPT)\fP rule. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C fixup_bundle( ) .ft P .fi .UNINDENT .UNINDENT .sp Fix up \fB\fP bundle in\-place and make it standalone, such that it can be drag\-n\-drop copied to another machine and run on that machine as long as all of the system libraries are compatible. .sp If you pass plugins to \fBfixup_bundle\fP as the libs parameter, you should install them or copy them into the bundle before calling \fBfixup_bundle\fP\&. The \fB\fP parameter is a list of libraries that must be fixed up, but that cannot be determined by \fBotool\fP output analysis (i.e. \fBplugins\fP). .sp Gather all the keys for all the executables and libraries in a bundle, and then, for each key, copy each prerequisite into the bundle. Then fix each one up according to its own list of prerequisites. .sp Then clear all the keys and call \fBverify_app\fP on the final bundle to ensure that it is truly standalone. .sp As an optional parameter (\fBIGNORE_ITEM\fP) a list of file names can be passed, which are then ignored (e.g. \fBIGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"\fP). .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C copy_and_fixup_bundle( ) .ft P .fi .UNINDENT .UNINDENT .sp Makes a copy of the bundle \fB\fP at location \fB\fP and then fixes up the new copied bundle in\-place at \fB\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C verify_app() .ft P .fi .UNINDENT .UNINDENT .sp Verifies that an application \fB\fP appears valid based on running analysis tools on it. Calls \fBmessage(FATAL_ERROR)\fP if the application is not verified. .sp As an optional parameter (\fBIGNORE_ITEM\fP) a list of file names can be passed, which are then ignored (e.g. \fBIGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"\fP) .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C get_bundle_main_executable( ) .ft P .fi .UNINDENT .UNINDENT .sp The result will be the full path name of the bundle\(aqs main executable file or an \fBerror:\fP prefixed string if it could not be determined. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C get_dotapp_dir( ) .ft P .fi .UNINDENT .UNINDENT .sp Returns the nearest parent dir whose name ends with \fB\&.app\fP given the full path to an executable. If there is no such parent dir, then simply return the dir containing the executable. .sp The returned directory may or may not exist. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C get_bundle_and_executable( ) .ft P .fi .UNINDENT .UNINDENT .sp Takes either a \fB\&.app\fP directory name or the name of an executable nested inside a \fB\&.app\fP directory and returns the path to the \fB\&.app\fP directory in \fB\fP and the path to its main executable in \fB\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C get_bundle_all_executables( ) .ft P .fi .UNINDENT .UNINDENT .sp Scans \fB\fP bundle recursively for all \fB\fP executable files and accumulates them into a variable. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C get_item_key( ) .ft P .fi .UNINDENT .UNINDENT .sp Given \fB\fP file name, generate \fB\fP key that should be unique considering the set of libraries that need copying or fixing up to make a bundle standalone. This is essentially the file name including extension with \fB\&.\fP replaced by \fB_\fP .sp This key is used as a prefix for CMake variables so that we can associate a set of variables with a given item based on its key. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C clear_bundle_keys() .ft P .fi .UNINDENT .UNINDENT .sp Loop over the \fB\fP list of keys, clearing all the variables associated with each key. After the loop, clear the list of keys itself. .sp Caller of \fBget_bundle_keys\fP should call \fBclear_bundle_keys\fP when done with list of keys. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C set_bundle_key_values( []) .ft P .fi .UNINDENT .UNINDENT .sp Add \fB\fP key to the list (if necessary) for the given item. If added, also set all the variables associated with that key. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C get_bundle_keys( ) .ft P .fi .UNINDENT .UNINDENT .sp Loop over all the executable and library files within \fB\fP bundle (and given as extra \fB\fP) and accumulate a list of keys representing them. Set values associated with each key such that we can loop over all of them and copy prerequisite libs into the bundle and then do appropriate \fBinstall_name_tool\fP fixups. .sp As an optional parameter (\fBIGNORE_ITEM\fP) a list of file names can be passed, which are then ignored (e.g. \fBIGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"\fP) .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C copy_resolved_item_into_bundle( ) .ft P .fi .UNINDENT .UNINDENT .sp Copy a resolved item into the bundle if necessary. Copy is not necessary, if the \fB\fP is "the same as" the \fB\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C copy_resolved_framework_into_bundle( ) .ft P .fi .UNINDENT .UNINDENT .sp Copy a resolved framework into the bundle if necessary. Copy is not necessary, if the \fB\fP is "the same as" the \fB\fP\&. .sp By default, \fBBU_COPY_FULL_FRAMEWORK_CONTENTS\fP is not set. If you want full frameworks embedded in your bundles, set \fBBU_COPY_FULL_FRAMEWORK_CONTENTS\fP to \fBON\fP before calling fixup_bundle. By default, \fBCOPY_RESOLVED_FRAMEWORK_INTO_BUNDLE\fP copies the framework dylib itself plus the framework \fBResources\fP directory. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C fixup_bundle_item( ) .ft P .fi .UNINDENT .UNINDENT .sp Get the direct/non\-system prerequisites of the \fB\fP\&. For each prerequisite, change the way it is referenced to the value of the \fB_EMBEDDED_ITEM\fP keyed variable for that prerequisite. (Most likely changing to an \fB@executable_path\fP style reference.) .sp This function requires that the \fB\fP be \fBinside\fP the bundle already. In other words, if you pass plugins to \fBfixup_bundle\fP as the libs parameter, you should install them or copy them into the bundle before calling \fBfixup_bundle\fP\&. The \fBlibs\fP parameter is a list of libraries that must be fixed up, but that cannot be determined by otool output analysis. (i.e., \fBplugins\fP) .sp Also, change the id of the item being fixed up to its own \fB_EMBEDDED_ITEM\fP value. .sp Accumulate changes in a local variable and make \fIone\fP call to \fBinstall_name_tool\fP at the end of the function with all the changes at once. .sp If the \fBBU_CHMOD_BUNDLE_ITEMS\fP variable is set then bundle items will be marked writable before \fBinstall_name_tool\fP tries to change them. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C verify_bundle_prerequisites( ) .ft P .fi .UNINDENT .UNINDENT .sp Verifies that the sum of all prerequisites of all files inside the bundle are contained within the bundle or are \fBsystem\fP libraries, presumed to exist everywhere. .sp As an optional parameter (\fBIGNORE_ITEM\fP) a list of file names can be passed, which are then ignored (e.g. \fBIGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"\fP) .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C verify_bundle_symlinks( ) .ft P .fi .UNINDENT .UNINDENT .sp Verifies that any symlinks found in the \fB\fP bundle point to other files that are already also in the bundle... Anything that points to an external file causes this function to fail the verification. .SS CheckCCompilerFlag .sp Check whether the C compiler supports a given flag. .INDENT 0.0 .TP .B check_c_compiler_flag .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_c_compiler_flag( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the \fB\fP is accepted by the compiler without a diagnostic. Stores the result in an internal cache entry named \fB\fP\&. .UNINDENT .sp This command temporarily sets the \fBCMAKE_REQUIRED_DEFINITIONS\fP variable and calls the \fBcheck_c_source_compiles\fP macro from the \fBCheckCSourceCompiles\fP module. See documentation of that module for a listing of variables that can otherwise modify the build. .sp A positive result from this check indicates only that the compiler did not issue a diagnostic message when given the flag. Whether the flag has any effect or even a specific one is beyond the scope of this module. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since the \fBtry_compile()\fP command forwards flags from variables like \fBCMAKE_C_FLAGS\fP, unknown flags in such variables may cause a false negative for this check. .UNINDENT .UNINDENT .SS CheckCSourceCompiles .sp Check if given C source compiles and links into an executable. .INDENT 0.0 .TP .B check_c_source_compiles .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_c_source_compiles( [FAIL_REGEX [...]]) .ft P .fi .UNINDENT .UNINDENT .sp Check that the source supplied in \fB\fP can be compiled as a C source file and linked as an executable (so it must contain at least a \fBmain()\fP function). The result will be stored in the internal cache variable specified by \fB\fP, with a boolean true value for success and boolean false for failure. If \fBFAIL_REGEX\fP is provided, then failure is determined by checking if anything in the output matches any of the specified regular expressions. .sp The underlying check is performed by the \fBtry_compile()\fP command. The compile and link commands can be influenced by setting any of the following variables prior to calling \fBcheck_c_source_compiles()\fP: .INDENT 7.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP Additional flags to pass to the compiler. Note that the contents of \fBCMAKE_C_FLAGS\fP and its associated configuration\-specific variable are automatically added to the compiler command before the contents of \fBCMAKE_REQUIRED_FLAGS\fP\&. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP A \fI;\-list\fP of compiler definitions of the form \fB\-DFOO\fP or \fB\-DFOO=bar\fP\&. A definition for the name specified by \fB\fP will also be added automatically. .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP A \fI;\-list\fP of header search paths to pass to the compiler. These will be the only header search paths used by \fBtry_compile()\fP, i.e. the contents of the \fBINCLUDE_DIRECTORIES\fP directory property will be ignored. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_QUIET\fP If this variable evaluates to a boolean true value, all status messages associated with the check will be suppressed. .UNINDENT .sp The check is only performed once, with the result cached in the variable named by \fB\fP\&. Every subsequent CMake run will re\-use this cached value rather than performing the check again, even if the \fB\fP changes. In order to force the check to be re\-evaluated, the variable named by \fB\fP must be manually removed from the cache. .UNINDENT .SS CheckCSourceRuns .sp Check if given C source compiles and links into an executable and can subsequently be run. .INDENT 0.0 .TP .B check_c_source_runs .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_c_source_runs( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the source supplied in \fB\fP can be compiled as a C source file, linked as an executable and then run. The \fB\fP must contain at least a \fBmain()\fP function. If the \fB\fP could be built and run successfully, the internal cache variable specified by \fB\fP will be set to 1, otherwise it will be set to an value that evaluates to boolean false (e.g. an empty string or an error message). .sp The underlying check is performed by the \fBtry_run()\fP command. The compile and link commands can be influenced by setting any of the following variables prior to calling \fBcheck_c_source_runs()\fP: .INDENT 7.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP Additional flags to pass to the compiler. Note that the contents of \fBCMAKE_C_FLAGS\fP and its associated configuration\-specific variable are automatically added to the compiler command before the contents of \fBCMAKE_REQUIRED_FLAGS\fP\&. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP A \fI;\-list\fP of compiler definitions of the form \fB\-DFOO\fP or \fB\-DFOO=bar\fP\&. A definition for the name specified by \fB\fP will also be added automatically. .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP A \fI;\-list\fP of header search paths to pass to the compiler. These will be the only header search paths used by \fBtry_run()\fP, i.e. the contents of the \fBINCLUDE_DIRECTORIES\fP directory property will be ignored. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_run()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_run()\fP for further details). .TP .B \fBCMAKE_REQUIRED_QUIET\fP If this variable evaluates to a boolean true value, all status messages associated with the check will be suppressed. .UNINDENT .sp The check is only performed once, with the result cached in the variable named by \fB\fP\&. Every subsequent CMake run will re\-use this cached value rather than performing the check again, even if the \fB\fP changes. In order to force the check to be re\-evaluated, the variable named by \fB\fP must be manually removed from the cache. .UNINDENT .SS CheckCXXCompilerFlag .sp Check whether the CXX compiler supports a given flag. .INDENT 0.0 .TP .B check_cxx_compiler_flag .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_cxx_compiler_flag( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the \fB\fP is accepted by the compiler without a diagnostic. Stores the result in an internal cache entry named \fB\fP\&. .UNINDENT .sp This command temporarily sets the \fBCMAKE_REQUIRED_DEFINITIONS\fP variable and calls the \fBcheck_cxx_source_compiles\fP macro from the \fBCheckCXXSourceCompiles\fP module. See documentation of that module for a listing of variables that can otherwise modify the build. .sp A positive result from this check indicates only that the compiler did not issue a diagnostic message when given the flag. Whether the flag has any effect or even a specific one is beyond the scope of this module. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since the \fBtry_compile()\fP command forwards flags from variables like \fBCMAKE_CXX_FLAGS\fP, unknown flags in such variables may cause a false negative for this check. .UNINDENT .UNINDENT .SS CheckCXXSourceCompiles .sp Check if given C++ source compiles and links into an executable. .INDENT 0.0 .TP .B check_cxx_source_compiles .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_cxx_source_compiles( [FAIL_REGEX [...]]) .ft P .fi .UNINDENT .UNINDENT .sp Check that the source supplied in \fB\fP can be compiled as a C++ source file and linked as an executable (so it must contain at least a \fBmain()\fP function). The result will be stored in the internal cache variable specified by \fB\fP, with a boolean true value for success and boolean false for failure. If \fBFAIL_REGEX\fP is provided, then failure is determined by checking if anything in the output matches any of the specified regular expressions. .sp The underlying check is performed by the \fBtry_compile()\fP command. The compile and link commands can be influenced by setting any of the following variables prior to calling \fBcheck_cxx_source_compiles()\fP: .INDENT 7.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP Additional flags to pass to the compiler. Note that the contents of \fBCMAKE_CXX_FLAGS\fP and its associated configuration\-specific variable are automatically added to the compiler command before the contents of \fBCMAKE_REQUIRED_FLAGS\fP\&. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP A \fI;\-list\fP of compiler definitions of the form \fB\-DFOO\fP or \fB\-DFOO=bar\fP\&. A definition for the name specified by \fB\fP will also be added automatically. .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP A \fI;\-list\fP of header search paths to pass to the compiler. These will be the only header search paths used by \fBtry_compile()\fP, i.e. the contents of the \fBINCLUDE_DIRECTORIES\fP directory property will be ignored. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_QUIET\fP If this variable evaluates to a boolean true value, all status messages associated with the check will be suppressed. .UNINDENT .sp The check is only performed once, with the result cached in the variable named by \fB\fP\&. Every subsequent CMake run will re\-use this cached value rather than performing the check again, even if the \fB\fP changes. In order to force the check to be re\-evaluated, the variable named by \fB\fP must be manually removed from the cache. .UNINDENT .SS CheckCXXSourceRuns .sp Check if given C++ source compiles and links into an executable and can subsequently be run. .INDENT 0.0 .TP .B check_cxx_source_runs .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_cxx_source_runs( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the source supplied in \fB\fP can be compiled as a C++ source file, linked as an executable and then run. The \fB\fP must contain at least a \fBmain()\fP function. If the \fB\fP could be built and run successfully, the internal cache variable specified by \fB\fP will be set to 1, otherwise it will be set to an value that evaluates to boolean false (e.g. an empty string or an error message). .sp The underlying check is performed by the \fBtry_run()\fP command. The compile and link commands can be influenced by setting any of the following variables prior to calling \fBcheck_cxx_source_runs()\fP: .INDENT 7.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP Additional flags to pass to the compiler. Note that the contents of \fBCMAKE_CXX_FLAGS\fP and its associated configuration\-specific variable are automatically added to the compiler command before the contents of \fBCMAKE_REQUIRED_FLAGS\fP\&. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP A \fI;\-list\fP of compiler definitions of the form \fB\-DFOO\fP or \fB\-DFOO=bar\fP\&. A definition for the name specified by \fB\fP will also be added automatically. .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP A \fI;\-list\fP of header search paths to pass to the compiler. These will be the only header search paths used by \fBtry_run()\fP, i.e. the contents of the \fBINCLUDE_DIRECTORIES\fP directory property will be ignored. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_run()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_run()\fP for further details). .TP .B \fBCMAKE_REQUIRED_QUIET\fP If this variable evaluates to a boolean true value, all status messages associated with the check will be suppressed. .UNINDENT .sp The check is only performed once, with the result cached in the variable named by \fB\fP\&. Every subsequent CMake run will re\-use this cached value rather than performing the check again, even if the \fB\fP changes. In order to force the check to be re\-evaluated, the variable named by \fB\fP must be manually removed from the cache. .UNINDENT .SS CheckCXXSymbolExists .sp Check if a symbol exists as a function, variable, or macro in C++ .INDENT 0.0 .TP .B CHECK_CXX_SYMBOL_EXISTS .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_CXX_SYMBOL_EXISTS( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the \fB\fP is available after including given header \fB\fP and store the result in a \fB\fP\&. Specify the list of files in one argument as a semicolon\-separated list. \fBCHECK_CXX_SYMBOL_EXISTS()\fP can be used to check in C++ files, as opposed to \fBCHECK_SYMBOL_EXISTS()\fP, which works only for \fBC\fP\&. .sp If the header files define the symbol as a macro it is considered available and assumed to work. If the header files declare the symbol as a function or variable then the symbol must also be available for linking. If the symbol is a type or enum value it will not be recognized (consider using \fBCheckTypeSize\fP or \fBCheckCXXSourceCompiles\fP). .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP string of compile command line flags. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP a \fI;\-list\fP of macros to define (\-DFOO=bar). .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP a \fI;\-list\fP of header search paths to pass to the compiler. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP a \fI;\-list\fP of options to add to the link command. .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP a \fI;\-list\fP of libraries to add to the link command. See policy \fBCMP0075\fP\&. .TP .B \fBCMAKE_REQUIRED_QUIET\fP execute quietly without messages. .UNINDENT .SS CheckFortranCompilerFlag .sp Check whether the Fortran compiler supports a given flag. .INDENT 0.0 .TP .B check_fortran_compiler_flag .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_fortran_compiler_flag( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the \fB\fP is accepted by the compiler without a diagnostic. Stores the result in an internal cache entry named \fB\fP\&. .UNINDENT .sp This command temporarily sets the \fBCMAKE_REQUIRED_DEFINITIONS\fP variable and calls the \fBcheck_fortran_source_compiles\fP macro from the \fBCheckFortranSourceCompiles\fP module. See documentation of that module for a listing of variables that can otherwise modify the build. .sp A positive result from this check indicates only that the compiler did not issue a diagnostic message when given the flag. Whether the flag has any effect or even a specific one is beyond the scope of this module. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Since the \fBtry_compile()\fP command forwards flags from variables like \fBCMAKE_Fortran_FLAGS\fP, unknown flags in such variables may cause a false negative for this check. .UNINDENT .UNINDENT .SS CheckFortranFunctionExists .sp Check if a Fortran function exists. .INDENT 0.0 .TP .B CHECK_FORTRAN_FUNCTION_EXISTS .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_FORTRAN_FUNCTION_EXISTS( ) .ft P .fi .UNINDENT .UNINDENT .sp where .INDENT 7.0 .TP .B \fB\fP the name of the Fortran function .TP .B \fB\fP variable to store the result; will be created as an internal cache variable. .UNINDENT .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_compile()\fP for further details). .UNINDENT .SS CheckFortranSourceCompiles .sp Check if given Fortran source compiles and links into an executable. .INDENT 0.0 .TP .B check_fortran_source_compiles .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_fortran_source_compiles( [FAIL_REGEX ...] [SRC_EXT ] ) .ft P .fi .UNINDENT .UNINDENT .sp Checks that the source supplied in \fB\fP can be compiled as a Fortran source file and linked as an executable. The \fB\fP must be a Fortran program containing at least an \fBend\fP statement\-\-for example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_fortran_source_compiles("character :: b; error stop b; end" F2018ESTOPOK SRC_EXT F90) .ft P .fi .UNINDENT .UNINDENT .sp This command can help avoid costly build processes when a compiler lacks support for a necessary feature, or a particular vendor library is not compatible with the Fortran compiler version being used. This generate\-time check may advise the user of such before the main build process. See also the \fBcheck_fortran_source_runs()\fP command to actually run the compiled code. .sp The result will be stored in the internal cache variable \fB\fP, with a boolean true value for success and boolean false for failure. .sp If \fBFAIL_REGEX\fP is provided, then failure is determined by checking if anything in the output matches any of the specified regular expressions. .sp By default, the test source file will be given a \fB\&.F\fP file extension. The \fBSRC_EXT\fP option can be used to override this with \fB\&.\fP instead\-\- \fB\&.F90\fP is a typical choice. .sp The underlying check is performed by the \fBtry_compile()\fP command. The compile and link commands can be influenced by setting any of the following variables prior to calling \fBcheck_fortran_source_compiles()\fP: .INDENT 7.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP Additional flags to pass to the compiler. Note that the contents of \fBCMAKE_Fortran_FLAGS\fP and its associated configuration\-specific variable are automatically added to the compiler command before the contents of \fBCMAKE_REQUIRED_FLAGS\fP\&. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP A \fI;\-list\fP of compiler definitions of the form \fB\-DFOO\fP or \fB\-DFOO=bar\fP\&. A definition for the name specified by \fB\fP will also be added automatically. .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP A \fI;\-list\fP of header search paths to pass to the compiler. These will be the only header search paths used by \fBtry_compile()\fP, i.e. the contents of the \fBINCLUDE_DIRECTORIES\fP directory property will be ignored. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_compile()\fP for further details). .TP .B \fBCMAKE_REQUIRED_QUIET\fP If this variable evaluates to a boolean true value, all status messages associated with the check will be suppressed. .UNINDENT .sp The check is only performed once, with the result cached in the variable named by \fB\fP\&. Every subsequent CMake run will re\-use this cached value rather than performing the check again, even if the \fB\fP changes. In order to force the check to be re\-evaluated, the variable named by \fB\fP must be manually removed from the cache. .UNINDENT .SS CheckFortranSourceRuns .sp Check if given Fortran source compiles and links into an executable and can subsequently be run. .INDENT 0.0 .TP .B check_fortran_source_runs .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_fortran_source_runs( [SRC_EXT ]) .ft P .fi .UNINDENT .UNINDENT .sp Check that the source supplied in \fB\fP can be compiled as a Fortran source file, linked as an executable and then run. The \fB\fP must be a Fortran program containing at least an \fBend\fP statement\-\-for example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_fortran_source_runs("real :: x[*]; call co_sum(x); end" F2018coarrayOK) .ft P .fi .UNINDENT .UNINDENT .sp This command can help avoid costly build processes when a compiler lacks support for a necessary feature, or a particular vendor library is not compatible with the Fortran compiler version being used. Some of these failures only occur at runtime instead of linktime, and a trivial runtime example can catch the issue before the main build process. .sp If the \fB\fP could be built and run successfully, the internal cache variable specified by \fB\fP will be set to 1, otherwise it will be set to an value that evaluates to boolean false (e.g. an empty string or an error message). .sp By default, the test source file will be given a \fB\&.F90\fP file extension. The \fBSRC_EXT\fP option can be used to override this with \fB\&.\fP instead. .sp The underlying check is performed by the \fBtry_run()\fP command. The compile and link commands can be influenced by setting any of the following variables prior to calling \fBcheck_fortran_source_runs()\fP: .INDENT 7.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP Additional flags to pass to the compiler. Note that the contents of \fBCMAKE_Fortran_FLAGS\fP and its associated configuration\-specific variable are automatically added to the compiler command before the contents of \fBCMAKE_REQUIRED_FLAGS\fP\&. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP A \fI;\-list\fP of compiler definitions of the form \fB\-DFOO\fP or \fB\-DFOO=bar\fP\&. A definition for the name specified by \fB\fP will also be added automatically. .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP A \fI;\-list\fP of header search paths to pass to the compiler. These will be the only header search paths used by \fBtry_run()\fP, i.e. the contents of the \fBINCLUDE_DIRECTORIES\fP directory property will be ignored. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP A \fI;\-list\fP of options to add to the link command (see \fBtry_run()\fP for further details). .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP A \fI;\-list\fP of libraries to add to the link command. These can be the name of system libraries or they can be \fIImported Targets\fP (see \fBtry_run()\fP for further details). .TP .B \fBCMAKE_REQUIRED_QUIET\fP If this variable evaluates to a boolean true value, all status messages associated with the check will be suppressed. .UNINDENT .sp The check is only performed once, with the result cached in the variable named by \fB\fP\&. Every subsequent CMake run will re\-use this cached value rather than performing the check again, even if the \fB\fP changes. In order to force the check to be re\-evaluated, the variable named by \fB\fP must be manually removed from the cache. .UNINDENT .SS CheckFunctionExists .sp Check if a C function can be linked .INDENT 0.0 .TP .B check_function_exists .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_function_exists( ) .ft P .fi .UNINDENT .UNINDENT .sp Checks that the \fB\fP is provided by libraries on the system and store the result in a \fB\fP, which will be created as an internal cache variable. .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP string of compile command line flags. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP a \fI;\-list\fP of macros to define (\-DFOO=bar). .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP a \fI;\-list\fP of header search paths to pass to the compiler. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP a \fI;\-list\fP of options to add to the link command. .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP a \fI;\-list\fP of libraries to add to the link command. See policy \fBCMP0075\fP\&. .TP .B \fBCMAKE_REQUIRED_QUIET\fP execute quietly without messages. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Prefer using \fBCheckSymbolExists\fP instead of this module, for the following reasons: .INDENT 0.0 .IP \(bu 2 \fBcheck_function_exists()\fP can\(aqt detect functions that are inlined in headers or specified as a macro. .IP \(bu 2 \fBcheck_function_exists()\fP can\(aqt detect anything in the 32\-bit versions of the Win32 API, because of a mismatch in calling conventions. .IP \(bu 2 \fBcheck_function_exists()\fP only verifies linking, it does not verify that the function is declared in system headers. .UNINDENT .UNINDENT .UNINDENT .SS CheckIPOSupported .sp Check whether the compiler supports an interprocedural optimization (IPO/LTO). Use this before enabling the \fBINTERPROCEDURAL_OPTIMIZATION\fP target property. .INDENT 0.0 .TP .B check_ipo_supported .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_ipo_supported([RESULT ] [OUTPUT ] [LANGUAGES ...]) .ft P .fi .UNINDENT .UNINDENT .sp Options are: .INDENT 7.0 .TP .B \fBRESULT \fP Set \fB\fP variable to \fBYES\fP if IPO is supported by the compiler and \fBNO\fP otherwise. If this option is not given then the command will issue a fatal error if IPO is not supported. .TP .B \fBOUTPUT \fP Set \fB\fP variable with details about any error. .TP .B \fBLANGUAGES ...\fP Specify languages whose compilers to check. Languages \fBC\fP, \fBCXX\fP, and \fBFortran\fP are supported. .UNINDENT .UNINDENT .sp It makes no sense to use this module when \fBCMP0069\fP is set to \fBOLD\fP so module will return error in this case. See policy \fBCMP0069\fP for details. .SS Examples .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C check_ipo_supported() # fatal error if IPO is not supported set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Optional IPO. Do not use IPO if it\(aqs not supported by compiler. check_ipo_supported(RESULT result OUTPUT output) if(result) set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) else() message(WARNING "IPO is not supported: ${output}") endif() .ft P .fi .UNINDENT .UNINDENT .SS CheckIncludeFileCXX .sp Provides a macro to check if a header file can be included in \fBCXX\fP\&. .INDENT 0.0 .TP .B CHECK_INCLUDE_FILE_CXX .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_INCLUDE_FILE_CXX( []) .ft P .fi .UNINDENT .UNINDENT .sp Check if the given \fB\fP file may be included in a \fBCXX\fP source file and store the result in an internal cache entry named \fB\fP\&. The optional third argument may be used to add compilation flags to the check (or use \fBCMAKE_REQUIRED_FLAGS\fP below). .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP string of compile command line flags. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP a \fI;\-list\fP of macros to define (\-DFOO=bar). .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP a \fI;\-list\fP of header search paths to pass to the compiler. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP a \fI;\-list\fP of options to add to the link command. .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP a \fI;\-list\fP of libraries to add to the link command. See policy \fBCMP0075\fP\&. .TP .B \fBCMAKE_REQUIRED_QUIET\fP execute quietly without messages. .UNINDENT .sp See modules \fBCheckIncludeFile\fP and \fBCheckIncludeFiles\fP to check for one or more \fBC\fP headers. .SS CheckIncludeFile .sp Provides a macro to check if a header file can be included in \fBC\fP\&. .INDENT 0.0 .TP .B CHECK_INCLUDE_FILE .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_INCLUDE_FILE( []) .ft P .fi .UNINDENT .UNINDENT .sp Check if the given \fB\fP file may be included in a \fBC\fP source file and store the result in an internal cache entry named \fB\fP\&. The optional third argument may be used to add compilation flags to the check (or use \fBCMAKE_REQUIRED_FLAGS\fP below). .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP string of compile command line flags. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP a \fI;\-list\fP of macros to define (\-DFOO=bar). .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP a \fI;\-list\fP of header search paths to pass to the compiler. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP a \fI;\-list\fP of options to add to the link command. .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP a \fI;\-list\fP of libraries to add to the link command. See policy \fBCMP0075\fP\&. .TP .B \fBCMAKE_REQUIRED_QUIET\fP execute quietly without messages. .UNINDENT .sp See the \fBCheckIncludeFiles\fP module to check for multiple headers at once. See the \fBCheckIncludeFileCXX\fP module to check for headers using the \fBCXX\fP language. .SS CheckIncludeFiles .sp Provides a macro to check if a list of one or more header files can be included together. .INDENT 0.0 .TP .B CHECK_INCLUDE_FILES .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_INCLUDE_FILES("" [LANGUAGE ]) .ft P .fi .UNINDENT .UNINDENT .sp Check if the given \fB\fP list may be included together in a source file and store the result in an internal cache entry named \fB\fP\&. Specify the \fB\fP argument as a \fI;\-list\fP of header file names. .sp If \fBLANGUAGE\fP is set, the specified compiler will be used to perform the check. Acceptable values are \fBC\fP and \fBCXX\fP\&. If not set, the C compiler will be used if enabled. If the C compiler is not enabled, the C++ compiler will be used if enabled. .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP string of compile command line flags. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP a \fI;\-list\fP of macros to define (\-DFOO=bar). .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP a \fI;\-list\fP of header search paths to pass to the compiler. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP a \fI;\-list\fP of options to add to the link command. .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP a \fI;\-list\fP of libraries to add to the link command. See policy \fBCMP0075\fP\&. .TP .B \fBCMAKE_REQUIRED_QUIET\fP execute quietly without messages. .UNINDENT .sp See modules \fBCheckIncludeFile\fP and \fBCheckIncludeFileCXX\fP to check for a single header file in \fBC\fP or \fBCXX\fP languages. .SS CheckLanguage .sp Check if a language can be enabled .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C check_language() .ft P .fi .UNINDENT .UNINDENT .sp where \fB\fP is a language that may be passed to \fBenable_language()\fP such as \fBFortran\fP\&. If \fBCMAKE__COMPILER\fP is already defined the check does nothing. Otherwise it tries enabling the language in a test project. The result is cached in \fBCMAKE__COMPILER\fP as the compiler that was found, or \fBNOTFOUND\fP if the language cannot be enabled. For CUDA which can have an explicit host compiler, the cache \fBCMAKE_CUDA_HOST_COMPILER\fP variable will be set if it was required for compilation. .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C check_language(Fortran) if(CMAKE_Fortran_COMPILER) enable_language(Fortran) else() message(STATUS "No Fortran support") endif() .ft P .fi .UNINDENT .UNINDENT .SS CheckLibraryExists .sp Check if the function exists. .INDENT 0.0 .TP .B CHECK_LIBRARY_EXISTS .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_LIBRARY_EXISTS(LIBRARY FUNCTION LOCATION VARIABLE) .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C LIBRARY \- the name of the library you are looking for FUNCTION \- the name of the function LOCATION \- location where the library should be found VARIABLE \- variable to store the result Will be created as an internal cache variable. .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_REQUIRED_FLAGS = string of compile command line flags CMAKE_REQUIRED_DEFINITIONS = list of macros to define (\-DFOO=bar) CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command CMAKE_REQUIRED_LIBRARIES = list of libraries to link CMAKE_REQUIRED_QUIET = execute quietly without messages .ft P .fi .UNINDENT .UNINDENT .SS CheckPIESupported .sp Check whether the linker supports Position Independent Code (PIE) or No Position Independent Code (NO_PIE) for executables. Use this to ensure that the \fBPOSITION_INDEPENDENT_CODE\fP target property for executables will be honored at link time. .INDENT 0.0 .TP .B check_pie_supported .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_pie_supported([OUTPUT_VARIABLE ] [LANGUAGES ...]) .ft P .fi .UNINDENT .UNINDENT .sp Options are: .INDENT 7.0 .TP .B \fBOUTPUT_VARIABLE \fP Set \fB\fP variable with details about any error. .TP .B \fBLANGUAGES ...\fP Check the linkers used for each of the specified languages. Supported languages are \fBC\fP, \fBCXX\fP, and \fBFortran\fP\&. .UNINDENT .UNINDENT .sp It makes no sense to use this module when \fBCMP0083\fP is set to \fBOLD\fP, so the command will return an error in this case. See policy \fBCMP0083\fP for details. .SS Variables .sp For each language checked, two boolean cache variables are defined. .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .TP .B \fBCMAKE__LINK_PIE_SUPPORTED\fP Set to \fBYES\fP if \fBPIE\fP is supported by the linker and \fBNO\fP otherwise. .TP .B \fBCMAKE__LINK_NO_PIE_SUPPORTED\fP Set to \fBYES\fP if \fBNO_PIE\fP is supported by the linker and \fBNO\fP otherwise. .UNINDENT .UNINDENT .UNINDENT .SS Examples .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C check_pie_supported() set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE) .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Retrieve any error message. check_pie_supported(OUTPUT_VARIABLE output LANGUAGES C) set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE) if(NOT CMAKE_C_LINK_PIE_SUPPORTED) message(WARNING "PIE is not supported at link time: ${output}.\en" "PIE link options will not be passed to linker.") endif() .ft P .fi .UNINDENT .UNINDENT .SS CheckPrototypeDefinition .sp Check if the prototype we expect is correct. .INDENT 0.0 .TP .B check_prototype_definition .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C FUNCTION \- The name of the function (used to check if prototype exists) PROTOTYPE\- The prototype to check. RETURN \- The return value of the function. HEADER \- The header files required. VARIABLE \- The variable to store the result. Will be created as an internal cache variable. .ft P .fi .UNINDENT .UNINDENT .sp Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_prototype_definition(getpwent_r "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" "NULL" "unistd.h;pwd.h" SOLARIS_GETPWENT_R) .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp The following variables may be set before calling this function to modify the way the check is run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_REQUIRED_FLAGS = string of compile command line flags CMAKE_REQUIRED_DEFINITIONS = list of macros to define (\-DFOO=bar) CMAKE_REQUIRED_INCLUDES = list of include directories CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command CMAKE_REQUIRED_LIBRARIES = list of libraries to link CMAKE_REQUIRED_QUIET = execute quietly without messages .ft P .fi .UNINDENT .UNINDENT .SS CheckStructHasMember .sp Check if the given struct or class has the specified member variable .INDENT 0.0 .TP .B CHECK_STRUCT_HAS_MEMBER .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_STRUCT_HAS_MEMBER(
[LANGUAGE ]) .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C \- the name of the struct or class you are interested in \- the member which existence you want to check
\- the header(s) where the prototype should be declared \- variable to store the result \- the compiler to use (C or CXX) .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_REQUIRED_FLAGS = string of compile command line flags CMAKE_REQUIRED_DEFINITIONS = list of macros to define (\-DFOO=bar) CMAKE_REQUIRED_INCLUDES = list of include directories CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command CMAKE_REQUIRED_LIBRARIES = list of libraries to link CMAKE_REQUIRED_QUIET = execute quietly without messages .ft P .fi .UNINDENT .UNINDENT .sp Example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h HAVE_TIMEVAL_TV_SEC LANGUAGE C) .ft P .fi .UNINDENT .UNINDENT .SS CheckSymbolExists .sp Provides a macro to check if a symbol exists as a function, variable, or macro in \fBC\fP\&. .INDENT 0.0 .TP .B check_symbol_exists .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C check_symbol_exists( ) .ft P .fi .UNINDENT .UNINDENT .sp Check that the \fB\fP is available after including given header \fB\fP and store the result in a \fB\fP\&. Specify the list of files in one argument as a semicolon\-separated list. \fB\fP will be created as an internal cache variable. .UNINDENT .sp If the header files define the symbol as a macro it is considered available and assumed to work. If the header files declare the symbol as a function or variable then the symbol must also be available for linking (so intrinsics may not be detected). If the symbol is a type, enum value, or intrinsic it will not be recognized (consider using \fBCheckTypeSize\fP or \fBCheckCSourceCompiles\fP). If the check needs to be done in C++, consider using \fBCheckCXXSymbolExists\fP instead. .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .TP .B \fBCMAKE_REQUIRED_FLAGS\fP string of compile command line flags. .TP .B \fBCMAKE_REQUIRED_DEFINITIONS\fP a \fI;\-list\fP of macros to define (\-DFOO=bar). .TP .B \fBCMAKE_REQUIRED_INCLUDES\fP a \fI;\-list\fP of header search paths to pass to the compiler. .TP .B \fBCMAKE_REQUIRED_LINK_OPTIONS\fP a \fI;\-list\fP of options to add to the link command. .TP .B \fBCMAKE_REQUIRED_LIBRARIES\fP a \fI;\-list\fP of libraries to add to the link command. See policy \fBCMP0075\fP\&. .TP .B \fBCMAKE_REQUIRED_QUIET\fP execute quietly without messages. .UNINDENT .SS CheckTypeSize .sp Check sizeof a type .INDENT 0.0 .TP .B CHECK_TYPE_SIZE .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY] [LANGUAGE ]) .ft P .fi .UNINDENT .UNINDENT .sp Check if the type exists and determine its size. On return, \fBHAVE_${VARIABLE}\fP holds the existence of the type, and \fB${VARIABLE}\fP holds one of the following: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C = type has non\-zero size "0" = type has arch\-dependent size (see below) "" = type does not exist .ft P .fi .UNINDENT .UNINDENT .sp Both \fBHAVE_${VARIABLE}\fP and \fB${VARIABLE}\fP will be created as internal cache variables. .sp Furthermore, the variable \fB${VARIABLE}_CODE\fP holds C preprocessor code to define the macro \fB${VARIABLE}\fP to the size of the type, or leave the macro undefined if the type does not exist. .sp The variable \fB${VARIABLE}\fP may be \fB0\fP when \fBCMAKE_OSX_ARCHITECTURES\fP has multiple architectures for building OS X universal binaries. This indicates that the type size varies across architectures. In this case \fB${VARIABLE}_CODE\fP contains C preprocessor tests mapping from each architecture macro to the corresponding type size. The list of architecture macros is stored in \fB${VARIABLE}_KEYS\fP, and the value for each key is stored in \fB${VARIABLE}\-${KEY}\fP\&. .sp If the \fBBUILTIN_TYPES_ONLY\fP option is not given, the macro checks for headers \fB\fP, \fB\fP, and \fB\fP, and saves results in \fBHAVE_SYS_TYPES_H\fP, \fBHAVE_STDINT_H\fP, and \fBHAVE_STDDEF_H\fP\&. The type size check automatically includes the available headers, thus supporting checks of types defined in the headers. .sp If \fBLANGUAGE\fP is set, the specified compiler will be used to perform the check. Acceptable values are \fBC\fP and \fBCXX\fP\&. .UNINDENT .sp Despite the name of the macro you may use it to check the size of more complex expressions, too. To check e.g. for the size of a struct member you can do something like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C check_type_size("((struct something*)0)\->member" SIZEOF_MEMBER) .ft P .fi .UNINDENT .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_REQUIRED_FLAGS = string of compile command line flags CMAKE_REQUIRED_DEFINITIONS = list of macros to define (\-DFOO=bar) CMAKE_REQUIRED_INCLUDES = list of include directories CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command CMAKE_REQUIRED_LIBRARIES = list of libraries to link CMAKE_REQUIRED_QUIET = execute quietly without messages CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include .ft P .fi .UNINDENT .UNINDENT .SS CheckVariableExists .sp Check if the variable exists. .INDENT 0.0 .TP .B CHECK_VARIABLE_EXISTS .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C CHECK_VARIABLE_EXISTS(VAR VARIABLE) .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C VAR \- the name of the variable VARIABLE \- variable to store the result Will be created as an internal cache variable. .ft P .fi .UNINDENT .UNINDENT .sp This macro is only for \fBC\fP variables. .UNINDENT .sp The following variables may be set before calling this macro to modify the way the check is run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_REQUIRED_FLAGS = string of compile command line flags CMAKE_REQUIRED_DEFINITIONS = list of macros to define (\-DFOO=bar) CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command CMAKE_REQUIRED_LIBRARIES = list of libraries to link CMAKE_REQUIRED_QUIET = execute quietly without messages .ft P .fi .UNINDENT .UNINDENT .SS CMakeAddFortranSubdirectory .sp Add a fortran\-only subdirectory, find a fortran compiler, and build. .sp The \fBcmake_add_fortran_subdirectory\fP function adds a subdirectory to a project that contains a fortran\-only subproject. The module will check the current compiler and see if it can support fortran. If no fortran compiler is found and the compiler is MSVC, then this module will find the MinGW gfortran. It will then use an external project to build with the MinGW tools. It will also create imported targets for the libraries created. This will only work if the fortran code is built into a dll, so \fBBUILD_SHARED_LIBS\fP is turned on in the project. In addition the \fBCMAKE_GNUtoMS\fP option is set to on, so that Microsoft \fB\&.lib\fP files are created. Usage is as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake_add_fortran_subdirectory( # name of subdirectory PROJECT # project name in subdir top CMakeLists.txt ARCHIVE_DIR # dir where project places .lib files RUNTIME_DIR # dir where project places .dll files LIBRARIES ... # names of library targets to import LINK_LIBRARIES # link interface libraries for LIBRARIES [LINK_LIBS ...]... CMAKE_COMMAND_LINE ... # extra command line flags to pass to cmake NO_EXTERNAL_INSTALL # skip installation of external project ) .ft P .fi .UNINDENT .UNINDENT .sp Relative paths in \fBARCHIVE_DIR\fP and \fBRUNTIME_DIR\fP are interpreted with respect to the build directory corresponding to the source directory in which the function is invoked. .sp Limitations: .sp \fBNO_EXTERNAL_INSTALL\fP is required for forward compatibility with a future version that supports installation of the external project binaries during \fBmake install\fP\&. .SS CMakeBackwardCompatibilityCXX .sp define a bunch of backwards compatibility variables .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_ANSI_CXXFLAGS \- flag for ansi c++ CMAKE_HAS_ANSI_STRING_STREAM \- has include(TestForANSIStreamHeaders) include(CheckIncludeFileCXX) include(TestForSTDNamespace) include(TestForANSIForScope) .ft P .fi .UNINDENT .UNINDENT .SS CMakeDependentOption .sp Macro to provide an option dependent on other options. .sp This macro presents an option to the user only if a set of other conditions are true. When the option is not presented a default value is used, but any value set by the user is preserved for when the option is presented again. Example invocation: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON "USE_BAR;NOT USE_ZOT" OFF) .ft P .fi .UNINDENT .UNINDENT .sp If USE_BAR is true and USE_ZOT is false, this provides an option called USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to OFF. If the status of USE_BAR or USE_ZOT ever changes, any value for the USE_FOO option is saved so that when the option is re\-enabled it retains its old value. .SS CMakeFindDependencyMacro .INDENT 0.0 .TP .B find_dependency The \fBfind_dependency()\fP macro wraps a \fBfind_package()\fP call for a package dependency: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C find_dependency( [...]) .ft P .fi .UNINDENT .UNINDENT .sp It is designed to be used in a \fIPackage Configuration File\fP (\fBConfig.cmake\fP). \fBfind_dependency\fP forwards the correct parameters for \fBQUIET\fP and \fBREQUIRED\fP which were passed to the original \fBfind_package()\fP call. Any additional arguments specified are forwarded to \fBfind_package()\fP\&. .sp If the dependency could not be found it sets an informative diagnostic message and calls \fBreturn()\fP to end processing of the calling package configuration file and return to the \fBfind_package()\fP command that loaded it. .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 The call to \fBreturn()\fP makes this macro unsuitable to call from \fIFind Modules\fP\&. .UNINDENT .UNINDENT .UNINDENT .SS CMakeFindFrameworks .sp helper module to find OSX frameworks .sp This module reads hints about search locations from variables: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS \- Extra directories .ft P .fi .UNINDENT .UNINDENT .SS CMakeFindPackageMode .sp This file is executed by cmake when invoked with \-\-find\-package. It expects that the following variables are set using \-D: .INDENT 0.0 .TP .B \fBNAME\fP name of the package .TP .B \fBCOMPILER_ID\fP the CMake compiler ID for which the result is, i.e. GNU/Intel/Clang/MSVC, etc. .TP .B \fBLANGUAGE\fP language for which the result will be used, i.e. C/CXX/Fortran/ASM .TP .B \fBMODE\fP .INDENT 7.0 .TP .B \fBEXIST\fP only check for existence of the given package .TP .B \fBCOMPILE\fP print the flags needed for compiling an object file which uses the given package .TP .B \fBLINK\fP print the flags needed for linking when using the given package .UNINDENT .TP .B \fBQUIET\fP if TRUE, don\(aqt print anything .UNINDENT .SS CMakeGraphVizOptions .sp The builtin graphviz support of CMake. .SS Variables specific to the graphviz support .sp CMake can generate \fI\%graphviz\fP files, showing the dependencies between the targets in a project and also external libraries which are linked against. When CMake is run with the \fB\-\-graphviz=foo.dot\fP option, it will produce: .INDENT 0.0 .IP \(bu 2 a \fBfoo.dot\fP file showing all dependencies in the project .IP \(bu 2 a \fBfoo.dot.\fP file for each target, file showing on which other targets the respective target depends .IP \(bu 2 a \fBfoo.dot..dependers\fP file, showing which other targets depend on the respective target .UNINDENT .sp The different dependency types \fBPUBLIC\fP, \fBPRIVATE\fP and \fBINTERFACE\fP are represented as solid, dashed and dotted edges. .sp This can result in huge graphs. Using the file \fBCMakeGraphVizOptions.cmake\fP the look and content of the generated graphs can be influenced. This file is searched first in \fBCMAKE_BINARY_DIR\fP and then in \fBCMAKE_SOURCE_DIR\fP\&. If found, it is read and the variables set in it are used to adjust options for the generated graphviz files. .INDENT 0.0 .TP .B GRAPHVIZ_GRAPH_TYPE The graph type. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : "digraph" .UNINDENT .sp Valid graph types are: .INDENT 7.0 .IP \(bu 2 "graph" : Nodes are joined with lines .IP \(bu 2 "digraph" : Nodes are joined with arrows showing direction .IP \(bu 2 "strict graph" : Like "graph" but max one line between each node .IP \(bu 2 "strict digraph" : Like "graph" but max one line between each node in each direction .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_GRAPH_NAME The graph name. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : "GG" .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_GRAPH_HEADER The header written at the top of the graphviz file. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : "node [n fontsize = "12"];" .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_NODE_PREFIX The prefix for each node in the graphviz file. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : "node" .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_EXECUTABLES Set this to FALSE to exclude executables from the generated graphs. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_STATIC_LIBS Set this to FALSE to exclude static libraries from the generated graphs. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_SHARED_LIBS Set this to FALSE to exclude shared libraries from the generated graphs. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_MODULE_LIBS Set this to FALSE to exclude module libraries from the generated graphs. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_EXTERNAL_LIBS Set this to FALSE to exclude external libraries from the generated graphs. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_IGNORE_TARGETS A list of regular expressions for ignoring targets. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : empty .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_GENERATE_PER_TARGET Set this to FALSE to exclude per target graphs \fBfoo.dot.\fP\&. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .INDENT 0.0 .TP .B GRAPHVIZ_GENERATE_DEPENDERS Set this to FALSE to exclude depender graphs \fBfoo.dot..dependers\fP\&. .INDENT 7.0 .IP \(bu 2 Mandatory : NO .IP \(bu 2 Default : TRUE .UNINDENT .UNINDENT .SS CMakePackageConfigHelpers .sp Helpers functions for creating config files that can be included by other projects to find and use a package. .sp Adds the \fBconfigure_package_config_file()\fP and \fBwrite_basic_package_version_file()\fP commands. .SS Generating a Package Configuration File .INDENT 0.0 .TP .B configure_package_config_file Create a config file for a project: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C configure_package_config_file( INSTALL_DESTINATION [PATH_VARS ... ] [NO_SET_AND_CHECK_MACRO] [NO_CHECK_REQUIRED_COMPONENTS_MACRO] [INSTALL_PREFIX ] ) .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp \fBconfigure_package_config_file()\fP should be used instead of the plain \fBconfigure_file()\fP command when creating the \fBConfig.cmake\fP or \fB\-config.cmake\fP file for installing a project or library. It helps making the resulting package relocatable by avoiding hardcoded paths in the installed \fBConfig.cmake\fP file. .sp In a \fBFooConfig.cmake\fP file there may be code like this to make the install destinations know to the using project: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C set(FOO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" ) set(FOO_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@RELATIVE_DATA_INSTALL_DIR@" ) set(FOO_ICONS_DIR "@CMAKE_INSTALL_PREFIX@/share/icons" ) #...logic to determine installedPrefix from the own location... set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" ) .ft P .fi .UNINDENT .UNINDENT .sp All 4 options shown above are not sufficient, since the first 3 hardcode the absolute directory locations, and the 4th case works only if the logic to determine the \fBinstalledPrefix\fP is correct, and if \fBCONFIG_INSTALL_DIR\fP contains a relative path, which in general cannot be guaranteed. This has the effect that the resulting \fBFooConfig.cmake\fP file would work poorly under Windows and OSX, where users are used to choose the install location of a binary package at install time, independent from how \fBCMAKE_INSTALL_PREFIX\fP was set at build/cmake time. .sp Using \fBconfigure_package_config_file\fP helps. If used correctly, it makes the resulting \fBFooConfig.cmake\fP file relocatable. Usage: .INDENT 0.0 .IP 1. 3 write a \fBFooConfig.cmake.in\fP file as you are used to .IP 2. 3 insert a line containing only the string \fB@PACKAGE_INIT@\fP .IP 3. 3 instead of \fBset(FOO_DIR "@SOME_INSTALL_DIR@")\fP, use \fBset(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")\fP (this must be after the \fB@PACKAGE_INIT@\fP line) .IP 4. 3 instead of using the normal \fBconfigure_file()\fP, use \fBconfigure_package_config_file()\fP .UNINDENT .sp The \fB\fP and \fB\fP arguments are the input and output file, the same way as in \fBconfigure_file()\fP\&. .sp The \fB\fP given to \fBINSTALL_DESTINATION\fP must be the destination where the \fBFooConfig.cmake\fP file will be installed to. This path can either be absolute, or relative to the \fBINSTALL_PREFIX\fP path. .sp The variables \fB\fP to \fB\fP given as \fBPATH_VARS\fP are the variables which contain install destinations. For each of them the macro will create a helper variable \fBPACKAGE_\fP\&. These helper variables must be used in the \fBFooConfig.cmake.in\fP file for setting the installed location. They are calculated by \fBconfigure_package_config_file\fP so that they are always relative to the installed location of the package. This works both for relative and also for absolute locations. For absolute locations it works only if the absolute location is a subdirectory of \fBINSTALL_PREFIX\fP\&. .sp If the \fBINSTALL_PREFIX\fP argument is passed, this is used as base path to calculate all the relative paths. The \fB\fP argument must be an absolute path. If this argument is not passed, the \fBCMAKE_INSTALL_PREFIX\fP variable will be used instead. The default value is good when generating a FooConfig.cmake file to use your package from the install tree. When generating a FooConfig.cmake file to use your package from the build tree this option should be used. .sp By default \fBconfigure_package_config_file\fP also generates two helper macros, \fBset_and_check()\fP and \fBcheck_required_components()\fP into the \fBFooConfig.cmake\fP file. .sp \fBset_and_check()\fP should be used instead of the normal \fBset()\fP command for setting directories and file locations. Additionally to setting the variable it also checks that the referenced file or directory actually exists and fails with a \fBFATAL_ERROR\fP otherwise. This makes sure that the created \fBFooConfig.cmake\fP file does not contain wrong references. When using the \fBNO_SET_AND_CHECK_MACRO\fP, this macro is not generated into the \fBFooConfig.cmake\fP file. .sp \fBcheck_required_components()\fP should be called at the end of the \fBFooConfig.cmake\fP file. This macro checks whether all requested, non\-optional components have been found, and if this is not the case, sets the \fBFoo_FOUND\fP variable to \fBFALSE\fP, so that the package is considered to be not found. It does that by testing the \fBFoo__FOUND\fP variables for all requested required components. This macro should be called even if the package doesn\(aqt provide any components to make sure users are not specifying components erroneously. When using the \fBNO_CHECK_REQUIRED_COMPONENTS_MACRO\fP option, this macro is not generated into the \fBFooConfig.cmake\fP file. .sp For an example see below the documentation for \fBwrite_basic_package_version_file()\fP\&. .SS Generating a Package Version File .INDENT 0.0 .TP .B write_basic_package_version_file Create a version file for a project: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C write_basic_package_version_file( [VERSION ] COMPATIBILITY [ARCH_INDEPENDENT] ) .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Writes a file for use as \fBConfigVersion.cmake\fP file to \fB\fP\&. See the documentation of \fBfind_package()\fP for details on this. .sp \fB\fP is the output filename, it should be in the build tree. \fB\fP is the version number of the project to be installed. .sp If no \fBVERSION\fP is given, the \fBPROJECT_VERSION\fP variable is used. If this hasn\(aqt been set, it errors out. .sp The \fBCOMPATIBILITY\fP mode \fBAnyNewerVersion\fP means that the installed package version will be considered compatible if it is newer or exactly the same as the requested version. This mode should be used for packages which are fully backward compatible, also across major versions. If \fBSameMajorVersion\fP is used instead, then the behaviour differs from \fBAnyNewerVersion\fP in that the major version number must be the same as requested, e.g. version 2.0 will not be considered compatible if 1.0 is requested. This mode should be used for packages which guarantee backward compatibility within the same major version. If \fBSameMinorVersion\fP is used, the behaviour is the same as \fBSameMajorVersion\fP, but both major and minor version must be the same as requested, e.g version 0.2 will not be compatible if 0.1 is requested. If \fBExactVersion\fP is used, then the package is only considered compatible if the requested version matches exactly its own version number (not considering the tweak version). For example, version 1.2.3 of a package is only considered compatible to requested version 1.2.3. This mode is for packages without compatibility guarantees. If your project has more elaborated version matching rules, you will need to write your own custom \fBConfigVersion.cmake\fP file instead of using this macro. .sp If \fBARCH_INDEPENDENT\fP is given, the installed package version will be considered compatible even if it was built for a different architecture than the requested architecture. Otherwise, an architecture check will be performed, and the package will be considered compatible only if the architecture matches exactly. For example, if the package is built for a 32\-bit architecture, the package is only considered compatible if it is used on a 32\-bit architecture, unless \fBARCH_INDEPENDENT\fP is given, in which case the package is considered compatible on any architecture. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 \fBARCH_INDEPENDENT\fP is intended for header\-only libraries or similar packages with no binaries. .UNINDENT .UNINDENT .sp Internally, this macro executes \fBconfigure_file()\fP to create the resulting version file. Depending on the \fBCOMPATIBILITY\fP, the corresponding \fBBasicConfigVersion\-.cmake.in\fP file is used. Please note that these files are internal to CMake and you should not call \fBconfigure_file()\fP on them yourself, but they can be used as starting point to create more sophisticted custom \fBConfigVersion.cmake\fP files. .SS Example Generating Package Files .sp Example using both \fBconfigure_package_config_file()\fP and \fBwrite_basic_package_version_file()\fP: .sp \fBCMakeLists.txt\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C set(INCLUDE_INSTALL_DIR include/ ... CACHE ) set(LIB_INSTALL_DIR lib/ ... CACHE ) set(SYSCONFIG_INSTALL_DIR etc/foo/ ... CACHE ) #... include(CMakePackageConfigHelpers) configure_package_config_file(FooConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake VERSION 1.2.3 COMPATIBILITY SameMajorVersion ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake ) .ft P .fi .UNINDENT .UNINDENT .sp \fBFooConfig.cmake.in\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C set(FOO_VERSION x.y.z) \&... @PACKAGE_INIT@ \&... set_and_check(FOO_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") set_and_check(FOO_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@") check_required_components(Foo) .ft P .fi .UNINDENT .UNINDENT .SS CMakePrintHelpers .sp Convenience functions for printing properties and variables, useful e.g. for debugging. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake_print_properties([TARGETS target1 .. targetN] [SOURCES source1 .. sourceN] [DIRECTORIES dir1 .. dirN] [TESTS test1 .. testN] [CACHE_ENTRIES entry1 .. entryN] PROPERTIES prop1 .. propN ) .ft P .fi .UNINDENT .UNINDENT .sp This function prints the values of the properties of the given targets, source files, directories, tests or cache entries. Exactly one of the scope keywords must be used. Example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake_print_properties(TARGETS foo bar PROPERTIES LOCATION INTERFACE_INCLUDE_DIRS) .ft P .fi .UNINDENT .UNINDENT .sp This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for both targets foo and bar. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake_print_variables(var1 var2 .. varN) .ft P .fi .UNINDENT .UNINDENT .sp This function will print the name of each variable followed by its value. Example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION DOES_NOT_EXIST) .ft P .fi .UNINDENT .UNINDENT .sp Gives: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-\- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST="" .ft P .fi .UNINDENT .UNINDENT .SS CMakePrintSystemInformation .sp print system information .sp This file can be used for diagnostic purposes just include it in a project to see various internal CMake variables. .SS CMakePushCheckState .sp This module defines three macros: \fBCMAKE_PUSH_CHECK_STATE()\fP \fBCMAKE_POP_CHECK_STATE()\fP and \fBCMAKE_RESET_CHECK_STATE()\fP These macros can be used to save, restore and reset (i.e., clear contents) the state of the variables \fBCMAKE_REQUIRED_FLAGS\fP, \fBCMAKE_REQUIRED_DEFINITIONS\fP, \fBCMAKE_REQUIRED_LINK_OPTIONS\fP, \fBCMAKE_REQUIRED_LIBRARIES\fP, \fBCMAKE_REQUIRED_INCLUDES\fP and \fBCMAKE_EXTRA_INCLUDE_FILES\fP used by the various Check\-files coming with CMake, like e.g. \fBcheck_function_exists()\fP etc. The variable contents are pushed on a stack, pushing multiple times is supported. This is useful e.g. when executing such tests in a Find\-module, where they have to be set, but after the Find\-module has been executed they should have the same value as they had before. .sp \fBCMAKE_PUSH_CHECK_STATE()\fP macro receives optional argument \fBRESET\fP\&. Whether it\(aqs specified, \fBCMAKE_PUSH_CHECK_STATE()\fP will set all \fBCMAKE_REQUIRED_*\fP variables to empty values, same as \fBCMAKE_RESET_CHECK_STATE()\fP call will do. .sp Usage: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cmake_push_check_state(RESET) set(CMAKE_REQUIRED_DEFINITIONS \-DSOME_MORE_DEF) check_function_exists(...) cmake_reset_check_state() set(CMAKE_REQUIRED_DEFINITIONS \-DANOTHER_DEF) check_function_exists(...) cmake_pop_check_state() .ft P .fi .UNINDENT .UNINDENT .SS CMakeVerifyManifest .sp CMakeVerifyManifest.cmake .sp This script is used to verify that embedded manifests and side by side manifests for a project match. To run this script, cd to a directory and run the script with cmake \-P. On the command line you can pass in versions that are OK even if not found in the .manifest files. For example, cmake \-Dallow_versions=8.0.50608.0 \-PCmakeVerifyManifest.cmake could be used to allow an embedded manifest of 8.0.50608.0 to be used in a project even if that version was not found in the .manifest file. .SS CPackComponent .sp Build binary and source package installers .SS Variables concerning CPack Components .sp The CPackComponent module is the module which handles the component part of CPack. See CPack module for general information about CPack. .sp For certain kinds of binary installers (including the graphical installers on macOS and Windows), CPack generates installers that allow users to select individual application components to install. The contents of each of the components are identified by the COMPONENT argument of CMake\(aqs INSTALL command. These components can be annotated with user\-friendly names and descriptions, inter\-component dependencies, etc., and grouped in various ways to customize the resulting installer. See the cpack_add_* commands, described below, for more information about component\-specific installations. .sp Component\-specific installation allows users to select specific sets of components to install during the install process. Installation components are identified by the COMPONENT argument of CMake\(aqs INSTALL commands, and should be further described by the following CPack commands: .INDENT 0.0 .TP .B CPACK_COMPONENTS_ALL The list of component to install. .sp The default value of this variable is computed by CPack and contains all components defined by the project. The user may set it to only include the specified components. .sp Instead of specifying all the desired components, it is possible to obtain a list of all defined components and then remove the unwanted ones from the list. The \fBget_cmake_property()\fP command can be used to obtain the \fBCOMPONENTS\fP property, then the \fBlist(REMOVE_ITEM)\fP command can be used to remove the unwanted ones. For example, to use all defined components except \fBfoo\fP and \fBbar\fP: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) list(REMOVE_ITEM CPACK_COMPONENTS_ALL "foo" "bar") .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B CPACK__COMPONENT_INSTALL Enable/Disable component install for CPack generator . .sp Each CPack Generator (RPM, DEB, ARCHIVE, NSIS, DMG, etc...) has a legacy default behavior. e.g. RPM builds monolithic whereas NSIS builds component. One can change the default behavior by setting this variable to 0/1 or OFF/ON. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENTS_GROUPING Specify how components are grouped for multi\-package component\-aware CPack generators. .sp Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates several packages files when asked for component packaging. They group the component differently depending on the value of this variable: .INDENT 7.0 .IP \(bu 2 ONE_PER_GROUP (default): creates one package file per component group .IP \(bu 2 ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) components .IP \(bu 2 IGNORE : creates one package per component, i.e. IGNORE component group .UNINDENT .sp One can specify different grouping for different CPack generator by using a CPACK_PROJECT_CONFIG_FILE. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__DISPLAY_NAME The name to be displayed for a component. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__DESCRIPTION The description of a component. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__GROUP The group of a component. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__DEPENDS The dependencies (list of components) on which this component depends. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__HIDDEN True if this component is hidden from the user. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__REQUIRED True if this component is required. .UNINDENT .INDENT 0.0 .TP .B CPACK_COMPONENT__DISABLED True if this component is not selected to be installed by default. .UNINDENT .INDENT 0.0 .TP .B cpack_add_component .UNINDENT .sp Describes a CPack installation component named by the COMPONENT argument to a CMake INSTALL command. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cpack_add_component(compname [DISPLAY_NAME name] [DESCRIPTION description] [HIDDEN | REQUIRED | DISABLED ] [GROUP group] [DEPENDS comp1 comp2 ... ] [INSTALL_TYPES type1 type2 ... ] [DOWNLOADED] [ARCHIVE_FILE filename] [PLIST filename]) .ft P .fi .UNINDENT .UNINDENT .sp The cmake_add_component command describes an installation component, which the user can opt to install or remove as part of the graphical installation process. compname is the name of the component, as provided to the COMPONENT argument of one or more CMake INSTALL commands. .sp DISPLAY_NAME is the displayed name of the component, used in graphical installers to display the component name. This value can be any string. .sp DESCRIPTION is an extended description of the component, used in graphical installers to give the user additional information about the component. Descriptions can span multiple lines using \fB\en\fP as the line separator. Typically, these descriptions should be no more than a few lines long. .sp HIDDEN indicates that this component will be hidden in the graphical installer, so that the user cannot directly change whether it is installed or not. .sp REQUIRED indicates that this component is required, and therefore will always be installed. It will be visible in the graphical installer, but it cannot be unselected. (Typically, required components are shown greyed out). .sp DISABLED indicates that this component should be disabled (unselected) by default. The user is free to select this component for installation, unless it is also HIDDEN. .sp DEPENDS lists the components on which this component depends. If this component is selected, then each of the components listed must also be selected. The dependency information is encoded within the installer itself, so that users cannot install inconsistent sets of components. .sp GROUP names the component group of which this component is a part. If not provided, the component will be a standalone component, not part of any component group. Component groups are described with the cpack_add_component_group command, detailed below. .sp INSTALL_TYPES lists the installation types of which this component is a part. When one of these installations types is selected, this component will automatically be selected. Installation types are described with the cpack_add_install_type command, detailed below. .sp DOWNLOADED indicates that this component should be downloaded on\-the\-fly by the installer, rather than packaged in with the installer itself. For more information, see the cpack_configure_downloads command. .sp ARCHIVE_FILE provides a name for the archive file created by CPack to be used for downloaded components. If not supplied, CPack will create a file with some name based on CPACK_PACKAGE_FILE_NAME and the name of the component. See cpack_configure_downloads for more information. .sp PLIST gives a filename that is passed to pkgbuild with the \fB\-\-component\-plist\fP argument when using the productbuild generator. .INDENT 0.0 .TP .B cpack_add_component_group .UNINDENT .sp Describes a group of related CPack installation components. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cpack_add_component_group(groupname [DISPLAY_NAME name] [DESCRIPTION description] [PARENT_GROUP parent] [EXPANDED] [BOLD_TITLE]) .ft P .fi .UNINDENT .UNINDENT .sp The cpack_add_component_group describes a group of installation components, which will be placed together within the listing of options. Typically, component groups allow the user to select/deselect all of the components within a single group via a single group\-level option. Use component groups to reduce the complexity of installers with many options. groupname is an arbitrary name used to identify the group in the GROUP argument of the cpack_add_component command, which is used to place a component in a group. The name of the group must not conflict with the name of any component. .sp DISPLAY_NAME is the displayed name of the component group, used in graphical installers to display the component group name. This value can be any string. .sp DESCRIPTION is an extended description of the component group, used in graphical installers to give the user additional information about the components within that group. Descriptions can span multiple lines using \fB\en\fP as the line separator. Typically, these descriptions should be no more than a few lines long. .sp PARENT_GROUP, if supplied, names the parent group of this group. Parent groups are used to establish a hierarchy of groups, providing an arbitrary hierarchy of groups. .sp EXPANDED indicates that, by default, the group should show up as "expanded", so that the user immediately sees all of the components within the group. Otherwise, the group will initially show up as a single entry. .sp BOLD_TITLE indicates that the group title should appear in bold, to call the user\(aqs attention to the group. .INDENT 0.0 .TP .B cpack_add_install_type .UNINDENT .sp Add a new installation type containing a set of predefined component selections to the graphical installer. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cpack_add_install_type(typename [DISPLAY_NAME name]) .ft P .fi .UNINDENT .UNINDENT .sp The cpack_add_install_type command identifies a set of preselected components that represents a common use case for an application. For example, a "Developer" install type might include an application along with its header and library files, while an "End user" install type might just include the application\(aqs executable. Each component identifies itself with one or more install types via the INSTALL_TYPES argument to cpack_add_component. .sp DISPLAY_NAME is the displayed name of the install type, which will typically show up in a drop\-down box within a graphical installer. This value can be any string. .INDENT 0.0 .TP .B cpack_configure_downloads .UNINDENT .sp Configure CPack to download selected components on\-the\-fly as part of the installation process. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cpack_configure_downloads(site [UPLOAD_DIRECTORY dirname] [ALL] [ADD_REMOVE|NO_ADD_REMOVE]) .ft P .fi .UNINDENT .UNINDENT .sp The cpack_configure_downloads command configures installation\-time downloads of selected components. For each downloadable component, CPack will create an archive containing the contents of that component, which should be uploaded to the given site. When the user selects that component for installation, the installer will download and extract the component in place. This feature is useful for creating small installers that only download the requested components, saving bandwidth. Additionally, the installers are small enough that they will be installed as part of the normal installation process, and the "Change" button in Windows Add/Remove Programs control panel will allow one to add or remove parts of the application after the original installation. On Windows, the downloaded\-components functionality requires the ZipDLL plug\-in for NSIS, available at: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C http://nsis.sourceforge.net/ZipDLL_plug\-in .ft P .fi .UNINDENT .UNINDENT .sp On macOS, installers that download components on\-the\-fly can only be built and installed on system using macOS 10.5 or later. .sp The site argument is a URL where the archives for downloadable components will reside, e.g., \fI\%https://cmake.org/files/2.6.1/installer/\fP All of the archives produced by CPack should be uploaded to that location. .sp UPLOAD_DIRECTORY is the local directory where CPack will create the various archives for each of the components. The contents of this directory should be uploaded to a location accessible by the URL given in the site argument. If omitted, CPack will use the directory CPackUploads inside the CMake binary directory to store the generated archives. .sp The ALL flag indicates that all components be downloaded. Otherwise, only those components explicitly marked as DOWNLOADED or that have a specified ARCHIVE_FILE will be downloaded. Additionally, the ALL option implies ADD_REMOVE (unless NO_ADD_REMOVE is specified). .sp ADD_REMOVE indicates that CPack should install a copy of the installer that can be called from Windows\(aq Add/Remove Programs dialog (via the "Modify" button) to change the set of installed components. NO_ADD_REMOVE turns off this behavior. This option is ignored on Mac OS X. .SS CPackIFW .sp The documentation for the CPack IFW generator has moved here: \fBCPack IFW Generator\fP .sp This module looks for the location of the command line utilities supplied with the Qt Installer Framework (\fI\%QtIFW\fP). .sp The module also defines several commands to control the behavior of the CPack \fBIFW\fP generator. .SS Commands .sp The module defines the following commands: .INDENT 0.0 .TP .B cpack_ifw_configure_component Sets the arguments specific to the CPack IFW generator. .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C cpack_ifw_configure_component( [COMMON] [ESSENTIAL] [VIRTUAL] [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS] [NAME ] [DISPLAY_NAME ] # Note: Internationalization supported [DESCRIPTION ] # Note: Internationalization supported [UPDATE_TEXT ] [VERSION ] [RELEASE_DATE ] [SCRIPT