diff options
467 files changed, 13718 insertions, 12283 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ee987d0..756e379 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,18 @@ option(CMake_BUILD_DEVELOPER_REFERENCE "Build CMake Developer Reference" OFF) mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE) +# option to build using interprocedural optimizations (IPO/LTO) +if (NOT CMAKE_VERSION VERSION_LESS 3.12.2) + option(CMake_BUILD_LTO "Compile CMake with link-time optimization if supported" OFF) + if(CMake_BUILD_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT HAVE_IPO) + if(HAVE_IPO) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + endif() +endif() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script @@ -410,7 +422,6 @@ macro (CMAKE_BUILD_UTILITIES) set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) - add_definitions(-DCURL_STATICLIB) set(CMAKE_CURL_INCLUDES) set(CMAKE_CURL_LIBRARIES cmcurl) if(CMAKE_TESTS_CDASH_SERVER) @@ -792,9 +803,10 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() endif() -# add a test -add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" - --system-information -G "${CMAKE_GENERATOR}" ) +if(BUILD_TESTING) + add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" + --system-information -G "${CMAKE_GENERATOR}" ) +endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) # Install license file as it requires. diff --git a/Help/command/LINK_OPTIONS_LINKER.txt b/Help/command/LINK_OPTIONS_LINKER.txt index 76927be..a723375 100644 --- a/Help/command/LINK_OPTIONS_LINKER.txt +++ b/Help/command/LINK_OPTIONS_LINKER.txt @@ -8,3 +8,15 @@ driver option and the rest of the option string defines linker arguments using For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for ``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``. + +The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix +expression. + +The ``LINKER:`` prefix supports, as alternate syntax, specification of +arguments using ``SHELL:`` prefix and space as separator. Previous example +becomes ``"LINKER:SHELL:-z defs"``. + +.. note:: + + Specifying ``SHELL:`` prefix elsewhere than at the beginning of the + ``LINKER:`` prefix is not supported. diff --git a/Help/command/add_compile_definitions.rst b/Help/command/add_compile_definitions.rst index 48815d4..8225da7 100644 --- a/Help/command/add_compile_definitions.rst +++ b/Help/command/add_compile_definitions.rst @@ -1,9 +1,9 @@ add_compile_definitions ----------------------- -Adds preprocessor definitions to the compilation of source files. +Add preprocessor definitions to the compilation of source files. -:: +.. code-block:: cmake add_compile_definitions(<definition> ...) diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst index 350a1c0..fcdcfd4 100644 --- a/Help/command/add_compile_options.rst +++ b/Help/command/add_compile_options.rst @@ -1,9 +1,9 @@ add_compile_options ------------------- -Adds options to the compilation of source files. +Add options to the compilation of source files. -:: +.. code-block:: cmake add_compile_options(<option> ...) diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index 71fe494..9bf0d87 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -8,7 +8,9 @@ There are two main signatures for ``add_custom_command``. Generating Files ^^^^^^^^^^^^^^^^ -The first signature is for adding a custom command to produce an output:: +The first signature is for adding a custom command to produce an output: + +.. code-block:: cmake add_custom_command(OUTPUT output1 [output2 ...] COMMAND command1 [ARGS] [args1...] @@ -200,7 +202,7 @@ before or after building the target. The command becomes part of the target and will only execute when the target itself is built. If the target is already built, the command will not execute. -:: +.. code-block:: cmake add_custom_command(TARGET <target> PRE_BUILD | PRE_LINK | POST_BUILD diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst index a6b2f77..c63dd23 100644 --- a/Help/command/add_custom_target.rst +++ b/Help/command/add_custom_target.rst @@ -3,7 +3,7 @@ add_custom_target Add a target with no output so it will always be built. -:: +.. code-block:: cmake add_custom_target(Name [ALL] [command1 [args1...]] [COMMAND command2 [args2...] ...] diff --git a/Help/command/add_definitions.rst b/Help/command/add_definitions.rst index 1da15a6..39a43f4 100644 --- a/Help/command/add_definitions.rst +++ b/Help/command/add_definitions.rst @@ -1,9 +1,9 @@ add_definitions --------------- -Adds -D define flags to the compilation of source files. +Add -D define flags to the compilation of source files. -:: +.. code-block:: cmake add_definitions(-DFOO -DBAR ...) diff --git a/Help/command/add_dependencies.rst b/Help/command/add_dependencies.rst index 7a66143..de219a5 100644 --- a/Help/command/add_dependencies.rst +++ b/Help/command/add_dependencies.rst @@ -3,11 +3,11 @@ add_dependencies Add a dependency between top-level targets. -:: +.. code-block:: cmake add_dependencies(<target> [<target-dependency>]...) -Make a top-level ``<target>`` depend on other top-level targets to +Makes a top-level ``<target>`` depend on other top-level targets to ensure that they build before ``<target>`` does. A top-level target is one created by one of the :command:`add_executable`, :command:`add_library`, or :command:`add_custom_target` commands diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst index c7a30d7..0a7d7e1 100644 --- a/Help/command/add_executable.rst +++ b/Help/command/add_executable.rst @@ -3,7 +3,7 @@ add_executable Add an executable to the project using the specified source files. -:: +.. code-block:: cmake add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] @@ -47,7 +47,7 @@ within IDE. -------------------------------------------------------------------------- -:: +.. code-block:: cmake add_executable(<name> IMPORTED [GLOBAL]) @@ -67,7 +67,7 @@ properties for more information. -------------------------------------------------------------------------- -:: +.. code-block:: cmake add_executable(<name> ALIAS <target>) diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index c4c512c..ec6cb9d 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -10,7 +10,7 @@ Add a library to the project using the specified source files. Normal Libraries ^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] @@ -67,7 +67,7 @@ within IDE. Imported Libraries ^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> <SHARED|STATIC|MODULE|OBJECT|UNKNOWN> IMPORTED [GLOBAL]) @@ -92,7 +92,7 @@ for more information. Object Libraries ^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> OBJECT <src>...) @@ -121,7 +121,7 @@ consider adding at least one real source file to any target that references Alias Libraries ^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> ALIAS <target>) @@ -141,7 +141,7 @@ installed or exported. Interface Libraries ^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake add_library(<name> INTERFACE [IMPORTED [GLOBAL]]) diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst index 551d440..1b02bee 100644 --- a/Help/command/add_link_options.rst +++ b/Help/command/add_link_options.rst @@ -1,9 +1,9 @@ add_link_options ---------------- -Adds options to the link of shared library, module and executable targets. +Add options to the link of shared library, module and executable targets. -:: +.. code-block:: cmake add_link_options(<option> ...) @@ -21,6 +21,6 @@ the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. -.. include:: LINK_OPTIONS_LINKER.txt - .. include:: OPTIONS_SHELL.txt + +.. include:: LINK_OPTIONS_LINKER.txt diff --git a/Help/command/add_subdirectory.rst b/Help/command/add_subdirectory.rst index 012ded4..8dba986 100644 --- a/Help/command/add_subdirectory.rst +++ b/Help/command/add_subdirectory.rst @@ -3,12 +3,11 @@ add_subdirectory Add a subdirectory to the build. -:: +.. code-block:: cmake - add_subdirectory(source_dir [binary_dir] - [EXCLUDE_FROM_ALL]) + add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL]) -Add a subdirectory to the build. The source_dir specifies the +Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.txt and code files are located. If it is a relative path it will be evaluated with respect to the current directory (the typical usage), but it may also be an diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index d8a96e9..a8c257d 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -3,13 +3,13 @@ add_test Add a test to the project to be run by :manual:`ctest(1)`. -:: +.. code-block:: cmake add_test(NAME <name> COMMAND <command> [<arg>...] [CONFIGURATIONS <config>...] [WORKING_DIRECTORY <dir>]) -Add a test called ``<name>``. The test name may not contain spaces, +Adds a test called ``<name>``. The test name may not contain spaces, quotes, or other characters special in CMake syntax. The options are: ``COMMAND`` @@ -39,7 +39,9 @@ The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator expressions" with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. -Example usage:: +Example usage: + +.. code-block:: cmake add_test(NAME mytest COMMAND testDriver --config $<CONFIGURATION> @@ -57,7 +59,7 @@ file produced by target ``myexe``. --------------------------------------------------------------------- -:: +.. code-block:: cmake add_test(<name> <command> [<arg>...]) diff --git a/Help/command/aux_source_directory.rst b/Help/command/aux_source_directory.rst index dcd1cdf..e0af665 100644 --- a/Help/command/aux_source_directory.rst +++ b/Help/command/aux_source_directory.rst @@ -3,7 +3,7 @@ aux_source_directory Find all source files in a directory. -:: +.. code-block:: cmake aux_source_directory(<dir> <variable>) diff --git a/Help/command/break.rst b/Help/command/break.rst index fc2cd3c..4875a2b 100644 --- a/Help/command/break.rst +++ b/Help/command/break.rst @@ -3,10 +3,10 @@ break Break from an enclosing foreach or while loop. -:: +.. code-block:: cmake break() -Breaks from an enclosing foreach loop or while loop +Breaks from an enclosing :command:`foreach` or :command:`while` loop. See also the :command:`continue` command. diff --git a/Help/command/build_name.rst b/Help/command/build_name.rst index f717db1..2a1fbae 100644 --- a/Help/command/build_name.rst +++ b/Help/command/build_name.rst @@ -1,7 +1,7 @@ build_name ---------- -Disallowed. See CMake Policy :policy:`CMP0036`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0036`. Use ``${CMAKE_SYSTEM}`` and ``${CMAKE_CXX_COMPILER}`` instead. diff --git a/Help/command/cmake_host_system_information.rst b/Help/command/cmake_host_system_information.rst index 2dee93a..2e9563a 100644 --- a/Help/command/cmake_host_system_information.rst +++ b/Help/command/cmake_host_system_information.rst @@ -3,7 +3,7 @@ cmake_host_system_information Query host system specific information. -:: +.. code-block:: cmake cmake_host_system_information(RESULT <variable> QUERY <key> ...) diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst index 2f1ab60..e6ebcf0 100644 --- a/Help/command/cmake_minimum_required.rst +++ b/Help/command/cmake_minimum_required.rst @@ -1,11 +1,15 @@ cmake_minimum_required ---------------------- -Set the minimum required version of cmake for a project and -update `Policy Settings`_ to match the version given:: +Require a minimum version of cmake. + +.. code-block:: cmake cmake_minimum_required(VERSION <min>[...<max>] [FATAL_ERROR]) +Sets the minimum required version of cmake for a project. +Also updates the policy settings as explained below. + ``<min>`` and the optional ``<max>`` are each CMake versions of the form ``major.minor[.patch[.tweak]]``, and the ``...`` is literal. @@ -47,13 +51,17 @@ as of a given CMake version and tells newer CMake versions to warn about their new policies. When a ``<min>`` version higher than 2.4 is specified the command -implicitly invokes:: +implicitly invokes + +.. code-block:: cmake cmake_policy(VERSION <min>[...<max>]) which sets CMake policies based on the range of versions specified. When a ``<min>`` version 2.4 or lower is given the command implicitly -invokes:: +invokes + +.. code-block:: cmake cmake_policy(VERSION 2.4[...<max>]) diff --git a/Help/command/cmake_parse_arguments.rst b/Help/command/cmake_parse_arguments.rst index efbef54..c8327e2 100644 --- a/Help/command/cmake_parse_arguments.rst +++ b/Help/command/cmake_parse_arguments.rst @@ -1,26 +1,28 @@ cmake_parse_arguments --------------------- -``cmake_parse_arguments`` is intended to be used in macros or functions for -parsing the arguments given to that macro or function. It processes the -arguments and defines a set of variables which hold the values of the -respective options. +Parse function or macro arguments. -:: +.. code-block:: cmake cmake_parse_arguments(<prefix> <options> <one_value_keywords> - <multi_value_keywords> args...) + <multi_value_keywords> <args>...) - cmake_parse_arguments(PARSE_ARGV N <prefix> <options> <one_value_keywords> - <multi_value_keywords>) + cmake_parse_arguments(PARSE_ARGV <N> <prefix> <options> + <one_value_keywords> <multi_value_keywords>) + +This command is for use in macros or functions. +It processes the arguments given to that macro or function, +and defines a set of variables which hold the values of the +respective options. -The first signature reads processes arguments passed in the ``args...``. +The first signature reads processes arguments passed in the ``<args>...``. This may be used in either a :command:`macro` or a :command:`function`. The ``PARSE_ARGV`` signature is only for use in a :command:`function` body. In this case the arguments that are parsed come from the ``ARGV#`` variables of the calling function. The parsing starts with -the Nth argument, where ``N`` is an unsigned integer. This allows for +the ``<N>``-th argument, where ``<N>`` is an unsigned integer. This allows for the values to have special characters like ``;`` in them. The ``<options>`` argument contains all options for the respective macro, diff --git a/Help/command/cmake_policy.rst b/Help/command/cmake_policy.rst index c3f7cfb..a80f982 100644 --- a/Help/command/cmake_policy.rst +++ b/Help/command/cmake_policy.rst @@ -22,7 +22,9 @@ Setting Policies by CMake Version The ``cmake_policy`` command is used to set policies to ``OLD`` or ``NEW`` behavior. While setting policies individually is supported, we -encourage projects to set policies based on CMake versions:: +encourage projects to set policies based on CMake versions: + +.. code-block:: cmake cmake_policy(VERSION <min>[...<max>]) @@ -50,7 +52,7 @@ command implicitly calls ``cmake_policy(VERSION)`` too. Setting Policies Explicitly ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake cmake_policy(SET CMP<NNNN> NEW) cmake_policy(SET CMP<NNNN> OLD) @@ -66,7 +68,7 @@ policy state to ``NEW``. Checking Policy Settings ^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake cmake_policy(GET CMP<NNNN> <variable>) @@ -85,7 +87,9 @@ scripts loaded by :command:`include` and :command:`find_package` commands except when invoked with the ``NO_POLICY_SCOPE`` option (see also policy :policy:`CMP0011`). The ``cmake_policy`` command provides an interface to manage custom -entries on the policy stack:: +entries on the policy stack: + +.. code-block:: cmake cmake_policy(PUSH) cmake_policy(POP) diff --git a/Help/command/configure_file.rst b/Help/command/configure_file.rst index e08c573..29e85bd 100644 --- a/Help/command/configure_file.rst +++ b/Help/command/configure_file.rst @@ -3,7 +3,7 @@ configure_file Copy a file to another location and modify its contents. -:: +.. code-block:: cmake configure_file(<input> <output> [COPYONLY] [ESCAPE_QUOTES] [@ONLY] @@ -13,15 +13,21 @@ Copies an ``<input>`` file to an ``<output>`` file and substitutes variable values referenced as ``@VAR@`` or ``${VAR}`` in the input file content. Each variable reference will be replaced with the current value of the variable, or the empty string if the variable -is not defined. Furthermore, input lines of the form:: +is not defined. Furthermore, input lines of the form + +.. code-block:: c #cmakedefine VAR ... -will be replaced with either:: +will be replaced with either + +.. code-block:: c #define VAR ... -or:: +or + +.. code-block:: c /* #undef VAR */ @@ -33,12 +39,16 @@ either ``#define VAR 1`` or ``#define VAR 0`` similarly. The result lines (with the exception of the ``#undef`` comments) can be indented using spaces and/or tabs between the ``#`` character and the ``cmakedefine`` or ``cmakedefine01`` words. This whitespace -indentation will be preserved in the output lines:: +indentation will be preserved in the output lines: + +.. code-block:: c # cmakedefine VAR # cmakedefine01 VAR -will be replaced, if ``VAR`` is defined, with:: +will be replaced, if ``VAR`` is defined, with + +.. code-block:: c # define VAR # define VAR 1 diff --git a/Help/command/continue.rst b/Help/command/continue.rst index 1c7d673..31c7089 100644 --- a/Help/command/continue.rst +++ b/Help/command/continue.rst @@ -3,10 +3,12 @@ continue Continue to the top of enclosing foreach or while loop. -:: +.. code-block:: cmake continue() The ``continue`` command allows a cmake script to abort the rest of a block in a :command:`foreach` or :command:`while` loop, and start at the top of -the next iteration. See also the :command:`break` command. +the next iteration. + +See also the :command:`break` command. diff --git a/Help/command/create_test_sourcelist.rst b/Help/command/create_test_sourcelist.rst index dde6812..77e37c5 100644 --- a/Help/command/create_test_sourcelist.rst +++ b/Help/command/create_test_sourcelist.rst @@ -3,7 +3,7 @@ create_test_sourcelist Create a test driver and source list for building test programs. -:: +.. code-block:: cmake create_test_sourcelist(sourceListName driverName test1 test2 test3 diff --git a/Help/command/define_property.rst b/Help/command/define_property.rst index da2631c..8f7439b 100644 --- a/Help/command/define_property.rst +++ b/Help/command/define_property.rst @@ -3,7 +3,7 @@ define_property Define and document custom properties. -:: +.. code-block:: cmake define_property(<GLOBAL | DIRECTORY | TARGET | SOURCE | TEST | VARIABLE | CACHED_VARIABLE> @@ -11,7 +11,7 @@ Define and document custom properties. BRIEF_DOCS <brief-doc> [docs...] FULL_DOCS <full-doc> [docs...]) -Define one property in a scope for use with the :command:`set_property` and +Defines one property in a scope for use with the :command:`set_property` and :command:`get_property` commands. This is primarily useful to associate documentation with property names that may be retrieved with the :command:`get_property` command. The first argument determines the kind of diff --git a/Help/command/else.rst b/Help/command/else.rst index 0e5a198..a98fcd8 100644 --- a/Help/command/else.rst +++ b/Help/command/else.rst @@ -3,8 +3,8 @@ else Starts the else portion of an if block. -:: +.. code-block:: cmake - else(expression) + else([<condition>]) See the :command:`if` command. diff --git a/Help/command/elseif.rst b/Help/command/elseif.rst index 9a8dfed..6bf8646 100644 --- a/Help/command/elseif.rst +++ b/Help/command/elseif.rst @@ -1,10 +1,11 @@ elseif ------ -Starts the elseif portion of an if block. +Starts an elseif portion of an if block. -:: +.. code-block:: cmake - elseif(expression) + elseif(<condition>) -See the :command:`if` command. +See the :command:`if` command, especially for the syntax and logic +of the ``<condition>``. diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst index 61dfc03..fb49b44 100644 --- a/Help/command/enable_language.rst +++ b/Help/command/enable_language.rst @@ -3,12 +3,12 @@ enable_language Enable a language (CXX/C/Fortran/etc) -:: +.. code-block:: cmake enable_language(<lang> [OPTIONAL] ) -This command enables support for the named language in CMake. This is -the same as the project command but does not create any of the extra +Enables support for the named language in CMake. This is +the same as the :command:`project` command but does not create any of the extra variables that are created by the project command. Example languages are ``CXX``, ``C``, ``CUDA``, ``Fortran``, and ``ASM``. diff --git a/Help/command/enable_testing.rst b/Help/command/enable_testing.rst index 1e3e279..e2028d2 100644 --- a/Help/command/enable_testing.rst +++ b/Help/command/enable_testing.rst @@ -3,7 +3,7 @@ enable_testing Enable testing for current directory and below. -:: +.. code-block:: cmake enable_testing() diff --git a/Help/command/endforeach.rst b/Help/command/endforeach.rst index 9af972b..fd923d5 100644 --- a/Help/command/endforeach.rst +++ b/Help/command/endforeach.rst @@ -3,8 +3,12 @@ endforeach Ends a list of commands in a foreach block. -:: +.. code-block:: cmake - endforeach(expression) + endforeach([<loop_var>]) See the :command:`foreach` command. + +The optional ``<loop_var>`` argument is supported for backward compatibility +only. If used it must be a verbatim repeat of the ``<loop_var>`` argument of +the opening ``foreach`` clause. diff --git a/Help/command/endfunction.rst b/Help/command/endfunction.rst index 6cc196c..e27129d 100644 --- a/Help/command/endfunction.rst +++ b/Help/command/endfunction.rst @@ -3,8 +3,12 @@ endfunction Ends a list of commands in a function block. -:: +.. code-block:: cmake - endfunction(expression) + endfunction([<name>]) See the :command:`function` command. + +The optional ``<name>`` argument is supported for backward compatibility +only. If used it must be a verbatim repeat of the ``<name>`` argument +of the opening ``function`` command. diff --git a/Help/command/endif.rst b/Help/command/endif.rst index a0163bf..fc4f038 100644 --- a/Help/command/endif.rst +++ b/Help/command/endif.rst @@ -3,8 +3,12 @@ endif Ends a list of commands in an if block. -:: +.. code-block:: cmake - endif(expression) + endif([<condition>]) See the :command:`if` command. + +The optional ``<condition>`` argument is supported for backward compatibility +only. If used it must be a verbatim repeat of the argument of the opening +``if`` clause. diff --git a/Help/command/endmacro.rst b/Help/command/endmacro.rst index 47327a7..4290ba7 100644 --- a/Help/command/endmacro.rst +++ b/Help/command/endmacro.rst @@ -3,8 +3,12 @@ endmacro Ends a list of commands in a macro block. -:: +.. code-block:: cmake - endmacro(expression) + endmacro([<name>]) See the :command:`macro` command. + +The optional ``<name>`` argument is supported for backward compatibility +only. If used it must be a verbatim repeat of the ``<name>`` argument +of the opening ``macro`` command. diff --git a/Help/command/endwhile.rst b/Help/command/endwhile.rst index 798c20e..5ef585b 100644 --- a/Help/command/endwhile.rst +++ b/Help/command/endwhile.rst @@ -3,8 +3,12 @@ endwhile Ends a list of commands in a while block. -:: +.. code-block:: cmake - endwhile(expression) + endwhile([<condition>]) See the :command:`while` command. + +The optional ``<condition>`` argument is supported for backward compatibility +only. If used it must be a verbatim repeat of the argument of the opening +``while`` clause. diff --git a/Help/command/exec_program.rst b/Help/command/exec_program.rst index 6dfdad3..bc9b069 100644 --- a/Help/command/exec_program.rst +++ b/Help/command/exec_program.rst @@ -1,7 +1,9 @@ exec_program ------------ -Deprecated. Use the :command:`execute_process` command instead. +.. deprecated:: 3.0 + + Use the :command:`execute_process` command instead. Run an executable program during the processing of the CMakeList.txt file. diff --git a/Help/command/export.rst b/Help/command/export.rst index 8c49328..b255ee8 100644 --- a/Help/command/export.rst +++ b/Help/command/export.rst @@ -3,11 +3,11 @@ export Export targets from the build tree for use by outside projects. -:: +.. code-block:: cmake export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>]) -Create a file ``<filename>`` that may be included by outside projects to +Creates a file ``<filename>`` that may be included by outside projects to import targets from the current project's build tree. This is useful during cross-compiling to build utility executables that can run on the host platform in one project and then import them into another @@ -25,7 +25,7 @@ export targets from an installation tree. The properties set on the generated IMPORTED targets will have the same values as the final values of the input TARGETS. -:: +.. code-block:: cmake export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>] [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES]) @@ -49,7 +49,7 @@ unspecified. transitive usage requirements of other targets that link to the object libraries in their implementation. -:: +.. code-block:: cmake export(PACKAGE <PackageName>) @@ -65,7 +65,7 @@ wide installations, it is not desirable to write the user package registry. If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable is enabled, the ``export(PACKAGE)`` command will do nothing. -:: +.. code-block:: cmake export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>]) diff --git a/Help/command/export_library_dependencies.rst b/Help/command/export_library_dependencies.rst index 2cb437e..9753abf 100644 --- a/Help/command/export_library_dependencies.rst +++ b/Help/command/export_library_dependencies.rst @@ -1,7 +1,7 @@ export_library_dependencies --------------------------- -Disallowed. See CMake Policy :policy:`CMP0033`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0033`. Use :command:`install(EXPORT)` or :command:`export` command. diff --git a/Help/command/file.rst b/Help/command/file.rst index d4a6006..f5279c0 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -42,7 +42,7 @@ Reading .. _READ: -:: +.. code-block:: cmake file(READ <filename> <variable> [OFFSET <offset>] [LIMIT <max-in>] [HEX]) @@ -54,7 +54,7 @@ be converted to a hexadecimal representation (useful for binary data). .. _STRINGS: -:: +.. code-block:: cmake file(STRINGS <filename> <variable> [<options>...]) @@ -105,7 +105,7 @@ from the input file. .. _HASH: -:: +.. code-block:: cmake file(<HASH> <filename> <variable>) @@ -116,7 +116,7 @@ command. .. _TIMESTAMP: -:: +.. code-block:: cmake file(TIMESTAMP <filename> <variable> [<format>] [UTC]) @@ -133,7 +133,7 @@ Writing .. _WRITE: .. _APPEND: -:: +.. code-block:: cmake file(WRITE <filename> <content>...) file(APPEND <filename> <content>...) @@ -150,7 +150,7 @@ to update the file only when its content changes. .. _TOUCH: .. _TOUCH_NOCREATE: -:: +.. code-block:: cmake file(TOUCH [<files>...]) file(TOUCH_NOCREATE [<files>...]) @@ -167,7 +167,7 @@ modified. .. _GENERATE: -:: +.. code-block:: cmake file(GENERATE OUTPUT output-file <INPUT input-file|CONTENT content> @@ -217,7 +217,7 @@ Filesystem .. _GLOB: .. _GLOB_RECURSE: -:: +.. code-block:: cmake file(GLOB <variable> [LIST_DIRECTORIES true|false] [RELATIVE <path>] [CONFIGURE_DEPENDS] @@ -272,7 +272,7 @@ Examples of recursive globbing include:: .. _RENAME: -:: +.. code-block:: cmake file(RENAME <oldname> <newname>) @@ -282,7 +282,7 @@ Move a file or directory within a filesystem from ``<oldname>`` to .. _REMOVE: .. _REMOVE_RECURSE: -:: +.. code-block:: cmake file(REMOVE [<files>...]) file(REMOVE_RECURSE [<files>...]) @@ -293,7 +293,7 @@ given file does not exist. .. _MAKE_DIRECTORY: -:: +.. code-block:: cmake file(MAKE_DIRECTORY [<directories>...]) @@ -302,7 +302,7 @@ Create the given directories and their parents as needed. .. _COPY: .. _INSTALL: -:: +.. code-block:: cmake file(<COPY|INSTALL> <files>... DESTINATION <dir> [FILE_PERMISSIONS <permissions>...] @@ -338,7 +338,7 @@ Path Conversion .. _RELATIVE_PATH: -:: +.. code-block:: cmake file(RELATIVE_PATH <variable> <directory> <file>) @@ -348,7 +348,7 @@ store it in the ``<variable>``. .. _TO_CMAKE_PATH: .. _TO_NATIVE_PATH: -:: +.. code-block:: cmake file(TO_CMAKE_PATH "<path>" <variable>) file(TO_NATIVE_PATH "<path>" <variable>) @@ -370,7 +370,7 @@ Transfer .. _DOWNLOAD: .. _UPLOAD: -:: +.. code-block:: cmake file(DOWNLOAD <url> <file> [<options>...]) file(UPLOAD <file> <url> [<options>...]) @@ -460,7 +460,7 @@ Locking .. _LOCK: -:: +.. code-block:: cmake file(LOCK <path> [DIRECTORY] [RELEASE] [GUARD <FUNCTION|FILE|PROCESS>] diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 3ad571c..9395356 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -12,7 +12,7 @@ Find an external project, and load its settings. Basic Signature and Module Mode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake find_package(<PackageName> [version] [EXACT] [QUIET] [MODULE] [REQUIRED] [[COMPONENTS] [components...]] @@ -51,8 +51,9 @@ mode and "Config" mode. The above signature selects Module mode. If no module is found the command falls back to Config mode, described below. This fall back is disabled if the ``MODULE`` option is given. -In Module mode, CMake searches for a file called ``Find<PackageName>.cmake`` -in the :variable:`CMAKE_MODULE_PATH` followed by the CMake installation. +In Module mode, CMake searches for a file called ``Find<PackageName>.cmake``. +The file is first searched in the :variable:`CMAKE_MODULE_PATH`, +then among the :ref:`Find Modules` provided by the CMake installation. If the file is found, it is read and processed by CMake. It is responsible for finding the package, checking the version, and producing any needed messages. Some find-modules provide limited or no support for versioning; @@ -67,7 +68,9 @@ full command signature and details of the search process. Project maintainers wishing to provide a package to be found by this command are encouraged to read on. -The complete Config mode command signature is:: +The complete Config mode command signature is + +.. code-block:: cmake find_package(<PackageName> [version] [EXACT] [QUIET] [REQUIRED] [[COMPONENTS] [components...]] @@ -202,7 +205,9 @@ is set no attempt is made to choose a highest or closest version number. To control the order in which ``find_package`` checks for compatibility use the two variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` and :variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`. -For instance in order to select the highest version one can set:: +For instance in order to select the highest version one can set + +.. code-block:: cmake SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) diff --git a/Help/command/fltk_wrap_ui.rst b/Help/command/fltk_wrap_ui.rst index 041e5a7..6675272 100644 --- a/Help/command/fltk_wrap_ui.rst +++ b/Help/command/fltk_wrap_ui.rst @@ -3,7 +3,7 @@ fltk_wrap_ui Create FLTK user interfaces Wrappers. -:: +.. code-block:: cmake fltk_wrap_ui(resultingLibraryName source1 source2 ... sourceN ) diff --git a/Help/command/foreach.rst b/Help/command/foreach.rst index 106ba73..ae2afb2 100644 --- a/Help/command/foreach.rst +++ b/Help/command/foreach.rst @@ -3,45 +3,82 @@ foreach Evaluate a group of commands for each value in a list. -:: +.. code-block:: cmake - foreach(loop_var arg1 arg2 ...) - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... - endforeach(loop_var) + foreach(<loop_var> <items>) + <commands> + endforeach() -All commands between foreach and the matching endforeach are recorded -without being invoked. Once the endforeach is evaluated, the recorded -list of commands is invoked once for each argument listed in the -original foreach command. Before each iteration of the loop -``${loop_var}`` will be set as a variable with the current value in the -list. +where ``<items>`` is a list of items that are separated by +semicolon or whitespace. +All commands between ``foreach`` and the matching ``endforeach`` are recorded +without being invoked. Once the ``endforeach`` is evaluated, the recorded +list of commands is invoked once for each item in ``<items>``. +At the beginning of each iteration the variable ``loop_var`` will be set +to the value of the current item. -:: +The commands :command:`break` and :command:`continue` provide means to +escape from the normal control flow. - foreach(loop_var RANGE total) - foreach(loop_var RANGE start stop [step]) +Per legacy, the :command:`endforeach` command admits +an optional ``<loop_var>`` argument. +If used, it must be a verbatim +repeat of the argument of the opening +``foreach`` command. -Foreach can also iterate over a generated range of numbers. There are -three types of this iteration: +.. code-block:: cmake -* When specifying single number, the range will have elements [0, ... to - "total"] (inclusive). + foreach(<loop_var> RANGE <stop>) -* When specifying two numbers, the range will have elements from the - first number to the second number (inclusive). +In this variant, ``foreach`` iterates over the numbers +0, 1, ... up to (and including) the nonnegative integer ``<stop>``. -* The third optional number is the increment used to iterate from the - first number to the second number (inclusive). +.. code-block:: cmake -:: + foreach(<loop_var> RANGE <start> <stop> [<step>]) + +In this variant, ``foreach`` iterates over the numbers from +``<start>`` up to at most ``<stop>`` in steps of ``<step>``. +If ``<step>`` is not specified, then the step size is 1. +The three arguments ``<start>`` ``<stop>`` ``<step>`` must +all be nonnegative integers, and ``<stop>`` must not be +smaller than ``<start>``; otherwise you enter the danger zone +of undocumented behavior that may change in future releases. + +.. code-block:: cmake + + foreach(loop_var IN [LISTS [<lists>]] [ITEMS [<items>]]) - foreach(loop_var IN [LISTS [list1 [...]]] - [ITEMS [item1 [...]]]) +In this variant, ``<lists>`` is a whitespace or semicolon +separated list of list-valued variables. The ``foreach`` +command iterates over each item in each given list. +The ``<items>`` following the ``ITEMS`` keyword are processed +as in the first variant of the ``foreach`` command. +The forms ``LISTS A`` and ``ITEMS ${A}`` are +equivalent. + +The following example shows how the ``LISTS`` option is +processed: + +.. code-block:: cmake + + set(A 0;1) + set(B 2 3) + set(C "4 5") + set(D 6;7 8) + set(E "") + foreach(X IN LISTS A B C D E) + message(STATUS "X=${X}") + endforeach() + +yields +:: -Iterates over a precise list of items. The ``LISTS`` option names -list-valued variables to be traversed, including empty elements (an -empty string is a zero-length list). (Note macro -arguments are not variables.) The ``ITEMS`` option ends argument -parsing and includes all arguments following it in the iteration. + -- X=0 + -- X=1 + -- X=2 + -- X=3 + -- X=4 5 + -- X=6 + -- X=7 + -- X=8 diff --git a/Help/command/function.rst b/Help/command/function.rst index 7ffdfee..4a223b4 100644 --- a/Help/command/function.rst +++ b/Help/command/function.rst @@ -1,27 +1,29 @@ function -------- -Start recording a function for later invocation as a command:: - - function(<name> [arg1 [arg2 [arg3 ...]]]) - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... - endfunction(<name>) - -Define a function named ``<name>`` that takes arguments named ``arg1``, -``arg2``, ``arg3``, (...). -Commands listed after function, but before the matching -:command:`endfunction()`, are not invoked until the function is invoked. -When it is invoked, the commands recorded in the function are first -modified by replacing formal parameters (``${arg1}``) with the arguments -passed, and then invoked as normal commands. +Start recording a function for later invocation as a command. + +.. code-block:: cmake + + function(<name> [<arg1> ...]) + <commands> + endfunction() + +Defines a function named ``<name>`` that takes arguments +named ``<arg1>``, ... +The ``<commands>`` in the function definition are recorded; +they are not invoked until the function is invoked. When +the function is invoked, the recorded ``<commands>`` are first +modified by replacing formal parameters (``${arg1}``, ...) +with the arguments passed, and then invoked as normal commands. + In addition to referencing the formal parameters you can reference the ``ARGC`` variable which will be set to the number of arguments passed into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ... which will have the actual values of the arguments passed in. This facilitates creating functions with optional arguments. -Additionally ``ARGV`` holds the list of all arguments given to the + +Furthermore, ``ARGV`` holds the list of all arguments given to the function and ``ARGN`` holds the list of arguments past the last expected argument. Referencing to ``ARGV#`` arguments beyond ``ARGC`` have undefined @@ -29,6 +31,10 @@ behavior. Checking that ``ARGC`` is greater than ``#`` is the only way to ensure that ``ARGV#`` was passed to the function as an extra argument. +Per legacy, the :command:`endfunction` command admits an optional +``<name>`` argument. If used, it must be a verbatim repeat of the +argument of the opening ``function`` command. + A function opens a new scope: see :command:`set(var PARENT_SCOPE)` for details. diff --git a/Help/command/get_cmake_property.rst b/Help/command/get_cmake_property.rst index 497ab4e..58bf741 100644 --- a/Help/command/get_cmake_property.rst +++ b/Help/command/get_cmake_property.rst @@ -3,14 +3,14 @@ get_cmake_property Get a global property of the CMake instance. -:: +.. code-block:: cmake - get_cmake_property(VAR property) + get_cmake_property(<var> <property>) -Get a global property from the CMake instance. The value of the property is -stored in the variable ``VAR``. If the property is not found, ``VAR`` -will be set to "NOTFOUND". See the :manual:`cmake-properties(7)` manual -for available properties. +Gets a global property from the CMake instance. The value of +the ``<property>`` is stored in the variable ``<var>``. +If the property is not found, ``<var>`` will be set to ``"NOTFOUND"``. +See the :manual:`cmake-properties(7)` manual for available properties. See also the :command:`get_property` command ``GLOBAL`` option. diff --git a/Help/command/get_directory_property.rst b/Help/command/get_directory_property.rst index bf8349c..218efa9 100644 --- a/Help/command/get_directory_property.rst +++ b/Help/command/get_directory_property.rst @@ -3,11 +3,11 @@ get_directory_property Get a property of ``DIRECTORY`` scope. -:: +.. code-block:: cmake get_directory_property(<variable> [DIRECTORY <dir>] <prop-name>) -Store a property of directory scope in the named ``<variable>``. +Stores a property of directory scope in the named ``<variable>``. The ``DIRECTORY`` argument specifies another directory from which to retrieve the property value instead of the current directory. The specified directory must have already been traversed by CMake. @@ -18,7 +18,7 @@ if the property is not found for the nominated directory scope, the search will chain to a parent scope as described for the :command:`define_property` command. -:: +.. code-block:: cmake get_directory_property(<variable> [DIRECTORY <dir>] DEFINITION <var-name>) diff --git a/Help/command/get_filename_component.rst b/Help/command/get_filename_component.rst index f11c0fc..3e3c9c3 100644 --- a/Help/command/get_filename_component.rst +++ b/Help/command/get_filename_component.rst @@ -3,13 +3,11 @@ get_filename_component Get a specific component of a full filename. ------------------------------------------------------------------------------- +.. code-block:: cmake -:: - - get_filename_component(<VAR> <FileName> <COMP> [CACHE]) + get_filename_component(<var> <FileName> <mode> [CACHE]) -Set ``<VAR>`` to a component of ``<FileName>``, where ``<COMP>`` is one of: +Sets ``<var>`` to a component of ``<FileName>``, where ``<mode>`` is one of: :: @@ -24,15 +22,11 @@ The longest file extension is always considered. If the optional ``CACHE`` argument is specified, the result variable is added to the cache. ------------------------------------------------------------------------------- - -:: +.. code-block:: cmake - get_filename_component(<VAR> <FileName> - <COMP> [BASE_DIR <BASE_DIR>] - [CACHE]) + get_filename_component(<var> <FileName> <mode> [BASE_DIR <dir>] [CACHE]) -Set ``<VAR>`` to the absolute path of ``<FileName>``, where ``<COMP>`` is one +Sets ``<var>`` to the absolute path of ``<FileName>``, where ``<mode>`` is one of: :: @@ -41,7 +35,7 @@ of: REALPATH = Full path to existing file with symlinks resolved If the provided ``<FileName>`` is a relative path, it is evaluated relative -to the given base directory ``<BASE_DIR>``. If no base directory is +to the given base directory ``<dir>``. If no base directory is provided, the default base directory will be :variable:`CMAKE_CURRENT_SOURCE_DIR`. @@ -49,16 +43,12 @@ Paths are returned with forward slashes and have no trailing slashes. If the optional ``CACHE`` argument is specified, the result variable is added to the cache. ------------------------------------------------------------------------------- - -:: +.. code-block:: cmake - get_filename_component(<VAR> <FileName> - PROGRAM [PROGRAM_ARGS <ARG_VAR>] - [CACHE]) + get_filename_component(<var> <FileName> PROGRAM [PROGRAM_ARGS <arg_var>] [CACHE]) The program in ``<FileName>`` will be found in the system search path or left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then any command-line arguments present in the ``<FileName>`` string are split -from the program name and stored in ``<ARG_VAR>``. This is used to +from the program name and stored in ``<arg_var>``. This is used to separate a program name from its arguments in a command line string. diff --git a/Help/command/get_property.rst b/Help/command/get_property.rst index 8b85f7d..c0f9b46 100644 --- a/Help/command/get_property.rst +++ b/Help/command/get_property.rst @@ -3,32 +3,33 @@ get_property Get a property. -:: +.. code-block:: cmake get_property(<variable> <GLOBAL | - DIRECTORY [dir] | + DIRECTORY [<dir>] | TARGET <target> | SOURCE <source> | INSTALL <file> | TEST <test> | CACHE <entry> | - VARIABLE> + VARIABLE > PROPERTY <name> [SET | DEFINED | BRIEF_DOCS | FULL_DOCS]) -Get one property from one object in a scope. The first argument -specifies the variable in which to store the result. The second -argument determines the scope from which to get the property. It must -be one of the following: +Gets one property from one object in a scope. + +The first argument specifies the variable in which to store the result. +The second argument determines the scope from which to get the property. +It must be one of the following: ``GLOBAL`` Scope is unique and does not accept a name. ``DIRECTORY`` Scope defaults to the current directory but another - directory (already processed by CMake) may be named by full or - relative path. + directory (already processed by CMake) may be named by the + full or relative path ``<dir>``. ``TARGET`` Scope must name one existing target. @@ -58,6 +59,7 @@ value indicating whether the property has been set. If the ``DEFINED`` option is given the variable is set to a boolean value indicating whether the property has been defined such as with the :command:`define_property` command. + If ``BRIEF_DOCS`` or ``FULL_DOCS`` is given then the variable is set to a string containing documentation for the requested property. If documentation is requested for a property that has not been defined diff --git a/Help/command/get_source_file_property.rst b/Help/command/get_source_file_property.rst index 51fbd33..decec19 100644 --- a/Help/command/get_source_file_property.rst +++ b/Help/command/get_source_file_property.rst @@ -3,11 +3,11 @@ get_source_file_property Get a property for a source file. -:: +.. code-block:: cmake get_source_file_property(VAR file property) -Get a property from a source file. The value of the property is +Gets a property from a source file. The value of the property is stored in the variable ``VAR``. If the source property is not found, the behavior depends on whether it has been defined to be an ``INHERITED`` property or not (see :command:`define_property`). Non-inherited properties will set diff --git a/Help/command/get_target_property.rst b/Help/command/get_target_property.rst index 98e9db3..cbf4721 100644 --- a/Help/command/get_target_property.rst +++ b/Help/command/get_target_property.rst @@ -3,7 +3,7 @@ get_target_property Get a property from a target. -:: +.. code-block:: cmake get_target_property(VAR target property) diff --git a/Help/command/get_test_property.rst b/Help/command/get_test_property.rst index 555c3b2..e02b9bc 100644 --- a/Help/command/get_test_property.rst +++ b/Help/command/get_test_property.rst @@ -3,7 +3,7 @@ get_test_property Get a property of the test. -:: +.. code-block:: cmake get_test_property(test property VAR) diff --git a/Help/command/if.rst b/Help/command/if.rst index 8abe9ba..4781f35 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -6,7 +6,7 @@ Conditionally execute a group of commands. Synopsis ^^^^^^^^ -:: +.. code-block:: cmake if(<condition>) <commands> @@ -23,8 +23,11 @@ Otherwise, optional ``elseif`` blocks are processed in the same way. Finally, if no ``condition`` is true, ``commands`` in the optional ``else`` block are executed. -Per legacy, the ``else`` and ``endif`` clause may also have a ``condition`` argument, -which then must be a verbatim repeat of the argument of the opening ``if`` clause. +Per legacy, the :command:`else` and :command:`elseif` commands admit +an optional ``<condition>`` argument. +If used, it must be a verbatim +repeat of the argument of the opening +``if`` command. Condition Syntax ^^^^^^^^^^^^^^^^ @@ -202,21 +205,27 @@ The if command was written very early in CMake's history, predating the ``${}`` variable evaluation syntax, and for convenience evaluates variables named by its arguments as shown in the above signatures. Note that normal variable evaluation with ``${}`` applies before the if -command even receives the arguments. Therefore code like:: +command even receives the arguments. Therefore code like + +.. code-block:: cmake set(var1 OFF) set(var2 "var1") if(${var2}) -appears to the if command as:: +appears to the if command as + +.. code-block:: cmake - if(var1) + if(var1) and is evaluated according to the ``if(<variable>)`` case documented above. The result is ``OFF`` which is false. However, if we remove the -``${}`` from the example then the command sees:: +``${}`` from the example then the command sees + +.. code-block:: cmake - if(var2) + if(var2) which is true because ``var2`` is defined to "var1" which is not a false constant. diff --git a/Help/command/include.rst b/Help/command/include.rst index eeca4c6..80968da 100644 --- a/Help/command/include.rst +++ b/Help/command/include.rst @@ -3,16 +3,16 @@ include Load and run CMake code from a file or module. -:: +.. code-block:: cmake - include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>] + include(<file|module> [OPTIONAL] [RESULT_VARIABLE <var>] [NO_POLICY_SCOPE]) -Load and run CMake code from the file given. Variable reads and +Loads and runs CMake code from the file given. Variable reads and writes access the scope of the caller (dynamic scoping). If ``OPTIONAL`` is present, then no error is raised if the file does not exist. If -``RESULT_VARIABLE`` is given the variable will be set to the full filename -which has been included or NOTFOUND if it failed. +``RESULT_VARIABLE`` is given the variable ``<var>`` will be set to the +full filename which has been included or ``NOTFOUND`` if it failed. If a module is specified instead of a file, the file with name ``<modulename>.cmake`` is searched first in :variable:`CMAKE_MODULE_PATH`, diff --git a/Help/command/include_directories.rst b/Help/command/include_directories.rst index e797b5d..fe281c3 100644 --- a/Help/command/include_directories.rst +++ b/Help/command/include_directories.rst @@ -3,7 +3,7 @@ include_directories Add include directories to the build. -:: +.. code-block:: cmake include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...]) diff --git a/Help/command/include_external_msproject.rst b/Help/command/include_external_msproject.rst index 335282a..375baf2 100644 --- a/Help/command/include_external_msproject.rst +++ b/Help/command/include_external_msproject.rst @@ -3,7 +3,7 @@ include_external_msproject Include an external Microsoft project file in a workspace. -:: +.. code-block:: cmake include_external_msproject(projectname location [TYPE projectTypeGUID] diff --git a/Help/command/include_guard.rst b/Help/command/include_guard.rst index 62cce22..877aa86 100644 --- a/Help/command/include_guard.rst +++ b/Help/command/include_guard.rst @@ -3,7 +3,7 @@ include_guard Provides an include guard for the file currently being processed by CMake. -:: +.. code-block:: cmake include_guard([DIRECTORY|GLOBAL]) diff --git a/Help/command/include_regular_expression.rst b/Help/command/include_regular_expression.rst index ab5a563..dde8378 100644 --- a/Help/command/include_regular_expression.rst +++ b/Help/command/include_regular_expression.rst @@ -3,11 +3,11 @@ include_regular_expression Set the regular expression used for dependency checking. -:: +.. code-block:: cmake include_regular_expression(regex_match [regex_complain]) -Set the regular expressions used in dependency checking. Only files +Sets the regular expressions used in dependency checking. Only files matching ``regex_match`` will be traced as dependencies. Only files matching ``regex_complain`` will generate warnings if they cannot be found (standard header paths are not searched). The defaults are: diff --git a/Help/command/install.rst b/Help/command/install.rst index 98074d0..4966df4 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -101,7 +101,7 @@ Installing Targets .. _TARGETS: -:: +.. code-block:: cmake install(TARGETS targets... [EXPORT <export-name>] [[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE| @@ -305,7 +305,7 @@ Installing Files .. _FILES: .. _PROGRAMS: -:: +.. code-block:: cmake install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] @@ -340,7 +340,7 @@ Installing Directories .. _DIRECTORY: -:: +.. code-block:: cmake install(DIRECTORY dirs... DESTINATION <dir> [FILE_PERMISSIONS permissions...] @@ -424,7 +424,7 @@ Custom Installation Logic .. _CODE: .. _SCRIPT: -:: +.. code-block:: cmake install([[SCRIPT <file>] [CODE <code>]] [COMPONENT <component>] [EXCLUDE_FROM_ALL] [...]) @@ -447,7 +447,7 @@ Installing Exports .. _EXPORT: -:: +.. code-block:: cmake install(EXPORT <export-name> DESTINATION <dir> [NAMESPACE <namespace>] [[FILE <name>.cmake]| diff --git a/Help/command/install_files.rst b/Help/command/install_files.rst index 1850be6..f5fb46d 100644 --- a/Help/command/install_files.rst +++ b/Help/command/install_files.rst @@ -1,7 +1,9 @@ install_files ------------- -Deprecated. Use the :command:`install(FILES)` command instead. +.. deprecated:: 3.0 + + Use the :command:`install(FILES)` command instead. This command has been superceded by the :command:`install` command. It is provided for compatibility with older CMake code. The ``FILES`` form is diff --git a/Help/command/install_programs.rst b/Help/command/install_programs.rst index 79aa486..fab6482 100644 --- a/Help/command/install_programs.rst +++ b/Help/command/install_programs.rst @@ -1,7 +1,9 @@ install_programs ---------------- -Deprecated. Use the :command:`install(PROGRAMS)` command instead. +.. deprecated:: 3.0 + + Use the :command:`install(PROGRAMS)` command instead. This command has been superceded by the :command:`install` command. It is provided for compatibility with older CMake code. The ``FILES`` form is diff --git a/Help/command/install_targets.rst b/Help/command/install_targets.rst index 49ca696..c9efdce 100644 --- a/Help/command/install_targets.rst +++ b/Help/command/install_targets.rst @@ -1,7 +1,9 @@ install_targets --------------- -Deprecated. Use the :command:`install(TARGETS)` command instead. +.. deprecated:: 3.0 + + Use the :command:`install(TARGETS)` command instead. This command has been superceded by the :command:`install` command. It is provided for compatibility with older CMake code. diff --git a/Help/command/link_directories.rst b/Help/command/link_directories.rst index 1dce9a0..9cb8faa 100644 --- a/Help/command/link_directories.rst +++ b/Help/command/link_directories.rst @@ -3,11 +3,11 @@ link_directories Add directories in which the linker will look for libraries. -:: +.. code-block:: cmake link_directories([AFTER|BEFORE] directory1 [directory2 ...]) -Add the paths in which the linker should search for libraries. +Adds the paths in which the linker should search for libraries. Relative paths given to this command are interpreted as relative to the current source directory, see :policy:`CMP0015`. diff --git a/Help/command/link_libraries.rst b/Help/command/link_libraries.rst index fd5dc37..8665cb7 100644 --- a/Help/command/link_libraries.rst +++ b/Help/command/link_libraries.rst @@ -3,7 +3,7 @@ link_libraries Link libraries to all targets added later. -:: +.. code-block:: cmake link_libraries([item1 [item2 [...]]] [[debug|optimized|general] <item>] ...) diff --git a/Help/command/list.rst b/Help/command/list.rst index 2357a9b..bfcdf34 100644 --- a/Help/command/list.rst +++ b/Help/command/list.rst @@ -64,7 +64,7 @@ Reading .. _LENGTH: -:: +.. code-block:: cmake list(LENGTH <list> <output variable>) @@ -72,7 +72,7 @@ Returns the list's length. .. _GET: -:: +.. code-block:: cmake list(GET <list> <element index> [<element index> ...] <output variable>) @@ -80,7 +80,7 @@ Returns the list of elements specified by indices from the list. .. _JOIN: -:: +.. code-block:: cmake list(JOIN <list> <glue> <output variable>) @@ -90,7 +90,7 @@ from :command:`string` command. .. _SUBLIST: -:: +.. code-block:: cmake list(SUBLIST <list> <begin> <length> <output variable>) @@ -104,7 +104,7 @@ Search .. _FIND: -:: +.. code-block:: cmake list(FIND <list> <value> <output variable>) @@ -116,7 +116,7 @@ Modification .. _APPEND: -:: +.. code-block:: cmake list(APPEND <list> [<element> ...]) @@ -124,7 +124,7 @@ Appends elements to the list. .. _FILTER: -:: +.. code-block:: cmake list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>) @@ -136,7 +136,7 @@ For more information on regular expressions see also the .. _INSERT: -:: +.. code-block:: cmake list(INSERT <list> <element_index> <element> [<element> ...]) @@ -144,7 +144,7 @@ Inserts elements to the list to the specified location. .. _REMOVE_ITEM: -:: +.. code-block:: cmake list(REMOVE_ITEM <list> <value> [<value> ...]) @@ -152,7 +152,7 @@ Removes the given items from the list. .. _REMOVE_AT: -:: +.. code-block:: cmake list(REMOVE_AT <list> <index> [<index> ...]) @@ -160,7 +160,7 @@ Removes items at given indices from the list. .. _REMOVE_DUPLICATES: -:: +.. code-block:: cmake list(REMOVE_DUPLICATES <list>) @@ -168,7 +168,7 @@ Removes duplicated items in the list. .. _TRANSFORM: -:: +.. code-block:: cmake list(TRANSFORM <list> <ACTION> [<SELECTOR>] [OUTPUT_VARIABLE <output variable>]) @@ -190,30 +190,40 @@ The actions have exactly the same semantics as sub-commands of The ``<ACTION>`` may be one of: ``APPEND``, ``PREPEND``: Append, prepend specified value to each element of -the list. :: +the list. + +.. code-block:: cmake list(TRANSFORM <list> <APPEND|PREPEND> <value> ...) ``TOUPPER``, ``TOLOWER``: Convert each element of the list to upper, lower -characters. :: +characters. + +.. code-block:: cmake list(TRANSFORM <list> <TOLOWER|TOUPPER> ...) ``STRIP``: Remove leading and trailing spaces from each element of the -list. :: +list. + +.. code-block:: cmake list(TRANSFORM <list> STRIP ...) ``GENEX_STRIP``: Strip any :manual:`generator expressions <cmake-generator-expressions(7)>` from each -element of the list. :: +element of the list. + +.. code-block:: cmake list(TRANSFORM <list> GENEX_STRIP ...) ``REPLACE``: Match the regular expression as many times as possible and substitute the replacement expression for the match for each element of the list -(Same semantic as ``REGEX REPLACE`` from :command:`string` command). :: +(Same semantic as ``REGEX REPLACE`` from :command:`string` command). + +.. code-block:: cmake list(TRANSFORM <list> REPLACE <regular_expression> <replace_expression> ...) @@ -223,17 +233,23 @@ type of selector can be specified at a time. The ``<SELECTOR>`` may be one of: -``AT``: Specify a list of indexes. :: +``AT``: Specify a list of indexes. + +.. code-block:: cmake list(TRANSFORM <list> <ACTION> AT <index> [<index> ...] ...) ``FOR``: Specify a range with, optionally, an increment used to iterate over -the range. :: +the range. + +.. code-block:: cmake list(TRANSFORM <list> <ACTION> FOR <start> <stop> [<step>] ...) ``REGEX``: Specify a regular expression. Only elements matching the regular -expression will be transformed. :: +expression will be transformed. + +.. code-block:: cmake list(TRANSFORM <list> <ACTION> REGEX <regular_expression> ...) @@ -243,7 +259,7 @@ Ordering .. _REVERSE: -:: +.. code-block:: cmake list(REVERSE <list>) @@ -251,7 +267,7 @@ Reverses the contents of the list in-place. .. _SORT: -:: +.. code-block:: cmake list(SORT <list> [COMPARE <compare>] [CASE <case>] [ORDER <order>]) diff --git a/Help/command/load_cache.rst b/Help/command/load_cache.rst index f113447..33625c4 100644 --- a/Help/command/load_cache.rst +++ b/Help/command/load_cache.rst @@ -3,21 +3,20 @@ load_cache Load in the values from another project's CMake cache. -:: +.. code-block:: cmake - load_cache(pathToCacheFile READ_WITH_PREFIX - prefix entry1...) + load_cache(pathToCacheFile READ_WITH_PREFIX prefix entry1...) -Read the cache and store the requested entries in variables with their +Reads the cache and store the requested entries in variables with their name prefixed with the given prefix. This only reads the values, and does not create entries in the local project's cache. -:: +.. code-block:: cmake load_cache(pathToCacheFile [EXCLUDE entry1...] [INCLUDE_INTERNALS entry1...]) -Load in the values from another cache and store them in the local +Loads in the values from another cache and store them in the local project's cache as internal entries. This is useful for a project that depends on another project built in a different tree. ``EXCLUDE`` option can be used to provide a list of entries to be excluded. diff --git a/Help/command/load_command.rst b/Help/command/load_command.rst index a1576e8..dc23599 100644 --- a/Help/command/load_command.rst +++ b/Help/command/load_command.rst @@ -1,7 +1,7 @@ load_command ------------ -Disallowed. See CMake Policy :policy:`CMP0031`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0031`. Load a command into a running CMake. diff --git a/Help/command/macro.rst b/Help/command/macro.rst index 6bee69c..2746b1b 100644 --- a/Help/command/macro.rst +++ b/Help/command/macro.rst @@ -1,27 +1,29 @@ macro ----- -Start recording a macro for later invocation as a command:: +Start recording a macro for later invocation as a command - macro(<name> [arg1 [arg2 [arg3 ...]]]) - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... +.. code-block:: cmake + + macro(<name> [<arg1> ...]) + <commands> endmacro(<name>) -Define a macro named ``<name>`` that takes arguments named ``arg1``, -``arg2``, ``arg3``, (...). +Defines a macro named ``<name>`` that takes arguments +named ``<arg1>``, ... Commands listed after macro, but before the matching :command:`endmacro()`, are not invoked until the macro is invoked. When it is invoked, the commands recorded in the macro are first -modified by replacing formal parameters (``${arg1}``) with the arguments -passed, and then invoked as normal commands. +modified by replacing formal parameters (``${arg1}``, ...) +with the arguments passed, and then invoked as normal commands. + In addition to referencing the formal parameters you can reference the values ``${ARGC}`` which will be set to the number of arguments passed into the function as well as ``${ARGV0}``, ``${ARGV1}``, ``${ARGV2}``, ... which will have the actual values of the arguments passed in. This facilitates creating macros with optional arguments. -Additionally ``${ARGV}`` holds the list of all arguments given to the + +Furthermore, ``${ARGV}`` holds the list of all arguments given to the macro and ``${ARGN}`` holds the list of arguments past the last expected argument. Referencing to ``${ARGV#}`` arguments beyond ``${ARGC}`` have undefined @@ -38,7 +40,9 @@ Macro Argument Caveats Note that the parameters to a macro and values such as ``ARGN`` are not variables in the usual CMake sense. They are string replacements much like the C preprocessor would do with a macro. -Therefore you will NOT be able to use commands like:: +Therefore you will NOT be able to use commands like + +.. code-block:: cmake if(ARGV1) # ARGV1 is not a variable if(DEFINED ARGV2) # ARGV2 is not a variable @@ -50,18 +54,22 @@ In the second and third case, the proper way to check if an optional variable was passed to the macro is to use ``if(${ARGC} GREATER 2)``. In the last case, you can use ``foreach(loop_var ${ARGN})`` but this will skip empty arguments. -If you need to include them, you can use:: +If you need to include them, you can use + +.. code-block:: cmake set(list_var "${ARGN}") foreach(loop_var IN LISTS list_var) Note that if you have a variable with the same name in the scope from which the macro is called, using unreferenced names will use the -existing variable instead of the arguments. For example:: +existing variable instead of the arguments. For example: + +.. code-block:: cmake macro(_BAR) foreach(arg IN LISTS ARGN) - [...] + <commands> endforeach() endmacro() diff --git a/Help/command/make_directory.rst b/Help/command/make_directory.rst index 27ecf51..8469b0a 100644 --- a/Help/command/make_directory.rst +++ b/Help/command/make_directory.rst @@ -1,7 +1,9 @@ make_directory -------------- -Deprecated. Use the :command:`file(MAKE_DIRECTORY)` command instead. +.. deprecated:: 3.0 + + Use the :command:`file(MAKE_DIRECTORY)` command instead. :: diff --git a/Help/command/mark_as_advanced.rst b/Help/command/mark_as_advanced.rst index c3f94fc..5712fb4 100644 --- a/Help/command/mark_as_advanced.rst +++ b/Help/command/mark_as_advanced.rst @@ -3,17 +3,22 @@ mark_as_advanced Mark cmake cached variables as advanced. -:: +.. code-block:: cmake - mark_as_advanced([CLEAR|FORCE] VAR [VAR2 ...]) + mark_as_advanced([CLEAR|FORCE] <var1> ...) -Mark the named cached variables as advanced. An advanced variable -will not be displayed in any of the cmake GUIs unless the show -advanced option is on. If ``CLEAR`` is the first argument advanced -variables are changed back to unadvanced. If ``FORCE`` is the first -argument, then the variable is made advanced. If neither ``FORCE`` nor -``CLEAR`` is specified, new values will be marked as advanced, but if the -variable already has an advanced/non-advanced state, it will not be -changed. +Sets the advanced/non-advanced state of the named +cached variables. -It does nothing in script mode. +An advanced variable will not be displayed in any +of the cmake GUIs unless the ``show advanced`` option is on. +In script mode, the advanced/non-advanced state has no effect. + +If the keyword ``CLEAR`` is given +then advanced variables are changed back to unadvanced. +If the keyword ``FORCE`` is given +then the variables are made advanced. +If neither ``FORCE`` nor ``CLEAR`` is specified, +new values will be marked as advanced, but if a +variable already has an advanced/non-advanced state, +it will not be changed. diff --git a/Help/command/math.rst b/Help/command/math.rst index 63af931..4fa55f6 100644 --- a/Help/command/math.rst +++ b/Help/command/math.rst @@ -1,30 +1,36 @@ math ---- -Mathematical expressions. +Evaluate a mathematical expression. -:: +.. code-block:: cmake - math(EXPR <output-variable> <math-expression> [OUTPUT_FORMAT <format>]) + math(EXPR <variable> "<expression>" [OUTPUT_FORMAT <format>]) -``EXPR`` evaluates mathematical expression and returns result in the -output variable. Example mathematical expression is ``5 * (10 + 13)``. +Evaluates a mathematical ``<expression>`` and sets ``<variable>`` to the +resulting value. + +The mathematical expression must be given as a string (i.e. enclosed in +double quotation marks). An example is ``"5 * (10 + 13)"``. Supported operators are ``+``, ``-``, ``*``, ``/``, ``%``, ``|``, ``&``, -``^``, ``~``, ``<<``, ``>>``, and ``(...)``. They have the same meaning -as they do in C code. +``^``, ``~``, ``<<``, ``>>``, and ``(...)``; they have the same meaning +as in C code. + +Hexadecimal numbers are recognized when prefixed with "0x", as in C code. -Numeric constants are evaluated in decimal or hexadecimal representation. +The result is formatted according to the option ``OUTPUT_FORMAT``, +where ``<format>`` is one of -The result is formatted according to the option "OUTPUT_FORMAT" , -where ``<format>`` is one of: -:: +``HEXADECIMAL`` + Hexadecimal notation as in C code, i. e. starting with "0x". +``DECIMAL`` + Decimal notation. Which is also used if no ``OUTPUT_FORMAT`` option + is specified. - HEXADECIMAL = Result in output variable will be formatted in C code - Hexadecimal notation. - DECIMAL = Result in output variable will be formatted in decimal notation. +For example -For example:: +.. code-block:: cmake - math(EXPR value "100 * 0xA" DECIMAL) results in value is set to "1000" - math(EXPR value "100 * 0xA" HEXADECIMAL) results in value is set to "0x3e8" + math(EXPR value "100 * 0xA" OUTPUT_FORMAT DECIMAL) # value is set to "1000" + math(EXPR value "100 * 0xA" OUTPUT_FORMAT HEXADECIMAL) # value is set to "0x3e8" diff --git a/Help/command/message.rst b/Help/command/message.rst index 04c62fd..2b4b1aa 100644 --- a/Help/command/message.rst +++ b/Help/command/message.rst @@ -3,7 +3,7 @@ message Display a message to the user. -:: +.. code-block:: cmake message([<mode>] "message to display" ...) diff --git a/Help/command/option.rst b/Help/command/option.rst index 4fabb87..8956307 100644 --- a/Help/command/option.rst +++ b/Help/command/option.rst @@ -1,17 +1,16 @@ option ------ -Provides an option that the user can optionally select. +Provide an option that the user can optionally select. -:: +.. code-block:: cmake - option(<option_variable> "help string describing option" - [initial value]) + option(<variable> "<help_text>" [value]) -Provide an option for the user to select as ``ON`` or ``OFF``. If no -initial value is provided, ``OFF`` is used. If the option is already -set as a normal variable then the command does nothing -(see policy :policy:`CMP0077`). +Provides an option for the user to select as ``ON`` or ``OFF``. +If no initial ``<value>`` is provided, ``OFF`` is used. +If ``<variable>`` is already set as a normal variable +then the command does nothing (see policy :policy:`CMP0077`). If you have options that depend on the values of other options, see the module help for :module:`CMakeDependentOption`. diff --git a/Help/command/output_required_files.rst b/Help/command/output_required_files.rst index 5e13557..8bc6a73 100644 --- a/Help/command/output_required_files.rst +++ b/Help/command/output_required_files.rst @@ -1,7 +1,7 @@ output_required_files --------------------- -Disallowed. See CMake Policy :policy:`CMP0032`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0032`. Approximate C preprocessor dependency scanning. diff --git a/Help/command/qt_wrap_cpp.rst b/Help/command/qt_wrap_cpp.rst index 3843bf5..c04c7a6 100644 --- a/Help/command/qt_wrap_cpp.rst +++ b/Help/command/qt_wrap_cpp.rst @@ -3,10 +3,9 @@ qt_wrap_cpp Create Qt Wrappers. -:: +.. code-block:: cmake - qt_wrap_cpp(resultingLibraryName DestName - SourceLists ...) + qt_wrap_cpp(resultingLibraryName DestName SourceLists ...) -Produce moc files for all the .h files listed in the SourceLists. The +Produces moc files for all the .h files listed in the SourceLists. The moc files will be added to the library using the ``DestName`` source list. diff --git a/Help/command/qt_wrap_ui.rst b/Help/command/qt_wrap_ui.rst index f731ed9..9a8863d 100644 --- a/Help/command/qt_wrap_ui.rst +++ b/Help/command/qt_wrap_ui.rst @@ -3,12 +3,12 @@ qt_wrap_ui Create Qt user interfaces Wrappers. -:: +.. code-block:: cmake qt_wrap_ui(resultingLibraryName HeadersDestName SourcesDestName SourceLists ...) -Produce .h and .cxx files for all the .ui files listed in the +Produces .h and .cxx files for all the .ui files listed in the ``SourceLists``. The .h files will be added to the library using the ``HeadersDestNamesource`` list. The .cxx files will be added to the library using the ``SourcesDestNamesource`` list. diff --git a/Help/command/remove.rst b/Help/command/remove.rst index 4628277..543d016 100644 --- a/Help/command/remove.rst +++ b/Help/command/remove.rst @@ -1,7 +1,9 @@ remove ------ -Deprecated. Use the :command:`list(REMOVE_ITEM)` command instead. +.. deprecated:: 3.0 + + Use the :command:`list(REMOVE_ITEM)` command instead. :: diff --git a/Help/command/remove_definitions.rst b/Help/command/remove_definitions.rst index ea18918..faad16d 100644 --- a/Help/command/remove_definitions.rst +++ b/Help/command/remove_definitions.rst @@ -1,9 +1,9 @@ remove_definitions ------------------ -Removes -D define flags added by :command:`add_definitions`. +Remove -D define flags added by :command:`add_definitions`. -:: +.. code-block:: cmake remove_definitions(-DFOO -DBAR ...) diff --git a/Help/command/return.rst b/Help/command/return.rst index e49fb3c..830992c 100644 --- a/Help/command/return.rst +++ b/Help/command/return.rst @@ -3,7 +3,7 @@ return Return from a file, directory or function. -:: +.. code-block:: cmake return() @@ -14,5 +14,6 @@ and control is returned to the including file. If it is encountered in a file which is not included by another file, e.g. a ``CMakeLists.txt``, control is returned to the parent directory if there is one. If return is called in a function, control is returned to the caller of the function. -Note that a macro is not a function and does not handle return like a -function does. + +Note that a :command:`macro <macro>`, unlike a :command:`function <function>`, +is expanded in place and therefore cannot handle ``return()``. diff --git a/Help/command/separate_arguments.rst b/Help/command/separate_arguments.rst index 47982a5..fbca859 100644 --- a/Help/command/separate_arguments.rst +++ b/Help/command/separate_arguments.rst @@ -1,33 +1,43 @@ separate_arguments ------------------ -Parse space-separated arguments into a semicolon-separated list. +Parse command-line arguments into a semicolon-separated list. -:: +.. code-block:: cmake - separate_arguments(<var> <NATIVE|UNIX|WINDOWS>_COMMAND "<args>") + separate_arguments(<variable> <mode> <args>) -Parses a UNIX- or Windows-style command-line string "<args>" and -stores a semicolon-separated list of the arguments in ``<var>``. The -entire command line must be given in one "<args>" argument. +Parses a space-separated string ``<args>`` into a list of items, +and stores this list in semicolon-separated standard form in ``<variable>``. -The ``UNIX_COMMAND`` mode separates arguments by unquoted whitespace. It -recognizes both single-quote and double-quote pairs. A backslash -escapes the next literal character (``\"`` is ``"``); there are no special -escapes (``\n`` is just ``n``). +This function is intended for parsing command-line arguments. +The entire command line must be passed as one string in the +argument ``<args>``. -The ``WINDOWS_COMMAND`` mode parses a Windows command-line using the same -syntax the runtime library uses to construct argv at startup. It -separates arguments by whitespace that is not double-quoted. -Backslashes are literal unless they precede double-quotes. See the -MSDN article `Parsing C Command-Line Arguments`_ for details. +The exact parsing rules depend on the operating system. +They are specified by the ``<mode>`` argument which must +be one of the following keywords: -The ``NATIVE_COMMAND`` mode parses a Windows command-line if the host -system is Windows, and a UNIX command-line otherwise. +``UNIX_COMMAND`` + Arguments are separated by by unquoted whitespace. + Both single-quote and double-quote pairs are respected. + A backslash escapes the next literal character (``\"`` is ``"``); + there are no special escapes (``\n`` is just ``n``). + +``WINDOWS_COMMAND`` + A Windows command-line is parsed using the same + syntax the runtime library uses to construct argv at startup. It + separates arguments by whitespace that is not double-quoted. + Backslashes are literal unless they precede double-quotes. See the + MSDN article `Parsing C Command-Line Arguments`_ for details. + +``NATIVE_COMMAND`` + Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows. + Otherwise proceeds as in ``UNIX_COMMAND`` mode. .. _`Parsing C Command-Line Arguments`: https://msdn.microsoft.com/library/a1y7w461.aspx -:: +.. code-block:: cmake separate_arguments(<var>) diff --git a/Help/command/set.rst b/Help/command/set.rst index b24ebef..d57b177 100644 --- a/Help/command/set.rst +++ b/Help/command/set.rst @@ -15,11 +15,11 @@ unset. See the :command:`unset` command to unset variables explicitly. Set Normal Variable ^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake set(<variable> <value>... [PARENT_SCOPE]) -Set the given ``<variable>`` in the current function or directory scope. +Sets the given ``<variable>`` in the current function or directory scope. If the ``PARENT_SCOPE`` option is given the variable will be set in the scope above the current scope. Each new directory or function @@ -32,11 +32,11 @@ undefined and if it had a value, it is still that value). Set Cache Entry ^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake set(<variable> <value>... CACHE <type> <docstring> [FORCE]) -Set the given cache ``<variable>`` (cache entry). Since cache entries +Sets the given cache ``<variable>`` (cache entry). Since cache entries are meant to provide user-settable values this does not overwrite existing cache entries by default. Use the ``FORCE`` option to overwrite existing entries. @@ -84,8 +84,8 @@ current working directory and convert it to an absolute path. Set Environment Variable ^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake set(ENV{<variable>} <value>...) -Set the current process environment ``<variable>`` to the given value. +Sets the current process environment ``<variable>`` to the given value. diff --git a/Help/command/set_directory_properties.rst b/Help/command/set_directory_properties.rst index 42e7fd7..cc71522 100644 --- a/Help/command/set_directory_properties.rst +++ b/Help/command/set_directory_properties.rst @@ -1,11 +1,13 @@ set_directory_properties ------------------------ -Set properties of the current directory and subdirectories in key-value pairs. +Set properties of the current directory and subdirectories. -:: +.. code-block:: cmake - set_directory_properties(PROPERTIES prop1 value1 prop2 value2) + set_directory_properties(PROPERTIES prop1 value1 [prop2 value2] ...) + +Sets properties of the current directory and its subdirectories in key-value pairs. See :ref:`Directory Properties` for the list of properties known to CMake and their individual documentation for the behavior of each property. diff --git a/Help/command/set_property.rst b/Help/command/set_property.rst index c89e1ce..2d270ec 100644 --- a/Help/command/set_property.rst +++ b/Help/command/set_property.rst @@ -3,21 +3,22 @@ set_property Set a named property in a given scope. -:: - - set_property(<GLOBAL | - DIRECTORY [dir] | - TARGET [target1 [target2 ...]] | - SOURCE [src1 [src2 ...]] | - INSTALL [file1 [file2 ...]] | - TEST [test1 [test2 ...]] | - CACHE [entry1 [entry2 ...]]> +.. code-block:: cmake + + set_property(<GLOBAL | + DIRECTORY [<dir>] | + TARGET [<target1> ...] | + SOURCE [<src1> ...] | + INSTALL [<file1> ...] | + TEST [<test1> ...] | + CACHE [<entry1> ...] > [APPEND] [APPEND_STRING] - PROPERTY <name> [value1 [value2 ...]]) + PROPERTY <name> [value1 ...]) -Set one property on zero or more objects of a scope. The first -argument determines the scope in which the property is set. It must -be one of the following: +Sets one property on zero or more objects of a scope. + +The first argument determines the scope in which the property is set. +It must be one of the following: ``GLOBAL`` Scope is unique and does not accept a name. diff --git a/Help/command/set_source_files_properties.rst b/Help/command/set_source_files_properties.rst index b4904e8..8538a1e 100644 --- a/Help/command/set_source_files_properties.rst +++ b/Help/command/set_source_files_properties.rst @@ -3,13 +3,13 @@ set_source_files_properties Source files can have properties that affect how they are built. -:: +.. code-block:: cmake set_source_files_properties([file1 [file2 [...]]] PROPERTIES prop1 value1 [prop2 value2 [...]]) -Set properties associated with source files using a key/value paired +Sets properties associated with source files using a key/value paired list. See :ref:`Source File Properties` for the list of properties known to CMake. Source file properties are visible only to targets added in the same directory (CMakeLists.txt). diff --git a/Help/command/set_target_properties.rst b/Help/command/set_target_properties.rst index 7db952d..597be23 100644 --- a/Help/command/set_target_properties.rst +++ b/Help/command/set_target_properties.rst @@ -3,13 +3,13 @@ set_target_properties Targets can have properties that affect how they are built. -:: +.. code-block:: cmake set_target_properties(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...) -Set properties on targets. The syntax for the command is to list all +Sets properties on targets. The syntax for the command is to list all the targets you want to change, and then provide the values you want to set next. You can use any prop value pair you want and extract it later with the :command:`get_property` or :command:`get_target_property` diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst index 3efb165..55fd635 100644 --- a/Help/command/set_tests_properties.rst +++ b/Help/command/set_tests_properties.rst @@ -3,11 +3,11 @@ set_tests_properties Set a property of the tests. -:: +.. code-block:: cmake set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2) -Set a property for the tests. If the test is not found, CMake +Sets a property for the tests. If the test is not found, CMake will report an error. :manual:`Generator expressions <cmake-generator-expressions(7)>` will be expanded the same as supported by the test's :command:`add_test` call. See diff --git a/Help/command/site_name.rst b/Help/command/site_name.rst index e17c1ee..1bcaead 100644 --- a/Help/command/site_name.rst +++ b/Help/command/site_name.rst @@ -3,6 +3,6 @@ site_name Set the given variable to the name of the computer. -:: +.. code-block:: cmake site_name(variable) diff --git a/Help/command/source_group.rst b/Help/command/source_group.rst index 938ca40..6623c98 100644 --- a/Help/command/source_group.rst +++ b/Help/command/source_group.rst @@ -4,7 +4,7 @@ source_group Define a grouping for source files in IDE project generation. There are two different signatures to create source groups. -:: +.. code-block:: cmake source_group(<name> [FILES <src>...] [REGULAR_EXPRESSION <regex>]) source_group(TREE <root> [PREFIX <prefix>] [FILES <src>...]) diff --git a/Help/command/string.rst b/Help/command/string.rst index cc18069..893fb43 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -48,7 +48,7 @@ Search and Replace .. _FIND: -:: +.. code-block:: cmake string(FIND <string> <substring> <output variable> [REVERSE]) @@ -59,7 +59,7 @@ substring. If the substring is not found, a position of -1 is returned. .. _REPLACE: -:: +.. code-block:: cmake string(REPLACE <match_string> <replace_string> <output variable> @@ -73,7 +73,7 @@ Regular Expressions .. _`REGEX MATCH`: -:: +.. code-block:: cmake string(REGEX MATCH <regular_expression> <output variable> <input> [<input>...]) @@ -83,7 +83,7 @@ All ``<input>`` arguments are concatenated before matching. .. _`REGEX MATCHALL`: -:: +.. code-block:: cmake string(REGEX MATCHALL <regular_expression> <output variable> <input> [<input>...]) @@ -94,7 +94,7 @@ All ``<input>`` arguments are concatenated before matching. .. _`REGEX REPLACE`: -:: +.. code-block:: cmake string(REGEX REPLACE <regular_expression> <replace_expression> <output variable> @@ -177,7 +177,7 @@ Manipulation .. _APPEND: -:: +.. code-block:: cmake string(APPEND <string variable> [<input>...]) @@ -185,7 +185,7 @@ Append all the input arguments to the string. .. _PREPEND: -:: +.. code-block:: cmake string(PREPEND <string variable> [<input>...]) @@ -193,7 +193,7 @@ Prepend all the input arguments to the string. .. _CONCAT: -:: +.. code-block:: cmake string(CONCAT <output variable> [<input>...]) @@ -202,7 +202,7 @@ the result in the named output variable. .. _JOIN: -:: +.. code-block:: cmake string(JOIN <glue> <output variable> [<input>...]) @@ -215,7 +215,7 @@ special characters like ``;`` in them. .. _TOLOWER: -:: +.. code-block:: cmake string(TOLOWER <string1> <output variable>) @@ -223,7 +223,7 @@ Convert string to lower characters. .. _TOUPPER: -:: +.. code-block:: cmake string(TOUPPER <string1> <output variable>) @@ -231,7 +231,7 @@ Convert string to upper characters. .. _LENGTH: -:: +.. code-block:: cmake string(LENGTH <string> <output variable>) @@ -239,7 +239,7 @@ Store in an output variable a given string's length. .. _SUBSTRING: -:: +.. code-block:: cmake string(SUBSTRING <string> <begin> <length> <output variable>) @@ -253,7 +253,7 @@ If string is shorter than length then end of string is used instead. .. _STRIP: -:: +.. code-block:: cmake string(STRIP <string> <output variable>) @@ -262,7 +262,7 @@ trailing spaces removed. .. _GENEX_STRIP: -:: +.. code-block:: cmake string(GENEX_STRIP <input string> <output variable>) @@ -274,7 +274,7 @@ Comparison .. _COMPARE: -:: +.. code-block:: cmake string(COMPARE LESS <string1> <string2> <output variable>) string(COMPARE GREATER <string1> <string2> <output variable>) @@ -292,7 +292,7 @@ Hashing .. _`HASH`: -:: +.. code-block:: cmake string(<HASH> <output variable> <input>) @@ -325,7 +325,7 @@ Generation .. _ASCII: -:: +.. code-block:: cmake string(ASCII <number> [<number> ...] <output variable>) @@ -333,7 +333,7 @@ Convert all numbers into corresponding ASCII characters. .. _CONFIGURE: -:: +.. code-block:: cmake string(CONFIGURE <string1> <output variable> [@ONLY] [ESCAPE_QUOTES]) @@ -342,7 +342,7 @@ Transform a string like :command:`configure_file` transforms a file. .. _MAKE_C_IDENTIFIER: -:: +.. code-block:: cmake string(MAKE_C_IDENTIFIER <input string> <output variable>) @@ -353,7 +353,7 @@ the result. .. _RANDOM: -:: +.. code-block:: cmake string(RANDOM [LENGTH <length>] [ALPHABET <alphabet>] [RANDOM_SEED <seed>] <output variable>) @@ -366,7 +366,7 @@ random number generator. .. _TIMESTAMP: -:: +.. code-block:: cmake string(TIMESTAMP <output variable> [<format string>] [UTC]) @@ -421,7 +421,7 @@ If no explicit ``<format string>`` is given it will default to: .. _UUID: -:: +.. code-block:: cmake string(UUID <output variable> NAMESPACE <namespace> NAME <name> TYPE <MD5|SHA1> [UPPER]) diff --git a/Help/command/subdir_depends.rst b/Help/command/subdir_depends.rst index 5676c8f..0c1b3c1 100644 --- a/Help/command/subdir_depends.rst +++ b/Help/command/subdir_depends.rst @@ -1,7 +1,7 @@ subdir_depends -------------- -Disallowed. See CMake Policy :policy:`CMP0029`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0029`. Does nothing. diff --git a/Help/command/subdirs.rst b/Help/command/subdirs.rst index 43b87d4..530951b 100644 --- a/Help/command/subdirs.rst +++ b/Help/command/subdirs.rst @@ -1,7 +1,9 @@ subdirs ------- -Deprecated. Use the :command:`add_subdirectory` command instead. +.. deprecated:: 3.0 + + Use the :command:`add_subdirectory` command instead. Add a list of subdirectories to the build. diff --git a/Help/command/target_compile_definitions.rst b/Help/command/target_compile_definitions.rst index a740117..9e9c690 100644 --- a/Help/command/target_compile_definitions.rst +++ b/Help/command/target_compile_definitions.rst @@ -3,13 +3,13 @@ target_compile_definitions Add compile definitions to a target. -:: +.. code-block:: cmake target_compile_definitions(<target> <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify compile definitions to use when compiling a given ``<target>``. The +Specifies compile definitions to use when compiling a given ``<target>``. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst index bf413bf..9271cd5 100644 --- a/Help/command/target_compile_features.rst +++ b/Help/command/target_compile_features.rst @@ -3,11 +3,11 @@ target_compile_features Add expected compiler features to a target. -:: +.. code-block:: cmake target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...]) -Specify compiler features required when compiling a given target. If the +Specifies compiler features required when compiling a given target. If the feature is not listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable or :variable:`CMAKE_CXX_COMPILE_FEATURES` variable, then an error will be reported by CMake. If the use of the feature requires diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst index 88b7f15..c26c926 100644 --- a/Help/command/target_compile_options.rst +++ b/Help/command/target_compile_options.rst @@ -3,13 +3,13 @@ target_compile_options Add compile options to a target. -:: +.. code-block:: cmake target_compile_options(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify compile options to use when compiling a given target. The +Specifies compile options to use when compiling a given target. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. diff --git a/Help/command/target_include_directories.rst b/Help/command/target_include_directories.rst index e71be64..660e15c 100644 --- a/Help/command/target_include_directories.rst +++ b/Help/command/target_include_directories.rst @@ -3,13 +3,13 @@ target_include_directories Add include directories to a target. -:: +.. code-block:: cmake target_include_directories(<target> [SYSTEM] [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify include directories to use when compiling a given target. +Specifies include directories to use when compiling a given target. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. diff --git a/Help/command/target_link_directories.rst b/Help/command/target_link_directories.rst index b46aac0..76da94d 100644 --- a/Help/command/target_link_directories.rst +++ b/Help/command/target_link_directories.rst @@ -3,13 +3,13 @@ target_link_directories Add link directories to a target. -:: +.. code-block:: cmake target_link_directories(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify the paths in which the linker should search for libraries when +Specifies the paths in which the linker should search for libraries when linking a given target. Each item can be an absolute or relative path, with the latter being interpreted as relative to the current source directory. These items will be added to the link command. diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst index 58f312e..76c0d28 100644 --- a/Help/command/target_link_libraries.rst +++ b/Help/command/target_link_libraries.rst @@ -14,7 +14,9 @@ Overview ^^^^^^^^ This command has several signatures as detailed in subsections below. -All of them have the general form:: +All of them have the general form + +.. code-block:: cmake target_link_libraries(<target> ... <item>... ...) @@ -128,7 +130,7 @@ buildsystem properties. Libraries for a Target and/or its Dependents ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> <item>... @@ -145,7 +147,7 @@ used for linking ``<target>``. Libraries for both a Target and its Dependents ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> <item>...) @@ -163,7 +165,7 @@ exclusively by this signature private. Libraries for a Target and/or its Dependents (Legacy) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> <LINK_PRIVATE|LINK_PUBLIC> <lib>... @@ -185,7 +187,7 @@ made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`. If policy Libraries for Dependents Only (Legacy) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake target_link_libraries(<target> LINK_INTERFACE_LIBRARIES <item>...) diff --git a/Help/command/target_link_options.rst b/Help/command/target_link_options.rst index 8f47180..285455a 100644 --- a/Help/command/target_link_options.rst +++ b/Help/command/target_link_options.rst @@ -3,13 +3,13 @@ target_link_options Add link options to a target. -:: +.. code-block:: cmake target_link_options(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify link options to use when linking a given target. The +Specifies link options to use when linking a given target. The named ``<target>`` must have been created by a command such as :command:`add_executable` or :command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`. @@ -37,6 +37,6 @@ with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem properties. -.. include:: LINK_OPTIONS_LINKER.txt - .. include:: OPTIONS_SHELL.txt + +.. include:: LINK_OPTIONS_LINKER.txt diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst index 5dd8d86..27e737b 100644 --- a/Help/command/target_sources.rst +++ b/Help/command/target_sources.rst @@ -3,13 +3,13 @@ target_sources Add sources to a target. -:: +.. code-block:: cmake target_sources(<target> <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...]) -Specify sources to use when compiling a given target. Relative +Specifies sources to use when compiling a given target. Relative source file paths are interpreted as being relative to the current source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`). The named ``<target>`` must have been created by a command such as diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 66ea3d7..28caa7c 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -10,7 +10,7 @@ Try building some code. Try Compiling Whole Projects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake try_compile(RESULT_VAR <bindir> <srcdir> <projectName> [<targetName>] [CMAKE_FLAGS <flags>...] @@ -28,7 +28,7 @@ below for the meaning of other options. Try Compiling Source Files ^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...> [CMAKE_FLAGS <flags>...] @@ -47,7 +47,9 @@ returned in ``RESULT_VAR``. In this form the user need only supply one or more source files that include a definition for ``main``. CMake will create a ``CMakeLists.txt`` file to build -the source(s) as an executable that looks something like this:: +the source(s) as an executable that looks something like this: + +.. code-block:: cmake add_definitions(<expanded COMPILE_DEFINITIONS from caller>) include_directories(${INCLUDE_DIRECTORIES}) diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst index e3bd57d..dfa0bf9 100644 --- a/Help/command/try_run.rst +++ b/Help/command/try_run.rst @@ -10,7 +10,7 @@ Try compiling and then running some code. Try Compiling and Running Source Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. code-block:: cmake try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR bindir srcfile [CMAKE_FLAGS <flags>...] diff --git a/Help/command/unset.rst b/Help/command/unset.rst index c19dd31..1a5e49f 100644 --- a/Help/command/unset.rst +++ b/Help/command/unset.rst @@ -3,7 +3,7 @@ unset Unset a variable, cache variable, or environment variable. -:: +.. code-block:: cmake unset(<variable> [CACHE | PARENT_SCOPE]) @@ -24,7 +24,7 @@ for further details. ``<variable>`` can be an environment variable such as: -:: +.. code-block:: cmake unset(ENV{LD_LIBRARY_PATH}) diff --git a/Help/command/use_mangled_mesa.rst b/Help/command/use_mangled_mesa.rst index 6f4d7ac..4d9e12b 100644 --- a/Help/command/use_mangled_mesa.rst +++ b/Help/command/use_mangled_mesa.rst @@ -1,7 +1,7 @@ use_mangled_mesa ---------------- -Disallowed. See CMake Policy :policy:`CMP0030`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0030`. Copy mesa headers for use in combination with system GL. diff --git a/Help/command/utility_source.rst b/Help/command/utility_source.rst index ee34492..94d6a4e 100644 --- a/Help/command/utility_source.rst +++ b/Help/command/utility_source.rst @@ -1,7 +1,7 @@ utility_source -------------- -Disallowed. See CMake Policy :policy:`CMP0034`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0034`. Specify the source tree of a third-party utility. diff --git a/Help/command/variable_requires.rst b/Help/command/variable_requires.rst index 9cf9f3f..b4742a5 100644 --- a/Help/command/variable_requires.rst +++ b/Help/command/variable_requires.rst @@ -1,7 +1,7 @@ variable_requires ----------------- -Disallowed. See CMake Policy :policy:`CMP0035`. +Disallowed since version 3.0. See CMake Policy :policy:`CMP0035`. Use the :command:`if` command instead. diff --git a/Help/command/variable_watch.rst b/Help/command/variable_watch.rst index a2df058..ce69bcf 100644 --- a/Help/command/variable_watch.rst +++ b/Help/command/variable_watch.rst @@ -3,11 +3,13 @@ variable_watch Watch the CMake variable for change. -:: +.. code-block:: cmake - variable_watch(<variable name> [<command to execute>]) + variable_watch(<variable> [<command>]) -If the specified variable changes, the message will be printed about -the variable being changed. If the command is specified, the command -will be executed. The command will receive the following arguments: -COMMAND(<variable> <access> <value> <current list file> <stack>) +If the specified ``<variable>`` changes, a message will be printed +to inform about the change. + +Additionally, if ``<command>`` is given, this command will be executed. +The command will receive the following arguments: +``COMMAND(<variable> <access> <value> <current_list_file> <stack>)`` diff --git a/Help/command/while.rst b/Help/command/while.rst index 7509da3..a4957c1 100644 --- a/Help/command/while.rst +++ b/Help/command/while.rst @@ -3,15 +3,23 @@ while Evaluate a group of commands while a condition is true -:: +.. code-block:: cmake - while(condition) - COMMAND1(ARGS ...) - COMMAND2(ARGS ...) - ... - endwhile(condition) + while(<condition>) + <commands> + endwhile() All commands between while and the matching :command:`endwhile` are recorded without being invoked. Once the :command:`endwhile` is evaluated, the -recorded list of commands is invoked as long as the condition is true. The -condition is evaluated using the same logic as the :command:`if` command. +recorded list of commands is invoked as long as the ``<condition>`` is true. + +The ``<condition>`` has the same syntax and is evaluated using the same logic +as described at length for the :command:`if` command. + +The commands :command:`break` and :command:`continue` provide means to +escape from the normal control flow. + +Per legacy, the :command:`endwhile` command admits +an optional ``<condition>`` argument. +If used, it must be a verbatim repeat of the argument of the opening +``while`` command. diff --git a/Help/command/write_file.rst b/Help/command/write_file.rst index 40e7557..4d476bd 100644 --- a/Help/command/write_file.rst +++ b/Help/command/write_file.rst @@ -1,7 +1,9 @@ write_file ---------- -Deprecated. Use the :command:`file(WRITE)` command instead. +.. deprecated:: 3.0 + + Use the :command:`file(WRITE)` command instead. :: diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst index 0cc5fca..aec9ba5 100644 --- a/Help/manual/cmake-commands.7.rst +++ b/Help/manual/cmake-commands.7.rst @@ -145,8 +145,9 @@ These commands are available only in CTest scripts. Deprecated Commands =================== -These commands are available only for compatibility with older -versions of CMake. Do not use them in new code. +These commands are deprecated since CMake version 3.0. +They are available only for backward compatibility. +Do not use them in new code. .. toctree:: :maxdepth: 1 diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 76fd3d9..0826ce0 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -31,7 +31,9 @@ Logical Expressions Logical expressions are used to create conditional output. The basic expressions are the ``0`` and ``1`` expressions. Because other logical expressions evaluate to either ``0`` or ``1``, they can be composed to -create conditional output:: +create conditional output: + +.. code-block:: cmake $<$<CONFIG:Debug>:DEBUG_MODE> @@ -151,14 +153,18 @@ Informational Expressions ========================= These expressions expand to some information. The information may be used -directly, eg:: +directly, eg: + +.. code-block:: cmake include_directories(/usr/include/$<CXX_COMPILER_ID>/) expands to ``/usr/include/GNU/`` or ``/usr/include/Clang/`` etc, depending on the Id of the compiler. -These expressions may also may be combined with logical expressions:: +These expressions may also may be combined with logical expressions: + +.. code-block:: cmake $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,4.2.0>:OLD_COMPILER> @@ -246,18 +252,24 @@ Output Expressions These expressions generate output, in some cases depending on an input. These expressions may be combined with other expressions for information or logical -comparison:: +comparison: + +.. code-block:: cmake -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I> generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target property with each entry preceded by ``-I``. Note that a more-complete use in this situation would require first checking if the INCLUDE_DIRECTORIES -property is non-empty:: +property is non-empty: + +.. code-block:: cmake $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>> -where ``${prop}`` refers to a helper variable:: +where ``${prop}`` refers to a helper variable: + +.. code-block:: cmake set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>") diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index 8740d97..630a86b 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -257,27 +257,31 @@ invocation as exactly one argument. .. No code-block syntax highlighting in the following example (escape \" not supported by our cmake.py) -For example:: +For example: - message("This is a quoted argument containing multiple lines. - This is always one argument even though it contains a ; character. - Both \\-escape sequences and ${variable} references are evaluated. - The text does not end on an escaped double-quote like \". - It does end in an unescaped double quote. - ") +.. code-block:: cmake + + message("This is a quoted argument containing multiple lines. + This is always one argument even though it contains a ; character. + Both \\-escape sequences and ${variable} references are evaluated. + The text does not end on an escaped double-quote like \". + It does end in an unescaped double quote. + ") .. No code-block syntax highlighting in the following example (for conformity with the two above examples) The final ``\`` on any line ending in an odd number of backslashes is treated as a line continuation and ignored along with the -immediately following newline character. For example:: +immediately following newline character. For example: + +.. code-block:: cmake - message("\ - This is the first line of a quoted argument. \ - In fact it is the only line but since it is long \ - the source code uses line continuation.\ - ") + message("\ + This is the first line of a quoted argument. \ + In fact it is the only line but since it is long \ + the source code uses line continuation.\ + ") .. note:: CMake versions prior to 3.0 do not support continuation with ``\``. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 5c3eb81..1651114 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -138,6 +138,7 @@ Properties on Targets /prop_tgt/AUTORCC_OPTIONS /prop_tgt/BINARY_DIR /prop_tgt/BUILD_RPATH + /prop_tgt/BUILD_RPATH_USE_ORIGIN /prop_tgt/BUILD_WITH_INSTALL_NAME_DIR /prop_tgt/BUILD_WITH_INSTALL_RPATH /prop_tgt/BUNDLE_EXTENSION diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9dd36ed..b88c661 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -322,6 +322,7 @@ Variables that Control the Build /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_AUTOUIC_SEARCH_PATHS /variable/CMAKE_BUILD_RPATH + /variable/CMAKE_BUILD_RPATH_USE_ORIGIN /variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR /variable/CMAKE_BUILD_WITH_INSTALL_RPATH /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY diff --git a/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst new file mode 100644 index 0000000..511de7a --- /dev/null +++ b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst @@ -0,0 +1,24 @@ +BUILD_RPATH_USE_ORIGIN +---------------------- + +Whether to use relative paths for the build ``RPATH``. + +This property is initialized by the value of the variable +:variable:`CMAKE_BUILD_RPATH_USE_ORIGIN`. + +On platforms that support runtime paths (``RPATH``) with the +``$ORIGIN`` token, setting this property to ``TRUE`` enables relative +paths in the build ``RPATH`` for executables that point to shared +libraries in the same build tree. + +Normally the build ``RPATH`` of an executable contains absolute paths +to the directory of shared libraries. Directories contained within the +build tree can be made relative to enable relocatable builds and to +help achieving reproducible builds by omitting the build directory +from the build environment. + +This property has no effect on platforms that do not support the +``$ORIGIN`` token in ``RPATH``, or when the :variable:`CMAKE_SKIP_RPATH` +variable is set. The runtime path set through the +:prop_tgt:`BUILD_RPATH` target property is also unaffected by this +property. diff --git a/Help/release/dev/relative-rpath.rst b/Help/release/dev/relative-rpath.rst new file mode 100644 index 0000000..5c62b10 --- /dev/null +++ b/Help/release/dev/relative-rpath.rst @@ -0,0 +1,8 @@ +relative-rpath +-------------- + +* A :variable:`CMAKE_BUILD_RPATH_USE_ORIGIN` variable and corresponding + :prop_tgt:`BUILD_RPATH_USE_ORIGIN` target property were added to + enable use of relative runtime paths (RPATHs). This helps achieving + relocatable and reproducible builds that are invariant of the build + directory. diff --git a/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst b/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst new file mode 100644 index 0000000..e34ede6 --- /dev/null +++ b/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst @@ -0,0 +1,7 @@ +CMAKE_BUILD_RPATH_USE_ORIGIN +---------------------------- + +Whether to use relative paths for the build ``RPATH``. + +This is used to initialize the :prop_tgt:`BUILD_RPATH_USE_ORIGIN` target +property for all targets, see that property for more details. diff --git a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst index 0e52282..321f97e 100644 --- a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst +++ b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst @@ -17,7 +17,7 @@ For example, for ``Clang`` we have: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Xlinker" " ") -Specifying ``"LINKER:-z defs"`` will be transformed in +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Xlinker -z -Xlinker defs``. For ``GNU GCC``: @@ -27,7 +27,7 @@ For ``GNU GCC``: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,") set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") -Specifying ``"LINKER:-z defs"`` will be transformed in ``-Wl,-z,defs``. +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Wl,-z,defs``. And for ``SunPro``: @@ -36,4 +36,4 @@ And for ``SunPro``: set (CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ") set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") -Specifying ``"LINKER:-z defs"`` will be transformed in ``-Qoption ld -z,defs``. +Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Qoption ld -z,defs``. diff --git a/Modules/AddFileDependencies.cmake b/Modules/AddFileDependencies.cmake index 999da95..4a4e645 100644 --- a/Modules/AddFileDependencies.cmake +++ b/Modules/AddFileDependencies.cmake @@ -1,17 +1,18 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# AddFileDependencies -# ------------------- -# -# Add dependencies to a source file. -# -# .. code-block:: cmake -# -# ADD_FILE_DEPENDENCIES(<source> <files>) -# -# Adds the given ``<files>`` to the dependencies of file ``<source>``. +#[=======================================================================[.rst: +AddFileDependencies +------------------- + +Add dependencies to a source file. + +.. code-block:: cmake + + ADD_FILE_DEPENDENCIES(<source> <files>) + +Adds the given ``<files>`` to the dependencies of file ``<source>``. +#]=======================================================================] macro(ADD_FILE_DEPENDENCIES _file) diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake index 4649f35..2bb3128 100644 --- a/Modules/CMakeAddFortranSubdirectory.cmake +++ b/Modules/CMakeAddFortranSubdirectory.cmake @@ -1,46 +1,47 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeAddFortranSubdirectory -# --------------------------- -# -# Use MinGW gfortran from VS if a fortran compiler is not found. -# -# The 'add_fortran_subdirectory' function adds a subdirectory to a -# project that contains a fortran only sub-project. 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 BUILD_SHARED_LIBS is turned on in the project. -# In addition the CMAKE_GNUtoMS option is set to on, so that the MS .lib -# files are created. Usage is as follows: -# -# :: -# -# cmake_add_fortran_subdirectory( -# <subdir> # name of subdirectory -# PROJECT <project_name> # project name in subdir top CMakeLists.txt -# ARCHIVE_DIR <dir> # dir where project places .lib files -# RUNTIME_DIR <dir> # dir where project places .dll files -# LIBRARIES <lib>... # names of library targets to import -# LINK_LIBRARIES # link interface libraries for LIBRARIES -# [LINK_LIBS <lib> <dep>...]... -# CMAKE_COMMAND_LINE ... # extra command line flags to pass to cmake -# NO_EXTERNAL_INSTALL # skip installation of external project -# ) -# -# Relative paths in ARCHIVE_DIR and RUNTIME_DIR are interpreted with -# respect to the build directory corresponding to the source directory -# in which the function is invoked. -# -# Limitations: -# -# NO_EXTERNAL_INSTALL is required for forward compatibility with a -# future version that supports installation of the external project -# binaries during "make install". +#[=======================================================================[.rst: +CMakeAddFortranSubdirectory +--------------------------- + +Use MinGW gfortran from VS if a fortran compiler is not found. + +The 'add_fortran_subdirectory' function adds a subdirectory to a +project that contains a fortran only sub-project. 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 BUILD_SHARED_LIBS is turned on in the project. +In addition the CMAKE_GNUtoMS option is set to on, so that the MS .lib +files are created. Usage is as follows: + +:: + + cmake_add_fortran_subdirectory( + <subdir> # name of subdirectory + PROJECT <project_name> # project name in subdir top CMakeLists.txt + ARCHIVE_DIR <dir> # dir where project places .lib files + RUNTIME_DIR <dir> # dir where project places .dll files + LIBRARIES <lib>... # names of library targets to import + LINK_LIBRARIES # link interface libraries for LIBRARIES + [LINK_LIBS <lib> <dep>...]... + CMAKE_COMMAND_LINE ... # extra command line flags to pass to cmake + NO_EXTERNAL_INSTALL # skip installation of external project + ) + +Relative paths in ARCHIVE_DIR and RUNTIME_DIR are interpreted with +respect to the build directory corresponding to the source directory +in which the function is invoked. + +Limitations: + +NO_EXTERNAL_INSTALL is required for forward compatibility with a +future version that supports installation of the external project +binaries during "make install". +#]=======================================================================] set(_MS_MINGW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) include(CheckLanguage) diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index cbd5ea7..628b541 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeBackwardCompatibilityCXX -# ----------------------------- -# -# define a bunch of backwards compatibility variables -# -# :: -# -# CMAKE_ANSI_CXXFLAGS - flag for ansi c++ -# CMAKE_HAS_ANSI_STRING_STREAM - has <strstream> -# include(TestForANSIStreamHeaders) -# include(CheckIncludeFileCXX) -# include(TestForSTDNamespace) -# include(TestForANSIForScope) +#[=======================================================================[.rst: +CMakeBackwardCompatibilityCXX +----------------------------- + +define a bunch of backwards compatibility variables + +:: + + CMAKE_ANSI_CXXFLAGS - flag for ansi c++ + CMAKE_HAS_ANSI_STRING_STREAM - has <strstream> + include(TestForANSIStreamHeaders) + include(CheckIncludeFileCXX) + include(TestForSTDNamespace) + include(TestForANSIForScope) +#]=======================================================================] if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) # check for some ANSI flags in the CXX compiler if it is not gnu diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 21d3c96..6046d85 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -1,27 +1,28 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeDependentOption -# -------------------- -# -# Macro to provide an option dependent on other options. -# -# 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: -# -# :: -# -# CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON -# "USE_BAR;NOT USE_ZOT" OFF) -# -# 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. +#[=======================================================================[.rst: +CMakeDependentOption +-------------------- + +Macro to provide an option dependent on other options. + +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: + +:: + + CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON + "USE_BAR;NOT USE_ZOT" OFF) + +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. +#]=======================================================================] macro(CMAKE_DEPENDENT_OPTION option doc default depends force) if(${option}_ISSET MATCHES "^${option}_ISSET$") diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index 0264621..9edc309 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -1,35 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeDetermineVSServicePack -# --------------------------- -# -# Deprecated. Do not use. -# -# The functionality of this module has been superseded by the -# :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable that contains -# the compiler version number. -# -# Determine the Visual Studio service pack of the 'cl' in use. -# -# Usage:: -# -# if(MSVC) -# include(CMakeDetermineVSServicePack) -# DetermineVSServicePack( my_service_pack ) -# if( my_service_pack ) -# message(STATUS "Detected: ${my_service_pack}") -# endif() -# endif() -# -# Function DetermineVSServicePack sets the given variable to one of the -# following values or an empty string if unknown:: -# -# vc80, vc80sp1 -# vc90, vc90sp1 -# vc100, vc100sp1 -# vc110, vc110sp1, vc110sp2, vc110sp3, vc110sp4 +#[=======================================================================[.rst: +CMakeDetermineVSServicePack +--------------------------- + +.. deprecated:: 3.0 + + Do not use. + +The functionality of this module has been superseded by the +:variable:`CMAKE_<LANG>_COMPILER_VERSION` variable that contains +the compiler version number. + +Determine the Visual Studio service pack of the 'cl' in use. + +Usage:: + + if(MSVC) + include(CMakeDetermineVSServicePack) + DetermineVSServicePack( my_service_pack ) + if( my_service_pack ) + message(STATUS "Detected: ${my_service_pack}") + endif() + endif() + +Function DetermineVSServicePack sets the given variable to one of the +following values or an empty string if unknown:: + + vc80, vc80sp1 + vc90, vc90sp1 + vc100, vc100sp1 + vc110, vc110sp1, vc110sp2, vc110sp3, vc110sp4 +#]=======================================================================] if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8) message(DEPRECATION @@ -169,4 +172,3 @@ function(DetermineVSServicePack _pack) endif() endif() endfunction() - diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake index 21a3065..ae26cc2 100644 --- a/Modules/CMakeExpandImportedTargets.cmake +++ b/Modules/CMakeExpandImportedTargets.cmake @@ -1,41 +1,44 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeExpandImportedTargets -# -------------------------- -# -# Deprecated. Do not use. -# -# This module was once needed to expand imported targets to the underlying -# libraries they reference on disk for use with the :command:`try_compile` -# and :command:`try_run` commands. These commands now support imported -# libraries in their ``LINK_LIBRARIES`` options (since CMake 2.8.11 -# for :command:`try_compile` and since CMake 3.2 for :command:`try_run`). -# -# This module does not support the policy :policy:`CMP0022` ``NEW`` -# behavior or use of the :prop_tgt:`INTERFACE_LINK_LIBRARIES` property -# because :manual:`generator expressions <cmake-generator-expressions(7)>` -# cannot be evaluated during configuration. -# -# :: -# -# CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN -# [CONFIGURATION <config>]) -# -# CMAKE_EXPAND_IMPORTED_TARGETS() takes a list of libraries and replaces -# all imported targets contained in this list with their actual file -# paths of the referenced libraries on disk, including the libraries -# from their link interfaces. If a CONFIGURATION is given, it uses the -# respective configuration of the imported targets if it exists. If no -# CONFIGURATION is given, it uses the first configuration from -# ${CMAKE_CONFIGURATION_TYPES} if set, otherwise ${CMAKE_BUILD_TYPE}. -# -# :: -# -# cmake_expand_imported_targets(expandedLibs -# LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -# CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" ) +#[=======================================================================[.rst: +CMakeExpandImportedTargets +-------------------------- + +.. deprecated:: 3.4 + + Do not use. + +This module was once needed to expand imported targets to the underlying +libraries they reference on disk for use with the :command:`try_compile` +and :command:`try_run` commands. These commands now support imported +libraries in their ``LINK_LIBRARIES`` options (since CMake 2.8.11 +for :command:`try_compile` and since CMake 3.2 for :command:`try_run`). + +This module does not support the policy :policy:`CMP0022` ``NEW`` +behavior or use of the :prop_tgt:`INTERFACE_LINK_LIBRARIES` property +because :manual:`generator expressions <cmake-generator-expressions(7)>` +cannot be evaluated during configuration. + +:: + + CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN + [CONFIGURATION <config>]) + +CMAKE_EXPAND_IMPORTED_TARGETS() takes a list of libraries and replaces +all imported targets contained in this list with their actual file +paths of the referenced libraries on disk, including the libraries +from their link interfaces. If a CONFIGURATION is given, it uses the +respective configuration of the imported targets if it exists. If no +CONFIGURATION is given, it uses the first configuration from +${CMAKE_CONFIGURATION_TYPES} if set, otherwise ${CMAKE_BUILD_TYPE}. + +:: + + cmake_expand_imported_targets(expandedLibs + LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} + CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" ) +#]=======================================================================] function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) diff --git a/Modules/CMakeFindFrameworks.cmake b/Modules/CMakeFindFrameworks.cmake index 6c4c527..06c05fb 100644 --- a/Modules/CMakeFindFrameworks.cmake +++ b/Modules/CMakeFindFrameworks.cmake @@ -1,15 +1,16 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeFindFrameworks -# ------------------- -# -# helper module to find OSX frameworks -# -# This module reads hints about search locations from variables:: -# -# CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories +#[=======================================================================[.rst: +CMakeFindFrameworks +------------------- + +helper module to find OSX frameworks + +This module reads hints about search locations from variables:: + + CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories +#]=======================================================================] if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index ec3652c..815dfc9 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -1,33 +1,34 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeFindPackageMode -# -------------------- -# -# -# -# This file is executed by cmake when invoked with --find-package. It -# expects that the following variables are set using -D: -# -# ``NAME`` -# name of the package -# ``COMPILER_ID`` -# the CMake compiler ID for which the result is, -# i.e. GNU/Intel/Clang/MSVC, etc. -# ``LANGUAGE`` -# language for which the result will be used, -# i.e. C/CXX/Fortran/ASM -# ``MODE`` -# ``EXIST`` -# only check for existence of the given package -# ``COMPILE`` -# print the flags needed for compiling an object file which uses -# the given package -# ``LINK`` -# print the flags needed for linking when using the given package -# ``QUIET`` -# if TRUE, don't print anything +#[=======================================================================[.rst: +CMakeFindPackageMode +-------------------- + + + +This file is executed by cmake when invoked with --find-package. It +expects that the following variables are set using -D: + +``NAME`` + name of the package +``COMPILER_ID`` + the CMake compiler ID for which the result is, + i.e. GNU/Intel/Clang/MSVC, etc. +``LANGUAGE`` + language for which the result will be used, + i.e. C/CXX/Fortran/ASM +``MODE`` + ``EXIST`` + only check for existence of the given package + ``COMPILE`` + print the flags needed for compiling an object file which uses + the given package + ``LINK`` + print the flags needed for linking when using the given package +``QUIET`` + if TRUE, don't print anything +#]=======================================================================] if(NOT NAME) message(FATAL_ERROR "Name of the package to be searched not specified. Set the CMake variable NAME, e.g. -DNAME=JPEG .") diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index 1bc80fd..7ac09dc 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -1,69 +1,72 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeForceCompiler -# ------------------ -# -# Deprecated. Do not use. -# -# The macros provided by this module were once intended for use by -# cross-compiling toolchain files when CMake was not able to automatically -# detect the compiler identification. Since the introduction of this module, -# CMake's compiler identification capabilities have improved and can now be -# taught to recognize any compiler. Furthermore, the suite of information -# CMake detects from a compiler is now too extensive to be provided by -# toolchain files using these macros. -# -# One common use case for this module was to skip CMake's checks for a -# working compiler when using a cross-compiler that cannot link binaries -# without special flags or custom linker scripts. This case is now supported -# by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the -# toolchain file instead. -# -# ------------------------------------------------------------------------- -# -# Macro CMAKE_FORCE_C_COMPILER has the following signature: -# -# :: -# -# CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>) -# -# It sets CMAKE_C_COMPILER to the given compiler and the cmake internal -# variable CMAKE_C_COMPILER_ID to the given compiler-id. It also -# bypasses the check for working compiler and basic compiler information -# tests. -# -# Macro CMAKE_FORCE_CXX_COMPILER has the following signature: -# -# :: -# -# CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>) -# -# It sets CMAKE_CXX_COMPILER to the given compiler and the cmake -# internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id. It -# also bypasses the check for working compiler and basic compiler -# information tests. -# -# Macro CMAKE_FORCE_Fortran_COMPILER has the following signature: -# -# :: -# -# CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>) -# -# It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake -# internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id. -# It also bypasses the check for working compiler and basic compiler -# information tests. -# -# So a simple toolchain file could look like this: -# -# :: -# -# include (CMakeForceCompiler) -# set(CMAKE_SYSTEM_NAME Generic) -# CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross) -# CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross) +#[=======================================================================[.rst: +CMakeForceCompiler +------------------ + +.. deprecated:: 3.6 + + Do not use. + +The macros provided by this module were once intended for use by +cross-compiling toolchain files when CMake was not able to automatically +detect the compiler identification. Since the introduction of this module, +CMake's compiler identification capabilities have improved and can now be +taught to recognize any compiler. Furthermore, the suite of information +CMake detects from a compiler is now too extensive to be provided by +toolchain files using these macros. + +One common use case for this module was to skip CMake's checks for a +working compiler when using a cross-compiler that cannot link binaries +without special flags or custom linker scripts. This case is now supported +by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the +toolchain file instead. + +------------------------------------------------------------------------- + +Macro CMAKE_FORCE_C_COMPILER has the following signature: + +:: + + CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>) + +It sets CMAKE_C_COMPILER to the given compiler and the cmake internal +variable CMAKE_C_COMPILER_ID to the given compiler-id. It also +bypasses the check for working compiler and basic compiler information +tests. + +Macro CMAKE_FORCE_CXX_COMPILER has the following signature: + +:: + + CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>) + +It sets CMAKE_CXX_COMPILER to the given compiler and the cmake +internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id. It +also bypasses the check for working compiler and basic compiler +information tests. + +Macro CMAKE_FORCE_Fortran_COMPILER has the following signature: + +:: + + CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>) + +It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake +internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id. +It also bypasses the check for working compiler and basic compiler +information tests. + +So a simple toolchain file could look like this: + +:: + + include (CMakeForceCompiler) + set(CMAKE_SYSTEM_NAME Generic) + CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross) + CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross) +#]=======================================================================] macro(CMAKE_FORCE_C_COMPILER compiler id) message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated. " diff --git a/Modules/CMakeGraphVizOptions.cmake b/Modules/CMakeGraphVizOptions.cmake index 0d7f1d9..1911e73 100644 --- a/Modules/CMakeGraphVizOptions.cmake +++ b/Modules/CMakeGraphVizOptions.cmake @@ -1,122 +1,123 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeGraphVizOptions -# -------------------- -# -# The builtin graphviz support of CMake. -# -# Variables specific to the graphviz support -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# CMake -# can generate `graphviz <http://www.graphviz.org/>`_ files, showing the dependencies between the -# targets in a project and also external libraries which are linked -# against. When CMake is run with the ``--graphviz=foo.dot`` option, it will -# produce: -# -# * a ``foo.dot`` file showing all dependencies in the project -# * a ``foo.dot.<target>`` file for each target, file showing on which other targets the respective target depends -# * a ``foo.dot.<target>.dependers`` file, showing which other targets depend on the respective target -# -# The different dependency types ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` -# are represented as solid, dashed and dotted edges. -# -# This can result in huge graphs. Using the file -# ``CMakeGraphVizOptions.cmake`` the look and content of the generated -# graphs can be influenced. This file is searched first in -# :variable:`CMAKE_BINARY_DIR` and then in :variable:`CMAKE_SOURCE_DIR`. If found, it is -# read and the variables set in it are used to adjust options for the -# generated graphviz files. -# -# .. variable:: GRAPHVIZ_GRAPH_TYPE -# -# The graph type. -# -# * Mandatory : NO -# * Default : "digraph" -# -# Valid graph types are: -# -# * "graph" : Nodes are joined with lines -# * "digraph" : Nodes are joined with arrows showing direction -# * "strict graph" : Like "graph" but max one line between each node -# * "strict digraph" : Like "graph" but max one line between each node in each direction -# -# .. variable:: GRAPHVIZ_GRAPH_NAME -# -# The graph name. -# -# * Mandatory : NO -# * Default : "GG" -# -# .. variable:: GRAPHVIZ_GRAPH_HEADER -# -# The header written at the top of the graphviz file. -# -# * Mandatory : NO -# * Default : "node [n fontsize = "12"];" -# -# .. variable:: GRAPHVIZ_NODE_PREFIX -# -# The prefix for each node in the graphviz file. -# -# * Mandatory : NO -# * Default : "node" -# -# .. variable:: GRAPHVIZ_EXECUTABLES -# -# Set this to FALSE to exclude executables from the generated graphs. -# -# * Mandatory : NO -# * Default : TRUE -# -# .. variable:: GRAPHVIZ_STATIC_LIBS -# -# Set this to FALSE to exclude static libraries from the generated graphs. -# -# * Mandatory : NO -# * Default : TRUE -# -# .. variable:: GRAPHVIZ_SHARED_LIBS -# -# Set this to FALSE to exclude shared libraries from the generated graphs. -# -# * Mandatory : NO -# * Default : TRUE -# -# .. variable:: GRAPHVIZ_MODULE_LIBS -# -# Set this to FALSE to exclude module libraries from the generated graphs. -# -# * Mandatory : NO -# * Default : TRUE -# -# .. variable:: GRAPHVIZ_EXTERNAL_LIBS -# -# Set this to FALSE to exclude external libraries from the generated graphs. -# -# * Mandatory : NO -# * Default : TRUE -# -# .. variable:: GRAPHVIZ_IGNORE_TARGETS -# -# A list of regular expressions for ignoring targets. -# -# * Mandatory : NO -# * Default : empty -# -# .. variable:: GRAPHVIZ_GENERATE_PER_TARGET -# -# Set this to FALSE to exclude per target graphs ``foo.dot.<target>``. -# -# * Mandatory : NO -# * Default : TRUE -# -# .. variable:: GRAPHVIZ_GENERATE_DEPENDERS -# -# Set this to FALSE to exclude depender graphs ``foo.dot.<target>.dependers``. -# -# * Mandatory : NO -# * Default : TRUE +#[=======================================================================[.rst: +CMakeGraphVizOptions +-------------------- + +The builtin graphviz support of CMake. + +Variables specific to the graphviz support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +CMake +can generate `graphviz <http://www.graphviz.org/>`_ files, showing the dependencies between the +targets in a project and also external libraries which are linked +against. When CMake is run with the ``--graphviz=foo.dot`` option, it will +produce: + +* a ``foo.dot`` file showing all dependencies in the project +* a ``foo.dot.<target>`` file for each target, file showing on which other targets the respective target depends +* a ``foo.dot.<target>.dependers`` file, showing which other targets depend on the respective target + +The different dependency types ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` +are represented as solid, dashed and dotted edges. + +This can result in huge graphs. Using the file +``CMakeGraphVizOptions.cmake`` the look and content of the generated +graphs can be influenced. This file is searched first in +:variable:`CMAKE_BINARY_DIR` and then in :variable:`CMAKE_SOURCE_DIR`. If found, it is +read and the variables set in it are used to adjust options for the +generated graphviz files. + +.. variable:: GRAPHVIZ_GRAPH_TYPE + + The graph type. + + * Mandatory : NO + * Default : "digraph" + + Valid graph types are: + + * "graph" : Nodes are joined with lines + * "digraph" : Nodes are joined with arrows showing direction + * "strict graph" : Like "graph" but max one line between each node + * "strict digraph" : Like "graph" but max one line between each node in each direction + +.. variable:: GRAPHVIZ_GRAPH_NAME + + The graph name. + + * Mandatory : NO + * Default : "GG" + +.. variable:: GRAPHVIZ_GRAPH_HEADER + + The header written at the top of the graphviz file. + + * Mandatory : NO + * Default : "node [n fontsize = "12"];" + +.. variable:: GRAPHVIZ_NODE_PREFIX + + The prefix for each node in the graphviz file. + + * Mandatory : NO + * Default : "node" + +.. variable:: GRAPHVIZ_EXECUTABLES + + Set this to FALSE to exclude executables from the generated graphs. + + * Mandatory : NO + * Default : TRUE + +.. variable:: GRAPHVIZ_STATIC_LIBS + + Set this to FALSE to exclude static libraries from the generated graphs. + + * Mandatory : NO + * Default : TRUE + +.. variable:: GRAPHVIZ_SHARED_LIBS + + Set this to FALSE to exclude shared libraries from the generated graphs. + + * Mandatory : NO + * Default : TRUE + +.. variable:: GRAPHVIZ_MODULE_LIBS + + Set this to FALSE to exclude module libraries from the generated graphs. + + * Mandatory : NO + * Default : TRUE + +.. variable:: GRAPHVIZ_EXTERNAL_LIBS + + Set this to FALSE to exclude external libraries from the generated graphs. + + * Mandatory : NO + * Default : TRUE + +.. variable:: GRAPHVIZ_IGNORE_TARGETS + + A list of regular expressions for ignoring targets. + + * Mandatory : NO + * Default : empty + +.. variable:: GRAPHVIZ_GENERATE_PER_TARGET + + Set this to FALSE to exclude per target graphs ``foo.dot.<target>``. + + * Mandatory : NO + * Default : TRUE + +.. variable:: GRAPHVIZ_GENERATE_DEPENDERS + + Set this to FALSE to exclude depender graphs ``foo.dot.<target>.dependers``. + + * Mandatory : NO + * Default : TRUE +#]=======================================================================] diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index d5301d7..bcc9bf8 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -1,209 +1,210 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakePackageConfigHelpers -# ------------------------- -# -# Helpers functions for creating config files that can be included by other -# projects to find and use a package. -# -# Adds the :command:`configure_package_config_file()` and -# :command:`write_basic_package_version_file()` commands. -# -# Generating a Package Configuration File -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# .. command:: configure_package_config_file -# -# Create a config file for a project:: -# -# configure_package_config_file(<input> <output> -# INSTALL_DESTINATION <path> -# [PATH_VARS <var1> <var2> ... <varN>] -# [NO_SET_AND_CHECK_MACRO] -# [NO_CHECK_REQUIRED_COMPONENTS_MACRO] -# [INSTALL_PREFIX <path>] -# ) -# -# ``configure_package_config_file()`` should be used instead of the plain -# :command:`configure_file()` command when creating the ``<PackageName>Config.cmake`` -# or ``<PackageName>-config.cmake`` file for installing a project or library. -# It helps making the resulting package relocatable by avoiding hardcoded paths -# in the installed ``Config.cmake`` file. -# -# In a ``FooConfig.cmake`` file there may be code like this to make the install -# destinations know to the using project: -# -# .. code-block:: cmake -# -# 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@" ) -# -# 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 ``installedPrefix`` is correct, and if ``CONFIG_INSTALL_DIR`` -# contains a relative path, which in general cannot be guaranteed. This has the -# effect that the resulting ``FooConfig.cmake`` 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 -# :variable:`CMAKE_INSTALL_PREFIX` was set at build/cmake time. -# -# Using ``configure_package_config_file`` helps. If used correctly, it makes -# the resulting ``FooConfig.cmake`` file relocatable. Usage: -# -# 1. write a ``FooConfig.cmake.in`` file as you are used to -# 2. insert a line containing only the string ``@PACKAGE_INIT@`` -# 3. instead of ``set(FOO_DIR "@SOME_INSTALL_DIR@")``, use -# ``set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")`` (this must be after the -# ``@PACKAGE_INIT@`` line) -# 4. instead of using the normal :command:`configure_file()`, use -# ``configure_package_config_file()`` -# -# -# -# The ``<input>`` and ``<output>`` arguments are the input and output file, the -# same way as in :command:`configure_file()`. -# -# The ``<path>`` given to ``INSTALL_DESTINATION`` must be the destination where -# the ``FooConfig.cmake`` file will be installed to. This path can either be -# absolute, or relative to the ``INSTALL_PREFIX`` path. -# -# The variables ``<var1>`` to ``<varN>`` given as ``PATH_VARS`` are the -# variables which contain install destinations. For each of them the macro will -# create a helper variable ``PACKAGE_<var...>``. These helper variables must be -# used in the ``FooConfig.cmake.in`` file for setting the installed location. -# They are calculated by ``configure_package_config_file`` 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 ``INSTALL_PREFIX``. -# -# If the ``INSTALL_PREFIX`` argument is passed, this is used as base path to -# calculate all the relative paths. The ``<path>`` argument must be an absolute -# path. If this argument is not passed, the :variable:`CMAKE_INSTALL_PREFIX` -# 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. -# -# By default ``configure_package_config_file`` also generates two helper macros, -# ``set_and_check()`` and ``check_required_components()`` into the -# ``FooConfig.cmake`` file. -# -# ``set_and_check()`` should be used instead of the normal ``set()`` 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 ``FATAL_ERROR`` otherwise. This makes sure that the created -# ``FooConfig.cmake`` file does not contain wrong references. -# When using the ``NO_SET_AND_CHECK_MACRO``, this macro is not generated -# into the ``FooConfig.cmake`` file. -# -# ``check_required_components(<PackageName>)`` should be called at the end of -# the ``FooConfig.cmake`` file. This macro checks whether all requested, -# non-optional components have been found, and if this is not the case, sets -# the ``Foo_FOUND`` variable to ``FALSE``, so that the package is considered to -# be not found. It does that by testing the ``Foo_<Component>_FOUND`` -# variables for all requested required components. This macro should be -# called even if the package doesn't provide any components to make sure -# users are not specifying components erroneously. When using the -# ``NO_CHECK_REQUIRED_COMPONENTS_MACRO`` option, this macro is not generated -# into the ``FooConfig.cmake`` file. -# -# For an example see below the documentation for -# :command:`write_basic_package_version_file()`. -# -# Generating a Package Version File -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# .. command:: write_basic_package_version_file -# -# Create a version file for a project:: -# -# write_basic_package_version_file(<filename> -# [VERSION <major.minor.patch>] -# COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion> ) -# -# -# Writes a file for use as ``<PackageName>ConfigVersion.cmake`` file to -# ``<filename>``. See the documentation of :command:`find_package()` for -# details on this. -# -# ``<filename>`` is the output filename, it should be in the build tree. -# ``<major.minor.patch>`` is the version number of the project to be installed. -# -# If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable is used. -# If this hasn't been set, it errors out. -# -# The ``COMPATIBILITY`` mode ``AnyNewerVersion`` 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 ``SameMajorVersion`` is used instead, then the behaviour differs from -# ``AnyNewerVersion`` 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 ``SameMinorVersion`` is used, the behaviour is the same as -# ``SameMajorVersion``, 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 ``ExactVersion`` 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 ``ConfigVersion.cmake`` file instead of using this -# macro. -# -# Internally, this macro executes :command:`configure_file()` to create the -# resulting version file. Depending on the ``COMPATIBILITY``, the corresponding -# ``BasicConfigVersion-<COMPATIBILITY>.cmake.in`` file is used. -# Please note that these files are internal to CMake and you should not call -# :command:`configure_file()` on them yourself, but they can be used as starting -# point to create more sophisticted custom ``ConfigVersion.cmake`` files. -# -# Example Generating Package Files -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# Example using both :command:`configure_package_config_file` and -# ``write_basic_package_version_file()``: -# -# ``CMakeLists.txt``: -# -# .. code-block:: cmake -# -# 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 ) -# -# ``FooConfig.cmake.in``: -# -# :: -# -# 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) +#[=======================================================================[.rst: +CMakePackageConfigHelpers +------------------------- + +Helpers functions for creating config files that can be included by other +projects to find and use a package. + +Adds the :command:`configure_package_config_file()` and +:command:`write_basic_package_version_file()` commands. + +Generating a Package Configuration File +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. command:: configure_package_config_file + + Create a config file for a project:: + + configure_package_config_file(<input> <output> + INSTALL_DESTINATION <path> + [PATH_VARS <var1> <var2> ... <varN>] + [NO_SET_AND_CHECK_MACRO] + [NO_CHECK_REQUIRED_COMPONENTS_MACRO] + [INSTALL_PREFIX <path>] + ) + +``configure_package_config_file()`` should be used instead of the plain +:command:`configure_file()` command when creating the ``<PackageName>Config.cmake`` +or ``<PackageName>-config.cmake`` file for installing a project or library. +It helps making the resulting package relocatable by avoiding hardcoded paths +in the installed ``Config.cmake`` file. + +In a ``FooConfig.cmake`` file there may be code like this to make the install +destinations know to the using project: + +.. code-block:: cmake + + 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@" ) + +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 ``installedPrefix`` is correct, and if ``CONFIG_INSTALL_DIR`` +contains a relative path, which in general cannot be guaranteed. This has the +effect that the resulting ``FooConfig.cmake`` 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 +:variable:`CMAKE_INSTALL_PREFIX` was set at build/cmake time. + +Using ``configure_package_config_file`` helps. If used correctly, it makes +the resulting ``FooConfig.cmake`` file relocatable. Usage: + +1. write a ``FooConfig.cmake.in`` file as you are used to +2. insert a line containing only the string ``@PACKAGE_INIT@`` +3. instead of ``set(FOO_DIR "@SOME_INSTALL_DIR@")``, use + ``set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")`` (this must be after the + ``@PACKAGE_INIT@`` line) +4. instead of using the normal :command:`configure_file()`, use + ``configure_package_config_file()`` + + + +The ``<input>`` and ``<output>`` arguments are the input and output file, the +same way as in :command:`configure_file()`. + +The ``<path>`` given to ``INSTALL_DESTINATION`` must be the destination where +the ``FooConfig.cmake`` file will be installed to. This path can either be +absolute, or relative to the ``INSTALL_PREFIX`` path. + +The variables ``<var1>`` to ``<varN>`` given as ``PATH_VARS`` are the +variables which contain install destinations. For each of them the macro will +create a helper variable ``PACKAGE_<var...>``. These helper variables must be +used in the ``FooConfig.cmake.in`` file for setting the installed location. +They are calculated by ``configure_package_config_file`` 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 ``INSTALL_PREFIX``. + +If the ``INSTALL_PREFIX`` argument is passed, this is used as base path to +calculate all the relative paths. The ``<path>`` argument must be an absolute +path. If this argument is not passed, the :variable:`CMAKE_INSTALL_PREFIX` +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. + +By default ``configure_package_config_file`` also generates two helper macros, +``set_and_check()`` and ``check_required_components()`` into the +``FooConfig.cmake`` file. + +``set_and_check()`` should be used instead of the normal ``set()`` 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 ``FATAL_ERROR`` otherwise. This makes sure that the created +``FooConfig.cmake`` file does not contain wrong references. +When using the ``NO_SET_AND_CHECK_MACRO``, this macro is not generated +into the ``FooConfig.cmake`` file. + +``check_required_components(<PackageName>)`` should be called at the end of +the ``FooConfig.cmake`` file. This macro checks whether all requested, +non-optional components have been found, and if this is not the case, sets +the ``Foo_FOUND`` variable to ``FALSE``, so that the package is considered to +be not found. It does that by testing the ``Foo_<Component>_FOUND`` +variables for all requested required components. This macro should be +called even if the package doesn't provide any components to make sure +users are not specifying components erroneously. When using the +``NO_CHECK_REQUIRED_COMPONENTS_MACRO`` option, this macro is not generated +into the ``FooConfig.cmake`` file. + +For an example see below the documentation for +:command:`write_basic_package_version_file()`. + +Generating a Package Version File +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. command:: write_basic_package_version_file + + Create a version file for a project:: + + write_basic_package_version_file(<filename> + [VERSION <major.minor.patch>] + COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion> ) + + +Writes a file for use as ``<PackageName>ConfigVersion.cmake`` file to +``<filename>``. See the documentation of :command:`find_package()` for +details on this. + +``<filename>`` is the output filename, it should be in the build tree. +``<major.minor.patch>`` is the version number of the project to be installed. + +If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable is used. +If this hasn't been set, it errors out. + +The ``COMPATIBILITY`` mode ``AnyNewerVersion`` 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 ``SameMajorVersion`` is used instead, then the behaviour differs from +``AnyNewerVersion`` 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 ``SameMinorVersion`` is used, the behaviour is the same as +``SameMajorVersion``, 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 ``ExactVersion`` 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 ``ConfigVersion.cmake`` file instead of using this +macro. + +Internally, this macro executes :command:`configure_file()` to create the +resulting version file. Depending on the ``COMPATIBILITY``, the corresponding +``BasicConfigVersion-<COMPATIBILITY>.cmake.in`` file is used. +Please note that these files are internal to CMake and you should not call +:command:`configure_file()` on them yourself, but they can be used as starting +point to create more sophisticted custom ``ConfigVersion.cmake`` files. + +Example Generating Package Files +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Example using both :command:`configure_package_config_file` and +``write_basic_package_version_file()``: + +``CMakeLists.txt``: + +.. code-block:: cmake + + 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 ) + +``FooConfig.cmake.in``: + +:: + + 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) +#]=======================================================================] include(WriteBasicConfigVersionFile) diff --git a/Modules/CMakeParseArguments.cmake b/Modules/CMakeParseArguments.cmake index 7ee2bba..c753b7f 100644 --- a/Modules/CMakeParseArguments.cmake +++ b/Modules/CMakeParseArguments.cmake @@ -1,11 +1,12 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeParseArguments -# ------------------- -# -# This module once implemented the :command:`cmake_parse_arguments` command -# that is now implemented natively by CMake. It is now an empty placeholder -# for compatibility with projects that include it to get the command from -# CMake 3.4 and lower. +#[=======================================================================[.rst: +CMakeParseArguments +------------------- + +This module once implemented the :command:`cmake_parse_arguments` command +that is now implemented natively by CMake. It is now an empty placeholder +for compatibility with projects that include it to get the command from +CMake 3.4 and lower. +#]=======================================================================] diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake index 21c333e..d5bbb4f 100644 --- a/Modules/CMakePrintHelpers.cmake +++ b/Modules/CMakePrintHelpers.cmake @@ -1,43 +1,44 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakePrintHelpers -# ----------------- -# -# Convenience macros for printing properties and variables, useful e.g. for debugging. -# -# :: -# -# CMAKE_PRINT_PROPERTIES([TARGETS target1 .. targetN] -# [SOURCES source1 .. sourceN] -# [DIRECTORIES dir1 .. dirN] -# [TESTS test1 .. testN] -# [CACHE_ENTRIES entry1 .. entryN] -# PROPERTIES prop1 .. propN ) -# -# This macro 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:: -# -# cmake_print_properties(TARGETS foo bar PROPERTIES -# LOCATION INTERFACE_INCLUDE_DIRS) -# -# This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for -# both targets foo and bar. -# -# -# -# CMAKE_PRINT_VARIABLES(var1 var2 .. varN) -# -# This macro will print the name of each variable followed by its value. -# Example:: -# -# cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION DOES_NOT_EXIST) -# -# Gives:: -# -# -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST="" +#[=======================================================================[.rst: +CMakePrintHelpers +----------------- + +Convenience macros for printing properties and variables, useful e.g. for debugging. + +:: + + CMAKE_PRINT_PROPERTIES([TARGETS target1 .. targetN] + [SOURCES source1 .. sourceN] + [DIRECTORIES dir1 .. dirN] + [TESTS test1 .. testN] + [CACHE_ENTRIES entry1 .. entryN] + PROPERTIES prop1 .. propN ) + +This macro 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:: + + cmake_print_properties(TARGETS foo bar PROPERTIES + LOCATION INTERFACE_INCLUDE_DIRS) + +This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for +both targets foo and bar. + + + +CMAKE_PRINT_VARIABLES(var1 var2 .. varN) + +This macro will print the name of each variable followed by its value. +Example:: + + cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION DOES_NOT_EXIST) + +Gives:: + + -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST="" +#]=======================================================================] function(CMAKE_PRINT_VARIABLES) set(msg "") diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake index e74c801..f873a4d 100644 --- a/Modules/CMakePrintSystemInformation.cmake +++ b/Modules/CMakePrintSystemInformation.cmake @@ -1,14 +1,15 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakePrintSystemInformation -# --------------------------- -# -# print system information -# -# This file can be used for diagnostic purposes just include it in a -# project to see various internal CMake variables. +#[=======================================================================[.rst: +CMakePrintSystemInformation +--------------------------- + +print system information + +This file can be used for diagnostic purposes just include it in a +project to see various internal CMake variables. +#]=======================================================================] message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}") message("CMAKE_SYSTEM file is ${CMAKE_SYSTEM_INFO_FILE}") diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake index 98eea05..7628d1a 100644 --- a/Modules/CMakePushCheckState.cmake +++ b/Modules/CMakePushCheckState.cmake @@ -1,40 +1,41 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakePushCheckState -# ------------------- -# -# -# -# This module defines three macros: CMAKE_PUSH_CHECK_STATE() -# CMAKE_POP_CHECK_STATE() and CMAKE_RESET_CHECK_STATE() These macros can -# be used to save, restore and reset (i.e., clear contents) the state of -# the variables CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, -# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_INCLUDES and CMAKE_EXTRA_INCLUDE_FILES -# used by the various Check-files coming with CMake, like e.g. -# check_function_exists() 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. -# -# CMAKE_PUSH_CHECK_STATE() macro receives optional argument RESET. -# Whether it's specified, CMAKE_PUSH_CHECK_STATE() will set all -# CMAKE_REQUIRED_* variables to empty values, same as -# CMAKE_RESET_CHECK_STATE() call will do. -# -# Usage: -# -# :: -# -# 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() +#[=======================================================================[.rst: +CMakePushCheckState +------------------- + + + +This module defines three macros: CMAKE_PUSH_CHECK_STATE() +CMAKE_POP_CHECK_STATE() and CMAKE_RESET_CHECK_STATE() These macros can +be used to save, restore and reset (i.e., clear contents) the state of +the variables CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, +CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_INCLUDES and CMAKE_EXTRA_INCLUDE_FILES +used by the various Check-files coming with CMake, like e.g. +check_function_exists() 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. + +CMAKE_PUSH_CHECK_STATE() macro receives optional argument RESET. +Whether it's specified, CMAKE_PUSH_CHECK_STATE() will set all +CMAKE_REQUIRED_* variables to empty values, same as +CMAKE_RESET_CHECK_STATE() call will do. + +Usage: + +:: + + 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() +#]=======================================================================] macro(CMAKE_RESET_CHECK_STATE) diff --git a/Modules/CMakeVerifyManifest.cmake b/Modules/CMakeVerifyManifest.cmake index c477ab1..705ef8a 100644 --- a/Modules/CMakeVerifyManifest.cmake +++ b/Modules/CMakeVerifyManifest.cmake @@ -1,22 +1,23 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CMakeVerifyManifest -# ------------------- -# -# -# -# CMakeVerifyManifest.cmake -# -# 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. +#[=======================================================================[.rst: +CMakeVerifyManifest +------------------- + + + +CMakeVerifyManifest.cmake + +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. +#]=======================================================================] # This script first recursively globs *.manifest files from # the current directory. Then globs *.exe and *.dll. Each diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index a0d9935..211d767 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -1,313 +1,314 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CPackComponent -# -------------- -# -# Build binary and source package installers -# -# Variables concerning CPack Components -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The CPackComponent module is the module which handles the component -# part of CPack. See CPack module for general information about CPack. -# -# 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's 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. -# -# 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's INSTALL -# commands, and should be further described by the following CPack -# commands: -# -# .. variable:: CPACK_COMPONENTS_ALL -# -# The list of component to install. -# -# 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. -# -# 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 :command:`get_cmake_property` command can be used to obtain the -# ``COMPONENTS`` property, then the :command:`list(REMOVE_ITEM)` command can be -# used to remove the unwanted ones. For example, to use all defined components -# except ``foo`` and ``bar``:: -# -# get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) -# list(REMOVE_ITEM CPACK_COMPONENTS_ALL "foo" "bar") -# -# .. variable:: CPACK_<GENNAME>_COMPONENT_INSTALL -# -# Enable/Disable component install for CPack generator <GENNAME>. -# -# 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. -# -# .. variable:: CPACK_COMPONENTS_GROUPING -# -# Specify how components are grouped for multi-package component-aware CPack -# generators. -# -# 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: -# -# * ONE_PER_GROUP (default): creates one package file per component group -# * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) components -# * IGNORE : creates one package per component, i.e. IGNORE component group -# -# One can specify different grouping for different CPack generator by -# using a CPACK_PROJECT_CONFIG_FILE. -# -# .. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME -# -# The name to be displayed for a component. -# -# .. variable:: CPACK_COMPONENT_<compName>_DESCRIPTION -# -# The description of a component. -# -# .. variable:: CPACK_COMPONENT_<compName>_GROUP -# -# The group of a component. -# -# .. variable:: CPACK_COMPONENT_<compName>_DEPENDS -# -# The dependencies (list of components) on which this component depends. -# -# .. variable:: CPACK_COMPONENT_<compName>_HIDDEN -# -# True if this component is hidden from the user. -# -# .. variable:: CPACK_COMPONENT_<compName>_REQUIRED -# -# True if this component is required. -# -# .. variable:: CPACK_COMPONENT_<compName>_DISABLED -# -# True if this component is not selected to be installed by default. -# -# .. command:: cpack_add_component -# -# Describes a CPack installation -# component named by the COMPONENT argument to a CMake INSTALL command. -# -# :: -# -# 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]) -# -# -# -# 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. -# -# DISPLAY_NAME is the displayed name of the component, used in graphical -# installers to display the component name. This value can be any -# string. -# -# 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 ``\n`` as the -# line separator. Typically, these descriptions should be no more than -# a few lines long. -# -# 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. -# -# 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). -# -# 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. -# -# 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. -# -# 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. -# -# 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. -# -# 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. -# -# 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. -# -# PLIST gives a filename that is passed to pkgbuild with the -# ``--component-plist`` argument when using the productbuild generator. -# -# .. command:: cpack_add_component_group -# -# Describes a group of related CPack installation components. -# -# :: -# -# cpack_add_component_group(groupname -# [DISPLAY_NAME name] -# [DESCRIPTION description] -# [PARENT_GROUP parent] -# [EXPANDED] -# [BOLD_TITLE]) -# -# -# -# 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. -# -# 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. -# -# 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 ``\n`` as the line separator. Typically, these descriptions -# should be no more than a few lines long. -# -# 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. -# -# 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. -# -# BOLD_TITLE indicates that the group title should appear in bold, to -# call the user's attention to the group. -# -# .. command:: cpack_add_install_type -# -# Add a new installation type containing -# a set of predefined component selections to the graphical installer. -# -# :: -# -# cpack_add_install_type(typename -# [DISPLAY_NAME name]) -# -# -# -# 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's executable. Each component -# identifies itself with one or more install types via the INSTALL_TYPES -# argument to cpack_add_component. -# -# 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. -# -# .. command:: cpack_configure_downloads -# -# Configure CPack to download -# selected components on-the-fly as part of the installation process. -# -# :: -# -# cpack_configure_downloads(site -# [UPLOAD_DIRECTORY dirname] -# [ALL] -# [ADD_REMOVE|NO_ADD_REMOVE]) -# -# -# -# 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: -# -# :: -# -# http://nsis.sourceforge.net/ZipDLL_plug-in -# -# -# -# On macOS, installers that download components on-the-fly can only -# be built and installed on system using macOS 10.5 or later. -# -# The site argument is a URL where the archives for downloadable -# components will reside, e.g., -# https://cmake.org/files/2.6.1/installer/ All of the archives -# produced by CPack should be uploaded to that location. -# -# 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. -# -# 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). -# -# ADD_REMOVE indicates that CPack should install a copy of the installer -# that can be called from Windows' 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. +#[=======================================================================[.rst: +CPackComponent +-------------- + +Build binary and source package installers + +Variables concerning CPack Components +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The CPackComponent module is the module which handles the component +part of CPack. See CPack module for general information about CPack. + +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's 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. + +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's INSTALL +commands, and should be further described by the following CPack +commands: + +.. variable:: CPACK_COMPONENTS_ALL + + The list of component to install. + + 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. + + 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 :command:`get_cmake_property` command can be used to obtain the + ``COMPONENTS`` property, then the :command:`list(REMOVE_ITEM)` command can be + used to remove the unwanted ones. For example, to use all defined components + except ``foo`` and ``bar``:: + + get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) + list(REMOVE_ITEM CPACK_COMPONENTS_ALL "foo" "bar") + +.. variable:: CPACK_<GENNAME>_COMPONENT_INSTALL + + Enable/Disable component install for CPack generator <GENNAME>. + + 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. + +.. variable:: CPACK_COMPONENTS_GROUPING + + Specify how components are grouped for multi-package component-aware CPack + generators. + + 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: + + * ONE_PER_GROUP (default): creates one package file per component group + * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) components + * IGNORE : creates one package per component, i.e. IGNORE component group + + One can specify different grouping for different CPack generator by + using a CPACK_PROJECT_CONFIG_FILE. + +.. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME + + The name to be displayed for a component. + +.. variable:: CPACK_COMPONENT_<compName>_DESCRIPTION + + The description of a component. + +.. variable:: CPACK_COMPONENT_<compName>_GROUP + + The group of a component. + +.. variable:: CPACK_COMPONENT_<compName>_DEPENDS + + The dependencies (list of components) on which this component depends. + +.. variable:: CPACK_COMPONENT_<compName>_HIDDEN + + True if this component is hidden from the user. + +.. variable:: CPACK_COMPONENT_<compName>_REQUIRED + + True if this component is required. + +.. variable:: CPACK_COMPONENT_<compName>_DISABLED + + True if this component is not selected to be installed by default. + +.. command:: cpack_add_component + +Describes a CPack installation +component named by the COMPONENT argument to a CMake INSTALL command. + +:: + + 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]) + + + +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. + +DISPLAY_NAME is the displayed name of the component, used in graphical +installers to display the component name. This value can be any +string. + +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 ``\n`` as the +line separator. Typically, these descriptions should be no more than +a few lines long. + +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. + +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). + +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. + +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. + +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. + +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. + +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. + +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. + +PLIST gives a filename that is passed to pkgbuild with the +``--component-plist`` argument when using the productbuild generator. + +.. command:: cpack_add_component_group + +Describes a group of related CPack installation components. + +:: + + cpack_add_component_group(groupname + [DISPLAY_NAME name] + [DESCRIPTION description] + [PARENT_GROUP parent] + [EXPANDED] + [BOLD_TITLE]) + + + +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. + +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. + +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 ``\n`` as the line separator. Typically, these descriptions +should be no more than a few lines long. + +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. + +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. + +BOLD_TITLE indicates that the group title should appear in bold, to +call the user's attention to the group. + +.. command:: cpack_add_install_type + +Add a new installation type containing +a set of predefined component selections to the graphical installer. + +:: + + cpack_add_install_type(typename + [DISPLAY_NAME name]) + + + +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's executable. Each component +identifies itself with one or more install types via the INSTALL_TYPES +argument to cpack_add_component. + +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. + +.. command:: cpack_configure_downloads + +Configure CPack to download +selected components on-the-fly as part of the installation process. + +:: + + cpack_configure_downloads(site + [UPLOAD_DIRECTORY dirname] + [ALL] + [ADD_REMOVE|NO_ADD_REMOVE]) + + + +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: + +:: + + http://nsis.sourceforge.net/ZipDLL_plug-in + + + +On macOS, installers that download components on-the-fly can only +be built and installed on system using macOS 10.5 or later. + +The site argument is a URL where the archives for downloadable +components will reside, e.g., +https://cmake.org/files/2.6.1/installer/ All of the archives +produced by CPack should be uploaded to that location. + +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. + +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). + +ADD_REMOVE indicates that CPack should install a copy of the installer +that can be called from Windows' 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. +#]=======================================================================] # Define var in order to avoid multiple inclusion if(NOT CPackComponent_CMake_INCLUDED) diff --git a/Modules/CPackIFWConfigureFile.cmake b/Modules/CPackIFWConfigureFile.cmake index 790574a..0abe0da 100644 --- a/Modules/CPackIFWConfigureFile.cmake +++ b/Modules/CPackIFWConfigureFile.cmake @@ -1,32 +1,33 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CPackIFWConfigureFile -# --------------------- -# -# The module defines :command:`configure_file` similar command to -# configure file templates prepared in QtIFW/SDK/Creator style. -# -# -# Commands -# ^^^^^^^^ -# -# The module defines the following commands: -# -# .. command:: cpack_ifw_configure_file -# -# Copy a file to another location and modify its contents. -# -# :: -# -# cpack_ifw_configure_file(<input> <output>) -# -# Copies an ``<input>`` file to an ``<output>`` file and substitutes variable -# values referenced as ``%{VAR}`` or ``%VAR%`` in the input file content. -# Each variable reference will be replaced with the current value of the -# variable, or the empty string if the variable is not defined. -# +#[=======================================================================[.rst: +CPackIFWConfigureFile +--------------------- + +The module defines :command:`configure_file` similar command to +configure file templates prepared in QtIFW/SDK/Creator style. + + +Commands +^^^^^^^^ + +The module defines the following commands: + +.. command:: cpack_ifw_configure_file + + Copy a file to another location and modify its contents. + + :: + + cpack_ifw_configure_file(<input> <output>) + + Copies an ``<input>`` file to an ``<output>`` file and substitutes variable + values referenced as ``%{VAR}`` or ``%VAR%`` in the input file content. + Each variable reference will be replaced with the current value of the + variable, or the empty string if the variable is not defined. + +#]=======================================================================] # NOTE: This file used to himself packaging via CPack IFW generator and # should be compatible with minimal CMake version defined in diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index 1203be4..2258271 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -1,69 +1,70 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CTestCoverageCollectGCOV -# ------------------------ -# -# This module provides the ``ctest_coverage_collect_gcov`` function. -# -# This function runs gcov on all .gcda files found in the binary tree -# and packages the resulting .gcov files into a tar file. -# This tarball also contains the following: -# -# * *data.json* defines the source and build directories for use by CDash. -# * *Labels.json* indicates any :prop_sf:`LABELS` that have been set on the -# source files. -# * The *uncovered* directory holds any uncovered files found by -# :variable:`CTEST_EXTRA_COVERAGE_GLOB`. -# -# After generating this tar file, it can be sent to CDash for display with the -# :command:`ctest_submit(CDASH_UPLOAD)` command. -# -# .. command:: cdash_coverage_collect_gcov -# -# :: -# -# ctest_coverage_collect_gcov(TARBALL <tarfile> -# [SOURCE <source_dir>][BUILD <build_dir>] -# [GCOV_COMMAND <gcov_command>] -# [GCOV_OPTIONS <options>...] -# ) -# -# Run gcov and package a tar file for CDash. The options are: -# -# ``TARBALL <tarfile>`` -# Specify the location of the ``.tar`` file to be created for later -# upload to CDash. Relative paths will be interpreted with respect -# to the top-level build directory. -# -# ``SOURCE <source_dir>`` -# Specify the top-level source directory for the build. -# Default is the value of :variable:`CTEST_SOURCE_DIRECTORY`. -# -# ``BUILD <build_dir>`` -# Specify the top-level build directory for the build. -# Default is the value of :variable:`CTEST_BINARY_DIRECTORY`. -# -# ``GCOV_COMMAND <gcov_command>`` -# Specify the full path to the ``gcov`` command on the machine. -# Default is the value of :variable:`CTEST_COVERAGE_COMMAND`. -# -# ``GCOV_OPTIONS <options>...`` -# Specify options to be passed to gcov. The ``gcov`` command -# is run as ``gcov <options>... -o <gcov-dir> <file>.gcda``. -# If not specified, the default option is just ``-b``. -# -# ``GLOB`` -# Recursively search for .gcda files in build_dir rather than -# determining search locations by reading TargetDirectories.txt. -# -# ``DELETE`` -# Delete coverage files after they've been packaged into the .tar. -# -# ``QUIET`` -# Suppress non-error messages that otherwise would have been -# printed out by this function. +#[=======================================================================[.rst: +CTestCoverageCollectGCOV +------------------------ + +This module provides the ``ctest_coverage_collect_gcov`` function. + +This function runs gcov on all .gcda files found in the binary tree +and packages the resulting .gcov files into a tar file. +This tarball also contains the following: + +* *data.json* defines the source and build directories for use by CDash. +* *Labels.json* indicates any :prop_sf:`LABELS` that have been set on the + source files. +* The *uncovered* directory holds any uncovered files found by + :variable:`CTEST_EXTRA_COVERAGE_GLOB`. + +After generating this tar file, it can be sent to CDash for display with the +:command:`ctest_submit(CDASH_UPLOAD)` command. + +.. command:: cdash_coverage_collect_gcov + + :: + + ctest_coverage_collect_gcov(TARBALL <tarfile> + [SOURCE <source_dir>][BUILD <build_dir>] + [GCOV_COMMAND <gcov_command>] + [GCOV_OPTIONS <options>...] + ) + + Run gcov and package a tar file for CDash. The options are: + + ``TARBALL <tarfile>`` + Specify the location of the ``.tar`` file to be created for later + upload to CDash. Relative paths will be interpreted with respect + to the top-level build directory. + + ``SOURCE <source_dir>`` + Specify the top-level source directory for the build. + Default is the value of :variable:`CTEST_SOURCE_DIRECTORY`. + + ``BUILD <build_dir>`` + Specify the top-level build directory for the build. + Default is the value of :variable:`CTEST_BINARY_DIRECTORY`. + + ``GCOV_COMMAND <gcov_command>`` + Specify the full path to the ``gcov`` command on the machine. + Default is the value of :variable:`CTEST_COVERAGE_COMMAND`. + + ``GCOV_OPTIONS <options>...`` + Specify options to be passed to gcov. The ``gcov`` command + is run as ``gcov <options>... -o <gcov-dir> <file>.gcda``. + If not specified, the default option is just ``-b``. + + ``GLOB`` + Recursively search for .gcda files in build_dir rather than + determining search locations by reading TargetDirectories.txt. + + ``DELETE`` + Delete coverage files after they've been packaged into the .tar. + + ``QUIET`` + Suppress non-error messages that otherwise would have been + printed out by this function. +#]=======================================================================] function(ctest_coverage_collect_gcov) set(options QUIET GLOB DELETE) diff --git a/Modules/CTestScriptMode.cmake b/Modules/CTestScriptMode.cmake index 5be78d5..7af3577 100644 --- a/Modules/CTestScriptMode.cmake +++ b/Modules/CTestScriptMode.cmake @@ -1,13 +1,14 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CTestScriptMode -# --------------- -# -# -# -# This file is read by ctest in script mode (-S) +#[=======================================================================[.rst: +CTestScriptMode +--------------- + + + +This file is read by ctest in script mode (-S) +#]=======================================================================] # Determine the current system, so this information can be used # in ctest scripts diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake index dc90513..3dff926 100644 --- a/Modules/CTestUseLaunchers.cmake +++ b/Modules/CTestUseLaunchers.cmake @@ -1,32 +1,33 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CTestUseLaunchers -# ----------------- -# -# Set the RULE_LAUNCH_* global properties when CTEST_USE_LAUNCHERS is on. -# -# CTestUseLaunchers is automatically included when you include(CTest). -# However, it is split out into its own module file so projects can use -# the CTEST_USE_LAUNCHERS functionality independently. -# -# To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S -# dashboard script, and then also set it in the cache of the configured -# project. Both cmake and ctest need to know the value of it for the -# launchers to work properly. CMake needs to know in order to generate -# proper build rules, and ctest, in order to produce the proper error -# and warning analysis. -# -# For convenience, you may set the ENV variable -# CTEST_USE_LAUNCHERS_DEFAULT in your ctest -S script, too. Then, as -# long as your CMakeLists uses include(CTest) or -# include(CTestUseLaunchers), it will use the value of the ENV variable -# to initialize a CTEST_USE_LAUNCHERS cache variable. This cache -# variable initialization only occurs if CTEST_USE_LAUNCHERS is not -# already defined. If CTEST_USE_LAUNCHERS is on in a ctest -S script -# the ctest_configure command will add -DCTEST_USE_LAUNCHERS:BOOL=TRUE -# to the cmake command used to configure the project. +#[=======================================================================[.rst: +CTestUseLaunchers +----------------- + +Set the RULE_LAUNCH_* global properties when CTEST_USE_LAUNCHERS is on. + +CTestUseLaunchers is automatically included when you include(CTest). +However, it is split out into its own module file so projects can use +the CTEST_USE_LAUNCHERS functionality independently. + +To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S +dashboard script, and then also set it in the cache of the configured +project. Both cmake and ctest need to know the value of it for the +launchers to work properly. CMake needs to know in order to generate +proper build rules, and ctest, in order to produce the proper error +and warning analysis. + +For convenience, you may set the ENV variable +CTEST_USE_LAUNCHERS_DEFAULT in your ctest -S script, too. Then, as +long as your CMakeLists uses include(CTest) or +include(CTestUseLaunchers), it will use the value of the ENV variable +to initialize a CTEST_USE_LAUNCHERS cache variable. This cache +variable initialization only occurs if CTEST_USE_LAUNCHERS is not +already defined. If CTEST_USE_LAUNCHERS is on in a ctest -S script +the ctest_configure command will add -DCTEST_USE_LAUNCHERS:BOOL=TRUE +to the cmake command used to configure the project. +#]=======================================================================] if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT}) set(CTEST_USE_LAUNCHERS "$ENV{CTEST_USE_LAUNCHERS_DEFAULT}" diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index ce23ffd..d067001 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -1,41 +1,42 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckCXXSymbolExists -# -------------------- -# -# Check if a symbol exists as a function, variable, or macro in C++ -# -# .. code-block:: cmake -# -# CHECK_CXX_SYMBOL_EXISTS(<symbol> <files> <variable>) -# -# Check that the ``<symbol>`` is available after including given header -# ``<files>`` and store the result in a ``<variable>``. Specify the list of -# files in one argument as a semicolon-separated list. -# CHECK_CXX_SYMBOL_EXISTS() can be used to check in C++ files, as -# opposed to CHECK_SYMBOL_EXISTS(), which works only for C. -# -# 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 CheckTypeSize or CheckCSourceCompiles). -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# ``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_LIBRARIES`` -# list of libraries to link -# ``CMAKE_REQUIRED_QUIET`` -# execute quietly without messages +#[=======================================================================[.rst: +CheckCXXSymbolExists +-------------------- + +Check if a symbol exists as a function, variable, or macro in C++ + +.. code-block:: cmake + + CHECK_CXX_SYMBOL_EXISTS(<symbol> <files> <variable>) + +Check that the ``<symbol>`` is available after including given header +``<files>`` and store the result in a ``<variable>``. Specify the list of +files in one argument as a semicolon-separated list. +CHECK_CXX_SYMBOL_EXISTS() can be used to check in C++ files, as +opposed to CHECK_SYMBOL_EXISTS(), which works only for C. + +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 CheckTypeSize or CheckCSourceCompiles). + +The following variables may be set before calling this macro to modify +the way the check is run: + +``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_LIBRARIES`` + list of libraries to link +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages +#]=======================================================================] include_guard(GLOBAL) include(CheckSymbolExists) diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index fbfa061..dc371aa 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -1,28 +1,29 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckFortranFunctionExists -# -------------------------- -# -# :command:`Macro <macro>` which checks if a Fortran function exists. -# -# .. code-block:: cmake -# -# CHECK_FORTRAN_FUNCTION_EXISTS(<function> <result>) -# -# where -# -# ``<function>`` -# the name of the Fortran function -# ``<result>`` -# variable to store the result; will be created as an internal cache variable. -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# ``CMAKE_REQUIRED_LIBRARIES`` -# list of libraries to link +#[=======================================================================[.rst: +CheckFortranFunctionExists +-------------------------- + +:command:`Macro <macro>` which checks if a Fortran function exists. + +.. code-block:: cmake + + CHECK_FORTRAN_FUNCTION_EXISTS(<function> <result>) + +where + +``<function>`` + the name of the Fortran function +``<result>`` + variable to store the result; will be created as an internal cache variable. + +The following variables may be set before calling this macro to modify +the way the check is run: + +``CMAKE_REQUIRED_LIBRARIES`` + list of libraries to link +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index 45f7a6b..cbec739 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -1,47 +1,48 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckFunctionExists -# ------------------- -# -# Check if a C function can be linked -# -# .. code-block:: cmake -# -# check_function_exists(<function> <variable>) -# -# Checks that the ``<function>`` is provided by libraries on the system and store -# the result in a ``<variable>``, which will be created as an internal -# cache variable. -# -# The following variables may be set before calling this macro to modify the -# way the check is run: -# -# ``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_LIBRARIES`` -# list of libraries to link -# ``CMAKE_REQUIRED_QUIET`` -# execute quietly without messages -# -# .. note:: -# -# Prefer using :Module:`CheckSymbolExists` instead of this module, -# for the following reasons: -# -# * ``check_function_exists()`` can't detect functions that are inlined -# in headers or specified as a macro. -# -# * ``check_function_exists()`` can't detect anything in the 32-bit -# versions of the Win32 API, because of a mismatch in calling conventions. -# -# * ``check_function_exists()`` only verifies linking, it does not verify -# that the function is declared in system headers. +#[=======================================================================[.rst: +CheckFunctionExists +------------------- + +Check if a C function can be linked + +.. code-block:: cmake + + check_function_exists(<function> <variable>) + +Checks that the ``<function>`` is provided by libraries on the system and store +the result in a ``<variable>``, which will be created as an internal +cache variable. + +The following variables may be set before calling this macro to modify the +way the check is run: + +``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_LIBRARIES`` + list of libraries to link +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages + +.. note:: + + Prefer using :Module:`CheckSymbolExists` instead of this module, + for the following reasons: + + * ``check_function_exists()`` can't detect functions that are inlined + in headers or specified as a macro. + + * ``check_function_exists()`` can't detect anything in the 32-bit + versions of the Win32 API, because of a mismatch in calling conventions. + + * ``check_function_exists()`` only verifies linking, it does not verify + that the function is declared in system headers. +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 24bc349..87dac4f 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -1,40 +1,41 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckIncludeFile -# ---------------- -# -# Provides a macro to check if a header file can be included in ``C``. -# -# .. command:: CHECK_INCLUDE_FILE -# -# :: -# -# CHECK_INCLUDE_FILE(<include> <variable> [<flags>]) -# -# Check if the given ``<include>`` file may be included in a ``C`` -# source file and store the result in an internal cache entry named -# ``<variable>``. The optional third argument may be used to add -# compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below). -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# ``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_LIBRARIES`` -# A list of libraries to link. See policy :policy:`CMP0075`. -# ``CMAKE_REQUIRED_QUIET`` -# execute quietly without messages -# -# See the :module:`CheckIncludeFiles` module to check for multiple headers -# at once. See the :module:`CheckIncludeFileCXX` module to check for headers -# using the ``CXX`` language. +#[=======================================================================[.rst: +CheckIncludeFile +---------------- + +Provides a macro to check if a header file can be included in ``C``. + +.. command:: CHECK_INCLUDE_FILE + + :: + + CHECK_INCLUDE_FILE(<include> <variable> [<flags>]) + + Check if the given ``<include>`` file may be included in a ``C`` + source file and store the result in an internal cache entry named + ``<variable>``. The optional third argument may be used to add + compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below). + +The following variables may be set before calling this macro to modify +the way the check is run: + +``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_LIBRARIES`` + A list of libraries to link. See policy :policy:`CMP0075`. +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages + +See the :module:`CheckIncludeFiles` module to check for multiple headers +at once. See the :module:`CheckIncludeFileCXX` module to check for headers +using the ``CXX`` language. +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index f13d983..42b5eaf 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -1,39 +1,40 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckIncludeFileCXX -# ------------------- -# -# Provides a macro to check if a header file can be included in ``CXX``. -# -# .. command:: CHECK_INCLUDE_FILE_CXX -# -# :: -# -# CHECK_INCLUDE_FILE_CXX(<include> <variable> [<flags>]) -# -# Check if the given ``<include>`` file may be included in a ``CXX`` -# source file and store the result in an internal cache entry named -# ``<variable>``. The optional third argument may be used to add -# compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below). -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# ``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_LIBRARIES`` -# A list of libraries to link. See policy :policy:`CMP0075`. -# ``CMAKE_REQUIRED_QUIET`` -# execute quietly without messages -# -# See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFiles` -# to check for one or more ``C`` headers. +#[=======================================================================[.rst: +CheckIncludeFileCXX +------------------- + +Provides a macro to check if a header file can be included in ``CXX``. + +.. command:: CHECK_INCLUDE_FILE_CXX + + :: + + CHECK_INCLUDE_FILE_CXX(<include> <variable> [<flags>]) + + Check if the given ``<include>`` file may be included in a ``CXX`` + source file and store the result in an internal cache entry named + ``<variable>``. The optional third argument may be used to add + compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below). + +The following variables may be set before calling this macro to modify +the way the check is run: + +``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_LIBRARIES`` + A list of libraries to link. See policy :policy:`CMP0075`. +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages + +See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFiles` +to check for one or more ``C`` headers. +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index c689f05..b303260 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -1,45 +1,46 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckIncludeFiles -# ----------------- -# -# Provides a macro to check if a list of one or more header files can -# be included together. -# -# .. command:: CHECK_INCLUDE_FILES -# -# :: -# -# CHECK_INCLUDE_FILES("<includes>" <variable> [LANGUAGE <language>]) -# -# Check if the given ``<includes>`` list may be included together -# in a source file and store the result in an internal cache -# entry named ``<variable>``. Specify the ``<includes>`` argument -# as a :ref:`;-list <CMake Language Lists>` of header file names. -# -# If LANGUAGE is set, the specified compiler will be used to perform the -# check. Acceptable values are ``C`` and ``CXX``. 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. -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# ``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_LIBRARIES`` -# A list of libraries to link. See policy :policy:`CMP0075`. -# ``CMAKE_REQUIRED_QUIET`` -# execute quietly without messages -# -# See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFileCXX` -# to check for a single header file in ``C`` or ``CXX`` languages. +#[=======================================================================[.rst: +CheckIncludeFiles +----------------- + +Provides a macro to check if a list of one or more header files can +be included together. + +.. command:: CHECK_INCLUDE_FILES + + :: + + CHECK_INCLUDE_FILES("<includes>" <variable> [LANGUAGE <language>]) + + Check if the given ``<includes>`` list may be included together + in a source file and store the result in an internal cache + entry named ``<variable>``. Specify the ``<includes>`` argument + as a :ref:`;-list <CMake Language Lists>` of header file names. + +If LANGUAGE is set, the specified compiler will be used to perform the +check. Acceptable values are ``C`` and ``CXX``. 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. + +The following variables may be set before calling this macro to modify +the way the check is run: + +``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_LIBRARIES`` + A list of libraries to link. See policy :policy:`CMP0075`. +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages + +See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFileCXX` +to check for a single header file in ``C`` or ``CXX`` languages. +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index ce92bfe..efa88bd 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -1,35 +1,36 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckLanguage -# ------------- -# -# Check if a language can be enabled -# -# Usage: -# -# :: -# -# check_language(<lang>) -# -# where <lang> is a language that may be passed to enable_language() -# such as "Fortran". If CMAKE_<lang>_COMPILER is already defined the -# check does nothing. Otherwise it tries enabling the language in a -# test project. The result is cached in CMAKE_<lang>_COMPILER as the -# compiler that was found, or NOTFOUND if the language cannot be -# enabled. -# -# Example: -# -# :: -# -# check_language(Fortran) -# if(CMAKE_Fortran_COMPILER) -# enable_language(Fortran) -# else() -# message(STATUS "No Fortran support") -# endif() +#[=======================================================================[.rst: +CheckLanguage +------------- + +Check if a language can be enabled + +Usage: + +:: + + check_language(<lang>) + +where <lang> is a language that may be passed to enable_language() +such as "Fortran". If CMAKE_<lang>_COMPILER is already defined the +check does nothing. Otherwise it tries enabling the language in a +test project. The result is cached in CMAKE_<lang>_COMPILER as the +compiler that was found, or NOTFOUND if the language cannot be +enabled. + +Example: + +:: + + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + else() + message(STATUS "No Fortran support") + endif() +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index 487cc59..428a6b0 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -1,33 +1,34 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckLibraryExists -# ------------------ -# -# Check if the function exists. -# -# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE) -# -# :: -# -# 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. -# -# -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link -# CMAKE_REQUIRED_QUIET = execute quietly without messages +#[=======================================================================[.rst: +CheckLibraryExists +------------------ + +Check if the function exists. + +CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE) + +:: + + 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. + + + +The following variables may be set before calling this macro to modify +the way the check is run: + +:: + + CMAKE_REQUIRED_FLAGS = string of compile command line flags + CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) + CMAKE_REQUIRED_LIBRARIES = list of libraries to link + CMAKE_REQUIRED_QUIET = execute quietly without messages +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index dde0775..b379ec4 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -1,43 +1,44 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckPrototypeDefinition -# ------------------------ -# -# Check if the prototype we expect is correct. -# -# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) -# -# :: -# -# 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. -# -# Example: -# -# :: -# -# check_prototype_definition(getpwent_r -# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" -# "NULL" -# "unistd.h;pwd.h" -# SOLARIS_GETPWENT_R) -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# 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_LIBRARIES = list of libraries to link -# CMAKE_REQUIRED_QUIET = execute quietly without messages +#[=======================================================================[.rst: +CheckPrototypeDefinition +------------------------ + +Check if the prototype we expect is correct. + +check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) + +:: + + 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. + +Example: + +:: + + check_prototype_definition(getpwent_r + "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" + "NULL" + "unistd.h;pwd.h" + SOLARIS_GETPWENT_R) + +The following variables may be set before calling this macro to modify +the way the check is run: + +:: + + 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_LIBRARIES = list of libraries to link + CMAKE_REQUIRED_QUIET = execute quietly without messages +#]=======================================================================] # diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake index 8689a5c..e7c337c 100644 --- a/Modules/CheckStructHasMember.cmake +++ b/Modules/CheckStructHasMember.cmake @@ -1,42 +1,43 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckStructHasMember -# -------------------- -# -# Check if the given struct or class has the specified member variable -# -# :: -# -# CHECK_STRUCT_HAS_MEMBER(<struct> <member> <header> <variable> -# [LANGUAGE <language>]) -# -# :: -# -# <struct> - the name of the struct or class you are interested in -# <member> - the member which existence you want to check -# <header> - the header(s) where the prototype should be declared -# <variable> - variable to store the result -# <language> - the compiler to use (C or CXX) -# -# -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# 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_LIBRARIES = list of libraries to link -# CMAKE_REQUIRED_QUIET = execute quietly without messages -# -# -# -# Example: CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h -# HAVE_TIMEVAL_TV_SEC LANGUAGE C) +#[=======================================================================[.rst: +CheckStructHasMember +-------------------- + +Check if the given struct or class has the specified member variable + +:: + + CHECK_STRUCT_HAS_MEMBER(<struct> <member> <header> <variable> + [LANGUAGE <language>]) + +:: + + <struct> - the name of the struct or class you are interested in + <member> - the member which existence you want to check + <header> - the header(s) where the prototype should be declared + <variable> - variable to store the result + <language> - the compiler to use (C or CXX) + + + +The following variables may be set before calling this macro to modify +the way the check is run: + +:: + + 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_LIBRARIES = list of libraries to link + CMAKE_REQUIRED_QUIET = execute quietly without messages + + + +Example: CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h +HAVE_TIMEVAL_TV_SEC LANGUAGE C) +#]=======================================================================] include_guard(GLOBAL) include(CheckCSourceCompiles) diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 2b5deec..2c53df9 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -1,72 +1,73 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckTypeSize -# ------------- -# -# Check sizeof a type -# -# :: -# -# CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY] -# [LANGUAGE <language>]) -# -# Check if the type exists and determine its size. On return, -# "HAVE_${VARIABLE}" holds the existence of the type, and "${VARIABLE}" -# holds one of the following: -# -# :: -# -# <size> = type has non-zero size <size> -# "0" = type has arch-dependent size (see below) -# "" = type does not exist -# -# Both ``HAVE_${VARIABLE}`` and ``${VARIABLE}`` will be created as internal -# cache variables. -# -# Furthermore, the variable "${VARIABLE}_CODE" holds C preprocessor code -# to define the macro "${VARIABLE}" to the size of the type, or leave -# the macro undefined if the type does not exist. -# -# The variable "${VARIABLE}" may be "0" when CMAKE_OSX_ARCHITECTURES has -# multiple architectures for building OS X universal binaries. This -# indicates that the type size varies across architectures. In this -# case "${VARIABLE}_CODE" contains C preprocessor tests mapping from -# each architecture macro to the corresponding type size. The list of -# architecture macros is stored in "${VARIABLE}_KEYS", and the value for -# each key is stored in "${VARIABLE}-${KEY}". -# -# If the BUILTIN_TYPES_ONLY option is not given, the macro checks for -# headers <sys/types.h>, <stdint.h>, and <stddef.h>, and saves results -# in HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H. The type size -# check automatically includes the available headers, thus supporting -# checks of types defined in the headers. -# -# If LANGUAGE is set, the specified compiler will be used to perform the -# check. Acceptable values are C and CXX -# -# 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: -# -# :: -# -# check_type_size("((struct something*)0)->member" SIZEOF_MEMBER) -# -# -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# 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_LIBRARIES = list of libraries to link -# CMAKE_REQUIRED_QUIET = execute quietly without messages -# CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include +#[=======================================================================[.rst: +CheckTypeSize +------------- + +Check sizeof a type + +:: + + CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY] + [LANGUAGE <language>]) + +Check if the type exists and determine its size. On return, +"HAVE_${VARIABLE}" holds the existence of the type, and "${VARIABLE}" +holds one of the following: + +:: + + <size> = type has non-zero size <size> + "0" = type has arch-dependent size (see below) + "" = type does not exist + +Both ``HAVE_${VARIABLE}`` and ``${VARIABLE}`` will be created as internal +cache variables. + +Furthermore, the variable "${VARIABLE}_CODE" holds C preprocessor code +to define the macro "${VARIABLE}" to the size of the type, or leave +the macro undefined if the type does not exist. + +The variable "${VARIABLE}" may be "0" when CMAKE_OSX_ARCHITECTURES has +multiple architectures for building OS X universal binaries. This +indicates that the type size varies across architectures. In this +case "${VARIABLE}_CODE" contains C preprocessor tests mapping from +each architecture macro to the corresponding type size. The list of +architecture macros is stored in "${VARIABLE}_KEYS", and the value for +each key is stored in "${VARIABLE}-${KEY}". + +If the BUILTIN_TYPES_ONLY option is not given, the macro checks for +headers <sys/types.h>, <stdint.h>, and <stddef.h>, and saves results +in HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H. The type size +check automatically includes the available headers, thus supporting +checks of types defined in the headers. + +If LANGUAGE is set, the specified compiler will be used to perform the +check. Acceptable values are C and CXX + +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: + +:: + + check_type_size("((struct something*)0)->member" SIZEOF_MEMBER) + + + +The following variables may be set before calling this macro to modify +the way the check is run: + +:: + + 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_LIBRARIES = list of libraries to link + CMAKE_REQUIRED_QUIET = execute quietly without messages + CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include +#]=======================================================================] include(CheckIncludeFile) include(CheckIncludeFileCXX) diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index ab456d1..f30165e 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# CheckVariableExists -# ------------------- -# -# Check if the variable exists. -# -# :: -# -# CHECK_VARIABLE_EXISTS(VAR VARIABLE) -# -# -# -# :: -# -# VAR - the name of the variable -# VARIABLE - variable to store the result -# Will be created as an internal cache variable. -# -# -# This macro is only for C variables. -# -# The following variables may be set before calling this macro to modify -# the way the check is run: -# -# :: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link -# CMAKE_REQUIRED_QUIET = execute quietly without messages +#[=======================================================================[.rst: +CheckVariableExists +------------------- + +Check if the variable exists. + +:: + + CHECK_VARIABLE_EXISTS(VAR VARIABLE) + + + +:: + + VAR - the name of the variable + VARIABLE - variable to store the result + Will be created as an internal cache variable. + + +This macro is only for C variables. + +The following variables may be set before calling this macro to modify +the way the check is run: + +:: + + CMAKE_REQUIRED_FLAGS = string of compile command line flags + CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) + CMAKE_REQUIRED_LIBRARIES = list of libraries to link + CMAKE_REQUIRED_QUIET = execute quietly without messages +#]=======================================================================] include_guard(GLOBAL) diff --git a/Modules/Dart.cmake b/Modules/Dart.cmake index e003cd5..154fe9d 100644 --- a/Modules/Dart.cmake +++ b/Modules/Dart.cmake @@ -1,27 +1,28 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Dart -# ---- -# -# Configure a project for testing with CTest or old Dart Tcl Client -# -# This file is the backwards-compatibility version of the CTest module. -# It supports using the old Dart 1 Tcl client for driving dashboard -# submissions as well as testing with CTest. This module should be -# included in the CMakeLists.txt file at the top of a project. Typical -# usage: -# -# :: -# -# include(Dart) -# if(BUILD_TESTING) -# # ... testing related CMake code ... -# endif() -# -# The BUILD_TESTING option is created by the Dart module to determine -# whether testing support should be enabled. The default is ON. +#[=======================================================================[.rst: +Dart +---- + +Configure a project for testing with CTest or old Dart Tcl Client + +This file is the backwards-compatibility version of the CTest module. +It supports using the old Dart 1 Tcl client for driving dashboard +submissions as well as testing with CTest. This module should be +included in the CMakeLists.txt file at the top of a project. Typical +usage: + +:: + + include(Dart) + if(BUILD_TESTING) + # ... testing related CMake code ... + endif() + +The BUILD_TESTING option is created by the Dart module to determine +whether testing support should be enabled. The default is ON. +#]=======================================================================] # This file configures a project to use the Dart testing/dashboard process. # It is broken into 3 sections. diff --git a/Modules/Documentation.cmake b/Modules/Documentation.cmake index 6e21249..229b8ab 100644 --- a/Modules/Documentation.cmake +++ b/Modules/Documentation.cmake @@ -1,14 +1,15 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Documentation -# ------------- -# -# DocumentationVTK.cmake -# -# This file provides support for the VTK documentation framework. It -# relies on several tools (Doxygen, Perl, etc). +#[=======================================================================[.rst: +Documentation +------------- + +DocumentationVTK.cmake + +This file provides support for the VTK documentation framework. It +relies on several tools (Doxygen, Perl, etc). +#]=======================================================================] # # Build the documentation ? diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake index c9cfd60..f27d7fe 100644 --- a/Modules/FindALSA.cmake +++ b/Modules/FindALSA.cmake @@ -1,44 +1,45 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindALSA -# -------- -# -# Find alsa -# -# Find the alsa libraries (asound) -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``ALSA::ALSA``, if -# ALSA has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# ``ALSA_FOUND`` -# True if ALSA_INCLUDE_DIR & ALSA_LIBRARY are found -# -# ``ALSA_LIBRARIES`` -# List of libraries when using ALSA. -# -# ``ALSA_INCLUDE_DIRS`` -# Where to find the ALSA headers. -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``ALSA_INCLUDE_DIR`` -# the ALSA include directory -# -# ``ALSA_LIBRARY`` -# the absolute path of the asound library +#[=======================================================================[.rst: +FindALSA +-------- + +Find alsa + +Find the alsa libraries (asound) + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``ALSA::ALSA``, if +ALSA has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``ALSA_FOUND`` + True if ALSA_INCLUDE_DIR & ALSA_LIBRARY are found + +``ALSA_LIBRARIES`` + List of libraries when using ALSA. + +``ALSA_INCLUDE_DIRS`` + Where to find the ALSA headers. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``ALSA_INCLUDE_DIR`` + the ALSA include directory + +``ALSA_LIBRARY`` + the absolute path of the asound library +#]=======================================================================] find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h DOC "The ALSA (asound) include directory" diff --git a/Modules/FindASPELL.cmake b/Modules/FindASPELL.cmake index 6944ac1..c2d29e2 100644 --- a/Modules/FindASPELL.cmake +++ b/Modules/FindASPELL.cmake @@ -1,21 +1,22 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindASPELL -# ---------- -# -# Try to find ASPELL -# -# Once done this will define -# -# :: -# -# ASPELL_FOUND - system has ASPELL -# ASPELL_EXECUTABLE - the ASPELL executable -# ASPELL_INCLUDE_DIR - the ASPELL include directory -# ASPELL_LIBRARIES - The libraries needed to use ASPELL -# ASPELL_DEFINITIONS - Compiler switches required for using ASPELL +#[=======================================================================[.rst: +FindASPELL +---------- + +Try to find ASPELL + +Once done this will define + +:: + + ASPELL_FOUND - system has ASPELL + ASPELL_EXECUTABLE - the ASPELL executable + ASPELL_INCLUDE_DIR - the ASPELL include directory + ASPELL_LIBRARIES - The libraries needed to use ASPELL + ASPELL_DEFINITIONS - Compiler switches required for using ASPELL +#]=======================================================================] find_path(ASPELL_INCLUDE_DIR aspell.h ) diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index 2df29ca..c12512f 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake @@ -1,23 +1,24 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindAVIFile -# ----------- -# -# Locate AVIFILE library and include paths -# -# AVIFILE (http://avifile.sourceforge.net/)is a set of libraries for -# i386 machines to use various AVI codecs. Support is limited beyond -# Linux. Windows provides native AVI support, and so doesn't need this -# library. This module defines -# -# :: -# -# AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. -# AVIFILE_LIBRARIES, the libraries to link against -# AVIFILE_DEFINITIONS, definitions to use when compiling -# AVIFILE_FOUND, If false, don't try to use AVIFILE +#[=======================================================================[.rst: +FindAVIFile +----------- + +Locate AVIFILE library and include paths + +AVIFILE (http://avifile.sourceforge.net/)is a set of libraries for +i386 machines to use various AVI codecs. Support is limited beyond +Linux. Windows provides native AVI support, and so doesn't need this +library. This module defines + +:: + + AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. + AVIFILE_LIBRARIES, the libraries to link against + AVIFILE_DEFINITIONS, definitions to use when compiling + AVIFILE_FOUND, If false, don't try to use AVIFILE +#]=======================================================================] if (UNIX) diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake index 95f0c56..ce76c99 100644 --- a/Modules/FindArmadillo.cmake +++ b/Modules/FindArmadillo.cmake @@ -1,35 +1,36 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindArmadillo -# ------------- -# -# Find Armadillo -# -# Find the Armadillo C++ library -# -# Using Armadillo: -# -# :: -# -# find_package(Armadillo REQUIRED) -# include_directories(${ARMADILLO_INCLUDE_DIRS}) -# add_executable(foo foo.cc) -# target_link_libraries(foo ${ARMADILLO_LIBRARIES}) -# -# This module sets the following variables: -# -# :: -# -# ARMADILLO_FOUND - set to true if the library is found -# ARMADILLO_INCLUDE_DIRS - list of required include directories -# ARMADILLO_LIBRARIES - list of libraries to be linked -# ARMADILLO_VERSION_MAJOR - major version number -# ARMADILLO_VERSION_MINOR - minor version number -# ARMADILLO_VERSION_PATCH - patch version number -# ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4") -# ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech") +#[=======================================================================[.rst: +FindArmadillo +------------- + +Find Armadillo + +Find the Armadillo C++ library + +Using Armadillo: + +:: + + find_package(Armadillo REQUIRED) + include_directories(${ARMADILLO_INCLUDE_DIRS}) + add_executable(foo foo.cc) + target_link_libraries(foo ${ARMADILLO_LIBRARIES}) + +This module sets the following variables: + +:: + + ARMADILLO_FOUND - set to true if the library is found + ARMADILLO_INCLUDE_DIRS - list of required include directories + ARMADILLO_LIBRARIES - list of libraries to be linked + ARMADILLO_VERSION_MAJOR - major version number + ARMADILLO_VERSION_MINOR - minor version number + ARMADILLO_VERSION_PATCH - patch version number + ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4") + ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech") +#]=======================================================================] # UNIX paths are standard, no need to write. find_library(ARMADILLO_LIBRARY diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 2000f7f..d59dc27 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -1,85 +1,86 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindBISON -# --------- -# -# Find ``bison`` executable and provide a macro to generate custom build rules. -# -# The module defines the following variables: -# -# ``BISON_EXECUTABLE`` -# path to the ``bison`` program -# -# ``BISON_VERSION`` -# version of ``bison`` -# -# ``BISON_FOUND`` -# true if the program was found -# -# The minimum required version of ``bison`` can be specified using the -# standard CMake syntax, e.g. ``find_package(BISON 2.1.3)``. -# -# If ``bison`` is found, the module defines the macro:: -# -# BISON_TARGET(<Name> <YaccInput> <CodeOutput> -# [COMPILE_FLAGS <flags>] -# [DEFINES_FILE <file>] -# [VERBOSE [<file>]] -# [REPORT_FILE <file>] -# ) -# -# which will create a custom rule to generate a parser. ``<YaccInput>`` is -# the path to a yacc file. ``<CodeOutput>`` is the name of the source file -# generated by bison. A header file is also be generated, and contains -# the token list. -# -# The options are: -# -# ``COMPILE_FLAGS <flags>`` -# Specify flags to be added to the ``bison`` command line. -# -# ``DEFINES_FILE <file>`` -# Specify a non-default header ``<file>`` to be generated by ``bison``. -# -# ``VERBOSE [<file>]`` -# Tell ``bison`` to write a report file of the grammar and parser. -# If ``<file>`` is given, it specifies path the report file is copied to. -# ``[<file>]`` is left for backward compatibility of this module. -# Use ``VERBOSE REPORT_FILE <file>``. -# -# ``REPORT_FILE <file>`` -# Specify a non-default report ``<file>``, if generated. -# -# The macro defines the following variables: -# -# ``BISON_<Name>_DEFINED`` -# true is the macro ran successfully -# -# ``BISON_<Name>_INPUT`` -# The input source file, an alias for <YaccInput> -# -# ``BISON_<Name>_OUTPUT_SOURCE`` -# The source file generated by bison -# -# ``BISON_<Name>_OUTPUT_HEADER`` -# The header file generated by bison -# -# ``BISON_<Name>_OUTPUTS`` -# All files generated by bison including the source, the header and the report -# -# ``BISON_<Name>_COMPILE_FLAGS`` -# Options used in the ``bison`` command line -# -# Example usage: -# -# .. code-block:: cmake -# -# find_package(BISON) -# BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp -# DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h) -# add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS}) +#[=======================================================================[.rst: +FindBISON +--------- + +Find ``bison`` executable and provide a macro to generate custom build rules. + +The module defines the following variables: + +``BISON_EXECUTABLE`` + path to the ``bison`` program + +``BISON_VERSION`` + version of ``bison`` + +``BISON_FOUND`` + true if the program was found + +The minimum required version of ``bison`` can be specified using the +standard CMake syntax, e.g. ``find_package(BISON 2.1.3)``. + +If ``bison`` is found, the module defines the macro:: + + BISON_TARGET(<Name> <YaccInput> <CodeOutput> + [COMPILE_FLAGS <flags>] + [DEFINES_FILE <file>] + [VERBOSE [<file>]] + [REPORT_FILE <file>] + ) + +which will create a custom rule to generate a parser. ``<YaccInput>`` is +the path to a yacc file. ``<CodeOutput>`` is the name of the source file +generated by bison. A header file is also be generated, and contains +the token list. + +The options are: + +``COMPILE_FLAGS <flags>`` + Specify flags to be added to the ``bison`` command line. + +``DEFINES_FILE <file>`` + Specify a non-default header ``<file>`` to be generated by ``bison``. + +``VERBOSE [<file>]`` + Tell ``bison`` to write a report file of the grammar and parser. + If ``<file>`` is given, it specifies path the report file is copied to. + ``[<file>]`` is left for backward compatibility of this module. + Use ``VERBOSE REPORT_FILE <file>``. + +``REPORT_FILE <file>`` + Specify a non-default report ``<file>``, if generated. + +The macro defines the following variables: + +``BISON_<Name>_DEFINED`` + true is the macro ran successfully + +``BISON_<Name>_INPUT`` + The input source file, an alias for <YaccInput> + +``BISON_<Name>_OUTPUT_SOURCE`` + The source file generated by bison + +``BISON_<Name>_OUTPUT_HEADER`` + The header file generated by bison + +``BISON_<Name>_OUTPUTS`` + All files generated by bison including the source, the header and the report + +``BISON_<Name>_COMPILE_FLAGS`` + Options used in the ``bison`` command line + +Example usage: + +.. code-block:: cmake + + find_package(BISON) + BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h) + add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS}) +#]=======================================================================] find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable") mark_as_advanced(BISON_EXECUTABLE) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index e955bc2..48cd207 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -1,74 +1,75 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindBLAS -# -------- -# -# Find BLAS library -# -# This module finds an installed fortran library that implements the -# BLAS linear-algebra interface (see http://www.netlib.org/blas/). The -# list of libraries searched for is taken from the autoconf macro file, -# acx_blas.m4 (distributed at -# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). -# -# This module sets the following variables: -# -# :: -# -# BLAS_FOUND - set to true if a library implementing the BLAS interface -# is found -# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l -# and -L). -# BLAS_LIBRARIES - uncached list of libraries (using full path name) to -# link against to use BLAS (may be empty if compiler implicitly links -# BLAS) -# BLAS95_LIBRARIES - uncached list of libraries (using full path name) -# to link against to use BLAS95 interface -# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface -# is found -# -# The following variables can be used to control this module: -# -# :: -# -# BLA_STATIC if set on this determines what kind of linkage we do (static) -# BLA_VENDOR if set checks only the specified vendor, if not set checks -# all the possibilities -# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK -# BLA_PREFER_PKGCONFIG if set pkg-config will be used to search for a BLAS -# library first and if one is found that is preferred -# -# List of vendors (BLA_VENDOR) valid in this module: -# -# * Goto -# * OpenBLAS -# * FLAME -# * ATLAS PhiPACK -# * CXML -# * DXML -# * SunPerf -# * SCSL -# * SGIMATH -# * IBMESSL -# * Intel10_32 (intel mkl v10 32 bit) -# * Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model) -# * Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model) -# * Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model) -# * Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model) -# * Intel (older versions of mkl 32 and 64 bit) -# * ACML -# * ACML_MP -# * ACML_GPU -# * Apple -# * NAS -# * Generic -# -# .. note:: -# -# C/CXX should be enabled to use Intel mkl -# +#[=======================================================================[.rst: +FindBLAS +-------- + +Find BLAS library + +This module finds an installed fortran library that implements the +BLAS linear-algebra interface (see http://www.netlib.org/blas/). The +list of libraries searched for is taken from the autoconf macro file, +acx_blas.m4 (distributed at +http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). + +This module sets the following variables: + +:: + + BLAS_FOUND - set to true if a library implementing the BLAS interface + is found + BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l + and -L). + BLAS_LIBRARIES - uncached list of libraries (using full path name) to + link against to use BLAS (may be empty if compiler implicitly links + BLAS) + BLAS95_LIBRARIES - uncached list of libraries (using full path name) + to link against to use BLAS95 interface + BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface + is found + +The following variables can be used to control this module: + +:: + + BLA_STATIC if set on this determines what kind of linkage we do (static) + BLA_VENDOR if set checks only the specified vendor, if not set checks + all the possibilities + BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK + BLA_PREFER_PKGCONFIG if set pkg-config will be used to search for a BLAS + library first and if one is found that is preferred + +List of vendors (BLA_VENDOR) valid in this module: + +* Goto +* OpenBLAS +* FLAME +* ATLAS PhiPACK +* CXML +* DXML +* SunPerf +* SCSL +* SGIMATH +* IBMESSL +* Intel10_32 (intel mkl v10 32 bit) +* Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model) +* Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model) +* Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model) +* Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model) +* Intel (older versions of mkl 32 and 64 bit) +* ACML +* ACML_MP +* ACML_GPU +* Apple +* NAS +* Generic + +.. note:: + + C/CXX should be enabled to use Intel mkl + +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 4d7123d..2495148 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -1,41 +1,42 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindBZip2 -# --------- -# -# Try to find BZip2 -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``BZip2::BZip2``, if -# BZip2 has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# ``BZIP2_FOUND`` -# system has BZip2 -# ``BZIP2_INCLUDE_DIRS`` -# the BZip2 include directories -# ``BZIP2_LIBRARIES`` -# Link these to use BZip2 -# ``BZIP2_NEED_PREFIX`` -# this is set if the functions are prefixed with ``BZ2_`` -# ``BZIP2_VERSION_STRING`` -# the version of BZip2 found -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``BZIP2_INCLUDE_DIR`` -# the BZip2 include directory +#[=======================================================================[.rst: +FindBZip2 +--------- + +Try to find BZip2 + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``BZip2::BZip2``, if +BZip2 has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``BZIP2_FOUND`` + system has BZip2 +``BZIP2_INCLUDE_DIRS`` + the BZip2 include directories +``BZIP2_LIBRARIES`` + Link these to use BZip2 +``BZIP2_NEED_PREFIX`` + this is set if the functions are prefixed with ``BZ2_`` +``BZIP2_VERSION_STRING`` + the version of BZip2 found + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``BZIP2_INCLUDE_DIR`` + the BZip2 include directory +#]=======================================================================] set(_BZIP2_PATHS PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]" diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake index 59ebdc2..e1f45f7 100644 --- a/Modules/FindBacktrace.cmake +++ b/Modules/FindBacktrace.cmake @@ -1,41 +1,42 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindBacktrace -# ------------- -# -# Find provider for backtrace(3). -# -# Checks if OS supports backtrace(3) via either libc or custom library. -# This module defines the following variables: -# -# ``Backtrace_HEADER`` -# The header file needed for backtrace(3). Cached. -# Could be forcibly set by user. -# ``Backtrace_INCLUDE_DIRS`` -# The include directories needed to use backtrace(3) header. -# ``Backtrace_LIBRARIES`` -# The libraries (linker flags) needed to use backtrace(3), if any. -# ``Backtrace_FOUND`` -# Is set if and only if backtrace(3) support detected. -# -# The following cache variables are also available to set or use: -# -# ``Backtrace_LIBRARY`` -# The external library providing backtrace, if any. -# ``Backtrace_INCLUDE_DIR`` -# The directory holding the backtrace(3) header. -# -# Typical usage is to generate of header file using configure_file() with the -# contents like the following:: -# -# #cmakedefine01 Backtrace_FOUND -# #if Backtrace_FOUND -# # include <${Backtrace_HEADER}> -# #endif -# -# And then reference that generated header file in actual source. +#[=======================================================================[.rst: +FindBacktrace +------------- + +Find provider for backtrace(3). + +Checks if OS supports backtrace(3) via either libc or custom library. +This module defines the following variables: + +``Backtrace_HEADER`` + The header file needed for backtrace(3). Cached. + Could be forcibly set by user. +``Backtrace_INCLUDE_DIRS`` + The include directories needed to use backtrace(3) header. +``Backtrace_LIBRARIES`` + The libraries (linker flags) needed to use backtrace(3), if any. +``Backtrace_FOUND`` + Is set if and only if backtrace(3) support detected. + +The following cache variables are also available to set or use: + +``Backtrace_LIBRARY`` + The external library providing backtrace, if any. +``Backtrace_INCLUDE_DIR`` + The directory holding the backtrace(3) header. + +Typical usage is to generate of header file using configure_file() with the +contents like the following:: + + #cmakedefine01 Backtrace_FOUND + #if Backtrace_FOUND + # include <${Backtrace_HEADER}> + #endif + +And then reference that generated header file in actual source. +#]=======================================================================] include(CMakePushCheckState) include(CheckSymbolExists) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 5090c60..501929a 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1,237 +1,238 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindBoost -# --------- -# -# Find Boost include dirs and libraries -# -# Use this module by invoking find_package with the form:: -# -# find_package(Boost -# [version] [EXACT] # Minimum or EXACT version e.g. 1.67.0 -# [REQUIRED] # Fail with error if Boost is not found -# [COMPONENTS <libs>...] # Boost libraries by their canonical name -# # e.g. "date_time" for "libboost_date_time" -# [OPTIONAL_COMPONENTS <libs>...] -# # Optional Boost libraries by their canonical name) -# ) # e.g. "date_time" for "libboost_date_time" -# -# This module finds headers and requested component libraries OR a CMake -# package configuration file provided by a "Boost CMake" build. For the -# latter case skip to the "Boost CMake" section below. For the former -# case results are reported in variables:: -# -# Boost_FOUND - True if headers and requested libraries were found -# Boost_INCLUDE_DIRS - Boost include directories -# Boost_LIBRARY_DIRS - Link directories for Boost libraries -# Boost_LIBRARIES - Boost component libraries to be linked -# Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case) -# Boost_<C>_LIBRARY - Libraries to link for component <C> (may include -# target_link_libraries debug/optimized keywords) -# Boost_VERSION - BOOST_VERSION value from boost/version.hpp -# Boost_LIB_VERSION - Version string appended to library filenames -# Boost_MAJOR_VERSION - Boost major version number (X in X.y.z) -# Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z) -# Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z) -# Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows) -# - Pass to add_definitions() to have diagnostic -# information about Boost's automatic linking -# displayed during compilation -# -# Note that Boost Python components require a Python version suffix -# (Boost 1.67 and later), e.g. ``python36`` or ``python27`` for the -# versions built against Python 3.6 and 2.7, respectively. This also -# applies to additional components using Python including -# ``mpi_python`` and ``numpy``. Earlier Boost releases may use -# distribution-specific suffixes such as ``2``, ``3`` or ``2.7``. -# These may also be used as suffixes, but note that they are not -# portable. -# -# This module reads hints about search locations from variables:: -# -# BOOST_ROOT - Preferred installation prefix -# (or BOOSTROOT) -# BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include -# BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib -# Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not -# specified by these hint variables. Default is OFF. -# Boost_ADDITIONAL_VERSIONS -# - List of Boost versions not known to this module -# (Boost install locations may contain the version) -# -# and saves search results persistently in CMake cache entries:: -# -# Boost_INCLUDE_DIR - Directory containing Boost headers -# Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries -# Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries -# Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant -# Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant -# -# The following :prop_tgt:`IMPORTED` targets are also defined:: -# -# Boost::boost - Target for header-only dependencies -# (Boost include directory) -# Boost::<C> - Target for specific component dependency -# (shared or static library); <C> is lower- -# case -# Boost::diagnostic_definitions - interface target to enable diagnostic -# information about Boost's automatic linking -# during compilation (adds BOOST_LIB_DIAGNOSTIC) -# Boost::disable_autolinking - interface target to disable automatic -# linking with MSVC (adds BOOST_ALL_NO_LIB) -# Boost::dynamic_linking - interface target to enable dynamic linking -# linking with MSVC (adds BOOST_ALL_DYN_LINK) -# -# Implicit dependencies such as Boost::filesystem requiring -# Boost::system will be automatically detected and satisfied, even -# if system is not specified when using find_package and if -# Boost::system is not added to target_link_libraries. If using -# Boost::thread, then Threads::Threads will also be added automatically. -# -# It is important to note that the imported targets behave differently -# than variables created by this module: multiple calls to -# find_package(Boost) in the same directory or sub-directories with -# different options (e.g. static or shared) will not override the -# values of the targets created by the first call. -# -# Users may set these hints or results as cache entries. Projects -# should not read these entries directly but instead use the above -# result variables. Note that some hint names start in upper-case -# "BOOST". One may specify these as environment variables if they are -# not specified as CMake variables or cache entries. -# -# This module first searches for the Boost header files using the above -# hint variables (excluding BOOST_LIBRARYDIR) and saves the result in -# Boost_INCLUDE_DIR. Then it searches for requested component libraries -# using the above hints (excluding BOOST_INCLUDEDIR and -# Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR, -# and the library name configuration settings below. It saves the -# library directories in Boost_LIBRARY_DIR_DEBUG and -# Boost_LIBRARY_DIR_RELEASE and individual library -# locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE. -# When one changes settings used by previous searches in the same build -# tree (excluding environment variables) this module discards previous -# search results affected by the changes and searches again. -# -# Boost libraries come in many variants encoded in their file name. -# Users or projects may tell this module which variant to find by -# setting variables:: -# -# Boost_USE_DEBUG_LIBS - Set to ON or OFF to specify whether to search -# and use the debug libraries. Default is ON. -# Boost_USE_RELEASE_LIBS - Set to ON or OFF to specify whether to search -# and use the release libraries. Default is ON. -# Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded -# libraries ('mt' tag). Default is ON. -# Boost_USE_STATIC_LIBS - Set to ON to force the use of the static -# libraries. Default is OFF. -# Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use -# libraries linked statically to the C++ runtime -# ('s' tag). Default is platform dependent. -# Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use -# libraries linked to the MS debug C++ runtime -# ('g' tag). Default is ON. -# Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a -# debug Python build ('y' tag). Default is OFF. -# Boost_USE_STLPORT - Set to ON to use libraries compiled with -# STLPort ('p' tag). Default is OFF. -# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS -# - Set to ON to use libraries compiled with -# STLPort deprecated "native iostreams" -# ('n' tag). Default is OFF. -# Boost_COMPILER - Set to the compiler-specific library suffix -# (e.g. "-gcc43"). Default is auto-computed -# for the C++ compiler in use. A list may be -# used if multiple compatible suffixes should -# be tested for, in decreasing order of -# preference. -# Boost_THREADAPI - Suffix for "thread" component library name, -# such as "pthread" or "win32". Names with -# and without this suffix will both be tried. -# Boost_NAMESPACE - Alternate namespace used to build boost with -# e.g. if set to "myboost", will search for -# myboost_thread instead of boost_thread. -# -# Other variables one may set to control this module are:: -# -# Boost_DEBUG - Set to ON to enable debug output from FindBoost. -# Please enable this before filing any bug report. -# Boost_DETAILED_FAILURE_MSG -# - Set to ON to add detailed information to the -# failure message even when the REQUIRED option -# is not given to the find_package call. -# Boost_REALPATH - Set to ON to resolve symlinks for discovered -# libraries to assist with packaging. For example, -# the "system" component library may be resolved to -# "/usr/lib/libboost_system.so.1.67.0" instead of -# "/usr/lib/libboost_system.so". This does not -# affect linking and should not be enabled unless -# the user needs this information. -# Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and -# Boost_LIBRARY_DIR_DEBUG. -# -# On Visual Studio and Borland compilers Boost headers request automatic -# linking to corresponding libraries. This requires matching libraries -# to be linked explicitly or available in the link library search path. -# In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve -# dynamic linking. Boost automatic linking typically requests static -# libraries with a few exceptions (such as Boost.Python). Use:: -# -# add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) -# -# to ask Boost to report information about automatic linking requests. -# -# Example to find Boost headers only:: -# -# find_package(Boost 1.36.0) -# if(Boost_FOUND) -# include_directories(${Boost_INCLUDE_DIRS}) -# add_executable(foo foo.cc) -# endif() -# -# Example to find Boost libraries and use imported targets:: -# -# find_package(Boost 1.56 REQUIRED COMPONENTS -# date_time filesystem iostreams) -# add_executable(foo foo.cc) -# target_link_libraries(foo Boost::date_time Boost::filesystem -# Boost::iostreams) -# -# Example to find Boost Python 3.6 libraries and use imported targets:: -# -# find_package(Boost 1.67 REQUIRED COMPONENTS -# python36 numpy36) -# add_executable(foo foo.cc) -# target_link_libraries(foo Boost::python36 Boost::numpy36) -# -# Example to find Boost headers and some *static* (release only) libraries:: -# -# set(Boost_USE_STATIC_LIBS ON) # only find static libs -# set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and -# set(Boost_USE_RELEASE_LIBS ON) # only find release libs -# set(Boost_USE_MULTITHREADED ON) -# set(Boost_USE_STATIC_RUNTIME OFF) -# find_package(Boost 1.66.0 COMPONENTS date_time filesystem system ...) -# if(Boost_FOUND) -# include_directories(${Boost_INCLUDE_DIRS}) -# add_executable(foo foo.cc) -# target_link_libraries(foo ${Boost_LIBRARIES}) -# endif() -# -# Boost CMake -# ^^^^^^^^^^^ -# -# If Boost was built using the boost-cmake project it provides a package -# configuration file for use with find_package's Config mode. This -# module looks for the package configuration file called -# BoostConfig.cmake or boost-config.cmake and stores the result in cache -# entry "Boost_DIR". If found, the package configuration file is loaded -# and this module returns with no further action. See documentation of -# the Boost CMake package configuration for details on what it provides. -# -# Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake. +#[=======================================================================[.rst: +FindBoost +--------- + +Find Boost include dirs and libraries + +Use this module by invoking find_package with the form:: + + find_package(Boost + [version] [EXACT] # Minimum or EXACT version e.g. 1.67.0 + [REQUIRED] # Fail with error if Boost is not found + [COMPONENTS <libs>...] # Boost libraries by their canonical name + # e.g. "date_time" for "libboost_date_time" + [OPTIONAL_COMPONENTS <libs>...] + # Optional Boost libraries by their canonical name) + ) # e.g. "date_time" for "libboost_date_time" + +This module finds headers and requested component libraries OR a CMake +package configuration file provided by a "Boost CMake" build. For the +latter case skip to the "Boost CMake" section below. For the former +case results are reported in variables:: + + Boost_FOUND - True if headers and requested libraries were found + Boost_INCLUDE_DIRS - Boost include directories + Boost_LIBRARY_DIRS - Link directories for Boost libraries + Boost_LIBRARIES - Boost component libraries to be linked + Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case) + Boost_<C>_LIBRARY - Libraries to link for component <C> (may include + target_link_libraries debug/optimized keywords) + Boost_VERSION - BOOST_VERSION value from boost/version.hpp + Boost_LIB_VERSION - Version string appended to library filenames + Boost_MAJOR_VERSION - Boost major version number (X in X.y.z) + Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z) + Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z) + Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows) + - Pass to add_definitions() to have diagnostic + information about Boost's automatic linking + displayed during compilation + +Note that Boost Python components require a Python version suffix +(Boost 1.67 and later), e.g. ``python36`` or ``python27`` for the +versions built against Python 3.6 and 2.7, respectively. This also +applies to additional components using Python including +``mpi_python`` and ``numpy``. Earlier Boost releases may use +distribution-specific suffixes such as ``2``, ``3`` or ``2.7``. +These may also be used as suffixes, but note that they are not +portable. + +This module reads hints about search locations from variables:: + + BOOST_ROOT - Preferred installation prefix + (or BOOSTROOT) + BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include + BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib + Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not + specified by these hint variables. Default is OFF. + Boost_ADDITIONAL_VERSIONS + - List of Boost versions not known to this module + (Boost install locations may contain the version) + +and saves search results persistently in CMake cache entries:: + + Boost_INCLUDE_DIR - Directory containing Boost headers + Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries + Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries + Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant + Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant + +The following :prop_tgt:`IMPORTED` targets are also defined:: + + Boost::boost - Target for header-only dependencies + (Boost include directory) + Boost::<C> - Target for specific component dependency + (shared or static library); <C> is lower- + case + Boost::diagnostic_definitions - interface target to enable diagnostic + information about Boost's automatic linking + during compilation (adds BOOST_LIB_DIAGNOSTIC) + Boost::disable_autolinking - interface target to disable automatic + linking with MSVC (adds BOOST_ALL_NO_LIB) + Boost::dynamic_linking - interface target to enable dynamic linking + linking with MSVC (adds BOOST_ALL_DYN_LINK) + +Implicit dependencies such as Boost::filesystem requiring +Boost::system will be automatically detected and satisfied, even +if system is not specified when using find_package and if +Boost::system is not added to target_link_libraries. If using +Boost::thread, then Threads::Threads will also be added automatically. + +It is important to note that the imported targets behave differently +than variables created by this module: multiple calls to +find_package(Boost) in the same directory or sub-directories with +different options (e.g. static or shared) will not override the +values of the targets created by the first call. + +Users may set these hints or results as cache entries. Projects +should not read these entries directly but instead use the above +result variables. Note that some hint names start in upper-case +"BOOST". One may specify these as environment variables if they are +not specified as CMake variables or cache entries. + +This module first searches for the Boost header files using the above +hint variables (excluding BOOST_LIBRARYDIR) and saves the result in +Boost_INCLUDE_DIR. Then it searches for requested component libraries +using the above hints (excluding BOOST_INCLUDEDIR and +Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR, +and the library name configuration settings below. It saves the +library directories in Boost_LIBRARY_DIR_DEBUG and +Boost_LIBRARY_DIR_RELEASE and individual library +locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE. +When one changes settings used by previous searches in the same build +tree (excluding environment variables) this module discards previous +search results affected by the changes and searches again. + +Boost libraries come in many variants encoded in their file name. +Users or projects may tell this module which variant to find by +setting variables:: + + Boost_USE_DEBUG_LIBS - Set to ON or OFF to specify whether to search + and use the debug libraries. Default is ON. + Boost_USE_RELEASE_LIBS - Set to ON or OFF to specify whether to search + and use the release libraries. Default is ON. + Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded + libraries ('mt' tag). Default is ON. + Boost_USE_STATIC_LIBS - Set to ON to force the use of the static + libraries. Default is OFF. + Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use + libraries linked statically to the C++ runtime + ('s' tag). Default is platform dependent. + Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use + libraries linked to the MS debug C++ runtime + ('g' tag). Default is ON. + Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a + debug Python build ('y' tag). Default is OFF. + Boost_USE_STLPORT - Set to ON to use libraries compiled with + STLPort ('p' tag). Default is OFF. + Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS + - Set to ON to use libraries compiled with + STLPort deprecated "native iostreams" + ('n' tag). Default is OFF. + Boost_COMPILER - Set to the compiler-specific library suffix + (e.g. "-gcc43"). Default is auto-computed + for the C++ compiler in use. A list may be + used if multiple compatible suffixes should + be tested for, in decreasing order of + preference. + Boost_THREADAPI - Suffix for "thread" component library name, + such as "pthread" or "win32". Names with + and without this suffix will both be tried. + Boost_NAMESPACE - Alternate namespace used to build boost with + e.g. if set to "myboost", will search for + myboost_thread instead of boost_thread. + +Other variables one may set to control this module are:: + + Boost_DEBUG - Set to ON to enable debug output from FindBoost. + Please enable this before filing any bug report. + Boost_DETAILED_FAILURE_MSG + - Set to ON to add detailed information to the + failure message even when the REQUIRED option + is not given to the find_package call. + Boost_REALPATH - Set to ON to resolve symlinks for discovered + libraries to assist with packaging. For example, + the "system" component library may be resolved to + "/usr/lib/libboost_system.so.1.67.0" instead of + "/usr/lib/libboost_system.so". This does not + affect linking and should not be enabled unless + the user needs this information. + Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and + Boost_LIBRARY_DIR_DEBUG. + +On Visual Studio and Borland compilers Boost headers request automatic +linking to corresponding libraries. This requires matching libraries +to be linked explicitly or available in the link library search path. +In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve +dynamic linking. Boost automatic linking typically requests static +libraries with a few exceptions (such as Boost.Python). Use:: + + add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) + +to ask Boost to report information about automatic linking requests. + +Example to find Boost headers only:: + + find_package(Boost 1.36.0) + if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + add_executable(foo foo.cc) + endif() + +Example to find Boost libraries and use imported targets:: + + find_package(Boost 1.56 REQUIRED COMPONENTS + date_time filesystem iostreams) + add_executable(foo foo.cc) + target_link_libraries(foo Boost::date_time Boost::filesystem + Boost::iostreams) + +Example to find Boost Python 3.6 libraries and use imported targets:: + + find_package(Boost 1.67 REQUIRED COMPONENTS + python36 numpy36) + add_executable(foo foo.cc) + target_link_libraries(foo Boost::python36 Boost::numpy36) + +Example to find Boost headers and some *static* (release only) libraries:: + + set(Boost_USE_STATIC_LIBS ON) # only find static libs + set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and + set(Boost_USE_RELEASE_LIBS ON) # only find release libs + set(Boost_USE_MULTITHREADED ON) + set(Boost_USE_STATIC_RUNTIME OFF) + find_package(Boost 1.66.0 COMPONENTS date_time filesystem system ...) + if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + add_executable(foo foo.cc) + target_link_libraries(foo ${Boost_LIBRARIES}) + endif() + +Boost CMake +^^^^^^^^^^^ + +If Boost was built using the boost-cmake project it provides a package +configuration file for use with find_package's Config mode. This +module looks for the package configuration file called +BoostConfig.cmake or boost-config.cmake and stores the result in cache +entry "Boost_DIR". If found, the package configuration file is loaded +and this module returns with no further action. See documentation of +the Boost CMake package configuration for details on what it provides. + +Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake. +#]=======================================================================] # Save project's policies cmake_policy(PUSH) @@ -823,27 +824,42 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + elseif(NOT Boost_VERSION VERSION_LESS 106800 AND Boost_VERSION VERSION_LESS 106900) + set(_Boost_CHRONO_DEPENDENCIES system) + set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) + set(_Boost_COROUTINE_DEPENDENCIES context system) + set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) + set(_Boost_FILESYSTEM_DEPENDENCIES system) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) + set(_Boost_RANDOM_DEPENDENCIES system) + set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_TIMER_DEPENDENCIES chrono system) + set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() - if(NOT Boost_VERSION VERSION_LESS 106800) - set(_Boost_CHRONO_DEPENDENCIES system) - set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) - set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) - set(_Boost_COROUTINE_DEPENDENCIES context system) - set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) - set(_Boost_FILESYSTEM_DEPENDENCIES system) + if(NOT Boost_VERSION VERSION_LESS 106900) + set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) + set(_Boost_COROUTINE_DEPENDENCIES context) + set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) - set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) - set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) - set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) - set(_Boost_RANDOM_DEPENDENCIES system) - set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python) + set(_Boost_SYNC_DEPENDENCIES chrono atomic) + set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) - set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) endif() - if(NOT Boost_VERSION VERSION_LESS 106900) + if(NOT Boost_VERSION VERSION_LESS 107000) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index fc6695c..a3c9fc6 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -1,39 +1,40 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindBullet -# ---------- -# -# Try to find the Bullet physics engine -# -# -# -# :: -# -# This module defines the following variables -# -# -# -# :: -# -# BULLET_FOUND - Was bullet found -# BULLET_INCLUDE_DIRS - the Bullet include directories -# BULLET_LIBRARIES - Link to this, by default it includes -# all bullet components (Dynamics, -# Collision, LinearMath, & SoftBody) -# -# -# -# :: -# -# This module accepts the following variables -# -# -# -# :: -# -# BULLET_ROOT - Can be set to bullet install path or Windows build path +#[=======================================================================[.rst: +FindBullet +---------- + +Try to find the Bullet physics engine + + + +:: + + This module defines the following variables + + + +:: + + BULLET_FOUND - Was bullet found + BULLET_INCLUDE_DIRS - the Bullet include directories + BULLET_LIBRARIES - Link to this, by default it includes + all bullet components (Dynamics, + Collision, LinearMath, & SoftBody) + + + +:: + + This module accepts the following variables + + + +:: + + BULLET_ROOT - Can be set to bullet install path or Windows build path +#]=======================================================================] macro(_FIND_BULLET_LIBRARY _var) find_library(${_var} diff --git a/Modules/FindCABLE.cmake b/Modules/FindCABLE.cmake index 450e322..1f4ae76 100644 --- a/Modules/FindCABLE.cmake +++ b/Modules/FindCABLE.cmake @@ -1,27 +1,28 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCABLE -# --------- -# -# Find CABLE -# -# This module finds if CABLE is installed and determines where the -# include files and libraries are. This code sets the following -# variables: -# -# :: -# -# CABLE the path to the cable executable -# CABLE_TCL_LIBRARY the path to the Tcl wrapper library -# CABLE_INCLUDE_DIR the path to the include directory -# -# -# -# To build Tcl wrappers, you should add shared library and link it to -# ${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as an -# include directory. +#[=======================================================================[.rst: +FindCABLE +--------- + +Find CABLE + +This module finds if CABLE is installed and determines where the +include files and libraries are. This code sets the following +variables: + +:: + + CABLE the path to the cable executable + CABLE_TCL_LIBRARY the path to the Tcl wrapper library + CABLE_INCLUDE_DIR the path to the include directory + + + +To build Tcl wrappers, you should add shared library and link it to +${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as an +include directory. +#]=======================================================================] if(NOT CABLE) find_path(CABLE_BUILD_DIR cableVersion.h) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 3527979..0f5cab4 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1,378 +1,382 @@ -#.rst: -# FindCUDA -# -------- -# -# .. note:: -# -# The FindCUDA module has been superseded by first-class support -# for the CUDA language in CMake. It is no longer necessary to -# use this module or call ``find_package(CUDA)``. This module -# now exists only for compatibility with projects that have not -# been ported. -# -# Instead, list ``CUDA`` among the languages named in the top-level -# call to the :command:`project` command, or call the -# :command:`enable_language` command with ``CUDA``. -# Then one can add CUDA (``.cu``) sources to programs directly -# in calls to :command:`add_library` and :command:`add_executable`. -# -# Tools for building CUDA C files: libraries and build dependencies. -# -# This script locates the NVIDIA CUDA C tools. It should work on Linux, -# Windows, and macOS and should be reasonably up to date with CUDA C -# releases. -# -# This script makes use of the standard :command:`find_package` arguments of -# ``<VERSION>``, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an -# acceptable version of CUDA was found. -# -# The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if -# the prefix cannot be determined by the location of nvcc in the system -# path and ``REQUIRED`` is specified to :command:`find_package`. To use -# a different installed version of the toolkit set the environment variable -# ``CUDA_BIN_PATH`` before running cmake (e.g. -# ``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default -# ``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If -# you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that -# depend on the path will be relocated. -# -# It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain -# platforms, or to use a CUDA runtime not installed in the default -# location. In newer versions of the toolkit the CUDA library is -# included with the graphics driver -- be sure that the driver version -# matches what is needed by the CUDA runtime version. -# -# The following variables affect the behavior of the macros in the -# script (in alphabetical order). Note that any of these flags can be -# changed multiple times in the same directory before calling -# ``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, -# ``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` -# or ``CUDA_WRAP_SRCS``:: -# -# CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) -# -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. -# Note that making this different from the host code when generating object -# or C files from CUDA code just won't work, because size_t gets defined by -# nvcc in the generated source. If you compile to PTX and then load the -# file yourself, you can mix bit sizes between device and host. -# -# CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) -# -- Set to ON if you want the custom build rule to be attached to the source -# file in Visual Studio. Turn OFF if you add the same cuda file to multiple -# targets. -# -# This allows the user to build the target from the CUDA file; however, bad -# things can happen if the CUDA source file is added to multiple targets. -# When performing parallel builds it is possible for the custom build -# command to be run more than once and in parallel causing cryptic build -# errors. VS runs the rules for every source file in the target, and a -# source can have only one rule no matter how many projects it is added to. -# When the rule is run from multiple targets race conditions can occur on -# the generated file. Eventually everything will get built, but if the user -# is unaware of this behavior, there may be confusion. It would be nice if -# this script could detect the reuse of source files across multiple targets -# and turn the option off for the user, but no good solution could be found. -# -# CUDA_BUILD_CUBIN (Default OFF) -# -- Set to ON to enable and extra compilation pass with the -cubin option in -# Device mode. The output is parsed and register, shared memory usage is -# printed during build. -# -# CUDA_BUILD_EMULATION (Default OFF for device mode) -# -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files -# when CUDA_BUILD_EMULATION is TRUE. -# -# CUDA_LINK_LIBRARIES_KEYWORD (Default "") -# -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal -# target_link_libraries calls. The default is to use no keyword which -# uses the old "plain" form of target_link_libraries. Note that is matters -# because whatever is used inside the FindCUDA module must also be used -# outside - the two forms of target_link_libraries cannot be mixed. -# -# CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) -# -- Set to the path you wish to have the generated files placed. If it is -# blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. -# Intermediate files will always be placed in -# CMAKE_CURRENT_BINARY_DIR/CMakeFiles. -# -# CUDA_HOST_COMPILATION_CPP (Default ON) -# -- Set to OFF for C compilation of host code. -# -# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) -# -- Set the host compiler to be used by nvcc. Ignored if -ccbin or -# --compiler-bindir is already present in the CUDA_NVCC_FLAGS or -# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets, -# the host compiler is constructed with one or more visual studio macros -# such as $(VCInstallDir), that expands out to the path when -# the command is run from within VS. -# If the CUDAHOSTCXX environment variable is set it will -# be used as the default. -# -# CUDA_NVCC_FLAGS -# CUDA_NVCC_FLAGS_<CONFIG> -# -- Additional NVCC command line arguments. NOTE: multiple arguments must be -# semi-colon delimited (e.g. --compiler-options;-Wall) -# -# CUDA_PROPAGATE_HOST_FLAGS (Default ON) -# -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration -# dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the -# host compiler through nvcc's -Xcompiler flag. This helps make the -# generated host code match the rest of the system better. Sometimes -# certain flags give nvcc problems, and this will help you turn the flag -# propagation off. This does not affect the flags supplied directly to nvcc -# via CUDA_NVCC_FLAGS or through the OPTION flags specified through -# CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for -# shared library compilation are not affected by this flag. -# -# CUDA_SEPARABLE_COMPILATION (Default OFF) -# -- If set this will enable separable compilation for all CUDA runtime object -# files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY -# (e.g. calling CUDA_WRAP_SRCS directly), -# CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and -# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. -# -# CUDA_SOURCE_PROPERTY_FORMAT -# -- If this source file property is set, it can override the format specified -# to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file -# is not a .cu file, setting this file will cause it to be treated as a .cu -# file. See documentation for set_source_files_properties on how to set -# this property. -# -# CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) -# -- When enabled the static version of the CUDA runtime library will be used -# in CUDA_LIBRARIES. If the version of CUDA configured doesn't support -# this option, then it will be silently disabled. -# -# CUDA_VERBOSE_BUILD (Default OFF) -# -- Set to ON to see all the commands used when building the CUDA file. When -# using a Makefile generator the value defaults to VERBOSE (run make -# VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will -# always print the output. -# -# The script creates the following macros (in alphabetical order):: -# -# CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) -# -- Adds the cufft library to the target (can be any target). Handles whether -# you are in emulation mode or not. -# -# CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) -# -- Adds the cublas library to the target (can be any target). Handles -# whether you are in emulation mode or not. -# -# CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... -# [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) -# -- Creates an executable "cuda_target" which is made up of the files -# specified. All of the non CUDA C files are compiled using the standard -# build rules specified by CMAKE and the cuda files are compiled to object -# files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is -# added automatically to include_directories(). Some standard CMake target -# calls can be used on the target after calling this macro -# (e.g. set_target_properties and target_link_libraries), but setting -# properties that adjust compilation flags will not affect code compiled by -# nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, -# CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. -# -# CUDA_ADD_LIBRARY( cuda_target file0 file1 ... -# [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) -# -- Same as CUDA_ADD_EXECUTABLE except that a library is created. -# -# CUDA_BUILD_CLEAN_TARGET() -# -- Creates a convenience target that deletes all the dependency files -# generated. You should make clean after running this target to ensure the -# dependency files get regenerated. -# -# CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] -# [OPTIONS ...] ) -# -- Returns a list of generated files from the input source files to be used -# with ADD_LIBRARY or ADD_EXECUTABLE. -# -# CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) -# -- Returns a list of PTX files generated from the input source files. -# -# CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) -# -- Returns a list of FATBIN files generated from the input source files. -# -# CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) -# -- Returns a list of CUBIN files generated from the input source files. -# -# CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var -# cuda_target -# object_files ) -# -- Compute the name of the intermediate link file used for separable -# compilation. This file name is typically passed into -# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced -# based on cuda_target the list of objects files that need separable -# compilation as specified by object_files. If the object_files list is -# empty, then output_file_var will be empty. This function is called -# automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that -# this is a function and not a macro. -# -# CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) -# -- Sets the directories that should be passed to nvcc -# (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu -# files. -# -# -# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target -# nvcc_flags object_files) -# -- Generates the link object required by separable compilation from the given -# object files. This is called automatically for CUDA_ADD_EXECUTABLE and -# CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS -# directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the -# nvcc_flags passed in are the same as the flags passed in via the OPTIONS -# argument. The only nvcc flag added automatically is the bitness flag as -# specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function -# instead of a macro. -# -# CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) -# -- Selects GPU arch flags for nvcc based on target_CUDA_architectures -# target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) -# - "Auto" detects local machine GPU compute arch at runtime. -# - "Common" and "All" cover common and entire subsets of architectures -# ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX -# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal -# NUM: Any number. Only those pairs are currently accepted by NVCC though: -# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 -# Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} -# Additionally, sets ${out_variable}_readable to the resulting numeric list -# Example: -# CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) -# LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) -# -# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA -# Note that this is a function instead of a macro. -# -# CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... -# [STATIC | SHARED | MODULE] [OPTIONS ...] ) -# -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, -# CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this -# function under the hood. -# -# Given the list of files (file0 file1 ... fileN) this macro generates -# custom commands that generate either PTX or linkable objects (use "PTX" or -# "OBJ" for the format argument to switch). Files that don't end with .cu -# or have the HEADER_FILE_ONLY property are ignored. -# -# The arguments passed in after OPTIONS are extra command line options to -# give to nvcc. You can also specify per configuration options by -# specifying the name of the configuration followed by the options. General -# options must precede configuration specific options. Not all -# configurations need to be specified, only the ones provided will be used. -# -# OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" -# DEBUG -g -# RELEASE --use_fast_math -# RELWITHDEBINFO --use_fast_math;-g -# MINSIZEREL --use_fast_math -# -# For certain configurations (namely VS generating object files with -# CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will -# be produced for the given cuda file. This is because when you add the -# cuda file to Visual Studio it knows that this file produces an object file -# and will link in the resulting object file automatically. -# -# This script will also generate a separate cmake script that is used at -# build time to invoke nvcc. This is for several reasons. -# -# 1. nvcc can return negative numbers as return values which confuses -# Visual Studio into thinking that the command succeeded. The script now -# checks the error codes and produces errors when there was a problem. -# -# 2. nvcc has been known to not delete incomplete results when it -# encounters problems. This confuses build systems into thinking the -# target was generated when in fact an unusable file exists. The script -# now deletes the output files if there was an error. -# -# 3. By putting all the options that affect the build into a file and then -# make the build rule dependent on the file, the output files will be -# regenerated when the options change. -# -# This script also looks at optional arguments STATIC, SHARED, or MODULE to -# determine when to target the object compilation for a shared library. -# BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in -# CUDA_ADD_LIBRARY. On some systems special flags are added for building -# objects intended for shared libraries. A preprocessor macro, -# <target_name>_EXPORTS is defined when a shared library compilation is -# detected. -# -# Flags passed into add_definitions with -D or /D are passed along to nvcc. -# -# -# -# The script defines the following variables:: -# -# CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. -# CUDA_VERSION_MINOR -- The minor version. -# CUDA_VERSION -# CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR -# CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. -# -# CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). -# CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the -# SDK. This script will not directly support finding -# specific libraries or headers, as that isn't -# supported by NVIDIA. If you want to change -# libraries when the path changes see the -# FindCUDA.cmake script for an example of how to clear -# these variables. There are also examples of how to -# use the CUDA_SDK_ROOT_DIR to locate headers or -# libraries, if you so choose (at your own risk). -# CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically -# for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. -# CUDA_LIBRARIES -- Cuda RT library. -# CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT -# implementation (alternative to: -# CUDA_ADD_CUFFT_TO_TARGET macro) -# CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS -# implementation (alternative to: -# CUDA_ADD_CUBLAS_TO_TARGET macro). -# CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. -# Only available for CUDA version 5.5+ -# CUDA_cudadevrt_LIBRARY -- Device runtime library. -# Required for separable compilation. -# CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. -# Only available for CUDA version 4.0+. -# CUDA_curand_LIBRARY -- CUDA Random Number Generation library. -# Only available for CUDA version 3.2+. -# CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. -# Only available for CUDA version 7.0+. -# CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. -# Only available for CUDA version 3.2+. -# CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. -# Only available for CUDA version 4.0+. -# CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). -# Only available for CUDA version 5.5+. -# CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 5.5 - 8.0. -# CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). -# Only available for CUDA version 9.0. -# CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). -# Only available for CUDA version 5.5+. -# CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. -# Only available for CUDA version 3.2+. -# Windows only. -# CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. -# Only available for CUDA version 3.2+. -# Windows only. -# +#[=======================================================================[.rst: +FindCUDA +-------- + +.. deprecated:: 3.10 + + Superseded by first-class support for the CUDA language in CMake. + +Replacement +^^^^^^^^^^^ + +It is no longer necessary to use this module or call ``find_package(CUDA)``. +Instead, list ``CUDA`` among the languages named in the top-level +call to the :command:`project` command, or call the +:command:`enable_language` command with ``CUDA``. +Then one can add CUDA (``.cu``) sources to programs directly +in calls to :command:`add_library` and :command:`add_executable`. + +Documentation of Deprecated Usage +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Tools for building CUDA C files: libraries and build dependencies. + +This script locates the NVIDIA CUDA C tools. It should work on Linux, +Windows, and macOS and should be reasonably up to date with CUDA C +releases. + +This script makes use of the standard :command:`find_package` arguments of +``<VERSION>``, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an +acceptable version of CUDA was found. + +The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if +the prefix cannot be determined by the location of nvcc in the system +path and ``REQUIRED`` is specified to :command:`find_package`. To use +a different installed version of the toolkit set the environment variable +``CUDA_BIN_PATH`` before running cmake (e.g. +``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default +``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If +you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that +depend on the path will be relocated. + +It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain +platforms, or to use a CUDA runtime not installed in the default +location. In newer versions of the toolkit the CUDA library is +included with the graphics driver -- be sure that the driver version +matches what is needed by the CUDA runtime version. + +The following variables affect the behavior of the macros in the +script (in alphabetical order). Note that any of these flags can be +changed multiple times in the same directory before calling +``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``, +``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN`` +or ``CUDA_WRAP_SRCS``:: + + CUDA_64_BIT_DEVICE_CODE (Default matches host bit size) + -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code. + Note that making this different from the host code when generating object + or C files from CUDA code just won't work, because size_t gets defined by + nvcc in the generated source. If you compile to PTX and then load the + file yourself, you can mix bit sizes between device and host. + + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON) + -- Set to ON if you want the custom build rule to be attached to the source + file in Visual Studio. Turn OFF if you add the same cuda file to multiple + targets. + + This allows the user to build the target from the CUDA file; however, bad + things can happen if the CUDA source file is added to multiple targets. + When performing parallel builds it is possible for the custom build + command to be run more than once and in parallel causing cryptic build + errors. VS runs the rules for every source file in the target, and a + source can have only one rule no matter how many projects it is added to. + When the rule is run from multiple targets race conditions can occur on + the generated file. Eventually everything will get built, but if the user + is unaware of this behavior, there may be confusion. It would be nice if + this script could detect the reuse of source files across multiple targets + and turn the option off for the user, but no good solution could be found. + + CUDA_BUILD_CUBIN (Default OFF) + -- Set to ON to enable and extra compilation pass with the -cubin option in + Device mode. The output is parsed and register, shared memory usage is + printed during build. + + CUDA_BUILD_EMULATION (Default OFF for device mode) + -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files + when CUDA_BUILD_EMULATION is TRUE. + + CUDA_LINK_LIBRARIES_KEYWORD (Default "") + -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal + target_link_libraries calls. The default is to use no keyword which + uses the old "plain" form of target_link_libraries. Note that is matters + because whatever is used inside the FindCUDA module must also be used + outside - the two forms of target_link_libraries cannot be mixed. + + CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR) + -- Set to the path you wish to have the generated files placed. If it is + blank output files will be placed in CMAKE_CURRENT_BINARY_DIR. + Intermediate files will always be placed in + CMAKE_CURRENT_BINARY_DIR/CMakeFiles. + + CUDA_HOST_COMPILATION_CPP (Default ON) + -- Set to OFF for C compilation of host code. + + CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER) + -- Set the host compiler to be used by nvcc. Ignored if -ccbin or + --compiler-bindir is already present in the CUDA_NVCC_FLAGS or + CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets, + the host compiler is constructed with one or more visual studio macros + such as $(VCInstallDir), that expands out to the path when + the command is run from within VS. + If the CUDAHOSTCXX environment variable is set it will + be used as the default. + + CUDA_NVCC_FLAGS + CUDA_NVCC_FLAGS_<CONFIG> + -- Additional NVCC command line arguments. NOTE: multiple arguments must be + semi-colon delimited (e.g. --compiler-options;-Wall) + + CUDA_PROPAGATE_HOST_FLAGS (Default ON) + -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration + dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the + host compiler through nvcc's -Xcompiler flag. This helps make the + generated host code match the rest of the system better. Sometimes + certain flags give nvcc problems, and this will help you turn the flag + propagation off. This does not affect the flags supplied directly to nvcc + via CUDA_NVCC_FLAGS or through the OPTION flags specified through + CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for + shared library compilation are not affected by this flag. + + CUDA_SEPARABLE_COMPILATION (Default OFF) + -- If set this will enable separable compilation for all CUDA runtime object + files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY + (e.g. calling CUDA_WRAP_SRCS directly), + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called. + + CUDA_SOURCE_PROPERTY_FORMAT + -- If this source file property is set, it can override the format specified + to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file + is not a .cu file, setting this file will cause it to be treated as a .cu + file. See documentation for set_source_files_properties on how to set + this property. + + CUDA_USE_STATIC_CUDA_RUNTIME (Default ON) + -- When enabled the static version of the CUDA runtime library will be used + in CUDA_LIBRARIES. If the version of CUDA configured doesn't support + this option, then it will be silently disabled. + + CUDA_VERBOSE_BUILD (Default OFF) + -- Set to ON to see all the commands used when building the CUDA file. When + using a Makefile generator the value defaults to VERBOSE (run make + VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will + always print the output. + +The script creates the following macros (in alphabetical order):: + + CUDA_ADD_CUFFT_TO_TARGET( cuda_target ) + -- Adds the cufft library to the target (can be any target). Handles whether + you are in emulation mode or not. + + CUDA_ADD_CUBLAS_TO_TARGET( cuda_target ) + -- Adds the cublas library to the target (can be any target). Handles + whether you are in emulation mode or not. + + CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ... + [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Creates an executable "cuda_target" which is made up of the files + specified. All of the non CUDA C files are compiled using the standard + build rules specified by CMAKE and the cuda files are compiled to object + files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is + added automatically to include_directories(). Some standard CMake target + calls can be used on the target after calling this macro + (e.g. set_target_properties and target_link_libraries), but setting + properties that adjust compilation flags will not affect code compiled by + nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS. + + CUDA_ADD_LIBRARY( cuda_target file0 file1 ... + [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] ) + -- Same as CUDA_ADD_EXECUTABLE except that a library is created. + + CUDA_BUILD_CLEAN_TARGET() + -- Creates a convenience target that deletes all the dependency files + generated. You should make clean after running this target to ensure the + dependency files get regenerated. + + CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE] + [OPTIONS ...] ) + -- Returns a list of generated files from the input source files to be used + with ADD_LIBRARY or ADD_EXECUTABLE. + + CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of PTX files generated from the input source files. + + CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of FATBIN files generated from the input source files. + + CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] ) + -- Returns a list of CUBIN files generated from the input source files. + + CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var + cuda_target + object_files ) + -- Compute the name of the intermediate link file used for separable + compilation. This file name is typically passed into + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced + based on cuda_target the list of objects files that need separable + compilation as specified by object_files. If the object_files list is + empty, then output_file_var will be empty. This function is called + automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that + this is a function and not a macro. + + CUDA_INCLUDE_DIRECTORIES( path0 path1 ... ) + -- Sets the directories that should be passed to nvcc + (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu + files. + + + CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target + nvcc_flags object_files) + -- Generates the link object required by separable compilation from the given + object files. This is called automatically for CUDA_ADD_EXECUTABLE and + CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS + directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the + nvcc_flags passed in are the same as the flags passed in via the OPTIONS + argument. The only nvcc flag added automatically is the bitness flag as + specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function + instead of a macro. + + CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures]) + -- Selects GPU arch flags for nvcc based on target_CUDA_architectures + target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...) + - "Auto" detects local machine GPU compute arch at runtime. + - "Common" and "All" cover common and entire subsets of architectures + ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX + NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal + NUM: Any number. Only those pairs are currently accepted by NVCC though: + 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 + Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable} + Additionally, sets ${out_variable}_readable to the resulting numeric list + Example: + CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell) + LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS}) + + More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA + Note that this is a function instead of a macro. + + CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ... + [STATIC | SHARED | MODULE] [OPTIONS ...] ) + -- This is where all the magic happens. CUDA_ADD_EXECUTABLE, + CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this + function under the hood. + + Given the list of files (file0 file1 ... fileN) this macro generates + custom commands that generate either PTX or linkable objects (use "PTX" or + "OBJ" for the format argument to switch). Files that don't end with .cu + or have the HEADER_FILE_ONLY property are ignored. + + The arguments passed in after OPTIONS are extra command line options to + give to nvcc. You can also specify per configuration options by + specifying the name of the configuration followed by the options. General + options must precede configuration specific options. Not all + configurations need to be specified, only the ones provided will be used. + + OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag" + DEBUG -g + RELEASE --use_fast_math + RELWITHDEBINFO --use_fast_math;-g + MINSIZEREL --use_fast_math + + For certain configurations (namely VS generating object files with + CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will + be produced for the given cuda file. This is because when you add the + cuda file to Visual Studio it knows that this file produces an object file + and will link in the resulting object file automatically. + + This script will also generate a separate cmake script that is used at + build time to invoke nvcc. This is for several reasons. + + 1. nvcc can return negative numbers as return values which confuses + Visual Studio into thinking that the command succeeded. The script now + checks the error codes and produces errors when there was a problem. + + 2. nvcc has been known to not delete incomplete results when it + encounters problems. This confuses build systems into thinking the + target was generated when in fact an unusable file exists. The script + now deletes the output files if there was an error. + + 3. By putting all the options that affect the build into a file and then + make the build rule dependent on the file, the output files will be + regenerated when the options change. + + This script also looks at optional arguments STATIC, SHARED, or MODULE to + determine when to target the object compilation for a shared library. + BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in + CUDA_ADD_LIBRARY. On some systems special flags are added for building + objects intended for shared libraries. A preprocessor macro, + <target_name>_EXPORTS is defined when a shared library compilation is + detected. + + Flags passed into add_definitions with -D or /D are passed along to nvcc. + + + +The script defines the following variables:: + + CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc. + CUDA_VERSION_MINOR -- The minor version. + CUDA_VERSION + CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR + CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported. + + CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set). + CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the + SDK. This script will not directly support finding + specific libraries or headers, as that isn't + supported by NVIDIA. If you want to change + libraries when the path changes see the + FindCUDA.cmake script for an example of how to clear + these variables. There are also examples of how to + use the CUDA_SDK_ROOT_DIR to locate headers or + libraries, if you so choose (at your own risk). + CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically + for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY. + CUDA_LIBRARIES -- Cuda RT library. + CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT + implementation (alternative to: + CUDA_ADD_CUFFT_TO_TARGET macro) + CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS + implementation (alternative to: + CUDA_ADD_CUBLAS_TO_TARGET macro). + CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library. + Only available for CUDA version 5.5+ + CUDA_cudadevrt_LIBRARY -- Device runtime library. + Required for separable compilation. + CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library. + Only available for CUDA version 4.0+. + CUDA_curand_LIBRARY -- CUDA Random Number Generation library. + Only available for CUDA version 3.2+. + CUDA_cusolver_LIBRARY -- CUDA Direct Solver library. + Only available for CUDA version 7.0+. + CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library. + Only available for CUDA version 3.2+. + CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib. + Only available for CUDA version 4.0+. + CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core). + Only available for CUDA version 5.5+. + CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 5.5 - 8.0. + CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing). + Only available for CUDA version 9.0. + CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing). + Only available for CUDA version 5.5+. + CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library. + Only available for CUDA version 3.2+. + Windows only. + CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. + Only available for CUDA version 3.2+. + Windows only. + +#]=======================================================================] # James Bigler, NVIDIA Corp (nvidia.com - jbigler) # Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 60ddf7b..a4b238d 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -1,34 +1,35 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCURL -# -------- -# -# Find the native CURL headers and libraries. -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``CURL::libcurl``, if -# curl has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# ``CURL_FOUND`` -# True if curl found. -# -# ``CURL_INCLUDE_DIRS`` -# where to find curl/curl.h, etc. -# -# ``CURL_LIBRARIES`` -# List of libraries when using curl. -# -# ``CURL_VERSION_STRING`` -# The version of curl found. +#[=======================================================================[.rst: +FindCURL +-------- + +Find the native CURL headers and libraries. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``CURL::libcurl``, if +curl has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``CURL_FOUND`` + True if curl found. + +``CURL_INCLUDE_DIRS`` + where to find curl/curl.h, etc. + +``CURL_LIBRARIES`` + List of libraries when using curl. + +``CURL_VERSION_STRING`` + The version of curl found. +#]=======================================================================] # Look for the header file. find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) diff --git a/Modules/FindCVS.cmake b/Modules/FindCVS.cmake index d59dfb0..89dbc0e 100644 --- a/Modules/FindCVS.cmake +++ b/Modules/FindCVS.cmake @@ -1,27 +1,28 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCVS -# ------- -# -# -# -# The module defines the following variables: -# -# :: -# -# CVS_EXECUTABLE - path to cvs command line client -# CVS_FOUND - true if the command line client was found -# -# Example usage: -# -# :: -# -# find_package(CVS) -# if(CVS_FOUND) -# message("CVS found: ${CVS_EXECUTABLE}") -# endif() +#[=======================================================================[.rst: +FindCVS +------- + + + +The module defines the following variables: + +:: + + CVS_EXECUTABLE - path to cvs command line client + CVS_FOUND - true if the command line client was found + +Example usage: + +:: + + find_package(CVS) + if(CVS_FOUND) + message("CVS found: ${CVS_EXECUTABLE}") + endif() +#]=======================================================================] # CVSNT diff --git a/Modules/FindCoin3D.cmake b/Modules/FindCoin3D.cmake index f11903d..301e70b 100644 --- a/Modules/FindCoin3D.cmake +++ b/Modules/FindCoin3D.cmake @@ -1,22 +1,23 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCoin3D -# ---------- -# -# Find Coin3D (Open Inventor) -# -# Coin3D is an implementation of the Open Inventor API. It provides -# data structures and algorithms for 3D visualization. -# -# This module defines the following variables -# -# :: -# -# COIN3D_FOUND - system has Coin3D - Open Inventor -# COIN3D_INCLUDE_DIRS - where the Inventor include directory can be found -# COIN3D_LIBRARIES - Link to this to use Coin3D +#[=======================================================================[.rst: +FindCoin3D +---------- + +Find Coin3D (Open Inventor) + +Coin3D is an implementation of the Open Inventor API. It provides +data structures and algorithms for 3D visualization. + +This module defines the following variables + +:: + + COIN3D_FOUND - system has Coin3D - Open Inventor + COIN3D_INCLUDE_DIRS - where the Inventor include directory can be found + COIN3D_LIBRARIES - Link to this to use Coin3D +#]=======================================================================] if (WIN32) if (CYGWIN) diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 13d3b98..10ce229 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -1,22 +1,23 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCups -# -------- -# -# Try to find the Cups printing system -# -# Once done this will define -# -# :: -# -# CUPS_FOUND - system has Cups -# CUPS_INCLUDE_DIR - the Cups include directory -# CUPS_LIBRARIES - Libraries needed to use Cups -# CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8) -# Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which -# features this function (i.e. at least 1.1.19) +#[=======================================================================[.rst: +FindCups +-------- + +Try to find the Cups printing system + +Once done this will define + +:: + + CUPS_FOUND - system has Cups + CUPS_INCLUDE_DIR - the Cups include directory + CUPS_LIBRARIES - Libraries needed to use Cups + CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8) + Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which + features this function (i.e. at least 1.1.19) +#]=======================================================================] find_path(CUPS_INCLUDE_DIR cups/cups.h ) diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 4f59d2c..c225847 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -1,46 +1,47 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCurses -# ---------- -# -# Find the curses or ncurses include file and library. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# ``CURSES_FOUND`` -# True if Curses is found. -# ``CURSES_INCLUDE_DIRS`` -# The include directories needed to use Curses. -# ``CURSES_LIBRARIES`` -# The libraries needed to use Curses. -# ``CURSES_HAVE_CURSES_H`` -# True if curses.h is available. -# ``CURSES_HAVE_NCURSES_H`` -# True if ncurses.h is available. -# ``CURSES_HAVE_NCURSES_NCURSES_H`` -# True if ``ncurses/ncurses.h`` is available. -# ``CURSES_HAVE_NCURSES_CURSES_H`` -# True if ``ncurses/curses.h`` is available. -# -# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the -# ``find_package(Curses)`` call if NCurses functionality is required. -# Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the -# ``find_package(Curses)`` call if unicode functionality is required. -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# The following variable are provided for backward compatibility: -# -# ``CURSES_INCLUDE_DIR`` -# Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead. -# ``CURSES_LIBRARY`` -# Path to Curses library. Use ``CURSES_LIBRARIES`` instead. +#[=======================================================================[.rst: +FindCurses +---------- + +Find the curses or ncurses include file and library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``CURSES_FOUND`` + True if Curses is found. +``CURSES_INCLUDE_DIRS`` + The include directories needed to use Curses. +``CURSES_LIBRARIES`` + The libraries needed to use Curses. +``CURSES_HAVE_CURSES_H`` + True if curses.h is available. +``CURSES_HAVE_NCURSES_H`` + True if ncurses.h is available. +``CURSES_HAVE_NCURSES_NCURSES_H`` + True if ``ncurses/ncurses.h`` is available. +``CURSES_HAVE_NCURSES_CURSES_H`` + True if ``ncurses/curses.h`` is available. + +Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the +``find_package(Curses)`` call if NCurses functionality is required. +Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the +``find_package(Curses)`` call if unicode functionality is required. + +Backward Compatibility +^^^^^^^^^^^^^^^^^^^^^^ + +The following variable are provided for backward compatibility: + +``CURSES_INCLUDE_DIR`` + Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead. +``CURSES_LIBRARY`` + Path to Curses library. Use ``CURSES_LIBRARIES`` instead. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake index 25454fd..4eec5fc 100644 --- a/Modules/FindCxxTest.cmake +++ b/Modules/FindCxxTest.cmake @@ -1,142 +1,143 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCxxTest -# ----------- -# -# Find CxxTest -# -# Find the CxxTest suite and declare a helper macro for creating unit -# tests and integrating them with CTest. For more details on CxxTest -# see http://cxxtest.tigris.org -# -# INPUT Variables -# -# :: -# -# CXXTEST_USE_PYTHON [deprecated since 1.3] -# Only used in the case both Python & Perl -# are detected on the system to control -# which CxxTest code generator is used. -# Valid only for CxxTest version 3. -# -# -# -# :: -# -# NOTE: In older versions of this Find Module, -# this variable controlled if the Python test -# generator was used instead of the Perl one, -# regardless of which scripting language the -# user had installed. -# -# -# -# :: -# -# CXXTEST_TESTGEN_ARGS (since CMake 2.8.3) -# Specify a list of options to pass to the CxxTest code -# generator. If not defined, --error-printer is -# passed. -# -# -# -# OUTPUT Variables -# -# :: -# -# CXXTEST_FOUND -# True if the CxxTest framework was found -# CXXTEST_INCLUDE_DIRS -# Where to find the CxxTest include directory -# CXXTEST_PERL_TESTGEN_EXECUTABLE -# The perl-based test generator -# CXXTEST_PYTHON_TESTGEN_EXECUTABLE -# The python-based test generator -# CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3) -# The test generator that is actually used (chosen using user preferences -# and interpreters found in the system) -# CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3) -# The full path to the Perl or Python executable on the system, on -# platforms where the script cannot be executed using its shebang line. -# -# -# -# MACROS for optional use by CMake users: -# -# :: -# -# CXXTEST_ADD_TEST(<test_name> <gen_source_file> <input_files_to_testgen...>) -# Creates a CxxTest runner and adds it to the CTest testing suite -# Parameters: -# test_name The name of the test -# gen_source_file The generated source filename to be -# generated by CxxTest -# input_files_to_testgen The list of header files containing the -# CxxTest::TestSuite's to be included in -# this runner -# -# -# -# :: -# -# #============== -# Example Usage: -# -# -# -# :: -# -# find_package(CxxTest) -# if(CXXTEST_FOUND) -# include_directories(${CXXTEST_INCLUDE_DIR}) -# enable_testing() -# -# -# -# :: -# -# CXXTEST_ADD_TEST(unittest_foo foo_test.cc -# ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h) -# target_link_libraries(unittest_foo foo) # as needed -# endif() -# -# -# -# :: -# -# This will (if CxxTest is found): -# 1. Invoke the testgen executable to autogenerate foo_test.cc in the -# binary tree from "foo_test.h" in the current source directory. -# 2. Create an executable and test called unittest_foo. -# -# -# -# :: -# -# #============= -# Example foo_test.h: -# -# -# -# :: -# -# #include <cxxtest/TestSuite.h> -# -# -# -# :: -# -# class MyTestSuite : public CxxTest::TestSuite -# { -# public: -# void testAddition( void ) -# { -# TS_ASSERT( 1 + 1 > 1 ); -# TS_ASSERT_EQUALS( 1 + 1, 2 ); -# } -# }; +#[=======================================================================[.rst: +FindCxxTest +----------- + +Find CxxTest + +Find the CxxTest suite and declare a helper macro for creating unit +tests and integrating them with CTest. For more details on CxxTest +see http://cxxtest.tigris.org + +INPUT Variables + +:: + + CXXTEST_USE_PYTHON [deprecated since 1.3] + Only used in the case both Python & Perl + are detected on the system to control + which CxxTest code generator is used. + Valid only for CxxTest version 3. + + + +:: + + NOTE: In older versions of this Find Module, + this variable controlled if the Python test + generator was used instead of the Perl one, + regardless of which scripting language the + user had installed. + + + +:: + + CXXTEST_TESTGEN_ARGS (since CMake 2.8.3) + Specify a list of options to pass to the CxxTest code + generator. If not defined, --error-printer is + passed. + + + +OUTPUT Variables + +:: + + CXXTEST_FOUND + True if the CxxTest framework was found + CXXTEST_INCLUDE_DIRS + Where to find the CxxTest include directory + CXXTEST_PERL_TESTGEN_EXECUTABLE + The perl-based test generator + CXXTEST_PYTHON_TESTGEN_EXECUTABLE + The python-based test generator + CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3) + The test generator that is actually used (chosen using user preferences + and interpreters found in the system) + CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3) + The full path to the Perl or Python executable on the system, on + platforms where the script cannot be executed using its shebang line. + + + +MACROS for optional use by CMake users: + +:: + + CXXTEST_ADD_TEST(<test_name> <gen_source_file> <input_files_to_testgen...>) + Creates a CxxTest runner and adds it to the CTest testing suite + Parameters: + test_name The name of the test + gen_source_file The generated source filename to be + generated by CxxTest + input_files_to_testgen The list of header files containing the + CxxTest::TestSuite's to be included in + this runner + + + +:: + + #============== + Example Usage: + + + +:: + + find_package(CxxTest) + if(CXXTEST_FOUND) + include_directories(${CXXTEST_INCLUDE_DIR}) + enable_testing() + + + +:: + + CXXTEST_ADD_TEST(unittest_foo foo_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h) + target_link_libraries(unittest_foo foo) # as needed + endif() + + + +:: + + This will (if CxxTest is found): + 1. Invoke the testgen executable to autogenerate foo_test.cc in the + binary tree from "foo_test.h" in the current source directory. + 2. Create an executable and test called unittest_foo. + + + +:: + + #============= + Example foo_test.h: + + + +:: + + #include <cxxtest/TestSuite.h> + + + +:: + + class MyTestSuite : public CxxTest::TestSuite + { + public: + void testAddition( void ) + { + TS_ASSERT( 1 + 1 > 1 ); + TS_ASSERT_EQUALS( 1 + 1, 2 ); + } + }; +#]=======================================================================] # Version 1.4 (11/18/10) (CMake 2.8.4) # Issue 11384: Added support to the CXX_ADD_TEST macro so header diff --git a/Modules/FindCygwin.cmake b/Modules/FindCygwin.cmake index 092a3bd..8811623 100644 --- a/Modules/FindCygwin.cmake +++ b/Modules/FindCygwin.cmake @@ -1,11 +1,12 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindCygwin -# ---------- -# -# this module looks for Cygwin +#[=======================================================================[.rst: +FindCygwin +---------- + +this module looks for Cygwin +#]=======================================================================] if (WIN32) if(CYGWIN_INSTALL_PATH) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 39c1a5b..302c089 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -1,82 +1,83 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindDCMTK -# --------- -# -# Find DCMTK libraries and applications -# -# The module defines the following variables:: -# -# DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK -# DCMTK_LIBRARIES - Files to link against to use DCMTK -# DCMTK_FOUND - If false, don't try to use DCMTK -# DCMTK_DIR - (optional) Source directory for DCMTK -# -# Compatibility -# ^^^^^^^^^^^^^ -# -# This module is able to find a version of DCMTK that does or does not export -# a *DCMTKConfig.cmake* file. It applies a two step process: -# -# * Step 1: Attempt to find DCMTK version providing a *DCMTKConfig.cmake* file. -# * Step 2: If step 1 failed, rely on *FindDCMTK.cmake* to set `DCMTK_*` variables details below. -# -# -# `Recent DCMTK -# <http://git.dcmtk.org/web?p=dcmtk.git;a=commit;h=662ae187c493c6b9a73dd5e3875372cebd0c11fe>`_ -# provides a *DCMTKConfig.cmake* :manual:`package configuration file -# <cmake-packages(7)>`. To exclusively use the package configuration file -# (recommended when possible), pass the `NO_MODULE` option to -# :command:`find_package`. For example, `find_package(DCMTK NO_MODULE)`. -# This requires official DCMTK snapshot *3.6.1_20140617* or newer. -# -# -# Until all clients update to the more recent DCMTK, build systems will need -# to support different versions of DCMTK. -# -# On any given system, the following combinations of DCMTK versions could be -# considered: -# -# +--------+---------------------+-----------------------+-------------------+ -# | | SYSTEM DCMTK | LOCAL DCMTK | Supported ? | -# +--------+---------------------+-----------------------+-------------------+ -# | Case A | NA | [ ] DCMTKConfig | YES | -# +--------+---------------------+-----------------------+-------------------+ -# | Case B | NA | [X] DCMTKConfig | YES | -# +--------+---------------------+-----------------------+-------------------+ -# | Case C | [ ] DCMTKConfig | NA | YES | -# +--------+---------------------+-----------------------+-------------------+ -# | Case D | [X] DCMTKConfig | NA | YES | -# +--------+---------------------+-----------------------+-------------------+ -# | Case E | [ ] DCMTKConfig | [ ] DCMTKConfig | YES (*) | -# +--------+---------------------+-----------------------+-------------------+ -# | Case F | [X] DCMTKConfig | [ ] DCMTKConfig | NO | -# +--------+---------------------+-----------------------+-------------------+ -# | Case G | [ ] DCMTKConfig | [X] DCMTKConfig | YES | -# +--------+---------------------+-----------------------+-------------------+ -# | Case H | [X] DCMTKConfig | [X] DCMTKConfig | YES | -# +--------+---------------------+-----------------------+-------------------+ -# -# (*) See Troubleshooting section. -# -# Legend: -# -# NA ...............: Means that no System or Local DCMTK is available -# -# [ ] DCMTKConfig ..: Means that the version of DCMTK does NOT export a DCMTKConfig.cmake file. -# -# [X] DCMTKConfig ..: Means that the version of DCMTK exports a DCMTKConfig.cmake file. -# -# -# Troubleshooting -# ^^^^^^^^^^^^^^^ -# -# What to do if my project finds a different version of DCMTK? -# -# Remove DCMTK entry from the CMake cache per :command:`find_package` -# documentation. +#[=======================================================================[.rst: +FindDCMTK +--------- + +Find DCMTK libraries and applications + +The module defines the following variables:: + + DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK + DCMTK_LIBRARIES - Files to link against to use DCMTK + DCMTK_FOUND - If false, don't try to use DCMTK + DCMTK_DIR - (optional) Source directory for DCMTK + +Compatibility +^^^^^^^^^^^^^ + +This module is able to find a version of DCMTK that does or does not export +a *DCMTKConfig.cmake* file. It applies a two step process: + +* Step 1: Attempt to find DCMTK version providing a *DCMTKConfig.cmake* file. +* Step 2: If step 1 failed, rely on *FindDCMTK.cmake* to set `DCMTK_*` variables details below. + + +`Recent DCMTK +<http://git.dcmtk.org/web?p=dcmtk.git;a=commit;h=662ae187c493c6b9a73dd5e3875372cebd0c11fe>`_ +provides a *DCMTKConfig.cmake* :manual:`package configuration file +<cmake-packages(7)>`. To exclusively use the package configuration file +(recommended when possible), pass the `NO_MODULE` option to +:command:`find_package`. For example, `find_package(DCMTK NO_MODULE)`. +This requires official DCMTK snapshot *3.6.1_20140617* or newer. + + +Until all clients update to the more recent DCMTK, build systems will need +to support different versions of DCMTK. + +On any given system, the following combinations of DCMTK versions could be +considered: + ++--------+---------------------+-----------------------+-------------------+ +| | SYSTEM DCMTK | LOCAL DCMTK | Supported ? | ++--------+---------------------+-----------------------+-------------------+ +| Case A | NA | [ ] DCMTKConfig | YES | ++--------+---------------------+-----------------------+-------------------+ +| Case B | NA | [X] DCMTKConfig | YES | ++--------+---------------------+-----------------------+-------------------+ +| Case C | [ ] DCMTKConfig | NA | YES | ++--------+---------------------+-----------------------+-------------------+ +| Case D | [X] DCMTKConfig | NA | YES | ++--------+---------------------+-----------------------+-------------------+ +| Case E | [ ] DCMTKConfig | [ ] DCMTKConfig | YES (*) | ++--------+---------------------+-----------------------+-------------------+ +| Case F | [X] DCMTKConfig | [ ] DCMTKConfig | NO | ++--------+---------------------+-----------------------+-------------------+ +| Case G | [ ] DCMTKConfig | [X] DCMTKConfig | YES | ++--------+---------------------+-----------------------+-------------------+ +| Case H | [X] DCMTKConfig | [X] DCMTKConfig | YES | ++--------+---------------------+-----------------------+-------------------+ + + (*) See Troubleshooting section. + +Legend: + + NA ...............: Means that no System or Local DCMTK is available + + [ ] DCMTKConfig ..: Means that the version of DCMTK does NOT export a DCMTKConfig.cmake file. + + [X] DCMTKConfig ..: Means that the version of DCMTK exports a DCMTKConfig.cmake file. + + +Troubleshooting +^^^^^^^^^^^^^^^ + +What to do if my project finds a different version of DCMTK? + +Remove DCMTK entry from the CMake cache per :command:`find_package` +documentation. +#]=======================================================================] # # Written for VXL by Amitha Perera. diff --git a/Modules/FindDart.cmake b/Modules/FindDart.cmake index acd4ef6..0492578 100644 --- a/Modules/FindDart.cmake +++ b/Modules/FindDart.cmake @@ -1,14 +1,15 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindDart -# -------- -# -# Find DART -# -# This module looks for the dart testing software and sets DART_ROOT to -# point to where it found it. +#[=======================================================================[.rst: +FindDart +-------- + +Find DART + +This module looks for the dart testing software and sets DART_ROOT to +point to where it found it. +#]=======================================================================] find_path(DART_ROOT README.INSTALL HINTS diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake index e904a30..9984943 100644 --- a/Modules/FindDevIL.cmake +++ b/Modules/FindDevIL.cmake @@ -1,35 +1,36 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindDevIL -# --------- -# -# -# -# This module locates the developer's image library. -# http://openil.sourceforge.net/ -# -# This module sets: -# -# :: -# -# IL_LIBRARIES - the name of the IL library. These include the full path to -# the core DevIL library. This one has to be linked into the -# application. -# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This -# library is for filters and effects, not actual loading. It -# doesn't have to be linked if the functionality it provides -# is not used. -# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the -# library interfaces with OpenGL. It is not strictly needed -# in applications. -# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files. -# DevIL_FOUND - this is set to TRUE if all the above variables were set. -# This will be set to false if ILU or ILUT are not found, -# even if they are not needed. In most systems, if one -# library is found all the others are as well. That's the -# way the DevIL developers release it. +#[=======================================================================[.rst: +FindDevIL +--------- + + + +This module locates the developer's image library. +http://openil.sourceforge.net/ + +This module sets: + +:: + + IL_LIBRARIES - the name of the IL library. These include the full path to + the core DevIL library. This one has to be linked into the + application. + ILU_LIBRARIES - the name of the ILU library. Again, the full path. This + library is for filters and effects, not actual loading. It + doesn't have to be linked if the functionality it provides + is not used. + ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the + library interfaces with OpenGL. It is not strictly needed + in applications. + IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files. + DevIL_FOUND - this is set to TRUE if all the above variables were set. + This will be set to false if ILU or ILUT are not found, + even if they are not needed. In most systems, if one + library is found all the others are as well. That's the + way the DevIL developers release it. +#]=======================================================================] # TODO: Add version support. # Tested under Linux and Windows (MSVC) diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 39086e4..58e0841 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -1,32 +1,33 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindEXPAT -# --------- -# -# Find the native Expat headers and library. -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``EXPAT::EXPAT`` -# The Expat ``expat`` library, if found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``EXPAT_INCLUDE_DIRS`` -# where to find expat.h, etc. -# ``EXPAT_LIBRARIES`` -# the libraries to link against to use Expat. -# ``EXPAT_FOUND`` -# true if the Expat headers and libraries were found. -# +#[=======================================================================[.rst: +FindEXPAT +--------- + +Find the native Expat headers and library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``EXPAT::EXPAT`` + The Expat ``expat`` library, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``EXPAT_INCLUDE_DIRS`` + where to find expat.h, etc. +``EXPAT_LIBRARIES`` + the libraries to link against to use Expat. +``EXPAT_FOUND`` + true if the Expat headers and libraries were found. + +#]=======================================================================] find_package(PkgConfig QUIET) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 3945b78..edebe75 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -1,100 +1,101 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindFLEX -# -------- -# -# Find flex executable and provides a macro to generate custom build rules -# -# -# -# The module defines the following variables: -# -# :: -# -# FLEX_FOUND - true is flex executable is found -# FLEX_EXECUTABLE - the path to the flex executable -# FLEX_VERSION - the version of flex -# FLEX_LIBRARIES - The flex libraries -# FLEX_INCLUDE_DIRS - The path to the flex headers -# -# -# -# The minimum required version of flex can be specified using the -# standard syntax, e.g. find_package(FLEX 2.5.13) -# -# -# -# If flex is found on the system, the module provides the macro: -# -# :: -# -# FLEX_TARGET(Name FlexInput FlexOutput -# [COMPILE_FLAGS <string>] -# [DEFINES_FILE <string>] -# ) -# -# which creates a custom command to generate the <FlexOutput> file from -# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next -# parameter is added to the flex command line. If flex is configured to -# output a header file, the DEFINES_FILE option may be used to specify its -# name. Name is an alias used to get details of this custom command. -# Indeed the macro defines the following variables: -# -# :: -# -# FLEX_${Name}_DEFINED - true is the macro ran successfully -# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an -# alias for FlexOutput -# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput} -# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any. -# -# -# -# Flex scanners often use tokens defined by Bison: the code generated -# by Flex depends of the header generated by Bison. This module also -# defines a macro: -# -# :: -# -# ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget) -# -# which adds the required dependency between a scanner and a parser -# where <FlexTarget> and <BisonTarget> are the first parameters of -# respectively FLEX_TARGET and BISON_TARGET macros. -# -# :: -# -# ==================================================================== -# Example: -# -# -# -# :: -# -# find_package(BISON) -# find_package(FLEX) -# -# -# -# :: -# -# BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp) -# FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp) -# ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser) -# -# -# -# :: -# -# include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# add_executable(Foo -# Foo.cc -# ${BISON_MyParser_OUTPUTS} -# ${FLEX_MyScanner_OUTPUTS} -# ) -# ==================================================================== +#[=======================================================================[.rst: +FindFLEX +-------- + +Find flex executable and provides a macro to generate custom build rules + + + +The module defines the following variables: + +:: + + FLEX_FOUND - true is flex executable is found + FLEX_EXECUTABLE - the path to the flex executable + FLEX_VERSION - the version of flex + FLEX_LIBRARIES - The flex libraries + FLEX_INCLUDE_DIRS - The path to the flex headers + + + +The minimum required version of flex can be specified using the +standard syntax, e.g. find_package(FLEX 2.5.13) + + + +If flex is found on the system, the module provides the macro: + +:: + + FLEX_TARGET(Name FlexInput FlexOutput + [COMPILE_FLAGS <string>] + [DEFINES_FILE <string>] + ) + +which creates a custom command to generate the <FlexOutput> file from +the <FlexInput> file. If COMPILE_FLAGS option is specified, the next +parameter is added to the flex command line. If flex is configured to +output a header file, the DEFINES_FILE option may be used to specify its +name. Name is an alias used to get details of this custom command. +Indeed the macro defines the following variables: + +:: + + FLEX_${Name}_DEFINED - true is the macro ran successfully + FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an + alias for FlexOutput + FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput} + FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any. + + + +Flex scanners often use tokens defined by Bison: the code generated +by Flex depends of the header generated by Bison. This module also +defines a macro: + +:: + + ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget) + +which adds the required dependency between a scanner and a parser +where <FlexTarget> and <BisonTarget> are the first parameters of +respectively FLEX_TARGET and BISON_TARGET macros. + +:: + + ==================================================================== + Example: + + + +:: + + find_package(BISON) + find_package(FLEX) + + + +:: + + BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp) + FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp) + ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser) + + + +:: + + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + add_executable(Foo + Foo.cc + ${BISON_MyParser_OUTPUTS} + ${FLEX_MyScanner_OUTPUTS} + ) + ==================================================================== +#]=======================================================================] find_program(FLEX_EXECUTABLE NAMES flex win_flex DOC "path to the flex executable") mark_as_advanced(FLEX_EXECUTABLE) diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index 82c63ef..89122c0 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -1,82 +1,83 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindFLTK -# -------- -# -# Find the FLTK library -# -# Input Variables -# ^^^^^^^^^^^^^^^ -# -# By default this module will search for all of the FLTK components and -# add them to the FLTK_LIBRARIES variable. You can limit the components -# which get placed in FLTK_LIBRARIES by defining one or more of the -# following three options: -# -# ``FLTK_SKIP_OPENGL`` -# Set to true to disable searching for the FLTK GL library -# -# ``FLTK_SKIP_FORMS`` -# Set to true to disable searching for the FLTK Forms library -# -# ``FLTK_SKIP_IMAGES`` -# Set to true to disable searching for the FLTK Images library -# -# FLTK is composed also by a binary tool. You can set the following option: -# -# ``FLTK_SKIP_FLUID`` -# Set to true to not look for the FLUID binary -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# The following variables will be defined: -# -# ``FLTK_FOUND`` -# True if all components not skipped were found -# -# ``FLTK_INCLUDE_DIR`` -# Path to the include directory for FLTK header files -# -# ``FLTK_LIBRARIES`` -# List of the FLTK libraries found -# -# ``FLTK_FLUID_EXECUTABLE`` -# Path to the FLUID binary tool -# -# ``FLTK_WRAP_UI`` -# True if FLUID is found, used to enable the FLTK_WRAP_UI command -# -# Cache Variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables are also available to set or use: -# -# ``FLTK_BASE_LIBRARY_RELEASE`` -# The FLTK base library (optimized) -# -# ``FLTK_BASE_LIBRARY_DEBUG`` -# The FLTK base library (debug) -# -# ``FLTK_GL_LIBRARY_RELEASE`` -# The FLTK GL library (optimized) -# -# ``FLTK_GL_LIBRARY_DEBUG`` -# The FLTK GL library (debug) -# -# ``FLTK_FORMS_LIBRARY_RELEASE`` -# The FLTK Forms library (optimized) -# -# ``FLTK_FORMS_LIBRARY_DEBUG`` -# The FLTK Forms library (debug) -# -# ``FLTK_IMAGES_LIBRARY_RELEASE`` -# The FLTK Images protobuf library (optimized) -# -# ``FLTK_IMAGES_LIBRARY_DEBUG`` -# The FLTK Images library (debug) +#[=======================================================================[.rst: +FindFLTK +-------- + +Find the FLTK library + +Input Variables +^^^^^^^^^^^^^^^ + +By default this module will search for all of the FLTK components and +add them to the FLTK_LIBRARIES variable. You can limit the components +which get placed in FLTK_LIBRARIES by defining one or more of the +following three options: + +``FLTK_SKIP_OPENGL`` + Set to true to disable searching for the FLTK GL library + +``FLTK_SKIP_FORMS`` + Set to true to disable searching for the FLTK Forms library + +``FLTK_SKIP_IMAGES`` + Set to true to disable searching for the FLTK Images library + +FLTK is composed also by a binary tool. You can set the following option: + +``FLTK_SKIP_FLUID`` + Set to true to not look for the FLUID binary + +Result Variables +^^^^^^^^^^^^^^^^ + +The following variables will be defined: + +``FLTK_FOUND`` + True if all components not skipped were found + +``FLTK_INCLUDE_DIR`` + Path to the include directory for FLTK header files + +``FLTK_LIBRARIES`` + List of the FLTK libraries found + +``FLTK_FLUID_EXECUTABLE`` + Path to the FLUID binary tool + +``FLTK_WRAP_UI`` + True if FLUID is found, used to enable the FLTK_WRAP_UI command + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables are also available to set or use: + +``FLTK_BASE_LIBRARY_RELEASE`` + The FLTK base library (optimized) + +``FLTK_BASE_LIBRARY_DEBUG`` + The FLTK base library (debug) + +``FLTK_GL_LIBRARY_RELEASE`` + The FLTK GL library (optimized) + +``FLTK_GL_LIBRARY_DEBUG`` + The FLTK GL library (debug) + +``FLTK_FORMS_LIBRARY_RELEASE`` + The FLTK Forms library (optimized) + +``FLTK_FORMS_LIBRARY_DEBUG`` + The FLTK Forms library (debug) + +``FLTK_IMAGES_LIBRARY_RELEASE`` + The FLTK Images protobuf library (optimized) + +``FLTK_IMAGES_LIBRARY_DEBUG`` + The FLTK Images library (debug) +#]=======================================================================] if(NOT FLTK_SKIP_OPENGL) find_package(OpenGL) diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake index 365a82a..161d15c 100644 --- a/Modules/FindFLTK2.cmake +++ b/Modules/FindFLTK2.cmake @@ -1,29 +1,30 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindFLTK2 -# --------- -# -# Find the native FLTK2 includes and library -# -# The following settings are defined -# -# :: -# -# FLTK2_FLUID_EXECUTABLE, where to find the Fluid tool -# FLTK2_WRAP_UI, This enables the FLTK2_WRAP_UI command -# FLTK2_INCLUDE_DIR, where to find include files -# FLTK2_LIBRARIES, list of fltk2 libraries -# FLTK2_FOUND, Don't use FLTK2 if false. -# -# The following settings should not be used in general. -# -# :: -# -# FLTK2_BASE_LIBRARY = the full path to fltk2.lib -# FLTK2_GL_LIBRARY = the full path to fltk2_gl.lib -# FLTK2_IMAGES_LIBRARY = the full path to fltk2_images.lib +#[=======================================================================[.rst: +FindFLTK2 +--------- + +Find the native FLTK2 includes and library + +The following settings are defined + +:: + + FLTK2_FLUID_EXECUTABLE, where to find the Fluid tool + FLTK2_WRAP_UI, This enables the FLTK2_WRAP_UI command + FLTK2_INCLUDE_DIR, where to find include files + FLTK2_LIBRARIES, list of fltk2 libraries + FLTK2_FOUND, Don't use FLTK2 if false. + +The following settings should not be used in general. + +:: + + FLTK2_BASE_LIBRARY = the full path to fltk2.lib + FLTK2_GL_LIBRARY = the full path to fltk2_gl.lib + FLTK2_IMAGES_LIBRARY = the full path to fltk2_images.lib +#]=======================================================================] set (FLTK2_DIR $ENV{FLTK2_DIR} ) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 61643be..3e6a177 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -1,45 +1,46 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindFreetype -# ------------ -# -# Find the FreeType font renderer includes and library. -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` target: -# -# ``Freetype::Freetype`` -# The Freetype ``freetype`` library, if found -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``FREETYPE_FOUND`` -# true if the Freetype headers and libraries were found -# ``FREETYPE_INCLUDE_DIRS`` -# directories containing the Freetype headers. This is the -# concatenation of the variables: -# -# ``FREETYPE_INCLUDE_DIR_ft2build`` -# directory holding the main Freetype API configuration header -# ``FREETYPE_INCLUDE_DIR_freetype2`` -# directory holding Freetype public headers -# ``FREETYPE_LIBRARIES`` -# the library to link against -# ``FREETYPE_VERSION_STRING`` -# the version of freetype found (since CMake 2.8.8) -# -# Hints -# ^^^^^ -# -# The user may set the environment variable ``FREETYPE_DIR`` to the root -# directory of a Freetype installation. +#[=======================================================================[.rst: +FindFreetype +------------ + +Find the FreeType font renderer includes and library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``Freetype::Freetype`` + The Freetype ``freetype`` library, if found + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``FREETYPE_FOUND`` + true if the Freetype headers and libraries were found +``FREETYPE_INCLUDE_DIRS`` + directories containing the Freetype headers. This is the + concatenation of the variables: + + ``FREETYPE_INCLUDE_DIR_ft2build`` + directory holding the main Freetype API configuration header + ``FREETYPE_INCLUDE_DIR_freetype2`` + directory holding Freetype public headers +``FREETYPE_LIBRARIES`` + the library to link against +``FREETYPE_VERSION_STRING`` + the version of freetype found (since CMake 2.8.8) + +Hints +^^^^^ + +The user may set the environment variable ``FREETYPE_DIR`` to the root +directory of a Freetype installation. +#]=======================================================================] # Created by Eric Wing. # Modifications by Alexander Neundorf. diff --git a/Modules/FindGCCXML.cmake b/Modules/FindGCCXML.cmake index 1f8d738..e6c7f24 100644 --- a/Modules/FindGCCXML.cmake +++ b/Modules/FindGCCXML.cmake @@ -1,19 +1,20 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGCCXML -# ---------- -# -# Find the GCC-XML front-end executable. -# -# -# -# This module will define the following variables: -# -# :: -# -# GCCXML - the GCC-XML front-end executable. +#[=======================================================================[.rst: +FindGCCXML +---------- + +Find the GCC-XML front-end executable. + + + +This module will define the following variables: + +:: + + GCCXML - the GCC-XML front-end executable. +#]=======================================================================] find_program(GCCXML NAMES gccxml diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index ff2976e..030553f 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -1,29 +1,30 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGDAL -# -------- -# -# -# -# Locate gdal -# -# This module accepts the following environment variables: -# -# :: -# -# GDAL_DIR or GDAL_ROOT - Specify the location of GDAL -# -# -# -# This module defines the following CMake variables: -# -# :: -# -# GDAL_FOUND - True if libgdal is found -# GDAL_LIBRARY - A variable pointing to the GDAL library -# GDAL_INCLUDE_DIR - Where to find the headers +#[=======================================================================[.rst: +FindGDAL +-------- + + + +Locate gdal + +This module accepts the following environment variables: + +:: + + GDAL_DIR or GDAL_ROOT - Specify the location of GDAL + + + +This module defines the following CMake variables: + +:: + + GDAL_FOUND - True if libgdal is found + GDAL_LIBRARY - A variable pointing to the GDAL library + GDAL_INCLUDE_DIR - Where to find the headers +#]=======================================================================] # # $GDALDIR is an environment variable that would diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index efc3973..9a995af 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -1,28 +1,29 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGIF -# ------- -# -# This finds the GIF library (giflib) -# -# The module defines the following variables: -# -# ``GIF_FOUND`` -# True if giflib was found -# ``GIF_LIBRARIES`` -# Libraries to link to in order to use giflib -# ``GIF_INCLUDE_DIR`` -# where to find the headers -# ``GIF_VERSION`` -# 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6 -# -# The minimum required version of giflib can be specified using the -# standard syntax, e.g. find_package(GIF 4) -# -# $GIF_DIR is an environment variable that would correspond to the -# ./configure --prefix=$GIF_DIR +#[=======================================================================[.rst: +FindGIF +------- + +This finds the GIF library (giflib) + +The module defines the following variables: + +``GIF_FOUND`` + True if giflib was found +``GIF_LIBRARIES`` + Libraries to link to in order to use giflib +``GIF_INCLUDE_DIR`` + where to find the headers +``GIF_VERSION`` + 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6 + +The minimum required version of giflib can be specified using the +standard syntax, e.g. find_package(GIF 4) + +$GIF_DIR is an environment variable that would correspond to the +./configure --prefix=$GIF_DIR +#]=======================================================================] # Created by Eric Wing. # Modifications by Alexander Neundorf, Ben Campbell diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index 11e8724..ad8a810 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -1,28 +1,29 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGLEW -# -------- -# -# Find the OpenGL Extension Wrangler Library (GLEW) -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``, -# if GLEW has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# :: -# -# GLEW_INCLUDE_DIRS - include directories for GLEW -# GLEW_LIBRARIES - libraries to link against GLEW -# GLEW_FOUND - true if GLEW has been found and can be used +#[=======================================================================[.rst: +FindGLEW +-------- + +Find the OpenGL Extension Wrangler Library (GLEW) + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``, +if GLEW has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + GLEW_INCLUDE_DIRS - include directories for GLEW + GLEW_LIBRARIES - libraries to link against GLEW + GLEW_FOUND - true if GLEW has been found and can be used +#]=======================================================================] find_path(GLEW_INCLUDE_DIR GL/glew.h) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 1779683..d42db53 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -1,38 +1,39 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGLUT -# -------- -# -# try to find glut library and include files. -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the :prop_tgt:`IMPORTED` targets: -# -# ``GLUT::GLUT`` -# Defined if the system has GLUT. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module sets the following variables: -# -# :: -# -# GLUT_INCLUDE_DIR, where to find GL/glut.h, etc. -# GLUT_LIBRARIES, the libraries to link against -# GLUT_FOUND, If false, do not try to use GLUT. -# -# Also defined, but not for general use are: -# -# :: -# -# GLUT_glut_LIBRARY = the full path to the glut library. -# GLUT_Xmu_LIBRARY = the full path to the Xmu library. -# GLUT_Xi_LIBRARY = the full path to the Xi Library. +#[=======================================================================[.rst: +FindGLUT +-------- + +try to find glut library and include files. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines the :prop_tgt:`IMPORTED` targets: + +``GLUT::GLUT`` + Defined if the system has GLUT. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +:: + + GLUT_INCLUDE_DIR, where to find GL/glut.h, etc. + GLUT_LIBRARIES, the libraries to link against + GLUT_FOUND, If false, do not try to use GLUT. + +Also defined, but not for general use are: + +:: + + GLUT_glut_LIBRARY = the full path to the glut library. + GLUT_Xmu_LIBRARY = the full path to the Xmu library. + GLUT_Xi_LIBRARY = the full path to the Xi Library. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake index 8d10b6c..db05121 100644 --- a/Modules/FindGSL.cmake +++ b/Modules/FindGSL.cmake @@ -1,60 +1,61 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGSL -# -------- -# -# Find the native GSL includes and libraries. -# -# The GNU Scientific Library (GSL) is a numerical library for C and C++ -# programmers. It is free software under the GNU General Public -# License. -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# -# If GSL is found, this module defines the following :prop_tgt:`IMPORTED` -# targets:: -# -# GSL::gsl - The main GSL library. -# GSL::gslcblas - The CBLAS support library used by GSL. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project:: -# -# GSL_FOUND - True if GSL found on the local system -# GSL_INCLUDE_DIRS - Location of GSL header files. -# GSL_LIBRARIES - The GSL libraries. -# GSL_VERSION - The version of the discovered GSL install. -# -# Hints -# ^^^^^ -# -# Set ``GSL_ROOT_DIR`` to a directory that contains a GSL installation. -# -# This script expects to find libraries at ``$GSL_ROOT_DIR/lib`` and the GSL -# headers at ``$GSL_ROOT_DIR/include/gsl``. The library directory may -# optionally provide Release and Debug folders. If available, the libraries -# named ``gsld``, ``gslblasd`` or ``cblasd`` are recognized as debug libraries. -# For Unix-like systems, this script will use ``$GSL_ROOT_DIR/bin/gsl-config`` -# (if found) to aid in the discovery of GSL. -# -# Cache Variables -# ^^^^^^^^^^^^^^^ -# -# This module may set the following variables depending on platform and type -# of GSL installation discovered. These variables may optionally be set to -# help this module find the correct files:: -# -# GSL_CBLAS_LIBRARY - Location of the GSL CBLAS library. -# GSL_CBLAS_LIBRARY_DEBUG - Location of the debug GSL CBLAS library (if any). -# GSL_CONFIG_EXECUTABLE - Location of the ``gsl-config`` script (if any). -# GSL_LIBRARY - Location of the GSL library. -# GSL_LIBRARY_DEBUG - Location of the debug GSL library (if any). -# +#[=======================================================================[.rst: +FindGSL +-------- + +Find the native GSL includes and libraries. + +The GNU Scientific Library (GSL) is a numerical library for C and C++ +programmers. It is free software under the GNU General Public +License. + +Imported Targets +^^^^^^^^^^^^^^^^ + +If GSL is found, this module defines the following :prop_tgt:`IMPORTED` +targets:: + + GSL::gsl - The main GSL library. + GSL::gslcblas - The CBLAS support library used by GSL. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project:: + + GSL_FOUND - True if GSL found on the local system + GSL_INCLUDE_DIRS - Location of GSL header files. + GSL_LIBRARIES - The GSL libraries. + GSL_VERSION - The version of the discovered GSL install. + +Hints +^^^^^ + +Set ``GSL_ROOT_DIR`` to a directory that contains a GSL installation. + +This script expects to find libraries at ``$GSL_ROOT_DIR/lib`` and the GSL +headers at ``$GSL_ROOT_DIR/include/gsl``. The library directory may +optionally provide Release and Debug folders. If available, the libraries +named ``gsld``, ``gslblasd`` or ``cblasd`` are recognized as debug libraries. +For Unix-like systems, this script will use ``$GSL_ROOT_DIR/bin/gsl-config`` +(if found) to aid in the discovery of GSL. + +Cache Variables +^^^^^^^^^^^^^^^ + +This module may set the following variables depending on platform and type +of GSL installation discovered. These variables may optionally be set to +help this module find the correct files:: + + GSL_CBLAS_LIBRARY - Location of the GSL CBLAS library. + GSL_CBLAS_LIBRARY_DEBUG - Location of the debug GSL CBLAS library (if any). + GSL_CONFIG_EXECUTABLE - Location of the ``gsl-config`` script (if any). + GSL_LIBRARY - Location of the GSL library. + GSL_LIBRARY_DEBUG - Location of the debug GSL library (if any). + +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindGTK.cmake b/Modules/FindGTK.cmake index 89fb54b..8cc6c97 100644 --- a/Modules/FindGTK.cmake +++ b/Modules/FindGTK.cmake @@ -1,18 +1,19 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGTK -# ------- -# -# try to find GTK (and glib) and GTKGLArea -# -# :: -# -# GTK_INCLUDE_DIR - Directories to include to use GTK -# GTK_LIBRARIES - Files to link against to use GTK -# GTK_FOUND - GTK was found -# GTK_GL_FOUND - GTK's GL features were found +#[=======================================================================[.rst: +FindGTK +------- + +try to find GTK (and glib) and GTKGLArea + +:: + + GTK_INCLUDE_DIR - Directories to include to use GTK + GTK_LIBRARIES - Files to link against to use GTK + GTK_FOUND - GTK was found + GTK_GL_FOUND - GTK's GL features were found +#]=======================================================================] # don't even bother under WIN32 if(UNIX) diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 15d1230..6c1897c 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -1,102 +1,103 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGTK2 -# -------- -# -# FindGTK2.cmake -# -# This module can find the GTK2 widget libraries and several of its -# other optional components like gtkmm, glade, and glademm. -# -# NOTE: If you intend to use version checking, CMake 2.6.2 or later is -# -# :: -# -# required. -# -# -# -# Specify one or more of the following components as you call this find -# module. See example below. -# -# :: -# -# gtk -# gtkmm -# glade -# glademm -# -# -# -# The following variables will be defined for your use -# -# :: -# -# GTK2_FOUND - Were all of your specified components found? -# GTK2_INCLUDE_DIRS - All include directories -# GTK2_LIBRARIES - All libraries -# GTK2_TARGETS - All imported targets -# GTK2_DEFINITIONS - Additional compiler flags -# -# -# -# :: -# -# GTK2_VERSION - The version of GTK2 found (x.y.z) -# GTK2_MAJOR_VERSION - The major version of GTK2 -# GTK2_MINOR_VERSION - The minor version of GTK2 -# GTK2_PATCH_VERSION - The patch version of GTK2 -# -# -# -# Optional variables you can define prior to calling this module: -# -# :: -# -# GTK2_DEBUG - Enables verbose debugging of the module -# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to -# search for include files -# -# -# -# ================= Example Usage: -# -# :: -# -# Call find_package() once, here are some examples to pick from: -# -# -# -# :: -# -# Require GTK 2.6 or later -# find_package(GTK2 2.6 REQUIRED gtk) -# -# -# -# :: -# -# Require GTK 2.10 or later and Glade -# find_package(GTK2 2.10 REQUIRED gtk glade) -# -# -# -# :: -# -# Search for GTK/GTKMM 2.8 or later -# find_package(GTK2 2.8 COMPONENTS gtk gtkmm) -# -# -# -# :: -# -# if(GTK2_FOUND) -# include_directories(${GTK2_INCLUDE_DIRS}) -# add_executable(mygui mygui.cc) -# target_link_libraries(mygui ${GTK2_LIBRARIES}) -# endif() +#[=======================================================================[.rst: +FindGTK2 +-------- + +FindGTK2.cmake + +This module can find the GTK2 widget libraries and several of its +other optional components like gtkmm, glade, and glademm. + +NOTE: If you intend to use version checking, CMake 2.6.2 or later is + +:: + + required. + + + +Specify one or more of the following components as you call this find +module. See example below. + +:: + + gtk + gtkmm + glade + glademm + + + +The following variables will be defined for your use + +:: + + GTK2_FOUND - Were all of your specified components found? + GTK2_INCLUDE_DIRS - All include directories + GTK2_LIBRARIES - All libraries + GTK2_TARGETS - All imported targets + GTK2_DEFINITIONS - Additional compiler flags + + + +:: + + GTK2_VERSION - The version of GTK2 found (x.y.z) + GTK2_MAJOR_VERSION - The major version of GTK2 + GTK2_MINOR_VERSION - The minor version of GTK2 + GTK2_PATCH_VERSION - The patch version of GTK2 + + + +Optional variables you can define prior to calling this module: + +:: + + GTK2_DEBUG - Enables verbose debugging of the module + GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to + search for include files + + + +================= Example Usage: + +:: + + Call find_package() once, here are some examples to pick from: + + + +:: + + Require GTK 2.6 or later + find_package(GTK2 2.6 REQUIRED gtk) + + + +:: + + Require GTK 2.10 or later and Glade + find_package(GTK2 2.10 REQUIRED gtk glade) + + + +:: + + Search for GTK/GTKMM 2.8 or later + find_package(GTK2 2.8 COMPONENTS gtk gtkmm) + + + +:: + + if(GTK2_FOUND) + include_directories(${GTK2_INCLUDE_DIRS}) + add_executable(mygui mygui.cc) + target_link_libraries(mygui ${GTK2_LIBRARIES}) + endif() +#]=======================================================================] # Version 1.6 (CMake 3.0) # * Create targets for each library diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index b0579d9..b0175fe 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -1,77 +1,78 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGTest -# --------- -# -# Locate the Google C++ Testing Framework. -# -# Imported targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``GTest::GTest`` -# The Google Test ``gtest`` library, if found; adds Thread::Thread -# automatically -# ``GTest::Main`` -# The Google Test ``gtest_main`` library, if found -# -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``GTEST_FOUND`` -# Found the Google Testing framework -# ``GTEST_INCLUDE_DIRS`` -# the directory containing the Google Test headers -# -# The library variables below are set as normal variables. These -# contain debug/optimized keywords when a debugging library is found. -# -# ``GTEST_LIBRARIES`` -# The Google Test ``gtest`` library; note it also requires linking -# with an appropriate thread library -# ``GTEST_MAIN_LIBRARIES`` -# The Google Test ``gtest_main`` library -# ``GTEST_BOTH_LIBRARIES`` -# Both ``gtest`` and ``gtest_main`` -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``GTEST_ROOT`` -# The root directory of the Google Test installation (may also be -# set as an environment variable) -# ``GTEST_MSVC_SEARCH`` -# If compiling with MSVC, this variable can be set to ``MT`` or -# ``MD`` (the default) to enable searching a GTest build tree -# -# -# Example usage -# ^^^^^^^^^^^^^ -# -# :: -# -# enable_testing() -# find_package(GTest REQUIRED) -# -# add_executable(foo foo.cc) -# target_link_libraries(foo GTest::GTest GTest::Main) -# -# add_test(AllTestsInFoo foo) -# -# -# Deeper integration with CTest -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# See :module:`GoogleTest` for information on the :command:`gtest_add_tests` -# and :command:`gtest_discover_tests` commands. +#[=======================================================================[.rst: +FindGTest +--------- + +Locate the Google C++ Testing Framework. + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``GTest::GTest`` + The Google Test ``gtest`` library, if found; adds Thread::Thread + automatically +``GTest::Main`` + The Google Test ``gtest_main`` library, if found + + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``GTEST_FOUND`` + Found the Google Testing framework +``GTEST_INCLUDE_DIRS`` + the directory containing the Google Test headers + +The library variables below are set as normal variables. These +contain debug/optimized keywords when a debugging library is found. + +``GTEST_LIBRARIES`` + The Google Test ``gtest`` library; note it also requires linking + with an appropriate thread library +``GTEST_MAIN_LIBRARIES`` + The Google Test ``gtest_main`` library +``GTEST_BOTH_LIBRARIES`` + Both ``gtest`` and ``gtest_main`` + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``GTEST_ROOT`` + The root directory of the Google Test installation (may also be + set as an environment variable) +``GTEST_MSVC_SEARCH`` + If compiling with MSVC, this variable can be set to ``MT`` or + ``MD`` (the default) to enable searching a GTest build tree + + +Example usage +^^^^^^^^^^^^^ + +:: + + enable_testing() + find_package(GTest REQUIRED) + + add_executable(foo foo.cc) + target_link_libraries(foo GTest::GTest GTest::Main) + + add_test(AllTestsInFoo foo) + + +Deeper integration with CTest +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +See :module:`GoogleTest` for information on the :command:`gtest_add_tests` +and :command:`gtest_discover_tests` commands. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/GoogleTest.cmake) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 9623b85..9e29e8d 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -1,61 +1,62 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGettext -# ----------- -# -# Find GNU gettext tools -# -# This module looks for the GNU gettext tools. This module defines the -# following values: -# -# :: -# -# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. -# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. -# GETTEXT_FOUND: True if gettext has been found. -# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8) -# -# -# -# Additionally it provides the following macros: -# -# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) -# -# :: -# -# This will create a target "translations" which will convert the -# given input po files into the binary output mo file. If the -# ALL option is used, the translations will also be created when -# building the default target. -# -# GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>] -# LANGUAGES <lang1> <lang2> ... ) -# -# :: -# -# Process the given pot file to mo files. -# If INSTALL_DESTINATION is given then automatically install rules will -# be created, the language subdirectory will be taken into account -# (by default use share/locale/). -# If ALL is specified, the pot file is processed when building the all traget. -# It creates a custom target "potfile". -# -# GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>] -# PO_FILES <po1> <po2> ... ) -# -# :: -# -# Process the given po files to mo files for the given language. -# If INSTALL_DESTINATION is given then automatically install rules will -# be created, the language subdirectory will be taken into account -# (by default use share/locale/). -# If ALL is specified, the po files are processed when building the all traget. -# It creates a custom target "pofiles". -# -# .. note:: -# If you wish to use the Gettext library (libintl), use :module:`FindIntl`. +#[=======================================================================[.rst: +FindGettext +----------- + +Find GNU gettext tools + +This module looks for the GNU gettext tools. This module defines the +following values: + +:: + + GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. + GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. + GETTEXT_FOUND: True if gettext has been found. + GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8) + + + +Additionally it provides the following macros: + +GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) + +:: + + This will create a target "translations" which will convert the + given input po files into the binary output mo file. If the + ALL option is used, the translations will also be created when + building the default target. + +GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>] +LANGUAGES <lang1> <lang2> ... ) + +:: + + Process the given pot file to mo files. + If INSTALL_DESTINATION is given then automatically install rules will + be created, the language subdirectory will be taken into account + (by default use share/locale/). + If ALL is specified, the pot file is processed when building the all traget. + It creates a custom target "potfile". + +GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>] +PO_FILES <po1> <po2> ... ) + +:: + + Process the given po files to mo files for the given language. + If INSTALL_DESTINATION is given then automatically install rules will + be created, the language subdirectory will be taken into account + (by default use share/locale/). + If ALL is specified, the po files are processed when building the all traget. + It creates a custom target "pofiles". + +.. note:: + If you wish to use the Gettext library (libintl), use :module:`FindIntl`. +#]=======================================================================] find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index fae31eb..c447a1a 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -1,27 +1,28 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGit -# ------- -# -# The module defines the following variables: -# -# ``GIT_EXECUTABLE`` -# Path to Git command-line client. -# ``Git_FOUND``, ``GIT_FOUND`` -# True if the Git command-line client was found. -# ``GIT_VERSION_STRING`` -# The version of Git found. -# -# Example usage: -# -# .. code-block:: cmake -# -# find_package(Git) -# if(Git_FOUND) -# message("Git found: ${GIT_EXECUTABLE}") -# endif() +#[=======================================================================[.rst: +FindGit +------- + +The module defines the following variables: + +``GIT_EXECUTABLE`` + Path to Git command-line client. +``Git_FOUND``, ``GIT_FOUND`` + True if the Git command-line client was found. +``GIT_VERSION_STRING`` + The version of Git found. + +Example usage: + +.. code-block:: cmake + + find_package(Git) + if(Git_FOUND) + message("Git found: ${GIT_EXECUTABLE}") + endif() +#]=======================================================================] # Look for 'git' or 'eg' (easy git) # diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake index 1a97d99..9c07444 100644 --- a/Modules/FindGnuTLS.cmake +++ b/Modules/FindGnuTLS.cmake @@ -1,22 +1,23 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGnuTLS -# ---------- -# -# Try to find the GNU Transport Layer Security library (gnutls) -# -# -# -# Once done this will define -# -# :: -# -# GNUTLS_FOUND - System has gnutls -# GNUTLS_INCLUDE_DIR - The gnutls include directory -# GNUTLS_LIBRARIES - The libraries needed to use gnutls -# GNUTLS_DEFINITIONS - Compiler switches required for using gnutls +#[=======================================================================[.rst: +FindGnuTLS +---------- + +Try to find the GNU Transport Layer Security library (gnutls) + + + +Once done this will define + +:: + + GNUTLS_FOUND - System has gnutls + GNUTLS_INCLUDE_DIR - The gnutls include directory + GNUTLS_LIBRARIES - The libraries needed to use gnutls + GNUTLS_DEFINITIONS - Compiler switches required for using gnutls +#]=======================================================================] # Note that this doesn't try to find the gnutls-extra package. diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake index aa4cd6c..ca2467d 100644 --- a/Modules/FindGnuplot.cmake +++ b/Modules/FindGnuplot.cmake @@ -1,25 +1,26 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindGnuplot -# ----------- -# -# this module looks for gnuplot -# -# -# -# Once done this will define -# -# :: -# -# GNUPLOT_FOUND - system has Gnuplot -# GNUPLOT_EXECUTABLE - the Gnuplot executable -# GNUPLOT_VERSION_STRING - the version of Gnuplot found (since CMake 2.8.8) -# -# -# -# GNUPLOT_VERSION_STRING will not work for old versions like 3.7.1. +#[=======================================================================[.rst: +FindGnuplot +----------- + +this module looks for gnuplot + + + +Once done this will define + +:: + + GNUPLOT_FOUND - system has Gnuplot + GNUPLOT_EXECUTABLE - the Gnuplot executable + GNUPLOT_VERSION_STRING - the version of Gnuplot found (since CMake 2.8.8) + + + +GNUPLOT_VERSION_STRING will not work for old versions like 3.7.1. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 41b1002..e36767a 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -1,109 +1,110 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindHDF5 -# -------- -# -# Find HDF5, a library for reading and writing self describing array data. -# -# -# -# This module invokes the HDF5 wrapper compiler that should be installed -# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper -# compiler is called either h5cc or h5pcc. If this succeeds, the module -# will then call the compiler with the -show argument to see what flags -# are used when compiling an HDF5 client application. -# -# The module will optionally accept the COMPONENTS argument. If no -# COMPONENTS are specified, then the find module will default to finding -# only the HDF5 C library. If one or more COMPONENTS are specified, the -# module will attempt to find the language bindings for the specified -# components. The only valid components are C, CXX, Fortran, HL, and -# Fortran_HL. If the COMPONENTS argument is not given, the module will -# attempt to find only the C bindings. -# -# This module will read the variable -# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a -# static link to a dynamic link for HDF5 and all of it's dependencies. -# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES -# variable is set before the call to find_package. -# -# To provide the module with a hint about where to find your HDF5 -# installation, you can set the environment variable HDF5_ROOT. The -# Find module will then look in this path when searching for HDF5 -# executables, paths, and libraries. -# -# Both the serial and parallel HDF5 wrappers are considered and the first -# directory to contain either one will be used. In the event that both appear -# in the same directory the serial version is preferentially selected. This -# behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to -# true. -# -# In addition to finding the includes and libraries required to compile -# an HDF5 client application, this module also makes an effort to find -# tools that come with the HDF5 distribution that may be useful for -# regression testing. -# -# This module will define the following variables: -# -# :: -# -# HDF5_FOUND - true if HDF5 was found on the system -# HDF5_VERSION - HDF5 version in format Major.Minor.Release -# HDF5_INCLUDE_DIRS - Location of the hdf5 includes -# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) -# HDF5_DEFINITIONS - Required compiler definitions for HDF5 -# HDF5_LIBRARIES - Required libraries for all requested bindings -# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all -# bindings, if the HL component is enabled -# -# Available components are: C CXX Fortran and HL. For each enabled language -# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially -# HDF5_${LANG}_DEFINITIONS, will be defined. -# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will -# also be defined. With all components enabled, the following variables will be defined: -# -# :: -# -# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings -# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings -# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings -# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings -# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings -# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings -# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings -# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings -# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings -# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings -# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran -# bindings. -# -# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support -# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler -# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler -# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler -# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler -# which is also the HDF5 wrapper -# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ -# compiler which is also -# the HDF5 wrapper -# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary -# Fortran compiler which -# is also the HDF5 wrapper -# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool -# -# The following variable can be set to guide the search for HDF5 libraries and includes: -# -# ``HDF5_ROOT`` -# Specify the path to the HDF5 installation to use. -# -# ``HDF5_FIND_DEBUG`` -# Set to a true value to get some extra debugging output. -# -# ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` -# Set to a true value to skip trying to find ``hdf5-config.cmake``. +#[=======================================================================[.rst: +FindHDF5 +-------- + +Find HDF5, a library for reading and writing self describing array data. + + + +This module invokes the HDF5 wrapper compiler that should be installed +alongside HDF5. Depending upon the HDF5 Configuration, the wrapper +compiler is called either h5cc or h5pcc. If this succeeds, the module +will then call the compiler with the -show argument to see what flags +are used when compiling an HDF5 client application. + +The module will optionally accept the COMPONENTS argument. If no +COMPONENTS are specified, then the find module will default to finding +only the HDF5 C library. If one or more COMPONENTS are specified, the +module will attempt to find the language bindings for the specified +components. The only valid components are C, CXX, Fortran, HL, and +Fortran_HL. If the COMPONENTS argument is not given, the module will +attempt to find only the C bindings. + +This module will read the variable +HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a +static link to a dynamic link for HDF5 and all of it's dependencies. +To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES +variable is set before the call to find_package. + +To provide the module with a hint about where to find your HDF5 +installation, you can set the environment variable HDF5_ROOT. The +Find module will then look in this path when searching for HDF5 +executables, paths, and libraries. + +Both the serial and parallel HDF5 wrappers are considered and the first +directory to contain either one will be used. In the event that both appear +in the same directory the serial version is preferentially selected. This +behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to +true. + +In addition to finding the includes and libraries required to compile +an HDF5 client application, this module also makes an effort to find +tools that come with the HDF5 distribution that may be useful for +regression testing. + +This module will define the following variables: + +:: + + HDF5_FOUND - true if HDF5 was found on the system + HDF5_VERSION - HDF5 version in format Major.Minor.Release + HDF5_INCLUDE_DIRS - Location of the hdf5 includes + HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) + HDF5_DEFINITIONS - Required compiler definitions for HDF5 + HDF5_LIBRARIES - Required libraries for all requested bindings + HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all + bindings, if the HL component is enabled + +Available components are: C CXX Fortran and HL. For each enabled language +binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially +HDF5_${LANG}_DEFINITIONS, will be defined. +If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will +also be defined. With all components enabled, the following variables will be defined: + +:: + + HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings + HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings + HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings + HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings + HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings + HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings + HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings + HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings + HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings + HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings + HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings + HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran + bindings. + + HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support + HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler + HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler + HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler + HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler + which is also the HDF5 wrapper + HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ + compiler which is also + the HDF5 wrapper + HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary + Fortran compiler which + is also the HDF5 wrapper + HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool + +The following variable can be set to guide the search for HDF5 libraries and includes: + +``HDF5_ROOT`` + Specify the path to the HDF5 installation to use. + +``HDF5_FIND_DEBUG`` + Set to a true value to get some extra debugging output. + +``HDF5_NO_FIND_PACKAGE_CONFIG_FILE`` + Set to a true value to skip trying to find ``hdf5-config.cmake``. +#]=======================================================================] # This module is maintained by Will Dicharry <wdicharry@stellarscience.com>. diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake index bb0e2f0..ec077a5 100644 --- a/Modules/FindHSPELL.cmake +++ b/Modules/FindHSPELL.cmake @@ -1,28 +1,29 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindHSPELL -# ---------- -# -# Try to find Hspell -# -# Once done this will define -# -# :: -# -# HSPELL_FOUND - system has Hspell -# HSPELL_INCLUDE_DIR - the Hspell include directory -# HSPELL_LIBRARIES - The libraries needed to use Hspell -# HSPELL_DEFINITIONS - Compiler switches required for using Hspell -# -# -# -# :: -# -# HSPELL_VERSION_STRING - The version of Hspell found (x.y) -# HSPELL_MAJOR_VERSION - the major version of Hspell -# HSPELL_MINOR_VERSION - The minor version of Hspell +#[=======================================================================[.rst: +FindHSPELL +---------- + +Try to find Hspell + +Once done this will define + +:: + + HSPELL_FOUND - system has Hspell + HSPELL_INCLUDE_DIR - the Hspell include directory + HSPELL_LIBRARIES - The libraries needed to use Hspell + HSPELL_DEFINITIONS - Compiler switches required for using Hspell + + + +:: + + HSPELL_VERSION_STRING - The version of Hspell found (x.y) + HSPELL_MAJOR_VERSION - the major version of Hspell + HSPELL_MINOR_VERSION - The minor version of Hspell +#]=======================================================================] find_path(HSPELL_INCLUDE_DIR hspell.h) diff --git a/Modules/FindHTMLHelp.cmake b/Modules/FindHTMLHelp.cmake index 6aab8a7..a11ad4d 100644 --- a/Modules/FindHTMLHelp.cmake +++ b/Modules/FindHTMLHelp.cmake @@ -1,19 +1,20 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindHTMLHelp -# ------------ -# -# This module looks for Microsoft HTML Help Compiler -# -# It defines: -# -# :: -# -# HTML_HELP_COMPILER : full path to the Compiler (hhc.exe) -# HTML_HELP_INCLUDE_PATH : include path to the API (htmlhelp.h) -# HTML_HELP_LIBRARY : full path to the library (htmlhelp.lib) +#[=======================================================================[.rst: +FindHTMLHelp +------------ + +This module looks for Microsoft HTML Help Compiler + +It defines: + +:: + + HTML_HELP_COMPILER : full path to the Compiler (hhc.exe) + HTML_HELP_INCLUDE_PATH : include path to the API (htmlhelp.h) + HTML_HELP_LIBRARY : full path to the library (htmlhelp.lib) +#]=======================================================================] if(WIN32) diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake index 8aa553e..1358363 100644 --- a/Modules/FindHg.cmake +++ b/Modules/FindHg.cmake @@ -1,45 +1,46 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindHg -# ------ -# -# Extract information from a mercurial working copy. -# -# The module defines the following variables: -# -# :: -# -# HG_EXECUTABLE - path to mercurial command line client (hg) -# HG_FOUND - true if the command line client was found -# HG_VERSION_STRING - the version of mercurial found -# -# If the command line client executable is found the following macro is defined: -# -# :: -# -# HG_WC_INFO(<dir> <var-prefix>) -# -# Hg_WC_INFO extracts information of a mercurial working copy -# at a given location. This macro defines the following variables: -# -# :: -# -# <var-prefix>_WC_CHANGESET - current changeset -# <var-prefix>_WC_REVISION - current revision -# -# Example usage: -# -# :: -# -# find_package(Hg) -# if(HG_FOUND) -# message("hg found: ${HG_EXECUTABLE}") -# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project) -# message("Current revision is ${Project_WC_REVISION}") -# message("Current changeset is ${Project_WC_CHANGESET}") -# endif() +#[=======================================================================[.rst: +FindHg +------ + +Extract information from a mercurial working copy. + +The module defines the following variables: + +:: + + HG_EXECUTABLE - path to mercurial command line client (hg) + HG_FOUND - true if the command line client was found + HG_VERSION_STRING - the version of mercurial found + +If the command line client executable is found the following macro is defined: + +:: + + HG_WC_INFO(<dir> <var-prefix>) + +Hg_WC_INFO extracts information of a mercurial working copy +at a given location. This macro defines the following variables: + +:: + + <var-prefix>_WC_CHANGESET - current changeset + <var-prefix>_WC_REVISION - current revision + +Example usage: + +:: + + find_package(Hg) + if(HG_FOUND) + message("hg found: ${HG_EXECUTABLE}") + HG_WC_INFO(${PROJECT_SOURCE_DIR} Project) + message("Current revision is ${Project_WC_REVISION}") + message("Current changeset is ${Project_WC_CHANGESET}") + endif() +#]=======================================================================] find_program(HG_EXECUTABLE NAMES hg diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake index aa531d5..685b10f 100644 --- a/Modules/FindICU.cmake +++ b/Modules/FindICU.cmake @@ -1,89 +1,90 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindICU -# ------- -# -# Find the International Components for Unicode (ICU) libraries and -# programs. -# -# This module supports multiple components. -# Components can include any of: ``data``, ``i18n``, ``io``, ``le``, -# ``lx``, ``test``, ``tu`` and ``uc``. -# -# Note that on Windows ``data`` is named ``dt`` and ``i18n`` is named -# ``in``; any of the names may be used, and the appropriate -# platform-specific library name will be automatically selected. -# -# This module reports information about the ICU installation in -# several variables. General variables:: -# -# ICU_VERSION - ICU release version -# ICU_FOUND - true if the main programs and libraries were found -# ICU_LIBRARIES - component libraries to be linked -# ICU_INCLUDE_DIRS - the directories containing the ICU headers -# -# Imported targets:: -# -# ICU::<C> -# -# Where ``<C>`` is the name of an ICU component, for example -# ``ICU::i18n``. -# -# ICU programs are reported in:: -# -# ICU_GENCNVAL_EXECUTABLE - path to gencnval executable -# ICU_ICUINFO_EXECUTABLE - path to icuinfo executable -# ICU_GENBRK_EXECUTABLE - path to genbrk executable -# ICU_ICU-CONFIG_EXECUTABLE - path to icu-config executable -# ICU_GENRB_EXECUTABLE - path to genrb executable -# ICU_GENDICT_EXECUTABLE - path to gendict executable -# ICU_DERB_EXECUTABLE - path to derb executable -# ICU_PKGDATA_EXECUTABLE - path to pkgdata executable -# ICU_UCONV_EXECUTABLE - path to uconv executable -# ICU_GENCFU_EXECUTABLE - path to gencfu executable -# ICU_MAKECONV_EXECUTABLE - path to makeconv executable -# ICU_GENNORM2_EXECUTABLE - path to gennorm2 executable -# ICU_GENCCODE_EXECUTABLE - path to genccode executable -# ICU_GENSPREP_EXECUTABLE - path to gensprep executable -# ICU_ICUPKG_EXECUTABLE - path to icupkg executable -# ICU_GENCMN_EXECUTABLE - path to gencmn executable -# -# ICU component libraries are reported in:: -# -# ICU_<C>_FOUND - ON if component was found -# ICU_<C>_LIBRARIES - libraries for component -# -# ICU datafiles are reported in:: -# -# ICU_MAKEFILE_INC - Makefile.inc -# ICU_PKGDATA_INC - pkgdata.inc -# -# Note that ``<C>`` is the uppercased name of the component. -# -# This module reads hints about search results from:: -# -# ICU_ROOT - the root of the ICU installation -# -# The environment variable ``ICU_ROOT`` may also be used; the -# ICU_ROOT variable takes precedence. -# -# The following cache variables may also be set:: -# -# ICU_<P>_EXECUTABLE - the path to executable <P> -# ICU_INCLUDE_DIR - the directory containing the ICU headers -# ICU_<C>_LIBRARY - the library for component <C> -# -# .. note:: -# -# In most cases none of the above variables will require setting, -# unless multiple ICU versions are available and a specific version -# is required. -# -# Other variables one may set to control this module are:: -# -# ICU_DEBUG - Set to ON to enable debug output from FindICU. +#[=======================================================================[.rst: +FindICU +------- + +Find the International Components for Unicode (ICU) libraries and +programs. + +This module supports multiple components. +Components can include any of: ``data``, ``i18n``, ``io``, ``le``, +``lx``, ``test``, ``tu`` and ``uc``. + +Note that on Windows ``data`` is named ``dt`` and ``i18n`` is named +``in``; any of the names may be used, and the appropriate +platform-specific library name will be automatically selected. + +This module reports information about the ICU installation in +several variables. General variables:: + + ICU_VERSION - ICU release version + ICU_FOUND - true if the main programs and libraries were found + ICU_LIBRARIES - component libraries to be linked + ICU_INCLUDE_DIRS - the directories containing the ICU headers + +Imported targets:: + + ICU::<C> + +Where ``<C>`` is the name of an ICU component, for example +``ICU::i18n``. + +ICU programs are reported in:: + + ICU_GENCNVAL_EXECUTABLE - path to gencnval executable + ICU_ICUINFO_EXECUTABLE - path to icuinfo executable + ICU_GENBRK_EXECUTABLE - path to genbrk executable + ICU_ICU-CONFIG_EXECUTABLE - path to icu-config executable + ICU_GENRB_EXECUTABLE - path to genrb executable + ICU_GENDICT_EXECUTABLE - path to gendict executable + ICU_DERB_EXECUTABLE - path to derb executable + ICU_PKGDATA_EXECUTABLE - path to pkgdata executable + ICU_UCONV_EXECUTABLE - path to uconv executable + ICU_GENCFU_EXECUTABLE - path to gencfu executable + ICU_MAKECONV_EXECUTABLE - path to makeconv executable + ICU_GENNORM2_EXECUTABLE - path to gennorm2 executable + ICU_GENCCODE_EXECUTABLE - path to genccode executable + ICU_GENSPREP_EXECUTABLE - path to gensprep executable + ICU_ICUPKG_EXECUTABLE - path to icupkg executable + ICU_GENCMN_EXECUTABLE - path to gencmn executable + +ICU component libraries are reported in:: + + ICU_<C>_FOUND - ON if component was found + ICU_<C>_LIBRARIES - libraries for component + +ICU datafiles are reported in:: + + ICU_MAKEFILE_INC - Makefile.inc + ICU_PKGDATA_INC - pkgdata.inc + +Note that ``<C>`` is the uppercased name of the component. + +This module reads hints about search results from:: + + ICU_ROOT - the root of the ICU installation + +The environment variable ``ICU_ROOT`` may also be used; the +ICU_ROOT variable takes precedence. + +The following cache variables may also be set:: + + ICU_<P>_EXECUTABLE - the path to executable <P> + ICU_INCLUDE_DIR - the directory containing the ICU headers + ICU_<C>_LIBRARY - the library for component <C> + +.. note:: + + In most cases none of the above variables will require setting, + unless multiple ICU versions are available and a specific version + is required. + +Other variables one may set to control this module are:: + + ICU_DEBUG - Set to ON to enable debug output from FindICU. +#]=======================================================================] # Written by Roger Leigh <rleigh@codelibre.net> diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake index df76e5a..42d3d47 100644 --- a/Modules/FindIce.cmake +++ b/Modules/FindIce.cmake @@ -1,146 +1,147 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindIce -# ------- -# -# Find the ZeroC Internet Communication Engine (ICE) programs, -# libraries and datafiles. -# -# This module supports multiple components. -# Components can include any of: ``Freeze``, ``Glacier2``, ``Ice``, -# ``IceBox``, ``IceDB``, ``IceDiscovery``, ``IceGrid``, -# ``IceLocatorDiscovery``, ``IcePatch``, ``IceSSL``, ``IceStorm``, -# ``IceUtil``, ``IceXML``, or ``Slice``. -# -# Ice 3.7 and later also include C++11-specific components: -# ``Glacier2++11``, ``Ice++11``, ``IceBox++11``, ``IceDiscovery++11`` -# ``IceGrid``, ``IceLocatorDiscovery++11``, ``IceSSL++11``, -# ``IceStorm++11`` -# -# Note that the set of supported components is Ice version-specific. -# -# This module reports information about the Ice installation in -# several variables. General variables:: -# -# Ice_VERSION - Ice release version -# Ice_FOUND - true if the main programs and libraries were found -# Ice_LIBRARIES - component libraries to be linked -# Ice_INCLUDE_DIRS - the directories containing the Ice headers -# Ice_SLICE_DIRS - the directories containing the Ice slice interface -# definitions -# -# Imported targets:: -# -# Ice::<C> -# -# Where ``<C>`` is the name of an Ice component, for example -# ``Ice::Glacier2`` or ``Ice++11``. -# -# Ice slice programs are reported in:: -# -# Ice_SLICE2CPP_EXECUTABLE - path to slice2cpp executable -# Ice_SLICE2CS_EXECUTABLE - path to slice2cs executable -# Ice_SLICE2FREEZEJ_EXECUTABLE - path to slice2freezej executable -# Ice_SLICE2FREEZE_EXECUTABLE - path to slice2freeze executable -# Ice_SLICE2HTML_EXECUTABLE - path to slice2html executable -# Ice_SLICE2JAVA_EXECUTABLE - path to slice2java executable -# Ice_SLICE2JS_EXECUTABLE - path to slice2js executable -# Ice_SLICE2OBJC_EXECUTABLE - path to slice2objc executable -# Ice_SLICE2PHP_EXECUTABLE - path to slice2php executable -# Ice_SLICE2PY_EXECUTABLE - path to slice2py executable -# Ice_SLICE2RB_EXECUTABLE - path to slice2rb executable -# -# Ice programs are reported in:: -# -# Ice_GLACIER2ROUTER_EXECUTABLE - path to glacier2router executable -# Ice_ICEBOX_EXECUTABLE - path to icebox executable -# Ice_ICEBOXXX11_EXECUTABLE - path to icebox++11 executable -# Ice_ICEBOXADMIN_EXECUTABLE - path to iceboxadmin executable -# Ice_ICEBOXD_EXECUTABLE - path to iceboxd executable -# Ice_ICEBOXNET_EXECUTABLE - path to iceboxnet executable -# Ice_ICEBRIDGE_EXECUTABLE - path to icebridge executable -# Ice_ICEGRIDADMIN_EXECUTABLE - path to icegridadmin executable -# Ice_ICEGRIDDB_EXECUTABLE - path to icegriddb executable -# Ice_ICEGRIDNODE_EXECUTABLE - path to icegridnode executable -# Ice_ICEGRIDNODED_EXECUTABLE - path to icegridnoded executable -# Ice_ICEGRIDREGISTRY_EXECUTABLE - path to icegridregistry executable -# Ice_ICEGRIDREGISTRYD_EXECUTABLE - path to icegridregistryd executable -# Ice_ICEPATCH2CALC_EXECUTABLE - path to icepatch2calc executable -# Ice_ICEPATCH2CLIENT_EXECUTABLE - path to icepatch2client executable -# Ice_ICEPATCH2SERVER_EXECUTABLE - path to icepatch2server executable -# Ice_ICESERVICEINSTALL_EXECUTABLE - path to iceserviceinstall executable -# Ice_ICESTORMADMIN_EXECUTABLE - path to icestormadmin executable -# Ice_ICESTORMDB_EXECUTABLE - path to icestormdb executable -# Ice_ICESTORMMIGRATE_EXECUTABLE - path to icestormmigrate executable -# -# Ice db programs (Windows only; standard system versions on all other -# platforms) are reported in:: -# -# Ice_DB_ARCHIVE_EXECUTABLE - path to db_archive executable -# Ice_DB_CHECKPOINT_EXECUTABLE - path to db_checkpoint executable -# Ice_DB_DEADLOCK_EXECUTABLE - path to db_deadlock executable -# Ice_DB_DUMP_EXECUTABLE - path to db_dump executable -# Ice_DB_HOTBACKUP_EXECUTABLE - path to db_hotbackup executable -# Ice_DB_LOAD_EXECUTABLE - path to db_load executable -# Ice_DB_LOG_VERIFY_EXECUTABLE - path to db_log_verify executable -# Ice_DB_PRINTLOG_EXECUTABLE - path to db_printlog executable -# Ice_DB_RECOVER_EXECUTABLE - path to db_recover executable -# Ice_DB_STAT_EXECUTABLE - path to db_stat executable -# Ice_DB_TUNER_EXECUTABLE - path to db_tuner executable -# Ice_DB_UPGRADE_EXECUTABLE - path to db_upgrade executable -# Ice_DB_VERIFY_EXECUTABLE - path to db_verify executable -# Ice_DUMPDB_EXECUTABLE - path to dumpdb executable -# Ice_TRANSFORMDB_EXECUTABLE - path to transformdb executable -# -# Ice component libraries are reported in:: -# -# Ice_<C>_FOUND - ON if component was found -# Ice_<C>_LIBRARIES - libraries for component -# -# Note that ``<C>`` is the uppercased name of the component. -# -# This module reads hints about search results from:: -# -# Ice_HOME - the root of the Ice installation -# -# The environment variable ``ICE_HOME`` may also be used; the -# Ice_HOME variable takes precedence. -# -# .. note:: -# On Windows, Ice 3.7.0 and later provide libraries via the NuGet -# package manager. Appropriate NuGet packages will be searched for -# using ``CMAKE_PREFIX_PATH``, or alternatively ``Ice_HOME`` may be -# set to the location of a specific NuGet package to restrict the -# search. -# -# The following cache variables may also be set:: -# -# Ice_<P>_EXECUTABLE - the path to executable <P> -# Ice_INCLUDE_DIR - the directory containing the Ice headers -# Ice_SLICE_DIR - the directory containing the Ice slice interface -# definitions -# Ice_<C>_LIBRARY - the library for component <C> -# -# .. note:: -# -# In most cases none of the above variables will require setting, -# unless multiple Ice versions are available and a specific version -# is required. On Windows, the most recent version of Ice will be -# found through the registry. On Unix, the programs, headers and -# libraries will usually be in standard locations, but Ice_SLICE_DIRS -# might not be automatically detected (commonly known locations are -# searched). All the other variables are defaulted using Ice_HOME, -# if set. It's possible to set Ice_HOME and selectively specify -# alternative locations for the other components; this might be -# required for e.g. newer versions of Visual Studio if the -# heuristics are not sufficient to identify the correct programs and -# libraries for the specific Visual Studio version. -# -# Other variables one may set to control this module are:: -# -# Ice_DEBUG - Set to ON to enable debug output from FindIce. +#[=======================================================================[.rst: +FindIce +------- + +Find the ZeroC Internet Communication Engine (ICE) programs, +libraries and datafiles. + +This module supports multiple components. +Components can include any of: ``Freeze``, ``Glacier2``, ``Ice``, +``IceBox``, ``IceDB``, ``IceDiscovery``, ``IceGrid``, +``IceLocatorDiscovery``, ``IcePatch``, ``IceSSL``, ``IceStorm``, +``IceUtil``, ``IceXML``, or ``Slice``. + +Ice 3.7 and later also include C++11-specific components: +``Glacier2++11``, ``Ice++11``, ``IceBox++11``, ``IceDiscovery++11`` +``IceGrid``, ``IceLocatorDiscovery++11``, ``IceSSL++11``, +``IceStorm++11`` + +Note that the set of supported components is Ice version-specific. + +This module reports information about the Ice installation in +several variables. General variables:: + + Ice_VERSION - Ice release version + Ice_FOUND - true if the main programs and libraries were found + Ice_LIBRARIES - component libraries to be linked + Ice_INCLUDE_DIRS - the directories containing the Ice headers + Ice_SLICE_DIRS - the directories containing the Ice slice interface + definitions + +Imported targets:: + + Ice::<C> + +Where ``<C>`` is the name of an Ice component, for example +``Ice::Glacier2`` or ``Ice++11``. + +Ice slice programs are reported in:: + + Ice_SLICE2CPP_EXECUTABLE - path to slice2cpp executable + Ice_SLICE2CS_EXECUTABLE - path to slice2cs executable + Ice_SLICE2FREEZEJ_EXECUTABLE - path to slice2freezej executable + Ice_SLICE2FREEZE_EXECUTABLE - path to slice2freeze executable + Ice_SLICE2HTML_EXECUTABLE - path to slice2html executable + Ice_SLICE2JAVA_EXECUTABLE - path to slice2java executable + Ice_SLICE2JS_EXECUTABLE - path to slice2js executable + Ice_SLICE2OBJC_EXECUTABLE - path to slice2objc executable + Ice_SLICE2PHP_EXECUTABLE - path to slice2php executable + Ice_SLICE2PY_EXECUTABLE - path to slice2py executable + Ice_SLICE2RB_EXECUTABLE - path to slice2rb executable + +Ice programs are reported in:: + + Ice_GLACIER2ROUTER_EXECUTABLE - path to glacier2router executable + Ice_ICEBOX_EXECUTABLE - path to icebox executable + Ice_ICEBOXXX11_EXECUTABLE - path to icebox++11 executable + Ice_ICEBOXADMIN_EXECUTABLE - path to iceboxadmin executable + Ice_ICEBOXD_EXECUTABLE - path to iceboxd executable + Ice_ICEBOXNET_EXECUTABLE - path to iceboxnet executable + Ice_ICEBRIDGE_EXECUTABLE - path to icebridge executable + Ice_ICEGRIDADMIN_EXECUTABLE - path to icegridadmin executable + Ice_ICEGRIDDB_EXECUTABLE - path to icegriddb executable + Ice_ICEGRIDNODE_EXECUTABLE - path to icegridnode executable + Ice_ICEGRIDNODED_EXECUTABLE - path to icegridnoded executable + Ice_ICEGRIDREGISTRY_EXECUTABLE - path to icegridregistry executable + Ice_ICEGRIDREGISTRYD_EXECUTABLE - path to icegridregistryd executable + Ice_ICEPATCH2CALC_EXECUTABLE - path to icepatch2calc executable + Ice_ICEPATCH2CLIENT_EXECUTABLE - path to icepatch2client executable + Ice_ICEPATCH2SERVER_EXECUTABLE - path to icepatch2server executable + Ice_ICESERVICEINSTALL_EXECUTABLE - path to iceserviceinstall executable + Ice_ICESTORMADMIN_EXECUTABLE - path to icestormadmin executable + Ice_ICESTORMDB_EXECUTABLE - path to icestormdb executable + Ice_ICESTORMMIGRATE_EXECUTABLE - path to icestormmigrate executable + +Ice db programs (Windows only; standard system versions on all other +platforms) are reported in:: + + Ice_DB_ARCHIVE_EXECUTABLE - path to db_archive executable + Ice_DB_CHECKPOINT_EXECUTABLE - path to db_checkpoint executable + Ice_DB_DEADLOCK_EXECUTABLE - path to db_deadlock executable + Ice_DB_DUMP_EXECUTABLE - path to db_dump executable + Ice_DB_HOTBACKUP_EXECUTABLE - path to db_hotbackup executable + Ice_DB_LOAD_EXECUTABLE - path to db_load executable + Ice_DB_LOG_VERIFY_EXECUTABLE - path to db_log_verify executable + Ice_DB_PRINTLOG_EXECUTABLE - path to db_printlog executable + Ice_DB_RECOVER_EXECUTABLE - path to db_recover executable + Ice_DB_STAT_EXECUTABLE - path to db_stat executable + Ice_DB_TUNER_EXECUTABLE - path to db_tuner executable + Ice_DB_UPGRADE_EXECUTABLE - path to db_upgrade executable + Ice_DB_VERIFY_EXECUTABLE - path to db_verify executable + Ice_DUMPDB_EXECUTABLE - path to dumpdb executable + Ice_TRANSFORMDB_EXECUTABLE - path to transformdb executable + +Ice component libraries are reported in:: + + Ice_<C>_FOUND - ON if component was found + Ice_<C>_LIBRARIES - libraries for component + +Note that ``<C>`` is the uppercased name of the component. + +This module reads hints about search results from:: + + Ice_HOME - the root of the Ice installation + +The environment variable ``ICE_HOME`` may also be used; the +Ice_HOME variable takes precedence. + +.. note:: + On Windows, Ice 3.7.0 and later provide libraries via the NuGet + package manager. Appropriate NuGet packages will be searched for + using ``CMAKE_PREFIX_PATH``, or alternatively ``Ice_HOME`` may be + set to the location of a specific NuGet package to restrict the + search. + +The following cache variables may also be set:: + + Ice_<P>_EXECUTABLE - the path to executable <P> + Ice_INCLUDE_DIR - the directory containing the Ice headers + Ice_SLICE_DIR - the directory containing the Ice slice interface + definitions + Ice_<C>_LIBRARY - the library for component <C> + +.. note:: + + In most cases none of the above variables will require setting, + unless multiple Ice versions are available and a specific version + is required. On Windows, the most recent version of Ice will be + found through the registry. On Unix, the programs, headers and + libraries will usually be in standard locations, but Ice_SLICE_DIRS + might not be automatically detected (commonly known locations are + searched). All the other variables are defaulted using Ice_HOME, + if set. It's possible to set Ice_HOME and selectively specify + alternative locations for the other components; this might be + required for e.g. newer versions of Visual Studio if the + heuristics are not sufficient to identify the correct programs and + libraries for the specific Visual Studio version. + +Other variables one may set to control this module are:: + + Ice_DEBUG - Set to ON to enable debug output from FindIce. +#]=======================================================================] # Written by Roger Leigh <rleigh@codelibre.net> diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake index 26e95a0..32fc4ae 100644 --- a/Modules/FindIcotool.cmake +++ b/Modules/FindIcotool.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindIcotool -# ----------- -# -# Find icotool -# -# This module looks for icotool. This module defines the following -# values: -# -# :: -# -# ICOTOOL_EXECUTABLE: the full path to the icotool tool. -# ICOTOOL_FOUND: True if icotool has been found. -# ICOTOOL_VERSION_STRING: the version of icotool found. +#[=======================================================================[.rst: +FindIcotool +----------- + +Find icotool + +This module looks for icotool. This module defines the following +values: + +:: + + ICOTOOL_EXECUTABLE: the full path to the icotool tool. + ICOTOOL_FOUND: True if icotool has been found. + ICOTOOL_VERSION_STRING: the version of icotool found. +#]=======================================================================] find_program(ICOTOOL_EXECUTABLE icotool diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 6d94d3b..2ddd11c 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -1,87 +1,88 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindImageMagick -# --------------- -# -# Find the ImageMagick binary suite. -# -# This module will search for a set of ImageMagick tools specified as -# components in the FIND_PACKAGE call. Typical components include, but -# are not limited to (future versions of ImageMagick might have -# additional components not listed here): -# -# :: -# -# animate -# compare -# composite -# conjure -# convert -# display -# identify -# import -# mogrify -# montage -# stream -# -# -# -# If no component is specified in the FIND_PACKAGE call, then it only -# searches for the ImageMagick executable directory. This code defines -# the following variables: -# -# :: -# -# ImageMagick_FOUND - TRUE if all components are found. -# ImageMagick_EXECUTABLE_DIR - Full path to executables directory. -# ImageMagick_<component>_FOUND - TRUE if <component> is found. -# ImageMagick_<component>_EXECUTABLE - Full path to <component> executable. -# ImageMagick_VERSION_STRING - the version of ImageMagick found -# (since CMake 2.8.8) -# -# -# -# ImageMagick_VERSION_STRING will not work for old versions like 5.2.3. -# -# There are also components for the following ImageMagick APIs: -# -# :: -# -# Magick++ -# MagickWand -# MagickCore -# -# -# -# For these components the following variables are set: -# -# :: -# -# ImageMagick_FOUND - TRUE if all components are found. -# ImageMagick_INCLUDE_DIRS - Full paths to all include dirs. -# ImageMagick_LIBRARIES - Full paths to all libraries. -# ImageMagick_<component>_FOUND - TRUE if <component> is found. -# ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs. -# ImageMagick_<component>_LIBRARIES - Full path to <component> libraries. -# -# -# -# Example Usages: -# -# :: -# -# find_package(ImageMagick) -# find_package(ImageMagick COMPONENTS convert) -# find_package(ImageMagick COMPONENTS convert mogrify display) -# find_package(ImageMagick COMPONENTS Magick++) -# find_package(ImageMagick COMPONENTS Magick++ convert) -# -# -# -# Note that the standard FIND_PACKAGE features are supported (i.e., -# QUIET, REQUIRED, etc.). +#[=======================================================================[.rst: +FindImageMagick +--------------- + +Find the ImageMagick binary suite. + +This module will search for a set of ImageMagick tools specified as +components in the FIND_PACKAGE call. Typical components include, but +are not limited to (future versions of ImageMagick might have +additional components not listed here): + +:: + + animate + compare + composite + conjure + convert + display + identify + import + mogrify + montage + stream + + + +If no component is specified in the FIND_PACKAGE call, then it only +searches for the ImageMagick executable directory. This code defines +the following variables: + +:: + + ImageMagick_FOUND - TRUE if all components are found. + ImageMagick_EXECUTABLE_DIR - Full path to executables directory. + ImageMagick_<component>_FOUND - TRUE if <component> is found. + ImageMagick_<component>_EXECUTABLE - Full path to <component> executable. + ImageMagick_VERSION_STRING - the version of ImageMagick found + (since CMake 2.8.8) + + + +ImageMagick_VERSION_STRING will not work for old versions like 5.2.3. + +There are also components for the following ImageMagick APIs: + +:: + + Magick++ + MagickWand + MagickCore + + + +For these components the following variables are set: + +:: + + ImageMagick_FOUND - TRUE if all components are found. + ImageMagick_INCLUDE_DIRS - Full paths to all include dirs. + ImageMagick_LIBRARIES - Full paths to all libraries. + ImageMagick_<component>_FOUND - TRUE if <component> is found. + ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs. + ImageMagick_<component>_LIBRARIES - Full path to <component> libraries. + + + +Example Usages: + +:: + + find_package(ImageMagick) + find_package(ImageMagick COMPONENTS convert) + find_package(ImageMagick COMPONENTS convert mogrify display) + find_package(ImageMagick COMPONENTS Magick++) + find_package(ImageMagick COMPONENTS Magick++ convert) + + + +Note that the standard FIND_PACKAGE features are supported (i.e., +QUIET, REQUIRED, etc.). +#]=======================================================================] find_package(PkgConfig QUIET) diff --git a/Modules/FindIntl.cmake b/Modules/FindIntl.cmake index f887721..3818d45 100644 --- a/Modules/FindIntl.cmake +++ b/Modules/FindIntl.cmake @@ -1,33 +1,34 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindIntl -# -------- -# -# Find the Gettext libintl headers and libraries. -# -# This module reports information about the Gettext libintl -# installation in several variables. General variables:: -# -# Intl_FOUND - true if the libintl headers and libraries were found -# Intl_INCLUDE_DIRS - the directory containing the libintl headers -# Intl_LIBRARIES - libintl libraries to be linked -# -# The following cache variables may also be set:: -# -# Intl_INCLUDE_DIR - the directory containing the libintl headers -# Intl_LIBRARY - the libintl library (if any) -# -# .. note:: -# On some platforms, such as Linux with GNU libc, the gettext -# functions are present in the C standard library and libintl -# is not required. ``Intl_LIBRARIES`` will be empty in this -# case. -# -# .. note:: -# If you wish to use the Gettext tools (``msgmerge``, -# ``msgfmt``, etc.), use :module:`FindGettext`. +#[=======================================================================[.rst: +FindIntl +-------- + +Find the Gettext libintl headers and libraries. + +This module reports information about the Gettext libintl +installation in several variables. General variables:: + + Intl_FOUND - true if the libintl headers and libraries were found + Intl_INCLUDE_DIRS - the directory containing the libintl headers + Intl_LIBRARIES - libintl libraries to be linked + +The following cache variables may also be set:: + + Intl_INCLUDE_DIR - the directory containing the libintl headers + Intl_LIBRARY - the libintl library (if any) + +.. note:: + On some platforms, such as Linux with GNU libc, the gettext + functions are present in the C standard library and libintl + is not required. ``Intl_LIBRARIES`` will be empty in this + case. + +.. note:: + If you wish to use the Gettext tools (``msgmerge``, + ``msgfmt``, etc.), use :module:`FindGettext`. +#]=======================================================================] # Written by Roger Leigh <rleigh@codelibre.net> diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 7290724..0aa387a 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -1,53 +1,54 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindJPEG -# -------- -# -# Find the JPEG library (libjpeg) -# -# Imported targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``JPEG::JPEG`` -# The JPEG library, if found. -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``JPEG_FOUND`` -# If false, do not try to use JPEG. -# ``JPEG_INCLUDE_DIRS`` -# where to find jpeglib.h, etc. -# ``JPEG_LIBRARIES`` -# the libraries needed to use JPEG. -# ``JPEG_VERSION`` -# the version of the JPEG library found -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``JPEG_INCLUDE_DIRS`` -# where to find jpeglib.h, etc. -# ``JPEG_LIBRARY_RELEASE`` -# where to find the JPEG library (optimized). -# ``JPEG_LIBRARY_DEBUG`` -# where to find the JPEG library (debug). -# -# Obsolete variables -# ^^^^^^^^^^^^^^^^^^ -# -# ``JPEG_INCLUDE_DIR`` -# where to find jpeglib.h, etc. (same as JPEG_INCLUDE_DIRS) -# ``JPEG_LIBRARY`` -# where to find the JPEG library. +#[=======================================================================[.rst: +FindJPEG +-------- + +Find the JPEG library (libjpeg) + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``JPEG::JPEG`` + The JPEG library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``JPEG_FOUND`` + If false, do not try to use JPEG. +``JPEG_INCLUDE_DIRS`` + where to find jpeglib.h, etc. +``JPEG_LIBRARIES`` + the libraries needed to use JPEG. +``JPEG_VERSION`` + the version of the JPEG library found + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``JPEG_INCLUDE_DIRS`` + where to find jpeglib.h, etc. +``JPEG_LIBRARY_RELEASE`` + where to find the JPEG library (optimized). +``JPEG_LIBRARY_DEBUG`` + where to find the JPEG library (debug). + +Obsolete variables +^^^^^^^^^^^^^^^^^^ + +``JPEG_INCLUDE_DIR`` + where to find jpeglib.h, etc. (same as JPEG_INCLUDE_DIRS) +``JPEG_LIBRARY`` + where to find the JPEG library. +#]=======================================================================] find_path(JPEG_INCLUDE_DIR jpeglib.h) diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index db76657..dd0e984 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindJasper -# ---------- -# -# Try to find the Jasper JPEG2000 library -# -# Once done this will define -# -# :: -# -# JASPER_FOUND - system has Jasper -# JASPER_INCLUDE_DIR - the Jasper include directory -# JASPER_LIBRARIES - the libraries needed to use Jasper -# JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8) +#[=======================================================================[.rst: +FindJasper +---------- + +Try to find the Jasper JPEG2000 library + +Once done this will define + +:: + + JASPER_FOUND - system has Jasper + JASPER_INCLUDE_DIR - the Jasper include directory + JASPER_LIBRARIES - the libraries needed to use Jasper + JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8) +#]=======================================================================] find_path(JASPER_INCLUDE_DIR jasper/jasper.h) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index bcdf166..0d62cd6 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -1,79 +1,80 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindJava -# -------- -# -# Find Java -# -# This module finds if Java is installed and determines where the -# include files and libraries are. The caller may set variable ``JAVA_HOME`` -# to specify a Java installation prefix explicitly. -# -# See also the :module:`FindJNI` module to find Java Native Interface (JNI). -# -# Specify one or more of the following components as you call this find module. See example below. -# -# :: -# -# Runtime = Java Runtime Environment used to execute Java byte-compiled applications -# Development = Development tools (java, javac, javah, jar and javadoc), includes Runtime component -# IdlJ = Interface Description Language (IDL) to Java compiler -# JarSigner = Signer and verifier tool for Java Archive (JAR) files -# -# -# This module sets the following result variables: -# -# :: -# -# Java_JAVA_EXECUTABLE = the full path to the Java runtime -# Java_JAVAC_EXECUTABLE = the full path to the Java compiler -# Java_JAVAH_EXECUTABLE = the full path to the Java header generator -# Java_JAVADOC_EXECUTABLE = the full path to the Java documentation generator -# Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler -# Java_JAR_EXECUTABLE = the full path to the Java archiver -# Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer -# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 -# Java_VERSION_MAJOR = The major version of the package found. -# Java_VERSION_MINOR = The minor version of the package found. -# Java_VERSION_PATCH = The patch version of the package found. -# Java_VERSION_TWEAK = The tweak version of the package found (after '_') -# Java_VERSION = This is set to: $major[.$minor[.$patch[.$tweak]]] -# -# -# -# The minimum required version of Java can be specified using the -# :command:`find_package` syntax, e.g. -# -# .. code-block:: cmake -# -# find_package(Java 1.8) -# -# NOTE: ``${Java_VERSION}`` and ``${Java_VERSION_STRING}`` are not guaranteed to -# be identical. For example some java version may return: -# ``Java_VERSION_STRING = 1.8.0_17`` and ``Java_VERSION = 1.8.0.17`` -# -# another example is the Java OEM, with: ``Java_VERSION_STRING = 1.8.0-oem`` -# and ``Java_VERSION = 1.8.0`` -# -# For these components the following variables are set: -# -# :: -# -# Java_FOUND - TRUE if all components are found. -# Java_<component>_FOUND - TRUE if <component> is found. -# -# -# -# Example Usages: -# -# :: -# -# find_package(Java) -# find_package(Java 1.8 REQUIRED) -# find_package(Java COMPONENTS Runtime) -# find_package(Java COMPONENTS Development) +#[=======================================================================[.rst: +FindJava +-------- + +Find Java + +This module finds if Java is installed and determines where the +include files and libraries are. The caller may set variable ``JAVA_HOME`` +to specify a Java installation prefix explicitly. + +See also the :module:`FindJNI` module to find Java Native Interface (JNI). + +Specify one or more of the following components as you call this find module. See example below. + +:: + + Runtime = Java Runtime Environment used to execute Java byte-compiled applications + Development = Development tools (java, javac, javah, jar and javadoc), includes Runtime component + IdlJ = Interface Description Language (IDL) to Java compiler + JarSigner = Signer and verifier tool for Java Archive (JAR) files + + +This module sets the following result variables: + +:: + + Java_JAVA_EXECUTABLE = the full path to the Java runtime + Java_JAVAC_EXECUTABLE = the full path to the Java compiler + Java_JAVAH_EXECUTABLE = the full path to the Java header generator + Java_JAVADOC_EXECUTABLE = the full path to the Java documentation generator + Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler + Java_JAR_EXECUTABLE = the full path to the Java archiver + Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer + Java_VERSION_STRING = Version of java found, eg. 1.6.0_12 + Java_VERSION_MAJOR = The major version of the package found. + Java_VERSION_MINOR = The minor version of the package found. + Java_VERSION_PATCH = The patch version of the package found. + Java_VERSION_TWEAK = The tweak version of the package found (after '_') + Java_VERSION = This is set to: $major[.$minor[.$patch[.$tweak]]] + + + +The minimum required version of Java can be specified using the +:command:`find_package` syntax, e.g. + +.. code-block:: cmake + + find_package(Java 1.8) + +NOTE: ``${Java_VERSION}`` and ``${Java_VERSION_STRING}`` are not guaranteed to +be identical. For example some java version may return: +``Java_VERSION_STRING = 1.8.0_17`` and ``Java_VERSION = 1.8.0.17`` + +another example is the Java OEM, with: ``Java_VERSION_STRING = 1.8.0-oem`` +and ``Java_VERSION = 1.8.0`` + +For these components the following variables are set: + +:: + + Java_FOUND - TRUE if all components are found. + Java_<component>_FOUND - TRUE if <component> is found. + + + +Example Usages: + +:: + + find_package(Java) + find_package(Java 1.8 REQUIRED) + find_package(Java COMPONENTS Runtime) + find_package(Java COMPONENTS Development) +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake) diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index daf6818..c7ad6e1 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -1,141 +1,142 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindKDE3 -# -------- -# -# Find the KDE3 include and library dirs, KDE preprocessors and define a some macros -# -# -# -# This module defines the following variables: -# -# ``KDE3_DEFINITIONS`` -# compiler definitions required for compiling KDE software -# ``KDE3_INCLUDE_DIR`` -# the KDE include directory -# ``KDE3_INCLUDE_DIRS`` -# the KDE and the Qt include directory, for use with include_directories() -# ``KDE3_LIB_DIR`` -# the directory where the KDE libraries are installed, for use with link_directories() -# ``QT_AND_KDECORE_LIBS`` -# this contains both the Qt and the kdecore library -# ``KDE3_DCOPIDL_EXECUTABLE`` -# the dcopidl executable -# ``KDE3_DCOPIDL2CPP_EXECUTABLE`` -# the dcopidl2cpp executable -# ``KDE3_KCFGC_EXECUTABLE`` -# the kconfig_compiler executable -# ``KDE3_FOUND`` -# set to TRUE if all of the above has been found -# -# The following user adjustable options are provided: -# -# ``KDE3_BUILD_TESTS`` -# enable this to build KDE testcases -# -# It also adds the following macros (from KDE3Macros.cmake) SRCS_VAR is -# always the variable which contains the list of source files for your -# application or library. -# -# KDE3_AUTOMOC(file1 ... fileN) -# -# :: -# -# Call this if you want to have automatic moc file handling. -# This means if you include "foo.moc" in the source file foo.cpp -# a moc file for the header foo.h will be created automatically. -# You can set the property SKIP_AUTOMAKE using set_source_files_properties() -# to exclude some files in the list from being processed. -# -# -# -# KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN ) -# -# :: -# -# If you don't use the KDE3_AUTOMOC() macro, for the files -# listed here moc files will be created (named "foo.moc.cpp") -# -# -# -# KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h ) -# -# :: -# -# Use this to generate DCOP skeletions from the listed headers. -# -# -# -# KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h ) -# -# :: -# -# Use this to generate DCOP stubs from the listed headers. -# -# -# -# KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui ) -# -# :: -# -# Use this to add the Qt designer ui files to your application/library. -# -# -# -# KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc ) -# -# :: -# -# Use this to add KDE kconfig compiler files to your application/library. -# -# -# -# KDE3_INSTALL_LIBTOOL_FILE(target) -# -# :: -# -# This will create and install a simple libtool file for the given target. -# -# -# -# KDE3_ADD_EXECUTABLE(name file1 ... fileN ) -# -# :: -# -# Currently identical to add_executable(), may provide some advanced -# features in the future. -# -# -# -# KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN ) -# -# :: -# -# Create a KDE plugin (KPart, kioslave, etc.) from the given source files. -# If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", -# otherwise it won't. -# It creates and installs an appropriate libtool la-file. -# -# -# -# KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN ) -# -# :: -# -# Create a KDE application in the form of a module loadable via kdeinit. -# A library named kdeinit_<name> will be created and a small executable -# which links to it. -# -# -# -# The option KDE3_ENABLE_FINAL to enable all-in-one compilation is no -# longer supported. -# -# -# -# Author: Alexander Neundorf <neundorf@kde.org> +#[=======================================================================[.rst: +FindKDE3 +-------- + +Find the KDE3 include and library dirs, KDE preprocessors and define a some macros + + + +This module defines the following variables: + +``KDE3_DEFINITIONS`` + compiler definitions required for compiling KDE software +``KDE3_INCLUDE_DIR`` + the KDE include directory +``KDE3_INCLUDE_DIRS`` + the KDE and the Qt include directory, for use with include_directories() +``KDE3_LIB_DIR`` + the directory where the KDE libraries are installed, for use with link_directories() +``QT_AND_KDECORE_LIBS`` + this contains both the Qt and the kdecore library +``KDE3_DCOPIDL_EXECUTABLE`` + the dcopidl executable +``KDE3_DCOPIDL2CPP_EXECUTABLE`` + the dcopidl2cpp executable +``KDE3_KCFGC_EXECUTABLE`` + the kconfig_compiler executable +``KDE3_FOUND`` + set to TRUE if all of the above has been found + +The following user adjustable options are provided: + +``KDE3_BUILD_TESTS`` + enable this to build KDE testcases + +It also adds the following macros (from KDE3Macros.cmake) SRCS_VAR is +always the variable which contains the list of source files for your +application or library. + +KDE3_AUTOMOC(file1 ... fileN) + +:: + + Call this if you want to have automatic moc file handling. + This means if you include "foo.moc" in the source file foo.cpp + a moc file for the header foo.h will be created automatically. + You can set the property SKIP_AUTOMAKE using set_source_files_properties() + to exclude some files in the list from being processed. + + + +KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN ) + +:: + + If you don't use the KDE3_AUTOMOC() macro, for the files + listed here moc files will be created (named "foo.moc.cpp") + + + +KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h ) + +:: + + Use this to generate DCOP skeletions from the listed headers. + + + +KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h ) + +:: + + Use this to generate DCOP stubs from the listed headers. + + + +KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui ) + +:: + + Use this to add the Qt designer ui files to your application/library. + + + +KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc ) + +:: + + Use this to add KDE kconfig compiler files to your application/library. + + + +KDE3_INSTALL_LIBTOOL_FILE(target) + +:: + + This will create and install a simple libtool file for the given target. + + + +KDE3_ADD_EXECUTABLE(name file1 ... fileN ) + +:: + + Currently identical to add_executable(), may provide some advanced + features in the future. + + + +KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN ) + +:: + + Create a KDE plugin (KPart, kioslave, etc.) from the given source files. + If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", + otherwise it won't. + It creates and installs an appropriate libtool la-file. + + + +KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN ) + +:: + + Create a KDE application in the form of a module loadable via kdeinit. + A library named kdeinit_<name> will be created and a small executable + which links to it. + + + +The option KDE3_ENABLE_FINAL to enable all-in-one compilation is no +longer supported. + + + +Author: Alexander Neundorf <neundorf@kde.org> +#]=======================================================================] if(NOT UNIX AND KDE3_FIND_REQUIRED) message(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported") diff --git a/Modules/FindKDE4.cmake b/Modules/FindKDE4.cmake index bb98e53..c04804b 100644 --- a/Modules/FindKDE4.cmake +++ b/Modules/FindKDE4.cmake @@ -1,29 +1,30 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindKDE4 -# -------- -# -# -# -# Find KDE4 and provide all necessary variables and macros to compile -# software for it. It looks for KDE 4 in the following directories in -# the given order: -# -# :: -# -# CMAKE_INSTALL_PREFIX -# KDEDIRS -# /opt/kde4 -# -# -# -# Please look in FindKDE4Internal.cmake and KDE4Macros.cmake for more -# information. They are installed with the KDE 4 libraries in -# $KDEDIRS/share/apps/cmake/modules/. -# -# Author: Alexander Neundorf <neundorf@kde.org> +#[=======================================================================[.rst: +FindKDE4 +-------- + + + +Find KDE4 and provide all necessary variables and macros to compile +software for it. It looks for KDE 4 in the following directories in +the given order: + +:: + + CMAKE_INSTALL_PREFIX + KDEDIRS + /opt/kde4 + + + +Please look in FindKDE4Internal.cmake and KDE4Macros.cmake for more +information. They are installed with the KDE 4 libraries in +$KDEDIRS/share/apps/cmake/modules/. + +Author: Alexander Neundorf <neundorf@kde.org> +#]=======================================================================] # If Qt3 has already been found, fail. if(QT_QT_LIBRARY) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 7ca9950..31e5620b 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -1,48 +1,49 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLAPACK -# ---------- -# -# Find LAPACK library -# -# This module finds an installed fortran library that implements the -# LAPACK linear-algebra interface (see http://www.netlib.org/lapack/). -# -# The approach follows that taken for the autoconf macro file, -# acx_lapack.m4 (distributed at -# http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). -# -# This module sets the following variables: -# -# :: -# -# LAPACK_FOUND - set to true if a library implementing the LAPACK interface -# is found -# LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l -# and -L). -# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to -# link against to use LAPACK -# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to -# link against to use LAPACK95 -# LAPACK95_FOUND - set to true if a library implementing the LAPACK f95 -# interface is found -# BLA_STATIC if set on this determines what kind of linkage we do (static) -# BLA_VENDOR if set checks only the specified vendor, if not set checks -# all the possibilities -# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK -# -# List of vendors (BLA_VENDOR) valid in this module: -# -# * Intel(mkl) -# * OpenBLAS -# * FLAME -# * ACML -# * Apple -# * NAS -# * Generic -# +#[=======================================================================[.rst: +FindLAPACK +---------- + +Find LAPACK library + +This module finds an installed fortran library that implements the +LAPACK linear-algebra interface (see http://www.netlib.org/lapack/). + +The approach follows that taken for the autoconf macro file, +acx_lapack.m4 (distributed at +http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). + +This module sets the following variables: + +:: + + LAPACK_FOUND - set to true if a library implementing the LAPACK interface + is found + LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l + and -L). + LAPACK_LIBRARIES - uncached list of libraries (using full path name) to + link against to use LAPACK + LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to + link against to use LAPACK95 + LAPACK95_FOUND - set to true if a library implementing the LAPACK f95 + interface is found + BLA_STATIC if set on this determines what kind of linkage we do (static) + BLA_VENDOR if set checks only the specified vendor, if not set checks + all the possibilities + BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK + +List of vendors (BLA_VENDOR) valid in this module: + +* Intel(mkl) +* OpenBLAS +* FLAME +* ACML +* Apple +* NAS +* Generic + +#]=======================================================================] set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLATEX.cmake b/Modules/FindLATEX.cmake index d1f4fa4..01f4793 100644 --- a/Modules/FindLATEX.cmake +++ b/Modules/FindLATEX.cmake @@ -1,56 +1,57 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLATEX -# --------- -# -# Find Latex -# -# This module finds an installed Latex and determines the location -# of the compiler. Additionally the module looks for Latex-related -# software like BibTeX. -# -# This module sets the following result variables:: -# -# LATEX_FOUND: whether found Latex and requested components -# LATEX_<component>_FOUND: whether found <component> -# LATEX_COMPILER: path to the LaTeX compiler -# PDFLATEX_COMPILER: path to the PdfLaTeX compiler -# XELATEX_COMPILER: path to the XeLaTeX compiler -# LUALATEX_COMPILER: path to the LuaLaTeX compiler -# BIBTEX_COMPILER: path to the BibTeX compiler -# BIBER_COMPILER: path to the Biber compiler -# MAKEINDEX_COMPILER: path to the MakeIndex compiler -# XINDY_COMPILER: path to the xindy compiler -# DVIPS_CONVERTER: path to the DVIPS converter -# DVIPDF_CONVERTER: path to the DVIPDF converter -# PS2PDF_CONVERTER: path to the PS2PDF converter -# PDFTOPS_CONVERTER: path to the pdftops converter -# LATEX2HTML_CONVERTER: path to the LaTeX2Html converter -# HTLATEX_COMPILER: path to the htlatex compiler -# -# Possible components are:: -# -# PDFLATEX -# XELATEX -# LUALATEX -# BIBTEX -# BIBER -# MAKEINDEX -# XINDY -# DVIPS -# DVIPDF -# PS2PDF -# PDFTOPS -# LATEX2HTML -# HTLATEX -# -# Example Usages:: -# -# find_package(LATEX) -# find_package(LATEX COMPONENTS PDFLATEX) -# find_package(LATEX COMPONENTS BIBTEX PS2PDF) +#[=======================================================================[.rst: +FindLATEX +--------- + +Find Latex + +This module finds an installed Latex and determines the location +of the compiler. Additionally the module looks for Latex-related +software like BibTeX. + +This module sets the following result variables:: + + LATEX_FOUND: whether found Latex and requested components + LATEX_<component>_FOUND: whether found <component> + LATEX_COMPILER: path to the LaTeX compiler + PDFLATEX_COMPILER: path to the PdfLaTeX compiler + XELATEX_COMPILER: path to the XeLaTeX compiler + LUALATEX_COMPILER: path to the LuaLaTeX compiler + BIBTEX_COMPILER: path to the BibTeX compiler + BIBER_COMPILER: path to the Biber compiler + MAKEINDEX_COMPILER: path to the MakeIndex compiler + XINDY_COMPILER: path to the xindy compiler + DVIPS_CONVERTER: path to the DVIPS converter + DVIPDF_CONVERTER: path to the DVIPDF converter + PS2PDF_CONVERTER: path to the PS2PDF converter + PDFTOPS_CONVERTER: path to the pdftops converter + LATEX2HTML_CONVERTER: path to the LaTeX2Html converter + HTLATEX_COMPILER: path to the htlatex compiler + +Possible components are:: + + PDFLATEX + XELATEX + LUALATEX + BIBTEX + BIBER + MAKEINDEX + XINDY + DVIPS + DVIPDF + PS2PDF + PDFTOPS + LATEX2HTML + HTLATEX + +Example Usages:: + + find_package(LATEX) + find_package(LATEX COMPONENTS PDFLATEX) + find_package(LATEX COMPONENTS BIBTEX PS2PDF) +#]=======================================================================] if (WIN32) # Try to find the MikTex binary path (look for its package manager). diff --git a/Modules/FindLTTngUST.cmake b/Modules/FindLTTngUST.cmake index 00d5e7a..a074187 100644 --- a/Modules/FindLTTngUST.cmake +++ b/Modules/FindLTTngUST.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLTTngUST -# ------------ -# -# This module finds the `LTTng-UST <http://lttng.org/>`__ library. -# -# Imported target -# ^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` target: -# -# ``LTTng::UST`` -# The LTTng-UST library, if found -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module sets the following -# -# ``LTTNGUST_FOUND`` -# ``TRUE`` if system has LTTng-UST -# ``LTTNGUST_INCLUDE_DIRS`` -# The LTTng-UST include directories -# ``LTTNGUST_LIBRARIES`` -# The libraries needed to use LTTng-UST -# ``LTTNGUST_VERSION_STRING`` -# The LTTng-UST version -# ``LTTNGUST_HAS_TRACEF`` -# ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST -# ``LTTNGUST_HAS_TRACELOG`` -# ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST +#[=======================================================================[.rst: +FindLTTngUST +------------ + +This module finds the `LTTng-UST <http://lttng.org/>`__ library. + +Imported target +^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``LTTng::UST`` + The LTTng-UST library, if found + +Result variables +^^^^^^^^^^^^^^^^ + +This module sets the following + +``LTTNGUST_FOUND`` + ``TRUE`` if system has LTTng-UST +``LTTNGUST_INCLUDE_DIRS`` + The LTTng-UST include directories +``LTTNGUST_LIBRARIES`` + The libraries needed to use LTTng-UST +``LTTNGUST_VERSION_STRING`` + The LTTng-UST version +``LTTNGUST_HAS_TRACEF`` + ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST +``LTTNGUST_HAS_TRACELOG`` + ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST +#]=======================================================================] find_path(LTTNGUST_INCLUDE_DIRS NAMES lttng/tracepoint.h) find_library(LTTNGUST_LIBRARIES NAMES lttng-ust) diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index 38e512f..34fc2e2 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLibArchive -# -------------- -# -# Find libarchive library and headers -# -# The module defines the following variables: -# -# :: -# -# LibArchive_FOUND - true if libarchive was found -# LibArchive_INCLUDE_DIRS - include search path -# LibArchive_LIBRARIES - libraries to link -# LibArchive_VERSION - libarchive 3-component version number +#[=======================================================================[.rst: +FindLibArchive +-------------- + +Find libarchive library and headers + +The module defines the following variables: + +:: + + LibArchive_FOUND - true if libarchive was found + LibArchive_INCLUDE_DIRS - include search path + LibArchive_LIBRARIES - libraries to link + LibArchive_VERSION - libarchive 3-component version number +#]=======================================================================] find_path(LibArchive_INCLUDE_DIR NAMES archive.h diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index d203eaf..6d30e57 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -1,26 +1,27 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLibLZMA -# ----------- -# -# Find LibLZMA -# -# Find LibLZMA headers and library -# -# :: -# -# LIBLZMA_FOUND - True if liblzma is found. -# LIBLZMA_INCLUDE_DIRS - Directory where liblzma headers are located. -# LIBLZMA_LIBRARIES - Lzma libraries to link against. -# LIBLZMA_HAS_AUTO_DECODER - True if lzma_auto_decoder() is found (required). -# LIBLZMA_HAS_EASY_ENCODER - True if lzma_easy_encoder() is found (required). -# LIBLZMA_HAS_LZMA_PRESET - True if lzma_lzma_preset() is found (required). -# LIBLZMA_VERSION_MAJOR - The major version of lzma -# LIBLZMA_VERSION_MINOR - The minor version of lzma -# LIBLZMA_VERSION_PATCH - The patch version of lzma -# LIBLZMA_VERSION_STRING - version number as a string (ex: "5.0.3") +#[=======================================================================[.rst: +FindLibLZMA +----------- + +Find LibLZMA + +Find LibLZMA headers and library + +:: + + LIBLZMA_FOUND - True if liblzma is found. + LIBLZMA_INCLUDE_DIRS - Directory where liblzma headers are located. + LIBLZMA_LIBRARIES - Lzma libraries to link against. + LIBLZMA_HAS_AUTO_DECODER - True if lzma_auto_decoder() is found (required). + LIBLZMA_HAS_EASY_ENCODER - True if lzma_easy_encoder() is found (required). + LIBLZMA_HAS_LZMA_PRESET - True if lzma_lzma_preset() is found (required). + LIBLZMA_VERSION_MAJOR - The major version of lzma + LIBLZMA_VERSION_MINOR - The minor version of lzma + LIBLZMA_VERSION_PATCH - The patch version of lzma + LIBLZMA_VERSION_STRING - version number as a string (ex: "5.0.3") +#]=======================================================================] find_path(LIBLZMA_INCLUDE_DIR lzma.h ) find_library(LIBLZMA_LIBRARY NAMES lzma liblzma) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 615de49..1a2af16 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -1,47 +1,48 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLibXml2 -# ----------- -# -# Find the XML processing library (libxml2). -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if -# libxml2 has been found. -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``LIBXML2_FOUND`` -# true if libxml2 headers and libraries were found -# ``LIBXML2_INCLUDE_DIR`` -# the directory containing LibXml2 headers -# ``LIBXML2_INCLUDE_DIRS`` -# list of the include directories needed to use LibXml2 -# ``LIBXML2_LIBRARIES`` -# LibXml2 libraries to be linked -# ``LIBXML2_DEFINITIONS`` -# the compiler switches required for using LibXml2 -# ``LIBXML2_XMLLINT_EXECUTABLE`` -# path to the XML checking tool xmllint coming with LibXml2 -# ``LIBXML2_VERSION_STRING`` -# the version of LibXml2 found (since CMake 2.8.8) -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``LIBXML2_INCLUDE_DIR`` -# the directory containing LibXml2 headers -# ``LIBXML2_LIBRARY`` -# path to the LibXml2 library +#[=======================================================================[.rst: +FindLibXml2 +----------- + +Find the XML processing library (libxml2). + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if +libxml2 has been found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``LIBXML2_FOUND`` + true if libxml2 headers and libraries were found +``LIBXML2_INCLUDE_DIR`` + the directory containing LibXml2 headers +``LIBXML2_INCLUDE_DIRS`` + list of the include directories needed to use LibXml2 +``LIBXML2_LIBRARIES`` + LibXml2 libraries to be linked +``LIBXML2_DEFINITIONS`` + the compiler switches required for using LibXml2 +``LIBXML2_XMLLINT_EXECUTABLE`` + path to the XML checking tool xmllint coming with LibXml2 +``LIBXML2_VERSION_STRING`` + the version of LibXml2 found (since CMake 2.8.8) + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``LIBXML2_INCLUDE_DIR`` + the directory containing LibXml2 headers +``LIBXML2_LIBRARY`` + path to the LibXml2 library +#]=======================================================================] # use pkg-config to get the directories and then use these values # in the find_path() and find_library() calls diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index abd1963..4cca64f 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -1,29 +1,30 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLibXslt -# ----------- -# -# Try to find the LibXslt library -# -# Once done this will define -# -# :: -# -# LIBXSLT_FOUND - system has LibXslt -# LIBXSLT_INCLUDE_DIR - the LibXslt include directory -# LIBXSLT_LIBRARIES - Link these to LibXslt -# LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt -# LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8) -# -# Additionally, the following two variables are set (but not required -# for using xslt): -# -# ``LIBXSLT_EXSLT_LIBRARIES`` -# Link to these if you need to link against the exslt library. -# ``LIBXSLT_XSLTPROC_EXECUTABLE`` -# Contains the full path to the xsltproc executable if found. +#[=======================================================================[.rst: +FindLibXslt +----------- + +Try to find the LibXslt library + +Once done this will define + +:: + + LIBXSLT_FOUND - system has LibXslt + LIBXSLT_INCLUDE_DIR - the LibXslt include directory + LIBXSLT_LIBRARIES - Link these to LibXslt + LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt + LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8) + +Additionally, the following two variables are set (but not required +for using xslt): + +``LIBXSLT_EXSLT_LIBRARIES`` + Link to these if you need to link against the exslt library. +``LIBXSLT_XSLTPROC_EXECUTABLE`` + Contains the full path to the xsltproc executable if found. +#]=======================================================================] # use pkg-config to get the directories and then use these values # in the find_path() and find_library() calls diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index 68530b3..eb3b5fb 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -1,40 +1,41 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLua -# ------- -# -# -# -# Locate Lua library This module defines -# -# :: -# -# LUA_FOUND - if false, do not try to link to Lua -# LUA_LIBRARIES - both lua and lualib -# LUA_INCLUDE_DIR - where to find lua.h -# LUA_VERSION_STRING - the version of Lua found -# LUA_VERSION_MAJOR - the major version of Lua -# LUA_VERSION_MINOR - the minor version of Lua -# LUA_VERSION_PATCH - the patch version of Lua -# -# -# -# Note that the expected include convention is -# -# :: -# -# #include "lua.h" -# -# and not -# -# :: -# -# #include <lua/lua.h> -# -# This is because, the lua location is not standardized and may exist in -# locations other than lua/ +#[=======================================================================[.rst: +FindLua +------- + + + +Locate Lua library This module defines + +:: + + LUA_FOUND - if false, do not try to link to Lua + LUA_LIBRARIES - both lua and lualib + LUA_INCLUDE_DIR - where to find lua.h + LUA_VERSION_STRING - the version of Lua found + LUA_VERSION_MAJOR - the major version of Lua + LUA_VERSION_MINOR - the minor version of Lua + LUA_VERSION_PATCH - the patch version of Lua + + + +Note that the expected include convention is + +:: + + #include "lua.h" + +and not + +:: + + #include <lua/lua.h> + +This is because, the lua location is not standardized and may exist in +locations other than lua/ +#]=======================================================================] cmake_policy(PUSH) # Policies apply to functions at definition-time cmake_policy(SET CMP0012 NEW) # For while(TRUE) diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake index 315f301..aafc056 100644 --- a/Modules/FindLua50.cmake +++ b/Modules/FindLua50.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLua50 -# --------- -# -# -# -# Locate Lua library This module defines -# -# :: -# -# LUA50_FOUND, if false, do not try to link to Lua -# LUA_LIBRARIES, both lua and lualib -# LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h) -# -# -# -# Note that the expected include convention is -# -# :: -# -# #include "lua.h" -# -# and not -# -# :: -# -# #include <lua/lua.h> -# -# This is because, the lua location is not standardized and may exist in -# locations other than lua/ +#[=======================================================================[.rst: +FindLua50 +--------- + + + +Locate Lua library This module defines + +:: + + LUA50_FOUND, if false, do not try to link to Lua + LUA_LIBRARIES, both lua and lualib + LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h) + + + +Note that the expected include convention is + +:: + + #include "lua.h" + +and not + +:: + + #include <lua/lua.h> + +This is because, the lua location is not standardized and may exist in +locations other than lua/ +#]=======================================================================] find_path(LUA_INCLUDE_DIR lua.h HINTS diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index f2b2322..31eaf87 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindLua51 -# --------- -# -# -# -# Locate Lua library This module defines -# -# :: -# -# LUA51_FOUND, if false, do not try to link to Lua -# LUA_LIBRARIES -# LUA_INCLUDE_DIR, where to find lua.h -# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) -# -# -# -# Note that the expected include convention is -# -# :: -# -# #include "lua.h" -# -# and not -# -# :: -# -# #include <lua/lua.h> -# -# This is because, the lua location is not standardized and may exist in -# locations other than lua/ +#[=======================================================================[.rst: +FindLua51 +--------- + + + +Locate Lua library This module defines + +:: + + LUA51_FOUND, if false, do not try to link to Lua + LUA_LIBRARIES + LUA_INCLUDE_DIR, where to find lua.h + LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) + + + +Note that the expected include convention is + +:: + + #include "lua.h" + +and not + +:: + + #include <lua/lua.h> + +This is because, the lua location is not standardized and may exist in +locations other than lua/ +#]=======================================================================] find_path(LUA_INCLUDE_DIR lua.h HINTS diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index 3baaf32..9738ac5 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindMFC -# ------- -# -# Find MFC on Windows -# -# Find the native MFC - i.e. decide if an application can link to the -# MFC libraries. -# -# :: -# -# MFC_FOUND - Was MFC support found -# -# You don't need to include anything or link anything to use it. +#[=======================================================================[.rst: +FindMFC +------- + +Find MFC on Windows + +Find the native MFC - i.e. decide if an application can link to the +MFC libraries. + +:: + + MFC_FOUND - Was MFC support found + +You don't need to include anything or link anything to use it. +#]=======================================================================] # Assume no MFC support set(MFC_FOUND "NO") diff --git a/Modules/FindMPEG.cmake b/Modules/FindMPEG.cmake index 850a57e..e5a80e3 100644 --- a/Modules/FindMPEG.cmake +++ b/Modules/FindMPEG.cmake @@ -1,26 +1,27 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindMPEG -# -------- -# -# Find the native MPEG includes and library -# -# This module defines -# -# :: -# -# MPEG_INCLUDE_DIR, where to find MPEG.h, etc. -# MPEG_LIBRARIES, the libraries required to use MPEG. -# MPEG_FOUND, If false, do not try to use MPEG. -# -# also defined, but not for general use are -# -# :: -# -# MPEG_mpeg2_LIBRARY, where to find the MPEG library. -# MPEG_vo_LIBRARY, where to find the vo library. +#[=======================================================================[.rst: +FindMPEG +-------- + +Find the native MPEG includes and library + +This module defines + +:: + + MPEG_INCLUDE_DIR, where to find MPEG.h, etc. + MPEG_LIBRARIES, the libraries required to use MPEG. + MPEG_FOUND, If false, do not try to use MPEG. + +also defined, but not for general use are + +:: + + MPEG_mpeg2_LIBRARY, where to find the MPEG library. + MPEG_vo_LIBRARY, where to find the vo library. +#]=======================================================================] find_path(MPEG_INCLUDE_DIR NAMES mpeg2.h mpeg2dec/mpeg2.h mpeg2dec/include/video_out.h) diff --git a/Modules/FindMPEG2.cmake b/Modules/FindMPEG2.cmake index f9ccd6a..763d86a 100644 --- a/Modules/FindMPEG2.cmake +++ b/Modules/FindMPEG2.cmake @@ -1,26 +1,27 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindMPEG2 -# --------- -# -# Find the native MPEG2 includes and library -# -# This module defines -# -# :: -# -# MPEG2_INCLUDE_DIR, path to mpeg2dec/mpeg2.h, etc. -# MPEG2_LIBRARIES, the libraries required to use MPEG2. -# MPEG2_FOUND, If false, do not try to use MPEG2. -# -# also defined, but not for general use are -# -# :: -# -# MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library. -# MPEG2_vo_LIBRARY, where to find the vo library. +#[=======================================================================[.rst: +FindMPEG2 +--------- + +Find the native MPEG2 includes and library + +This module defines + +:: + + MPEG2_INCLUDE_DIR, path to mpeg2dec/mpeg2.h, etc. + MPEG2_LIBRARIES, the libraries required to use MPEG2. + MPEG2_FOUND, If false, do not try to use MPEG2. + +also defined, but not for general use are + +:: + + MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library. + MPEG2_vo_LIBRARY, where to find the vo library. +#]=======================================================================] find_path(MPEG2_INCLUDE_DIR NAMES mpeg2.h mpeg2dec/mpeg2.h) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index bfcd876..8c45a8c 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1,247 +1,248 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindMPI -# ------- -# -# Find a Message Passing Interface (MPI) implementation. -# -# The Message Passing Interface (MPI) is a library used to write -# high-performance distributed-memory parallel applications, and is -# typically deployed on a cluster. MPI is a standard interface (defined -# by the MPI forum) for which many implementations are available. -# -# Variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. -# Each of these controls the various MPI languages to search for. -# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the -# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API -# that was removed again in MPI-3. -# -# Depending on the enabled components the following variables will be set: -# -# ``MPI_FOUND`` -# Variable indicating that MPI settings for all requested languages have been found. -# If no components are specified, this is true if MPI settings for all enabled languages -# were detected. Note that the ``MPICXX`` component does not affect this variable. -# ``MPI_VERSION`` -# Minimal version of MPI detected among the requested languages, or all enabled languages -# if no components were specified. -# -# This module will set the following variables per language in your -# project, where ``<lang>`` is one of C, CXX, or Fortran: -# -# ``MPI_<lang>_FOUND`` -# Variable indicating the MPI settings for ``<lang>`` were found and that -# simple MPI test programs compile with the provided settings. -# ``MPI_<lang>_COMPILER`` -# MPI compiler for ``<lang>`` if such a program exists. -# ``MPI_<lang>_COMPILE_OPTIONS`` -# Compilation options for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`. -# ``MPI_<lang>_COMPILE_DEFINITIONS`` -# Compilation definitions for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`. -# ``MPI_<lang>_INCLUDE_DIRS`` -# Include path(s) for MPI header. -# ``MPI_<lang>_LINK_FLAGS`` -# Linker flags for MPI programs. -# ``MPI_<lang>_LIBRARIES`` -# All libraries to link MPI programs against. -# -# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: -# -# ``MPI::MPI_<lang>`` -# Target for using MPI from ``<lang>``. -# -# The following variables indicating which bindings are present will be defined: -# -# ``MPI_MPICXX_FOUND`` -# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). -# ``MPI_Fortran_HAVE_F77_HEADER`` -# True if the Fortran 77 header ``mpif.h`` is available. -# ``MPI_Fortran_HAVE_F90_MODULE`` -# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). -# ``MPI_Fortran_HAVE_F08_MODULE`` -# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). -# -# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version -# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. -# -# ``MPI_<lang>_VERSION_MAJOR`` -# Major version of MPI implemented for ``<lang>`` by the MPI distribution. -# ``MPI_<lang>_VERSION_MINOR`` -# Minor version of MPI implemented for ``<lang>`` by the MPI distribution. -# ``MPI_<lang>_VERSION`` -# MPI version implemented for ``<lang>`` by the MPI distribution. -# -# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards -# always have required this binding to work in both C and C++ code. -# -# For running MPI programs, the module sets the following variables -# -# ``MPIEXEC_EXECUTABLE`` -# Executable for running MPI programs, if such exists. -# ``MPIEXEC_NUMPROC_FLAG`` -# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. -# ``MPIEXEC_MAX_NUMPROCS`` -# Number of MPI processors to utilize. Defaults to the number -# of processors detected on the host system. -# ``MPIEXEC_PREFLAGS`` -# Flags to pass to ``mpiexec`` directly before the executable to run. -# ``MPIEXEC_POSTFLAGS`` -# Flags to pass to ``mpiexec`` after other flags. -# -# Variables for locating MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# This module performs a three step search for an MPI implementation: -# -# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a -# compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system. -# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. -# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. -# Currently, only Microsoft MPI and MPICH2 on Windows are supported. -# -# For controlling the second step, the following variables may be set: -# -# ``MPI_<lang>_COMPILER`` -# Search for the specified compiler wrapper and use it. -# ``MPI_<lang>_COMPILER_FLAGS`` -# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers -# support linking debug or tracing libraries if a specific flag is passed and this variable -# may be used to obtain them. -# ``MPI_COMPILER_FLAGS`` -# Used to initialize ``MPI_<lang>_COMPILER_FLAGS`` if no language specific flag has been given. -# Empty by default. -# ``MPI_EXECUTABLE_SUFFIX`` -# A suffix which is appended to all names that are being looked for. For instance you may set this -# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. -# -# In order to control the guessing step, the following variable may be set: -# -# ``MPI_GUESS_LIBRARY_NAME`` -# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. -# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. -# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. -# -# Each of the search steps may be skipped with the following control variables: -# -# ``MPI_ASSUME_NO_BUILTIN_MPI`` -# If true, the module assumes that the compiler itself does not provide an MPI implementation and -# skips to step 2. -# ``MPI_SKIP_COMPILER_WRAPPER`` -# If true, no compiler wrapper will be searched for. -# ``MPI_SKIP_GUESSING`` -# If true, the guessing step will be skipped. -# -# Additionally, the following control variable is available to change search behavior: -# -# ``MPI_CXX_SKIP_MPICXX`` -# Add some definitions that will disable the MPI-2 C++ bindings. -# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, -# for example MVAPICH or Intel MPI. -# -# If the find procedure fails for a variable ``MPI_<lang>_WORKS``, then the settings detected by or passed to -# the module did not work and even a simple MPI test program failed to compile. -# -# If all of these parameters were not sufficient to find the right MPI implementation, a user may -# disable the entire autodetection process by specifying both a list of libraries in ``MPI_<lang>_LIBRARIES`` -# and a list of include directories in ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS``. -# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the -# settings in the cache. -# -# Cache variables for MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The variable ``MPI_<lang>_INCLUDE_DIRS`` will be assembled from the following variables. -# For C and CXX: -# -# ``MPI_<lang>_HEADER_DIR`` -# Location of the ``mpi.h`` header on disk. -# -# For Fortran: -# -# ``MPI_Fortran_F77_HEADER_DIR`` -# Location of the Fortran 77 header ``mpif.h``, if it exists. -# ``MPI_Fortran_MODULE_DIR`` -# Location of the ``mpi`` or ``mpi_f08`` modules, if available. -# -# For all languages the following variables are additionally considered: -# -# ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS`` -# A :ref:`;-list <CMake Language Lists>` of paths needed in addition to the normal include directories. -# ``MPI_<include_name>_INCLUDE_DIR`` -# Path variables for include folders referred to by ``<include_name>``. -# ``MPI_<lang>_ADDITIONAL_INCLUDE_VARS`` -# A :ref:`;-list <CMake Language Lists>` of ``<include_name>`` that will be added to the include locations of ``<lang>``. -# -# The variable ``MPI_<lang>_LIBRARIES`` will be assembled from the following variables: -# -# ``MPI_<lib_name>_LIBRARY`` -# The location of a library called ``<lib_name>`` for use with MPI. -# ``MPI_<lang>_LIB_NAMES`` -# A :ref:`;-list <CMake Language Lists>` of ``<lib_name>`` that will be added to the include locations of ``<lang>``. -# -# Usage of mpiexec -# ^^^^^^^^^^^^^^^^ -# -# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically -# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: -# -# :: -# -# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} -# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS -# -# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to -# pass to the MPI program. -# -# Advanced variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module can perform some advanced feature detections upon explicit request. -# -# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. -# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. -# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. -# You should only enable these detections if you absolutely need the information. -# -# If the following variables are set to true, the respective search will be performed: -# -# ``MPI_DETERMINE_Fortran_CAPABILITIES`` -# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and -# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran_<binding>_SUBARRAYS`` -# and ``MPI_Fortran_<binding>_ASYNCPROT``, where ``<binding>`` is one of ``F77_HEADER``, ``F90_MODULE`` and -# ``F08_MODULE``. -# ``MPI_DETERMINE_LIBRARY_VERSION`` -# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI_<lang>_LIBRARY_VERSION``. -# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ``<lang>``. -# Note that the return value is entirely implementation defined. This information might be used to identify -# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# For backward compatibility with older versions of FindMPI, these -# variables are set, but deprecated: -# -# :: -# -# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY -# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS -# MPI_LIBRARIES -# -# In new projects, please use the ``MPI_<lang>_XXX`` equivalents. -# Additionally, the following variables are deprecated: -# -# ``MPI_<lang>_COMPILE_FLAGS`` -# Use ``MPI_<lang>_COMPILE_OPTIONS`` and ``MPI_<lang>_COMPILE_DEFINITIONS`` instead. -# ``MPI_<lang>_INCLUDE_PATH`` -# For consumption use ``MPI_<lang>_INCLUDE_DIRS`` and for specifying folders use ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS`` instead. -# ``MPIEXEC`` -# Use ``MPIEXEC_EXECUTABLE`` instead. +#[=======================================================================[.rst: +FindMPI +------- + +Find a Message Passing Interface (MPI) implementation. + +The Message Passing Interface (MPI) is a library used to write +high-performance distributed-memory parallel applications, and is +typically deployed on a cluster. MPI is a standard interface (defined +by the MPI forum) for which many implementations are available. + +Variables for using MPI +^^^^^^^^^^^^^^^^^^^^^^^ + +The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. +Each of these controls the various MPI languages to search for. +The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the +MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API +that was removed again in MPI-3. + +Depending on the enabled components the following variables will be set: + +``MPI_FOUND`` + Variable indicating that MPI settings for all requested languages have been found. + If no components are specified, this is true if MPI settings for all enabled languages + were detected. Note that the ``MPICXX`` component does not affect this variable. +``MPI_VERSION`` + Minimal version of MPI detected among the requested languages, or all enabled languages + if no components were specified. + +This module will set the following variables per language in your +project, where ``<lang>`` is one of C, CXX, or Fortran: + +``MPI_<lang>_FOUND`` + Variable indicating the MPI settings for ``<lang>`` were found and that + simple MPI test programs compile with the provided settings. +``MPI_<lang>_COMPILER`` + MPI compiler for ``<lang>`` if such a program exists. +``MPI_<lang>_COMPILE_OPTIONS`` + Compilation options for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`. +``MPI_<lang>_COMPILE_DEFINITIONS`` + Compilation definitions for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`. +``MPI_<lang>_INCLUDE_DIRS`` + Include path(s) for MPI header. +``MPI_<lang>_LINK_FLAGS`` + Linker flags for MPI programs. +``MPI_<lang>_LIBRARIES`` + All libraries to link MPI programs against. + +Additionally, the following :prop_tgt:`IMPORTED` targets are defined: + +``MPI::MPI_<lang>`` + Target for using MPI from ``<lang>``. + +The following variables indicating which bindings are present will be defined: + +``MPI_MPICXX_FOUND`` + Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). +``MPI_Fortran_HAVE_F77_HEADER`` + True if the Fortran 77 header ``mpif.h`` is available. +``MPI_Fortran_HAVE_F90_MODULE`` + True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). +``MPI_Fortran_HAVE_F08_MODULE`` + True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). + +If possible, the MPI version will be determined by this module. The facilities to detect the MPI version +were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. + +``MPI_<lang>_VERSION_MAJOR`` + Major version of MPI implemented for ``<lang>`` by the MPI distribution. +``MPI_<lang>_VERSION_MINOR`` + Minor version of MPI implemented for ``<lang>`` by the MPI distribution. +``MPI_<lang>_VERSION`` + MPI version implemented for ``<lang>`` by the MPI distribution. + +Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards +always have required this binding to work in both C and C++ code. + +For running MPI programs, the module sets the following variables + +``MPIEXEC_EXECUTABLE`` + Executable for running MPI programs, if such exists. +``MPIEXEC_NUMPROC_FLAG`` + Flag to pass to ``mpiexec`` before giving it the number of processors to run on. +``MPIEXEC_MAX_NUMPROCS`` + Number of MPI processors to utilize. Defaults to the number + of processors detected on the host system. +``MPIEXEC_PREFLAGS`` + Flags to pass to ``mpiexec`` directly before the executable to run. +``MPIEXEC_POSTFLAGS`` + Flags to pass to ``mpiexec`` after other flags. + +Variables for locating MPI +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This module performs a three step search for an MPI implementation: + +1. Check if the compiler has MPI support built-in. This is the case if the user passed a + compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system. +2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. +3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. + Currently, only Microsoft MPI and MPICH2 on Windows are supported. + +For controlling the second step, the following variables may be set: + +``MPI_<lang>_COMPILER`` + Search for the specified compiler wrapper and use it. +``MPI_<lang>_COMPILER_FLAGS`` + Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers + support linking debug or tracing libraries if a specific flag is passed and this variable + may be used to obtain them. +``MPI_COMPILER_FLAGS`` + Used to initialize ``MPI_<lang>_COMPILER_FLAGS`` if no language specific flag has been given. + Empty by default. +``MPI_EXECUTABLE_SUFFIX`` + A suffix which is appended to all names that are being looked for. For instance you may set this + to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. + +In order to control the guessing step, the following variable may be set: + +``MPI_GUESS_LIBRARY_NAME`` + Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. + By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. + This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. + +Each of the search steps may be skipped with the following control variables: + +``MPI_ASSUME_NO_BUILTIN_MPI`` + If true, the module assumes that the compiler itself does not provide an MPI implementation and + skips to step 2. +``MPI_SKIP_COMPILER_WRAPPER`` + If true, no compiler wrapper will be searched for. +``MPI_SKIP_GUESSING`` + If true, the guessing step will be skipped. + +Additionally, the following control variable is available to change search behavior: + +``MPI_CXX_SKIP_MPICXX`` + Add some definitions that will disable the MPI-2 C++ bindings. + Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, + for example MVAPICH or Intel MPI. + +If the find procedure fails for a variable ``MPI_<lang>_WORKS``, then the settings detected by or passed to +the module did not work and even a simple MPI test program failed to compile. + +If all of these parameters were not sufficient to find the right MPI implementation, a user may +disable the entire autodetection process by specifying both a list of libraries in ``MPI_<lang>_LIBRARIES`` +and a list of include directories in ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS``. +Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the +settings in the cache. + +Cache variables for MPI +^^^^^^^^^^^^^^^^^^^^^^^ + +The variable ``MPI_<lang>_INCLUDE_DIRS`` will be assembled from the following variables. +For C and CXX: + +``MPI_<lang>_HEADER_DIR`` + Location of the ``mpi.h`` header on disk. + +For Fortran: + +``MPI_Fortran_F77_HEADER_DIR`` + Location of the Fortran 77 header ``mpif.h``, if it exists. +``MPI_Fortran_MODULE_DIR`` + Location of the ``mpi`` or ``mpi_f08`` modules, if available. + +For all languages the following variables are additionally considered: + +``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS`` + A :ref:`;-list <CMake Language Lists>` of paths needed in addition to the normal include directories. +``MPI_<include_name>_INCLUDE_DIR`` + Path variables for include folders referred to by ``<include_name>``. +``MPI_<lang>_ADDITIONAL_INCLUDE_VARS`` + A :ref:`;-list <CMake Language Lists>` of ``<include_name>`` that will be added to the include locations of ``<lang>``. + +The variable ``MPI_<lang>_LIBRARIES`` will be assembled from the following variables: + +``MPI_<lib_name>_LIBRARY`` + The location of a library called ``<lib_name>`` for use with MPI. +``MPI_<lang>_LIB_NAMES`` + A :ref:`;-list <CMake Language Lists>` of ``<lib_name>`` that will be added to the include locations of ``<lang>``. + +Usage of mpiexec +^^^^^^^^^^^^^^^^ + +When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically +use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: + +:: + + ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} + ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS + +where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to +pass to the MPI program. + +Advanced variables for using MPI +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The module can perform some advanced feature detections upon explicit request. + +**Important notice:** The following checks cannot be performed without *executing* an MPI test program. +Consider the special considerations for the behavior of :command:`try_run` during cross compilation. +Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. +You should only enable these detections if you absolutely need the information. + +If the following variables are set to true, the respective search will be performed: + +``MPI_DETERMINE_Fortran_CAPABILITIES`` + Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and + ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran_<binding>_SUBARRAYS`` + and ``MPI_Fortran_<binding>_ASYNCPROT``, where ``<binding>`` is one of ``F77_HEADER``, ``F90_MODULE`` and + ``F08_MODULE``. +``MPI_DETERMINE_LIBRARY_VERSION`` + For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI_<lang>_LIBRARY_VERSION``. + This information is usually tied to the runtime component of an MPI implementation and might differ depending on ``<lang>``. + Note that the return value is entirely implementation defined. This information might be used to identify + the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. + +Backward Compatibility +^^^^^^^^^^^^^^^^^^^^^^ + +For backward compatibility with older versions of FindMPI, these +variables are set, but deprecated: + +:: + + MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY + MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS + MPI_LIBRARIES + +In new projects, please use the ``MPI_<lang>_XXX`` equivalents. +Additionally, the following variables are deprecated: + +``MPI_<lang>_COMPILE_FLAGS`` + Use ``MPI_<lang>_COMPILE_OPTIONS`` and ``MPI_<lang>_COMPILE_DEFINITIONS`` instead. +``MPI_<lang>_INCLUDE_PATH`` + For consumption use ``MPI_<lang>_INCLUDE_DIRS`` and for specifying folders use ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS`` instead. +``MPIEXEC`` + Use ``MPIEXEC_EXECUTABLE`` instead. +#]=======================================================================] cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST @@ -1131,7 +1132,12 @@ macro(_MPI_create_imported_target LANG) add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) endif() - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + # When this is consumed for compiling CUDA, use '-Xcompiler' to wrap '-pthread'. + string(REPLACE "-pthread" "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler >-pthread" + _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}") + unset(_MPI_${LANG}_COMPILE_OPTIONS) + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 547a330..8ba88b0 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -1,232 +1,233 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindMatlab -# ---------- -# -# Finds Matlab or Matlab Compiler Runtime (MCR) and provides Matlab tools, -# libraries and compilers to CMake. -# -# This package primary purpose is to find the libraries associated with Matlab -# or the MCR in order to be able to build Matlab extensions (mex files). It -# can also be used: -# -# * to run specific commands in Matlab in case Matlab is available -# * for declaring Matlab unit test -# * to retrieve various information from Matlab (mex extensions, versions and -# release queries, ...) -# -# The module supports the following components: -# -# * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``MX``, -# ``ENG`` and ``MAT`` libraries of Matlab -# * ``ENGINE_LIBRARY``, ``DATAARRAY_LIBRARY``: respectively the ``MatlabEngine`` -# and ``MatlabDataArray`` libraries of Matlab (Matlab 2018a and later) -# * ``MAIN_PROGRAM`` the Matlab binary program. Note that this component is not -# available on the MCR version, and will yield an error if the MCR is found -# instead of the regular Matlab installation. -# * ``MEX_COMPILER`` the MEX compiler. -# * ``MCC_COMPILER`` the MCC compiler, included with the Matlab Compiler add-on. -# * ``SIMULINK`` the Simulink environment. -# -# .. note:: -# -# The version given to the :command:`find_package` directive is the Matlab -# **version**, which should not be confused with the Matlab *release* name -# (eg. `R2014`). -# The :command:`matlab_get_version_from_release_name` and -# :command:`matlab_get_release_name_from_version` provide a mapping -# between the release name and the version. -# -# The variable :variable:`Matlab_ROOT_DIR` may be specified in order to give -# the path of the desired Matlab version. Otherwise, the behaviour is platform -# specific: -# -# * Windows: The installed versions of Matlab/MCR are retrieved from the -# Windows registry -# * OS X: The installed versions of Matlab/MCR are given by the MATLAB -# default installation paths in ``/Application``. If no such application is -# found, it falls back to the one that might be accessible from the ``PATH``. -# * Unix: The desired Matlab should be accessible from the ``PATH``. This does -# not work for MCR installation and :variable:`Matlab_ROOT_DIR` should be -# specified on this platform. -# -# Additional information is provided when :variable:`MATLAB_FIND_DEBUG` is set. -# When a Matlab/MCR installation is found automatically and the ``MATLAB_VERSION`` -# is not given, the version is queried from Matlab directly (on Windows this -# may pop up a Matlab window) or from the MCR installation. -# -# The mapping of the release names and the version of Matlab is performed by -# defining pairs (name, version). The variable -# :variable:`MATLAB_ADDITIONAL_VERSIONS` may be provided before the call to -# the :command:`find_package` in order to handle additional versions. -# -# A Matlab scripts can be added to the set of tests using the -# :command:`matlab_add_unit_test`. By default, the Matlab unit test framework -# will be used (>= 2013a) to run this script, but regular ``.m`` files -# returning an exit code can be used as well (0 indicating a success). -# -# Module Input Variables -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# Users or projects may set the following variables to configure the module -# behaviour: -# -# :variable:`Matlab_ROOT_DIR` -# the root of the Matlab installation. -# :variable:`MATLAB_FIND_DEBUG` -# outputs debug information -# :variable:`MATLAB_ADDITIONAL_VERSIONS` -# additional versions of Matlab for the automatic retrieval of the installed -# versions. -# -# Variables defined by the module -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# Result variables -# """""""""""""""" -# -# ``Matlab_FOUND`` -# ``TRUE`` if the Matlab installation is found, ``FALSE`` -# otherwise. All variable below are defined if Matlab is found. -# ``Matlab_ROOT_DIR`` -# the final root of the Matlab installation determined by the FindMatlab -# module. -# ``Matlab_MAIN_PROGRAM`` -# the Matlab binary program. Available only if the component ``MAIN_PROGRAM`` -# is given in the :command:`find_package` directive. -# ``Matlab_INCLUDE_DIRS`` -# the path of the Matlab libraries headers -# ``Matlab_MEX_LIBRARY`` -# library for mex, always available. -# ``Matlab_MX_LIBRARY`` -# mx library of Matlab (arrays). Available only if the component -# ``MX_LIBRARY`` has been requested. -# ``Matlab_ENG_LIBRARY`` -# Matlab engine library. Available only if the component ``ENG_LIBRARY`` -# is requested. -# ``Matlab_MAT_LIBRARY`` -# Matlab matrix library. Available only if the component ``MAT_LIBRARY`` -# is requested. -# ``Matlab_ENGINE_LIBRARY`` -# Matlab C++ engine library. Available only if the component ``ENGINE_LIBRARY`` -# is requested. -# ``Matlab_DATAARRAY_LIBRARY`` -# Matlab C++ data array library. Available only if the component ``DATAARRAY_LIBRARY`` -# is requested. -# ``Matlab_LIBRARIES`` -# the whole set of libraries of Matlab -# ``Matlab_MEX_COMPILER`` -# the mex compiler of Matlab. Currently not used. -# Available only if the component ``MEX_COMPILER`` is requested. -# ``Matlab_MCC_COMPILER`` -# the mcc compiler of Matlab. Included with the Matlab Compiler add-on. -# Available only if the component ``MCC_COMPILER`` is requested. -# -# Cached variables -# """""""""""""""" -# -# ``Matlab_MEX_EXTENSION`` -# the extension of the mex files for the current platform (given by Matlab). -# ``Matlab_ROOT_DIR`` -# the location of the root of the Matlab installation found. If this value -# is changed by the user, the result variables are recomputed. -# -# Provided macros -# ^^^^^^^^^^^^^^^ -# -# :command:`matlab_get_version_from_release_name` -# returns the version from the release name -# :command:`matlab_get_release_name_from_version` -# returns the release name from the Matlab version -# -# Provided functions -# ^^^^^^^^^^^^^^^^^^ -# -# :command:`matlab_add_mex` -# adds a target compiling a MEX file. -# :command:`matlab_add_unit_test` -# adds a Matlab unit test file as a test to the project. -# :command:`matlab_extract_all_installed_versions_from_registry` -# parses the registry for all Matlab versions. Available on Windows only. -# The part of the registry parsed is dependent on the host processor -# :command:`matlab_get_all_valid_matlab_roots_from_registry` -# returns all the possible Matlab or MCR paths, according to a previously -# given list. Only the existing/accessible paths are kept. This is mainly -# useful for the searching all possible Matlab installation. -# :command:`matlab_get_mex_suffix` -# returns the suffix to be used for the mex files -# (platform/architecture dependent) -# :command:`matlab_get_version_from_matlab_run` -# returns the version of Matlab/MCR, given the full directory of the Matlab/MCR -# installation path. -# -# -# Known issues -# ^^^^^^^^^^^^ -# -# **Symbol clash in a MEX target** -# By default, every symbols inside a MEX -# file defined with the command :command:`matlab_add_mex` have hidden -# visibility, except for the entry point. This is the default behaviour of -# the MEX compiler, which lowers the risk of symbol collision between the -# libraries shipped with Matlab, and the libraries to which the MEX file is -# linking to. This is also the default on Windows platforms. -# -# However, this is not sufficient in certain case, where for instance your -# MEX file is linking against libraries that are already loaded by Matlab, -# even if those libraries have different SONAMES. -# A possible solution is to hide the symbols of the libraries to which the -# MEX target is linking to. This can be achieved in GNU GCC compilers with -# the linker option ``-Wl,--exclude-libs,ALL``. -# -# **Tests using GPU resources** -# in case your MEX file is using the GPU and -# in order to be able to run unit tests on this MEX file, the GPU resources -# should be properly released by Matlab. A possible solution is to make -# Matlab aware of the use of the GPU resources in the session, which can be -# performed by a command such as ``D = gpuDevice()`` at the beginning of -# the test script (or via a fixture). -# -# -# Reference -# ^^^^^^^^^ -# -# .. variable:: Matlab_ROOT_DIR -# -# The root folder of the Matlab installation. If set before the call to -# :command:`find_package`, the module will look for the components in that -# path. If not set, then an automatic search of Matlab -# will be performed. If set, it should point to a valid version of Matlab. -# -# .. variable:: MATLAB_FIND_DEBUG -# -# If set, the lookup of Matlab and the intermediate configuration steps are -# outputted to the console. -# -# .. variable:: MATLAB_ADDITIONAL_VERSIONS -# -# If set, specifies additional versions of Matlab that may be looked for. -# The variable should be a list of strings, organised by pairs of release -# name and versions, such as follows:: -# -# set(MATLAB_ADDITIONAL_VERSIONS -# "release_name1=corresponding_version1" -# "release_name2=corresponding_version2" -# ... -# ) -# -# Example:: -# -# set(MATLAB_ADDITIONAL_VERSIONS -# "R2013b=8.2" -# "R2013a=8.1" -# "R2012b=8.0") -# -# The order of entries in this list matters when several versions of -# Matlab are installed. The priority is set according to the ordering in -# this list. +#[=======================================================================[.rst: +FindMatlab +---------- + +Finds Matlab or Matlab Compiler Runtime (MCR) and provides Matlab tools, +libraries and compilers to CMake. + +This package primary purpose is to find the libraries associated with Matlab +or the MCR in order to be able to build Matlab extensions (mex files). It +can also be used: + +* to run specific commands in Matlab in case Matlab is available +* for declaring Matlab unit test +* to retrieve various information from Matlab (mex extensions, versions and + release queries, ...) + +The module supports the following components: + +* ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``MX``, + ``ENG`` and ``MAT`` libraries of Matlab +* ``ENGINE_LIBRARY``, ``DATAARRAY_LIBRARY``: respectively the ``MatlabEngine`` + and ``MatlabDataArray`` libraries of Matlab (Matlab 2018a and later) +* ``MAIN_PROGRAM`` the Matlab binary program. Note that this component is not + available on the MCR version, and will yield an error if the MCR is found + instead of the regular Matlab installation. +* ``MEX_COMPILER`` the MEX compiler. +* ``MCC_COMPILER`` the MCC compiler, included with the Matlab Compiler add-on. +* ``SIMULINK`` the Simulink environment. + +.. note:: + + The version given to the :command:`find_package` directive is the Matlab + **version**, which should not be confused with the Matlab *release* name + (eg. `R2014`). + The :command:`matlab_get_version_from_release_name` and + :command:`matlab_get_release_name_from_version` provide a mapping + between the release name and the version. + +The variable :variable:`Matlab_ROOT_DIR` may be specified in order to give +the path of the desired Matlab version. Otherwise, the behaviour is platform +specific: + +* Windows: The installed versions of Matlab/MCR are retrieved from the + Windows registry +* OS X: The installed versions of Matlab/MCR are given by the MATLAB + default installation paths in ``/Application``. If no such application is + found, it falls back to the one that might be accessible from the ``PATH``. +* Unix: The desired Matlab should be accessible from the ``PATH``. This does + not work for MCR installation and :variable:`Matlab_ROOT_DIR` should be + specified on this platform. + +Additional information is provided when :variable:`MATLAB_FIND_DEBUG` is set. +When a Matlab/MCR installation is found automatically and the ``MATLAB_VERSION`` +is not given, the version is queried from Matlab directly (on Windows this +may pop up a Matlab window) or from the MCR installation. + +The mapping of the release names and the version of Matlab is performed by +defining pairs (name, version). The variable +:variable:`MATLAB_ADDITIONAL_VERSIONS` may be provided before the call to +the :command:`find_package` in order to handle additional versions. + +A Matlab scripts can be added to the set of tests using the +:command:`matlab_add_unit_test`. By default, the Matlab unit test framework +will be used (>= 2013a) to run this script, but regular ``.m`` files +returning an exit code can be used as well (0 indicating a success). + +Module Input Variables +^^^^^^^^^^^^^^^^^^^^^^ + +Users or projects may set the following variables to configure the module +behaviour: + +:variable:`Matlab_ROOT_DIR` + the root of the Matlab installation. +:variable:`MATLAB_FIND_DEBUG` + outputs debug information +:variable:`MATLAB_ADDITIONAL_VERSIONS` + additional versions of Matlab for the automatic retrieval of the installed + versions. + +Variables defined by the module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Result variables +"""""""""""""""" + +``Matlab_FOUND`` + ``TRUE`` if the Matlab installation is found, ``FALSE`` + otherwise. All variable below are defined if Matlab is found. +``Matlab_ROOT_DIR`` + the final root of the Matlab installation determined by the FindMatlab + module. +``Matlab_MAIN_PROGRAM`` + the Matlab binary program. Available only if the component ``MAIN_PROGRAM`` + is given in the :command:`find_package` directive. +``Matlab_INCLUDE_DIRS`` + the path of the Matlab libraries headers +``Matlab_MEX_LIBRARY`` + library for mex, always available. +``Matlab_MX_LIBRARY`` + mx library of Matlab (arrays). Available only if the component + ``MX_LIBRARY`` has been requested. +``Matlab_ENG_LIBRARY`` + Matlab engine library. Available only if the component ``ENG_LIBRARY`` + is requested. +``Matlab_MAT_LIBRARY`` + Matlab matrix library. Available only if the component ``MAT_LIBRARY`` + is requested. +``Matlab_ENGINE_LIBRARY`` + Matlab C++ engine library. Available only if the component ``ENGINE_LIBRARY`` + is requested. +``Matlab_DATAARRAY_LIBRARY`` + Matlab C++ data array library. Available only if the component ``DATAARRAY_LIBRARY`` + is requested. +``Matlab_LIBRARIES`` + the whole set of libraries of Matlab +``Matlab_MEX_COMPILER`` + the mex compiler of Matlab. Currently not used. + Available only if the component ``MEX_COMPILER`` is requested. +``Matlab_MCC_COMPILER`` + the mcc compiler of Matlab. Included with the Matlab Compiler add-on. + Available only if the component ``MCC_COMPILER`` is requested. + +Cached variables +"""""""""""""""" + +``Matlab_MEX_EXTENSION`` + the extension of the mex files for the current platform (given by Matlab). +``Matlab_ROOT_DIR`` + the location of the root of the Matlab installation found. If this value + is changed by the user, the result variables are recomputed. + +Provided macros +^^^^^^^^^^^^^^^ + +:command:`matlab_get_version_from_release_name` + returns the version from the release name +:command:`matlab_get_release_name_from_version` + returns the release name from the Matlab version + +Provided functions +^^^^^^^^^^^^^^^^^^ + +:command:`matlab_add_mex` + adds a target compiling a MEX file. +:command:`matlab_add_unit_test` + adds a Matlab unit test file as a test to the project. +:command:`matlab_extract_all_installed_versions_from_registry` + parses the registry for all Matlab versions. Available on Windows only. + The part of the registry parsed is dependent on the host processor +:command:`matlab_get_all_valid_matlab_roots_from_registry` + returns all the possible Matlab or MCR paths, according to a previously + given list. Only the existing/accessible paths are kept. This is mainly + useful for the searching all possible Matlab installation. +:command:`matlab_get_mex_suffix` + returns the suffix to be used for the mex files + (platform/architecture dependent) +:command:`matlab_get_version_from_matlab_run` + returns the version of Matlab/MCR, given the full directory of the Matlab/MCR + installation path. + + +Known issues +^^^^^^^^^^^^ + +**Symbol clash in a MEX target** + By default, every symbols inside a MEX + file defined with the command :command:`matlab_add_mex` have hidden + visibility, except for the entry point. This is the default behaviour of + the MEX compiler, which lowers the risk of symbol collision between the + libraries shipped with Matlab, and the libraries to which the MEX file is + linking to. This is also the default on Windows platforms. + + However, this is not sufficient in certain case, where for instance your + MEX file is linking against libraries that are already loaded by Matlab, + even if those libraries have different SONAMES. + A possible solution is to hide the symbols of the libraries to which the + MEX target is linking to. This can be achieved in GNU GCC compilers with + the linker option ``-Wl,--exclude-libs,ALL``. + +**Tests using GPU resources** + in case your MEX file is using the GPU and + in order to be able to run unit tests on this MEX file, the GPU resources + should be properly released by Matlab. A possible solution is to make + Matlab aware of the use of the GPU resources in the session, which can be + performed by a command such as ``D = gpuDevice()`` at the beginning of + the test script (or via a fixture). + + +Reference +^^^^^^^^^ + +.. variable:: Matlab_ROOT_DIR + + The root folder of the Matlab installation. If set before the call to + :command:`find_package`, the module will look for the components in that + path. If not set, then an automatic search of Matlab + will be performed. If set, it should point to a valid version of Matlab. + +.. variable:: MATLAB_FIND_DEBUG + + If set, the lookup of Matlab and the intermediate configuration steps are + outputted to the console. + +.. variable:: MATLAB_ADDITIONAL_VERSIONS + + If set, specifies additional versions of Matlab that may be looked for. + The variable should be a list of strings, organised by pairs of release + name and versions, such as follows:: + + set(MATLAB_ADDITIONAL_VERSIONS + "release_name1=corresponding_version1" + "release_name2=corresponding_version2" + ... + ) + + Example:: + + set(MATLAB_ADDITIONAL_VERSIONS + "R2013b=8.2" + "R2013a=8.1" + "R2012b=8.0") + + The order of entries in this list matters when several versions of + Matlab are installed. The priority is set according to the ordering in + this list. +#]=======================================================================] set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}") @@ -271,10 +272,11 @@ if(NOT EXISTS "${_matlab_temporary_folder}") file(MAKE_DIRECTORY "${_matlab_temporary_folder}") endif() -#.rst: -# .. command:: matlab_get_version_from_release_name -# -# Returns the version of Matlab (17.58) from a release name (R2017k) +#[=======================================================================[.rst: +.. command:: matlab_get_version_from_release_name + + Returns the version of Matlab (17.58) from a release name (R2017k) +#]=======================================================================] macro(matlab_get_version_from_release_name release_name version_name) string(REGEX MATCHALL "${release_name}=([0-9]+\\.?[0-9]*)" _matched ${MATLAB_VERSIONS_MAPPING}) @@ -293,10 +295,11 @@ endmacro() -#.rst: -# .. command:: matlab_get_release_name_from_version -# -# Returns the release name (R2017k) from the version of Matlab (17.58) +#[=======================================================================[.rst: +.. command:: matlab_get_release_name_from_version + + Returns the release name (R2017k) from the version of Matlab (17.58) +#]=======================================================================] macro(matlab_get_release_name_from_version version release_name) set(${release_name} "") @@ -353,22 +356,23 @@ macro(matlab_get_supported_versions list_versions) endmacro() -#.rst: -# .. command:: matlab_extract_all_installed_versions_from_registry -# -# This function parses the registry and founds the Matlab versions that are -# installed. The found versions are returned in `matlab_versions`. -# Set `win64` to `TRUE` if the 64 bit version of Matlab should be looked for -# The returned list contains all versions under -# ``HKLM\\SOFTWARE\\Mathworks\\MATLAB`` and -# ``HKLM\\SOFTWARE\\Mathworks\\MATLAB Runtime`` or an empty list in case an -# error occurred (or nothing found). -# -# .. note:: -# -# Only the versions are provided. No check is made over the existence of the -# installation referenced in the registry, -# +#[=======================================================================[.rst: +.. command:: matlab_extract_all_installed_versions_from_registry + + This function parses the registry and founds the Matlab versions that are + installed. The found versions are returned in `matlab_versions`. + Set `win64` to `TRUE` if the 64 bit version of Matlab should be looked for + The returned list contains all versions under + ``HKLM\\SOFTWARE\\Mathworks\\MATLAB`` and + ``HKLM\\SOFTWARE\\Mathworks\\MATLAB Runtime`` or an empty list in case an + error occurred (or nothing found). + + .. note:: + + Only the versions are provided. No check is made over the existence of the + installation referenced in the registry, + +#]=======================================================================] function(matlab_extract_all_installed_versions_from_registry win64 matlab_versions) if(NOT CMAKE_HOST_WIN32) @@ -477,25 +481,26 @@ endmacro() -#.rst: -# .. command:: matlab_get_all_valid_matlab_roots_from_registry -# -# Populates the Matlab root with valid versions of Matlab or -# Matlab Runtime (MCR). -# The returned matlab_roots is organized in triplets -# ``(type,version_number,matlab_root_path)``, where ``type`` -# indicates either ``MATLAB`` or ``MCR``. -# -# :: -# -# matlab_get_all_valid_matlab_roots_from_registry( -# matlab_versions -# matlab_roots) -# -# ``matlab_versions`` -# the versions of each of the Matlab or MCR installations -# ``matlab_roots`` -# the location of each of the Matlab or MCR installations +#[=======================================================================[.rst: +.. command:: matlab_get_all_valid_matlab_roots_from_registry + + Populates the Matlab root with valid versions of Matlab or + Matlab Runtime (MCR). + The returned matlab_roots is organized in triplets + ``(type,version_number,matlab_root_path)``, where ``type`` + indicates either ``MATLAB`` or ``MCR``. + + :: + + matlab_get_all_valid_matlab_roots_from_registry( + matlab_versions + matlab_roots) + + ``matlab_versions`` + the versions of each of the Matlab or MCR installations + ``matlab_roots`` + the location of each of the Matlab or MCR installations +#]=======================================================================] function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_roots) # The matlab_versions comes either from @@ -534,23 +539,24 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_ set(${matlab_roots} ${_matlab_roots_list} PARENT_SCOPE) endfunction() -#.rst: -# .. command:: matlab_get_mex_suffix -# -# Returns the extension of the mex files (the suffixes). -# This function should not be called before the appropriate Matlab root has -# been found. -# -# :: -# -# matlab_get_mex_suffix( -# matlab_root -# mex_suffix) -# -# ``matlab_root`` -# the root of the Matlab/MCR installation -# ``mex_suffix`` -# the variable name in which the suffix will be returned. +#[=======================================================================[.rst: +.. command:: matlab_get_mex_suffix + + Returns the extension of the mex files (the suffixes). + This function should not be called before the appropriate Matlab root has + been found. + + :: + + matlab_get_mex_suffix( + matlab_root + mex_suffix) + + ``matlab_root`` + the root of the Matlab/MCR installation + ``mex_suffix`` + the variable name in which the suffix will be returned. +#]=======================================================================] function(matlab_get_mex_suffix matlab_root mex_suffix) # todo setup the extension properly. Currently I do not know if this is @@ -636,23 +642,24 @@ endfunction() -#.rst: -# .. command:: matlab_get_version_from_matlab_run -# -# This function runs Matlab program specified on arguments and extracts its -# version. If the path provided for the Matlab installation points to an MCR -# installation, the version is extracted from the installed files. -# -# :: -# -# matlab_get_version_from_matlab_run( -# matlab_binary_path -# matlab_list_versions) -# -# ``matlab_binary_path`` -# the location of the `matlab` binary executable -# ``matlab_list_versions`` -# the version extracted from Matlab +#[=======================================================================[.rst: +.. command:: matlab_get_version_from_matlab_run + + This function runs Matlab program specified on arguments and extracts its + version. If the path provided for the Matlab installation points to an MCR + installation, the version is extracted from the installed files. + + :: + + matlab_get_version_from_matlab_run( + matlab_binary_path + matlab_list_versions) + + ``matlab_binary_path`` + the location of the `matlab` binary executable + ``matlab_list_versions`` + the version extracted from Matlab +#]=======================================================================] function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_versions) set(${matlab_list_versions} "" PARENT_SCOPE) @@ -754,76 +761,77 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve endfunction() -#.rst: -# .. command:: matlab_add_unit_test -# -# Adds a Matlab unit test to the test set of cmake/ctest. -# This command requires the component ``MAIN_PROGRAM`` and hence is not -# available for an MCR installation. -# -# The unit test uses the Matlab unittest framework (default, available -# starting Matlab 2013b+) except if the option ``NO_UNITTEST_FRAMEWORK`` -# is given. -# -# The function expects one Matlab test script file to be given. -# In the case ``NO_UNITTEST_FRAMEWORK`` is given, the unittest script file -# should contain the script to be run, plus an exit command with the exit -# value. This exit value will be passed to the ctest framework (0 success, -# non 0 failure). Additional arguments accepted by :command:`add_test` can be -# passed through ``TEST_ARGS`` (eg. ``CONFIGURATION <config> ...``). -# -# :: -# -# matlab_add_unit_test( -# NAME <name> -# UNITTEST_FILE matlab_file_containing_unittest.m -# [CUSTOM_TEST_COMMAND matlab_command_to_run_as_test] -# [UNITTEST_PRECOMMAND matlab_command_to_run] -# [TIMEOUT timeout] -# [ADDITIONAL_PATH path1 [path2 ...]] -# [MATLAB_ADDITIONAL_STARTUP_OPTIONS option1 [option2 ...]] -# [TEST_ARGS arg1 [arg2 ...]] -# [NO_UNITTEST_FRAMEWORK] -# ) -# -# The function arguments are: -# -# ``NAME`` -# name of the unittest in ctest. -# ``UNITTEST_FILE`` -# the matlab unittest file. Its path will be automatically -# added to the Matlab path. -# ``CUSTOM_TEST_COMMAND`` -# Matlab script command to run as the test. -# If this is not set, then the following is run: -# ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))`` -# where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension. -# ``UNITTEST_PRECOMMAND`` -# Matlab script command to be ran before the file -# containing the test (eg. GPU device initialisation based on CMake -# variables). -# ``TIMEOUT`` -# the test timeout in seconds. Defaults to 180 seconds as the -# Matlab unit test may hang. -# ``ADDITIONAL_PATH`` -# a list of paths to add to the Matlab path prior to -# running the unit test. -# ``MATLAB_ADDITIONAL_STARTUP_OPTIONS`` -# a list of additional option in order -# to run Matlab from the command line. -# ``-nosplash -nodesktop -nodisplay`` are always added. -# ``TEST_ARGS`` -# Additional options provided to the add_test command. These -# options are added to the default options (eg. "CONFIGURATIONS Release") -# ``NO_UNITTEST_FRAMEWORK`` -# when set, indicates that the test should not -# use the unittest framework of Matlab (available for versions >= R2013a). -# ``WORKING_DIRECTORY`` -# This will be the working directory for the test. If specified it will -# also be the output directory used for the log file of the test run. -# If not specified the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will -# be used as the working directory and the log location. -# +#[=======================================================================[.rst: +.. command:: matlab_add_unit_test + + Adds a Matlab unit test to the test set of cmake/ctest. + This command requires the component ``MAIN_PROGRAM`` and hence is not + available for an MCR installation. + + The unit test uses the Matlab unittest framework (default, available + starting Matlab 2013b+) except if the option ``NO_UNITTEST_FRAMEWORK`` + is given. + + The function expects one Matlab test script file to be given. + In the case ``NO_UNITTEST_FRAMEWORK`` is given, the unittest script file + should contain the script to be run, plus an exit command with the exit + value. This exit value will be passed to the ctest framework (0 success, + non 0 failure). Additional arguments accepted by :command:`add_test` can be + passed through ``TEST_ARGS`` (eg. ``CONFIGURATION <config> ...``). + + :: + + matlab_add_unit_test( + NAME <name> + UNITTEST_FILE matlab_file_containing_unittest.m + [CUSTOM_TEST_COMMAND matlab_command_to_run_as_test] + [UNITTEST_PRECOMMAND matlab_command_to_run] + [TIMEOUT timeout] + [ADDITIONAL_PATH path1 [path2 ...]] + [MATLAB_ADDITIONAL_STARTUP_OPTIONS option1 [option2 ...]] + [TEST_ARGS arg1 [arg2 ...]] + [NO_UNITTEST_FRAMEWORK] + ) + + The function arguments are: + + ``NAME`` + name of the unittest in ctest. + ``UNITTEST_FILE`` + the matlab unittest file. Its path will be automatically + added to the Matlab path. + ``CUSTOM_TEST_COMMAND`` + Matlab script command to run as the test. + If this is not set, then the following is run: + ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))`` + where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension. + ``UNITTEST_PRECOMMAND`` + Matlab script command to be ran before the file + containing the test (eg. GPU device initialisation based on CMake + variables). + ``TIMEOUT`` + the test timeout in seconds. Defaults to 180 seconds as the + Matlab unit test may hang. + ``ADDITIONAL_PATH`` + a list of paths to add to the Matlab path prior to + running the unit test. + ``MATLAB_ADDITIONAL_STARTUP_OPTIONS`` + a list of additional option in order + to run Matlab from the command line. + ``-nosplash -nodesktop -nodisplay`` are always added. + ``TEST_ARGS`` + Additional options provided to the add_test command. These + options are added to the default options (eg. "CONFIGURATIONS Release") + ``NO_UNITTEST_FRAMEWORK`` + when set, indicates that the test should not + use the unittest framework of Matlab (available for versions >= R2013a). + ``WORKING_DIRECTORY`` + This will be the working directory for the test. If specified it will + also be the output directory used for the log file of the test run. + If not specified the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will + be used as the working directory and the log location. + +#]=======================================================================] function(matlab_add_unit_test) if(NOT Matlab_MAIN_PROGRAM) @@ -862,58 +870,59 @@ function(matlab_add_unit_test) endfunction() -#.rst: -# .. command:: matlab_add_mex -# -# Adds a Matlab MEX target. -# This commands compiles the given sources with the current tool-chain in -# order to produce a MEX file. The final name of the produced output may be -# specified, as well as additional link libraries, and a documentation entry -# for the MEX file. Remaining arguments of the call are passed to the -# :command:`add_library` or :command:`add_executable` command. -# -# :: -# -# matlab_add_mex( -# NAME <name> -# [EXECUTABLE | MODULE | SHARED] -# SRC src1 [src2 ...] -# [OUTPUT_NAME output_name] -# [DOCUMENTATION file.txt] -# [LINK_TO target1 target2 ...] -# [...] -# ) -# -# ``NAME`` -# name of the target. -# ``SRC`` -# list of source files. -# ``LINK_TO`` -# a list of additional link dependencies. The target links to ``libmex`` -# by default. If ``Matlab_MX_LIBRARY`` is defined, it also -# links to ``libmx``. -# ``OUTPUT_NAME`` -# if given, overrides the default name. The default name is -# the name of the target without any prefix and -# with ``Matlab_MEX_EXTENSION`` suffix. -# ``DOCUMENTATION`` -# if given, the file ``file.txt`` will be considered as -# being the documentation file for the MEX file. This file is copied into -# the same folder without any processing, with the same name as the final -# mex file, and with extension `.m`. In that case, typing ``help <name>`` -# in Matlab prints the documentation contained in this file. -# ``MODULE`` or ``SHARED`` may be given to specify the type of library to be -# created. ``EXECUTABLE`` may be given to create an executable instead of -# a library. If no type is given explicitly, the type is ``SHARED``. -# -# The documentation file is not processed and should be in the following -# format: -# -# :: -# -# % This is the documentation -# function ret = mex_target_output_name(input1) -# +#[=======================================================================[.rst: +.. command:: matlab_add_mex + + Adds a Matlab MEX target. + This commands compiles the given sources with the current tool-chain in + order to produce a MEX file. The final name of the produced output may be + specified, as well as additional link libraries, and a documentation entry + for the MEX file. Remaining arguments of the call are passed to the + :command:`add_library` or :command:`add_executable` command. + + :: + + matlab_add_mex( + NAME <name> + [EXECUTABLE | MODULE | SHARED] + SRC src1 [src2 ...] + [OUTPUT_NAME output_name] + [DOCUMENTATION file.txt] + [LINK_TO target1 target2 ...] + [...] + ) + + ``NAME`` + name of the target. + ``SRC`` + list of source files. + ``LINK_TO`` + a list of additional link dependencies. The target links to ``libmex`` + by default. If ``Matlab_MX_LIBRARY`` is defined, it also + links to ``libmx``. + ``OUTPUT_NAME`` + if given, overrides the default name. The default name is + the name of the target without any prefix and + with ``Matlab_MEX_EXTENSION`` suffix. + ``DOCUMENTATION`` + if given, the file ``file.txt`` will be considered as + being the documentation file for the MEX file. This file is copied into + the same folder without any processing, with the same name as the final + mex file, and with extension `.m`. In that case, typing ``help <name>`` + in Matlab prints the documentation contained in this file. + ``MODULE`` or ``SHARED`` may be given to specify the type of library to be + created. ``EXECUTABLE`` may be given to create an executable instead of + a library. If no type is given explicitly, the type is ``SHARED``. + + The documentation file is not processed and should be in the following + format: + + :: + + % This is the documentation + function ret = mex_target_output_name(input1) + +#]=======================================================================] function(matlab_add_mex) if(NOT WIN32) diff --git a/Modules/FindMotif.cmake b/Modules/FindMotif.cmake index 7304d95..4f7080a 100644 --- a/Modules/FindMotif.cmake +++ b/Modules/FindMotif.cmake @@ -1,19 +1,20 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindMotif -# --------- -# -# Try to find Motif (or lesstif) -# -# Once done this will define: -# -# :: -# -# MOTIF_FOUND - system has MOTIF -# MOTIF_INCLUDE_DIR - include paths to use Motif -# MOTIF_LIBRARIES - Link these to use Motif +#[=======================================================================[.rst: +FindMotif +--------- + +Try to find Motif (or lesstif) + +Once done this will define: + +:: + + MOTIF_FOUND - system has MOTIF + MOTIF_INCLUDE_DIR - include paths to use Motif + MOTIF_LIBRARIES - Link these to use Motif +#]=======================================================================] set(MOTIF_FOUND 0) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 7521d51..dbd7961 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -1,21 +1,22 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindOpenAL -# ---------- -# -# -# -# Locate OpenAL This module defines OPENAL_LIBRARY OPENAL_FOUND, if -# false, do not try to link to OpenAL OPENAL_INCLUDE_DIR, where to find -# the headers -# -# $OPENALDIR is an environment variable that would correspond to the -# ./configure --prefix=$OPENALDIR used in building OpenAL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module. +#[=======================================================================[.rst: +FindOpenAL +---------- + + + +Locate OpenAL This module defines OPENAL_LIBRARY OPENAL_FOUND, if +false, do not try to link to OpenAL OPENAL_INCLUDE_DIR, where to find +the headers + +$OPENALDIR is an environment variable that would correspond to the +./configure --prefix=$OPENALDIR used in building OpenAL. + +Created by Eric Wing. This was influenced by the FindSDL.cmake +module. +#]=======================================================================] # This makes the presumption that you are include al.h like # #include "al.h" diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index fe162b4..79c0382 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -1,35 +1,36 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindOpenCL -# ---------- -# -# Try to find OpenCL -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if -# OpenCL has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables:: -# -# OpenCL_FOUND - True if OpenCL was found -# OpenCL_INCLUDE_DIRS - include directories for OpenCL -# OpenCL_LIBRARIES - link against this library to use OpenCL -# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) -# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation -# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation -# -# The module will also define two cache variables:: -# -# OpenCL_INCLUDE_DIR - the OpenCL include directory -# OpenCL_LIBRARY - the path to the OpenCL library -# +#[=======================================================================[.rst: +FindOpenCL +---------- + +Try to find OpenCL + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if +OpenCL has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables:: + + OpenCL_FOUND - True if OpenCL was found + OpenCL_INCLUDE_DIRS - include directories for OpenCL + OpenCL_LIBRARIES - link against this library to use OpenCL + OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) + OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation + OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation + +The module will also define two cache variables:: + + OpenCL_INCLUDE_DIR - the OpenCL include directory + OpenCL_LIBRARY - the path to the OpenCL library + +#]=======================================================================] function(_FIND_OPENCL_VERSION) include(CheckSymbolExists) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index df0bbc4..af45d8e 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -1,78 +1,79 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindOpenMP -# ---------- -# -# Finds OpenMP support -# -# This module can be used to detect OpenMP support in a compiler. If -# the compiler supports OpenMP, the flags required to compile with -# OpenMP support are returned in variables for the different languages. -# The variables may be empty if the compiler does not need a special -# flag to support OpenMP. -# -# Variables -# ^^^^^^^^^ -# -# The module exposes the components ``C``, ``CXX``, and ``Fortran``. -# Each of these controls the various languages to search OpenMP support for. -# -# Depending on the enabled components the following variables will be set: -# -# ``OpenMP_FOUND`` -# Variable indicating that OpenMP flags for all requested languages have been found. -# If no components are specified, this is true if OpenMP settings for all enabled languages -# were detected. -# ``OpenMP_VERSION`` -# Minimal version of the OpenMP standard detected among the requested languages, -# or all enabled languages if no components were specified. -# -# This module will set the following variables per language in your -# project, where ``<lang>`` is one of C, CXX, or Fortran: -# -# ``OpenMP_<lang>_FOUND`` -# Variable indicating if OpenMP support for ``<lang>`` was detected. -# ``OpenMP_<lang>_FLAGS`` -# OpenMP compiler flags for ``<lang>``, separated by spaces. -# -# For linking with OpenMP code written in ``<lang>``, the following -# variables are provided: -# -# ``OpenMP_<lang>_LIB_NAMES`` -# :ref:`;-list <CMake Language Lists>` of libraries for OpenMP programs for ``<lang>``. -# ``OpenMP_<libname>_LIBRARY`` -# Location of the individual libraries needed for OpenMP support in ``<lang>``. -# ``OpenMP_<lang>_LIBRARIES`` -# A list of libraries needed to link with OpenMP code written in ``<lang>``. -# -# Additionally, the module provides :prop_tgt:`IMPORTED` targets: -# -# ``OpenMP::OpenMP_<lang>`` -# Target for using OpenMP from ``<lang>``. -# -# Specifically for Fortran, the module sets the following variables: -# -# ``OpenMP_Fortran_HAVE_OMPLIB_HEADER`` -# Boolean indicating if OpenMP is accessible through ``omp_lib.h``. -# ``OpenMP_Fortran_HAVE_OMPLIB_MODULE`` -# Boolean indicating if OpenMP is accessible through the ``omp_lib`` Fortran module. -# -# The module will also try to provide the OpenMP version variables: -# -# ``OpenMP_<lang>_SPEC_DATE`` -# Date of the OpenMP specification implemented by the ``<lang>`` compiler. -# ``OpenMP_<lang>_VERSION_MAJOR`` -# Major version of OpenMP implemented by the ``<lang>`` compiler. -# ``OpenMP_<lang>_VERSION_MINOR`` -# Minor version of OpenMP implemented by the ``<lang>`` compiler. -# ``OpenMP_<lang>_VERSION`` -# OpenMP version implemented by the ``<lang>`` compiler. -# -# The specification date is formatted as given in the OpenMP standard: -# ``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of -# the OpenMP specification implemented by the ``<lang>`` compiler. +#[=======================================================================[.rst: +FindOpenMP +---------- + +Finds OpenMP support + +This module can be used to detect OpenMP support in a compiler. If +the compiler supports OpenMP, the flags required to compile with +OpenMP support are returned in variables for the different languages. +The variables may be empty if the compiler does not need a special +flag to support OpenMP. + +Variables +^^^^^^^^^ + +The module exposes the components ``C``, ``CXX``, and ``Fortran``. +Each of these controls the various languages to search OpenMP support for. + +Depending on the enabled components the following variables will be set: + +``OpenMP_FOUND`` + Variable indicating that OpenMP flags for all requested languages have been found. + If no components are specified, this is true if OpenMP settings for all enabled languages + were detected. +``OpenMP_VERSION`` + Minimal version of the OpenMP standard detected among the requested languages, + or all enabled languages if no components were specified. + +This module will set the following variables per language in your +project, where ``<lang>`` is one of C, CXX, or Fortran: + +``OpenMP_<lang>_FOUND`` + Variable indicating if OpenMP support for ``<lang>`` was detected. +``OpenMP_<lang>_FLAGS`` + OpenMP compiler flags for ``<lang>``, separated by spaces. + +For linking with OpenMP code written in ``<lang>``, the following +variables are provided: + +``OpenMP_<lang>_LIB_NAMES`` + :ref:`;-list <CMake Language Lists>` of libraries for OpenMP programs for ``<lang>``. +``OpenMP_<libname>_LIBRARY`` + Location of the individual libraries needed for OpenMP support in ``<lang>``. +``OpenMP_<lang>_LIBRARIES`` + A list of libraries needed to link with OpenMP code written in ``<lang>``. + +Additionally, the module provides :prop_tgt:`IMPORTED` targets: + +``OpenMP::OpenMP_<lang>`` + Target for using OpenMP from ``<lang>``. + +Specifically for Fortran, the module sets the following variables: + +``OpenMP_Fortran_HAVE_OMPLIB_HEADER`` + Boolean indicating if OpenMP is accessible through ``omp_lib.h``. +``OpenMP_Fortran_HAVE_OMPLIB_MODULE`` + Boolean indicating if OpenMP is accessible through the ``omp_lib`` Fortran module. + +The module will also try to provide the OpenMP version variables: + +``OpenMP_<lang>_SPEC_DATE`` + Date of the OpenMP specification implemented by the ``<lang>`` compiler. +``OpenMP_<lang>_VERSION_MAJOR`` + Major version of OpenMP implemented by the ``<lang>`` compiler. +``OpenMP_<lang>_VERSION_MINOR`` + Minor version of OpenMP implemented by the ``<lang>`` compiler. +``OpenMP_<lang>_VERSION`` + OpenMP version implemented by the ``<lang>`` compiler. + +The specification date is formatted as given in the OpenMP standard: +``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of +the OpenMP specification implemented by the ``<lang>`` compiler. +#]=======================================================================] cmake_policy(PUSH) cmake_policy(SET CMP0012 NEW) # if() recognizes numbers and booleans diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index d5cd8bc..5f947fe 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -1,53 +1,54 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindOpenSSL -# ----------- -# -# Find the OpenSSL encryption library. -# -# Optional COMPONENTS -# ^^^^^^^^^^^^^^^^^^^ -# -# This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both -# components have associated imported targets, as described below. -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``OpenSSL::SSL`` -# The OpenSSL ``ssl`` library, if found. -# ``OpenSSL::Crypto`` -# The OpenSSL ``crypto`` library, if found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``OPENSSL_FOUND`` -# System has the OpenSSL library. If no components are requested it only -# requires the crypto library. -# ``OPENSSL_INCLUDE_DIR`` -# The OpenSSL include directory. -# ``OPENSSL_CRYPTO_LIBRARY`` -# The OpenSSL crypto library. -# ``OPENSSL_SSL_LIBRARY`` -# The OpenSSL SSL library. -# ``OPENSSL_LIBRARIES`` -# All OpenSSL libraries. -# ``OPENSSL_VERSION`` -# This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``). -# -# Hints -# ^^^^^ -# -# Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation. -# Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries. -# Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib. +#[=======================================================================[.rst: +FindOpenSSL +----------- + +Find the OpenSSL encryption library. + +Optional COMPONENTS +^^^^^^^^^^^^^^^^^^^ + +This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both +components have associated imported targets, as described below. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``OpenSSL::SSL`` + The OpenSSL ``ssl`` library, if found. +``OpenSSL::Crypto`` + The OpenSSL ``crypto`` library, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``OPENSSL_FOUND`` + System has the OpenSSL library. If no components are requested it only + requires the crypto library. +``OPENSSL_INCLUDE_DIR`` + The OpenSSL include directory. +``OPENSSL_CRYPTO_LIBRARY`` + The OpenSSL crypto library. +``OPENSSL_SSL_LIBRARY`` + The OpenSSL SSL library. +``OPENSSL_LIBRARIES`` + All OpenSSL libraries. +``OPENSSL_VERSION`` + This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``). + +Hints +^^^^^ + +Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation. +Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries. +Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib. +#]=======================================================================] if (UNIX) find_package(PkgConfig QUIET) diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake index 425aa45..6f7d3c8 100644 --- a/Modules/FindOpenSceneGraph.cmake +++ b/Modules/FindOpenSceneGraph.cmake @@ -1,102 +1,103 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindOpenSceneGraph -# ------------------ -# -# Find OpenSceneGraph -# -# This module searches for the OpenSceneGraph core "osg" library as well -# as OpenThreads, and whatever additional COMPONENTS (nodekits) that you -# specify. -# -# :: -# -# See http://www.openscenegraph.org -# -# -# -# NOTE: To use this module effectively you must either require CMake >= -# 2.6.3 with cmake_minimum_required(VERSION 2.6.3) or download and place -# FindOpenThreads.cmake, Findosg_functions.cmake, Findosg.cmake, and -# Find<etc>.cmake files into your CMAKE_MODULE_PATH. -# -# ================================== -# -# This module accepts the following variables (note mixed case) -# -# :: -# -# OpenSceneGraph_DEBUG - Enable debugging output -# -# -# -# :: -# -# OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced -# automatically -# -# -# -# The following environment variables are also respected for finding the -# OSG and it's various components. CMAKE_PREFIX_PATH can also be used -# for this (see find_library() CMake documentation). -# -# ``<MODULE>_DIR`` -# (where MODULE is of the form "OSGVOLUME" and there is a FindosgVolume.cmake file) -# ``OSG_DIR`` -# .. -# ``OSGDIR`` -# .. -# ``OSG_ROOT`` -# .. -# -# -# [CMake 2.8.10]: The CMake variable OSG_DIR can now be used as well to -# influence detection, instead of needing to specify an environment -# variable. -# -# This module defines the following output variables: -# -# :: -# -# OPENSCENEGRAPH_FOUND - Was the OSG and all of the specified components found? -# -# -# -# :: -# -# OPENSCENEGRAPH_VERSION - The version of the OSG which was found -# -# -# -# :: -# -# OPENSCENEGRAPH_INCLUDE_DIRS - Where to find the headers -# -# -# -# :: -# -# OPENSCENEGRAPH_LIBRARIES - The OSG libraries -# -# -# -# ================================== Example Usage: -# -# :: -# -# find_package(OpenSceneGraph 2.0.0 REQUIRED osgDB osgUtil) -# # libOpenThreads & libosg automatically searched -# include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}) -# -# -# -# :: -# -# add_executable(foo foo.cc) -# target_link_libraries(foo ${OPENSCENEGRAPH_LIBRARIES}) +#[=======================================================================[.rst: +FindOpenSceneGraph +------------------ + +Find OpenSceneGraph + +This module searches for the OpenSceneGraph core "osg" library as well +as OpenThreads, and whatever additional COMPONENTS (nodekits) that you +specify. + +:: + + See http://www.openscenegraph.org + + + +NOTE: To use this module effectively you must either require CMake >= +2.6.3 with cmake_minimum_required(VERSION 2.6.3) or download and place +FindOpenThreads.cmake, Findosg_functions.cmake, Findosg.cmake, and +Find<etc>.cmake files into your CMAKE_MODULE_PATH. + +================================== + +This module accepts the following variables (note mixed case) + +:: + + OpenSceneGraph_DEBUG - Enable debugging output + + + +:: + + OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced + automatically + + + +The following environment variables are also respected for finding the +OSG and it's various components. CMAKE_PREFIX_PATH can also be used +for this (see find_library() CMake documentation). + +``<MODULE>_DIR`` + (where MODULE is of the form "OSGVOLUME" and there is a FindosgVolume.cmake file) +``OSG_DIR`` + .. +``OSGDIR`` + .. +``OSG_ROOT`` + .. + + +[CMake 2.8.10]: The CMake variable OSG_DIR can now be used as well to +influence detection, instead of needing to specify an environment +variable. + +This module defines the following output variables: + +:: + + OPENSCENEGRAPH_FOUND - Was the OSG and all of the specified components found? + + + +:: + + OPENSCENEGRAPH_VERSION - The version of the OSG which was found + + + +:: + + OPENSCENEGRAPH_INCLUDE_DIRS - Where to find the headers + + + +:: + + OPENSCENEGRAPH_LIBRARIES - The OSG libraries + + + +================================== Example Usage: + +:: + + find_package(OpenSceneGraph 2.0.0 REQUIRED osgDB osgUtil) + # libOpenThreads & libosg automatically searched + include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}) + + + +:: + + add_executable(foo foo.cc) + target_link_libraries(foo ${OPENSCENEGRAPH_LIBRARIES}) +#]=======================================================================] # # Naming convention: diff --git a/Modules/FindOpenThreads.cmake b/Modules/FindOpenThreads.cmake index 91545e0..bc45eea 100644 --- a/Modules/FindOpenThreads.cmake +++ b/Modules/FindOpenThreads.cmake @@ -1,30 +1,31 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindOpenThreads -# --------------- -# -# -# -# OpenThreads is a C++ based threading library. Its largest userbase -# seems to OpenSceneGraph so you might notice I accept OSGDIR as an -# environment path. I consider this part of the Findosg* suite used to -# find OpenSceneGraph components. Each component is separate and you -# must opt in to each module. -# -# Locate OpenThreads This module defines OPENTHREADS_LIBRARY -# OPENTHREADS_FOUND, if false, do not try to link to OpenThreads -# OPENTHREADS_INCLUDE_DIR, where to find the headers -# -# $OPENTHREADS_DIR is an environment variable that would correspond to -# the ./configure --prefix=$OPENTHREADS_DIR used in building osg. -# -# [CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now -# be used as well to influence detection, instead of needing to specify -# an environment variable. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindOpenThreads +--------------- + + + +OpenThreads is a C++ based threading library. Its largest userbase +seems to OpenSceneGraph so you might notice I accept OSGDIR as an +environment path. I consider this part of the Findosg* suite used to +find OpenSceneGraph components. Each component is separate and you +must opt in to each module. + +Locate OpenThreads This module defines OPENTHREADS_LIBRARY +OPENTHREADS_FOUND, if false, do not try to link to OpenThreads +OPENTHREADS_INCLUDE_DIR, where to find the headers + +$OPENTHREADS_DIR is an environment variable that would correspond to +the ./configure --prefix=$OPENTHREADS_DIR used in building osg. + +[CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now +be used as well to influence detection, instead of needing to specify +an environment variable. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <OpenThreads/Thread> diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake index 426453b..34b4adb 100644 --- a/Modules/FindPHP4.cmake +++ b/Modules/FindPHP4.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPHP4 -# -------- -# -# Find PHP4 -# -# This module finds if PHP4 is installed and determines where the -# include files and libraries are. It also determines what the name of -# the library is. This code sets the following variables: -# -# :: -# -# PHP4_INCLUDE_PATH = path to where php.h can be found -# PHP4_EXECUTABLE = full path to the php4 binary +#[=======================================================================[.rst: +FindPHP4 +-------- + +Find PHP4 + +This module finds if PHP4 is installed and determines where the +include files and libraries are. It also determines what the name of +the library is. This code sets the following variables: + +:: + + PHP4_INCLUDE_PATH = path to where php.h can be found + PHP4_EXECUTABLE = full path to the php4 binary +#]=======================================================================] set(PHP4_POSSIBLE_INCLUDE_PATHS /usr/include/php4 diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index 936f01f..2208b48 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -1,49 +1,50 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPNG -# ------- -# -# Find libpng, the official reference library for the PNG image format. -# -# Imported targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` target: -# -# ``PNG::PNG`` -# The libpng library, if found. -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``PNG_INCLUDE_DIRS`` -# where to find png.h, etc. -# ``PNG_LIBRARIES`` -# the libraries to link against to use PNG. -# ``PNG_DEFINITIONS`` -# You should add_definitions(${PNG_DEFINITIONS}) before compiling code -# that includes png library files. -# ``PNG_FOUND`` -# If false, do not try to use PNG. -# ``PNG_VERSION_STRING`` -# the version of the PNG library found (since CMake 2.8.8) -# -# Obsolete variables -# ^^^^^^^^^^^^^^^^^^ -# -# The following variables may also be set, for backwards compatibility: -# -# ``PNG_LIBRARY`` -# where to find the PNG library. -# ``PNG_INCLUDE_DIR`` -# where to find the PNG headers (same as PNG_INCLUDE_DIRS) -# -# Since PNG depends on the ZLib compression library, none of the above -# will be defined unless ZLib can be found. +#[=======================================================================[.rst: +FindPNG +------- + +Find libpng, the official reference library for the PNG image format. + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``PNG::PNG`` + The libpng library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``PNG_INCLUDE_DIRS`` + where to find png.h, etc. +``PNG_LIBRARIES`` + the libraries to link against to use PNG. +``PNG_DEFINITIONS`` + You should add_definitions(${PNG_DEFINITIONS}) before compiling code + that includes png library files. +``PNG_FOUND`` + If false, do not try to use PNG. +``PNG_VERSION_STRING`` + the version of the PNG library found (since CMake 2.8.8) + +Obsolete variables +^^^^^^^^^^^^^^^^^^ + +The following variables may also be set, for backwards compatibility: + +``PNG_LIBRARY`` + where to find the PNG library. +``PNG_INCLUDE_DIR`` + where to find the PNG headers (same as PNG_INCLUDE_DIRS) + +Since PNG depends on the ZLib compression library, none of the above +will be defined unless ZLib can be found. +#]=======================================================================] if(PNG_FIND_QUIETLY) set(_FIND_ZLIB_ARG QUIET) diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index 6821cee..1cdfde8 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -1,33 +1,34 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPackageMessage -# ------------------ -# -# -# -# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details") -# -# This macro is intended to be used in FindXXX.cmake modules files. It -# will print a message once for each unique find result. This is useful -# for telling the user where a package was found. The first argument -# specifies the name (XXX) of the package. The second argument -# specifies the message to display. The third argument lists details -# about the find result so that if they change the message will be -# displayed again. The macro also obeys the QUIET argument to the -# find_package command. -# -# Example: -# -# :: -# -# if(X11_FOUND) -# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" -# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") -# else() -# ... -# endif() +#[=======================================================================[.rst: +FindPackageMessage +------------------ + + + +FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details") + +This macro is intended to be used in FindXXX.cmake modules files. It +will print a message once for each unique find result. This is useful +for telling the user where a package was found. The first argument +specifies the name (XXX) of the package. The second argument +specifies the message to display. The third argument lists details +about the find result so that if they change the message will be +displayed again. The macro also obeys the QUIET argument to the +find_package command. + +Example: + +:: + + if(X11_FOUND) + FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" + "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") + else() + ... + endif() +#]=======================================================================] function(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. diff --git a/Modules/FindPatch.cmake b/Modules/FindPatch.cmake index 3ebcae9..4998839 100644 --- a/Modules/FindPatch.cmake +++ b/Modules/FindPatch.cmake @@ -1,30 +1,31 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPatch -# --------- -# -# The module defines the following variables: -# -# ``Patch_EXECUTABLE`` -# Path to patch command-line executable. -# ``Patch_FOUND`` -# True if the patch command-line executable was found. -# -# The following :prop_tgt:`IMPORTED` targets are also defined: -# -# ``Patch::patch`` -# The command-line executable. -# -# Example usage: -# -# .. code-block:: cmake -# -# find_package(Patch) -# if(Patch_FOUND) -# message("Patch found: ${Patch_EXECUTABLE}") -# endif() +#[=======================================================================[.rst: +FindPatch +--------- + +The module defines the following variables: + +``Patch_EXECUTABLE`` + Path to patch command-line executable. +``Patch_FOUND`` + True if the patch command-line executable was found. + +The following :prop_tgt:`IMPORTED` targets are also defined: + +``Patch::patch`` + The command-line executable. + +Example usage: + +.. code-block:: cmake + + find_package(Patch) + if(Patch_FOUND) + message("Patch found: ${Patch_EXECUTABLE}") + endif() +#]=======================================================================] set(_doc "Patch command line executable") set(_patch_path ) diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index c38527c..fd120bf 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -1,19 +1,20 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPerl -# -------- -# -# Find perl -# -# this module looks for Perl -# -# :: -# -# PERL_EXECUTABLE - the full path to perl -# PERL_FOUND - If false, don't attempt to use perl. -# PERL_VERSION_STRING - version of perl found (since CMake 2.8.8) +#[=======================================================================[.rst: +FindPerl +-------- + +Find perl + +this module looks for Perl + +:: + + PERL_EXECUTABLE - the full path to perl + PERL_FOUND - If false, don't attempt to use perl. + PERL_VERSION_STRING - version of perl found (since CMake 2.8.8) +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index 0b902e7..7e27f31 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -1,47 +1,48 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPerlLibs -# ------------ -# -# Find Perl libraries -# -# This module finds if PERL is installed and determines where the -# include files and libraries are. It also determines what the name of -# the library is. This code sets the following variables: -# -# :: -# -# PERLLIBS_FOUND = True if perl.h & libperl were found -# PERL_INCLUDE_PATH = path to where perl.h is found -# PERL_LIBRARY = path to libperl -# PERL_EXECUTABLE = full path to the perl binary -# -# -# -# The minimum required version of Perl can be specified using the -# standard syntax, e.g. find_package(PerlLibs 6.0) -# -# :: -# -# The following variables are also available if needed -# (introduced after CMake 2.6.4) -# -# -# -# :: -# -# PERL_SITESEARCH = path to the sitesearch install dir (-V:installsitesearch) -# PERL_SITEARCH = path to the sitelib install directory (-V:installsitearch) -# PERL_SITELIB = path to the sitelib install directory (-V:installsitelib) -# PERL_VENDORARCH = path to the vendor arch install directory (-V:installvendorarch) -# PERL_VENDORLIB = path to the vendor lib install directory (-V:installvendorlib) -# PERL_ARCHLIB = path to the core arch lib install directory (-V:archlib) -# PERL_PRIVLIB = path to the core priv lib install directory (-V:privlib) -# PERL_UPDATE_ARCHLIB = path to the update arch lib install directory (-V:installarchlib) -# PERL_UPDATE_PRIVLIB = path to the update priv lib install directory (-V:installprivlib) -# PERL_EXTRA_C_FLAGS = Compilation flags used to build perl +#[=======================================================================[.rst: +FindPerlLibs +------------ + +Find Perl libraries + +This module finds if PERL is installed and determines where the +include files and libraries are. It also determines what the name of +the library is. This code sets the following variables: + +:: + + PERLLIBS_FOUND = True if perl.h & libperl were found + PERL_INCLUDE_PATH = path to where perl.h is found + PERL_LIBRARY = path to libperl + PERL_EXECUTABLE = full path to the perl binary + + + +The minimum required version of Perl can be specified using the +standard syntax, e.g. find_package(PerlLibs 6.0) + +:: + + The following variables are also available if needed + (introduced after CMake 2.6.4) + + + +:: + + PERL_SITESEARCH = path to the sitesearch install dir (-V:installsitesearch) + PERL_SITEARCH = path to the sitelib install directory (-V:installsitearch) + PERL_SITELIB = path to the sitelib install directory (-V:installsitelib) + PERL_VENDORARCH = path to the vendor arch install directory (-V:installvendorarch) + PERL_VENDORLIB = path to the vendor lib install directory (-V:installvendorlib) + PERL_ARCHLIB = path to the core arch lib install directory (-V:archlib) + PERL_PRIVLIB = path to the core priv lib install directory (-V:privlib) + PERL_UPDATE_ARCHLIB = path to the update arch lib install directory (-V:installarchlib) + PERL_UPDATE_PRIVLIB = path to the update priv lib install directory (-V:installprivlib) + PERL_EXTRA_C_FLAGS = Compilation flags used to build perl +#]=======================================================================] # find the perl executable include(${CMAKE_CURRENT_LIST_DIR}/FindPerl.cmake) diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake index cfe9b0f..0366f77 100644 --- a/Modules/FindPhysFS.cmake +++ b/Modules/FindPhysFS.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPhysFS -# ---------- -# -# -# -# Locate PhysFS library This module defines PHYSFS_LIBRARY, the name of -# the library to link against PHYSFS_FOUND, if false, do not try to link -# to PHYSFS PHYSFS_INCLUDE_DIR, where to find physfs.h -# -# $PHYSFSDIR is an environment variable that would correspond to the -# ./configure --prefix=$PHYSFSDIR used in building PHYSFS. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindPhysFS +---------- + + + +Locate PhysFS library This module defines PHYSFS_LIBRARY, the name of +the library to link against PHYSFS_FOUND, if false, do not try to link +to PHYSFS PHYSFS_INCLUDE_DIR, where to find physfs.h + +$PHYSFSDIR is an environment variable that would correspond to the +./configure --prefix=$PHYSFSDIR used in building PHYSFS. + +Created by Eric Wing. +#]=======================================================================] find_path(PHYSFS_INCLUDE_DIR physfs.h HINTS diff --git a/Modules/FindPike.cmake b/Modules/FindPike.cmake index ec71c94..b78db2a 100644 --- a/Modules/FindPike.cmake +++ b/Modules/FindPike.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPike -# -------- -# -# Find Pike -# -# This module finds if PIKE is installed and determines where the -# include files and libraries are. It also determines what the name of -# the library is. This code sets the following variables: -# -# :: -# -# PIKE_INCLUDE_PATH = path to where program.h is found -# PIKE_EXECUTABLE = full path to the pike binary +#[=======================================================================[.rst: +FindPike +-------- + +Find Pike + +This module finds if PIKE is installed and determines where the +include files and libraries are. It also determines what the name of +the library is. This code sets the following variables: + +:: + + PIKE_INCLUDE_PATH = path to where program.h is found + PIKE_EXECUTABLE = full path to the pike binary +#]=======================================================================] find_path(PIKE_INCLUDE_PATH program.h ${PIKE_POSSIBLE_INCLUDE_PATHS} diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 3f6fa6c..cb6265a 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPostgreSQL -# -------------- -# -# Find the PostgreSQL installation. -# -# This module defines -# -# :: -# -# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking -# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers -# PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries -# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8) +#[=======================================================================[.rst: +FindPostgreSQL +-------------- + +Find the PostgreSQL installation. + +This module defines + +:: + + PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking + PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers + PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries + PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8) +#]=======================================================================] # ---------------------------------------------------------------------------- # History: diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake index 500c8ed..fba0494 100644 --- a/Modules/FindProducer.cmake +++ b/Modules/FindProducer.cmake @@ -1,35 +1,36 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindProducer -# ------------ -# -# -# -# Though Producer isn't directly part of OpenSceneGraph, its primary -# user is OSG so I consider this part of the Findosg* suite used to find -# OpenSceneGraph components. You'll notice that I accept OSGDIR as an -# environment path. -# -# Each component is separate and you must opt in to each module. You -# must also opt into OpenGL (and OpenThreads?) as these modules won't do -# it for you. This is to allow you control over your own system piece -# by piece in case you need to opt out of certain components or change -# the Find behavior for a particular module (perhaps because the default -# FindOpenGL.cmake module doesn't work with your system as an example). -# If you want to use a more convenient module that includes everything, -# use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake -# modules. -# -# Locate Producer This module defines PRODUCER_LIBRARY PRODUCER_FOUND, -# if false, do not try to link to Producer PRODUCER_INCLUDE_DIR, where -# to find the headers -# -# $PRODUCER_DIR is an environment variable that would correspond to the -# ./configure --prefix=$PRODUCER_DIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindProducer +------------ + + + +Though Producer isn't directly part of OpenSceneGraph, its primary +user is OSG so I consider this part of the Findosg* suite used to find +OpenSceneGraph components. You'll notice that I accept OSGDIR as an +environment path. + +Each component is separate and you must opt in to each module. You +must also opt into OpenGL (and OpenThreads?) as these modules won't do +it for you. This is to allow you control over your own system piece +by piece in case you need to opt out of certain components or change +the Find behavior for a particular module (perhaps because the default +FindOpenGL.cmake module doesn't work with your system as an example). +If you want to use a more convenient module that includes everything, +use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake +modules. + +Locate Producer This module defines PRODUCER_LIBRARY PRODUCER_FOUND, +if false, do not try to link to Producer PRODUCER_INCLUDE_DIR, where +to find the headers + +$PRODUCER_DIR is an environment variable that would correspond to the +./configure --prefix=$PRODUCER_DIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <Producer/CameraGroup> diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index d6d1ec6..1fc2167 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -1,123 +1,124 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindProtobuf -# ------------ -# -# Locate and configure the Google Protocol Buffers library. -# -# The following variables can be set and are optional: -# -# ``Protobuf_SRC_ROOT_FOLDER`` -# When compiling with MSVC, if this cache variable is set -# the protobuf-default VS project build locations -# (vsprojects/Debug and vsprojects/Release -# or vsprojects/x64/Debug and vsprojects/x64/Release) -# will be searched for libraries and binaries. -# ``Protobuf_IMPORT_DIRS`` -# List of additional directories to be searched for -# imported .proto files. -# ``Protobuf_DEBUG`` -# Show debug messages. -# ``Protobuf_USE_STATIC_LIBS`` -# Set to ON to force the use of the static libraries. -# Default is OFF. -# -# Defines the following variables: -# -# ``Protobuf_FOUND`` -# Found the Google Protocol Buffers library -# (libprotobuf & header files) -# ``Protobuf_VERSION`` -# Version of package found. -# ``Protobuf_INCLUDE_DIRS`` -# Include directories for Google Protocol Buffers -# ``Protobuf_LIBRARIES`` -# The protobuf libraries -# ``Protobuf_PROTOC_LIBRARIES`` -# The protoc libraries -# ``Protobuf_LITE_LIBRARIES`` -# The protobuf-lite libraries -# -# The following :prop_tgt:`IMPORTED` targets are also defined: -# -# ``protobuf::libprotobuf`` -# The protobuf library. -# ``protobuf::libprotobuf-lite`` -# The protobuf lite library. -# ``protobuf::libprotoc`` -# The protoc library. -# ``protobuf::protoc`` -# The protoc compiler. -# -# The following cache variables are also available to set or use: -# -# ``Protobuf_LIBRARY`` -# The protobuf library -# ``Protobuf_PROTOC_LIBRARY`` -# The protoc library -# ``Protobuf_INCLUDE_DIR`` -# The include directory for protocol buffers -# ``Protobuf_PROTOC_EXECUTABLE`` -# The protoc compiler -# ``Protobuf_LIBRARY_DEBUG`` -# The protobuf library (debug) -# ``Protobuf_PROTOC_LIBRARY_DEBUG`` -# The protoc library (debug) -# ``Protobuf_LITE_LIBRARY`` -# The protobuf lite library -# ``Protobuf_LITE_LIBRARY_DEBUG`` -# The protobuf lite library (debug) -# -# Example: -# -# .. code-block:: cmake -# -# find_package(Protobuf REQUIRED) -# include_directories(${Protobuf_INCLUDE_DIRS}) -# include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto) -# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS EXPORT_MACRO DLL_EXPORT foo.proto) -# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS DESCRIPTORS PROTO_DESCS foo.proto) -# protobuf_generate_python(PROTO_PY foo.proto) -# add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS}) -# target_link_libraries(bar ${Protobuf_LIBRARIES}) -# -# .. note:: -# The ``protobuf_generate_cpp`` and ``protobuf_generate_python`` -# functions and :command:`add_executable` or :command:`add_library` -# calls only work properly within the same directory. -# -# .. command:: protobuf_generate_cpp -# -# Add custom commands to process ``.proto`` files to C++:: -# -# protobuf_generate_cpp (<SRCS> <HDRS> -# [DESCRIPTORS <DESC>] [EXPORT_MACRO <MACRO>] [<ARGN>...]) -# -# ``SRCS`` -# Variable to define with autogenerated source files -# ``HDRS`` -# Variable to define with autogenerated header files -# ``DESCRIPTORS`` -# Variable to define with autogenerated descriptor files, if requested. -# ``EXPORT_MACRO`` -# is a macro which should expand to ``__declspec(dllexport)`` or -# ``__declspec(dllimport)`` depending on what is being compiled. -# ``ARGN`` -# ``.proto`` files -# -# .. command:: protobuf_generate_python -# -# Add custom commands to process ``.proto`` files to Python:: -# -# protobuf_generate_python (<PY> [<ARGN>...]) -# -# ``PY`` -# Variable to define with autogenerated Python files -# ``ARGN`` -# ``.proto`` filess +#[=======================================================================[.rst: +FindProtobuf +------------ + +Locate and configure the Google Protocol Buffers library. + +The following variables can be set and are optional: + +``Protobuf_SRC_ROOT_FOLDER`` + When compiling with MSVC, if this cache variable is set + the protobuf-default VS project build locations + (vsprojects/Debug and vsprojects/Release + or vsprojects/x64/Debug and vsprojects/x64/Release) + will be searched for libraries and binaries. +``Protobuf_IMPORT_DIRS`` + List of additional directories to be searched for + imported .proto files. +``Protobuf_DEBUG`` + Show debug messages. +``Protobuf_USE_STATIC_LIBS`` + Set to ON to force the use of the static libraries. + Default is OFF. + +Defines the following variables: + +``Protobuf_FOUND`` + Found the Google Protocol Buffers library + (libprotobuf & header files) +``Protobuf_VERSION`` + Version of package found. +``Protobuf_INCLUDE_DIRS`` + Include directories for Google Protocol Buffers +``Protobuf_LIBRARIES`` + The protobuf libraries +``Protobuf_PROTOC_LIBRARIES`` + The protoc libraries +``Protobuf_LITE_LIBRARIES`` + The protobuf-lite libraries + +The following :prop_tgt:`IMPORTED` targets are also defined: + +``protobuf::libprotobuf`` + The protobuf library. +``protobuf::libprotobuf-lite`` + The protobuf lite library. +``protobuf::libprotoc`` + The protoc library. +``protobuf::protoc`` + The protoc compiler. + +The following cache variables are also available to set or use: + +``Protobuf_LIBRARY`` + The protobuf library +``Protobuf_PROTOC_LIBRARY`` + The protoc library +``Protobuf_INCLUDE_DIR`` + The include directory for protocol buffers +``Protobuf_PROTOC_EXECUTABLE`` + The protoc compiler +``Protobuf_LIBRARY_DEBUG`` + The protobuf library (debug) +``Protobuf_PROTOC_LIBRARY_DEBUG`` + The protoc library (debug) +``Protobuf_LITE_LIBRARY`` + The protobuf lite library +``Protobuf_LITE_LIBRARY_DEBUG`` + The protobuf lite library (debug) + +Example: + +.. code-block:: cmake + + find_package(Protobuf REQUIRED) + include_directories(${Protobuf_INCLUDE_DIRS}) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto) + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS EXPORT_MACRO DLL_EXPORT foo.proto) + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS DESCRIPTORS PROTO_DESCS foo.proto) + protobuf_generate_python(PROTO_PY foo.proto) + add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS}) + target_link_libraries(bar ${Protobuf_LIBRARIES}) + +.. note:: + The ``protobuf_generate_cpp`` and ``protobuf_generate_python`` + functions and :command:`add_executable` or :command:`add_library` + calls only work properly within the same directory. + +.. command:: protobuf_generate_cpp + + Add custom commands to process ``.proto`` files to C++:: + + protobuf_generate_cpp (<SRCS> <HDRS> + [DESCRIPTORS <DESC>] [EXPORT_MACRO <MACRO>] [<ARGN>...]) + + ``SRCS`` + Variable to define with autogenerated source files + ``HDRS`` + Variable to define with autogenerated header files + ``DESCRIPTORS`` + Variable to define with autogenerated descriptor files, if requested. + ``EXPORT_MACRO`` + is a macro which should expand to ``__declspec(dllexport)`` or + ``__declspec(dllimport)`` depending on what is being compiled. + ``ARGN`` + ``.proto`` files + +.. command:: protobuf_generate_python + + Add custom commands to process ``.proto`` files to Python:: + + protobuf_generate_python (<PY> [<ARGN>...]) + + ``PY`` + Variable to define with autogenerated Python files + ``ARGN`` + ``.proto`` filess +#]=======================================================================] function(protobuf_generate) include(CMakeParseArguments) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 370e5e42..d1f7b31 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -1,44 +1,45 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPythonInterp -# ---------------- -# -# Find python interpreter -# -# .. deprecated:: 3.12 -# -# Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. -# -# This module finds if Python interpreter is installed and determines -# where the executables are. This code sets the following variables: -# -# :: -# -# PYTHONINTERP_FOUND - Was the Python executable found -# PYTHON_EXECUTABLE - path to the Python interpreter -# -# -# -# :: -# -# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 -# PYTHON_VERSION_MAJOR - Python major version found e.g. 2 -# PYTHON_VERSION_MINOR - Python minor version found e.g. 5 -# PYTHON_VERSION_PATCH - Python patch version found e.g. 2 -# -# -# -# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list -# of version numbers that should be taken into account when searching -# for Python. You need to set this variable before calling -# find_package(PythonInterp). -# -# If calling both ``find_package(PythonInterp)`` and -# ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to -# get the currently active Python version by default with a consistent version -# of PYTHON_LIBRARIES. +#[=======================================================================[.rst: +FindPythonInterp +---------------- + +.. deprecated:: 3.12 + + Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. + +Find python interpreter + +This module finds if Python interpreter is installed and determines +where the executables are. This code sets the following variables: + +:: + + PYTHONINTERP_FOUND - Was the Python executable found + PYTHON_EXECUTABLE - path to the Python interpreter + + + +:: + + PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 + PYTHON_VERSION_MAJOR - Python major version found e.g. 2 + PYTHON_VERSION_MINOR - Python minor version found e.g. 5 + PYTHON_VERSION_PATCH - Python patch version found e.g. 2 + + + +The Python_ADDITIONAL_VERSIONS variable can be used to specify a list +of version numbers that should be taken into account when searching +for Python. You need to set this variable before calling +find_package(PythonInterp). + +If calling both ``find_package(PythonInterp)`` and +``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to +get the currently active Python version by default with a consistent version +of PYTHON_LIBRARIES. +#]=======================================================================] unset(_Python_NAMES) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 6da87a8..1d62ac4 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -1,48 +1,49 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindPythonLibs -# -------------- -# -# Find python libraries -# -# .. deprecated:: 3.12 -# -# Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. -# -# This module finds if Python is installed and determines where the -# include files and libraries are. It also determines what the name of -# the library is. This code sets the following variables: -# -# :: -# -# PYTHONLIBS_FOUND - have the Python libs been found -# PYTHON_LIBRARIES - path to the python library -# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) -# PYTHON_INCLUDE_DIRS - path to where Python.h is found -# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) -# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) -# -# -# -# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list -# of version numbers that should be taken into account when searching -# for Python. You need to set this variable before calling -# find_package(PythonLibs). -# -# If you'd like to specify the installation of Python to use, you should -# modify the following cache variables: -# -# :: -# -# PYTHON_LIBRARY - path to the python library -# PYTHON_INCLUDE_DIR - path to where Python.h is found -# -# If calling both ``find_package(PythonInterp)`` and -# ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to -# get the currently active Python version by default with a consistent version -# of PYTHON_LIBRARIES. +#[=======================================================================[.rst: +FindPythonLibs +-------------- + +.. deprecated:: 3.12 + + Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead. + +Find python libraries + +This module finds if Python is installed and determines where the +include files and libraries are. It also determines what the name of +the library is. This code sets the following variables: + +:: + + PYTHONLIBS_FOUND - have the Python libs been found + PYTHON_LIBRARIES - path to the python library + PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) + PYTHON_INCLUDE_DIRS - path to where Python.h is found + PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) + PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) + + + +The Python_ADDITIONAL_VERSIONS variable can be used to specify a list +of version numbers that should be taken into account when searching +for Python. You need to set this variable before calling +find_package(PythonLibs). + +If you'd like to specify the installation of Python to use, you should +modify the following cache variables: + +:: + + PYTHON_LIBRARY - path to the python library + PYTHON_INCLUDE_DIR - path to where Python.h is found + +If calling both ``find_package(PythonInterp)`` and +``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to +get the currently active Python version by default with a consistent version +of PYTHON_LIBRARIES. +#]=======================================================================] # Use the executable's path as a hint set(_Python_LIBRARY_PATH_HINT) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 4dff7c3..083d6a6 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindQt -# ------ -# -# Searches for all installed versions of Qt3 or Qt4. -# -# This module cannot handle Qt5 or any later versions. -# For those, see :manual:`cmake-qt(7)`. -# -# This module should only be used if your project can work with multiple -# versions of Qt. If not, you should just directly use FindQt4 or -# FindQt3. If multiple versions of Qt are found on the machine, then -# The user must set the option DESIRED_QT_VERSION to the version they -# want to use. If only one version of qt is found on the machine, then -# the DESIRED_QT_VERSION is set to that version and the matching FindQt3 -# or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION, -# then the FindQt3 or FindQt4 module is included. -# -# :: -# -# QT_REQUIRED if this is set to TRUE then if CMake can -# not find Qt4 or Qt3 an error is raised -# and a message is sent to the user. -# -# -# -# :: -# -# DESIRED_QT_VERSION OPTION is created -# QT4_INSTALLED is set to TRUE if qt4 is found. -# QT3_INSTALLED is set to TRUE if qt3 is found. +#[=======================================================================[.rst: +FindQt +------ + +Searches for all installed versions of Qt3 or Qt4. + +This module cannot handle Qt5 or any later versions. +For those, see :manual:`cmake-qt(7)`. + +This module should only be used if your project can work with multiple +versions of Qt. If not, you should just directly use FindQt4 or +FindQt3. If multiple versions of Qt are found on the machine, then +The user must set the option DESIRED_QT_VERSION to the version they +want to use. If only one version of qt is found on the machine, then +the DESIRED_QT_VERSION is set to that version and the matching FindQt3 +or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION, +then the FindQt3 or FindQt4 module is included. + +:: + + QT_REQUIRED if this is set to TRUE then if CMake can + not find Qt4 or Qt3 an error is raised + and a message is sent to the user. + + + +:: + + DESIRED_QT_VERSION OPTION is created + QT4_INSTALLED is set to TRUE if qt4 is found. + QT3_INSTALLED is set to TRUE if qt3 is found. +#]=======================================================================] # look for signs of qt3 installations file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake) diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index a034210..4a8e28b 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindQt3 -# ------- -# -# Locate Qt include paths and libraries -# -# This module defines: -# -# :: -# -# QT_INCLUDE_DIR - where to find qt.h, etc. -# QT_LIBRARIES - the libraries to link against to use Qt. -# QT_DEFINITIONS - definitions to use when -# compiling code that uses Qt. -# QT_FOUND - If false, don't try to use Qt. -# QT_VERSION_STRING - the version of Qt found -# -# -# -# If you need the multithreaded version of Qt, set QT_MT_REQUIRED to -# TRUE -# -# Also defined, but not for general use are: -# -# :: -# -# QT_MOC_EXECUTABLE, where to find the moc tool. -# QT_UIC_EXECUTABLE, where to find the uic tool. -# QT_QT_LIBRARY, where to find the Qt library. -# QT_QTMAIN_LIBRARY, where to find the qtmain -# library. This is only required by Qt3 on Windows. +#[=======================================================================[.rst: +FindQt3 +------- + +Locate Qt include paths and libraries + +This module defines: + +:: + + QT_INCLUDE_DIR - where to find qt.h, etc. + QT_LIBRARIES - the libraries to link against to use Qt. + QT_DEFINITIONS - definitions to use when + compiling code that uses Qt. + QT_FOUND - If false, don't try to use Qt. + QT_VERSION_STRING - the version of Qt found + + + +If you need the multithreaded version of Qt, set QT_MT_REQUIRED to +TRUE + +Also defined, but not for general use are: + +:: + + QT_MOC_EXECUTABLE, where to find the moc tool. + QT_UIC_EXECUTABLE, where to find the uic tool. + QT_QT_LIBRARY, where to find the Qt library. + QT_QTMAIN_LIBRARY, where to find the qtmain + library. This is only required by Qt3 on Windows. +#]=======================================================================] # These are around for backwards compatibility # they will be set diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 847a798..a145b46 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1,304 +1,305 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindQt4 -# ------- -# -# Finding and Using Qt4 -# ^^^^^^^^^^^^^^^^^^^^^ -# -# This module can be used to find Qt4. The most important issue is that -# the Qt4 qmake is available via the system path. This qmake is then -# used to detect basically everything else. This module defines a -# number of :prop_tgt:`IMPORTED` targets, macros and variables. -# -# Typical usage could be something like: -# -# .. code-block:: cmake -# -# set(CMAKE_AUTOMOC ON) -# set(CMAKE_INCLUDE_CURRENT_DIR ON) -# find_package(Qt4 4.4.3 REQUIRED QtGui QtXml) -# add_executable(myexe main.cpp) -# target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) -# -# .. note:: -# -# When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is -# automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>` -# executables. To disable that globally, set the -# ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that -# for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target -# property to ``TRUE`` on the executable. -# -# Qt Build Tools -# ^^^^^^^^^^^^^^ -# -# Qt relies on some bundled tools for code generation, such as ``moc`` for -# meta-object code generation,``uic`` for widget layout and population, -# and ``rcc`` for virtual filesystem content generation. These tools may be -# automatically invoked by :manual:`cmake(1)` if the appropriate conditions -# are met. See :manual:`cmake-qt(7)` for more. -# -# Qt Macros -# ^^^^^^^^^ -# -# In some cases it can be necessary or useful to invoke the Qt build tools in a -# more-manual way. Several macros are available to add targets for such uses. -# -# :: -# -# macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...) -# create moc code from a list of files containing Qt class with -# the Q_OBJECT declaration. Per-directory preprocessor definitions -# are also added. If the <tgt> is specified, the -# INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from -# the <tgt> are passed to moc. Options may be given to moc, such as -# those found when executing "moc -help". -# -# -# :: -# -# macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...) -# create code from a list of Qt designer ui files. -# Options may be given to uic, such as those found -# when executing "uic -help" -# -# -# :: -# -# macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...) -# create code from a list of Qt resource files. -# Options may be given to rcc, such as those found -# when executing "rcc -help" -# -# -# :: -# -# macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt]) -# creates a rule to run moc on infile and create outfile. -# Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g. -# because you need a custom filename for the moc file or something -# similar. If the <tgt> is specified, the -# INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from -# the <tgt> are passed to moc. -# -# -# :: -# -# macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename) -# Create the interface header and implementation files with the -# given basename from the given interface xml file and add it to -# the list of sources. -# -# You can pass additional parameters to the qdbusxml2cpp call by setting -# properties on the input file: -# -# INCLUDE the given file will be included in the generate interface header -# -# CLASSNAME the generated class is named accordingly -# -# NO_NAMESPACE the generated class is not wrapped in a namespace -# -# -# :: -# -# macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... ) -# Create the interface header and implementation files -# for all listed interface xml files. -# The basename will be automatically determined from the name -# of the xml file. -# -# The source file properties described for -# QT4_ADD_DBUS_INTERFACE also apply here. -# -# -# :: -# -# macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname -# [basename] [classname]) -# create a dbus adaptor (header and implementation file) from the xml file -# describing the interface, and add it to the list of sources. The adaptor -# forwards the calls to a parent class, defined in parentheader and named -# parentclassname. The name of the generated files will be -# <basename>adaptor.{cpp,h} where basename defaults to the basename of the -# xml file. -# If <classname> is provided, then it will be used as the classname of the -# adaptor itself. -# -# -# :: -# -# macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...) -# generate the xml interface file from the given header. -# If the optional argument interfacename is omitted, the name of the -# interface file is constructed from the basename of the header with -# the suffix .xml appended. -# Options may be given to qdbuscpp2xml, such as those found when -# executing "qdbuscpp2xml --help" -# -# -# :: -# -# macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... -# ts_files ... OPTIONS ...) -# out: qm_files -# in: directories sources ts_files -# options: flags to pass to lupdate, such as -extensions to specify -# extensions for a directory scan. -# generates commands to create .ts (vie lupdate) and .qm -# (via lrelease) - files from directories and/or sources. The ts files are -# created and/or updated in the source tree (unless given with full paths). -# The qm files are generated in the build tree. -# Updating the translations can be done by adding the qm_files -# to the source list of your library/executable, so they are -# always updated, or by adding a custom target to control when -# they get updated/generated. -# -# -# :: -# -# macro QT4_ADD_TRANSLATION( qm_files ts_files ... ) -# out: qm_files -# in: ts_files -# generates commands to create .qm from .ts - files. The generated -# filenames can be found in qm_files. The ts_files -# must exist and are not updated in any way. -# -# -# :: -# -# macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) -# The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. -# This macro is still experimental. -# It can be used to have moc automatically handled. -# So if you have the files foo.h and foo.cpp, and in foo.h a -# a class uses the Q_OBJECT macro, moc has to run on it. If you don't -# want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert -# #include "foo.moc" -# in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will -# scan all listed files at cmake-time for such included moc files and if it -# finds them cause a rule to be generated to run moc at build time on the -# accompanying header file foo.h. -# If a source file has the SKIP_AUTOMOC property set it will be ignored by -# this macro. -# If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and -# INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. -# -# -# :: -# -# function QT4_USE_MODULES( target [link_type] modules...) -# This function is obsolete. Use target_link_libraries with IMPORTED targets -# instead. -# Make <target> use the <modules> from Qt. Using a Qt module means -# to link to the library, add the relevant include directories for the -# module, and add the relevant compiler defines for using the module. -# Modules are roughly equivalent to components of Qt4, so usage would be -# something like: -# qt4_use_modules(myexe Core Gui Declarative) -# to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument -# can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the -# same argument to the target_link_libraries call. -# -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# A particular Qt library may be used by using the corresponding -# :prop_tgt:`IMPORTED` target with the :command:`target_link_libraries` -# command: -# -# .. code-block:: cmake -# -# target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) -# -# Using a target in this way causes :cmake(1)` to use the appropriate include -# directories and compile definitions for the target when compiling ``myexe``. -# -# Targets are aware of their dependencies, so for example it is not necessary -# to list ``Qt4::QtCore`` if another Qt library is listed, and it is not -# necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed. -# Targets may be tested for existence in the usual way with the -# :command:`if(TARGET)` command. -# -# The Qt toolkit may contain both debug and release libraries. -# :manual:`cmake(1)` will choose the appropriate version based on the build -# configuration. -# -# ``Qt4::QtCore`` -# The QtCore target -# ``Qt4::QtGui`` -# The QtGui target -# ``Qt4::Qt3Support`` -# The Qt3Support target -# ``Qt4::QtAssistant`` -# The QtAssistant target -# ``Qt4::QtAssistantClient`` -# The QtAssistantClient target -# ``Qt4::QAxContainer`` -# The QAxContainer target (Windows only) -# ``Qt4::QAxServer`` -# The QAxServer target (Windows only) -# ``Qt4::QtDBus`` -# The QtDBus target -# ``Qt4::QtDeclarative`` -# The QtDeclarative target -# ``Qt4::QtDesigner`` -# The QtDesigner target -# ``Qt4::QtDesignerComponents`` -# The QtDesignerComponents target -# ``Qt4::QtHelp`` -# The QtHelp target -# ``Qt4::QtMotif`` -# The QtMotif target -# ``Qt4::QtMultimedia`` -# The QtMultimedia target -# ``Qt4::QtNetwork`` -# The QtNetwork target -# ``Qt4::QtNsPLugin`` -# The QtNsPLugin target -# ``Qt4::QtOpenGL`` -# The QtOpenGL target -# ``Qt4::QtScript`` -# The QtScript target -# ``Qt4::QtScriptTools`` -# The QtScriptTools target -# ``Qt4::QtSql`` -# The QtSql target -# ``Qt4::QtSvg`` -# The QtSvg target -# ``Qt4::QtTest`` -# The QtTest target -# ``Qt4::QtUiTools`` -# The QtUiTools target -# ``Qt4::QtWebKit`` -# The QtWebKit target -# ``Qt4::QtXml`` -# The QtXml target -# ``Qt4::QtXmlPatterns`` -# The QtXmlPatterns target -# ``Qt4::phonon`` -# The phonon target -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# Below is a detailed list of variables that FindQt4.cmake sets. -# -# ``Qt4_FOUND`` -# If false, don't try to use Qt 4. -# ``QT_FOUND`` -# If false, don't try to use Qt. This variable is for compatibility only. -# ``QT4_FOUND`` -# If false, don't try to use Qt 4. This variable is for compatibility only. -# ``QT_VERSION_MAJOR`` -# The major version of Qt found. -# ``QT_VERSION_MINOR`` -# The minor version of Qt found. -# ``QT_VERSION_PATCH`` -# The patch version of Qt found. +#[=======================================================================[.rst: +FindQt4 +------- + +Finding and Using Qt4 +^^^^^^^^^^^^^^^^^^^^^ + +This module can be used to find Qt4. The most important issue is that +the Qt4 qmake is available via the system path. This qmake is then +used to detect basically everything else. This module defines a +number of :prop_tgt:`IMPORTED` targets, macros and variables. + +Typical usage could be something like: + +.. code-block:: cmake + + set(CMAKE_AUTOMOC ON) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + find_package(Qt4 4.4.3 REQUIRED QtGui QtXml) + add_executable(myexe main.cpp) + target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) + +.. note:: + + When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is + automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>` + executables. To disable that globally, set the + ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that + for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target + property to ``TRUE`` on the executable. + +Qt Build Tools +^^^^^^^^^^^^^^ + +Qt relies on some bundled tools for code generation, such as ``moc`` for +meta-object code generation,``uic`` for widget layout and population, +and ``rcc`` for virtual filesystem content generation. These tools may be +automatically invoked by :manual:`cmake(1)` if the appropriate conditions +are met. See :manual:`cmake-qt(7)` for more. + +Qt Macros +^^^^^^^^^ + +In some cases it can be necessary or useful to invoke the Qt build tools in a +more-manual way. Several macros are available to add targets for such uses. + +:: + + macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...) + create moc code from a list of files containing Qt class with + the Q_OBJECT declaration. Per-directory preprocessor definitions + are also added. If the <tgt> is specified, the + INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from + the <tgt> are passed to moc. Options may be given to moc, such as + those found when executing "moc -help". + + +:: + + macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...) + create code from a list of Qt designer ui files. + Options may be given to uic, such as those found + when executing "uic -help" + + +:: + + macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...) + create code from a list of Qt resource files. + Options may be given to rcc, such as those found + when executing "rcc -help" + + +:: + + macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt]) + creates a rule to run moc on infile and create outfile. + Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g. + because you need a custom filename for the moc file or something + similar. If the <tgt> is specified, the + INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from + the <tgt> are passed to moc. + + +:: + + macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename) + Create the interface header and implementation files with the + given basename from the given interface xml file and add it to + the list of sources. + + You can pass additional parameters to the qdbusxml2cpp call by setting + properties on the input file: + + INCLUDE the given file will be included in the generate interface header + + CLASSNAME the generated class is named accordingly + + NO_NAMESPACE the generated class is not wrapped in a namespace + + +:: + + macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... ) + Create the interface header and implementation files + for all listed interface xml files. + The basename will be automatically determined from the name + of the xml file. + + The source file properties described for + QT4_ADD_DBUS_INTERFACE also apply here. + + +:: + + macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname + [basename] [classname]) + create a dbus adaptor (header and implementation file) from the xml file + describing the interface, and add it to the list of sources. The adaptor + forwards the calls to a parent class, defined in parentheader and named + parentclassname. The name of the generated files will be + <basename>adaptor.{cpp,h} where basename defaults to the basename of the + xml file. + If <classname> is provided, then it will be used as the classname of the + adaptor itself. + + +:: + + macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...) + generate the xml interface file from the given header. + If the optional argument interfacename is omitted, the name of the + interface file is constructed from the basename of the header with + the suffix .xml appended. + Options may be given to qdbuscpp2xml, such as those found when + executing "qdbuscpp2xml --help" + + +:: + + macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... + ts_files ... OPTIONS ...) + out: qm_files + in: directories sources ts_files + options: flags to pass to lupdate, such as -extensions to specify + extensions for a directory scan. + generates commands to create .ts (vie lupdate) and .qm + (via lrelease) - files from directories and/or sources. The ts files are + created and/or updated in the source tree (unless given with full paths). + The qm files are generated in the build tree. + Updating the translations can be done by adding the qm_files + to the source list of your library/executable, so they are + always updated, or by adding a custom target to control when + they get updated/generated. + + +:: + + macro QT4_ADD_TRANSLATION( qm_files ts_files ... ) + out: qm_files + in: ts_files + generates commands to create .qm from .ts - files. The generated + filenames can be found in qm_files. The ts_files + must exist and are not updated in any way. + + +:: + + macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) + The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. + This macro is still experimental. + It can be used to have moc automatically handled. + So if you have the files foo.h and foo.cpp, and in foo.h a + a class uses the Q_OBJECT macro, moc has to run on it. If you don't + want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert + #include "foo.moc" + in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will + scan all listed files at cmake-time for such included moc files and if it + finds them cause a rule to be generated to run moc at build time on the + accompanying header file foo.h. + If a source file has the SKIP_AUTOMOC property set it will be ignored by + this macro. + If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and + INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. + + +:: + + function QT4_USE_MODULES( target [link_type] modules...) + This function is obsolete. Use target_link_libraries with IMPORTED targets + instead. + Make <target> use the <modules> from Qt. Using a Qt module means + to link to the library, add the relevant include directories for the + module, and add the relevant compiler defines for using the module. + Modules are roughly equivalent to components of Qt4, so usage would be + something like: + qt4_use_modules(myexe Core Gui Declarative) + to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument + can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the + same argument to the target_link_libraries call. + + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +A particular Qt library may be used by using the corresponding +:prop_tgt:`IMPORTED` target with the :command:`target_link_libraries` +command: + +.. code-block:: cmake + + target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) + +Using a target in this way causes :cmake(1)` to use the appropriate include +directories and compile definitions for the target when compiling ``myexe``. + +Targets are aware of their dependencies, so for example it is not necessary +to list ``Qt4::QtCore`` if another Qt library is listed, and it is not +necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed. +Targets may be tested for existence in the usual way with the +:command:`if(TARGET)` command. + +The Qt toolkit may contain both debug and release libraries. +:manual:`cmake(1)` will choose the appropriate version based on the build +configuration. + +``Qt4::QtCore`` + The QtCore target +``Qt4::QtGui`` + The QtGui target +``Qt4::Qt3Support`` + The Qt3Support target +``Qt4::QtAssistant`` + The QtAssistant target +``Qt4::QtAssistantClient`` + The QtAssistantClient target +``Qt4::QAxContainer`` + The QAxContainer target (Windows only) +``Qt4::QAxServer`` + The QAxServer target (Windows only) +``Qt4::QtDBus`` + The QtDBus target +``Qt4::QtDeclarative`` + The QtDeclarative target +``Qt4::QtDesigner`` + The QtDesigner target +``Qt4::QtDesignerComponents`` + The QtDesignerComponents target +``Qt4::QtHelp`` + The QtHelp target +``Qt4::QtMotif`` + The QtMotif target +``Qt4::QtMultimedia`` + The QtMultimedia target +``Qt4::QtNetwork`` + The QtNetwork target +``Qt4::QtNsPLugin`` + The QtNsPLugin target +``Qt4::QtOpenGL`` + The QtOpenGL target +``Qt4::QtScript`` + The QtScript target +``Qt4::QtScriptTools`` + The QtScriptTools target +``Qt4::QtSql`` + The QtSql target +``Qt4::QtSvg`` + The QtSvg target +``Qt4::QtTest`` + The QtTest target +``Qt4::QtUiTools`` + The QtUiTools target +``Qt4::QtWebKit`` + The QtWebKit target +``Qt4::QtXml`` + The QtXml target +``Qt4::QtXmlPatterns`` + The QtXmlPatterns target +``Qt4::phonon`` + The phonon target + +Result Variables +^^^^^^^^^^^^^^^^ + + Below is a detailed list of variables that FindQt4.cmake sets. + +``Qt4_FOUND`` + If false, don't try to use Qt 4. +``QT_FOUND`` + If false, don't try to use Qt. This variable is for compatibility only. +``QT4_FOUND`` + If false, don't try to use Qt 4. This variable is for compatibility only. +``QT_VERSION_MAJOR`` + The major version of Qt found. +``QT_VERSION_MINOR`` + The minor version of Qt found. +``QT_VERSION_PATCH`` + The patch version of Qt found. +#]=======================================================================] # Use find_package( Qt4 COMPONENTS ... ) to enable modules if( Qt4_FIND_COMPONENTS ) diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake index 995d882..107486d 100644 --- a/Modules/FindQuickTime.cmake +++ b/Modules/FindQuickTime.cmake @@ -1,20 +1,21 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindQuickTime -# ------------- -# -# -# -# Locate QuickTime This module defines QUICKTIME_LIBRARY -# QUICKTIME_FOUND, if false, do not try to link to gdal -# QUICKTIME_INCLUDE_DIR, where to find the headers -# -# $QUICKTIME_DIR is an environment variable that would correspond to the -# ./configure --prefix=$QUICKTIME_DIR -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindQuickTime +------------- + + + +Locate QuickTime This module defines QUICKTIME_LIBRARY +QUICKTIME_FOUND, if false, do not try to link to gdal +QUICKTIME_INCLUDE_DIR, where to find the headers + +$QUICKTIME_DIR is an environment variable that would correspond to the +./configure --prefix=$QUICKTIME_DIR + +Created by Eric Wing. +#]=======================================================================] find_path(QUICKTIME_INCLUDE_DIR QuickTime/QuickTime.h QuickTime.h HINTS diff --git a/Modules/FindRTI.cmake b/Modules/FindRTI.cmake index b2ef076..54d2bec 100644 --- a/Modules/FindRTI.cmake +++ b/Modules/FindRTI.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindRTI -# ------- -# -# Try to find M&S HLA RTI libraries -# -# This module finds if any HLA RTI is installed and locates the standard -# RTI include files and libraries. -# -# RTI is a simulation infrastructure standardized by IEEE and SISO. It -# has a well defined C++ API that assures that simulation applications -# are independent on a particular RTI implementation. -# -# :: -# -# http://en.wikipedia.org/wiki/Run-Time_Infrastructure_(simulation) -# -# -# -# This code sets the following variables: -# -# :: -# -# RTI_INCLUDE_DIR = the directory where RTI includes file are found -# RTI_LIBRARIES = The libraries to link against to use RTI -# RTI_DEFINITIONS = -DRTI_USES_STD_FSTREAM -# RTI_FOUND = Set to FALSE if any HLA RTI was not found -# -# -# -# Report problems to <certi-devel@nongnu.org> +#[=======================================================================[.rst: +FindRTI +------- + +Try to find M&S HLA RTI libraries + +This module finds if any HLA RTI is installed and locates the standard +RTI include files and libraries. + +RTI is a simulation infrastructure standardized by IEEE and SISO. It +has a well defined C++ API that assures that simulation applications +are independent on a particular RTI implementation. + +:: + + http://en.wikipedia.org/wiki/Run-Time_Infrastructure_(simulation) + + + +This code sets the following variables: + +:: + + RTI_INCLUDE_DIR = the directory where RTI includes file are found + RTI_LIBRARIES = The libraries to link against to use RTI + RTI_DEFINITIONS = -DRTI_USES_STD_FSTREAM + RTI_FOUND = Set to FALSE if any HLA RTI was not found + + + +Report problems to <certi-devel@nongnu.org> +#]=======================================================================] macro(RTI_MESSAGE_QUIETLY QUIET TYPE MSG) if(NOT ${QUIET}) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index bd9f835..58debdd 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindRuby -# -------- -# -# Find Ruby -# -# This module finds if Ruby is installed and determines where the -# include files and libraries are. Ruby 1.8, 1.9, 2.0 and 2.1 are -# supported. -# -# The minimum required version of Ruby can be specified using the -# standard syntax, e.g. find_package(Ruby 1.8) -# -# It also determines what the name of the library is. This code sets -# the following variables: -# -# ``RUBY_EXECUTABLE`` -# full path to the ruby binary -# ``RUBY_INCLUDE_DIRS`` -# include dirs to be used when using the ruby library -# ``RUBY_LIBRARY`` -# full path to the ruby library -# ``RUBY_VERSION`` -# the version of ruby which was found, e.g. "1.8.7" -# ``RUBY_FOUND`` -# set to true if ruby ws found successfully -# -# Also: -# -# ``RUBY_INCLUDE_PATH`` -# same as RUBY_INCLUDE_DIRS, only provided for compatibility reasons, don't use it +#[=======================================================================[.rst: +FindRuby +-------- + +Find Ruby + +This module finds if Ruby is installed and determines where the +include files and libraries are. Ruby 1.8, 1.9, 2.0 and 2.1 are +supported. + +The minimum required version of Ruby can be specified using the +standard syntax, e.g. find_package(Ruby 1.8) + +It also determines what the name of the library is. This code sets +the following variables: + +``RUBY_EXECUTABLE`` + full path to the ruby binary +``RUBY_INCLUDE_DIRS`` + include dirs to be used when using the ruby library +``RUBY_LIBRARY`` + full path to the ruby library +``RUBY_VERSION`` + the version of ruby which was found, e.g. "1.8.7" +``RUBY_FOUND`` + set to true if ruby ws found successfully + +Also: + +``RUBY_INCLUDE_PATH`` + same as RUBY_INCLUDE_DIRS, only provided for compatibility reasons, don't use it +#]=======================================================================] # RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'` # RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'` diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 3410018..2813831 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -1,75 +1,76 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSDL -# ------- -# -# Locate SDL library -# -# This module defines -# -# :: -# -# SDL_LIBRARY, the name of the library to link against -# SDL_FOUND, if false, do not try to link to SDL -# SDL_INCLUDE_DIR, where to find SDL.h -# SDL_VERSION_STRING, human-readable string containing the version of SDL -# -# -# -# This module responds to the flag: -# -# :: -# -# SDL_BUILDING_LIBRARY -# If this is defined, then no SDL_main will be linked in because -# only applications need main(). -# Otherwise, it is assumed you are building an application and this -# module will attempt to locate and set the proper link flags -# as part of the returned SDL_LIBRARY variable. -# -# -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDLmain which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# -# -# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your -# configuration and no SDL_LIBRARY, it means CMake did not find your SDL -# library (SDL.dll, libsdl.so, SDL.framework, etc). Set -# SDL_LIBRARY_TEMP to point to your SDL library, and configure again. -# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this -# value as appropriate. These values are used to generate the final -# SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY -# does not get created. -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02 -# -# Modified by Eric Wing. Added code to assist with automated building -# by using environmental variables and providing a more -# controlled/consistent search behavior. Added new modifications to -# recognize OS X frameworks and additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL -# guidelines. Added a search for SDLmain which is needed by some -# platforms. Added a search for threads which is needed by some -# platforms. Added needed compile switches for MinGW. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of SDL_LIBRARY to -# override this selection or set the CMake environment -# CMAKE_INCLUDE_PATH to modify the search paths. -# -# Note that the header path has changed from SDL/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention is #include -# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons -# because not all systems place things in SDL/ (see FreeBSD). +#[=======================================================================[.rst: +FindSDL +------- + +Locate SDL library + +This module defines + +:: + + SDL_LIBRARY, the name of the library to link against + SDL_FOUND, if false, do not try to link to SDL + SDL_INCLUDE_DIR, where to find SDL.h + SDL_VERSION_STRING, human-readable string containing the version of SDL + + + +This module responds to the flag: + +:: + + SDL_BUILDING_LIBRARY + If this is defined, then no SDL_main will be linked in because + only applications need main(). + Otherwise, it is assumed you are building an application and this + module will attempt to locate and set the proper link flags + as part of the returned SDL_LIBRARY variable. + + + +Don't forget to include SDLmain.h and SDLmain.m your project for the +OS X framework based version. (Other versions link to -lSDLmain which +this module will try to find on your behalf.) Also for OS X, this +module will automatically add the -framework Cocoa on your behalf. + + + +Additional Note: If you see an empty SDL_LIBRARY_TEMP in your +configuration and no SDL_LIBRARY, it means CMake did not find your SDL +library (SDL.dll, libsdl.so, SDL.framework, etc). Set +SDL_LIBRARY_TEMP to point to your SDL library, and configure again. +Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this +value as appropriate. These values are used to generate the final +SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY +does not get created. + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02 + +Modified by Eric Wing. Added code to assist with automated building +by using environmental variables and providing a more +controlled/consistent search behavior. Added new modifications to +recognize OS X frameworks and additional Unix paths (FreeBSD, etc). +Also corrected the header search path to follow "proper" SDL +guidelines. Added a search for SDLmain which is needed by some +platforms. Added a search for threads which is needed by some +platforms. Added needed compile switches for MinGW. + +On OSX, this will prefer the Framework version (if found) over others. +People will have to manually change the cache values of SDL_LIBRARY to +override this selection or set the CMake environment +CMAKE_INCLUDE_PATH to modify the search paths. + +Note that the header path has changed from SDL/SDL.h to just SDL.h +This needed to change because "proper" SDL convention is #include +"SDL.h", not <SDL/SDL.h>. This is done for portability reasons +because not all systems place things in SDL/ (see FreeBSD). +#]=======================================================================] find_path(SDL_INCLUDE_DIR SDL.h HINTS diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index 8cdaa7a..e687b49 100644 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -1,40 +1,41 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSDL_image -# ------------- -# -# Locate SDL_image library -# -# This module defines: -# -# :: -# -# SDL_IMAGE_LIBRARIES, the name of the library to link against -# SDL_IMAGE_INCLUDE_DIRS, where to find the headers -# SDL_IMAGE_FOUND, if false, do not try to link against -# SDL_IMAGE_VERSION_STRING - human-readable string containing the -# version of SDL_image -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES) -# SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS) -# SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). +#[=======================================================================[.rst: +FindSDL_image +------------- + +Locate SDL_image library + +This module defines: + +:: + + SDL_IMAGE_LIBRARIES, the name of the library to link against + SDL_IMAGE_INCLUDE_DIRS, where to find the headers + SDL_IMAGE_FOUND, if false, do not try to link against + SDL_IMAGE_VERSION_STRING - human-readable string containing the + version of SDL_image + + + +For backward compatibility the following variables are also set: + +:: + + SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES) + SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS) + SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND) + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. + +Created by Eric Wing. This was influenced by the FindSDL.cmake +module, but with modifications to recognize OS X frameworks and +additional Unix paths (FreeBSD, etc). +#]=======================================================================] if(NOT SDL_IMAGE_INCLUDE_DIR AND SDLIMAGE_INCLUDE_DIR) set(SDL_IMAGE_INCLUDE_DIR ${SDLIMAGE_INCLUDE_DIR} CACHE PATH "directory cache diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index 35233d1..315400a 100644 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -1,40 +1,41 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSDL_mixer -# ------------- -# -# Locate SDL_mixer library -# -# This module defines: -# -# :: -# -# SDL_MIXER_LIBRARIES, the name of the library to link against -# SDL_MIXER_INCLUDE_DIRS, where to find the headers -# SDL_MIXER_FOUND, if false, do not try to link against -# SDL_MIXER_VERSION_STRING - human-readable string containing the -# version of SDL_mixer -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLMIXER_LIBRARY (same value as SDL_MIXER_LIBRARIES) -# SDLMIXER_INCLUDE_DIR (same value as SDL_MIXER_INCLUDE_DIRS) -# SDLMIXER_FOUND (same value as SDL_MIXER_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). +#[=======================================================================[.rst: +FindSDL_mixer +------------- + +Locate SDL_mixer library + +This module defines: + +:: + + SDL_MIXER_LIBRARIES, the name of the library to link against + SDL_MIXER_INCLUDE_DIRS, where to find the headers + SDL_MIXER_FOUND, if false, do not try to link against + SDL_MIXER_VERSION_STRING - human-readable string containing the + version of SDL_mixer + + + +For backward compatibility the following variables are also set: + +:: + + SDLMIXER_LIBRARY (same value as SDL_MIXER_LIBRARIES) + SDLMIXER_INCLUDE_DIR (same value as SDL_MIXER_INCLUDE_DIRS) + SDLMIXER_FOUND (same value as SDL_MIXER_FOUND) + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. + +Created by Eric Wing. This was influenced by the FindSDL.cmake +module, but with modifications to recognize OS X frameworks and +additional Unix paths (FreeBSD, etc). +#]=======================================================================] if(NOT SDL_MIXER_INCLUDE_DIR AND SDLMIXER_INCLUDE_DIR) set(SDL_MIXER_INCLUDE_DIR ${SDLMIXER_INCLUDE_DIR} CACHE PATH "directory cache diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index b406946..28cb4d6 100644 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -1,39 +1,40 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSDL_net -# ----------- -# -# Locate SDL_net library -# -# This module defines: -# -# :: -# -# SDL_NET_LIBRARIES, the name of the library to link against -# SDL_NET_INCLUDE_DIRS, where to find the headers -# SDL_NET_FOUND, if false, do not try to link against -# SDL_NET_VERSION_STRING - human-readable string containing the version of SDL_net -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLNET_LIBRARY (same value as SDL_NET_LIBRARIES) -# SDLNET_INCLUDE_DIR (same value as SDL_NET_INCLUDE_DIRS) -# SDLNET_FOUND (same value as SDL_NET_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). +#[=======================================================================[.rst: +FindSDL_net +----------- + +Locate SDL_net library + +This module defines: + +:: + + SDL_NET_LIBRARIES, the name of the library to link against + SDL_NET_INCLUDE_DIRS, where to find the headers + SDL_NET_FOUND, if false, do not try to link against + SDL_NET_VERSION_STRING - human-readable string containing the version of SDL_net + + + +For backward compatibility the following variables are also set: + +:: + + SDLNET_LIBRARY (same value as SDL_NET_LIBRARIES) + SDLNET_INCLUDE_DIR (same value as SDL_NET_INCLUDE_DIRS) + SDLNET_FOUND (same value as SDL_NET_FOUND) + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. + +Created by Eric Wing. This was influenced by the FindSDL.cmake +module, but with modifications to recognize OS X frameworks and +additional Unix paths (FreeBSD, etc). +#]=======================================================================] if(NOT SDL_NET_INCLUDE_DIR AND SDLNET_INCLUDE_DIR) set(SDL_NET_INCLUDE_DIR ${SDLNET_INCLUDE_DIR} CACHE PATH "directory cache diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index cf33a4c..e217981 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -1,84 +1,85 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSDL_sound -# ------------- -# -# Locates the SDL_sound library -# -# -# -# This module depends on SDL being found and must be called AFTER -# FindSDL.cmake is called. -# -# This module defines -# -# :: -# -# SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h -# SDL_SOUND_FOUND, if false, do not try to link to SDL_sound -# SDL_SOUND_LIBRARIES, this contains the list of libraries that you need -# to link against. -# SDL_SOUND_EXTRAS, this is an optional variable for you to add your own -# flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES. -# This is available mostly for cases this module failed to anticipate for -# and you must add additional flags. This is marked as ADVANCED. -# SDL_SOUND_VERSION_STRING, human-readable string containing the -# version of SDL_sound -# -# -# -# This module also defines (but you shouldn't need to use directly) -# -# :: -# -# SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link -# against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one. -# -# And might define the following as needed -# -# :: -# -# MIKMOD_LIBRARY -# MODPLUG_LIBRARY -# OGG_LIBRARY -# VORBIS_LIBRARY -# SMPEG_LIBRARY -# FLAC_LIBRARY -# SPEEX_LIBRARY -# -# -# -# Typically, you should not use these variables directly, and you should -# use SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other -# audio libraries (if needed) to successfully compile on your system. -# -# Created by Eric Wing. This module is a bit more complicated than the -# other FindSDL* family modules. The reason is that SDL_sound can be -# compiled in a large variety of different ways which are independent of -# platform. SDL_sound may dynamically link against other 3rd party -# libraries to get additional codec support, such as Ogg Vorbis, SMPEG, -# ModPlug, MikMod, FLAC, Speex, and potentially others. Under some -# circumstances which I don't fully understand, there seems to be a -# requirement that dependent libraries of libraries you use must also be -# explicitly linked against in order to successfully compile. SDL_sound -# does not currently have any system in place to know how it was -# compiled. So this CMake module does the hard work in trying to -# discover which 3rd party libraries are required for building (if any). -# This module uses a brute force approach to create a test program that -# uses SDL_sound, and then tries to build it. If the build fails, it -# parses the error output for known symbol names to figure out which -# libraries are needed. -# -# Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that -# would correspond to the ./configure --prefix=$SDLDIR used in building -# SDL. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of SDL_LIBRARY to -# override this selectionor set the CMake environment CMAKE_INCLUDE_PATH -# to modify the search paths. +#[=======================================================================[.rst: +FindSDL_sound +------------- + +Locates the SDL_sound library + + + +This module depends on SDL being found and must be called AFTER +FindSDL.cmake is called. + +This module defines + +:: + + SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h + SDL_SOUND_FOUND, if false, do not try to link to SDL_sound + SDL_SOUND_LIBRARIES, this contains the list of libraries that you need + to link against. + SDL_SOUND_EXTRAS, this is an optional variable for you to add your own + flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES. + This is available mostly for cases this module failed to anticipate for + and you must add additional flags. This is marked as ADVANCED. + SDL_SOUND_VERSION_STRING, human-readable string containing the + version of SDL_sound + + + +This module also defines (but you shouldn't need to use directly) + +:: + + SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link + against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one. + +And might define the following as needed + +:: + + MIKMOD_LIBRARY + MODPLUG_LIBRARY + OGG_LIBRARY + VORBIS_LIBRARY + SMPEG_LIBRARY + FLAC_LIBRARY + SPEEX_LIBRARY + + + +Typically, you should not use these variables directly, and you should +use SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other +audio libraries (if needed) to successfully compile on your system. + +Created by Eric Wing. This module is a bit more complicated than the +other FindSDL* family modules. The reason is that SDL_sound can be +compiled in a large variety of different ways which are independent of +platform. SDL_sound may dynamically link against other 3rd party +libraries to get additional codec support, such as Ogg Vorbis, SMPEG, +ModPlug, MikMod, FLAC, Speex, and potentially others. Under some +circumstances which I don't fully understand, there seems to be a +requirement that dependent libraries of libraries you use must also be +explicitly linked against in order to successfully compile. SDL_sound +does not currently have any system in place to know how it was +compiled. So this CMake module does the hard work in trying to +discover which 3rd party libraries are required for building (if any). +This module uses a brute force approach to create a test program that +uses SDL_sound, and then tries to build it. If the build fails, it +parses the error output for known symbol names to figure out which +libraries are needed. + +Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that +would correspond to the ./configure --prefix=$SDLDIR used in building +SDL. + +On OSX, this will prefer the Framework version (if found) over others. +People will have to manually change the cache values of SDL_LIBRARY to +override this selectionor set the CMake environment CMAKE_INCLUDE_PATH +to modify the search paths. +#]=======================================================================] set(SDL_SOUND_EXTRAS "" CACHE STRING "SDL_sound extra flags") mark_as_advanced(SDL_SOUND_EXTRAS) diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index aa705f2..d5721da 100644 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -1,39 +1,40 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSDL_ttf -# ----------- -# -# Locate SDL_ttf library -# -# This module defines: -# -# :: -# -# SDL_TTF_LIBRARIES, the name of the library to link against -# SDL_TTF_INCLUDE_DIRS, where to find the headers -# SDL_TTF_FOUND, if false, do not try to link against -# SDL_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES) -# SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS) -# SDLTTF_FOUND (same value as SDL_TTF_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). +#[=======================================================================[.rst: +FindSDL_ttf +----------- + +Locate SDL_ttf library + +This module defines: + +:: + + SDL_TTF_LIBRARIES, the name of the library to link against + SDL_TTF_INCLUDE_DIRS, where to find the headers + SDL_TTF_FOUND, if false, do not try to link against + SDL_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf + + + +For backward compatibility the following variables are also set: + +:: + + SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES) + SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS) + SDLTTF_FOUND (same value as SDL_TTF_FOUND) + + + +$SDLDIR is an environment variable that would correspond to the +./configure --prefix=$SDLDIR used in building SDL. + +Created by Eric Wing. This was influenced by the FindSDL.cmake +module, but with modifications to recognize OS X frameworks and +additional Unix paths (FreeBSD, etc). +#]=======================================================================] if(NOT SDL_TTF_INCLUDE_DIR AND SDLTTF_INCLUDE_DIR) set(SDL_TTF_INCLUDE_DIR ${SDLTTF_INCLUDE_DIR} CACHE PATH "directory cache diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index 92c032f..fc0ed00 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -1,29 +1,30 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSWIG -# -------- -# -# Find SWIG -# -# This module finds an installed SWIG. It sets the following variables: -# -# :: -# -# SWIG_FOUND - set to true if SWIG is found -# SWIG_DIR - the directory where swig is installed -# SWIG_EXECUTABLE - the path to the swig executable -# SWIG_VERSION - the version number of the swig executable -# -# -# -# The minimum required version of SWIG can be specified using the -# standard syntax, e.g. find_package(SWIG 1.1) -# -# All information is collected from the SWIG_EXECUTABLE so the version -# to be found can be changed from the command line by means of setting -# SWIG_EXECUTABLE +#[=======================================================================[.rst: +FindSWIG +-------- + +Find SWIG + +This module finds an installed SWIG. It sets the following variables: + +:: + + SWIG_FOUND - set to true if SWIG is found + SWIG_DIR - the directory where swig is installed + SWIG_EXECUTABLE - the path to the swig executable + SWIG_VERSION - the version number of the swig executable + + + +The minimum required version of SWIG can be specified using the +standard syntax, e.g. find_package(SWIG 1.1) + +All information is collected from the SWIG_EXECUTABLE so the version +to be found can be changed from the command line by means of setting +SWIG_EXECUTABLE +#]=======================================================================] find_program(SWIG_EXECUTABLE NAMES swig3.0 swig2.0 swig) diff --git a/Modules/FindSelfPackers.cmake b/Modules/FindSelfPackers.cmake index ac2c7cf..1abbcbd 100644 --- a/Modules/FindSelfPackers.cmake +++ b/Modules/FindSelfPackers.cmake @@ -1,19 +1,20 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSelfPackers -# --------------- -# -# Find upx -# -# This module looks for some executable packers (i.e. software that -# compress executables or shared libs into on-the-fly self-extracting -# executables or shared libs. Examples: -# -# :: -# -# UPX: http://wildsau.idv.uni-linz.ac.at/mfx/upx.html +#[=======================================================================[.rst: +FindSelfPackers +--------------- + +Find upx + +This module looks for some executable packers (i.e. software that +compress executables or shared libs into on-the-fly self-extracting +executables or shared libs. Examples: + +:: + + UPX: http://wildsau.idv.uni-linz.ac.at/mfx/upx.html +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index d1ce200..7d49505 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -1,123 +1,124 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSquish -# ---------- -# -# -- Typical Use -# -# -# -# This module can be used to find Squish. Currently Squish versions 3 -# and 4 are supported. -# -# :: -# -# SQUISH_FOUND If false, don't try to use Squish -# SQUISH_VERSION The full version of Squish found -# SQUISH_VERSION_MAJOR The major version of Squish found -# SQUISH_VERSION_MINOR The minor version of Squish found -# SQUISH_VERSION_PATCH The patch version of Squish found -# -# -# -# :: -# -# SQUISH_INSTALL_DIR The Squish installation directory -# (containing bin, lib, etc) -# SQUISH_SERVER_EXECUTABLE The squishserver executable -# SQUISH_CLIENT_EXECUTABLE The squishrunner executable -# -# -# -# :: -# -# SQUISH_INSTALL_DIR_FOUND Was the install directory found? -# SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found? -# SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found? -# -# -# -# It provides the function squish_v4_add_test() for adding a squish test -# to cmake using Squish 4.x: -# -# :: -# -# squish_v4_add_test(cmakeTestName -# AUT targetName SUITE suiteName TEST squishTestName -# [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] ) -# -# -# -# The arguments have the following meaning: -# -# ``cmakeTestName`` -# this will be used as the first argument for add_test() -# ``AUT targetName`` -# the name of the cmake target which will be used as AUT, i.e. the -# executable which will be tested. -# ``SUITE suiteName`` -# this is either the full path to the squish suite, or just the -# last directory of the suite, i.e. the suite name. In this case -# the CMakeLists.txt which calls squish_add_test() must be located -# in the parent directory of the suite directory. -# ``TEST squishTestName`` -# the name of the squish test, i.e. the name of the subdirectory -# of the test inside the suite directory. -# ``SETTINGSGROUP group`` -# if specified, the given settings group will be used for executing the test. -# If not specified, the groupname will be "CTest_<username>" -# ``PRE_COMMAND command`` -# if specified, the given command will be executed before starting the squish test. -# ``POST_COMMAND command`` -# same as PRE_COMMAND, but after the squish test has been executed. -# -# -# -# :: -# -# enable_testing() -# find_package(Squish 4.0) -# if (SQUISH_FOUND) -# squish_v4_add_test(myTestName -# AUT myApp -# SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite -# TEST someSquishTest -# SETTINGSGROUP myGroup -# ) -# endif () -# -# -# -# -# -# For users of Squish version 3.x the macro squish_v3_add_test() is -# provided: -# -# :: -# -# squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper) -# Use this macro to add a test using Squish 3.x. -# -# -# -# :: -# -# enable_testing() -# find_package(Squish) -# if (SQUISH_FOUND) -# squish_v3_add_test(myTestName myApplication testCase envVars testWrapper) -# endif () -# -# -# -# macro SQUISH_ADD_TEST(testName applicationUnderTest testCase envVars -# testWrapper) -# -# :: -# -# This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead. +#[=======================================================================[.rst: +FindSquish +---------- + +-- Typical Use + + + +This module can be used to find Squish. Currently Squish versions 3 +and 4 are supported. + +:: + + SQUISH_FOUND If false, don't try to use Squish + SQUISH_VERSION The full version of Squish found + SQUISH_VERSION_MAJOR The major version of Squish found + SQUISH_VERSION_MINOR The minor version of Squish found + SQUISH_VERSION_PATCH The patch version of Squish found + + + +:: + + SQUISH_INSTALL_DIR The Squish installation directory + (containing bin, lib, etc) + SQUISH_SERVER_EXECUTABLE The squishserver executable + SQUISH_CLIENT_EXECUTABLE The squishrunner executable + + + +:: + + SQUISH_INSTALL_DIR_FOUND Was the install directory found? + SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found? + SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found? + + + +It provides the function squish_v4_add_test() for adding a squish test +to cmake using Squish 4.x: + +:: + + squish_v4_add_test(cmakeTestName + AUT targetName SUITE suiteName TEST squishTestName + [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] ) + + + +The arguments have the following meaning: + +``cmakeTestName`` + this will be used as the first argument for add_test() +``AUT targetName`` + the name of the cmake target which will be used as AUT, i.e. the + executable which will be tested. +``SUITE suiteName`` + this is either the full path to the squish suite, or just the + last directory of the suite, i.e. the suite name. In this case + the CMakeLists.txt which calls squish_add_test() must be located + in the parent directory of the suite directory. +``TEST squishTestName`` + the name of the squish test, i.e. the name of the subdirectory + of the test inside the suite directory. +``SETTINGSGROUP group`` + if specified, the given settings group will be used for executing the test. + If not specified, the groupname will be "CTest_<username>" +``PRE_COMMAND command`` + if specified, the given command will be executed before starting the squish test. +``POST_COMMAND command`` + same as PRE_COMMAND, but after the squish test has been executed. + + + +:: + + enable_testing() + find_package(Squish 4.0) + if (SQUISH_FOUND) + squish_v4_add_test(myTestName + AUT myApp + SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite + TEST someSquishTest + SETTINGSGROUP myGroup + ) + endif () + + + + + +For users of Squish version 3.x the macro squish_v3_add_test() is +provided: + +:: + + squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper) + Use this macro to add a test using Squish 3.x. + + + +:: + + enable_testing() + find_package(Squish) + if (SQUISH_FOUND) + squish_v3_add_test(myTestName myApplication testCase envVars testWrapper) + endif () + + + +macro SQUISH_ADD_TEST(testName applicationUnderTest testCase envVars +testWrapper) + +:: + + This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead. +#]=======================================================================] set(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.") set(SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program.") diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index e18ae88..ce280e2 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -1,68 +1,69 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindSubversion -# -------------- -# -# Extract information from a subversion working copy -# -# The module defines the following variables: -# -# :: -# -# Subversion_SVN_EXECUTABLE - path to svn command line client -# Subversion_VERSION_SVN - version of svn command line client -# Subversion_FOUND - true if the command line client was found -# SUBVERSION_FOUND - same as Subversion_FOUND, set for compatibility reasons -# -# -# -# The minimum required version of Subversion can be specified using the -# standard syntax, e.g. ``find_package(Subversion 1.4)``. -# -# If the command line client executable is found two macros are defined: -# -# :: -# -# Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE]) -# Subversion_WC_LOG(<dir> <var-prefix>) -# -# ``Subversion_WC_INFO`` extracts information of a subversion working copy at a -# given location. This macro defines the following variables if running -# Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a -# ``SEND_ERROR`` message is generated. The error can be ignored by providing the -# ``IGNORE_SVN_FAILURE`` option, which causes these variables to remain -# undefined. -# -# :: -# -# <var-prefix>_WC_URL - url of the repository (at <dir>) -# <var-prefix>_WC_ROOT - root url of the repository -# <var-prefix>_WC_REVISION - current revision -# <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit -# <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit -# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit -# <var-prefix>_WC_INFO - output of command `svn info <dir>' -# -# ``Subversion_WC_LOG`` retrieves the log message of the base revision of a -# subversion working copy at a given location. This macro defines the variable: -# -# :: -# -# <var-prefix>_LAST_CHANGED_LOG - last log of base revision -# -# Example usage: -# -# :: -# -# find_package(Subversion) -# if(SUBVERSION_FOUND) -# Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) -# message("Current revision is ${Project_WC_REVISION}") -# Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) -# message("Last changed log is ${Project_LAST_CHANGED_LOG}") -# endif() +#[=======================================================================[.rst: +FindSubversion +-------------- + +Extract information from a subversion working copy + +The module defines the following variables: + +:: + + Subversion_SVN_EXECUTABLE - path to svn command line client + Subversion_VERSION_SVN - version of svn command line client + Subversion_FOUND - true if the command line client was found + SUBVERSION_FOUND - same as Subversion_FOUND, set for compatibility reasons + + + +The minimum required version of Subversion can be specified using the +standard syntax, e.g. ``find_package(Subversion 1.4)``. + +If the command line client executable is found two macros are defined: + +:: + + Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE]) + Subversion_WC_LOG(<dir> <var-prefix>) + +``Subversion_WC_INFO`` extracts information of a subversion working copy at a +given location. This macro defines the following variables if running +Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a +``SEND_ERROR`` message is generated. The error can be ignored by providing the +``IGNORE_SVN_FAILURE`` option, which causes these variables to remain +undefined. + +:: + + <var-prefix>_WC_URL - url of the repository (at <dir>) + <var-prefix>_WC_ROOT - root url of the repository + <var-prefix>_WC_REVISION - current revision + <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit + <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit + <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit + <var-prefix>_WC_INFO - output of command `svn info <dir>' + +``Subversion_WC_LOG`` retrieves the log message of the base revision of a +subversion working copy at a given location. This macro defines the variable: + +:: + + <var-prefix>_LAST_CHANGED_LOG - last log of base revision + +Example usage: + +:: + + find_package(Subversion) + if(SUBVERSION_FOUND) + Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) + message("Current revision is ${Project_WC_REVISION}") + Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) + message("Last changed log is ${Project_LAST_CHANGED_LOG}") + endif() +#]=======================================================================] find_program(Subversion_SVN_EXECUTABLE svn PATHS diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index ad16e0d..be47c39 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -1,48 +1,49 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindTCL -# ------- -# -# TK_INTERNAL_PATH was removed. -# -# This module finds if Tcl is installed and determines where the include -# files and libraries are. It also determines what the name of the -# library is. This code sets the following variables: -# -# :: -# -# TCL_FOUND = Tcl was found -# TK_FOUND = Tk was found -# TCLTK_FOUND = Tcl and Tk were found -# TCL_LIBRARY = path to Tcl library (tcl tcl80) -# TCL_INCLUDE_PATH = path to where tcl.h can be found -# TCL_TCLSH = path to tclsh binary (tcl tcl80) -# TK_LIBRARY = path to Tk library (tk tk80 etc) -# TK_INCLUDE_PATH = path to where tk.h can be found -# TK_WISH = full path to the wish executable -# -# -# -# In an effort to remove some clutter and clear up some issues for -# people who are not necessarily Tcl/Tk gurus/developers, some -# variables were moved or removed. Changes compared to CMake 2.4 are: -# -# :: -# -# => they were only useful for people writing Tcl/Tk extensions. -# => these libs are not packaged by default with Tcl/Tk distributions. -# Even when Tcl/Tk is built from source, several flavors of debug libs -# are created and there is no real reason to pick a single one -# specifically (say, amongst tcl84g, tcl84gs, or tcl84sgx). -# Let's leave that choice to the user by allowing him to assign -# TCL_LIBRARY to any Tcl library, debug or not. -# => this ended up being only a Win32 variable, and there is a lot of -# confusion regarding the location of this file in an installed Tcl/Tk -# tree anyway (see 8.5 for example). If you need the internal path at -# this point it is safer you ask directly where the *source* tree is -# and dig from there. +#[=======================================================================[.rst: +FindTCL +------- + +TK_INTERNAL_PATH was removed. + +This module finds if Tcl is installed and determines where the include +files and libraries are. It also determines what the name of the +library is. This code sets the following variables: + +:: + + TCL_FOUND = Tcl was found + TK_FOUND = Tk was found + TCLTK_FOUND = Tcl and Tk were found + TCL_LIBRARY = path to Tcl library (tcl tcl80) + TCL_INCLUDE_PATH = path to where tcl.h can be found + TCL_TCLSH = path to tclsh binary (tcl tcl80) + TK_LIBRARY = path to Tk library (tk tk80 etc) + TK_INCLUDE_PATH = path to where tk.h can be found + TK_WISH = full path to the wish executable + + + +In an effort to remove some clutter and clear up some issues for +people who are not necessarily Tcl/Tk gurus/developers, some +variables were moved or removed. Changes compared to CMake 2.4 are: + +:: + + => they were only useful for people writing Tcl/Tk extensions. + => these libs are not packaged by default with Tcl/Tk distributions. + Even when Tcl/Tk is built from source, several flavors of debug libs + are created and there is no real reason to pick a single one + specifically (say, amongst tcl84g, tcl84gs, or tcl84sgx). + Let's leave that choice to the user by allowing him to assign + TCL_LIBRARY to any Tcl library, debug or not. + => this ended up being only a Win32 variable, and there is a lot of + confusion regarding the location of this file in an installed Tcl/Tk + tree anyway (see 8.5 for example). If you need the internal path at + this point it is safer you ask directly where the *source* tree is + and dig from there. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindTclsh.cmake) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index b622ca6..63ca936 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -1,43 +1,44 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindTIFF -# -------- -# -# Find the TIFF library (libtiff). -# -# Imported targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``TIFF::TIFF`` -# The TIFF library, if found. -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``TIFF_FOUND`` -# true if the TIFF headers and libraries were found -# ``TIFF_INCLUDE_DIR`` -# the directory containing the TIFF headers -# ``TIFF_INCLUDE_DIRS`` -# the directory containing the TIFF headers -# ``TIFF_LIBRARIES`` -# TIFF libraries to be linked -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``TIFF_INCLUDE_DIR`` -# the directory containing the TIFF headers -# ``TIFF_LIBRARY`` -# the path to the TIFF library +#[=======================================================================[.rst: +FindTIFF +-------- + +Find the TIFF library (libtiff). + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``TIFF::TIFF`` + The TIFF library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``TIFF_FOUND`` + true if the TIFF headers and libraries were found +``TIFF_INCLUDE_DIR`` + the directory containing the TIFF headers +``TIFF_INCLUDE_DIRS`` + the directory containing the TIFF headers +``TIFF_LIBRARIES`` + TIFF libraries to be linked + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``TIFF_INCLUDE_DIR`` + the directory containing the TIFF headers +``TIFF_LIBRARY`` + the path to the TIFF library +#]=======================================================================] find_path(TIFF_INCLUDE_DIR tiff.h) diff --git a/Modules/FindTclStub.cmake b/Modules/FindTclStub.cmake index db0a7a1..8f63480 100644 --- a/Modules/FindTclStub.cmake +++ b/Modules/FindTclStub.cmake @@ -1,48 +1,49 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindTclStub -# ----------- -# -# TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed. -# -# This module finds Tcl stub libraries. It first finds Tcl include -# files and libraries by calling FindTCL.cmake. How to Use the Tcl -# Stubs Library: -# -# :: -# -# http://tcl.activestate.com/doc/howto/stubs.html -# -# Using Stub Libraries: -# -# :: -# -# http://safari.oreilly.com/0130385603/ch48lev1sec3 -# -# This code sets the following variables: -# -# :: -# -# TCL_STUB_LIBRARY = path to Tcl stub library -# TK_STUB_LIBRARY = path to Tk stub library -# TTK_STUB_LIBRARY = path to ttk stub library -# -# -# -# In an effort to remove some clutter and clear up some issues for -# people who are not necessarily Tcl/Tk gurus/developers, some -# variables were moved or removed. Changes compared to CMake 2.4 are: -# -# :: -# -# => these libs are not packaged by default with Tcl/Tk distributions. -# Even when Tcl/Tk is built from source, several flavors of debug libs -# are created and there is no real reason to pick a single one -# specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx). -# Let's leave that choice to the user by allowing him to assign -# TCL_STUB_LIBRARY to any Tcl library, debug or not. +#[=======================================================================[.rst: +FindTclStub +----------- + +TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed. + +This module finds Tcl stub libraries. It first finds Tcl include +files and libraries by calling FindTCL.cmake. How to Use the Tcl +Stubs Library: + +:: + + http://tcl.activestate.com/doc/howto/stubs.html + +Using Stub Libraries: + +:: + + http://safari.oreilly.com/0130385603/ch48lev1sec3 + +This code sets the following variables: + +:: + + TCL_STUB_LIBRARY = path to Tcl stub library + TK_STUB_LIBRARY = path to Tk stub library + TTK_STUB_LIBRARY = path to ttk stub library + + + +In an effort to remove some clutter and clear up some issues for +people who are not necessarily Tcl/Tk gurus/developers, some +variables were moved or removed. Changes compared to CMake 2.4 are: + +:: + + => these libs are not packaged by default with Tcl/Tk distributions. + Even when Tcl/Tk is built from source, several flavors of debug libs + are created and there is no real reason to pick a single one + specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx). + Let's leave that choice to the user by allowing him to assign + TCL_STUB_LIBRARY to any Tcl library, debug or not. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindTCL.cmake) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 9bf935d..e3bd110 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -1,23 +1,24 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindTclsh -# --------- -# -# Find tclsh -# -# This module finds if TCL is installed and determines where the include -# files and libraries are. It also determines what the name of the -# library is. This code sets the following variables: -# -# :: -# -# TCLSH_FOUND = TRUE if tclsh has been found -# TCL_TCLSH = the path to the tclsh executable -# -# In cygwin, look for the cygwin version first. Don't look for it later -# to avoid finding the cygwin version on a Win32 build. +#[=======================================================================[.rst: +FindTclsh +--------- + +Find tclsh + +This module finds if TCL is installed and determines where the include +files and libraries are. It also determines what the name of the +library is. This code sets the following variables: + +:: + + TCLSH_FOUND = TRUE if tclsh has been found + TCL_TCLSH = the path to the tclsh executable + +In cygwin, look for the cygwin version first. Don't look for it later +to avoid finding the cygwin version on a Win32 build. +#]=======================================================================] if(CYGWIN) find_program(TCL_TCLSH NAMES cygtclsh83 cygtclsh80) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a0148dd..dfb683f 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -1,44 +1,45 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindThreads -# ----------- -# -# This module determines the thread library of the system. -# -# The following variables are set -# -# :: -# -# CMAKE_THREAD_LIBS_INIT - the thread library -# CMAKE_USE_SPROC_INIT - are we using sproc? -# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads? -# CMAKE_USE_PTHREADS_INIT - are we using pthreads -# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads -# -# The following import target is created -# -# :: -# -# Threads::Threads -# -# For systems with multiple thread libraries, caller can set -# -# :: -# -# CMAKE_THREAD_PREFER_PTHREAD -# -# If the use of the -pthread compiler and linker flag is preferred then the -# caller can set -# -# :: -# -# THREADS_PREFER_PTHREAD_FLAG -# -# Please note that the compiler flag can only be used with the imported -# target. Use of both the imported target as well as this switch is highly -# recommended for new code. +#[=======================================================================[.rst: +FindThreads +----------- + +This module determines the thread library of the system. + +The following variables are set + +:: + + CMAKE_THREAD_LIBS_INIT - the thread library + CMAKE_USE_SPROC_INIT - are we using sproc? + CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads? + CMAKE_USE_PTHREADS_INIT - are we using pthreads + CMAKE_HP_PTHREADS_INIT - are we using hp pthreads + +The following import target is created + +:: + + Threads::Threads + +For systems with multiple thread libraries, caller can set + +:: + + CMAKE_THREAD_PREFER_PTHREAD + +If the use of the -pthread compiler and linker flag is preferred then the +caller can set + +:: + + THREADS_PREFER_PTHREAD_FLAG + +Please note that the compiler flag can only be used with the imported +target. Use of both the imported target as well as this switch is highly +recommended for new code. +#]=======================================================================] include (CheckLibraryExists) include (CheckSymbolExists) @@ -208,7 +209,9 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads) add_library(Threads::Threads INTERFACE IMPORTED) if(THREADS_HAVE_PTHREAD_ARG) - set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") + set_property(TARGET Threads::Threads + PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -pthread>" + "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>") endif() if(CMAKE_THREAD_LIBS_INIT) diff --git a/Modules/FindUnixCommands.cmake b/Modules/FindUnixCommands.cmake index 45047a9..3a735f7 100644 --- a/Modules/FindUnixCommands.cmake +++ b/Modules/FindUnixCommands.cmake @@ -1,14 +1,15 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindUnixCommands -# ---------------- -# -# Find Unix commands, including the ones from Cygwin -# -# This module looks for the Unix commands bash, cp, gzip, mv, rm, and tar -# and stores the result in the variables BASH, CP, GZIP, MV, RM, and TAR. +#[=======================================================================[.rst: +FindUnixCommands +---------------- + +Find Unix commands, including the ones from Cygwin + +This module looks for the Unix commands bash, cp, gzip, mv, rm, and tar +and stores the result in the variables BASH, CP, GZIP, MV, RM, and TAR. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 4c60ed7..b1201b4 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -1,32 +1,33 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindVulkan -# ---------- -# -# Try to find Vulkan -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if -# Vulkan has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables:: -# -# Vulkan_FOUND - True if Vulkan was found -# Vulkan_INCLUDE_DIRS - include directories for Vulkan -# Vulkan_LIBRARIES - link against this library to use Vulkan -# -# The module will also define two cache variables:: -# -# Vulkan_INCLUDE_DIR - the Vulkan include directory -# Vulkan_LIBRARY - the path to the Vulkan library -# +#[=======================================================================[.rst: +FindVulkan +---------- + +Try to find Vulkan + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if +Vulkan has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables:: + + Vulkan_FOUND - True if Vulkan was found + Vulkan_INCLUDE_DIRS - include directories for Vulkan + Vulkan_LIBRARIES - link against this library to use Vulkan + +The module will also define two cache variables:: + + Vulkan_INCLUDE_DIR - the Vulkan include directory + Vulkan_LIBRARY - the path to the Vulkan library + +#]=======================================================================] if(WIN32) find_path(Vulkan_INCLUDE_DIR diff --git a/Modules/FindWget.cmake b/Modules/FindWget.cmake index 4fcb2fa..bd01ec2 100644 --- a/Modules/FindWget.cmake +++ b/Modules/FindWget.cmake @@ -1,18 +1,19 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindWget -# -------- -# -# Find wget -# -# This module looks for wget. This module defines the following values: -# -# :: -# -# WGET_EXECUTABLE: the full path to the wget tool. -# WGET_FOUND: True if wget has been found. +#[=======================================================================[.rst: +FindWget +-------- + +Find wget + +This module looks for wget. This module defines the following values: + +:: + + WGET_EXECUTABLE: the full path to the wget tool. + WGET_FOUND: True if wget has been found. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) diff --git a/Modules/FindWish.cmake b/Modules/FindWish.cmake index b64b041..b332bde 100644 --- a/Modules/FindWish.cmake +++ b/Modules/FindWish.cmake @@ -1,23 +1,24 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindWish -# -------- -# -# Find wish installation -# -# This module finds if TCL is installed and determines where the include -# files and libraries are. It also determines what the name of the -# library is. This code sets the following variables: -# -# :: -# -# TK_WISH = the path to the wish executable -# -# -# -# if UNIX is defined, then it will look for the cygwin version first +#[=======================================================================[.rst: +FindWish +-------- + +Find wish installation + +This module finds if TCL is installed and determines where the include +files and libraries are. It also determines what the name of the +library is. This code sets the following variables: + +:: + + TK_WISH = the path to the wish executable + + + +if UNIX is defined, then it will look for the cygwin version first +#]=======================================================================] if(UNIX) find_program(TK_WISH cygwish80 ) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index f7dfc82..232804a 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -1,58 +1,59 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindX11 -# ------- -# -# Find X11 installation -# -# Try to find X11 on UNIX systems. The following values are defined -# -# :: -# -# X11_FOUND - True if X11 is available -# X11_INCLUDE_DIR - include directories to use X11 -# X11_LIBRARIES - link against these to use X11 -# -# and also the following more fine grained variables: -# -# :: -# -# X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND -# X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND -# X11_X11_INCLUDE_PATH, X11_X11_LIB -# X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND -# X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND -# X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND -# X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND -# X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND -# X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND -# X11_Xdmcp_INCLUDE_PATH, X11_Xdmcp_LIB, X11_Xdmcp_FOUND -# X11_Xext_LIB, X11_Xext_FOUND -# X11_dpms_INCLUDE_PATH, (in X11_Xext_LIB), X11_dpms_FOUND -# X11_XShm_INCLUDE_PATH, (in X11_Xext_LIB), X11_XShm_FOUND -# X11_Xshape_INCLUDE_PATH, (in X11_Xext_LIB), X11_Xshape_FOUND -# X11_xf86misc_INCLUDE_PATH, X11_Xxf86misc_LIB, X11_xf86misc_FOUND -# X11_xf86vmode_INCLUDE_PATH, X11_Xxf86vm_LIB X11_xf86vmode_FOUND -# X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND -# X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND -# X11_Xi_INCLUDE_PATH, X11_Xi_LIB, X11_Xi_FOUND -# X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND -# X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND -# X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND -# X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND -# X11_Xkbfile_INCLUDE_PATH, X11_Xkbfile_LIB, X11_Xkbfile_FOUND -# X11_Xmu_INCLUDE_PATH, X11_Xmu_LIB, X11_Xmu_FOUND -# X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND -# X11_XTest_INCLUDE_PATH, X11_XTest_LIB, X11_XTest_FOUND -# X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND -# X11_Xrender_INCLUDE_PATH, X11_Xrender_LIB, X11_Xrender_FOUND -# X11_Xscreensaver_INCLUDE_PATH, X11_Xscreensaver_LIB, X11_Xscreensaver_FOUND -# X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND -# X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND -# X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND -# X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND +#[=======================================================================[.rst: +FindX11 +------- + +Find X11 installation + +Try to find X11 on UNIX systems. The following values are defined + +:: + + X11_FOUND - True if X11 is available + X11_INCLUDE_DIR - include directories to use X11 + X11_LIBRARIES - link against these to use X11 + +and also the following more fine grained variables: + +:: + + X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND + X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND + X11_X11_INCLUDE_PATH, X11_X11_LIB + X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND + X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND + X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND + X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND + X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND + X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND + X11_Xdmcp_INCLUDE_PATH, X11_Xdmcp_LIB, X11_Xdmcp_FOUND + X11_Xext_LIB, X11_Xext_FOUND + X11_dpms_INCLUDE_PATH, (in X11_Xext_LIB), X11_dpms_FOUND + X11_XShm_INCLUDE_PATH, (in X11_Xext_LIB), X11_XShm_FOUND + X11_Xshape_INCLUDE_PATH, (in X11_Xext_LIB), X11_Xshape_FOUND + X11_xf86misc_INCLUDE_PATH, X11_Xxf86misc_LIB, X11_xf86misc_FOUND + X11_xf86vmode_INCLUDE_PATH, X11_Xxf86vm_LIB X11_xf86vmode_FOUND + X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND + X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND + X11_Xi_INCLUDE_PATH, X11_Xi_LIB, X11_Xi_FOUND + X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND + X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND + X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND + X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND + X11_Xkbfile_INCLUDE_PATH, X11_Xkbfile_LIB, X11_Xkbfile_FOUND + X11_Xmu_INCLUDE_PATH, X11_Xmu_LIB, X11_Xmu_FOUND + X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND + X11_XTest_INCLUDE_PATH, X11_XTest_LIB, X11_XTest_FOUND + X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND + X11_Xrender_INCLUDE_PATH, X11_Xrender_LIB, X11_Xrender_FOUND + X11_Xscreensaver_INCLUDE_PATH, X11_Xscreensaver_LIB, X11_Xscreensaver_FOUND + X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND + X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND + X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND + X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND +#]=======================================================================] if (UNIX) set(X11_FOUND 0) diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake index e7ae919..69e6df2 100644 --- a/Modules/FindXMLRPC.cmake +++ b/Modules/FindXMLRPC.cmake @@ -1,35 +1,36 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindXMLRPC -# ---------- -# -# Find xmlrpc -# -# Find the native XMLRPC headers and libraries. -# -# :: -# -# XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc. -# XMLRPC_LIBRARIES - List of libraries when using xmlrpc. -# XMLRPC_FOUND - True if xmlrpc found. -# -# XMLRPC modules may be specified as components for this find module. -# Modules may be listed by running "xmlrpc-c-config". Modules include: -# -# :: -# -# c++ C++ wrapper code -# libwww-client libwww-based client -# cgi-server CGI-based server -# abyss-server ABYSS-based server -# -# Typical usage: -# -# :: -# -# find_package(XMLRPC REQUIRED libwww-client) +#[=======================================================================[.rst: +FindXMLRPC +---------- + +Find xmlrpc + +Find the native XMLRPC headers and libraries. + +:: + + XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc. + XMLRPC_LIBRARIES - List of libraries when using xmlrpc. + XMLRPC_FOUND - True if xmlrpc found. + +XMLRPC modules may be specified as components for this find module. +Modules may be listed by running "xmlrpc-c-config". Modules include: + +:: + + c++ C++ wrapper code + libwww-client libwww-based client + cgi-server CGI-based server + abyss-server ABYSS-based server + +Typical usage: + +:: + + find_package(XMLRPC REQUIRED libwww-client) +#]=======================================================================] # First find the config script from which to obtain other values. find_program(XMLRPC_C_CONFIG NAMES xmlrpc-c-config) diff --git a/Modules/FindXalanC.cmake b/Modules/FindXalanC.cmake index 1951b49..0eba3d9 100644 --- a/Modules/FindXalanC.cmake +++ b/Modules/FindXalanC.cmake @@ -1,45 +1,46 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindXalanC -# ----------- -# -# Find the Apache Xalan-C++ XSL transform processor headers and libraries. -# -# Imported targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``XalanC::XalanC`` -# The Xalan-C++ ``xalan-c`` library, if found. -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``XalanC_FOUND`` -# true if the Xalan headers and libraries were found -# ``XalanC_VERSION`` -# Xalan release version -# ``XalanC_INCLUDE_DIRS`` -# the directory containing the Xalan headers; note -# ``XercesC_INCLUDE_DIRS`` is also required -# ``XalanC_LIBRARIES`` -# Xalan libraries to be linked; note ``XercesC_LIBRARIES`` is also -# required -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``XalanC_INCLUDE_DIR`` -# the directory containing the Xalan headers -# ``XalanC_LIBRARY`` -# the Xalan library +#[=======================================================================[.rst: +FindXalanC +----------- + +Find the Apache Xalan-C++ XSL transform processor headers and libraries. + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``XalanC::XalanC`` + The Xalan-C++ ``xalan-c`` library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``XalanC_FOUND`` + true if the Xalan headers and libraries were found +``XalanC_VERSION`` + Xalan release version +``XalanC_INCLUDE_DIRS`` + the directory containing the Xalan headers; note + ``XercesC_INCLUDE_DIRS`` is also required +``XalanC_LIBRARIES`` + Xalan libraries to be linked; note ``XercesC_LIBRARIES`` is also + required + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``XalanC_INCLUDE_DIR`` + the directory containing the Xalan headers +``XalanC_LIBRARY`` + the Xalan library +#]=======================================================================] # Written by Roger Leigh <rleigh@codelibre.net> diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake index 55db7ae..085fafc 100644 --- a/Modules/FindXercesC.cmake +++ b/Modules/FindXercesC.cmake @@ -1,43 +1,44 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindXercesC -# ----------- -# -# Find the Apache Xerces-C++ validating XML parser headers and libraries. -# -# Imported targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following :prop_tgt:`IMPORTED` targets: -# -# ``XercesC::XercesC`` -# The Xerces-C++ ``xerces-c`` library, if found. -# -# Result variables -# ^^^^^^^^^^^^^^^^ -# -# This module will set the following variables in your project: -# -# ``XercesC_FOUND`` -# true if the Xerces headers and libraries were found -# ``XercesC_VERSION`` -# Xerces release version -# ``XercesC_INCLUDE_DIRS`` -# the directory containing the Xerces headers -# ``XercesC_LIBRARIES`` -# Xerces libraries to be linked -# -# Cache variables -# ^^^^^^^^^^^^^^^ -# -# The following cache variables may also be set: -# -# ``XercesC_INCLUDE_DIR`` -# the directory containing the Xerces headers -# ``XercesC_LIBRARY`` -# the Xerces library +#[=======================================================================[.rst: +FindXercesC +----------- + +Find the Apache Xerces-C++ validating XML parser headers and libraries. + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``XercesC::XercesC`` + The Xerces-C++ ``xerces-c`` library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``XercesC_FOUND`` + true if the Xerces headers and libraries were found +``XercesC_VERSION`` + Xerces release version +``XercesC_INCLUDE_DIRS`` + the directory containing the Xerces headers +``XercesC_LIBRARIES`` + Xerces libraries to be linked + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``XercesC_INCLUDE_DIR`` + the directory containing the Xerces headers +``XercesC_LIBRARY`` + the Xerces library +#]=======================================================================] # Written by Roger Leigh <rleigh@codelibre.net> diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 1a4635a..790eb42 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -1,53 +1,54 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindZLIB -# -------- -# -# Find the native ZLIB includes and library. -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# This module defines :prop_tgt:`IMPORTED` target ``ZLIB::ZLIB``, if -# ZLIB has been found. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# :: -# -# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. -# ZLIB_LIBRARIES - List of libraries when using zlib. -# ZLIB_FOUND - True if zlib found. -# -# :: -# -# ZLIB_VERSION_STRING - The version of zlib found (x.y.z) -# ZLIB_VERSION_MAJOR - The major version of zlib -# ZLIB_VERSION_MINOR - The minor version of zlib -# ZLIB_VERSION_PATCH - The patch version of zlib -# ZLIB_VERSION_TWEAK - The tweak version of zlib -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# The following variable are provided for backward compatibility -# -# :: -# -# ZLIB_MAJOR_VERSION - The major version of zlib -# ZLIB_MINOR_VERSION - The minor version of zlib -# ZLIB_PATCH_VERSION - The patch version of zlib -# -# Hints -# ^^^^^ -# -# A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this -# module where to look. +#[=======================================================================[.rst: +FindZLIB +-------- + +Find the native ZLIB includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``ZLIB::ZLIB``, if +ZLIB has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. + ZLIB_LIBRARIES - List of libraries when using zlib. + ZLIB_FOUND - True if zlib found. + +:: + + ZLIB_VERSION_STRING - The version of zlib found (x.y.z) + ZLIB_VERSION_MAJOR - The major version of zlib + ZLIB_VERSION_MINOR - The minor version of zlib + ZLIB_VERSION_PATCH - The patch version of zlib + ZLIB_VERSION_TWEAK - The tweak version of zlib + +Backward Compatibility +^^^^^^^^^^^^^^^^^^^^^^ + +The following variable are provided for backward compatibility + +:: + + ZLIB_MAJOR_VERSION - The major version of zlib + ZLIB_MINOR_VERSION - The minor version of zlib + ZLIB_PATCH_VERSION - The patch version of zlib + +Hints +^^^^^ + +A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this +module where to look. +#]=======================================================================] set(_ZLIB_SEARCHES) diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake index 474ea82..bb28454 100644 --- a/Modules/Findosg.cmake +++ b/Modules/Findosg.cmake @@ -1,42 +1,43 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Findosg -# ------- -# -# -# -# -# -# NOTE: It is highly recommended that you use the new -# FindOpenSceneGraph.cmake introduced in CMake 2.6.3 and not use this -# Find module directly. -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osg This module defines -# -# OSG_FOUND - Was the Osg found? OSG_INCLUDE_DIR - Where to find the -# headers OSG_LIBRARIES - The libraries to link against for the OSG (use -# this) -# -# OSG_LIBRARY - The OSG library OSG_LIBRARY_DEBUG - The OSG debug -# library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +Findosg +------- + + + + + +NOTE: It is highly recommended that you use the new +FindOpenSceneGraph.cmake introduced in CMake 2.6.3 and not use this +Find module directly. + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osg This module defines + +OSG_FOUND - Was the Osg found? OSG_INCLUDE_DIR - Where to find the +headers OSG_LIBRARIES - The libraries to link against for the OSG (use +this) + +OSG_LIBRARY - The OSG library OSG_LIBRARY_DEBUG - The OSG debug +library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgAnimation.cmake b/Modules/FindosgAnimation.cmake index 5b26b64..65e3016 100644 --- a/Modules/FindosgAnimation.cmake +++ b/Modules/FindosgAnimation.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgAnimation -# ---------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgAnimation This module defines -# -# OSGANIMATION_FOUND - Was osgAnimation found? OSGANIMATION_INCLUDE_DIR -# - Where to find the headers OSGANIMATION_LIBRARIES - The libraries to -# link against for the OSG (use this) -# -# OSGANIMATION_LIBRARY - The OSG library OSGANIMATION_LIBRARY_DEBUG - -# The OSG debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgAnimation +---------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgAnimation This module defines + +OSGANIMATION_FOUND - Was osgAnimation found? OSGANIMATION_INCLUDE_DIR +- Where to find the headers OSGANIMATION_LIBRARIES - The libraries to +link against for the OSG (use this) + +OSGANIMATION_LIBRARY - The OSG library OSGANIMATION_LIBRARY_DEBUG - +The OSG debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake index 6ddf53c..d0789ba 100644 --- a/Modules/FindosgDB.cmake +++ b/Modules/FindosgDB.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgDB -# --------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgDB This module defines -# -# OSGDB_FOUND - Was osgDB found? OSGDB_INCLUDE_DIR - Where to find the -# headers OSGDB_LIBRARIES - The libraries to link against for the osgDB -# (use this) -# -# OSGDB_LIBRARY - The osgDB library OSGDB_LIBRARY_DEBUG - The osgDB -# debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgDB +--------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgDB This module defines + +OSGDB_FOUND - Was osgDB found? OSGDB_INCLUDE_DIR - Where to find the +headers OSGDB_LIBRARIES - The libraries to link against for the osgDB +(use this) + +OSGDB_LIBRARY - The osgDB library OSGDB_LIBRARY_DEBUG - The osgDB +debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgFX.cmake b/Modules/FindosgFX.cmake index e4bc276..438fab7 100644 --- a/Modules/FindosgFX.cmake +++ b/Modules/FindosgFX.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgFX -# --------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgFX This module defines -# -# OSGFX_FOUND - Was osgFX found? OSGFX_INCLUDE_DIR - Where to find the -# headers OSGFX_LIBRARIES - The libraries to link against for the osgFX -# (use this) -# -# OSGFX_LIBRARY - The osgFX library OSGFX_LIBRARY_DEBUG - The osgFX -# debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgFX +--------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgFX This module defines + +OSGFX_FOUND - Was osgFX found? OSGFX_INCLUDE_DIR - Where to find the +headers OSGFX_LIBRARIES - The libraries to link against for the osgFX +(use this) + +OSGFX_LIBRARY - The osgFX library OSGFX_LIBRARY_DEBUG - The osgFX +debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgGA.cmake b/Modules/FindosgGA.cmake index 97adeb7..7b6ef30 100644 --- a/Modules/FindosgGA.cmake +++ b/Modules/FindosgGA.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgGA -# --------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgGA This module defines -# -# OSGGA_FOUND - Was osgGA found? OSGGA_INCLUDE_DIR - Where to find the -# headers OSGGA_LIBRARIES - The libraries to link against for the osgGA -# (use this) -# -# OSGGA_LIBRARY - The osgGA library OSGGA_LIBRARY_DEBUG - The osgGA -# debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgGA +--------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgGA This module defines + +OSGGA_FOUND - Was osgGA found? OSGGA_INCLUDE_DIR - Where to find the +headers OSGGA_LIBRARIES - The libraries to link against for the osgGA +(use this) + +OSGGA_LIBRARY - The osgGA library OSGGA_LIBRARY_DEBUG - The osgGA +debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgIntrospection.cmake b/Modules/FindosgIntrospection.cmake index e735942..625e4c2 100644 --- a/Modules/FindosgIntrospection.cmake +++ b/Modules/FindosgIntrospection.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgIntrospection -# -------------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgINTROSPECTION This module defines -# -# OSGINTROSPECTION_FOUND - Was osgIntrospection found? -# OSGINTROSPECTION_INCLUDE_DIR - Where to find the headers -# OSGINTROSPECTION_LIBRARIES - The libraries to link for -# osgIntrospection (use this) -# -# OSGINTROSPECTION_LIBRARY - The osgIntrospection library -# OSGINTROSPECTION_LIBRARY_DEBUG - The osgIntrospection debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgIntrospection +-------------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgINTROSPECTION This module defines + +OSGINTROSPECTION_FOUND - Was osgIntrospection found? +OSGINTROSPECTION_INCLUDE_DIR - Where to find the headers +OSGINTROSPECTION_LIBRARIES - The libraries to link for +osgIntrospection (use this) + +OSGINTROSPECTION_LIBRARY - The osgIntrospection library +OSGINTROSPECTION_LIBRARY_DEBUG - The osgIntrospection debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgManipulator.cmake b/Modules/FindosgManipulator.cmake index b88f1a4..857ff5d 100644 --- a/Modules/FindosgManipulator.cmake +++ b/Modules/FindosgManipulator.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgManipulator -# ------------------ -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgManipulator This module defines -# -# OSGMANIPULATOR_FOUND - Was osgManipulator found? -# OSGMANIPULATOR_INCLUDE_DIR - Where to find the headers -# OSGMANIPULATOR_LIBRARIES - The libraries to link for osgManipulator -# (use this) -# -# OSGMANIPULATOR_LIBRARY - The osgManipulator library -# OSGMANIPULATOR_LIBRARY_DEBUG - The osgManipulator debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgManipulator +------------------ + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgManipulator This module defines + +OSGMANIPULATOR_FOUND - Was osgManipulator found? +OSGMANIPULATOR_INCLUDE_DIR - Where to find the headers +OSGMANIPULATOR_LIBRARIES - The libraries to link for osgManipulator +(use this) + +OSGMANIPULATOR_LIBRARY - The osgManipulator library +OSGMANIPULATOR_LIBRARY_DEBUG - The osgManipulator debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgParticle.cmake b/Modules/FindosgParticle.cmake index 059746a..91a30dc 100644 --- a/Modules/FindosgParticle.cmake +++ b/Modules/FindosgParticle.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgParticle -# --------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgParticle This module defines -# -# OSGPARTICLE_FOUND - Was osgParticle found? OSGPARTICLE_INCLUDE_DIR - -# Where to find the headers OSGPARTICLE_LIBRARIES - The libraries to -# link for osgParticle (use this) -# -# OSGPARTICLE_LIBRARY - The osgParticle library -# OSGPARTICLE_LIBRARY_DEBUG - The osgParticle debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgParticle +--------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgParticle This module defines + +OSGPARTICLE_FOUND - Was osgParticle found? OSGPARTICLE_INCLUDE_DIR - +Where to find the headers OSGPARTICLE_LIBRARIES - The libraries to +link for osgParticle (use this) + +OSGPARTICLE_LIBRARY - The osgParticle library +OSGPARTICLE_LIBRARY_DEBUG - The osgParticle debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgPresentation.cmake b/Modules/FindosgPresentation.cmake index 84a4105..eae75d6 100644 --- a/Modules/FindosgPresentation.cmake +++ b/Modules/FindosgPresentation.cmake @@ -1,38 +1,39 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgPresentation -# ------------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgPresentation This module defines -# -# OSGPRESENTATION_FOUND - Was osgPresentation found? -# OSGPRESENTATION_INCLUDE_DIR - Where to find the headers -# OSGPRESENTATION_LIBRARIES - The libraries to link for osgPresentation -# (use this) -# -# OSGPRESENTATION_LIBRARY - The osgPresentation library -# OSGPRESENTATION_LIBRARY_DEBUG - The osgPresentation debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. Modified to work with osgPresentation by Robert -# Osfield, January 2012. +#[=======================================================================[.rst: +FindosgPresentation +------------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgPresentation This module defines + +OSGPRESENTATION_FOUND - Was osgPresentation found? +OSGPRESENTATION_INCLUDE_DIR - Where to find the headers +OSGPRESENTATION_LIBRARIES - The libraries to link for osgPresentation +(use this) + +OSGPRESENTATION_LIBRARY - The osgPresentation library +OSGPRESENTATION_LIBRARY_DEBUG - The osgPresentation debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. Modified to work with osgPresentation by Robert +Osfield, January 2012. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgProducer.cmake b/Modules/FindosgProducer.cmake index e5700bf..33b9f73 100644 --- a/Modules/FindosgProducer.cmake +++ b/Modules/FindosgProducer.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgProducer -# --------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgProducer This module defines -# -# OSGPRODUCER_FOUND - Was osgProducer found? OSGPRODUCER_INCLUDE_DIR - -# Where to find the headers OSGPRODUCER_LIBRARIES - The libraries to -# link for osgProducer (use this) -# -# OSGPRODUCER_LIBRARY - The osgProducer library -# OSGPRODUCER_LIBRARY_DEBUG - The osgProducer debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgProducer +--------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgProducer This module defines + +OSGPRODUCER_FOUND - Was osgProducer found? OSGPRODUCER_INCLUDE_DIR - +Where to find the headers OSGPRODUCER_LIBRARIES - The libraries to +link for osgProducer (use this) + +OSGPRODUCER_LIBRARY - The osgProducer library +OSGPRODUCER_LIBRARY_DEBUG - The osgProducer debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgQt.cmake b/Modules/FindosgQt.cmake index 04a2393..cf35630 100644 --- a/Modules/FindosgQt.cmake +++ b/Modules/FindosgQt.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgQt -# --------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgQt This module defines -# -# OSGQT_FOUND - Was osgQt found? OSGQT_INCLUDE_DIR - Where to find the -# headers OSGQT_LIBRARIES - The libraries to link for osgQt (use this) -# -# OSGQT_LIBRARY - The osgQt library OSGQT_LIBRARY_DEBUG - The osgQt -# debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. Modified to work with osgQt by Robert Osfield, -# January 2012. +#[=======================================================================[.rst: +FindosgQt +--------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgQt This module defines + +OSGQT_FOUND - Was osgQt found? OSGQT_INCLUDE_DIR - Where to find the +headers OSGQT_LIBRARIES - The libraries to link for osgQt (use this) + +OSGQT_LIBRARY - The osgQt library OSGQT_LIBRARY_DEBUG - The osgQt +debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. Modified to work with osgQt by Robert Osfield, +January 2012. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgShadow.cmake b/Modules/FindosgShadow.cmake index 0a7ba23..0049c4e 100644 --- a/Modules/FindosgShadow.cmake +++ b/Modules/FindosgShadow.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgShadow -# ------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgShadow This module defines -# -# OSGSHADOW_FOUND - Was osgShadow found? OSGSHADOW_INCLUDE_DIR - Where -# to find the headers OSGSHADOW_LIBRARIES - The libraries to link for -# osgShadow (use this) -# -# OSGSHADOW_LIBRARY - The osgShadow library OSGSHADOW_LIBRARY_DEBUG - -# The osgShadow debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgShadow +------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgShadow This module defines + +OSGSHADOW_FOUND - Was osgShadow found? OSGSHADOW_INCLUDE_DIR - Where +to find the headers OSGSHADOW_LIBRARIES - The libraries to link for +osgShadow (use this) + +OSGSHADOW_LIBRARY - The osgShadow library OSGSHADOW_LIBRARY_DEBUG - +The osgShadow debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgSim.cmake b/Modules/FindosgSim.cmake index 15426a2..43ba542 100644 --- a/Modules/FindosgSim.cmake +++ b/Modules/FindosgSim.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgSim -# ---------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgSim This module defines -# -# OSGSIM_FOUND - Was osgSim found? OSGSIM_INCLUDE_DIR - Where to find -# the headers OSGSIM_LIBRARIES - The libraries to link for osgSim (use -# this) -# -# OSGSIM_LIBRARY - The osgSim library OSGSIM_LIBRARY_DEBUG - The osgSim -# debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgSim +---------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgSim This module defines + +OSGSIM_FOUND - Was osgSim found? OSGSIM_INCLUDE_DIR - Where to find +the headers OSGSIM_LIBRARIES - The libraries to link for osgSim (use +this) + +OSGSIM_LIBRARY - The osgSim library OSGSIM_LIBRARY_DEBUG - The osgSim +debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgTerrain.cmake b/Modules/FindosgTerrain.cmake index 04eae14..c6f5b69 100644 --- a/Modules/FindosgTerrain.cmake +++ b/Modules/FindosgTerrain.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgTerrain -# -------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgTerrain This module defines -# -# OSGTERRAIN_FOUND - Was osgTerrain found? OSGTERRAIN_INCLUDE_DIR - -# Where to find the headers OSGTERRAIN_LIBRARIES - The libraries to link -# for osgTerrain (use this) -# -# OSGTERRAIN_LIBRARY - The osgTerrain library OSGTERRAIN_LIBRARY_DEBUG - -# The osgTerrain debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgTerrain +-------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgTerrain This module defines + +OSGTERRAIN_FOUND - Was osgTerrain found? OSGTERRAIN_INCLUDE_DIR - +Where to find the headers OSGTERRAIN_LIBRARIES - The libraries to link +for osgTerrain (use this) + +OSGTERRAIN_LIBRARY - The osgTerrain library OSGTERRAIN_LIBRARY_DEBUG - +The osgTerrain debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgText.cmake b/Modules/FindosgText.cmake index 1e2d9fd..fd3c232 100644 --- a/Modules/FindosgText.cmake +++ b/Modules/FindosgText.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgText -# ----------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgText This module defines -# -# OSGTEXT_FOUND - Was osgText found? OSGTEXT_INCLUDE_DIR - Where to find -# the headers OSGTEXT_LIBRARIES - The libraries to link for osgText (use -# this) -# -# OSGTEXT_LIBRARY - The osgText library OSGTEXT_LIBRARY_DEBUG - The -# osgText debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgText +----------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgText This module defines + +OSGTEXT_FOUND - Was osgText found? OSGTEXT_INCLUDE_DIR - Where to find +the headers OSGTEXT_LIBRARIES - The libraries to link for osgText (use +this) + +OSGTEXT_LIBRARY - The osgText library OSGTEXT_LIBRARY_DEBUG - The +osgText debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgUtil.cmake b/Modules/FindosgUtil.cmake index 13e0b80..e84727a 100644 --- a/Modules/FindosgUtil.cmake +++ b/Modules/FindosgUtil.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgUtil -# ----------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgUtil This module defines -# -# OSGUTIL_FOUND - Was osgUtil found? OSGUTIL_INCLUDE_DIR - Where to find -# the headers OSGUTIL_LIBRARIES - The libraries to link for osgUtil (use -# this) -# -# OSGUTIL_LIBRARY - The osgUtil library OSGUTIL_LIBRARY_DEBUG - The -# osgUtil debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgUtil +----------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgUtil This module defines + +OSGUTIL_FOUND - Was osgUtil found? OSGUTIL_INCLUDE_DIR - Where to find +the headers OSGUTIL_LIBRARIES - The libraries to link for osgUtil (use +this) + +OSGUTIL_LIBRARY - The osgUtil library OSGUTIL_LIBRARY_DEBUG - The +osgUtil debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgViewer.cmake b/Modules/FindosgViewer.cmake index a91c49c..2174357 100644 --- a/Modules/FindosgViewer.cmake +++ b/Modules/FindosgViewer.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgViewer -# ------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgViewer This module defines -# -# OSGVIEWER_FOUND - Was osgViewer found? OSGVIEWER_INCLUDE_DIR - Where -# to find the headers OSGVIEWER_LIBRARIES - The libraries to link for -# osgViewer (use this) -# -# OSGVIEWER_LIBRARY - The osgViewer library OSGVIEWER_LIBRARY_DEBUG - -# The osgViewer debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgViewer +------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgViewer This module defines + +OSGVIEWER_FOUND - Was osgViewer found? OSGVIEWER_INCLUDE_DIR - Where +to find the headers OSGVIEWER_LIBRARIES - The libraries to link for +osgViewer (use this) + +OSGVIEWER_LIBRARY - The osgViewer library OSGVIEWER_LIBRARY_DEBUG - +The osgViewer debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgVolume.cmake b/Modules/FindosgVolume.cmake index 1178ed3..35defef 100644 --- a/Modules/FindosgVolume.cmake +++ b/Modules/FindosgVolume.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgVolume -# ------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgVolume This module defines -# -# OSGVOLUME_FOUND - Was osgVolume found? OSGVOLUME_INCLUDE_DIR - Where -# to find the headers OSGVOLUME_LIBRARIES - The libraries to link for -# osgVolume (use this) -# -# OSGVOLUME_LIBRARY - The osgVolume library OSGVOLUME_LIBRARY_DEBUG - -# The osgVolume debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# Created by Eric Wing. +#[=======================================================================[.rst: +FindosgVolume +------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgVolume This module defines + +OSGVOLUME_FOUND - Was osgVolume found? OSGVOLUME_INCLUDE_DIR - Where +to find the headers OSGVOLUME_LIBRARIES - The libraries to link for +osgVolume (use this) + +OSGVOLUME_LIBRARY - The osgVolume library OSGVOLUME_LIBRARY_DEBUG - +The osgVolume debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +Created by Eric Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/FindosgWidget.cmake b/Modules/FindosgWidget.cmake index 78999ec..c7aae44 100644 --- a/Modules/FindosgWidget.cmake +++ b/Modules/FindosgWidget.cmake @@ -1,37 +1,38 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindosgWidget -# ------------- -# -# -# -# This is part of the Findosg* suite used to find OpenSceneGraph -# components. Each component is separate and you must opt in to each -# module. You must also opt into OpenGL and OpenThreads (and Producer -# if needed) as these modules won't do it for you. This is to allow you -# control over your own system piece by piece in case you need to opt -# out of certain components or change the Find behavior for a particular -# module (perhaps because the default FindOpenGL.cmake module doesn't -# work with your system as an example). If you want to use a more -# convenient module that includes everything, use the -# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. -# -# Locate osgWidget This module defines -# -# OSGWIDGET_FOUND - Was osgWidget found? OSGWIDGET_INCLUDE_DIR - Where -# to find the headers OSGWIDGET_LIBRARIES - The libraries to link for -# osgWidget (use this) -# -# OSGWIDGET_LIBRARY - The osgWidget library OSGWIDGET_LIBRARY_DEBUG - -# The osgWidget debug library -# -# $OSGDIR is an environment variable that would correspond to the -# ./configure --prefix=$OSGDIR used in building osg. -# -# FindosgWidget.cmake tweaked from Findosg* suite as created by Eric -# Wing. +#[=======================================================================[.rst: +FindosgWidget +------------- + + + +This is part of the Findosg* suite used to find OpenSceneGraph +components. Each component is separate and you must opt in to each +module. You must also opt into OpenGL and OpenThreads (and Producer +if needed) as these modules won't do it for you. This is to allow you +control over your own system piece by piece in case you need to opt +out of certain components or change the Find behavior for a particular +module (perhaps because the default FindOpenGL.cmake module doesn't +work with your system as an example). If you want to use a more +convenient module that includes everything, use the +FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. + +Locate osgWidget This module defines + +OSGWIDGET_FOUND - Was osgWidget found? OSGWIDGET_INCLUDE_DIR - Where +to find the headers OSGWIDGET_LIBRARIES - The libraries to link for +osgWidget (use this) + +OSGWIDGET_LIBRARY - The osgWidget library OSGWIDGET_LIBRARY_DEBUG - +The osgWidget debug library + +$OSGDIR is an environment variable that would correspond to the +./configure --prefix=$OSGDIR used in building osg. + +FindosgWidget.cmake tweaked from Findosg* suite as created by Eric +Wing. +#]=======================================================================] # Header files are presumed to be included like # #include <osg/PositionAttitudeTransform> diff --git a/Modules/Findosg_functions.cmake b/Modules/Findosg_functions.cmake index adaeb6b..40df4d5 100644 --- a/Modules/Findosg_functions.cmake +++ b/Modules/Findosg_functions.cmake @@ -1,17 +1,18 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Findosg_functions -# ----------------- -# -# -# -# -# -# This CMake file contains two macros to assist with searching for OSG -# libraries and nodekits. Please see FindOpenSceneGraph.cmake for full -# documentation. +#[=======================================================================[.rst: +Findosg_functions +----------------- + + + + + +This CMake file contains two macros to assist with searching for OSG +libraries and nodekits. Please see FindOpenSceneGraph.cmake for full +documentation. +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index e366842..c813ead 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -1,111 +1,112 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindwxWidgets -# ------------- -# -# Find a wxWidgets (a.k.a., wxWindows) installation. -# -# This module finds if wxWidgets is installed and selects a default -# configuration to use. wxWidgets is a modular library. To specify the -# modules that you will use, you need to name them as components to the -# package: -# -# find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...) -# -# There are two search branches: a windows style and a unix style. For -# windows, the following variables are searched for and set to defaults -# in case of multiple choices. Change them if the defaults are not -# desired (i.e., these are the only variables you should change to -# select a configuration): -# -# :: -# -# wxWidgets_ROOT_DIR - Base wxWidgets directory -# (e.g., C:/wxWidgets-2.6.3). -# wxWidgets_LIB_DIR - Path to wxWidgets libraries -# (e.g., C:/wxWidgets-2.6.3/lib/vc_lib). -# wxWidgets_CONFIGURATION - Configuration to use -# (e.g., msw, mswd, mswu, mswunivud, etc.) -# wxWidgets_EXCLUDE_COMMON_LIBRARIES -# - Set to TRUE to exclude linking of -# commonly required libs (e.g., png tiff -# jpeg zlib regex expat). -# -# -# -# For unix style it uses the wx-config utility. You can select between -# debug/release, unicode/ansi, universal/non-universal, and -# static/shared in the QtDialog or ccmake interfaces by turning ON/OFF -# the following variables: -# -# :: -# -# wxWidgets_USE_DEBUG -# wxWidgets_USE_UNICODE -# wxWidgets_USE_UNIVERSAL -# wxWidgets_USE_STATIC -# -# -# -# There is also a wxWidgets_CONFIG_OPTIONS variable for all other -# options that need to be passed to the wx-config utility. For example, -# to use the base toolkit found in the /usr/local path, set the variable -# (before calling the FIND_PACKAGE command) as such: -# -# :: -# -# set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr) -# -# -# -# The following are set after the configuration is done for both windows -# and unix style: -# -# :: -# -# wxWidgets_FOUND - Set to TRUE if wxWidgets was found. -# wxWidgets_INCLUDE_DIRS - Include directories for WIN32 -# i.e., where to find "wx/wx.h" and -# "wx/setup.h"; possibly empty for unices. -# wxWidgets_LIBRARIES - Path to the wxWidgets libraries. -# wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for -# rpath on UNIX. Typically an empty string -# in WIN32 environment. -# wxWidgets_DEFINITIONS - Contains defines required to compile/link -# against WX, e.g. WXUSINGDLL -# wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link -# against WX debug builds, e.g. __WXDEBUG__ -# wxWidgets_CXX_FLAGS - Include dirs and compiler flags for -# unices, empty on WIN32. Essentially -# "`wx-config --cxxflags`". -# wxWidgets_USE_FILE - Convenience include file. -# -# -# -# Sample usage: -# -# :: -# -# # Note that for MinGW users the order of libs is important! -# find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net) -# if(wxWidgets_FOUND) -# include(${wxWidgets_USE_FILE}) -# # and for each of your dependent executable/library targets: -# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) -# endif() -# -# -# -# If wxWidgets is required (i.e., not an optional part): -# -# :: -# -# find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net) -# include(${wxWidgets_USE_FILE}) -# # and for each of your dependent executable/library targets: -# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) +#[=======================================================================[.rst: +FindwxWidgets +------------- + +Find a wxWidgets (a.k.a., wxWindows) installation. + +This module finds if wxWidgets is installed and selects a default +configuration to use. wxWidgets is a modular library. To specify the +modules that you will use, you need to name them as components to the +package: + +find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...) + +There are two search branches: a windows style and a unix style. For +windows, the following variables are searched for and set to defaults +in case of multiple choices. Change them if the defaults are not +desired (i.e., these are the only variables you should change to +select a configuration): + +:: + + wxWidgets_ROOT_DIR - Base wxWidgets directory + (e.g., C:/wxWidgets-2.6.3). + wxWidgets_LIB_DIR - Path to wxWidgets libraries + (e.g., C:/wxWidgets-2.6.3/lib/vc_lib). + wxWidgets_CONFIGURATION - Configuration to use + (e.g., msw, mswd, mswu, mswunivud, etc.) + wxWidgets_EXCLUDE_COMMON_LIBRARIES + - Set to TRUE to exclude linking of + commonly required libs (e.g., png tiff + jpeg zlib regex expat). + + + +For unix style it uses the wx-config utility. You can select between +debug/release, unicode/ansi, universal/non-universal, and +static/shared in the QtDialog or ccmake interfaces by turning ON/OFF +the following variables: + +:: + + wxWidgets_USE_DEBUG + wxWidgets_USE_UNICODE + wxWidgets_USE_UNIVERSAL + wxWidgets_USE_STATIC + + + +There is also a wxWidgets_CONFIG_OPTIONS variable for all other +options that need to be passed to the wx-config utility. For example, +to use the base toolkit found in the /usr/local path, set the variable +(before calling the FIND_PACKAGE command) as such: + +:: + + set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr) + + + +The following are set after the configuration is done for both windows +and unix style: + +:: + + wxWidgets_FOUND - Set to TRUE if wxWidgets was found. + wxWidgets_INCLUDE_DIRS - Include directories for WIN32 + i.e., where to find "wx/wx.h" and + "wx/setup.h"; possibly empty for unices. + wxWidgets_LIBRARIES - Path to the wxWidgets libraries. + wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for + rpath on UNIX. Typically an empty string + in WIN32 environment. + wxWidgets_DEFINITIONS - Contains defines required to compile/link + against WX, e.g. WXUSINGDLL + wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link + against WX debug builds, e.g. __WXDEBUG__ + wxWidgets_CXX_FLAGS - Include dirs and compiler flags for + unices, empty on WIN32. Essentially + "`wx-config --cxxflags`". + wxWidgets_USE_FILE - Convenience include file. + + + +Sample usage: + +:: + + # Note that for MinGW users the order of libs is important! + find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net) + if(wxWidgets_FOUND) + include(${wxWidgets_USE_FILE}) + # and for each of your dependent executable/library targets: + target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) + endif() + + + +If wxWidgets is required (i.e., not an optional part): + +:: + + find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net) + include(${wxWidgets_USE_FILE}) + # and for each of your dependent executable/library targets: + target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) +#]=======================================================================] # # FIXME: check this and provide a correct sample usage... diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake index 115cdc6..35840f5 100644 --- a/Modules/FindwxWindows.cmake +++ b/Modules/FindwxWindows.cmake @@ -1,84 +1,87 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# FindwxWindows -# ------------- -# -# Find wxWindows (wxWidgets) installation -# -# This module finds if wxWindows/wxWidgets is installed and determines -# where the include files and libraries are. It also determines what -# the name of the library is. Please note this file is DEPRECATED and -# replaced by FindwxWidgets.cmake. This code sets the following -# variables: -# -# :: -# -# WXWINDOWS_FOUND = system has WxWindows -# WXWINDOWS_LIBRARIES = path to the wxWindows libraries -# on Unix/Linux with additional -# linker flags from -# "wx-config --libs" -# CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows, -# essentially "`wx-config --cxxflags`" -# on Linux -# WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h" -# WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on -# Unix -# WXWINDOWS_DEFINITIONS = extra defines -# -# -# -# OPTIONS If you need OpenGL support please -# -# :: -# -# set(WXWINDOWS_USE_GL 1) -# -# in your CMakeLists.txt *before* you include this file. -# -# :: -# -# HAVE_ISYSTEM - true required to replace -I by -isystem on g++ -# -# -# -# For convenience include Use_wxWindows.cmake in your project's -# CMakeLists.txt using -# include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake). -# -# USAGE -# -# :: -# -# set(WXWINDOWS_USE_GL 1) -# find_package(wxWindows) -# -# -# -# NOTES wxWidgets 2.6.x is supported for monolithic builds e.g. -# compiled in wx/build/msw dir as: -# -# :: -# -# nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1 -# -# -# -# DEPRECATED -# -# :: -# -# CMAKE_WX_CAN_COMPILE -# WXWINDOWS_LIBRARY -# CMAKE_WX_CXX_FLAGS -# WXWINDOWS_INCLUDE_PATH -# -# -# -# AUTHOR Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw> -# (07/2003-01/2006) +#[=======================================================================[.rst: +FindwxWindows +------------- + +.. deprecated:: 3.0 + + Replaced by :module:`FindwxWidgets`. + +Find wxWindows (wxWidgets) installation + +This module finds if wxWindows/wxWidgets is installed and determines +where the include files and libraries are. It also determines what +the name of the library is. This code sets the following variables: + +:: + + WXWINDOWS_FOUND = system has WxWindows + WXWINDOWS_LIBRARIES = path to the wxWindows libraries + on Unix/Linux with additional + linker flags from + "wx-config --libs" + CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows, + essentially "`wx-config --cxxflags`" + on Linux + WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h" + WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on + Unix + WXWINDOWS_DEFINITIONS = extra defines + + + +OPTIONS If you need OpenGL support please + +:: + + set(WXWINDOWS_USE_GL 1) + +in your CMakeLists.txt *before* you include this file. + +:: + + HAVE_ISYSTEM - true required to replace -I by -isystem on g++ + + + +For convenience include Use_wxWindows.cmake in your project's +CMakeLists.txt using +include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake). + +USAGE + +:: + + set(WXWINDOWS_USE_GL 1) + find_package(wxWindows) + + + +NOTES wxWidgets 2.6.x is supported for monolithic builds e.g. +compiled in wx/build/msw dir as: + +:: + + nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1 + + + +DEPRECATED + +:: + + CMAKE_WX_CAN_COMPILE + WXWINDOWS_LIBRARY + CMAKE_WX_CXX_FLAGS + WXWINDOWS_INCLUDE_PATH + + + +AUTHOR Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw> +(07/2003-01/2006) +#]=======================================================================] # ------------------------------------------------------------------ # diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index 9dd464c..48d830f 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -1,127 +1,128 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# GNUInstallDirs -# -------------- -# -# Define GNU standard installation directories -# -# Provides install directory variables as defined by the -# `GNU Coding Standards`_. -# -# .. _`GNU Coding Standards`: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# Inclusion of this module defines the following variables: -# -# ``CMAKE_INSTALL_<dir>`` -# -# Destination for files of a given type. This value may be passed to -# the ``DESTINATION`` options of :command:`install` commands for the -# corresponding file type. -# -# ``CMAKE_INSTALL_FULL_<dir>`` -# -# The absolute path generated from the corresponding ``CMAKE_INSTALL_<dir>`` -# value. If the value is not already an absolute path, an absolute path -# is constructed typically by prepending the value of the -# :variable:`CMAKE_INSTALL_PREFIX` variable. However, there are some -# `special cases`_ as documented below. -# -# where ``<dir>`` is one of: -# -# ``BINDIR`` -# user executables (``bin``) -# ``SBINDIR`` -# system admin executables (``sbin``) -# ``LIBEXECDIR`` -# program executables (``libexec``) -# ``SYSCONFDIR`` -# read-only single-machine data (``etc``) -# ``SHAREDSTATEDIR`` -# modifiable architecture-independent data (``com``) -# ``LOCALSTATEDIR`` -# modifiable single-machine data (``var``) -# ``RUNSTATEDIR`` -# run-time variable data (``LOCALSTATEDIR/run``) -# ``LIBDIR`` -# object code libraries (``lib`` or ``lib64`` -# or ``lib/<multiarch-tuple>`` on Debian) -# ``INCLUDEDIR`` -# C header files (``include``) -# ``OLDINCLUDEDIR`` -# C header files for non-gcc (``/usr/include``) -# ``DATAROOTDIR`` -# read-only architecture-independent data root (``share``) -# ``DATADIR`` -# read-only architecture-independent data (``DATAROOTDIR``) -# ``INFODIR`` -# info documentation (``DATAROOTDIR/info``) -# ``LOCALEDIR`` -# locale-dependent data (``DATAROOTDIR/locale``) -# ``MANDIR`` -# man documentation (``DATAROOTDIR/man``) -# ``DOCDIR`` -# documentation root (``DATAROOTDIR/doc/PROJECT_NAME``) -# -# If the includer does not define a value the above-shown default will be -# used and the value will appear in the cache for editing by the user. -# -# Special Cases -# ^^^^^^^^^^^^^ -# -# The following values of :variable:`CMAKE_INSTALL_PREFIX` are special: -# -# ``/`` -# -# For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and -# ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed -# with ``usr/`` if it is not user-specified as an absolute path. -# For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``. -# This is required by the `GNU Coding Standards`_, which state: -# -# When building the complete GNU system, the prefix will be empty -# and ``/usr`` will be a symbolic link to ``/``. -# -# ``/usr`` -# -# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or -# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by -# prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>`` -# if it is not user-specified as an absolute path. -# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``. -# This is required by the `GNU Coding Standards`_. -# -# ``/opt/...`` -# -# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or -# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by -# *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>`` -# if it is not user-specified as an absolute path. -# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``. -# This is defined by the `Filesystem Hierarchy Standard`_. -# -# .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html -# -# Macros -# ^^^^^^ -# -# .. command:: GNUInstallDirs_get_absolute_install_dir -# -# :: -# -# GNUInstallDirs_get_absolute_install_dir(absvar var) -# -# Set the given variable ``absvar`` to the absolute path contained -# within the variable ``var``. This is to allow the computation of an -# absolute path, accounting for all the special cases documented -# above. While this macro is used to compute the various -# ``CMAKE_INSTALL_FULL_<dir>`` variables, it is exposed publicly to -# allow users who create additional path variables to also compute -# absolute paths where necessary, using the same logic. +#[=======================================================================[.rst: +GNUInstallDirs +-------------- + +Define GNU standard installation directories + +Provides install directory variables as defined by the +`GNU Coding Standards`_. + +.. _`GNU Coding Standards`: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html + +Result Variables +^^^^^^^^^^^^^^^^ + +Inclusion of this module defines the following variables: + +``CMAKE_INSTALL_<dir>`` + + Destination for files of a given type. This value may be passed to + the ``DESTINATION`` options of :command:`install` commands for the + corresponding file type. + +``CMAKE_INSTALL_FULL_<dir>`` + + The absolute path generated from the corresponding ``CMAKE_INSTALL_<dir>`` + value. If the value is not already an absolute path, an absolute path + is constructed typically by prepending the value of the + :variable:`CMAKE_INSTALL_PREFIX` variable. However, there are some + `special cases`_ as documented below. + +where ``<dir>`` is one of: + +``BINDIR`` + user executables (``bin``) +``SBINDIR`` + system admin executables (``sbin``) +``LIBEXECDIR`` + program executables (``libexec``) +``SYSCONFDIR`` + read-only single-machine data (``etc``) +``SHAREDSTATEDIR`` + modifiable architecture-independent data (``com``) +``LOCALSTATEDIR`` + modifiable single-machine data (``var``) +``RUNSTATEDIR`` + run-time variable data (``LOCALSTATEDIR/run``) +``LIBDIR`` + object code libraries (``lib`` or ``lib64`` + or ``lib/<multiarch-tuple>`` on Debian) +``INCLUDEDIR`` + C header files (``include``) +``OLDINCLUDEDIR`` + C header files for non-gcc (``/usr/include``) +``DATAROOTDIR`` + read-only architecture-independent data root (``share``) +``DATADIR`` + read-only architecture-independent data (``DATAROOTDIR``) +``INFODIR`` + info documentation (``DATAROOTDIR/info``) +``LOCALEDIR`` + locale-dependent data (``DATAROOTDIR/locale``) +``MANDIR`` + man documentation (``DATAROOTDIR/man``) +``DOCDIR`` + documentation root (``DATAROOTDIR/doc/PROJECT_NAME``) + +If the includer does not define a value the above-shown default will be +used and the value will appear in the cache for editing by the user. + +Special Cases +^^^^^^^^^^^^^ + +The following values of :variable:`CMAKE_INSTALL_PREFIX` are special: + +``/`` + + For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and + ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed + with ``usr/`` if it is not user-specified as an absolute path. + For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``. + This is required by the `GNU Coding Standards`_, which state: + + When building the complete GNU system, the prefix will be empty + and ``/usr`` will be a symbolic link to ``/``. + +``/usr`` + + For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or + ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by + prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>`` + if it is not user-specified as an absolute path. + For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``. + This is required by the `GNU Coding Standards`_. + +``/opt/...`` + + For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or + ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by + *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>`` + if it is not user-specified as an absolute path. + For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``. + This is defined by the `Filesystem Hierarchy Standard`_. + +.. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html + +Macros +^^^^^^ + +.. command:: GNUInstallDirs_get_absolute_install_dir + + :: + + GNUInstallDirs_get_absolute_install_dir(absvar var) + + Set the given variable ``absvar`` to the absolute path contained + within the variable ``var``. This is to allow the computation of an + absolute path, accounting for all the special cases documented + above. While this macro is used to compute the various + ``CMAKE_INSTALL_FULL_<dir>`` variables, it is exposed publicly to + allow users who create additional path variables to also compute + absolute paths where necessary, using the same logic. +#]=======================================================================] cmake_policy(PUSH) cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced @@ -276,7 +277,7 @@ _GNUInstallDirs_cache_path(CMAKE_INSTALL_DATAROOTDIR "share" _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}" "Read-only architecture-independent data (DATAROOTDIR)") -if(CMAKE_SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$") +if(CMAKE_SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$") _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_INFODIR "info" "Info documentation (info)") _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_MANDIR "man" diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index e6dcd00..f2e4527 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -1,189 +1,190 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# GenerateExportHeader -# -------------------- -# -# Function for generation of export macros for libraries -# -# This module provides the function GENERATE_EXPORT_HEADER(). -# -# The ``GENERATE_EXPORT_HEADER`` function can be used to generate a file -# suitable for preprocessor inclusion which contains EXPORT macros to be -# used in library classes:: -# -# GENERATE_EXPORT_HEADER( LIBRARY_TARGET -# [BASE_NAME <base_name>] -# [EXPORT_MACRO_NAME <export_macro_name>] -# [EXPORT_FILE_NAME <export_file_name>] -# [DEPRECATED_MACRO_NAME <deprecated_macro_name>] -# [NO_EXPORT_MACRO_NAME <no_export_macro_name>] -# [INCLUDE_GUARD_NAME <include_guard_name>] -# [STATIC_DEFINE <static_define>] -# [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>] -# [DEFINE_NO_DEPRECATED] -# [PREFIX_NAME <prefix_name>] -# [CUSTOM_CONTENT_FROM_VARIABLE <variable>] -# ) -# -# -# The target properties :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` -# and :prop_tgt:`VISIBILITY_INLINES_HIDDEN` can be used to add the appropriate -# compile flags for targets. See the documentation of those target properties, -# and the convenience variables -# :variable:`CMAKE_CXX_VISIBILITY_PRESET <CMAKE_<LANG>_VISIBILITY_PRESET>` and -# :variable:`CMAKE_VISIBILITY_INLINES_HIDDEN`. -# -# By default ``GENERATE_EXPORT_HEADER()`` generates macro names in a file -# name determined by the name of the library. This means that in the -# simplest case, users of ``GenerateExportHeader`` will be equivalent to: -# -# .. code-block:: cmake -# -# set(CMAKE_CXX_VISIBILITY_PRESET hidden) -# set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -# add_library(somelib someclass.cpp) -# generate_export_header(somelib) -# install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) -# install(FILES -# someclass.h -# ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR} -# ) -# -# -# And in the ABI header files: -# -# .. code-block:: c++ -# -# #include "somelib_export.h" -# class SOMELIB_EXPORT SomeClass { -# ... -# }; -# -# -# The CMake fragment will generate a file in the -# ``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the -# macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``, -# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``. -# They will be followed by content taken from the variable specified by -# the ``CUSTOM_CONTENT_FROM_VARIABLE`` option, if any. -# The resulting file should be installed with other headers in the library. -# -# The ``BASE_NAME`` argument can be used to override the file name and the -# names used for the macros: -# -# .. code-block:: cmake -# -# add_library(somelib someclass.cpp) -# generate_export_header(somelib -# BASE_NAME other_name -# ) -# -# -# Generates a file called ``other_name_export.h`` containing the macros -# ``OTHER_NAME_EXPORT``, ``OTHER_NAME_NO_EXPORT`` and ``OTHER_NAME_DEPRECATED`` -# etc. -# -# The ``BASE_NAME`` may be overridden by specifying other options in the -# function. For example: -# -# .. code-block:: cmake -# -# add_library(somelib someclass.cpp) -# generate_export_header(somelib -# EXPORT_MACRO_NAME OTHER_NAME_EXPORT -# ) -# -# -# creates the macro ``OTHER_NAME_EXPORT`` instead of ``SOMELIB_EXPORT``, but -# other macros and the generated file name is as default: -# -# .. code-block:: cmake -# -# add_library(somelib someclass.cpp) -# generate_export_header(somelib -# DEPRECATED_MACRO_NAME KDE_DEPRECATED -# ) -# -# -# creates the macro ``KDE_DEPRECATED`` instead of ``SOMELIB_DEPRECATED``. -# -# If ``LIBRARY_TARGET`` is a static library, macros are defined without -# values. -# -# If the same sources are used to create both a shared and a static -# library, the uppercased symbol ``${BASE_NAME}_STATIC_DEFINE`` should be -# used when building the static library: -# -# .. code-block:: cmake -# -# add_library(shared_variant SHARED ${lib_SRCS}) -# add_library(static_variant ${lib_SRCS}) -# generate_export_header(shared_variant BASE_NAME libshared_and_static) -# set_target_properties(static_variant PROPERTIES -# COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) -# -# This will cause the export macros to expand to nothing when building -# the static library. -# -# If ``DEFINE_NO_DEPRECATED`` is specified, then a macro -# ``${BASE_NAME}_NO_DEPRECATED`` will be defined This macro can be used to -# remove deprecated code from preprocessor output: -# -# .. code-block:: cmake -# -# option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) -# if (EXCLUDE_DEPRECATED) -# set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED) -# endif() -# generate_export_header(somelib ${NO_BUILD_DEPRECATED}) -# -# -# And then in somelib: -# -# .. code-block:: c++ -# -# class SOMELIB_EXPORT SomeClass -# { -# public: -# #ifndef SOMELIB_NO_DEPRECATED -# SOMELIB_DEPRECATED void oldMethod(); -# #endif -# }; -# -# .. code-block:: c++ -# -# #ifndef SOMELIB_NO_DEPRECATED -# void SomeClass::oldMethod() { } -# #endif -# -# -# If ``PREFIX_NAME`` is specified, the argument will be used as a prefix to -# all generated macros. -# -# For example: -# -# .. code-block:: cmake -# -# generate_export_header(somelib PREFIX_NAME VTK_) -# -# Generates the macros ``VTK_SOMELIB_EXPORT`` etc. -# -# :: -# -# ADD_COMPILER_EXPORT_FLAGS( [<output_variable>] ) -# -# The ``ADD_COMPILER_EXPORT_FLAGS`` function adds ``-fvisibility=hidden`` to -# :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` if supported, and is a no-op -# on Windows which does not need extra compiler flags for exporting support. -# You may optionally pass a single argument to ``ADD_COMPILER_EXPORT_FLAGS`` -# that will be populated with the ``CXX_FLAGS`` required to enable visibility -# support for the compiler/architecture in use. -# -# This function is deprecated. Set the target properties -# :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` and -# :prop_tgt:`VISIBILITY_INLINES_HIDDEN` instead. +#[=======================================================================[.rst: +GenerateExportHeader +-------------------- + +Function for generation of export macros for libraries + +This module provides the function GENERATE_EXPORT_HEADER(). + +The ``GENERATE_EXPORT_HEADER`` function can be used to generate a file +suitable for preprocessor inclusion which contains EXPORT macros to be +used in library classes:: + + GENERATE_EXPORT_HEADER( LIBRARY_TARGET + [BASE_NAME <base_name>] + [EXPORT_MACRO_NAME <export_macro_name>] + [EXPORT_FILE_NAME <export_file_name>] + [DEPRECATED_MACRO_NAME <deprecated_macro_name>] + [NO_EXPORT_MACRO_NAME <no_export_macro_name>] + [INCLUDE_GUARD_NAME <include_guard_name>] + [STATIC_DEFINE <static_define>] + [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>] + [DEFINE_NO_DEPRECATED] + [PREFIX_NAME <prefix_name>] + [CUSTOM_CONTENT_FROM_VARIABLE <variable>] + ) + + +The target properties :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` +and :prop_tgt:`VISIBILITY_INLINES_HIDDEN` can be used to add the appropriate +compile flags for targets. See the documentation of those target properties, +and the convenience variables +:variable:`CMAKE_CXX_VISIBILITY_PRESET <CMAKE_<LANG>_VISIBILITY_PRESET>` and +:variable:`CMAKE_VISIBILITY_INLINES_HIDDEN`. + +By default ``GENERATE_EXPORT_HEADER()`` generates macro names in a file +name determined by the name of the library. This means that in the +simplest case, users of ``GenerateExportHeader`` will be equivalent to: + +.. code-block:: cmake + + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + add_library(somelib someclass.cpp) + generate_export_header(somelib) + install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) + install(FILES + someclass.h + ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR} + ) + + +And in the ABI header files: + +.. code-block:: c++ + + #include "somelib_export.h" + class SOMELIB_EXPORT SomeClass { + ... + }; + + +The CMake fragment will generate a file in the +``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the +macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``, +``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``. +They will be followed by content taken from the variable specified by +the ``CUSTOM_CONTENT_FROM_VARIABLE`` option, if any. +The resulting file should be installed with other headers in the library. + +The ``BASE_NAME`` argument can be used to override the file name and the +names used for the macros: + +.. code-block:: cmake + + add_library(somelib someclass.cpp) + generate_export_header(somelib + BASE_NAME other_name + ) + + +Generates a file called ``other_name_export.h`` containing the macros +``OTHER_NAME_EXPORT``, ``OTHER_NAME_NO_EXPORT`` and ``OTHER_NAME_DEPRECATED`` +etc. + +The ``BASE_NAME`` may be overridden by specifying other options in the +function. For example: + +.. code-block:: cmake + + add_library(somelib someclass.cpp) + generate_export_header(somelib + EXPORT_MACRO_NAME OTHER_NAME_EXPORT + ) + + +creates the macro ``OTHER_NAME_EXPORT`` instead of ``SOMELIB_EXPORT``, but +other macros and the generated file name is as default: + +.. code-block:: cmake + + add_library(somelib someclass.cpp) + generate_export_header(somelib + DEPRECATED_MACRO_NAME KDE_DEPRECATED + ) + + +creates the macro ``KDE_DEPRECATED`` instead of ``SOMELIB_DEPRECATED``. + +If ``LIBRARY_TARGET`` is a static library, macros are defined without +values. + +If the same sources are used to create both a shared and a static +library, the uppercased symbol ``${BASE_NAME}_STATIC_DEFINE`` should be +used when building the static library: + +.. code-block:: cmake + + add_library(shared_variant SHARED ${lib_SRCS}) + add_library(static_variant ${lib_SRCS}) + generate_export_header(shared_variant BASE_NAME libshared_and_static) + set_target_properties(static_variant PROPERTIES + COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) + +This will cause the export macros to expand to nothing when building +the static library. + +If ``DEFINE_NO_DEPRECATED`` is specified, then a macro +``${BASE_NAME}_NO_DEPRECATED`` will be defined This macro can be used to +remove deprecated code from preprocessor output: + +.. code-block:: cmake + + option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) + if (EXCLUDE_DEPRECATED) + set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED) + endif() + generate_export_header(somelib ${NO_BUILD_DEPRECATED}) + + +And then in somelib: + +.. code-block:: c++ + + class SOMELIB_EXPORT SomeClass + { + public: + #ifndef SOMELIB_NO_DEPRECATED + SOMELIB_DEPRECATED void oldMethod(); + #endif + }; + +.. code-block:: c++ + + #ifndef SOMELIB_NO_DEPRECATED + void SomeClass::oldMethod() { } + #endif + + +If ``PREFIX_NAME`` is specified, the argument will be used as a prefix to +all generated macros. + +For example: + +.. code-block:: cmake + + generate_export_header(somelib PREFIX_NAME VTK_) + +Generates the macros ``VTK_SOMELIB_EXPORT`` etc. + +:: + + ADD_COMPILER_EXPORT_FLAGS( [<output_variable>] ) + +The ``ADD_COMPILER_EXPORT_FLAGS`` function adds ``-fvisibility=hidden`` to +:variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` if supported, and is a no-op +on Windows which does not need extra compiler flags for exporting support. +You may optionally pass a single argument to ``ADD_COMPILER_EXPORT_FLAGS`` +that will be populated with the ``CXX_FLAGS`` required to enable visibility +support for the compiler/architecture in use. + +This function is deprecated. Set the target properties +:prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` and +:prop_tgt:`VISIBILITY_INLINES_HIDDEN` instead. +#]=======================================================================] include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index ca71009..5b32f7c 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -1,169 +1,170 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# GetPrerequisites -# ---------------- -# -# Functions to analyze and list executable file prerequisites. -# -# This module provides functions to list the .dll, .dylib or .so files -# that an executable or shared library file depends on. (Its -# prerequisites.) -# -# It uses various tools to obtain the list of required shared library -# files: -# -# :: -# -# dumpbin (Windows) -# objdump (MinGW on Windows) -# ldd (Linux/Unix) -# otool (Mac OSX) -# -# The following functions are provided by this module: -# -# :: -# -# get_prerequisites -# list_prerequisites -# list_prerequisites_by_glob -# gp_append_unique -# is_file_executable -# gp_item_default_embedded_path -# (projects can override with gp_item_default_embedded_path_override) -# gp_resolve_item -# (projects can override with gp_resolve_item_override) -# gp_resolved_file_type -# (projects can override with gp_resolved_file_type_override) -# gp_file_type -# -# Requires CMake 2.6 or greater because it uses function, break, return -# and PARENT_SCOPE. -# -# :: -# -# GET_PREREQUISITES(<target> <prerequisites_var> <exclude_system> <recurse> -# <exepath> <dirs> [<rpaths>]) -# -# Get the list of shared library files required by <target>. The list -# in the variable named <prerequisites_var> should be empty on first -# entry to this function. On exit, <prerequisites_var> will contain the -# list of required shared library files. -# -# <target> is the full path to an executable file. <prerequisites_var> -# is the name of a CMake variable to contain the results. -# <exclude_system> must be 0 or 1 indicating whether to include or -# exclude "system" prerequisites. If <recurse> is set to 1 all -# prerequisites will be found recursively, if set to 0 only direct -# prerequisites are listed. <exepath> is the path to the top level -# executable used for @executable_path replacment on the Mac. <dirs> is -# a list of paths where libraries might be found: these paths are -# searched first when a target without any path info is given. Then -# standard system locations are also searched: PATH, Framework -# locations, /usr/lib... -# -# :: -# -# LIST_PREREQUISITES(<target> [<recurse> [<exclude_system> [<verbose>]]]) -# -# Print a message listing the prerequisites of <target>. -# -# <target> is the name of a shared library or executable target or the -# full path to a shared library or executable file. If <recurse> is set -# to 1 all prerequisites will be found recursively, if set to 0 only -# direct prerequisites are listed. <exclude_system> must be 0 or 1 -# indicating whether to include or exclude "system" prerequisites. With -# <verbose> set to 0 only the full path names of the prerequisites are -# printed, set to 1 extra informatin will be displayed. -# -# :: -# -# LIST_PREREQUISITES_BY_GLOB(<glob_arg> <glob_exp>) -# -# Print the prerequisites of shared library and executable files -# matching a globbing pattern. <glob_arg> is GLOB or GLOB_RECURSE and -# <glob_exp> is a globbing expression used with "file(GLOB" or -# "file(GLOB_RECURSE" to retrieve a list of matching files. If a -# matching file is executable, its prerequisites are listed. -# -# Any additional (optional) arguments provided are passed along as the -# optional arguments to the list_prerequisites calls. -# -# :: -# -# GP_APPEND_UNIQUE(<list_var> <value>) -# -# Append <value> to the list variable <list_var> only if the value is -# not already in the list. -# -# :: -# -# IS_FILE_EXECUTABLE(<file> <result_var>) -# -# Return 1 in <result_var> if <file> is a binary executable, 0 -# otherwise. -# -# :: -# -# GP_ITEM_DEFAULT_EMBEDDED_PATH(<item> <default_embedded_path_var>) -# -# Return the path that others should refer to the item by when the item -# is embedded inside a bundle. -# -# Override on a per-project basis by providing a project-specific -# gp_item_default_embedded_path_override function. -# -# :: -# -# GP_RESOLVE_ITEM(<context> <item> <exepath> <dirs> <resolved_item_var> -# [<rpaths>]) -# -# Resolve an item into an existing full path file. -# -# Override on a per-project basis by providing a project-specific -# gp_resolve_item_override function. -# -# :: -# -# GP_RESOLVED_FILE_TYPE(<original_file> <file> <exepath> <dirs> <type_var> -# [<rpaths>]) -# -# Return the type of <file> with respect to <original_file>. String -# describing type of prerequisite is returned in variable named -# <type_var>. -# -# Use <exepath> and <dirs> if necessary to resolve non-absolute <file> -# values -- but only for non-embedded items. -# -# Possible types are: -# -# :: -# -# system -# local -# embedded -# other -# -# Override on a per-project basis by providing a project-specific -# gp_resolved_file_type_override function. -# -# :: -# -# GP_FILE_TYPE(<original_file> <file> <type_var>) -# -# Return the type of <file> with respect to <original_file>. String -# describing type of prerequisite is returned in variable named -# <type_var>. -# -# Possible types are: -# -# :: -# -# system -# local -# embedded -# other +#[=======================================================================[.rst: +GetPrerequisites +---------------- + +Functions to analyze and list executable file prerequisites. + +This module provides functions to list the .dll, .dylib or .so files +that an executable or shared library file depends on. (Its +prerequisites.) + +It uses various tools to obtain the list of required shared library +files: + +:: + + dumpbin (Windows) + objdump (MinGW on Windows) + ldd (Linux/Unix) + otool (Mac OSX) + +The following functions are provided by this module: + +:: + + get_prerequisites + list_prerequisites + list_prerequisites_by_glob + gp_append_unique + is_file_executable + gp_item_default_embedded_path + (projects can override with gp_item_default_embedded_path_override) + gp_resolve_item + (projects can override with gp_resolve_item_override) + gp_resolved_file_type + (projects can override with gp_resolved_file_type_override) + gp_file_type + +Requires CMake 2.6 or greater because it uses function, break, return +and PARENT_SCOPE. + +:: + + GET_PREREQUISITES(<target> <prerequisites_var> <exclude_system> <recurse> + <exepath> <dirs> [<rpaths>]) + +Get the list of shared library files required by <target>. The list +in the variable named <prerequisites_var> should be empty on first +entry to this function. On exit, <prerequisites_var> will contain the +list of required shared library files. + +<target> is the full path to an executable file. <prerequisites_var> +is the name of a CMake variable to contain the results. +<exclude_system> must be 0 or 1 indicating whether to include or +exclude "system" prerequisites. If <recurse> is set to 1 all +prerequisites will be found recursively, if set to 0 only direct +prerequisites are listed. <exepath> is the path to the top level +executable used for @executable_path replacment on the Mac. <dirs> is +a list of paths where libraries might be found: these paths are +searched first when a target without any path info is given. Then +standard system locations are also searched: PATH, Framework +locations, /usr/lib... + +:: + + LIST_PREREQUISITES(<target> [<recurse> [<exclude_system> [<verbose>]]]) + +Print a message listing the prerequisites of <target>. + +<target> is the name of a shared library or executable target or the +full path to a shared library or executable file. If <recurse> is set +to 1 all prerequisites will be found recursively, if set to 0 only +direct prerequisites are listed. <exclude_system> must be 0 or 1 +indicating whether to include or exclude "system" prerequisites. With +<verbose> set to 0 only the full path names of the prerequisites are +printed, set to 1 extra informatin will be displayed. + +:: + + LIST_PREREQUISITES_BY_GLOB(<glob_arg> <glob_exp>) + +Print the prerequisites of shared library and executable files +matching a globbing pattern. <glob_arg> is GLOB or GLOB_RECURSE and +<glob_exp> is a globbing expression used with "file(GLOB" or +"file(GLOB_RECURSE" to retrieve a list of matching files. If a +matching file is executable, its prerequisites are listed. + +Any additional (optional) arguments provided are passed along as the +optional arguments to the list_prerequisites calls. + +:: + + GP_APPEND_UNIQUE(<list_var> <value>) + +Append <value> to the list variable <list_var> only if the value is +not already in the list. + +:: + + IS_FILE_EXECUTABLE(<file> <result_var>) + +Return 1 in <result_var> if <file> is a binary executable, 0 +otherwise. + +:: + + GP_ITEM_DEFAULT_EMBEDDED_PATH(<item> <default_embedded_path_var>) + +Return the path that others should refer to the item by when the item +is embedded inside a bundle. + +Override on a per-project basis by providing a project-specific +gp_item_default_embedded_path_override function. + +:: + + GP_RESOLVE_ITEM(<context> <item> <exepath> <dirs> <resolved_item_var> + [<rpaths>]) + +Resolve an item into an existing full path file. + +Override on a per-project basis by providing a project-specific +gp_resolve_item_override function. + +:: + + GP_RESOLVED_FILE_TYPE(<original_file> <file> <exepath> <dirs> <type_var> + [<rpaths>]) + +Return the type of <file> with respect to <original_file>. String +describing type of prerequisite is returned in variable named +<type_var>. + +Use <exepath> and <dirs> if necessary to resolve non-absolute <file> +values -- but only for non-embedded items. + +Possible types are: + +:: + + system + local + embedded + other + +Override on a per-project basis by providing a project-specific +gp_resolved_file_type_override function. + +:: + + GP_FILE_TYPE(<original_file> <file> <type_var>) + +Return the type of <file> with respect to <original_file>. String +describing type of prerequisite is returned in variable named +<type_var>. + +Possible types are: + +:: + + system + local + embedded + other +#]=======================================================================] function(gp_append_unique list_var value) set(contains 0) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 4ecba05..9a5e64d 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -1,60 +1,61 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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 :command:`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`` -# 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. -# -# 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 :command:`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`` -# Specify the :command:`install(PROGRAMS)` command ``COMPONENT`` -# option. If not specified, no such option will be used. +#[=======================================================================[.rst: +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 :command:`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`` + 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. + + 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 :command:`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`` + Specify the :command:`install(PROGRAMS)` command ``COMPONENT`` + option. If not specified, no such option will be used. +#]=======================================================================] cmake_policy(PUSH) cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced diff --git a/Modules/MacroAddFileDependencies.cmake b/Modules/MacroAddFileDependencies.cmake index db26814..39393d6 100644 --- a/Modules/MacroAddFileDependencies.cmake +++ b/Modules/MacroAddFileDependencies.cmake @@ -1,19 +1,20 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# MacroAddFileDependencies -# ------------------------ -# -# MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) -# -# Using the macro MACRO_ADD_FILE_DEPENDENCIES() is discouraged. There -# are usually better ways to specify the correct dependencies. -# -# MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) is just a -# convenience wrapper around the OBJECT_DEPENDS source file property. -# You can just use set_property(SOURCE <file> APPEND PROPERTY -# OBJECT_DEPENDS depend_files) instead. +#[=======================================================================[.rst: +MacroAddFileDependencies +------------------------ + +MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) + +Using the macro MACRO_ADD_FILE_DEPENDENCIES() is discouraged. There +are usually better ways to specify the correct dependencies. + +MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) is just a +convenience wrapper around the OBJECT_DEPENDS source file property. +You can just use set_property(SOURCE <file> APPEND PROPERTY +OBJECT_DEPENDS depend_files) instead. +#]=======================================================================] macro (MACRO_ADD_FILE_DEPENDENCIES _file) diff --git a/Modules/Platform/DragonFly.cmake b/Modules/Platform/DragonFly.cmake index c22677b..12e5f3c 100644 --- a/Modules/Platform/DragonFly.cmake +++ b/Modules/Platform/DragonFly.cmake @@ -3,3 +3,7 @@ # see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361 include(Platform/FreeBSD) + +# DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH. +# This is not required for FreeBSD since 10.2-RELEASE. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,") diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index ce4d3ce..082e9f6 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -6,6 +6,8 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +# Does not require -z origin since 10.2-RELEASE +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index dfc2664..7e0af61 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -11,6 +11,7 @@ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index 1f8c1b4..b5d5464 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -1,6 +1,7 @@ set(CMAKE_DL_LIBS "dl") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 1004eb3..a8f4cc8 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -6,6 +6,7 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty +set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index 6466a0a..97e2a6a 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -15,6 +15,10 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH) "${LDCONFIG_HINTS}") endif() +# OpenBSD requires -z origin to enable $ORIGIN expansion in RPATH. +# This is not required for NetBSD. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,") + set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) # OpenBSD has no multilib diff --git a/Modules/Platform/SunOS-GNU.cmake b/Modules/Platform/SunOS-GNU.cmake index 485f235..47334d6 100644 --- a/Modules/Platform/SunOS-GNU.cmake +++ b/Modules/Platform/SunOS-GNU.cmake @@ -11,6 +11,7 @@ set(__SUNOS_COMPILER_GNU 1) macro(__sunos_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-R") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN") set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-h") # Initialize C link type selection flags. These flags are used when diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index 8a37884..05f56d8 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -1,44 +1,45 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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, IRIX, Linux, macOS, QNX, Sun and -# Windows. -# -# 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. -# -# 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. +#[=======================================================================[.rst: +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, IRIX, Linux, macOS, QNX, Sun and +Windows. + +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. + +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. +#]=======================================================================] # A more reliable way might be to compile a small C program that uses the CPUID # instruction, but that again requires compiler support or compiling assembler diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake index e21ecf4..684ec21 100644 --- a/Modules/Qt4ConfigDependentSettings.cmake +++ b/Modules/Qt4ConfigDependentSettings.cmake @@ -1,13 +1,14 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Qt4ConfigDependentSettings -# -------------------------- -# -# -# -# This file is included by FindQt4.cmake, don't include it directly. +#[=======================================================================[.rst: +Qt4ConfigDependentSettings +-------------------------- + + + +This file is included by FindQt4.cmake, don't include it directly. +#]=======================================================================] ############################################### # diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index a2c8d85..5c48970 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -1,13 +1,14 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Qt4Macros -# --------- -# -# -# -# This file is included by FindQt4.cmake, don't include it directly. +#[=======================================================================[.rst: +Qt4Macros +--------- + + + +This file is included by FindQt4.cmake, don't include it directly. +#]=======================================================================] ###################################### # diff --git a/Modules/SelectLibraryConfigurations.cmake b/Modules/SelectLibraryConfigurations.cmake index fe3bb00..8cb714d 100644 --- a/Modules/SelectLibraryConfigurations.cmake +++ b/Modules/SelectLibraryConfigurations.cmake @@ -1,31 +1,32 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# SelectLibraryConfigurations -# --------------------------- -# -# -# -# select_library_configurations( basename ) -# -# This macro takes a library base name as an argument, and will choose -# good values for basename_LIBRARY, basename_LIBRARIES, -# basename_LIBRARY_DEBUG, and 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. +#[=======================================================================[.rst: +SelectLibraryConfigurations +--------------------------- + + + +select_library_configurations( basename ) + +This macro takes a library base name as an argument, and will choose +good values for basename_LIBRARY, basename_LIBRARIES, +basename_LIBRARY_DEBUG, and 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. +#]=======================================================================] # This macro was adapted from the FindQt4 CMake module and is maintained by Will # Dicharry <wdicharry@stellarscience.com>. diff --git a/Modules/SquishTestScript.cmake b/Modules/SquishTestScript.cmake index c0e1bea..2a80be5 100644 --- a/Modules/SquishTestScript.cmake +++ b/Modules/SquishTestScript.cmake @@ -1,21 +1,22 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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. +#[=======================================================================[.rst: +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. +#]=======================================================================] # print out the variable that we are using message(STATUS "squish_aut='${squish_aut}'") diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index 9a4bce5..0c6e188 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -1,18 +1,19 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# TestBigEndian -# ------------- -# -# Define macro to determine endian type -# -# Check if the system is big endian or little endian -# -# :: -# -# TEST_BIG_ENDIAN(VARIABLE) -# VARIABLE - variable to store the result to +#[=======================================================================[.rst: +TestBigEndian +------------- + +Define macro to determine endian type + +Check if the system is big endian or little endian + +:: + + TEST_BIG_ENDIAN(VARIABLE) + VARIABLE - variable to store the result to +#]=======================================================================] include(CheckTypeSize) diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index 10019ec..92a362e 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -1,22 +1,25 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# TestCXXAcceptsFlag -# ------------------ -# -# Deprecated. See :module:`CheckCXXCompilerFlag`. -# -# Check if the CXX compiler accepts a flag. -# -# .. code-block:: cmake -# -# CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>) -# -# ``<flags>`` -# the flags to try -# ``<variable>`` -# variable to store the result +#[=======================================================================[.rst: +TestCXXAcceptsFlag +------------------ + +.. deprecated:: 3.0 + + See :module:`CheckCXXCompilerFlag`. + +Check if the CXX compiler accepts a flag. + +.. code-block:: cmake + + CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>) + +``<flags>`` + the flags to try +``<variable>`` + variable to store the result +#]=======================================================================] macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) if(NOT DEFINED ${VARIABLE}) diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake index 7d2aad6..272e4ec 100644 --- a/Modules/TestForANSIForScope.cmake +++ b/Modules/TestForANSIForScope.cmake @@ -1,18 +1,19 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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 +#[=======================================================================[.rst: +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 +#]=======================================================================] if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE) message(STATUS "Check for ANSI scope") diff --git a/Modules/TestForANSIStreamHeaders.cmake b/Modules/TestForANSIStreamHeaders.cmake index e890c67..e532a71 100644 --- a/Modules/TestForANSIStreamHeaders.cmake +++ b/Modules/TestForANSIStreamHeaders.cmake @@ -1,18 +1,19 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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 +#[=======================================================================[.rst: +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 +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CheckIncludeFileCXX.cmake) diff --git a/Modules/TestForSSTREAM.cmake b/Modules/TestForSSTREAM.cmake index 0bfbfbb..e70df00 100644 --- a/Modules/TestForSSTREAM.cmake +++ b/Modules/TestForSSTREAM.cmake @@ -1,17 +1,18 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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 +#[=======================================================================[.rst: +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 +#]=======================================================================] if(NOT DEFINED CMAKE_HAS_ANSI_STRING_STREAM) message(STATUS "Check for sstream") diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake index 3ae80c7..703e631 100644 --- a/Modules/TestForSTDNamespace.cmake +++ b/Modules/TestForSTDNamespace.cmake @@ -1,17 +1,18 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# TestForSTDNamespace -# ------------------- -# -# Test for std:: namespace support -# -# check if the compiler supports std:: on stl classes -# -# :: -# -# CMAKE_NO_STD_NAMESPACE - defined by the results +#[=======================================================================[.rst: +TestForSTDNamespace +------------------- + +Test for std:: namespace support + +check if the compiler supports std:: on stl classes + +:: + + CMAKE_NO_STD_NAMESPACE - defined by the results +#]=======================================================================] if(NOT DEFINED CMAKE_STD_NAMESPACE) message(STATUS "Check for STD namespace") diff --git a/Modules/UseEcos.cmake b/Modules/UseEcos.cmake index 700bfe6..6d13d42 100644 --- a/Modules/UseEcos.cmake +++ b/Modules/UseEcos.cmake @@ -1,32 +1,33 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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 +#[=======================================================================[.rst: +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 +#]=======================================================================] # first check that ecosconfig is available find_program(ECOSCONFIG_EXECUTABLE NAMES ecosconfig) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 6e2c511..68c9a27 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -1,438 +1,439 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# UseJava -# ------- -# -# Use Module for Java -# -# This file provides functions for Java. It is assumed that -# FindJava.cmake has already been loaded. See FindJava.cmake for -# information on how to load Java into your CMake project. -# -# :: -# -# add_jar(target_name -# [SOURCES] source1 [source2 ...] [resource1 ...] -# [INCLUDE_JARS jar1 [jar2 ...]] -# [ENTRY_POINT entry] -# [VERSION version] -# [OUTPUT_NAME name] -# [OUTPUT_DIR dir] -# [GENERATE_NATIVE_HEADERS target [DESTINATION dir]] -# ) -# -# This command creates a <target_name>.jar. It compiles the given -# source files (source) and adds the given resource files (resource) 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. The list of include 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). -# -# The default OUTPUT_DIR can also be changed by setting the variable -# CMAKE_JAVA_TARGET_OUTPUT_DIR. -# -# Optionally, using option GENERATE_NATIVE_HEADERS, native header files can be generated -# 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 output directory for -# generated header files. -# -# GENERATE_NATIVE_HEADERS option requires, at least, version 1.8 of the JDK. -# -# Additional instructions: -# -# :: -# -# To add compile flags to the target you can set these flags with -# the following variable: -# -# -# -# :: -# -# set(CMAKE_JAVA_COMPILE_FLAGS -nowarn) -# -# -# -# :: -# -# To add a path or a jar file to the class path you can do this -# with the CMAKE_JAVA_INCLUDE_PATH variable. -# -# -# -# :: -# -# set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar) -# -# -# -# :: -# -# To use a different output name for the target you can set it with: -# -# -# -# :: -# -# add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar) -# -# -# -# :: -# -# To use a different output directory than CMAKE_CURRENT_BINARY_DIR -# you can set it with: -# -# -# -# :: -# -# add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin) -# -# -# -# :: -# -# To define an entry point in your jar you can set it with the ENTRY_POINT -# named argument: -# -# -# -# :: -# -# add_jar(example ENTRY_POINT com/examples/MyProject/Main) -# -# -# -# :: -# -# To define a custom manifest for the jar, you can set it with the manifest -# named argument: -# -# -# -# :: -# -# add_jar(example MANIFEST /path/to/manifest) -# -# -# -# :: -# -# To add a VERSION to the target output name you can set it using -# the VERSION named argument to add_jar. This will create a jar file with the -# name shibboleet-1.0.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) -# -# -# -# :: -# -# If the target is a JNI library, 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}) -# -# -# -# :: -# -# If a single target needs to produce more than one jar from its -# java source code, to prevent the accumulation of duplicate class -# files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior -# to calling the add_jar() function: -# -# -# -# :: -# -# 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) -# -# -# -# :: -# -# For an optimum usage of option GENERATE_NATIVE_HEADERS, 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 command -# target_link_libraries. -# -# -# :: -# -# 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) -# -# -# Target Properties: -# -# :: -# -# The add_jar() function sets some target properties. You can get these -# properties with the -# get_property(TARGET <target_name> PROPERTY <propery_name>) -# command. -# -# -# -# :: -# -# 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. -# -# :: -# -# 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 stor 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. The name of the full path to a file that is -# searched for is specified by the names listed after NAMES argument. -# Additional search locations can be specified after the PATHS argument. -# If you require special a version of a jar file you can specify it with -# the VERSIONS argument. The argument after DOC will be used for the -# documentation string in the cache. -# -# :: -# -# install_jar(target_name destination) -# install_jar(target_name DESTINATION destination [COMPONENT component]) -# -# This command installs the TARGET_NAME files to the given DESTINATION. -# It should be called in the same scope as add_jar() or it will fail. -# -# Target Properties: -# -# :: -# -# The install_jar() function sets the INSTALL_DESTINATION target property -# on jars so installed. This property holds the DESTINATION as described -# above, and is used by install_jar_exports(). You can get this property -# with the -# get_property(TARGET <target_name> PROPERTY INSTALL_DESTINATION) -# command. -# -# -# -# :: -# -# 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. -# -# :: -# -# install_jar_exports(TARGETS jars... -# [NAMESPACE <namespace>] -# FILE <filename> -# DESTINATION <dir> [COMPONENT <component>]) -# -# This command installs a target export file ``<filename>`` for the named jar -# targets to the given ``DESTINATION``. Its function is similar to that of -# :command:`install(EXPORTS ...)`. -# -# :: -# -# export_jars(TARGETS jars... -# [NAMESPACE <namespace>] -# FILE <filename>) -# -# This command writes a target export file ``<filename>`` for the named jar -# targets. Its function is similar to that of :command:`export(...)`. -# -# :: -# -# create_javadoc(<VAR> -# PACKAGES pkg1 [pkg2 ...] -# [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] -# ) -# -# Create java documentation based on files or packages. For more -# details please read the javadoc manpage. -# -# There are two main signatures for create_javadoc. The first signature -# works with package names on a path with source files: -# -# :: -# -# Example: -# 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(<VAR> -# FILES file1 [file2 ...] -# [CLASSPATH <classpath>] -# [INSTALLPATH <install path>] -# [DOCTITLE "the documentation title"] -# [WINDOWTITLE "the title of the document"] -# [AUTHOR TRUE|FALSE] -# [USE TRUE|FALSE] -# [VERSION TRUE|FALSE] -# ) -# -# -# -# Example: -# -# :: -# -# create_javadoc(my_example_doc -# FILES ${example_SRCS} -# 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. These options are the same -# as what you can find in the javadoc manpage. Please look at the -# manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and VERSION. -# -# The documentation will be by default installed to -# -# :: -# -# ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR> -# -# -# -# if you don't set the INSTALLPATH. -# -# :: -# -# create_javah(TARGET <target> -# GENERATED_FILES <VAR> -# CLASSES <class>... -# [CLASSPATH <classpath>...] -# [DEPENDS <depend>...] -# [OUTPUT_NAME <path>|OUTPUT_DIR <path>] -# ) -# -# Create C header files from java classes. These files provide the connective glue -# that allow your Java and C code to interact. -# -# This command will no longer be supported starting with version 10 of the JDK due -# to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_. -# Command ``add_jar(GENERATE_NATIVE_HEADERS)`` must be used instead. -# -# There are two main signatures for create_javah. The first signature -# returns generated files through variable specified by GENERATED_FILES option: -# -# :: -# -# 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. -# -# :: -# -# Example: -# Create_javah(TARGET target_headers -# CLASSES org.cmake.HelloWorld -# CLASSPATH hello.jar -# ) -# -# -# -# Both signatures share same options. -# -# ``CLASSES <class>...`` -# Specifies Java classes used to generate headers. -# -# ``CLASSPATH <classpath>...`` -# Specifies various paths to look up classes. Here .class files, jar files or targets -# created by command add_jar can be used. -# -# ``DEPENDS <depend>...`` -# Targets on which the javah target depends -# -# ``OUTPUT_NAME <path>`` -# 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 <path>`` -# 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 output directory. +#[=======================================================================[.rst: +UseJava +------- + +Use Module for Java + +This file provides functions for Java. It is assumed that +FindJava.cmake has already been loaded. See FindJava.cmake for +information on how to load Java into your CMake project. + +:: + + add_jar(target_name + [SOURCES] source1 [source2 ...] [resource1 ...] + [INCLUDE_JARS jar1 [jar2 ...]] + [ENTRY_POINT entry] + [VERSION version] + [OUTPUT_NAME name] + [OUTPUT_DIR dir] + [GENERATE_NATIVE_HEADERS target [DESTINATION dir]] + ) + +This command creates a <target_name>.jar. It compiles the given +source files (source) and adds the given resource files (resource) 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. The list of include 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). + +The default OUTPUT_DIR can also be changed by setting the variable +CMAKE_JAVA_TARGET_OUTPUT_DIR. + +Optionally, using option GENERATE_NATIVE_HEADERS, native header files can be generated +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 output directory for +generated header files. + +GENERATE_NATIVE_HEADERS option requires, at least, version 1.8 of the JDK. + +Additional instructions: + +:: + + To add compile flags to the target you can set these flags with + the following variable: + + + +:: + + set(CMAKE_JAVA_COMPILE_FLAGS -nowarn) + + + +:: + + To add a path or a jar file to the class path you can do this + with the CMAKE_JAVA_INCLUDE_PATH variable. + + + +:: + + set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar) + + + +:: + + To use a different output name for the target you can set it with: + + + +:: + + add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar) + + + +:: + + To use a different output directory than CMAKE_CURRENT_BINARY_DIR + you can set it with: + + + +:: + + add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin) + + + +:: + + To define an entry point in your jar you can set it with the ENTRY_POINT + named argument: + + + +:: + + add_jar(example ENTRY_POINT com/examples/MyProject/Main) + + + +:: + + To define a custom manifest for the jar, you can set it with the manifest + named argument: + + + +:: + + add_jar(example MANIFEST /path/to/manifest) + + + +:: + + To add a VERSION to the target output name you can set it using + the VERSION named argument to add_jar. This will create a jar file with the + name shibboleet-1.0.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) + + + +:: + + If the target is a JNI library, 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}) + + + +:: + + If a single target needs to produce more than one jar from its + java source code, to prevent the accumulation of duplicate class + files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior + to calling the add_jar() function: + + + +:: + + 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) + + + +:: + + For an optimum usage of option GENERATE_NATIVE_HEADERS, 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 command + target_link_libraries. + + +:: + + 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) + + +Target Properties: + +:: + + The add_jar() function sets some target properties. You can get these + properties with the + get_property(TARGET <target_name> PROPERTY <propery_name>) + command. + + + +:: + + 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. + +:: + + 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 stor 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. The name of the full path to a file that is +searched for is specified by the names listed after NAMES argument. +Additional search locations can be specified after the PATHS argument. +If you require special a version of a jar file you can specify it with +the VERSIONS argument. The argument after DOC will be used for the +documentation string in the cache. + +:: + + install_jar(target_name destination) + install_jar(target_name DESTINATION destination [COMPONENT component]) + +This command installs the TARGET_NAME files to the given DESTINATION. +It should be called in the same scope as add_jar() or it will fail. + +Target Properties: + +:: + + The install_jar() function sets the INSTALL_DESTINATION target property + on jars so installed. This property holds the DESTINATION as described + above, and is used by install_jar_exports(). You can get this property + with the + get_property(TARGET <target_name> PROPERTY INSTALL_DESTINATION) + command. + + + +:: + + 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. + +:: + + install_jar_exports(TARGETS jars... + [NAMESPACE <namespace>] + FILE <filename> + DESTINATION <dir> [COMPONENT <component>]) + +This command installs a target export file ``<filename>`` for the named jar +targets to the given ``DESTINATION``. Its function is similar to that of +:command:`install(EXPORTS ...)`. + +:: + + export_jars(TARGETS jars... + [NAMESPACE <namespace>] + FILE <filename>) + +This command writes a target export file ``<filename>`` for the named jar +targets. Its function is similar to that of :command:`export(...)`. + +:: + + create_javadoc(<VAR> + PACKAGES pkg1 [pkg2 ...] + [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] + ) + +Create java documentation based on files or packages. For more +details please read the javadoc manpage. + +There are two main signatures for create_javadoc. The first signature +works with package names on a path with source files: + +:: + + Example: + 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(<VAR> + FILES file1 [file2 ...] + [CLASSPATH <classpath>] + [INSTALLPATH <install path>] + [DOCTITLE "the documentation title"] + [WINDOWTITLE "the title of the document"] + [AUTHOR TRUE|FALSE] + [USE TRUE|FALSE] + [VERSION TRUE|FALSE] + ) + + + +Example: + +:: + + create_javadoc(my_example_doc + FILES ${example_SRCS} + 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. These options are the same +as what you can find in the javadoc manpage. Please look at the +manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and VERSION. + +The documentation will be by default installed to + +:: + + ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR> + + + +if you don't set the INSTALLPATH. + +:: + + create_javah(TARGET <target> + GENERATED_FILES <VAR> + CLASSES <class>... + [CLASSPATH <classpath>...] + [DEPENDS <depend>...] + [OUTPUT_NAME <path>|OUTPUT_DIR <path>] + ) + +Create C header files from java classes. These files provide the connective glue +that allow your Java and C code to interact. + +This command will no longer be supported starting with version 10 of the JDK due +to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_. +Command ``add_jar(GENERATE_NATIVE_HEADERS)`` must be used instead. + +There are two main signatures for create_javah. The first signature +returns generated files through variable specified by GENERATED_FILES option: + +:: + + 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. + +:: + + Example: + Create_javah(TARGET target_headers + CLASSES org.cmake.HelloWorld + CLASSPATH hello.jar + ) + + + +Both signatures share same options. + + ``CLASSES <class>...`` + Specifies Java classes used to generate headers. + + ``CLASSPATH <classpath>...`` + Specifies various paths to look up classes. Here .class files, jar files or targets + created by command add_jar can be used. + + ``DEPENDS <depend>...`` + Targets on which the javah target depends + + ``OUTPUT_NAME <path>`` + 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 <path>`` + 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 output directory. +#]=======================================================================] function (__java_copy_file src dest comment) add_custom_command( diff --git a/Modules/UseJavaClassFilelist.cmake b/Modules/UseJavaClassFilelist.cmake index c2f9afa..1c4baa9 100644 --- a/Modules/UseJavaClassFilelist.cmake +++ b/Modules/UseJavaClassFilelist.cmake @@ -1,17 +1,18 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# UseJavaClassFilelist -# -------------------- -# -# -# -# -# -# This script create a list of compiled Java class files to be added to -# a jar file. This avoids including cmake files which get created in -# the binary directory. +#[=======================================================================[.rst: +UseJavaClassFilelist +-------------------- + + + + + +This script create a list of compiled Java class files to be added to +a jar file. This avoids including cmake files which get created in +the binary directory. +#]=======================================================================] if (CMAKE_JAVA_CLASS_OUTPUT_PATH) if (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}") diff --git a/Modules/UseJavaSymlinks.cmake b/Modules/UseJavaSymlinks.cmake index 358b9ef..3969f54 100644 --- a/Modules/UseJavaSymlinks.cmake +++ b/Modules/UseJavaSymlinks.cmake @@ -1,15 +1,16 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# UseJavaSymlinks -# --------------- -# -# -# -# -# -# Helper script for UseJava.cmake +#[=======================================================================[.rst: +UseJavaSymlinks +--------------- + + + + + +Helper script for UseJava.cmake +#]=======================================================================] if (UNIX AND _JAVA_TARGET_OUTPUT_LINK) if (_JAVA_TARGET_OUTPUT_NAME) diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index 28618eb..32d228d 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -1,24 +1,25 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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 +#[=======================================================================[.rst: +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 +#]=======================================================================] find_program(PKGCONFIG_EXECUTABLE NAMES pkg-config ) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index c8eab77..dc2348e 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -1,15 +1,16 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# UseQt4 -# ------ -# -# Use Module for QT4 -# -# Sets up C and C++ to use Qt 4. It is assumed that FindQt.cmake has -# already been loaded. See FindQt.cmake for information on how to load -# Qt 4 into your CMake project. +#[=======================================================================[.rst: +UseQt4 +------ + +Use Module for QT4 + +Sets up C and C++ to use Qt 4. It is assumed that FindQt.cmake has +already been loaded. See FindQt.cmake for information on how to load +Qt 4 into your CMake project. +#]=======================================================================] add_definitions(${QT_DEFINITIONS}) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>) diff --git a/Modules/Use_wxWindows.cmake b/Modules/Use_wxWindows.cmake index 7cdd92e..782874c 100644 --- a/Modules/Use_wxWindows.cmake +++ b/Modules/Use_wxWindows.cmake @@ -1,36 +1,37 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# Use_wxWindows -# ------------- -# -# Deprecated. 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. +#[=======================================================================[.rst: +Use_wxWindows +------------- + +.. deprecated:: 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. +#]=======================================================================] # ----------------------------------------------------- # 16.Feb.2004: changed INCLUDE to FIND_PACKAGE to read from users own non-system CMAKE_MODULE_PATH (Jan Woetzel JW) @@ -66,4 +67,3 @@ if(WXWINDOWS_FOUND) else() message(SEND_ERROR "wxWindows not found by Use_wxWindows.cmake") endif() - diff --git a/Modules/UsewxWidgets.cmake b/Modules/UsewxWidgets.cmake index a50d03d..eed0410 100644 --- a/Modules/UsewxWidgets.cmake +++ b/Modules/UsewxWidgets.cmake @@ -1,41 +1,42 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# 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> +#[=======================================================================[.rst: +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> +#]=======================================================================] # debug message and logging. # comment these out for distribution diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 2f7c80a..1f13096 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -1,22 +1,24 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# WriteBasicConfigVersionFile -# --------------------------- -# -# -# -# :: -# -# WRITE_BASIC_CONFIG_VERSION_FILE( filename -# [VERSION major.minor.patch] -# COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion) -# ) -# -# -# -# Deprecated, see WRITE_BASIC_PACKAGE_VERSION_FILE(), it is identical. +#[=======================================================================[.rst: +WriteBasicConfigVersionFile +--------------------------- + +.. deprecated:: 3.0 + + Use the identical command :command:`write_basic_package_version_file()` + from module :module:`CMakePackageConfigHelpers`. + +:: + + WRITE_BASIC_CONFIG_VERSION_FILE( filename + [VERSION major.minor.patch] + COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion) + ) + + +#]=======================================================================] function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 3718e9d..a556567 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -1,236 +1,237 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -#.rst: -# WriteCompilerDetectionHeader -# ---------------------------- -# -# This module provides the function write_compiler_detection_header(). -# -# The ``WRITE_COMPILER_DETECTION_HEADER`` 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] -# ) -# -# The ``write_compiler_detection_header`` function 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: -# -# .. code-block:: cmake -# -# 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 :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` -# variable is used if no explicit version is specified. -# (As of CMake version |release| 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 -# :variable:`CMAKE_<LANG>_COMPILER_ID` variable. -# Available features in this version of CMake are listed in the -# :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and -# :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties. -# The ``{c,cxx}_std_*`` meta-features are ignored if requested. -# -# See the :manual:`cmake-compile-features(7)` manual for information on -# compile features. -# -# ``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. -# -# ``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. -# -# 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: -# -# .. code-block:: cmake -# -# write_compiler_detection_header( -# FILE climbingstats_compiler_detection.h -# PREFIX ClimbingStats -# COMPILERS GNU Clang AppleClang MSVC Intel -# FEATURES cxx_variadic_templates -# ) -# -# .. code-block:: c++ -# -# #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: -# -# .. code-block:: c++ -# -# 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: -# -# .. code-block:: cmake -# -# add_library(compat_support ${srcs}) -# target_compile_definitions(compat_support -# PRIVATE -# CompatSupport_DEPRECATED= -# ) +#[=======================================================================[.rst: +WriteCompilerDetectionHeader +---------------------------- + +This module provides the function write_compiler_detection_header(). + +The ``WRITE_COMPILER_DETECTION_HEADER`` 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] + ) + +The ``write_compiler_detection_header`` function 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: + +.. code-block:: cmake + + 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 :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` +variable is used if no explicit version is specified. +(As of CMake version |release| 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 +:variable:`CMAKE_<LANG>_COMPILER_ID` variable. +Available features in this version of CMake are listed in the +:prop_gbl:`CMAKE_C_KNOWN_FEATURES` and +:prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties. +The ``{c,cxx}_std_*`` meta-features are ignored if requested. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features. + +``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. + +``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. + +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: + +.. code-block:: cmake + + write_compiler_detection_header( + FILE climbingstats_compiler_detection.h + PREFIX ClimbingStats + COMPILERS GNU Clang AppleClang MSVC Intel + FEATURES cxx_variadic_templates + ) + +.. code-block:: c++ + + #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: + +.. code-block:: c++ + + 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: + +.. code-block:: cmake + + add_library(compat_support ${srcs}) + target_compile_definitions(compat_support + PRIVATE + CompatSupport_DEPRECATED= + ) +#]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerIdDetection.cmake) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bea9c96..2c106b6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 13) -set(CMake_VERSION_PATCH 20181023) +set(CMake_VERSION_PATCH 20181029) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0e48ca8..27b8599 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -421,7 +421,8 @@ std::string cmComputeLinkInformation::GetRPathLinkString() const return ""; } - // Construct the linker runtime search path. + // Construct the linker runtime search path. These MUST NOT contain tokens + // such as $ORIGIN, see https://sourceware.org/bugzilla/show_bug.cgi?id=16936 return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":"); } @@ -1702,6 +1703,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + // Select whether to use $ORIGIN in RPATHs for artifacts in the build tree. + std::string const& originToken = this->Makefile->GetSafeDefinition( + "CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN"); + std::string targetOutputDir = this->Target->GetDirectory(this->Config); + bool use_relative_build_rpath = + this->Target->GetPropertyAsBool("BUILD_RPATH_USE_ORIGIN") && + !originToken.empty() && !targetOutputDir.empty(); + // Construct the RPATH. std::set<std::string> emitted; if (use_install_rpath) { @@ -1711,6 +1720,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, if (use_build_rpath) { // Add directories explicitly specified by user if (const char* build_rpath = this->Target->GetProperty("BUILD_RPATH")) { + // This will not resolve entries to use $ORIGIN, the user is expected to + // do that if necessary. cmCLI_ExpandListUnique(build_rpath, runtimeDirs, emitted); } } @@ -1728,6 +1739,8 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); + std::string const& topBinaryDir = + this->CMakeInstance->GetHomeOutputDirectory(); for (std::string const& ri : rdirs) { // Put this directory in the rpath if using build-tree rpath // support or if using the link path as an rpath. @@ -1741,6 +1754,18 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, d += "/"; d += suffix; cmSystemTools::ConvertToUnixSlashes(d); + } else if (use_relative_build_rpath) { + // If expansion of the $ORIGIN token is supported and permitted per + // policy, use relative paths in the RPATH. + if (cmSystemTools::ComparePath(d, topBinaryDir) || + cmSystemTools::IsSubDirectory(d, topBinaryDir)) { + d = cmSystemTools::RelativePath(targetOutputDir, d); + if (!d.empty()) { + d = originToken + "/" + d; + } else { + d = originToken; + } + } } if (emitted.insert(d).second) { runtimeDirs.push_back(std::move(d)); @@ -1749,8 +1774,6 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // Do not add any path inside the source or build tree. std::string const& topSourceDir = this->CMakeInstance->GetHomeDirectory(); - std::string const& topBinaryDir = - this->CMakeInstance->GetHomeOutputDirectory(); if (!cmSystemTools::ComparePath(ri, topSourceDir) && !cmSystemTools::ComparePath(ri, topBinaryDir) && !cmSystemTools::IsSubDirectory(ri, topSourceDir) && diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 4aa52c3..da3daf8 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -878,12 +878,13 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir, const std::string& projectName, bool dryRun) { - std::string buildDir = cmSystemTools::ConvertToOutputPath(bindir); - std::string sln = buildDir + "\\" + projectName + ".sln"; + std::string sln = bindir + "/" + projectName + ".sln"; if (dryRun) { return cmSystemTools::FileExists(sln, true); } + sln = cmSystemTools::ConvertToOutputPath(sln); + return std::async(std::launch::async, OpenSolution, sln).get(); } diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index c9bbde1..025c6e4 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -25,6 +25,23 @@ cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer() { } +static bool cmLinkItemValidForDevice(std::string const& item) +{ + // Valid items are: + // * Non-flags (does not start in '-') + // * Specific flags --library, --library-path, -l, -L + // For example: + // * 'cublas_device' => pass-along + // * '--library pthread' => pass-along + // * '-lpthread' => pass-along + // * '-pthread' => drop + // * '-a' => drop + return (!cmHasLiteralPrefix(item, "-") || // + cmHasLiteralPrefix(item, "-l") || // + cmHasLiteralPrefix(item, "-L") || // + cmHasLiteralPrefix(item, "--library")); +} + std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( cmComputeLinkInformation& cli, std::string const& stdLibString) { @@ -69,7 +86,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( } out += this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value)); - } else { + } else if (cmLinkItemValidForDevice(item.Value)) { out += item.Value; } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index d0495f7..4689f42 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -481,7 +481,7 @@ std::ostream& operator<<(std::ostream& os, BT<std::string> const& s) } std::vector<BT<std::string>> ExpandListWithBacktrace( - const char* list, cmListFileBacktrace const& bt) + std::string const& list, cmListFileBacktrace const& bt) { std::vector<BT<std::string>> result; std::vector<std::string> tmp; diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 7c2802e..9e4a833 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -199,7 +199,8 @@ public: std::ostream& operator<<(std::ostream& os, BT<std::string> const& s); std::vector<BT<std::string>> ExpandListWithBacktrace( - const char* list, cmListFileBacktrace const& bt = cmListFileBacktrace()); + std::string const& list, + cmListFileBacktrace const& bt = cmListFileBacktrace()); struct cmListFile { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7beeb71..d5a18e6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2108,7 +2108,7 @@ void cmLocalGenerator::AppendIncludeDirectories( } void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, - const char* defines_list) const + std::string const& defines_list) const { std::set<BT<std::string>> tmp; this->AppendDefines(tmp, ExpandListWithBacktrace(defines_list)); @@ -2118,10 +2118,10 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, } void cmLocalGenerator::AppendDefines(std::set<BT<std::string>>& defines, - const char* defines_list) const + std::string const& defines_list) const { // Short-circuit if there are no definitions. - if (!defines_list) { + if (defines_list.empty()) { return; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 95a8a6a..3dd6929 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -169,19 +169,9 @@ public: * command line. */ void AppendDefines(std::set<std::string>& defines, - const char* defines_list) const; - void AppendDefines(std::set<std::string>& defines, - std::string const& defines_list) const - { - this->AppendDefines(defines, defines_list.c_str()); - } + std::string const& defines_list) const; void AppendDefines(std::set<BT<std::string>>& defines, - const char* defines_list) const; - void AppendDefines(std::set<BT<std::string>>& defines, - std::string const& defines_list) const - { - this->AppendDefines(defines, defines_list.c_str()); - } + std::string const& defines_list) const; void AppendDefines(std::set<BT<std::string>>& defines, const std::vector<BT<std::string>>& defines_vec) const; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index d05d660..568ee82 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1733,6 +1733,32 @@ void list_item_verbose(FILE* out, struct archive_entry* entry) fflush(out); } +bool la_diagnostic(struct archive* ar, __LA_SSIZE_T r) +{ + // See archive.h definition of ARCHIVE_OK for return values. + + if (r >= ARCHIVE_OK) { + return true; + } + + if (r >= ARCHIVE_WARN) { + const char* warn = archive_error_string(ar); + if (!warn) { + warn = "unknown warning"; + } + std::cerr << "cmake -E tar: warning: " << warn << '\n'; + return true; + } + + // Error. + const char* err = archive_error_string(ar); + if (!err) { + err = "unknown error"; + } + std::cerr << "cmake -E tar: error: " << err << '\n'; + return false; +} + // Return 'true' on success bool copy_data(struct archive* ar, struct archive* aw) { @@ -1746,24 +1772,17 @@ bool copy_data(struct archive* ar, struct archive* aw) # endif for (;;) { - // Return value: - // * ARCHIVE_OK - read succeed - // * ARCHIVE_EOF - no more data to read left + // See archive.h definition of ARCHIVE_OK for return values. r = archive_read_data_block(ar, &buff, &size, &offset); if (r == ARCHIVE_EOF) { return true; } - if (r != ARCHIVE_OK) { + if (!la_diagnostic(ar, r)) { return false; } - // Return value: - // * >= ARCHIVE_OK - write succeed - // * < ARCHIVE_OK - write failed - const __LA_SSIZE_T w_size = - archive_write_data_block(aw, buff, size, offset); - if (w_size < ARCHIVE_OK) { - cmSystemTools::Message("archive_write_data_block()", - archive_error_string(aw)); + // See archive.h definition of ARCHIVE_OK for return values. + __LA_SSIZE_T const w = archive_write_data_block(aw, buff, size, offset); + if (!la_diagnostic(ar, w)) { return false; } } @@ -1822,7 +1841,6 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract) r = archive_write_header(ext, entry); if (r == ARCHIVE_OK) { if (!copy_data(a, ext)) { - cmSystemTools::Error("Problem with copy_data"); break; } r = archive_write_finish_entry(ext); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1458f01..987bdb3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -218,6 +218,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", nullptr); this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", nullptr); this->SetPropertyDefault("BUILD_RPATH", nullptr); + this->SetPropertyDefault("BUILD_RPATH_USE_ORIGIN", nullptr); this->SetPropertyDefault("INSTALL_NAME_DIR", nullptr); this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); diff --git a/Source/cmVS10CSharpFlagTable.h b/Source/cmVS10CSharpFlagTable.h index 18d587c..6ac7a76 100644 --- a/Source/cmVS10CSharpFlagTable.h +++ b/Source/cmVS10CSharpFlagTable.h @@ -21,8 +21,8 @@ static cmVS7FlagTable cmVS10CSharpFlagTable[] = { { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable }, { "", "link", "", "", 0 }, - { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired }, - { "ApplicationIcon", "win32icon", "", "", + { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired }, + { "ApplicationIcon", "win32icon:", "", "", cmIDEFlagTable::UserValueRequired }, { "ApplicationManifest", "win32manifest:", "", "", diff --git a/Source/cmVS11CSharpFlagTable.h b/Source/cmVS11CSharpFlagTable.h index e3ba83c..18b804a 100644 --- a/Source/cmVS11CSharpFlagTable.h +++ b/Source/cmVS11CSharpFlagTable.h @@ -21,8 +21,8 @@ static cmVS7FlagTable cmVS11CSharpFlagTable[] = { { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable }, { "", "link", "", "", 0 }, - { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired }, - { "ApplicationIcon", "win32icon", "", "", + { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired }, + { "ApplicationIcon", "win32icon:", "", "", cmIDEFlagTable::UserValueRequired }, { "ApplicationManifest", "win32manifest:", "", "", diff --git a/Source/cmVS12CSharpFlagTable.h b/Source/cmVS12CSharpFlagTable.h index f8db636..0370499 100644 --- a/Source/cmVS12CSharpFlagTable.h +++ b/Source/cmVS12CSharpFlagTable.h @@ -21,8 +21,8 @@ static cmVS7FlagTable cmVS12CSharpFlagTable[] = { { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable }, { "", "link", "", "", 0 }, - { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired }, - { "ApplicationIcon", "win32icon", "", "", + { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired }, + { "ApplicationIcon", "win32icon:", "", "", cmIDEFlagTable::UserValueRequired }, { "ApplicationManifest", "win32manifest:", "", "", diff --git a/Source/cmVS140CSharpFlagTable.h b/Source/cmVS140CSharpFlagTable.h index 055d5cb..f695f45 100644 --- a/Source/cmVS140CSharpFlagTable.h +++ b/Source/cmVS140CSharpFlagTable.h @@ -21,8 +21,8 @@ static cmVS7FlagTable cmVS140CSharpFlagTable[] = { { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable }, { "", "link", "", "", 0 }, - { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired }, - { "ApplicationIcon", "win32icon", "", "", + { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired }, + { "ApplicationIcon", "win32icon:", "", "", cmIDEFlagTable::UserValueRequired }, { "ApplicationManifest", "win32manifest:", "", "", diff --git a/Source/cmVS141CSharpFlagTable.h b/Source/cmVS141CSharpFlagTable.h index 66c61bd..1f84097 100644 --- a/Source/cmVS141CSharpFlagTable.h +++ b/Source/cmVS141CSharpFlagTable.h @@ -21,8 +21,8 @@ static cmVS7FlagTable cmVS141CSharpFlagTable[] = { { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable }, { "", "link", "", "", 0 }, - { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired }, - { "ApplicationIcon", "win32icon", "", "", + { "Win32Resource", "win32res:", "", "", cmIDEFlagTable::UserValueRequired }, + { "ApplicationIcon", "win32icon:", "", "", cmIDEFlagTable::UserValueRequired }, { "ApplicationManifest", "win32manifest:", "", "", diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7383efd..eb1a27e 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1122,6 +1122,10 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( Elem& e1, std::string const& config) { + if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) { + return; + } + cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; Options& o = *(this->ClOptions[config]); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 43aec00..a2fcc16 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -90,6 +90,7 @@ FOREACH(p CMP0048 # CMake 3.0, Let the project command manage version variables. CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature. CMP0063 # CMake 3.3, Honor visibility properties for all target types. + CMP0069 # CMake 3.9, INTERPROCEDURAL_OPTIMIZATION is enforced when enabled. ) IF(POLICY ${p}) CMAKE_POLICY(SET ${p} NEW) diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt index 0e3e39e..84b58ca 100644 --- a/Tests/CSharpOnly/CMakeLists.txt +++ b/Tests/CSharpOnly/CMakeLists.txt @@ -8,3 +8,6 @@ add_library(lib2 SHARED lib2.cs) add_executable(CSharpOnly csharponly.cs) target_link_libraries(CSharpOnly lib1 lib2) + +add_custom_target(CSharpCustom SOURCES empty.cs) +add_custom_target(custom.cs DEPENDS empty.txt) diff --git a/Tests/CSharpOnly/empty.cs b/Tests/CSharpOnly/empty.cs new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CSharpOnly/empty.cs diff --git a/Tests/CSharpOnly/empty.txt b/Tests/CSharpOnly/empty.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CSharpOnly/empty.txt diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 8a43df5..1b3daa6 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -4,5 +4,6 @@ ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures) ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary) ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels) ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude) +ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries) ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags) ADD_TEST_MACRO(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt new file mode 100644 index 0000000..cb47b09 --- /dev/null +++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.13) +project(ProperDeviceLibraries CXX CUDA) + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") +set(CMAKE_CUDA_STANDARD 11) + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads) + +add_executable(ProperDeviceLibraries main.cu) +set_target_properties(ProperDeviceLibraries + PROPERTIES CUDA_SEPARABLE_COMPILATION ON) + +add_library(UseThreadsMixed SHARED use_pthreads.cxx use_pthreads.cu) +target_link_libraries(UseThreadsMixed Threads::Threads) + +add_library(UseThreadsCuda SHARED use_pthreads.cu) +target_link_libraries(UseThreadsCuda Threads::Threads) + +target_link_libraries(ProperDeviceLibraries PRIVATE UseThreadsMixed UseThreadsCuda) + +if(THREADS_HAVE_PTHREAD_ARG AND CMAKE_USE_PTHREADS_INIT) + add_library(UseExplicitPThreadsFlag SHARED use_pthreads.cu) + target_compile_options(UseExplicitPThreadsFlag PUBLIC "-Xcompiler=-pthread") + target_link_libraries(UseExplicitPThreadsFlag PUBLIC "-pthread") + + add_library(UseExplicitLThreadsFlag SHARED use_pthreads.cu) + target_compile_options(UseExplicitLThreadsFlag PUBLIC "-Xcompiler=-pthread") + target_link_libraries(UseExplicitLThreadsFlag PUBLIC "-lpthread") + + add_library(UseExplicitLongThreadsFlag SHARED use_pthreads.cu) + target_link_libraries(UseExplicitLongThreadsFlag PUBLIC "--library pthread") + + target_link_libraries(ProperDeviceLibraries PRIVATE UseExplicitPThreadsFlag UseExplicitLThreadsFlag UseExplicitLongThreadsFlag) +endif() + +if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0) + #CUDA 10 removed the cublas_device library + target_link_libraries(ProperDeviceLibraries PRIVATE cublas_device) +endif() + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET ProperDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu b/Tests/Cuda/ProperDeviceLibraries/main.cu index 2c7c388..8ceb0cc 100644 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu +++ b/Tests/Cuda/ProperDeviceLibraries/main.cu @@ -3,6 +3,15 @@ #include <cuda_runtime.h> #include <iostream> +#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +# include <pthread.h> +static int verify_linking_to_pthread() +{ + return static_cast<int>(pthread_self()); +} +#endif + // this test only makes sense for versions of CUDA that ships // static libraries that have separable compilation device symbols #if __CUDACC_VER_MAJOR__ <= 9 diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu new file mode 100644 index 0000000..c57b8a8 --- /dev/null +++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu @@ -0,0 +1,9 @@ + +#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +# include <pthread.h> +static int verify_linking_to_pthread_cuda() +{ + return static_cast<int>(pthread_self()); +} +#endif diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx new file mode 100644 index 0000000..dc7c208 --- /dev/null +++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx @@ -0,0 +1,9 @@ + +#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) + +# include <pthread.h> +static int verify_linking_to_pthread_cxx() +{ + return static_cast<int>(pthread_self()); +} +#endif diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 5b7c0e6..9c4f86a 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -3,7 +3,6 @@ ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) -ADD_TEST_MACRO(CudaOnly.LinkSystemDeviceLibraries CudaOnlyLinkSystemDeviceLibraries) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt deleted file mode 100644 index 7f7f606..0000000 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(LinkSystemDeviceLibraries CUDA) - -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") -set(CMAKE_CUDA_STANDARD 11) - -add_executable(CudaOnlyLinkSystemDeviceLibraries main.cu) -set_target_properties( CudaOnlyLinkSystemDeviceLibraries - PROPERTIES CUDA_SEPARABLE_COMPILATION ON) -target_link_libraries( CudaOnlyLinkSystemDeviceLibraries PRIVATE cublas_device) - -if(APPLE) - # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. - set_property(TARGET CudaOnlyLinkSystemDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) -endif() diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake index b544ba6..e00af58 100644 --- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake +++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake @@ -1,6 +1,6 @@ include(RunCMake) -if(SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$") +if(SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$") set(EXPECT_BSD 1) endif() diff --git a/Tests/RunCMake/RuntimePath/Relative.cmake b/Tests/RunCMake/RuntimePath/Relative.cmake new file mode 100644 index 0000000..203241f --- /dev/null +++ b/Tests/RunCMake/RuntimePath/Relative.cmake @@ -0,0 +1,69 @@ +enable_language(C) + +if(NOT CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN) + if(CMAKE_C_PLATFORM_ID STREQUAL "Linux") + # Sanity check for platform that is definitely known to support $ORIGIN. + message(FATAL_ERROR "Platform fails to report relative RPATH support") + else() + message(STATUS "Platform does not support relative RPATHs, skipping") + endif() + return() +endif() +set(CMAKE_BUILD_RPATH_USE_ORIGIN ON) + +function(CheckRpath target rpath) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -Dfile=$<TARGET_FILE:${target}> -Drpath=${rpath} + -P "${CMAKE_CURRENT_SOURCE_DIR}/RelativeCheck.cmake" + VERBATIM + ) +endfunction() + +if(CMAKE_C_COMPILER_ID STREQUAL "XL" AND CMAKE_BINARY_DIR MATCHES " ") + # XL 16.1.0.0 fails building the library if the output path contains a space. + set(externDir) + message(STATUS "Skipping external library test because of a toolchain bug") +else() + get_filename_component(externDir "${CMAKE_BINARY_DIR}" DIRECTORY) + set(externDir "${externDir}/Relative-extern") +endif() + +add_library(utils SHARED A.c) +add_library(utils-sub SHARED A.c) +set_property(TARGET utils-sub PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs) +if(externDir) + add_library(utils-extern SHARED A.c) + set_property(TARGET utils-extern PROPERTY LIBRARY_OUTPUT_DIRECTORY ${externDir}) +endif() + +add_executable(main main.c) +target_link_libraries(main utils) +CheckRpath(main "\$ORIGIN") + +add_executable(main-norel main.c) +target_link_libraries(main-norel utils) +set_property(TARGET main-norel PROPERTY BUILD_RPATH_USE_ORIGIN OFF) +CheckRpath(main-norel "${CMAKE_CURRENT_BINARY_DIR}") + +add_executable(mainsub main.c) +target_link_libraries(mainsub utils) +set_property(TARGET mainsub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +CheckRpath(mainsub "\$ORIGIN/../") + +add_executable(main-sub main.c) +target_link_libraries(main-sub utils-sub) +CheckRpath(main-sub "\$ORIGIN/libs") + +add_executable(mainsub-sub main.c) +target_link_libraries(mainsub-sub utils-sub) +set_property(TARGET mainsub-sub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +CheckRpath(mainsub-sub "\$ORIGIN/../libs") + +if(externDir) + # Binaries linking to libraries outside the build tree should have an absolute RPATH. + add_executable(main-extern main.c) + target_link_libraries(main-extern utils-extern) + CheckRpath(main-extern "${externDir}") +endif() diff --git a/Tests/RunCMake/RuntimePath/RelativeCheck.cmake b/Tests/RunCMake/RuntimePath/RelativeCheck.cmake new file mode 100644 index 0000000..9ee403f --- /dev/null +++ b/Tests/RunCMake/RuntimePath/RelativeCheck.cmake @@ -0,0 +1,4 @@ +file(RPATH_CHECK FILE "${file}" RPATH "${rpath}") +if(NOT EXISTS "${file}") + message(FATAL_ERROR "RPATH for ${file} did not contain the expected value") +endif() diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake index 3f238f2..6f1baa1 100644 --- a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake +++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake @@ -16,3 +16,17 @@ function(run_SymlinkImplicit) ${CMAKE_COMMAND} -Ddir=${RunCMake_TEST_BINARY_DIR} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake) endfunction() run_SymlinkImplicit() + +function(run_Relative) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Relative-build) + set(RunCMake_TEST_NO_CLEAN 1) + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(Relative) + run_cmake_command(Relative-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +run_Relative() diff --git a/Tests/RunCMake/RuntimePath/main.c b/Tests/RunCMake/RuntimePath/main.c index 8488f4e..181cd09 100644 --- a/Tests/RunCMake/RuntimePath/main.c +++ b/Tests/RunCMake/RuntimePath/main.c @@ -1,4 +1,6 @@ +extern int libA(void); + int main(void) { - return 0; + return libA(); } diff --git a/Utilities/Scripts/update-curl.bash b/Utilities/Scripts/update-curl.bash index b02180f..3d31e38 100755 --- a/Utilities/Scripts/update-curl.bash +++ b/Utilities/Scripts/update-curl.bash @@ -8,7 +8,7 @@ readonly name="curl" readonly ownership="Curl Upstream <curl-library@cool.haxx.se>" readonly subtree="Utilities/cmcurl" readonly repo="https://github.com/curl/curl.git" -readonly tag="curl-7_60_0" +readonly tag="curl-7_61_1" readonly shortlog=false readonly paths=" CMake/* diff --git a/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake b/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake index 9f7d296..15ba46e 100644 --- a/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake +++ b/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake @@ -4,57 +4,57 @@ option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide al mark_as_advanced(CURL_HIDDEN_SYMBOLS) if(CURL_HIDDEN_SYMBOLS) - set(SUPPORTS_SYMBOL_HIDING FALSE) + set(SUPPORTS_SYMBOL_HIDING FALSE) - if(CMAKE_C_COMPILER_ID MATCHES "Clang") - set(SUPPORTS_SYMBOL_HIDING TRUE) - set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))") - set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") - elseif(CMAKE_COMPILER_IS_GNUCC) - if(NOT CMAKE_VERSION VERSION_LESS 2.8.10) - set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION}) - else() - execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_VARIABLE GCC_VERSION) - endif() - if(NOT GCC_VERSION VERSION_LESS 3.4) - # note: this is considered buggy prior to 4.0 but the autotools don't care, so let's ignore that fact - set(SUPPORTS_SYMBOL_HIDING TRUE) - set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))") - set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") - endif() - elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) - set(SUPPORTS_SYMBOL_HIDING TRUE) - set(_SYMBOL_EXTERN "__global") - set(_CFLAG_SYMBOLS_HIDE "-xldscope=hidden") - elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) - # note: this should probably just check for version 9.1.045 but I'm not 100% sure - # so let's to it the same way autotools do. - set(SUPPORTS_SYMBOL_HIDING TRUE) - set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))") - set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") - check_c_source_compiles("#include <stdio.h> - int main (void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug) - if(NOT _no_bug) - set(SUPPORTS_SYMBOL_HIDING FALSE) - set(_SYMBOL_EXTERN "") - set(_CFLAG_SYMBOLS_HIDE "") - endif() - elseif(MSVC) - set(SUPPORTS_SYMBOL_HIDING TRUE) + if(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(SUPPORTS_SYMBOL_HIDING TRUE) + set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))") + set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") + elseif(CMAKE_COMPILER_IS_GNUCC) + if(NOT CMAKE_VERSION VERSION_LESS 2.8.10) + set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION}) + else() + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + endif() + if(NOT GCC_VERSION VERSION_LESS 3.4) + # note: this is considered buggy prior to 4.0 but the autotools don't care, so let's ignore that fact + set(SUPPORTS_SYMBOL_HIDING TRUE) + set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))") + set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") endif() + elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0) + set(SUPPORTS_SYMBOL_HIDING TRUE) + set(_SYMBOL_EXTERN "__global") + set(_CFLAG_SYMBOLS_HIDE "-xldscope=hidden") + elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0) + # note: this should probably just check for version 9.1.045 but I'm not 100% sure + # so let's to it the same way autotools do. + set(SUPPORTS_SYMBOL_HIDING TRUE) + set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))") + set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden") + check_c_source_compiles("#include <stdio.h> + int main (void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug) + if(NOT _no_bug) + set(SUPPORTS_SYMBOL_HIDING FALSE) + set(_SYMBOL_EXTERN "") + set(_CFLAG_SYMBOLS_HIDE "") + endif() + elseif(MSVC) + set(SUPPORTS_SYMBOL_HIDING TRUE) + endif() - set(HIDES_CURL_PRIVATE_SYMBOLS ${SUPPORTS_SYMBOL_HIDING}) + set(HIDES_CURL_PRIVATE_SYMBOLS ${SUPPORTS_SYMBOL_HIDING}) elseif(MSVC) - if(NOT CMAKE_VERSION VERSION_LESS 3.7) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #present since 3.4.3 but broken - set(HIDES_CURL_PRIVATE_SYMBOLS FALSE) - else() - message(WARNING "Hiding private symbols regardless CURL_HIDDEN_SYMBOLS being disabled.") - set(HIDES_CURL_PRIVATE_SYMBOLS TRUE) - endif() -elseif() + if(NOT CMAKE_VERSION VERSION_LESS 3.7) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #present since 3.4.3 but broken set(HIDES_CURL_PRIVATE_SYMBOLS FALSE) + else() + message(WARNING "Hiding private symbols regardless CURL_HIDDEN_SYMBOLS being disabled.") + set(HIDES_CURL_PRIVATE_SYMBOLS TRUE) + endif() +elseif() + set(HIDES_CURL_PRIVATE_SYMBOLS FALSE) endif() set(CURL_CFLAG_SYMBOLS_HIDE ${_CFLAG_SYMBOLS_HIDE}) diff --git a/Utilities/cmcurl/CMake/CurlTests.c b/Utilities/cmcurl/CMake/CurlTests.c index bc36c8e..ab244ac 100644 --- a/Utilities/cmcurl/CMake/CurlTests.c +++ b/Utilities/cmcurl/CMake/CurlTests.c @@ -507,30 +507,30 @@ main () #ifdef HAVE_GLIBC_STRERROR_R #include <string.h> #include <errno.h> + +void check(char c) {} + int main () { - char buffer[1024]; /* big enough to play with */ - char *string = - strerror_r(EACCES, buffer, sizeof(buffer)); - /* this should've returned a string */ - if(!string || !string[0]) - return 99; - return 0; + char buffer[1024]; + /* This will not compile if strerror_r does not return a char* */ + check(strerror_r(EACCES, buffer, sizeof(buffer))[0]); + return 0; } #endif #ifdef HAVE_POSIX_STRERROR_R #include <string.h> #include <errno.h> + +/* float, because a pointer can't be implicitly cast to float */ +void check(float f) {} + int main () { - char buffer[1024]; /* big enough to play with */ - int error = - strerror_r(EACCES, buffer, sizeof(buffer)); - /* This should've returned zero, and written an error string in the - buffer.*/ - if(!buffer[0] || error) - return 99; - return 0; + char buffer[1024]; + /* This will not compile if strerror_r does not return an int */ + check(strerror_r(EACCES, buffer, sizeof(buffer))); + return 0; } #endif #ifdef HAVE_FSETXATTR_6 diff --git a/Utilities/cmcurl/CMake/FindCARES.cmake b/Utilities/cmcurl/CMake/FindCARES.cmake index c4ab5f1..723044a 100644 --- a/Utilities/cmcurl/CMake/FindCARES.cmake +++ b/Utilities/cmcurl/CMake/FindCARES.cmake @@ -7,36 +7,36 @@ # also defined, but not for general use are # CARES_LIBRARY, where to find the c-ares library. -FIND_PATH(CARES_INCLUDE_DIR ares.h +find_path(CARES_INCLUDE_DIR ares.h /usr/local/include /usr/include ) -SET(CARES_NAMES ${CARES_NAMES} cares) -FIND_LIBRARY(CARES_LIBRARY +set(CARES_NAMES ${CARES_NAMES} cares) +find_library(CARES_LIBRARY NAMES ${CARES_NAMES} PATHS /usr/lib /usr/local/lib ) -IF (CARES_LIBRARY AND CARES_INCLUDE_DIR) - SET(CARES_LIBRARIES ${CARES_LIBRARY}) - SET(CARES_FOUND "YES") -ELSE (CARES_LIBRARY AND CARES_INCLUDE_DIR) - SET(CARES_FOUND "NO") -ENDIF (CARES_LIBRARY AND CARES_INCLUDE_DIR) +if(CARES_LIBRARY AND CARES_INCLUDE_DIR) + set(CARES_LIBRARIES ${CARES_LIBRARY}) + set(CARES_FOUND "YES") +else() + set(CARES_FOUND "NO") +endif() -IF (CARES_FOUND) - IF (NOT CARES_FIND_QUIETLY) - MESSAGE(STATUS "Found c-ares: ${CARES_LIBRARIES}") - ENDIF (NOT CARES_FIND_QUIETLY) -ELSE (CARES_FOUND) - IF (CARES_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find c-ares library") - ENDIF (CARES_FIND_REQUIRED) -ENDIF (CARES_FOUND) +if(CARES_FOUND) + if(NOT CARES_FIND_QUIETLY) + message(STATUS "Found c-ares: ${CARES_LIBRARIES}") + endif() +else() + if(CARES_FIND_REQUIRED) + message(FATAL_ERROR "Could not find c-ares library") + endif() +endif() -MARK_AS_ADVANCED( +mark_as_advanced( CARES_LIBRARY CARES_INCLUDE_DIR ) diff --git a/Utilities/cmcurl/CMake/FindGSS.cmake b/Utilities/cmcurl/CMake/FindGSS.cmake index 60dcb73..7a637fc 100644 --- a/Utilities/cmcurl/CMake/FindGSS.cmake +++ b/Utilities/cmcurl/CMake/FindGSS.cmake @@ -28,211 +28,209 @@ set(_GSS_ROOT_HINTS # try to find library using system pkg-config if user didn't specify root dir if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}") - if(UNIX) - find_package(PkgConfig QUIET) - pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME}) - list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}") - elseif(WIN32) - list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]") - endif() + if(UNIX) + find_package(PkgConfig QUIET) + pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME}) + list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}") + elseif(WIN32) + list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]") + endif() endif() if(NOT _GSS_FOUND) #not found by pkg-config. Let's take more traditional approach. - find_file(_GSS_CONFIGURE_SCRIPT - NAMES - "krb5-config" - HINTS - ${_GSS_ROOT_HINTS} - PATH_SUFFIXES - bin - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH + find_file(_GSS_CONFIGURE_SCRIPT + NAMES + "krb5-config" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + ) + + # if not found in user-supplied directories, maybe system knows better + find_file(_GSS_CONFIGURE_SCRIPT + NAMES + "krb5-config" + PATH_SUFFIXES + bin + ) + + if(_GSS_CONFIGURE_SCRIPT) + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi" + OUTPUT_VARIABLE _GSS_CFLAGS + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) + message(STATUS "CFLAGS: ${_GSS_CFLAGS}") + if(NOT _GSS_CONFIGURE_FAILED) # 0 means success + # should also work in an odd case when multiple directories are given + string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS) + string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}") + string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}") + + foreach(_flag ${_GSS_CFLAGS}) + if(_flag MATCHES "^-I.*") + string(REGEX REPLACE "^-I" "" _val "${_flag}") + list(APPEND _GSS_INCLUDE_DIR "${_val}") + else() + list(APPEND _GSS_COMPILER_FLAGS "${_flag}") + endif() + endforeach() + endif() + + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi" + OUTPUT_VARIABLE _GSS_LIB_FLAGS + RESULT_VARIABLE _GSS_CONFIGURE_FAILED ) + message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}") + + if(NOT _GSS_CONFIGURE_FAILED) # 0 means success + # this script gives us libraries and link directories. Blah. We have to deal with it. + string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS) + string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") + string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") + + foreach(_flag ${_GSS_LIB_FLAGS}) + if(_flag MATCHES "^-l.*") + string(REGEX REPLACE "^-l" "" _val "${_flag}") + list(APPEND _GSS_LIBRARIES "${_val}") + elseif(_flag MATCHES "^-L.*") + string(REGEX REPLACE "^-L" "" _val "${_flag}") + list(APPEND _GSS_LINK_DIRECTORIES "${_val}") + else() + list(APPEND _GSS_LINKER_FLAGS "${_flag}") + endif() + endforeach() + endif() - # if not found in user-supplied directories, maybe system knows better - find_file(_GSS_CONFIGURE_SCRIPT - NAMES - "krb5-config" - PATH_SUFFIXES - bin + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version" + OUTPUT_VARIABLE _GSS_VERSION + RESULT_VARIABLE _GSS_CONFIGURE_FAILED ) - if(_GSS_CONFIGURE_SCRIPT) - execute_process( - COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi" - OUTPUT_VARIABLE _GSS_CFLAGS - RESULT_VARIABLE _GSS_CONFIGURE_FAILED - ) -message(STATUS "CFLAGS: ${_GSS_CFLAGS}") - if(NOT _GSS_CONFIGURE_FAILED) # 0 means success - # should also work in an odd case when multiple directories are given - string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS) - string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}") - string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}") - - foreach(_flag ${_GSS_CFLAGS}) - if(_flag MATCHES "^-I.*") - string(REGEX REPLACE "^-I" "" _val "${_flag}") - list(APPEND _GSS_INCLUDE_DIR "${_val}") - else() - list(APPEND _GSS_COMPILER_FLAGS "${_flag}") - endif() - endforeach() - endif() + # older versions may not have the "--version" parameter. In this case we just don't care. + if(_GSS_CONFIGURE_FAILED) + set(_GSS_VERSION 0) + endif() - execute_process( - COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi" - OUTPUT_VARIABLE _GSS_LIB_FLAGS - RESULT_VARIABLE _GSS_CONFIGURE_FAILED - ) -message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}") - if(NOT _GSS_CONFIGURE_FAILED) # 0 means success - # this script gives us libraries and link directories. Blah. We have to deal with it. - string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS) - string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") - string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}") - - foreach(_flag ${_GSS_LIB_FLAGS}) - if(_flag MATCHES "^-l.*") - string(REGEX REPLACE "^-l" "" _val "${_flag}") - list(APPEND _GSS_LIBRARIES "${_val}") - elseif(_flag MATCHES "^-L.*") - string(REGEX REPLACE "^-L" "" _val "${_flag}") - list(APPEND _GSS_LINK_DIRECTORIES "${_val}") - else() - list(APPEND _GSS_LINKER_FLAGS "${_flag}") - endif() - endforeach() - endif() + execute_process( + COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor" + OUTPUT_VARIABLE _GSS_VENDOR + RESULT_VARIABLE _GSS_CONFIGURE_FAILED + ) + # older versions may not have the "--vendor" parameter. In this case we just don't care. + if(_GSS_CONFIGURE_FAILED) + set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter + else() + if(_GSS_VENDOR MATCHES ".*H|heimdal.*") + set(GSS_FLAVOUR "Heimdal") + else() + set(GSS_FLAVOUR "MIT") + endif() + endif() - execute_process( - COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version" - OUTPUT_VARIABLE _GSS_VERSION - RESULT_VARIABLE _GSS_CONFIGURE_FAILED - ) + else() # either there is no config script or we are on platform that doesn't provide one (Windows?) - # older versions may not have the "--version" parameter. In this case we just don't care. - if(_GSS_CONFIGURE_FAILED) - set(_GSS_VERSION 0) - endif() + find_path(_GSS_INCLUDE_DIR + NAMES + "gssapi/gssapi.h" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + include + inc + ) + if(_GSS_INCLUDE_DIR) #jay, we've found something + set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}") + check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS) - execute_process( - COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor" - OUTPUT_VARIABLE _GSS_VENDOR - RESULT_VARIABLE _GSS_CONFIGURE_FAILED - ) + if(_GSS_HAVE_MIT_HEADERS) + set(GSS_FLAVOUR "MIT") + else() + # prevent compiling the header - just check if we can include it + set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__") + check_include_file( "roken.h" _GSS_HAVE_ROKEN_H) + + check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H) + if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H) + set(GSS_FLAVOUR "Heimdal") + endif() + set(CMAKE_REQUIRED_DEFINITIONS "") + endif() + else() + # I'm not convienced if this is the right way but this is what autotools do at the moment + find_path(_GSS_INCLUDE_DIR + NAMES + "gssapi.h" + HINTS + ${_GSS_ROOT_HINTS} + PATH_SUFFIXES + include + inc + ) + + if(_GSS_INCLUDE_DIR) + set(GSS_FLAVOUR "Heimdal") + endif() + endif() + + # if we have headers, check if we can link libraries + if(GSS_FLAVOUR) + set(_GSS_LIBDIR_SUFFIXES "") + set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS}) + get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH) + list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT}) - # older versions may not have the "--vendor" parameter. In this case we just don't care. - if(_GSS_CONFIGURE_FAILED) - set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter + if(WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64") + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi64") + else() + set(_GSS_LIBNAME "libgssapi") + endif() else() - if(_GSS_VENDOR MATCHES ".*H|heimdal.*") - set(GSS_FLAVOUR "Heimdal") - else() - set(GSS_FLAVOUR "MIT") - endif() + list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386") + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi32") + else() + set(_GSS_LIBNAME "libgssapi") + endif() endif() - - else() # either there is no config script or we are on platform that doesn't provide one (Windows?) - - find_path(_GSS_INCLUDE_DIR - NAMES - "gssapi/gssapi.h" - HINTS - ${_GSS_ROOT_HINTS} - PATH_SUFFIXES - include - inc - ) - - if(_GSS_INCLUDE_DIR) #jay, we've found something - set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}") - check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS) - - if(_GSS_HAVE_MIT_HEADERS) - set(GSS_FLAVOUR "MIT") - else() - # prevent compiling the header - just check if we can include it - set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__") - check_include_file( "roken.h" _GSS_HAVE_ROKEN_H) - - check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H) - if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H) - set(GSS_FLAVOUR "Heimdal") - endif() - set(CMAKE_REQUIRED_DEFINITIONS "") - endif() + else() + list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS + if(GSS_FLAVOUR STREQUAL "MIT") + set(_GSS_LIBNAME "gssapi_krb5") else() - # I'm not convienced if this is the right way but this is what autotools do at the moment - find_path(_GSS_INCLUDE_DIR - NAMES - "gssapi.h" - HINTS - ${_GSS_ROOT_HINTS} - PATH_SUFFIXES - include - inc - ) - - if(_GSS_INCLUDE_DIR) - set(GSS_FLAVOUR "Heimdal") - endif() + set(_GSS_LIBNAME "gssapi") endif() + endif() - # if we have headers, check if we can link libraries - if(GSS_FLAVOUR) - set(_GSS_LIBDIR_SUFFIXES "") - set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS}) - get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH) - list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT}) - - if(WIN32) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64") - if(GSS_FLAVOUR STREQUAL "MIT") - set(_GSS_LIBNAME "gssapi64") - else() - set(_GSS_LIBNAME "libgssapi") - endif() - else() - list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386") - if(GSS_FLAVOUR STREQUAL "MIT") - set(_GSS_LIBNAME "gssapi32") - else() - set(_GSS_LIBNAME "libgssapi") - endif() - endif() - else() - list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS - if(GSS_FLAVOUR STREQUAL "MIT") - set(_GSS_LIBNAME "gssapi_krb5") - else() - set(_GSS_LIBNAME "gssapi") - endif() - endif() - - find_library(_GSS_LIBRARIES - NAMES - ${_GSS_LIBNAME} - HINTS - ${_GSS_LIBDIR_HINTS} - PATH_SUFFIXES - ${_GSS_LIBDIR_SUFFIXES} - ) - - endif() + find_library(_GSS_LIBRARIES + NAMES + ${_GSS_LIBNAME} + HINTS + ${_GSS_LIBDIR_HINTS} + PATH_SUFFIXES + ${_GSS_LIBDIR_SUFFIXES} + ) endif() + endif() else() - if(_GSS_PKG_${_MIT_MODNAME}_VERSION) - set(GSS_FLAVOUR "MIT") - set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION) - else() - set(GSS_FLAVOUR "Heimdal") - set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION) - endif() + if(_GSS_PKG_${_MIT_MODNAME}_VERSION) + set(GSS_FLAVOUR "MIT") + set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION) + else() + set(GSS_FLAVOUR "Heimdal") + set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION) + endif() endif() set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIR}) @@ -243,36 +241,34 @@ set(GSS_COMPILER_FLAGS ${_GSS_COMPILER_FLAGS}) set(GSS_VERSION ${_GSS_VERSION}) if(GSS_FLAVOUR) + if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest") + else() + set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest") + endif() - if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal") - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest") - else() - set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest") - endif() - - if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}") - file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str - REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$") + if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}") + file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str + REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$") - string(REGEX MATCH "[0-9]\\.[^\"]+" - GSS_VERSION "${heimdal_version_str}") - endif() + string(REGEX MATCH "[0-9]\\.[^\"]+" + GSS_VERSION "${heimdal_version_str}") + endif() - if(NOT GSS_VERSION) - set(GSS_VERSION "Heimdal Unknown") - endif() - elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT") - get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE) - if(WIN32 AND _MIT_VERSION) - set(GSS_VERSION "${_MIT_VERSION}") - else() - set(GSS_VERSION "MIT Unknown") - endif() + if(NOT GSS_VERSION) + set(GSS_VERSION "Heimdal Unknown") endif() + elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT") + get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE) + if(WIN32 AND _MIT_VERSION) + set(GSS_VERSION "${_MIT_VERSION}") + else() + set(GSS_VERSION "MIT Unknown") + endif() + endif() endif() - include(FindPackageHandleStandardArgs) set(_GSS_REQUIRED_VARS GSS_LIBRARIES GSS_FLAVOUR) diff --git a/Utilities/cmcurl/CMake/FindLibSSH2.cmake b/Utilities/cmcurl/CMake/FindLibSSH2.cmake index 12a7c61..84822db 100644 --- a/Utilities/cmcurl/CMake/FindLibSSH2.cmake +++ b/Utilities/cmcurl/CMake/FindLibSSH2.cmake @@ -5,14 +5,14 @@ # LIBSSH2_INCLUDE_DIR - the libssh2 include directory # LIBSSH2_LIBRARY - the libssh2 library name -if (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY) +if(LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY) set(LibSSH2_FIND_QUIETLY TRUE) -endif (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY) +endif() -FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h +find_path(LIBSSH2_INCLUDE_DIR libssh2.h ) -FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2 +find_library(LIBSSH2_LIBRARY NAMES ssh2 ) if(LIBSSH2_INCLUDE_DIR) @@ -27,9 +27,9 @@ if(LIBSSH2_INCLUDE_DIR) string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_PATCH "${LIBSSH2_VERSION_PATCH}") set(LIBSSH2_VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}") -endif(LIBSSH2_INCLUDE_DIR) +endif() include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY ) +find_package_handle_standard_args(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY ) -MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION) +mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION) diff --git a/Utilities/cmcurl/CMake/FindNGHTTP2.cmake b/Utilities/cmcurl/CMake/FindNGHTTP2.cmake index 4e566cf..348b961 100644 --- a/Utilities/cmcurl/CMake/FindNGHTTP2.cmake +++ b/Utilities/cmcurl/CMake/FindNGHTTP2.cmake @@ -14,5 +14,5 @@ find_package_handle_standard_args(NGHTTP2 "Could NOT find NGHTTP2" ) -set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR} ) +set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR}) set(NGHTTP2_LIBRARIES ${NGHTTP2_LIBRARY}) diff --git a/Utilities/cmcurl/CMake/Macros.cmake b/Utilities/cmcurl/CMake/Macros.cmake index 82aadca..7f71345 100644 --- a/Utilities/cmcurl/CMake/Macros.cmake +++ b/Utilities/cmcurl/CMake/Macros.cmake @@ -5,35 +5,35 @@ # multiple times with a sequence of possibly dependent libraries in # order of least-to-most-dependent. Some libraries depend on others # to link correctly. -macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) +macro(check_library_exists_concat LIBRARY SYMBOL VARIABLE) check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}" ${VARIABLE}) if(${VARIABLE}) set(CURL_LIBS ${LIBRARY} ${CURL_LIBS}) - endif(${VARIABLE}) -endmacro(CHECK_LIBRARY_EXISTS_CONCAT) + endif() +endmacro() # Check if header file exists and add it to the list. # This macro is intended to be called multiple times with a sequence of # possibly dependent header files. Some headers depend on others to be # compiled correctly. -macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) +macro(check_include_file_concat FILE VARIABLE) check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE}) if(${VARIABLE}) set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE}) set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}") - endif(${VARIABLE}) -endmacro(CHECK_INCLUDE_FILE_CONCAT) + endif() +endmacro() # For other curl specific tests, use this macro. -macro(CURL_INTERNAL_TEST CURL_TEST) +macro(curl_internal_test CURL_TEST) if(NOT DEFINED "${CURL_TEST}") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LIBRARIES) set(CURL_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - endif(CMAKE_REQUIRED_LIBRARIES) + endif() message(STATUS "Performing Curl Test ${CURL_TEST}") try_compile(${CURL_TEST} @@ -48,53 +48,17 @@ macro(CURL_INTERNAL_TEST CURL_TEST) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing Curl Test ${CURL_TEST} passed with the following output:\n" "${OUTPUT}\n") - else(${CURL_TEST}) + else() message(STATUS "Performing Curl Test ${CURL_TEST} - Failed") set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Curl Test ${CURL_TEST} failed with the following output:\n" "${OUTPUT}\n") - endif(${CURL_TEST}) - endif() -endmacro(CURL_INTERNAL_TEST) - -macro(CURL_INTERNAL_TEST_RUN CURL_TEST) - if(NOT DEFINED "${CURL_TEST}_COMPILE") - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}") - if(CMAKE_REQUIRED_LIBRARIES) - set(CURL_TEST_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - endif(CMAKE_REQUIRED_LIBRARIES) - - message(STATUS "Performing Curl Test ${CURL_TEST}") - try_run(${CURL_TEST} ${CURL_TEST}_COMPILE - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CURL_TEST_ADD_LIBRARIES}" - OUTPUT_VARIABLE OUTPUT) - if(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) - set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}") - message(STATUS "Performing Curl Test ${CURL_TEST} - Success") - else(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) - message(STATUS "Performing Curl Test ${CURL_TEST} - Failed") - set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}") - file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" - "Performing Curl Test ${CURL_TEST} failed with the following output:\n" - "${OUTPUT}") - if(${CURL_TEST}_COMPILE) - file(APPEND - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" - "There was a problem running this test\n") - endif(${CURL_TEST}_COMPILE) - file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log" - "\n\n") - endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST}) + endif() endif() -endmacro(CURL_INTERNAL_TEST_RUN) +endmacro() -macro(CURL_NROFF_CHECK) +macro(curl_nroff_check) find_program(NROFF NAMES gnroff nroff) if(NROFF) # Need a way to write to stdin, this will do @@ -121,4 +85,4 @@ macro(CURL_NROFF_CHECK) else() message(WARNING "Found no *nroff program") endif() -endmacro(CURL_NROFF_CHECK) +endmacro() diff --git a/Utilities/cmcurl/CMake/OtherTests.cmake b/Utilities/cmcurl/CMake/OtherTests.cmake index 989f04e..ce6d3e1 100644 --- a/Utilities/cmcurl/CMake/OtherTests.cmake +++ b/Utilities/cmcurl/CMake/OtherTests.cmake @@ -5,8 +5,8 @@ set(_source_epilogue "#undef inline") macro(add_header_include check header) if(${check}) set(_source_epilogue "${_source_epilogue}\n#include <${header}>") - endif(${check}) -endmacro(add_header_include) + endif() +endmacro() set(signature_call_conv) if(HAVE_WINDOWS_H) @@ -19,10 +19,10 @@ if(HAVE_WINDOWS_H) if(HAVE_LIBWS2_32) set(CMAKE_REQUIRED_LIBRARIES ws2_32) endif() -else(HAVE_WINDOWS_H) +else() add_header_include(HAVE_SYS_TYPES_H "sys/types.h") add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h") -endif(HAVE_WINDOWS_H) +endif() check_c_source_compiles("${_source_epilogue} int main(void) { @@ -64,13 +64,13 @@ if(curl_cv_recv) set(RECV_TYPE_RETV "${recv_retv}") set(HAVE_RECV 1) set(curl_cv_func_recv_done 1) - endif(curl_cv_func_recv_test) - endif(NOT curl_cv_func_recv_done) - endforeach(recv_arg4) - endforeach(recv_arg3) - endforeach(recv_arg2) - endforeach(recv_arg1) - endforeach(recv_retv) + endif() + endif() + endforeach() + endforeach() + endforeach() + endforeach() + endforeach() else() string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}") string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}") @@ -81,10 +81,10 @@ if(curl_cv_recv) if("${curl_cv_func_recv_args}" STREQUAL "unknown") message(FATAL_ERROR "Cannot find proper types to use for recv args") - endif("${curl_cv_func_recv_args}" STREQUAL "unknown") -else(curl_cv_recv) + endif() +else() message(FATAL_ERROR "Unable to link function recv") -endif(curl_cv_recv) +endif() set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv") set(HAVE_RECV 1) @@ -130,13 +130,13 @@ if(curl_cv_send) set(SEND_TYPE_RETV "${send_retv}") set(HAVE_SEND 1) set(curl_cv_func_send_done 1) - endif(curl_cv_func_send_test) - endif(NOT curl_cv_func_send_done) - endforeach(send_arg4) - endforeach(send_arg3) - endforeach(send_arg2) - endforeach(send_arg1) - endforeach(send_retv) + endif() + endif() + endforeach() + endforeach() + endforeach() + endforeach() + endforeach() else() string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}") string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}") @@ -148,11 +148,11 @@ if(curl_cv_send) if("${curl_cv_func_send_args}" STREQUAL "unknown") message(FATAL_ERROR "Cannot find proper types to use for send args") - endif("${curl_cv_func_send_args}" STREQUAL "unknown") + endif() set(SEND_QUAL_ARG2 "const") -else(curl_cv_send) +else() message(FATAL_ERROR "Unable to link function send") -endif(curl_cv_send) +endif() set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send") set(HAVE_SEND 1) @@ -184,7 +184,7 @@ if(NOT APPLE) set(CMAKE_REQUIRED_FLAGS) if(HAVE_SYS_POLL_H) set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H") - endif(HAVE_SYS_POLL_H) + endif() check_c_source_runs(" #ifdef HAVE_SYS_POLL_H # include <sys/poll.h> @@ -199,7 +199,7 @@ set(CMAKE_REQUIRED_FLAGS) if(HAVE_SIGNAL_H) set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H") set(CMAKE_EXTRA_INCLUDE_FILES "signal.h") -endif(HAVE_SIGNAL_H) +endif() check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T) if(HAVE_SIZEOF_SIG_ATOMIC_T) check_c_source_compiles(" @@ -213,8 +213,8 @@ if(HAVE_SIZEOF_SIG_ATOMIC_T) }" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) set(HAVE_SIG_ATOMIC_T_VOLATILE 1) - endif(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) -endif(HAVE_SIZEOF_SIG_ATOMIC_T) + endif() +endif() if(HAVE_WINDOWS_H) set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h) @@ -222,11 +222,10 @@ else() set(CMAKE_EXTRA_INCLUDE_FILES) if(HAVE_SYS_SOCKET_H) set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h) - endif(HAVE_SYS_SOCKET_H) + endif() endif() check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE) if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE) set(HAVE_STRUCT_SOCKADDR_STORAGE 1) -endif(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE) - +endif() diff --git a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake index 53d0a5e..2dbe1bb 100644 --- a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake +++ b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake @@ -115,8 +115,7 @@ if(NOT UNIX) set(HAVE_SIGACTION 0) set(HAVE_MACRO_SIGSETJMP 0) - else(WIN32) + else() message("This file should be included on Windows platform only") - endif(WIN32) -endif(NOT UNIX) - + endif() +endif() diff --git a/Utilities/cmcurl/CMake/Utilities.cmake b/Utilities/cmcurl/CMake/Utilities.cmake index 005b166..5cb1d44 100644 --- a/Utilities/cmcurl/CMake/Utilities.cmake +++ b/Utilities/cmcurl/CMake/Utilities.cmake @@ -1,44 +1,13 @@ # File containing various utilities -# Converts a CMake list to a string containing elements separated by spaces -function(TO_LIST_SPACES _LIST_NAME OUTPUT_VAR) - set(NEW_LIST_SPACE) - foreach(ITEM ${${_LIST_NAME}}) - set(NEW_LIST_SPACE "${NEW_LIST_SPACE} ${ITEM}") - endforeach() - string(STRIP ${NEW_LIST_SPACE} NEW_LIST_SPACE) - set(${OUTPUT_VAR} "${NEW_LIST_SPACE}" PARENT_SCOPE) -endfunction() - -# Appends a lis of item to a string which is a space-separated list, if they don't already exist. -function(LIST_SPACES_APPEND_ONCE LIST_NAME) - string(REPLACE " " ";" _LIST ${${LIST_NAME}}) - list(APPEND _LIST ${ARGN}) - list(REMOVE_DUPLICATES _LIST) - to_list_spaces(_LIST NEW_LIST_SPACE) - set(${LIST_NAME} "${NEW_LIST_SPACE}" PARENT_SCOPE) -endfunction() - -# Convenience function that does the same as LIST(FIND ...) but with a TRUE/FALSE return value. -# Ex: IN_STR_LIST(MY_LIST "Searched item" WAS_FOUND) -function(IN_STR_LIST LIST_NAME ITEM_SEARCHED RETVAL) - list(FIND ${LIST_NAME} ${ITEM_SEARCHED} FIND_POS) - if(${FIND_POS} EQUAL -1) - set(${RETVAL} FALSE PARENT_SCOPE) - else() - set(${RETVAL} TRUE PARENT_SCOPE) - endif() -endfunction() - # Returns a list of arguments that evaluate to true -function(collect_true output_var output_count_var) - set(${output_var}) +function(count_true output_count_var) + set(lst) foreach(option_var IN LISTS ARGN) if(${option_var}) - list(APPEND ${output_var} ${option_var}) + list(APPEND lst ${option_var}) endif() endforeach() - set(${output_var} ${${output_var}} PARENT_SCOPE) - list(LENGTH ${output_var} ${output_count_var}) - set(${output_count_var} ${${output_count_var}} PARENT_SCOPE) + list(LENGTH lst lst_len) + set(${output_count_var} ${lst_len} PARENT_SCOPE) endfunction() diff --git a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in index d00a516..db8e536 100644 --- a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in +++ b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in @@ -1,11 +1,11 @@ if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") -endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif() -if (NOT DEFINED CMAKE_INSTALL_PREFIX) - set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") -endif () - message(${CMAKE_INSTALL_PREFIX}) +if(NOT DEFINED CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@") +endif() +message(${CMAKE_INSTALL_PREFIX}) file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") @@ -19,8 +19,8 @@ foreach(file ${files}) ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif(NOT "${rm_retval}" STREQUAL 0) - else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + endif() + else() message(STATUS "File $ENV{DESTDIR}${file} does not exist.") - endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) + endif() +endforeach() diff --git a/Utilities/cmcurl/CMake/curl-config.cmake b/Utilities/cmcurl/CMake/curl-config.cmake deleted file mode 100644 index 119332c..0000000 --- a/Utilities/cmcurl/CMake/curl-config.cmake +++ /dev/null @@ -1,59 +0,0 @@ - -get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - -if(NOT CURL_FIND_COMPONENTS) - set(CURL_FIND_COMPONENTS curl libcurl) - if(CURL_FIND_REQUIRED) - set(CURL_FIND_REQUIRED_curl TRUE) - set(CURL_FIND_REQUIRED_libcurl TRUE) - endif() -endif() - -set(_curl_missing_components) -foreach(_comp ${CURL_FIND_COMPONENTS}) - if(EXISTS "${_DIR}/${_comp}-target.cmake") - include("${_DIR}/${_comp}-target.cmake") - set(CURL_${_comp}_FOUND TRUE) - else() - set(CURL_${_comp}_FOUND FALSE) - if(CURL_FIND_REQUIRED_${_comp}) - set(CURL_FOUND FALSE) - list(APPEND _curl_missing_components ${_comp}) - endif() - endif() -endforeach() - -if(_curl_missing_components) - set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components}) -else() - if(TARGET CURL::libcurl) - string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config) - if(NOT _curl_current_config) - set(_curl_current_config "NOCONFIG") - endif() - get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS) - list(FIND _curl_configurations "${_curl_current_config}" _i) - if(_i LESS 0) - set(_curl_config "RELEASE") - list(FIND _curl_configurations "${_curl_current_config}" _i) - if(_i LESS 0) - set(_curl_config "NOCONFIG") - list(FIND _curl_configurations "${_curl_current_config}" _i) - endif() - endif() - - if(_i LESS 0) - set(_curl_current_config "") # let CMake pick config at random - else() - set(_curl_current_config "_${_curl_current_config}") - endif() - - get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}") - set(_curl_current_config) - set(_curl_configurations) - set(_i) - endif() -endif() - -unset(_curl_missing_components) diff --git a/Utilities/cmcurl/CMake/curl-config.cmake.in b/Utilities/cmcurl/CMake/curl-config.cmake.in new file mode 100644 index 0000000..73e04c6 --- /dev/null +++ b/Utilities/cmcurl/CMake/curl-config.cmake.in @@ -0,0 +1,64 @@ + +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +if(NOT CURL_FIND_COMPONENTS) + set(CURL_FIND_COMPONENTS curl libcurl) + if(CURL_FIND_REQUIRED) + set(CURL_FIND_REQUIRED_curl TRUE) + set(CURL_FIND_REQUIRED_libcurl TRUE) + endif() +endif() + +include(CMakeFindDependencyMacro) +if(CURL_FIND_REQUIRED_libcurl) + find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@") +endif() + +set(_curl_missing_components) +foreach(_comp ${CURL_FIND_COMPONENTS}) + if(EXISTS "${_DIR}/${_comp}-target.cmake") + include("${_DIR}/${_comp}-target.cmake") + set(CURL_${_comp}_FOUND TRUE) + else() + set(CURL_${_comp}_FOUND FALSE) + if(CURL_FIND_REQUIRED_${_comp}) + set(CURL_FOUND FALSE) + list(APPEND _curl_missing_components ${_comp}) + endif() + endif() +endforeach() + +if(_curl_missing_components) + set(CURL_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components}) +else() + if(TARGET CURL::libcurl) + string(TOUPPER "${CMAKE_BUILD_TYPE}" _curl_current_config) + if(NOT _curl_current_config) + set(_curl_current_config "NOCONFIG") + endif() + get_target_property(_curl_configurations CURL::libcurl IMPORTED_CONFIGURATIONS) + list(FIND _curl_configurations "${_curl_current_config}" _i) + if(_i LESS 0) + set(_curl_config "RELEASE") + list(FIND _curl_configurations "${_curl_current_config}" _i) + if(_i LESS 0) + set(_curl_config "NOCONFIG") + list(FIND _curl_configurations "${_curl_current_config}" _i) + endif() + endif() + + if(_i LESS 0) + set(_curl_current_config "") # let CMake pick config at random + else() + set(_curl_current_config "_${_curl_current_config}") + endif() + + get_target_property(CURL_INCLUDE_DIRS CURL::libcurl INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(CURL_LIBRARIES CURL::libcurl "LOCATION${_curl_current_config}") + set(_curl_current_config) + set(_curl_configurations) + set(_i) + endif() +endif() + +unset(_curl_missing_components) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 0128214..f38b7d4 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -2,6 +2,7 @@ set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe") set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports") set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs") +set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries") set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi") set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2") set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP") @@ -23,7 +24,6 @@ set(CURL_DISABLE_TELNET ON CACHE INTERNAL "Disable curl telnet protocol?") set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?") set(CURL_DISABLE_VERBOSE_STRINGS OFF CACHE INTERNAL "Do not disable curl verbosity") set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols") -set(CURL_STATICLIB ON CACHE INTERNAL "Static curl") set(CURL_WERROR OFF CACHE INTERNAL "Turn compiler warnings into errors") set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions") set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support") @@ -123,26 +123,25 @@ endif() # To check: # (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not. # (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options. -cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") include(Utilities) include(Macros) include(CMakeDependentOption) include(CheckCCompilerFlag) -project( CURL C ) +project(CURL C) if(0) # This code not needed for building within CMake. message(WARNING "the curl cmake build system is poorly maintained. Be aware") endif() -file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) -string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" +file(READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS) +string(REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*" CURL_VERSION ${CURL_VERSION_H_CONTENTS}) -string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) -string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" +string(REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION}) +string(REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+" CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS}) -string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) +string(REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM}) include_regular_expression("^.*$") # Sukender: Is it necessary? @@ -160,19 +159,19 @@ set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}") set(OS "\"${CMAKE_SYSTEM_NAME}\"") include_directories(${PROJECT_BINARY_DIR}/include/curl) -include_directories( ${CURL_SOURCE_DIR}/include ) +include_directories(${CURL_SOURCE_DIR}/include) option(CURL_WERROR "Turn compiler warnings into errors" OFF) option(PICKY_COMPILER "Enable picky compiler options" ON) option(BUILD_CURL_EXE "Set to ON to build curl executable." ON) -option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF) +option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) if(WIN32) option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF) option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON) endif() -CMAKE_DEPENDENT_OPTION(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup" +cmake_dependent_option(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup" ON "NOT ENABLE_ARES" OFF) @@ -180,19 +179,19 @@ option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF) option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) - if (PICKY_COMPILER) - foreach (_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers) + if(PICKY_COMPILER) + foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers) # surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new # test result in. - CHECK_C_COMPILER_FLAG(${_CCOPT} OPT${_CCOPT}) + check_c_compiler_flag(${_CCOPT} OPT${_CCOPT}) if(OPT${_CCOPT}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}") endif() endforeach() - endif(PICKY_COMPILER) -endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) + endif() +endif() -if (ENABLE_DEBUG) +if(ENABLE_DEBUG) # DEBUGBUILD will be defined only for Debug builds if(NOT CMAKE_VERSION VERSION_LESS 3.0) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>) @@ -202,13 +201,15 @@ if (ENABLE_DEBUG) set(ENABLE_CURLDEBUG ON) endif() -if (ENABLE_CURLDEBUG) +if(ENABLE_CURLDEBUG) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG) endif() if(0) # This code not needed for building within CMake. # For debug libs and exes, add "-d" postfix -set(CMAKE_DEBUG_POSTFIX "-d" CACHE STRING "Set debug library postfix") +if(NOT DEFINED CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "-d") +endif() endif() # initialize CURL_LIBS @@ -217,7 +218,7 @@ set(CURL_LIBS "") if(ENABLE_ARES) set(USE_ARES 1) find_package(CARES REQUIRED) - list(APPEND CURL_LIBS ${CARES_LIBRARY} ) + list(APPEND CURL_LIBS ${CARES_LIBRARY}) set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY}) endif() @@ -297,11 +298,11 @@ if(ENABLE_IPV6 AND NOT WIN32) endif() if(0) # This code not needed for building within CMake. -CURL_NROFF_CHECK() # Required for building manual, docs, tests +curl_nroff_check() find_package(Perl) -CMAKE_DEPENDENT_OPTION(ENABLE_MANUAL "to provide the built-in manual" +cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual" ON "NROFF_USEFUL;PERL_FOUND" OFF) @@ -326,27 +327,27 @@ endif() # Disable warnings on Borland to avoid changing 3rd party code. if(BORLAND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") -endif(BORLAND) +endif() # If we are on AIX, do the _ALL_SOURCE magic if(${CMAKE_SYSTEM_NAME} MATCHES AIX) set(_ALL_SOURCE 1) -endif(${CMAKE_SYSTEM_NAME} MATCHES AIX) +endif() # Include all the necessary files for macros -include (CheckFunctionExists) -include (CheckIncludeFile) -include (CheckIncludeFiles) -include (CheckLibraryExists) -include (CheckSymbolExists) -include (CheckTypeSize) -include (CheckCSourceCompiles) +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckCSourceCompiles) # On windows preload settings if(WIN32) set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=") include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake) -endif(WIN32) +endif() if(ENABLE_THREADED_RESOLVER) find_package(Threads REQUIRED) @@ -375,13 +376,13 @@ if(BEOS) set(NOT_NEED_LIBNSL 1) check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND) check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI) -endif(BEOS) +endif() check_library_exists_concat("network" recv HAVE_LIBNETWORK) if(NOT NOT_NEED_LIBNSL) check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL) -endif(NOT NOT_NEED_LIBNSL) +endif() check_function_exists(gethostname HAVE_GETHOSTNAME) @@ -409,14 +410,14 @@ if(WIN32 OR CMAKE_USE_DARWINSSL OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS) set(openssl_default OFF) endif() -collect_true(enabled_ssl_options enabled_ssl_options_count +count_true(enabled_ssl_options_count CMAKE_USE_WINSSL CMAKE_USE_DARWINSSL CMAKE_USE_OPENSSL CMAKE_USE_MBEDTLS ) -if(enabled_ssl_options_count GREATER 1) - message(FATAL_ERROR "Multiple SSL options specified: ${enabled_ssl_options}. Please pick at most one and disable the rest.") +if(enabled_ssl_options_count GREATER "1") + set(CURL_WITH_MULTI_SSL ON) endif() if(CMAKE_USE_WINSSL) @@ -454,9 +455,9 @@ if(CMAKE_USE_OPENSSL) set(HAVE_LIBSSL ON) list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES}) include_directories(${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H) - check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H) check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H) check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H) check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H) @@ -585,7 +586,6 @@ if(NOT CURL_DISABLE_LDAP) endif() endif() endif() - endif() # No ldap, no ldaps. @@ -677,9 +677,8 @@ if(CMAKE_USE_LIBSSH2) check_function_exists(libssh2_scp_send64 HAVE_LIBSSH2_SCP_SEND64) check_function_exists(libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE) set(CMAKE_EXTRA_INCLUDE_FILES "") - - endif(LIBSSH2_FOUND) -endif(CMAKE_USE_LIBSSH2) + endif() +endif() option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF) mark_as_advanced(CMAKE_USE_GSSAPI) @@ -761,68 +760,67 @@ set(CURL_CA_PATH "auto" CACHE STRING "Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.") if("${CURL_CA_BUNDLE}" STREQUAL "") - message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.") + message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.") elseif("${CURL_CA_BUNDLE}" STREQUAL "none") - unset(CURL_CA_BUNDLE CACHE) + unset(CURL_CA_BUNDLE CACHE) elseif("${CURL_CA_BUNDLE}" STREQUAL "auto") - unset(CURL_CA_BUNDLE CACHE) - set(CURL_CA_BUNDLE_AUTODETECT TRUE) + unset(CURL_CA_BUNDLE CACHE) + set(CURL_CA_BUNDLE_AUTODETECT TRUE) else() - set(CURL_CA_BUNDLE_SET TRUE) + set(CURL_CA_BUNDLE_SET TRUE) endif() if("${CURL_CA_PATH}" STREQUAL "") - message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.") + message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.") elseif("${CURL_CA_PATH}" STREQUAL "none") - unset(CURL_CA_PATH CACHE) + unset(CURL_CA_PATH CACHE) elseif("${CURL_CA_PATH}" STREQUAL "auto") - unset(CURL_CA_PATH CACHE) - set(CURL_CA_PATH_AUTODETECT TRUE) + unset(CURL_CA_PATH CACHE) + set(CURL_CA_PATH_AUTODETECT TRUE) else() - set(CURL_CA_PATH_SET TRUE) + set(CURL_CA_PATH_SET TRUE) endif() if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT) - # Skip autodetection of unset CA path because CA bundle is set explicitly + # Skip autodetection of unset CA path because CA bundle is set explicitly elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT) - # Skip autodetection of unset CA bundle because CA path is set explicitly + # Skip autodetection of unset CA bundle because CA path is set explicitly elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT) - # first try autodetecting a CA bundle, then a CA path - - if(CURL_CA_BUNDLE_AUTODETECT) - set(SEARCH_CA_BUNDLE_PATHS - /etc/ssl/certs/ca-certificates.crt - /etc/pki/tls/certs/ca-bundle.crt - /usr/share/ssl/certs/ca-bundle.crt - /usr/local/share/certs/ca-root-nss.crt - /etc/ssl/cert.pem) - - foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS}) - if(EXISTS "${SEARCH_CA_BUNDLE_PATH}") - message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}") - set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}") - set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set") - break() - endif() - endforeach() - endif() + # first try autodetecting a CA bundle, then a CA path + + if(CURL_CA_BUNDLE_AUTODETECT) + set(SEARCH_CA_BUNDLE_PATHS + /etc/ssl/certs/ca-certificates.crt + /etc/pki/tls/certs/ca-bundle.crt + /usr/share/ssl/certs/ca-bundle.crt + /usr/local/share/certs/ca-root-nss.crt + /etc/ssl/cert.pem) + + foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS}) + if(EXISTS "${SEARCH_CA_BUNDLE_PATH}") + message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}") + set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}") + set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set") + break() + endif() + endforeach() + endif() - if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET)) - if(EXISTS "/etc/ssl/certs") - set(CURL_CA_PATH "/etc/ssl/certs") - set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set") - endif() + if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET)) + if(EXISTS "/etc/ssl/certs") + set(CURL_CA_PATH "/etc/ssl/certs") + set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set") endif() + endif() endif() if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS) - message(FATAL_ERROR - "CA path only supported by OpenSSL, GnuTLS or mbed TLS. " - "Set CURL_CA_PATH=none or enable one of those TLS backends.") + message(FATAL_ERROR + "CA path only supported by OpenSSL, GnuTLS or mbed TLS. " + "Set CURL_CA_PATH=none or enable one of those TLS backends.") endif() endif() - # Check for header files if(NOT UNIX) check_include_file_concat("windows.h" HAVE_WINDOWS_H) @@ -920,7 +918,7 @@ check_type_size("time_t" SIZEOF_TIME_T) if(HAVE_SIZEOF_LONG_LONG) set(HAVE_LONGLONG 1) set(HAVE_LL 1) -endif(HAVE_SIZEOF_LONG_LONG) +endif() find_file(RANDOM_FILE urandom /dev) mark_as_advanced(RANDOM_FILE) @@ -954,7 +952,7 @@ check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI) check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM) if(NOT HAVE_STRNCMPI) set(HAVE_STRCMPI) -endif(NOT HAVE_STRNCMPI) +endif() check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR) check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R) check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) @@ -970,6 +968,7 @@ check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP) check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R) check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT) check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID) +check_symbol_exists(getpwuid_r "${CURL_INCLUDES}" HAVE_GETPWUID_R) check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID) check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME) check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R) @@ -982,7 +981,7 @@ check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC) check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO) if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) set(HAVE_SIGNAL 1) -endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO) +endif() check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME) check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL) check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64) @@ -1016,35 +1015,35 @@ if(WIN32) add_definitions(-D_WIN32_WINNT=0x0501) endif() else() - check_function_exists(inet_pton HAVE_INET_PTON) + check_function_exists(inet_pton HAVE_INET_PTON) endif() check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR) if(HAVE_FSETXATTR) foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6) - curl_internal_test_run(${CURL_TEST}) - endforeach(CURL_TEST) -endif(HAVE_FSETXATTR) + curl_internal_test(${CURL_TEST}) + endforeach() +endif() # sigaction and sigsetjmp are special. Use special mechanism for # detecting those, but only if previous attempt failed. if(HAVE_SIGNAL_H) check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION) -endif(HAVE_SIGNAL_H) +endif() if(NOT HAVE_SIGSETJMP) if(HAVE_SETJMP_H) check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP) if(HAVE_MACRO_SIGSETJMP) set(HAVE_SIGSETJMP 1) - endif(HAVE_MACRO_SIGSETJMP) - endif(HAVE_SETJMP_H) -endif(NOT HAVE_SIGSETJMP) + endif() + endif() +endif() # If there is no stricmp(), do not allow LDAP to parse URLs if(NOT HAVE_STRICMP) set(HAVE_LDAP_URL_PARSE 1) -endif(NOT HAVE_STRICMP) +endif() # Do curl specific tests foreach(CURL_TEST @@ -1082,12 +1081,12 @@ foreach(CURL_TEST HAVE_FILE_OFFSET_BITS ) curl_internal_test(${CURL_TEST}) -endforeach(CURL_TEST) +endforeach() if(HAVE_FILE_OFFSET_BITS) set(_FILE_OFFSET_BITS 64) set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64") -endif(HAVE_FILE_OFFSET_BITS) +endif() check_type_size("off_t" SIZEOF_OFF_T) # include this header to get the type @@ -1102,8 +1101,8 @@ foreach(CURL_TEST HAVE_GLIBC_STRERROR_R HAVE_POSIX_STRERROR_R ) - curl_internal_test_run(${CURL_TEST}) -endforeach(CURL_TEST) + curl_internal_test(${CURL_TEST}) +endforeach() # Check for reentrant foreach(CURL_TEST @@ -1117,9 +1116,9 @@ foreach(CURL_TEST if(NOT ${CURL_TEST}) if(${CURL_TEST}_REENTRANT) set(NEED_REENTRANT 1) - endif(${CURL_TEST}_REENTRANT) - endif(NOT ${CURL_TEST}) -endforeach(CURL_TEST) + endif() + endif() +endforeach() if(NEED_REENTRANT) foreach(CURL_TEST @@ -1132,32 +1131,32 @@ if(NEED_REENTRANT) set(${CURL_TEST} 0) if(${CURL_TEST}_REENTRANT) set(${CURL_TEST} 1) - endif(${CURL_TEST}_REENTRANT) - endforeach(CURL_TEST) -endif(NEED_REENTRANT) + endif() + endforeach() +endif() if(HAVE_INET_NTOA_R_DECL_REENTRANT) set(HAVE_INET_NTOA_R_DECL 1) set(NEED_REENTRANT 1) -endif(HAVE_INET_NTOA_R_DECL_REENTRANT) +endif() # Some other minor tests if(NOT HAVE_IN_ADDR_T) set(in_addr_t "unsigned long") -endif(NOT HAVE_IN_ADDR_T) +endif() # Fix libz / zlib.h if(NOT CURL_SPECIAL_LIBZ) if(NOT HAVE_LIBZ) set(HAVE_ZLIB_H 0) - endif(NOT HAVE_LIBZ) + endif() if(NOT HAVE_ZLIB_H) set(HAVE_LIBZ 0) - endif(NOT HAVE_ZLIB_H) -endif(NOT CURL_SPECIAL_LIBZ) + endif() +endif() # Check for nonblocking set(HAVE_DISABLED_NONBLOCKING 1) @@ -1166,16 +1165,13 @@ if(HAVE_FIONBIO OR HAVE_IOCTLSOCKET_CASE OR HAVE_O_NONBLOCK) set(HAVE_DISABLED_NONBLOCKING) -endif(HAVE_FIONBIO OR - HAVE_IOCTLSOCKET OR - HAVE_IOCTLSOCKET_CASE OR - HAVE_O_NONBLOCK) +endif() if(RETSIGTYPE_TEST) set(RETSIGTYPE void) -else(RETSIGTYPE_TEST) +else() set(RETSIGTYPE int) -endif(RETSIGTYPE_TEST) +endif() if(CMAKE_COMPILER_IS_GNUCC AND APPLE) include(CheckCCompilerFlag) @@ -1185,13 +1181,13 @@ if(CMAKE_COMPILER_IS_GNUCC AND APPLE) get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) if(MPRINTF_COMPILE_FLAGS) set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") - else(MPRINTF_COMPILE_FLAGS) + else() set(MPRINTF_COMPILE_FLAGS "-Wno-long-double") - endif(MPRINTF_COMPILE_FLAGS) + endif() set_source_files_properties(mprintf.c PROPERTIES COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) - endif(HAVE_C_FLAG_Wno_long_double) -endif(CMAKE_COMPILER_IS_GNUCC AND APPLE) + endif() +endif() if(HAVE_SOCKLEN_T) set(CURL_HAVE_SOCKLEN_T 1) @@ -1226,19 +1222,25 @@ include(CMake/OtherTests.cmake) add_definitions(-DHAVE_CONFIG_H) -# For windows, all compilers used by cmake should support large files +# For Windows, all compilers used by CMake should support large files if(WIN32) set(USE_WIN32_LARGE_FILES ON) -endif(WIN32) + + # Use the manifest embedded in the Windows Resource + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST") +endif() if(MSVC) + # Disable default manifest added by CMake + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) if(CMAKE_C_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - else(CMAKE_C_FLAGS MATCHES "/W[0-4]") + else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") - endif(CMAKE_C_FLAGS MATCHES "/W[0-4]") -endif(MSVC) + endif() +endif() if(CURL_WERROR) if(MSVC_VERSION) @@ -1247,7 +1249,7 @@ if(CURL_WERROR) # this assumes clang or gcc style options set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") endif() -endif(CURL_WERROR) +endif() # Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it). function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE) @@ -1266,9 +1268,9 @@ function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE) endfunction() if(WIN32 AND NOT CYGWIN) - set(CURL_INSTALL_CMAKE_DIR CMake) + set(CURL_INSTALL_CMAKE_DIR CMake) else() - set(CURL_INSTALL_CMAKE_DIR lib/cmake/curl) + set(CURL_INSTALL_CMAKE_DIR lib/cmake/curl) endif() if(USE_MANUAL) @@ -1286,7 +1288,7 @@ endif() add_executable(LIBCURL curltest.c) target_link_libraries(LIBCURL cmcurl) -if(CMAKE_CURL_TEST_URL) +if(BUILD_TESTING AND CMAKE_CURL_TEST_URL) add_test(curl LIBCURL ${CMAKE_CURL_TEST_URL}) endif() @@ -1381,11 +1383,12 @@ set(CONFIGURE_OPTIONS "") # TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB? set(CPPFLAG_CURL_STATICLIB "") set(CURLVERSION "${CURL_VERSION}") -set(ENABLE_SHARED "yes") -if(CURL_STATICLIB) - set(ENABLE_STATIC "yes") -else() +if(BUILD_SHARED_LIBS) + set(ENABLE_SHARED "yes") set(ENABLE_STATIC "no") +else() + set(ENABLE_SHARED "no") + set(ENABLE_STATIC "yes") endif() set(exec_prefix "\${prefix}") set(includedir "\${prefix}/include") @@ -1409,6 +1412,9 @@ set(REQUIRE_LIB_DEPS "no") set(VERSIONNUM "${CURL_VERSION_NUM}") # Finally generate a "curl-config" matching this config +# Use: +# * ENABLE_SHARED +# * ENABLE_STATIC configure_file("${CURL_SOURCE_DIR}/curl-config.in" "${CURL_BINARY_DIR}/curl-config" @ONLY) install(FILES "${CURL_BINARY_DIR}/curl-config" @@ -1442,9 +1448,9 @@ write_basic_package_version_file( COMPATIBILITY SameMajorVersion ) -configure_file(CMake/curl-config.cmake +configure_file(CMake/curl-config.cmake.in "${PROJECT_BINARY_DIR}/curl-config.cmake" - COPYONLY + @ONLY ) install( diff --git a/Utilities/cmcurl/include/curl/curl.h b/Utilities/cmcurl/include/curl/curl.h index 10e5c49..d9955bd 100644 --- a/Utilities/cmcurl/include/curl/curl.h +++ b/Utilities/cmcurl/include/curl/curl.h @@ -691,6 +691,7 @@ typedef enum { * CURLAUTH_NTLM - HTTP NTLM authentication * CURLAUTH_DIGEST_IE - HTTP Digest authentication with IE flavour * CURLAUTH_NTLM_WB - HTTP NTLM authentication delegated to winbind helper + * CURLAUTH_BEARER - HTTP Bearer token authentication * CURLAUTH_ONLY - Use together with a single other type to force no * authentication or just that single type * CURLAUTH_ANY - All fine types set @@ -708,6 +709,7 @@ typedef enum { #define CURLAUTH_NTLM (((unsigned long)1)<<3) #define CURLAUTH_DIGEST_IE (((unsigned long)1)<<4) #define CURLAUTH_NTLM_WB (((unsigned long)1)<<5) +#define CURLAUTH_BEARER (((unsigned long)1)<<6) #define CURLAUTH_ONLY (((unsigned long)1)<<31) #define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) #define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE)) @@ -1847,6 +1849,13 @@ typedef enum { /* shuffle addresses before use when DNS returns multiple */ CINIT(DNS_SHUFFLE_ADDRESSES, LONG, 275), + /* Specify which TLS 1.3 ciphers suites to use */ + CINIT(TLS13_CIPHERS, STRINGPOINT, 276), + CINIT(PROXY_TLS13_CIPHERS, STRINGPOINT, 277), + + /* Disallow specifying username/login in URL. */ + CINIT(DISALLOW_USERNAME_IN_URL, LONG, 278), + CURLOPT_LASTENTRY /* the last unused */ } CURLoption; @@ -2527,7 +2536,17 @@ typedef enum { CURLINFO_SCHEME = CURLINFO_STRING + 49, /* Fill in new entries below here! */ - CURLINFO_LASTONE = 49 + /* Preferably these would be defined conditionally based on the + sizeof curl_off_t being 64-bits */ + CURLINFO_TOTAL_TIME_T = CURLINFO_OFF_T + 50, + CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51, + CURLINFO_CONNECT_TIME_T = CURLINFO_OFF_T + 52, + CURLINFO_PRETRANSFER_TIME_T = CURLINFO_OFF_T + 53, + CURLINFO_STARTTRANSFER_TIME_T = CURLINFO_OFF_T + 54, + CURLINFO_REDIRECT_TIME_T = CURLINFO_OFF_T + 55, + CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56, + + CURLINFO_LASTONE = 56 } CURLINFO; /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as @@ -2570,6 +2589,7 @@ typedef enum { CURL_LOCK_DATA_DNS, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_DATA_CONNECT, + CURL_LOCK_DATA_PSL, CURL_LOCK_DATA_LAST } curl_lock_data; diff --git a/Utilities/cmcurl/include/curl/curlver.h b/Utilities/cmcurl/include/curl/curlver.h index 2d1505a..e266f18 100644 --- a/Utilities/cmcurl/include/curl/curlver.h +++ b/Utilities/cmcurl/include/curl/curlver.h @@ -30,13 +30,13 @@ /* This is the version number of the libcurl package from which this header file origins: */ -#define LIBCURL_VERSION "7.60.0" +#define LIBCURL_VERSION "7.61.1" /* The numeric version number is also available "in parts" by using these defines: */ #define LIBCURL_VERSION_MAJOR 7 -#define LIBCURL_VERSION_MINOR 60 -#define LIBCURL_VERSION_PATCH 0 +#define LIBCURL_VERSION_MINOR 61 +#define LIBCURL_VERSION_PATCH 1 /* This is the numeric version of the libcurl version number, meant for easier parsing and comparions by programs. The LIBCURL_VERSION_NUM define will @@ -57,7 +57,7 @@ CURL_VERSION_BITS() macro since curl's own configure script greps for it and needs it to contain the full number. */ -#define LIBCURL_VERSION_NUM 0x073C00 +#define LIBCURL_VERSION_NUM 0x073D01 /* * This is the date and time when the full source package was created. The diff --git a/Utilities/cmcurl/include/curl/system.h b/Utilities/cmcurl/include/curl/system.h index eac4cfe..a54fd58 100644 --- a/Utilities/cmcurl/include/curl/system.h +++ b/Utilities/cmcurl/include/curl/system.h @@ -320,6 +320,24 @@ # define CURL_PULL_SYS_TYPES_H 1 # define CURL_PULL_SYS_SOCKET_H 1 +#elif defined(__xlc__) /* IBM xlc compiler */ +# if !defined(_LP64) +# define CURL_TYPEOF_CURL_OFF_T long long +# define CURL_FORMAT_CURL_OFF_T "lld" +# define CURL_FORMAT_CURL_OFF_TU "llu" +# define CURL_SUFFIX_CURL_OFF_T LL +# define CURL_SUFFIX_CURL_OFF_TU ULL +# else +# define CURL_TYPEOF_CURL_OFF_T long +# define CURL_FORMAT_CURL_OFF_T "ld" +# define CURL_FORMAT_CURL_OFF_TU "lu" +# define CURL_SUFFIX_CURL_OFF_T L +# define CURL_SUFFIX_CURL_OFF_TU UL +# endif +# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t +# define CURL_PULL_SYS_TYPES_H 1 +# define CURL_PULL_SYS_SOCKET_H 1 + /* ===================================== */ /* KEEP MSVC THE PENULTIMATE ENTRY */ /* ===================================== */ @@ -344,7 +362,7 @@ /* KEEP GENERIC GCC THE LAST ENTRY */ /* ===================================== */ -#elif defined(__GNUC__) +#elif defined(__GNUC__) && !defined(_SCO_DS) # if !defined(__LP64__) && \ (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \ defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \ diff --git a/Utilities/cmcurl/include/curl/typecheck-gcc.h b/Utilities/cmcurl/include/curl/typecheck-gcc.h index 3a0f253..a6f6386 100644 --- a/Utilities/cmcurl/include/curl/typecheck-gcc.h +++ b/Utilities/cmcurl/include/curl/typecheck-gcc.h @@ -428,7 +428,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_off_t, * == or whatsoever. */ -/* XXX: should evaluate to true iff expr is a pointer */ +/* XXX: should evaluate to true if expr is a pointer */ #define _curl_is_any_ptr(expr) \ (sizeof(expr) == sizeof(void *)) diff --git a/Utilities/cmcurl/lib/CMakeLists.txt b/Utilities/cmcurl/lib/CMakeLists.txt index 9f19daa..3d52105 100644 --- a/Utilities/cmcurl/lib/CMakeLists.txt +++ b/Utilities/cmcurl/lib/CMakeLists.txt @@ -1,5 +1,13 @@ set(LIB_NAME cmcurl) +if(BUILD_SHARED_LIBS) + set(CURL_STATICLIB NO) +else() + set(CURL_STATICLIB YES) +endif() + +# Use: +# * CURL_STATICLIB configure_file(curl_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h) @@ -59,14 +67,6 @@ if(USE_ARES) include_directories(${CARES_INCLUDE_DIR}) endif() -if(CURL_STATICLIB) - # Static lib - set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC) -else() - # DLL / so dynamic lib - set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED) -endif() - # For windows we want to install OPENSSL_LIBRARIES dlls # and also copy them into the build tree so that testing # can find them. @@ -93,16 +93,19 @@ endif() add_library( ${LIB_NAME} - ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC} ${HHEADERS} ${CSOURCES} ${CMAKE_CURL_SSL_DLLS} ) +if(NOT BUILD_SHARED_LIBS) + set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB) +endif() + target_link_libraries(${LIB_NAME} ${CURL_LIBS}) if(0) # This code not needed for building within CMake. if(WIN32) - add_definitions( -D_USRDLL ) + add_definitions(-D_USRDLL) endif() endif() @@ -119,21 +122,14 @@ set_target_properties(${LIB_NAME} PROPERTIES PREFIX "") set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "") if(WIN32) - if(NOT CURL_STATICLIB) + if(BUILD_SHARED_LIBS) # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib" set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib") - - set_target_properties (${LIB_NAME} PROPERTIES - DEBUG_POSTFIX "-d" - # Note: no postfix for release variants, let user choose what style of release he wants - # MINSIZEREL_POSTFIX "-z" - # RELWITHDEBINFO_POSTFIX "-g" - ) endif() endif() target_include_directories(${LIB_NAME} INTERFACE - $<INSTALL_INTERFACE:include>) + $<INSTALL_INTERFACE:include>) install(TARGETS ${LIB_NAME} EXPORT libcurl-target diff --git a/Utilities/cmcurl/lib/Makefile.inc b/Utilities/cmcurl/lib/Makefile.inc index 61c2341..76ca6d0 100644 --- a/Utilities/cmcurl/lib/Makefile.inc +++ b/Utilities/cmcurl/lib/Makefile.inc @@ -54,7 +54,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \ curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \ x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \ - mime.c sha256.c setopt.c curl_path.c curl_ctype.c curl_range.c + mime.c sha256.c setopt.c curl_path.c curl_ctype.c curl_range.c psl.c LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ @@ -74,7 +74,7 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \ x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h \ - curl_path.h curl_ctype.h curl_range.h + curl_path.h curl_ctype.h curl_range.h psl.h LIB_RCFILES = libcurl.rc diff --git a/Utilities/cmcurl/lib/asyn-ares.c b/Utilities/cmcurl/lib/asyn-ares.c index aa581a4..5cfb260 100644 --- a/Utilities/cmcurl/lib/asyn-ares.c +++ b/Utilities/cmcurl/lib/asyn-ares.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -312,22 +312,25 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn, conn->async.os_specific; CURLcode result = CURLE_OK; - *dns = NULL; + if(dns) + *dns = NULL; waitperform(conn, 0); if(res && !res->num_pending) { - (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai); - /* temp_ai ownership is moved to the connection, so we need not free-up - them */ - res->temp_ai = NULL; + if(dns) { + (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai); + /* temp_ai ownership is moved to the connection, so we need not free-up + them */ + res->temp_ai = NULL; + } if(!conn->async.dns) { failf(data, "Could not resolve: %s (%s)", conn->async.hostname, ares_strerror(conn->async.status)); result = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY: CURLE_COULDNT_RESOLVE_HOST; } - else + else if(dns) *dns = conn->async.dns; destroy_async_data(&conn->async); @@ -390,7 +393,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, timeout_ms = 1000; waitperform(conn, timeout_ms); - result = Curl_resolver_is_resolved(conn, &temp_entry); + result = Curl_resolver_is_resolved(conn, entry?&temp_entry:NULL); if(result || conn->async.done) break; @@ -472,17 +475,19 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */ return; res = (struct ResolverResults *)conn->async.os_specific; - res->num_pending--; + if(res) { + res->num_pending--; - if(CURL_ASYNC_SUCCESS == status) { - Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port); - if(ai) { - compound_results(res, ai); + if(CURL_ASYNC_SUCCESS == status) { + Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port); + if(ai) { + compound_results(res, ai); + } } + /* A successful result overwrites any previous error */ + if(res->last_status != ARES_SUCCESS) + res->last_status = status; } - /* A successful result overwrites any previous error */ - if(res->last_status != ARES_SUCCESS) - res->last_status = status; } /* diff --git a/Utilities/cmcurl/lib/asyn-thread.c b/Utilities/cmcurl/lib/asyn-thread.c index b11fab2..2a59294 100644 --- a/Utilities/cmcurl/lib/asyn-thread.c +++ b/Utilities/cmcurl/lib/asyn-thread.c @@ -182,8 +182,6 @@ static struct thread_sync_data *conn_thread_sync_data(struct connectdata *conn) return &(((struct thread_data *)conn->async.os_specific)->tsd); } -#define CONN_THREAD_SYNC_DATA(conn) &(((conn)->async.os_specific)->tsd); - /* Destroy resolver thread synchronization data */ static void destroy_thread_sync_data(struct thread_sync_data * tsd) @@ -481,8 +479,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn, DEBUGASSERT(conn && td); /* wait for the thread to resolve the name */ - if(Curl_thread_join(&td->thread_hnd)) - result = getaddrinfo_complete(conn); + if(Curl_thread_join(&td->thread_hnd)) { + if(entry) + result = getaddrinfo_complete(conn); + } else DEBUGASSERT(0); @@ -572,10 +572,10 @@ int Curl_resolver_getsock(struct connectdata *conn, (void)socks; (void)numsocks; ms = Curl_timediff(Curl_now(), reslv->start); - if(ms < 10) - milli = ms/3; + if(ms < 3) + milli = 0; else if(ms <= 50) - milli = 10; + milli = ms/3; else if(ms <= 250) milli = 50; else diff --git a/Utilities/cmcurl/lib/base64.c b/Utilities/cmcurl/lib/base64.c index 204a227..6370e4c 100644 --- a/Utilities/cmcurl/lib/base64.c +++ b/Utilities/cmcurl/lib/base64.c @@ -49,13 +49,12 @@ static size_t decodeQuantum(unsigned char *dest, const char *src) unsigned long i, x = 0; for(i = 0, s = src; i < 4; i++, s++) { - unsigned long v = 0; - if(*s == '=') { x = (x << 6); padding++; } else { + unsigned long v = 0; p = base64; while(*p && (*p != *s)) { diff --git a/Utilities/cmcurl/lib/conncache.c b/Utilities/cmcurl/lib/conncache.c index b8f5444..6fbf3b1 100644 --- a/Utilities/cmcurl/lib/conncache.c +++ b/Utilities/cmcurl/lib/conncache.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se> - * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2012 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -63,10 +63,9 @@ static void conn_llist_dtor(void *user, void *element) { - struct connectdata *data = element; + struct connectdata *conn = element; (void)user; - - data->bundle = NULL; + conn->bundle = NULL; } static CURLcode bundle_create(struct Curl_easy *data, @@ -96,14 +95,13 @@ static void bundle_destroy(struct connectbundle *cb_ptr) } /* Add a connection to a bundle */ -static CURLcode bundle_add_conn(struct connectbundle *cb_ptr, - struct connectdata *conn) +static void bundle_add_conn(struct connectbundle *cb_ptr, + struct connectdata *conn) { Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn, &conn->bundle_node); conn->bundle = cb_ptr; cb_ptr->num_connections++; - return CURLE_OK; } /* Remove a connection from a bundle */ @@ -263,7 +261,7 @@ static void conncache_remove_bundle(struct conncache *connc, CURLcode Curl_conncache_add_conn(struct conncache *connc, struct connectdata *conn) { - CURLcode result; + CURLcode result = CURLE_OK; struct connectbundle *bundle; struct connectbundle *new_bundle = NULL; struct Curl_easy *data = conn->data; @@ -290,19 +288,13 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, bundle = new_bundle; } - result = bundle_add_conn(bundle, conn); - if(result) { - if(new_bundle) - conncache_remove_bundle(data->state.conn_cache, new_bundle); - goto unlock; - } - + bundle_add_conn(bundle, conn); conn->connection_id = connc->next_connection_id++; connc->num_conn++; DEBUGF(infof(conn->data, "Added connection %ld. " - "The cache now contains %" CURL_FORMAT_CURL_OFF_TU " members\n", - conn->connection_id, (curl_off_t) connc->num_conn)); + "The cache now contains %zu members\n", + conn->connection_id, connc->num_conn)); unlock: CONN_UNLOCK(data); @@ -320,7 +312,7 @@ void Curl_conncache_remove_conn(struct connectdata *conn, bool lock) due to a failed connection attempt, before being added to a bundle */ if(bundle) { if(lock) { - CONN_LOCK(conn->data); + CONN_LOCK(data); } bundle_remove_conn(bundle, conn); if(bundle->num_connections == 0) @@ -328,12 +320,11 @@ void Curl_conncache_remove_conn(struct connectdata *conn, bool lock) conn->bundle = NULL; /* removed from it */ if(connc) { connc->num_conn--; - DEBUGF(infof(conn->data, "The cache now contains %" - CURL_FORMAT_CURL_OFF_TU " members\n", - (curl_off_t) connc->num_conn)); + DEBUGF(infof(data, "The cache now contains %zu members\n", + connc->num_conn)); } if(lock) { - CONN_UNLOCK(conn->data); + CONN_UNLOCK(data); } } } @@ -441,18 +432,11 @@ bool Curl_conncache_return_conn(struct connectdata *conn) infof(data, "Connection cache is full, closing the oldest one.\n"); conn_candidate = Curl_conncache_extract_oldest(data); - if(conn_candidate) { - /* Set the connection's owner correctly */ - conn_candidate->data = data; - /* the winner gets the honour of being disconnected */ - (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); + (void)Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE); } } - CONN_LOCK(data); - conn->inuse = FALSE; /* Mark the connection unused */ - CONN_UNLOCK(data); return (conn_candidate == conn) ? FALSE : TRUE; @@ -486,7 +470,7 @@ Curl_conncache_extract_bundle(struct Curl_easy *data, while(curr) { conn = curr->ptr; - if(!conn->inuse) { + if(!CONN_INUSE(conn)) { /* Set higher score for the age passed since the connection was used */ score = Curl_timediff(now, conn->now); @@ -501,9 +485,9 @@ Curl_conncache_extract_bundle(struct Curl_easy *data, /* remove it to prevent another thread from nicking it */ bundle_remove_conn(bundle, conn_candidate); data->state.conn_cache->num_conn--; - DEBUGF(infof(data, "The cache now contains %" - CURL_FORMAT_CURL_OFF_TU " members\n", - (curl_off_t) data->state.conn_cache->num_conn)); + DEBUGF(infof(data, "The cache now contains %zu members\n", + data->state.conn_cache->num_conn)); + conn_candidate->data = data; /* associate! */ } return conn_candidate; @@ -544,7 +528,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) while(curr) { conn = curr->ptr; - if(!conn->inuse) { + if(!CONN_INUSE(conn)) { /* Set higher score for the age passed since the connection was used */ score = Curl_timediff(now, conn->now); @@ -563,9 +547,9 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) /* remove it to prevent another thread from nicking it */ bundle_remove_conn(bundle_candidate, conn_candidate); connc->num_conn--; - DEBUGF(infof(data, "The cache now contains %" - CURL_FORMAT_CURL_OFF_TU " members\n", - (curl_off_t) connc->num_conn)); + DEBUGF(infof(data, "The cache now contains %zu members\n", + connc->num_conn)); + conn_candidate->data = data; /* associate! */ } CONN_UNLOCK(data); @@ -586,7 +570,7 @@ void Curl_conncache_close_all_connections(struct conncache *connc) pointer */ /* This will remove the connection from the cache */ connclose(conn, "kill all"); - (void)Curl_disconnect(conn, FALSE); + (void)Curl_disconnect(connc->closure_handle, conn, FALSE); sigpipe_restore(&pipe_st); conn = Curl_conncache_find_first_connection(connc); diff --git a/Utilities/cmcurl/lib/conncache.h b/Utilities/cmcurl/lib/conncache.h index d8ad80f..eedd7a8 100644 --- a/Utilities/cmcurl/lib/conncache.h +++ b/Utilities/cmcurl/lib/conncache.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2015 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se> * * This software is licensed as described in the file COPYING, which @@ -63,7 +63,7 @@ size_t Curl_conncache_bundle_size(struct connectdata *conn); bool Curl_conncache_return_conn(struct connectdata *conn); CURLcode Curl_conncache_add_conn(struct conncache *connc, - struct connectdata *conn); + struct connectdata *conn) WARN_UNUSED_RESULT; void Curl_conncache_remove_conn(struct connectdata *conn, bool lock); bool Curl_conncache_foreach(struct Curl_easy *data, diff --git a/Utilities/cmcurl/lib/connect.c b/Utilities/cmcurl/lib/connect.c index 1a27ae1..41f2202 100644 --- a/Utilities/cmcurl/lib/connect.c +++ b/Utilities/cmcurl/lib/connect.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -1237,8 +1237,6 @@ static int conn_is_conn(struct connectdata *conn, void *param) curl_socket_t Curl_getconnectinfo(struct Curl_easy *data, struct connectdata **connp) { - curl_socket_t sockfd; - DEBUGASSERT(data); /* this works for an easy handle: @@ -1261,15 +1259,15 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data, return CURL_SOCKET_BAD; } - if(connp) + if(connp) { /* only store this if the caller cares for it */ *connp = c; - sockfd = c->sock[FIRSTSOCKET]; + c->data = data; + } + return c->sock[FIRSTSOCKET]; } else return CURL_SOCKET_BAD; - - return sockfd; } /* diff --git a/Utilities/cmcurl/lib/content_encoding.c b/Utilities/cmcurl/lib/content_encoding.c index 7c979ef..6d47537 100644 --- a/Utilities/cmcurl/lib/content_encoding.c +++ b/Utilities/cmcurl/lib/content_encoding.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -71,13 +71,13 @@ #define RESERVED 0xE0 /* bits 5..7: reserved */ typedef enum { - ZLIB_UNINIT, /* uninitialized */ - ZLIB_INIT, /* initialized */ - ZLIB_INFLATING, /* Inflating started. */ - ZLIB_GZIP_HEADER, /* reading gzip header */ - ZLIB_GZIP_TRAILER, /* reading gzip trailer */ - ZLIB_GZIP_INFLATING, /* inflating gzip stream */ - ZLIB_INIT_GZIP /* initialized in transparent gzip mode */ + ZLIB_UNINIT, /* uninitialized */ + ZLIB_INIT, /* initialized */ + ZLIB_INFLATING, /* inflating started. */ + ZLIB_EXTERNAL_TRAILER, /* reading external trailer */ + ZLIB_GZIP_HEADER, /* reading gzip header */ + ZLIB_GZIP_INFLATING, /* inflating gzip stream */ + ZLIB_INIT_GZIP /* initialized in transparent gzip mode */ } zlibInitState; /* Writer parameters. */ @@ -150,8 +150,8 @@ static CURLcode process_trailer(struct connectdata *conn, zlib_params *zp) if(result || !zp->trailerlen) result = exit_zlib(conn, z, &zp->zlib_init, result); else { - /* Only occurs for gzip with zlib < 1.2.0.4. */ - zp->zlib_init = ZLIB_GZIP_TRAILER; + /* Only occurs for gzip with zlib < 1.2.0.4 or raw deflate. */ + zp->zlib_init = ZLIB_EXTERNAL_TRAILER; } return result; } @@ -163,7 +163,6 @@ static CURLcode inflate_stream(struct connectdata *conn, z_stream *z = &zp->z; /* zlib state structure */ uInt nread = z->avail_in; Bytef *orig_in = z->next_in; - int status; /* zlib status */ bool done = FALSE; CURLcode result = CURLE_OK; /* Curl_client_write status */ char *decomp; /* Put the decompressed data here. */ @@ -184,13 +183,20 @@ static CURLcode inflate_stream(struct connectdata *conn, /* because the buffer size is fixed, iteratively decompress and transfer to the client via downstream_write function. */ while(!done) { + int status; /* zlib status */ done = TRUE; /* (re)set buffer for decompressed output for every iteration */ z->next_out = (Bytef *) decomp; z->avail_out = DSIZ; +#ifdef Z_BLOCK + /* Z_BLOCK is only available in zlib ver. >= 1.2.0.5 */ status = inflate(z, Z_BLOCK); +#else + /* fallback for zlib ver. < 1.2.0.5 */ + status = inflate(z, Z_SYNC_FLUSH); +#endif /* Flush output data if some. */ if(z->avail_out != DSIZ) { @@ -227,6 +233,7 @@ static CURLcode inflate_stream(struct connectdata *conn, z->next_in = orig_in; z->avail_in = nread; zp->zlib_init = ZLIB_INFLATING; + zp->trailerlen = 4; /* Tolerate up to 4 unknown trailer bytes. */ done = FALSE; break; } @@ -281,6 +288,9 @@ static CURLcode deflate_unencode_write(struct connectdata *conn, z->next_in = (Bytef *) buf; z->avail_in = (uInt) nbytes; + if(zp->zlib_init == ZLIB_EXTERNAL_TRAILER) + return process_trailer(conn, zp); + /* Now uncompress the data */ return inflate_stream(conn, writer, ZLIB_INFLATING); } @@ -526,7 +536,7 @@ static CURLcode gzip_unencode_write(struct connectdata *conn, } break; - case ZLIB_GZIP_TRAILER: + case ZLIB_EXTERNAL_TRAILER: z->next_in = (Bytef *) buf; z->avail_in = (uInt) nbytes; return process_trailer(conn, zp); @@ -755,7 +765,6 @@ char *Curl_all_content_encodings(void) const content_encoding * const *cep; const content_encoding *ce; char *ace; - char *p; for(cep = encodings; *cep; cep++) { ce = *cep; @@ -768,7 +777,7 @@ char *Curl_all_content_encodings(void) ace = malloc(len); if(ace) { - p = ace; + char *p = ace; for(cep = encodings; *cep; cep++) { ce = *cep; if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) { @@ -915,10 +924,9 @@ void Curl_unencode_cleanup(struct connectdata *conn) static const content_encoding *find_encoding(const char *name, size_t len) { const content_encoding * const *cep; - const content_encoding *ce; for(cep = encodings; *cep; cep++) { - ce = *cep; + const content_encoding *ce = *cep; if((strncasecompare(name, ce->name, len) && !ce->name[len]) || (ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len])) return ce; diff --git a/Utilities/cmcurl/lib/cookie.c b/Utilities/cmcurl/lib/cookie.c index 2c028b3..da49c2a 100644 --- a/Utilities/cmcurl/lib/cookie.c +++ b/Utilities/cmcurl/lib/cookie.c @@ -40,7 +40,7 @@ struct Cookie *Curl_cookie_add(struct Curl_easy *data, received from a server. The function need to replace previously stored lines that this new - line superceeds. + line supersedes. It may remove lines that are expired. @@ -84,12 +84,9 @@ Example set of cookies: #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) -#ifdef USE_LIBPSL -# include <libpsl.h> -#endif - #include "urldata.h" #include "cookie.h" +#include "psl.h" #include "strtok.h" #include "sendf.h" #include "slist.h" @@ -253,9 +250,9 @@ static const char *get_top_domain(const char * const domain, size_t *outlen) len = strlen(domain); last = memrchr(domain, '.', len); if(last) { - first = memrchr(domain, '.', (size_t) (last - domain)); + first = memrchr(domain, '.', (last - domain)); if(first) - len -= (size_t) (++first - domain); + len -= (++first - domain); } if(outlen) @@ -379,13 +376,13 @@ static void strstore(char **str, const char *newstr) */ static void remove_expired(struct CookieInfo *cookies) { - struct Cookie *co, *nx, *pv; + struct Cookie *co, *nx; curl_off_t now = (curl_off_t)time(NULL); unsigned int i; for(i = 0; i < COOKIE_HASH_SIZE; i++) { + struct Cookie *pv = NULL; co = cookies->cookies[i]; - pv = NULL; while(co) { nx = co->next; if(co->expires && co->expires < now) { @@ -406,6 +403,12 @@ static void remove_expired(struct CookieInfo *cookies) } } +/* Make sure domain contains a dot or is localhost. */ +static bool bad_domain(const char *domain) +{ + return !strchr(domain, '.') && !strcasecompare(domain, "localhost"); +} + /**************************************************************************** * * Curl_cookie_add() @@ -442,10 +445,6 @@ Curl_cookie_add(struct Curl_easy *data, bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */ size_t myhash; -#ifdef USE_LIBPSL - const psl_ctx_t *psl; -#endif - #ifdef CURL_DISABLE_VERBOSE_STRINGS (void)data; #endif @@ -497,7 +496,7 @@ Curl_cookie_add(struct Curl_easy *data, name + contents. Chrome and Firefox support 4095 or 4096 bytes combo. */ freecookie(co); - infof(data, "oversized cookie dropped, name/val %d + %d bytes\n", + infof(data, "oversized cookie dropped, name/val %zu + %zu bytes\n", nlen, len); return NULL; } @@ -585,13 +584,8 @@ Curl_cookie_add(struct Curl_easy *data, * TLD or otherwise "protected" suffix. To reduce risk, we require a * dot OR the exact host name being "localhost". */ - { - const char *dotp; - /* check for more dots */ - dotp = strchr(whatptr, '.'); - if(!dotp && !strcasecompare("localhost", whatptr)) - domain = ":"; - } + if(bad_domain(whatptr)) + domain = ":"; #endif is_ip = isip(domain ? domain : whatptr); @@ -723,9 +717,9 @@ Curl_cookie_add(struct Curl_easy *data, if(!queryp) endslash = strrchr(path, '/'); else - endslash = memrchr(path, '/', (size_t)(queryp - path)); + endslash = memrchr(path, '/', (queryp - path)); if(endslash) { - size_t pathlen = (size_t)(endslash-path + 1); /* include end slash */ + size_t pathlen = (endslash-path + 1); /* include end slash */ co->path = malloc(pathlen + 1); /* one extra for the zero byte */ if(co->path) { memcpy(co->path, path, pathlen); @@ -880,9 +874,10 @@ Curl_cookie_add(struct Curl_easy *data, } co->livecookie = c->running; + co->creationtime = ++c->lastct; /* now, we have parsed the incoming line, we must now check if this - superceeds an already existing cookie, which it may if the previous have + supersedes an already existing cookie, which it may if the previous have the same domain and path as this */ /* at first, remove expired cookies */ @@ -890,14 +885,21 @@ Curl_cookie_add(struct Curl_easy *data, remove_expired(c); #ifdef USE_LIBPSL - /* Check if the domain is a Public Suffix and if yes, ignore the cookie. - This needs a libpsl compiled with builtin data. */ + /* Check if the domain is a Public Suffix and if yes, ignore the cookie. */ if(domain && co->domain && !isip(co->domain)) { - psl = psl_builtin(); - if(psl && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) { - infof(data, - "cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n", - co->name, domain, co->domain); + const psl_ctx_t *psl = Curl_psl_use(data); + int acceptable; + + if(psl) { + acceptable = psl_is_cookie_domain_acceptable(psl, domain, co->domain); + Curl_psl_release(data); + } + else + acceptable = !bad_domain(domain); + + if(!acceptable) { + infof(data, "cookie '%s' dropped, domain '%s' must not " + "set cookies for '%s'\n", co->name, domain, co->domain); freecookie(co); return NULL; } @@ -951,6 +953,9 @@ Curl_cookie_add(struct Curl_easy *data, if(replace_old) { co->next = clist->next; /* get the next-pointer first */ + /* when replacing, creationtime is kept from old */ + co->creationtime = clist->creationtime; + /* then free all the old pointers */ free(clist->name); free(clist->value); @@ -1140,12 +1145,24 @@ static int cookie_sort(const void *p1, const void *p2) if(l1 != l2) return (l2 > l1) ? 1 : -1 ; /* avoid size_t <=> int conversions */ - /* 3 - compare cookie names */ - if(c1->name && c2->name) - return strcmp(c1->name, c2->name); + /* 3 - compare cookie name lengths */ + l1 = c1->name ? strlen(c1->name) : 0; + l2 = c2->name ? strlen(c2->name) : 0; - /* sorry, can't be more deterministic */ - return 0; + if(l1 != l2) + return (l2 > l1) ? 1 : -1; + + /* 4 - compare cookie creation time */ + return (c2->creationtime > c1->creationtime) ? 1 : -1; +} + +/* sort cookies only according to creation time */ +static int cookie_sort_ct(const void *p1, const void *p2) +{ + struct Cookie *c1 = *(struct Cookie **)p1; + struct Cookie *c2 = *(struct Cookie **)p2; + + return (c2->creationtime > c1->creationtime) ? 1 : -1; } #define CLONE(field) \ @@ -1174,6 +1191,7 @@ static struct Cookie *dup_cookie(struct Cookie *src) d->secure = src->secure; d->livecookie = src->livecookie; d->httponly = src->httponly; + d->creationtime = src->creationtime; } return d; @@ -1384,9 +1402,8 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies) ****************************************************************************/ void Curl_cookie_cleanup(struct CookieInfo *c) { - unsigned int i; - if(c) { + unsigned int i; free(c->filename); for(i = 0; i < COOKIE_HASH_SIZE; i++) Curl_cookie_freelist(c->cookies[i]); @@ -1439,6 +1456,8 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) bool use_stdout = FALSE; char *format_ptr; unsigned int i; + unsigned int j; + struct Cookie **array; if((NULL == c) || (0 == c->numcookies)) /* If there are no known cookies, we don't write or even create any @@ -1452,6 +1471,10 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) if(0 == c->numcookies) return 0; + array = malloc(sizeof(struct Cookie *) * c->numcookies); + if(!array) + return 1; + if(!strcmp("-", dumphere)) { /* use stdout */ out = stdout; @@ -1459,8 +1482,10 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) } else { out = fopen(dumphere, FOPEN_WRITETEXT); - if(!out) + if(!out) { + free(array); return 1; /* failure */ + } } fputs("# Netscape HTTP Cookie File\n" @@ -1468,22 +1493,33 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere) "# This file was generated by libcurl! Edit at your own risk.\n\n", out); + j = 0; for(i = 0; i < COOKIE_HASH_SIZE; i++) { for(co = c->cookies[i]; co; co = co->next) { if(!co->domain) continue; - format_ptr = get_netscape_format(co); - if(format_ptr == NULL) { - fprintf(out, "#\n# Fatal libcurl error\n"); - if(!use_stdout) - fclose(out); - return 1; + array[j++] = co; + } + } + + qsort(array, c->numcookies, sizeof(struct Cookie *), cookie_sort_ct); + + for(i = 0; i < j; i++) { + format_ptr = get_netscape_format(array[i]); + if(format_ptr == NULL) { + fprintf(out, "#\n# Fatal libcurl error\n"); + if(!use_stdout) { + free(array); + fclose(out); } - fprintf(out, "%s\n", format_ptr); - free(format_ptr); + return 1; } + fprintf(out, "%s\n", format_ptr); + free(format_ptr); } + free(array); + if(!use_stdout) fclose(out); diff --git a/Utilities/cmcurl/lib/cookie.h b/Utilities/cmcurl/lib/cookie.h index 79b5928..a9f90ca 100644 --- a/Utilities/cmcurl/lib/cookie.h +++ b/Utilities/cmcurl/lib/cookie.h @@ -34,7 +34,7 @@ struct Cookie { char *domain; /* domain = <this> */ curl_off_t expires; /* expires = <this> */ char *expirestr; /* the plain text version */ - bool tailmatch; /* weather we do tail-matchning of the domain name */ + bool tailmatch; /* whether we do tail-matching of the domain name */ /* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */ char *version; /* Version = <value> */ @@ -43,6 +43,7 @@ struct Cookie { bool secure; /* whether the 'secure' keyword was used */ bool livecookie; /* updated from a server, not a stored file */ bool httponly; /* true if the httponly directive is present */ + int creationtime; /* time when the cookie was written */ }; #define COOKIE_HASH_SIZE 256 @@ -55,6 +56,7 @@ struct CookieInfo { bool running; /* state info, for cookie adding information */ long numcookies; /* number of cookies in the "jar" */ bool newsession; /* new session, discard session cookies on load */ + int lastct; /* last creation-time used in the jar */ }; /* This is the maximum line length we accept for a cookie line. RFC 2109 diff --git a/Utilities/cmcurl/lib/curl_addrinfo.c b/Utilities/cmcurl/lib/curl_addrinfo.c index 55d5a39..fd49679 100644 --- a/Utilities/cmcurl/lib/curl_addrinfo.c +++ b/Utilities/cmcurl/lib/curl_addrinfo.c @@ -536,7 +536,8 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract) } #endif -#if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) +#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \ + defined(HAVE_FREEADDRINFO) /* * curl_dofreeaddrinfo() * diff --git a/Utilities/cmcurl/lib/curl_config.h.cmake b/Utilities/cmcurl/lib/curl_config.h.cmake index 24d1ca0..f67188e 100644 --- a/Utilities/cmcurl/lib/curl_config.h.cmake +++ b/Utilities/cmcurl/lib/curl_config.h.cmake @@ -226,6 +226,9 @@ /* Define to 1 if you have the `getpwuid' function. */ #cmakedefine HAVE_GETPWUID 1 +/* Define to 1 if you have the `getpwuid_r' function. */ +#cmakedefine HAVE_GETPWUID_R 1 + /* Define to 1 if you have the `getrlimit' function. */ #cmakedefine HAVE_GETRLIMIT 1 @@ -876,6 +879,12 @@ /* The size of `long', as computed by sizeof. */ @SIZEOF_LONG_CODE@ +/* The size of `long long', as computed by sizeof. */ +@SIZEOF_LONG_LONG_CODE@ + +/* The size of `__int64', as computed by sizeof. */ +@SIZEOF___INT64_CODE@ + /* The size of `off_t', as computed by sizeof. */ @SIZEOF_OFF_T_CODE@ @@ -951,6 +960,9 @@ /* to enable Windows SSL */ #cmakedefine USE_SCHANNEL 1 +/* enable multiple SSL backends */ +#cmakedefine CURL_WITH_MULTI_SSL 1 + /* Define to 1 if using yaSSL in OpenSSL compatibility mode. */ #cmakedefine USE_YASSLEMUL 1 diff --git a/Utilities/cmcurl/lib/curl_fnmatch.c b/Utilities/cmcurl/lib/curl_fnmatch.c index 0179a4f..fbfd85c 100644 --- a/Utilities/cmcurl/lib/curl_fnmatch.c +++ b/Utilities/cmcurl/lib/curl_fnmatch.c @@ -30,6 +30,17 @@ /* The last #include file should be: */ #include "memdebug.h" +#ifndef HAVE_FNMATCH + +/* + * TODO: + * + * Make this function match POSIX. Test 1307 includes a set of test patterns + * that returns different results with a POSIX fnmatch() than with this + * implementation and this is considered a bug where POSIX is the guiding + * light. + */ + #define CURLFNM_CHARSET_LEN (sizeof(char) * 256) #define CURLFNM_CHSET_SIZE (CURLFNM_CHARSET_LEN + 15) @@ -334,9 +345,9 @@ static int loop(const unsigned char *pattern, const unsigned char *string, s++; break; } + /* Syntax error in set; mismatch! */ + return CURL_FNMATCH_NOMATCH; - /* Syntax error in set: this must be taken as a regular character. */ - /* FALLTHROUGH */ default: if(*p++ != *s++) return CURL_FNMATCH_NOMATCH; @@ -355,5 +366,31 @@ int Curl_fnmatch(void *ptr, const char *pattern, const char *string) if(!pattern || !string) { return CURL_FNMATCH_FAIL; } - return loop((unsigned char *)pattern, (unsigned char *)string, 5); + return loop((unsigned char *)pattern, (unsigned char *)string, 2); +} +#else +#include <fnmatch.h> +/* + * @unittest: 1307 + */ +int Curl_fnmatch(void *ptr, const char *pattern, const char *string) +{ + int rc; + (void)ptr; /* the argument is specified by the curl_fnmatch_callback + prototype, but not used by Curl_fnmatch() */ + if(!pattern || !string) { + return CURL_FNMATCH_FAIL; + } + rc = fnmatch(pattern, string, 0); + switch(rc) { + case 0: + return CURL_FNMATCH_MATCH; + case FNM_NOMATCH: + return CURL_FNMATCH_NOMATCH; + default: + return CURL_FNMATCH_FAIL; + } + /* not reached */ } + +#endif diff --git a/Utilities/cmcurl/lib/curl_ntlm_core.c b/Utilities/cmcurl/lib/curl_ntlm_core.c index e27cab3..922e85a 100644 --- a/Utilities/cmcurl/lib/curl_ntlm_core.c +++ b/Utilities/cmcurl/lib/curl_ntlm_core.c @@ -557,8 +557,11 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data, unsigned char *ntbuffer /* 21 bytes */) { size_t len = strlen(password); - unsigned char *pw = len ? malloc(len * 2) : strdup(""); + unsigned char *pw; CURLcode result; + if(len > SIZE_T_MAX/2) /* avoid integer overflow */ + return CURLE_OUT_OF_MEMORY; + pw = len ? malloc(len * 2) : strdup(""); if(!pw) return CURLE_OUT_OF_MEMORY; diff --git a/Utilities/cmcurl/lib/curl_sasl.c b/Utilities/cmcurl/lib/curl_sasl.c index e54e487..354bc54 100644 --- a/Utilities/cmcurl/lib/curl_sasl.c +++ b/Utilities/cmcurl/lib/curl_sasl.c @@ -146,7 +146,6 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl, const char *value, size_t len) { CURLcode result = CURLE_OK; - unsigned int mechbit; size_t mechlen; if(!len) @@ -160,7 +159,7 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl, if(!strncmp(value, "*", len)) sasl->prefmech = SASL_AUTH_DEFAULT; else { - mechbit = Curl_sasl_decode_mech(value, len, &mechlen); + unsigned int mechbit = Curl_sasl_decode_mech(value, len, &mechlen); if(mechbit && mechlen == len) sasl->prefmech |= mechbit; else diff --git a/Utilities/cmcurl/lib/curl_setup.h b/Utilities/cmcurl/lib/curl_setup.h index 7e6fd5e..b056126 100644 --- a/Utilities/cmcurl/lib/curl_setup.h +++ b/Utilities/cmcurl/lib/curl_setup.h @@ -221,7 +221,7 @@ /* * Use getaddrinfo to resolve the IPv4 address literal. If the current network - * interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64, + * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64, * performing this task will result in a synthesized IPv6 address. */ #ifdef __APPLE__ @@ -246,6 +246,7 @@ # if defined(_UNICODE) && !defined(UNICODE) # define UNICODE # endif +# include <winerror.h> # include <windows.h> # ifdef HAVE_WINSOCK2_H # include <winsock2.h> @@ -815,4 +816,16 @@ endings either CRLF or LF so 't' is appropriate. #define CURL_SA_FAMILY_T unsigned short #endif +/* Some convenience macros to get the larger/smaller value out of two given. + We prefix with CURL to prevent name collisions. */ +#define CURLMAX(x,y) ((x)>(y)?(x):(y)) +#define CURLMIN(x,y) ((x)<(y)?(x):(y)) + +/* Some versions of the Android SDK is missing the declaration */ +#if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING) +struct passwd; +int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, + size_t buflen, struct passwd **result); +#endif + #endif /* HEADER_CURL_SETUP_H */ diff --git a/Utilities/cmcurl/lib/curl_threads.c b/Utilities/cmcurl/lib/curl_threads.c index c1624a9..b8f0cd3 100644 --- a/Utilities/cmcurl/lib/curl_threads.c +++ b/Utilities/cmcurl/lib/curl_threads.c @@ -108,7 +108,8 @@ curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void *), #ifdef _WIN32_WCE t = CreateThread(NULL, 0, func, arg, 0, NULL); #else - t = (curl_thread_t)_beginthreadex(NULL, 0, func, arg, 0, NULL); + uintptr_t thread_handle = _beginthreadex(NULL, 0, func, arg, 0, NULL); + t = (curl_thread_t)thread_handle; #endif if((t == 0) || (t == LongToHandle(-1L))) { #ifdef _WIN32_WCE diff --git a/Utilities/cmcurl/lib/dict.c b/Utilities/cmcurl/lib/dict.c index 4fc8552..408d57b 100644 --- a/Utilities/cmcurl/lib/dict.c +++ b/Utilities/cmcurl/lib/dict.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -95,17 +95,17 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff) { char *newp = NULL; char *dictp; - char *ptr; size_t len; - char ch; - int olen = 0; CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE); if(!newp || result) return NULL; - dictp = malloc(((size_t)len)*2 + 1); /* add one for terminating zero */ + dictp = malloc(len*2 + 1); /* add one for terminating zero */ if(dictp) { + char *ptr; + char ch; + int olen = 0; /* According to RFC2229 section 2.2, these letters need to be escaped with \[letter] */ for(ptr = newp; diff --git a/Utilities/cmcurl/lib/easy.c b/Utilities/cmcurl/lib/easy.c index 6b91435..027d0be 100644 --- a/Utilities/cmcurl/lib/easy.c +++ b/Utilities/cmcurl/lib/easy.c @@ -113,7 +113,7 @@ static CURLcode win32_init(void) res = WSAStartup(wVersionRequested, &wsaData); if(res != 0) - /* Tell the user that we couldn't find a useable */ + /* Tell the user that we couldn't find a usable */ /* winsock.dll. */ return CURLE_FAILED_INIT; @@ -125,7 +125,7 @@ static CURLcode win32_init(void) if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) || HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) { - /* Tell the user that we couldn't find a useable */ + /* Tell the user that we couldn't find a usable */ /* winsock.dll. */ WSACleanup(); @@ -661,38 +661,27 @@ static CURLcode easy_transfer(struct Curl_multi *multi) bool done = FALSE; CURLMcode mcode = CURLM_OK; CURLcode result = CURLE_OK; - struct curltime before; - int without_fds = 0; /* count number of consecutive returns from - curl_multi_wait() without any filedescriptors */ while(!done && !mcode) { int still_running = 0; int rc; - before = Curl_now(); mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc); if(!mcode) { if(!rc) { - struct curltime after = Curl_now(); + long sleep_ms; /* If it returns without any filedescriptor instantly, we need to avoid busy-looping during periods where it has nothing particular to wait for */ - if(Curl_timediff(after, before) <= 10) { - without_fds++; - if(without_fds > 2) { - int sleep_ms = without_fds < 10 ? (1 << (without_fds - 1)) : 1000; - Curl_wait_ms(sleep_ms); - } + curl_multi_timeout(multi, &sleep_ms); + if(sleep_ms) { + if(sleep_ms > 1000) + sleep_ms = 1000; + Curl_wait_ms((int)sleep_ms); } - else - /* it wasn't "instant", restart counter */ - without_fds = 0; } - else - /* got file descriptor, restart counter */ - without_fds = 0; mcode = curl_multi_perform(multi, &still_running); } @@ -969,6 +958,13 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) outcurl->change.referer_alloc = TRUE; } + /* Reinitialize an SSL engine for the new handle + * note: the engine name has already been copied by dupset */ + if(outcurl->set.str[STRING_SSL_ENGINE]) { + if(Curl_ssl_set_engine(outcurl, outcurl->set.str[STRING_SSL_ENGINE])) + goto fail; + } + /* Clone the resolver handle, if present, for the new handle */ if(Curl_resolver_duphandle(&outcurl->state.resolver, data->state.resolver)) diff --git a/Utilities/cmcurl/lib/escape.c b/Utilities/cmcurl/lib/escape.c index b7e2d32..10774f0 100644 --- a/Utilities/cmcurl/lib/escape.c +++ b/Utilities/cmcurl/lib/escape.c @@ -82,7 +82,6 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string, size_t alloc; char *ns; char *testing_ptr = NULL; - unsigned char in; /* we need to treat the characters unsigned */ size_t newlen; size_t strindex = 0; size_t length; @@ -100,7 +99,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string, length = alloc-1; while(length--) { - in = *string; + unsigned char in = *string; /* we need to treat the characters unsigned */ if(Curl_isunreserved(in)) /* just copy this */ @@ -150,7 +149,6 @@ CURLcode Curl_urldecode(struct Curl_easy *data, { size_t alloc = (length?length:strlen(string)) + 1; char *ns = malloc(alloc); - unsigned char in; size_t strindex = 0; unsigned long hex; CURLcode result; @@ -159,7 +157,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; while(--alloc > 0) { - in = *string; + unsigned char in = *string; if(('%' == in) && (alloc > 2) && ISXDIGIT(string[1]) && ISXDIGIT(string[2])) { /* this is two hexadecimal digits following a '%' */ diff --git a/Utilities/cmcurl/lib/file.c b/Utilities/cmcurl/lib/file.c index db04cc2..e50e988 100644 --- a/Utilities/cmcurl/lib/file.c +++ b/Utilities/cmcurl/lib/file.c @@ -256,8 +256,6 @@ static CURLcode file_upload(struct connectdata *conn) CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; char *buf = data->state.buffer; - size_t nread; - size_t nwrite; curl_off_t bytecount = 0; struct_stat file_stat; const char *buf2; @@ -306,7 +304,9 @@ static CURLcode file_upload(struct connectdata *conn) } while(!result) { - int readcount; + size_t nread; + size_t nwrite; + size_t readcount; result = Curl_fillreadbuffer(conn, (int)data->set.buffer_size, &readcount); if(result) break; @@ -314,7 +314,7 @@ static CURLcode file_upload(struct connectdata *conn) if(readcount <= 0) /* fix questionable compare error. curlvms */ break; - nread = (size_t)readcount; + nread = readcount; /*skip bytes before resume point*/ if(data->state.resume_from) { @@ -378,7 +378,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done) curl_off_t expected_size = 0; bool size_known; bool fstated = FALSE; - ssize_t nread; struct Curl_easy *data = conn->data; char *buf = data->state.buffer; curl_off_t bytecount = 0; @@ -461,7 +460,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done) return result; /* Adjust the start offset in case we want to get the N last bytes - * of the stream iff the filesize could be determined */ + * of the stream if the filesize could be determined */ if(data->state.resume_from < 0) { if(!fstated) { failf(data, "Can't get the size of file."); @@ -502,6 +501,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done) Curl_pgrsTime(data, TIMER_STARTTRANSFER); while(!result) { + ssize_t nread; /* Don't fill a whole buffer if we want less than all data */ size_t bytestoread; diff --git a/Utilities/cmcurl/lib/formdata.c b/Utilities/cmcurl/lib/formdata.c index f912410..202d930 100644 --- a/Utilities/cmcurl/lib/formdata.c +++ b/Utilities/cmcurl/lib/formdata.c @@ -39,16 +39,13 @@ #include "sendf.h" #include "strdup.h" #include "rand.h" +#include "warnless.h" /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" #include "memdebug.h" -/* What kind of Content-Type to use on un-specified files with unrecognized - extensions. */ -#define HTTPPOST_CONTENTTYPE_DEFAULT "application/octet-stream" - #define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME #define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME #define HTTPPOST_PTRCONTENTS CURL_HTTPPOST_PTRCONTENTS @@ -305,7 +302,8 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, * Set the contents property. */ case CURLFORM_PTRCONTENTS: - current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */ + current_form->flags |= HTTPPOST_PTRCONTENTS; + /* FALLTHROUGH */ case CURLFORM_COPYCONTENTS: if(current_form->value) return_value = CURL_FORMADD_OPTION_TWICE; @@ -725,7 +723,7 @@ int curl_formget(struct curl_httppost *form, void *arg, while(!result) { char buffer[8192]; - size_t nread = Curl_mime_read(buffer, 1, sizeof buffer, &toppart); + size_t nread = Curl_mime_read(buffer, 1, sizeof(buffer), &toppart); if(!nread) break; @@ -812,7 +810,6 @@ CURLcode Curl_getformdata(struct Curl_easy *data, { CURLcode result = CURLE_OK; curl_mime *form = NULL; - curl_mime *multipart; curl_mimepart *part; struct curl_httppost *file; @@ -831,7 +828,7 @@ CURLcode Curl_getformdata(struct Curl_easy *data, /* Process each top part. */ for(; !result && post; post = post->next) { /* If we have more than a file here, create a mime subpart and fill it. */ - multipart = form; + curl_mime *multipart = form; if(post->more) { part = curl_mime_addpart(form); if(!part) @@ -883,7 +880,8 @@ CURLcode Curl_getformdata(struct Curl_easy *data, compatibility: use of "-" pseudo file name should be avoided. */ result = curl_mime_data_cb(part, (curl_off_t) -1, (curl_read_callback) fread, - (curl_seek_callback) fseek, + CURLX_FUNCTION_CAST(curl_seek_callback, + fseek), NULL, (void *) stdin); } else diff --git a/Utilities/cmcurl/lib/ftp.c b/Utilities/cmcurl/lib/ftp.c index a42c0c7..63f32cf 100644 --- a/Utilities/cmcurl/lib/ftp.c +++ b/Utilities/cmcurl/lib/ftp.c @@ -239,8 +239,8 @@ static void close_secondarysocket(struct connectdata *conn) static void freedirs(struct ftp_conn *ftpc) { - int i; if(ftpc->dirs) { + int i; for(i = 0; i < ftpc->dirdepth; i++) { free(ftpc->dirs[i]); ftpc->dirs[i] = NULL; @@ -637,8 +637,6 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */ * line in a response or continue reading. */ curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; - time_t timeout; /* timeout in milliseconds */ - time_t interval_ms; struct Curl_easy *data = conn->data; CURLcode result = CURLE_OK; struct ftp_conn *ftpc = &conn->proto.ftpc; @@ -657,7 +655,8 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */ while(!*ftpcode && !result) { /* check and reset timeout value every lap */ - timeout = Curl_pp_state_timeout(pp); + time_t timeout = Curl_pp_state_timeout(pp); /* timeout in milliseconds */ + time_t interval_ms; if(timeout <= 0) { failf(data, "FTP response timeout"); @@ -1589,7 +1588,6 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, struct FTP *ftp = conn->data->req.protop; struct Curl_easy *data = conn->data; struct ftp_conn *ftpc = &conn->proto.ftpc; - int seekerr = CURL_SEEKFUNC_OK; if((data->state.resume_from && !sizechecked) || ((data->state.resume_from > 0) && sizechecked)) { @@ -1605,6 +1603,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn, /* 3. pass file-size number of bytes in the source file */ /* 4. lower the infilesize counter */ /* => transfer as usual */ + int seekerr = CURL_SEEKFUNC_OK; if(data->state.resume_from < 0) { /* Got no given size to start from, figure it out */ @@ -2782,7 +2781,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) char *ptr = &data->state.buffer[4]; /* start on the first letter */ const size_t buf_size = data->set.buffer_size; char *dir; - char *store; bool entry_extracted = FALSE; dir = malloc(nread + 1); @@ -2805,6 +2803,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn) if('\"' == *ptr) { /* it started good */ + char *store; ptr++; for(store = dir; *ptr;) { if('\"' == *ptr) { @@ -3993,8 +3992,7 @@ CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd) break; if(conn->data->set.verbose) - Curl_debug(conn->data, CURLINFO_HEADER_OUT, - sptr, (size_t)bytes_written, conn); + Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written); if(bytes_written != (ssize_t)write_len) { write_len -= bytes_written; @@ -4385,7 +4383,6 @@ static CURLcode ftp_setup_connection(struct connectdata *conn) { struct Curl_easy *data = conn->data; char *type; - char command; struct FTP *ftp; conn->data->req.protop = ftp = malloc(sizeof(struct FTP)); @@ -4403,6 +4400,7 @@ static CURLcode ftp_setup_connection(struct connectdata *conn) type = strstr(conn->host.rawalloc, ";type="); if(type) { + char command; *type = 0; /* it was in the middle of the hostname */ command = Curl_raw_toupper(type[6]); conn->bits.type_set = TRUE; diff --git a/Utilities/cmcurl/lib/getinfo.c b/Utilities/cmcurl/lib/getinfo.c index d280eeb..14b4562 100644 --- a/Utilities/cmcurl/lib/getinfo.c +++ b/Utilities/cmcurl/lib/getinfo.c @@ -281,6 +281,28 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info, *param_offt = (data->progress.flags & PGRS_UL_SIZE_KNOWN)? data->progress.size_ul:-1; break; + case CURLINFO_TOTAL_TIME_T: + *param_offt = data->progress.timespent; + break; + case CURLINFO_NAMELOOKUP_TIME_T: + *param_offt = data->progress.t_nslookup; + break; + case CURLINFO_CONNECT_TIME_T: + *param_offt = data->progress.t_connect; + break; + case CURLINFO_APPCONNECT_TIME_T: + *param_offt = data->progress.t_appconnect; + break; + case CURLINFO_PRETRANSFER_TIME_T: + *param_offt = data->progress.t_pretransfer; + break; + case CURLINFO_STARTTRANSFER_TIME_T: + *param_offt = data->progress.t_starttransfer; + break; + case CURLINFO_REDIRECT_TIME_T: + *param_offt = data->progress.t_redirect; + break; + default: return CURLE_UNKNOWN_OPTION; } diff --git a/Utilities/cmcurl/lib/gopher.c b/Utilities/cmcurl/lib/gopher.c index b7c31b6..3ecee9b 100644 --- a/Utilities/cmcurl/lib/gopher.c +++ b/Utilities/cmcurl/lib/gopher.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -89,22 +89,15 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done) /* Create selector. Degenerate cases: / and /1 => convert to "" */ if(strlen(path) <= 2) { sel = (char *)""; - len = (int)strlen(sel); + len = strlen(sel); } else { char *newp; - size_t j, i; /* Otherwise, drop / and the first character (i.e., item type) ... */ newp = path; newp += 2; - /* ... then turn ? into TAB for search servers, Veronica, etc. ... */ - j = strlen(newp); - for(i = 0; i<j; i++) - if(newp[i] == '?') - newp[i] = '\x09'; - /* ... and finally unescape */ result = Curl_urldecode(data, newp, 0, &sel, &len, FALSE); if(result) diff --git a/Utilities/cmcurl/lib/hash.c b/Utilities/cmcurl/lib/hash.c index 15a128f..421d68f 100644 --- a/Utilities/cmcurl/lib/hash.c +++ b/Utilities/cmcurl/lib/hash.c @@ -60,8 +60,6 @@ Curl_hash_init(struct curl_hash *h, comp_function comparator, curl_hash_dtor dtor) { - int i; - if(!slots || !hfunc || !comparator ||!dtor) { return 1; /* failure */ } @@ -74,6 +72,7 @@ Curl_hash_init(struct curl_hash *h, h->table = malloc(slots * sizeof(struct curl_llist)); if(h->table) { + int i; for(i = 0; i < slots; ++i) Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor); return 0; /* fine */ @@ -140,11 +139,10 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len) { struct curl_llist_element *le; - struct curl_hash_element *he; struct curl_llist *l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { - he = le->ptr; + struct curl_hash_element *he = le->ptr; if(h->comp_func(he->key, he->key_len, key, key_len)) { Curl_llist_remove(l, le, (void *) h); --h->size; @@ -162,13 +160,12 @@ void * Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len) { struct curl_llist_element *le; - struct curl_hash_element *he; struct curl_llist *l; if(h) { l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { - he = le->ptr; + struct curl_hash_element *he = le->ptr; if(h->comp_func(he->key, he->key_len, key, key_len)) { return he->ptr; } @@ -291,7 +288,6 @@ void Curl_hash_start_iterate(struct curl_hash *hash, struct curl_hash_element * Curl_hash_next_element(struct curl_hash_iterator *iter) { - int i; struct curl_hash *h = iter->hash; /* Get the next element in the current list, if any */ @@ -300,6 +296,7 @@ Curl_hash_next_element(struct curl_hash_iterator *iter) /* If we have reached the end of the list, find the next one */ if(!iter->current_element) { + int i; for(i = iter->slot_index; i < h->slots; i++) { if(h->table[i].head) { iter->current_element = h->table[i].head; diff --git a/Utilities/cmcurl/lib/hmac.c b/Utilities/cmcurl/lib/hmac.c index dae9505..bf49ebe 100644 --- a/Utilities/cmcurl/lib/hmac.c +++ b/Utilities/cmcurl/lib/hmac.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -58,7 +58,7 @@ Curl_HMAC_init(const HMAC_params * hashparams, unsigned char b; /* Create HMAC context. */ - i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize + + i = sizeof(*ctxt) + 2 * hashparams->hmac_ctxtsize + hashparams->hmac_resultlen; ctxt = malloc(i); diff --git a/Utilities/cmcurl/lib/hostasyn.c b/Utilities/cmcurl/lib/hostasyn.c index 7b6e856..e7b399e 100644 --- a/Utilities/cmcurl/lib/hostasyn.c +++ b/Utilities/cmcurl/lib/hostasyn.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -131,7 +131,7 @@ CURLcode Curl_async_resolved(struct connectdata *conn, if(result) /* We're not allowed to return failure with memory left allocated in the connectdata struct, free those here */ - Curl_disconnect(conn, FALSE); /* close the connection */ + Curl_disconnect(conn->data, conn, TRUE); /* close the connection */ return result; } diff --git a/Utilities/cmcurl/lib/hostip.c b/Utilities/cmcurl/lib/hostip.c index c2f9def..bc20f71 100644 --- a/Utilities/cmcurl/lib/hostip.c +++ b/Utilities/cmcurl/lib/hostip.c @@ -907,7 +907,9 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) char *entry_id; size_t entry_len; char address[64]; +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) char *addresses = NULL; +#endif char *addr_begin; char *addr_end; char *port_ptr; @@ -930,7 +932,9 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) goto err; port = (int)tmp_port; +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) addresses = end_ptr + 1; +#endif while(*end_ptr) { size_t alen; @@ -1010,24 +1014,28 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) /* See if its already in our dns cache */ dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1); + if(dns) { + infof(data, "RESOLVE %s:%d is - old addresses discarded!\n", + hostname, port); + /* delete old entry entry, there are two reasons for this + 1. old entry may have different addresses. + 2. even if entry with correct addresses is already in the cache, + but if it is close to expire, then by the time next http + request is made, it can get expired and pruned because old + entry is not necessarily marked as added by CURLOPT_RESOLVE. */ + + Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1); + } /* free the allocated entry_id again */ free(entry_id); - if(!dns) { - /* if not in the cache already, put this host in the cache */ - dns = Curl_cache_addr(data, head, hostname, port); - if(dns) { - dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */ - /* release the returned reference; the cache itself will keep the - * entry alive: */ - dns->inuse--; - } - } - else { - /* this is a duplicate, free it again */ - infof(data, "RESOLVE %s:%d is already cached, %s not stored!\n", - hostname, port, addresses); - Curl_freeaddrinfo(head); + /* put this new host in the cache */ + dns = Curl_cache_addr(data, head, hostname, port); + if(dns) { + dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */ + /* release the returned reference; the cache itself will keep the + * entry alive: */ + dns->inuse--; } if(data->share) diff --git a/Utilities/cmcurl/lib/hostip6.c b/Utilities/cmcurl/lib/hostip6.c index 7c9988f..3bf47b4 100644 --- a/Utilities/cmcurl/lib/hostip6.c +++ b/Utilities/cmcurl/lib/hostip6.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -59,39 +59,6 @@ #include "curl_memory.h" #include "memdebug.h" -#if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) -/* These are strictly for memory tracing and are using the same style as the - * family otherwise present in memdebug.c. I put these ones here since they - * require a bunch of structs I didn't want to include in memdebug.c - */ - -/* - * For CURLRES_ARS, this should be written using ares_gethostbyaddr() - * (ignoring the fact c-ares doesn't return 'serv'). - */ - -int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa, - GETNAMEINFO_TYPE_ARG2 salen, - char *host, GETNAMEINFO_TYPE_ARG46 hostlen, - char *serv, GETNAMEINFO_TYPE_ARG46 servlen, - GETNAMEINFO_TYPE_ARG7 flags, - int line, const char *source) -{ - int res = (getnameinfo)(sa, salen, - host, hostlen, - serv, servlen, - flags); - if(0 == res) - /* success */ - curl_memlog("GETNAME %s:%d getnameinfo()\n", - source, line); - else - curl_memlog("GETNAME %s:%d getnameinfo() failed = %d\n", - source, line, res); - return res; -} -#endif /* defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) */ - /* * Curl_ipv6works() returns TRUE if IPv6 seems to work. */ diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c index ff1d681..e727ed8 100644 --- a/Utilities/cmcurl/lib/http.c +++ b/Utilities/cmcurl/lib/http.c @@ -158,18 +158,20 @@ CURLcode Curl_http_setup_conn(struct connectdata *conn) /* allocate the HTTP-specific struct for the Curl_easy, only to survive during this request */ struct HTTP *http; - DEBUGASSERT(conn->data->req.protop == NULL); + struct Curl_easy *data = conn->data; + DEBUGASSERT(data->req.protop == NULL); http = calloc(1, sizeof(struct HTTP)); if(!http) return CURLE_OUT_OF_MEMORY; Curl_mime_initpart(&http->form, conn->data); - conn->data->req.protop = http; - - Curl_http2_setup_conn(conn); - Curl_http2_setup_req(conn->data); + data->req.protop = http; + if(!CONN_INUSE(conn)) + /* if not alredy multi-using, setup connection details */ + Curl_http2_setup_conn(conn); + Curl_http2_setup_req(data); return CURLE_OK; } @@ -310,22 +312,49 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy) return result; } +/* + * http_output_bearer() sets up an Authorization: header + * for HTTP Bearer authentication. + * + * Returns CURLcode. + */ +static CURLcode http_output_bearer(struct connectdata *conn) +{ + char **userp; + CURLcode result = CURLE_OK; + + userp = &conn->allocptr.userpwd; + free(*userp); + *userp = aprintf("Authorization: Bearer %s\r\n", + conn->oauth_bearer); + + if(!*userp) { + result = CURLE_OUT_OF_MEMORY; + goto fail; + } + + fail: + return result; +} + /* pickoneauth() selects the most favourable authentication method from the * ones available and the ones we want. * * return TRUE if one was picked */ -static bool pickoneauth(struct auth *pick) +static bool pickoneauth(struct auth *pick, unsigned long mask) { bool picked; /* only deal with authentication we want */ - unsigned long avail = pick->avail & pick->want; + unsigned long avail = pick->avail & pick->want & mask; picked = TRUE; /* The order of these checks is highly relevant, as this will be the order of preference in case of the existence of multiple accepted types. */ if(avail & CURLAUTH_NEGOTIATE) pick->picked = CURLAUTH_NEGOTIATE; + else if(avail & CURLAUTH_BEARER) + pick->picked = CURLAUTH_BEARER; else if(avail & CURLAUTH_DIGEST) pick->picked = CURLAUTH_DIGEST; else if(avail & CURLAUTH_NTLM) @@ -479,6 +508,10 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) bool pickhost = FALSE; bool pickproxy = FALSE; CURLcode result = CURLE_OK; + unsigned long authmask = ~0ul; + + if(!conn->oauth_bearer) + authmask &= (unsigned long)~CURLAUTH_BEARER; if(100 <= data->req.httpcode && 199 >= data->req.httpcode) /* this is a transient response code, ignore */ @@ -487,17 +520,18 @@ CURLcode Curl_http_auth_act(struct connectdata *conn) if(data->state.authproblem) return data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK; - if(conn->bits.user_passwd && + if((conn->bits.user_passwd || conn->oauth_bearer) && ((data->req.httpcode == 401) || (conn->bits.authneg && data->req.httpcode < 300))) { - pickhost = pickoneauth(&data->state.authhost); + pickhost = pickoneauth(&data->state.authhost, authmask); if(!pickhost) data->state.authproblem = TRUE; } if(conn->bits.proxy_user_passwd && ((data->req.httpcode == 407) || (conn->bits.authneg && data->req.httpcode < 300))) { - pickproxy = pickoneauth(&data->state.authproxy); + pickproxy = pickoneauth(&data->state.authproxy, + authmask & ~CURLAUTH_BEARER); if(!pickproxy) data->state.authproblem = TRUE; } @@ -628,6 +662,20 @@ output_auth_headers(struct connectdata *conn, functions work that way */ authstatus->done = TRUE; } + if(authstatus->picked == CURLAUTH_BEARER) { + /* Bearer */ + if((!proxy && conn->oauth_bearer && + !Curl_checkheaders(conn, "Authorization:"))) { + auth = "Bearer"; + result = http_output_bearer(conn); + if(result) + return result; + } + + /* NOTE: this function should set 'done' TRUE, as the other auth + functions work that way */ + authstatus->done = TRUE; + } if(auth) { infof(data, "%s auth using %s with user '%s'\n", @@ -674,7 +722,7 @@ Curl_http_output_auth(struct connectdata *conn, authproxy = &data->state.authproxy; if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) || - conn->bits.user_passwd) + conn->bits.user_passwd || conn->oauth_bearer) /* continue please */; else { authhost->done = TRUE; @@ -883,6 +931,18 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy, data->state.authproblem = TRUE; } } + else + if(checkprefix("Bearer", auth)) { + *availp |= CURLAUTH_BEARER; + authp->avail |= CURLAUTH_BEARER; + if(authp->picked == CURLAUTH_BEARER) { + /* We asked for Bearer authentication but got a 40X back + anyway, which basically means our token isn't valid. */ + authp->avail = CURLAUTH_NONE; + infof(data, "Authentication problem. Ignoring this.\n"); + data->state.authproblem = TRUE; + } + } /* there may be multiple methods on one line, so keep reading */ while(*auth && *auth != ',') /* read up to the next comma */ @@ -1063,7 +1123,8 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, CURLcode result; char *ptr; size_t size; - struct HTTP *http = conn->data->req.protop; + struct Curl_easy *data = conn->data; + struct HTTP *http = data->req.protop; size_t sendsize; curl_socket_t sockfd; size_t headersize; @@ -1083,7 +1144,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, DEBUGASSERT(size > included_body_bytes); - result = Curl_convert_to_network(conn->data, ptr, headersize); + result = Curl_convert_to_network(data, ptr, headersize); /* Curl_convert_to_network calls failf if unsuccessful */ if(result) { /* conversion failed, free memory and return to the caller */ @@ -1108,8 +1169,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, must copy the data to the uploadbuffer first, since that is the buffer we will be using if this send is retried later. */ - memcpy(conn->data->state.uploadbuffer, ptr, sendsize); - ptr = conn->data->state.uploadbuffer; + result = Curl_get_upload_buffer(data); + if(result) { + /* malloc failed, free memory and return to the caller */ + Curl_add_buffer_free(in); + return result; + } + memcpy(data->state.ulbuf, ptr, sendsize); + ptr = data->state.ulbuf; } else sendsize = size; @@ -1126,14 +1193,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, size_t headlen = (size_t)amount>headersize ? headersize : (size_t)amount; size_t bodylen = amount - headlen; - if(conn->data->set.verbose) { + if(data->set.verbose) { /* this data _may_ contain binary stuff */ - Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, headlen, conn); + Curl_debug(data, CURLINFO_HEADER_OUT, ptr, headlen); if(bodylen) { /* there was body data sent beyond the initial header part, pass that on to the debug callback too */ - Curl_debug(conn->data, CURLINFO_DATA_OUT, - ptr + headlen, bodylen, conn); + Curl_debug(data, CURLINFO_DATA_OUT, + ptr + headlen, bodylen); } } @@ -1157,14 +1224,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in, ptr = in->buffer + amount; /* backup the currently set pointers */ - http->backup.fread_func = conn->data->state.fread_func; - http->backup.fread_in = conn->data->state.in; + http->backup.fread_func = data->state.fread_func; + http->backup.fread_in = data->state.in; http->backup.postdata = http->postdata; http->backup.postsize = http->postsize; /* set the new pointers for the request-sending */ - conn->data->state.fread_func = (curl_read_callback)readmoredata; - conn->data->state.in = (void *)conn; + data->state.fread_func = (curl_read_callback)readmoredata; + data->state.in = (void *)conn; http->postdata = ptr; http->postsize = (curl_off_t)size; @@ -1223,7 +1290,6 @@ CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...) CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size) { char *new_rb; - size_t new_size; if(~size < in->size_used) { /* If resulting used size of send buffer would wrap size_t, cleanup @@ -1236,10 +1302,10 @@ CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size) if(!in->buffer || ((in->size_used + size) > (in->size_max - 1))) { - /* If current buffer size isn't enough to hold the result, use a buffer size that doubles the required size. If this new size would wrap size_t, then just use the largest possible one */ + size_t new_size; if((size > (size_t)-1 / 2) || (in->size_used > (size_t)-1 / 2) || (~(size * 2) < (in->size_used * 2))) @@ -1406,7 +1472,7 @@ static CURLcode add_haproxy_protocol_header(struct connectdata *conn) } snprintf(proxy_header, - sizeof proxy_header, + sizeof(proxy_header), "PROXY %s %s %s %li %li\r\n", tcp_version, conn->data->info.conn_local_ip, @@ -1574,7 +1640,6 @@ static CURLcode expect100(struct Curl_easy *data, Curl_send_buffer *req_buffer) { CURLcode result = CURLE_OK; - const char *ptr; data->state.expect100header = FALSE; /* default to false unless it is set to TRUE below */ if(use_http_1_1plus(data, conn) && @@ -1582,7 +1647,7 @@ static CURLcode expect100(struct Curl_easy *data, /* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an Expect: 100-continue to the headers which actually speeds up post operations (as there is one packet coming back from the web server) */ - ptr = Curl_checkheaders(conn, "Expect"); + const char *ptr = Curl_checkheaders(conn, "Expect"); if(ptr) { data->state.expect100header = Curl_compareheader(ptr, "Expect:", "100-continue"); @@ -1819,7 +1884,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) const char *httpstring; Curl_send_buffer *req_buffer; curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */ - int seekerr = CURL_SEEKFUNC_CANTSEEK; /* Always consider the DO phase done after this function call, even if there may be parts of the request that is not yet sent, since we can deal with @@ -1863,6 +1927,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) } http = data->req.protop; + DEBUGASSERT(http); if(!data->state.this_is_a_follow) { /* Free to avoid leaking memory on multiple requests*/ @@ -2088,7 +2153,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) else { /* If the host begins with '[', we start searching for the port after the bracket has been closed */ - int startsearch = 0; if(*cookiehost == '[') { char *closingbracket; /* since the 'cookiehost' is an allocated memory area that will be @@ -2099,6 +2163,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) *closingbracket = 0; } else { + int startsearch = 0; char *colon = strchr(cookiehost + startsearch, ':'); if(colon) *colon = 0; /* The host must not include an embedded port number */ @@ -2244,6 +2309,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) /* Now, let's read off the proper amount of bytes from the input. */ + int seekerr = CURL_SEEKFUNC_CANTSEEK; if(conn->seek_func) { Curl_set_in_callback(data, true); seekerr = conn->seek_func(conn->seek_client, data->state.resume_from, @@ -2828,6 +2894,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) data->req.exp100 = EXP100_SEND_DATA; /* already sent */ Curl_expire_done(data, EXPIRE_100_TIMEOUT); } + else + data->req.writebytecount = http->writebytecount; } if((conn->httpversion == 20) && data->req.upload_chunky) @@ -2838,17 +2906,32 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) return result; } +typedef enum { + STATUS_UNKNOWN, /* not enough data to tell yet */ + STATUS_DONE, /* a status line was read */ + STATUS_BAD /* not a status line */ +} statusline; + + +/* Check a string for a prefix. Check no more than 'len' bytes */ +static bool checkprefixmax(const char *prefix, const char *buffer, size_t len) +{ + size_t ch = CURLMIN(strlen(prefix), len); + return curl_strnequal(prefix, buffer, ch); +} + /* * checkhttpprefix() * * Returns TRUE if member of the list matches prefix of string */ -static bool +static statusline checkhttpprefix(struct Curl_easy *data, - const char *s) + const char *s, size_t len) { struct curl_slist *head = data->set.http200aliases; - bool rc = FALSE; + statusline rc = STATUS_BAD; + statusline onmatch = len >= 5? STATUS_DONE : STATUS_UNKNOWN; #ifdef CURL_DOES_CONVERSIONS /* convert from the network encoding using a scratch area */ char *scratch = strdup(s); @@ -2865,15 +2948,15 @@ checkhttpprefix(struct Curl_easy *data, #endif /* CURL_DOES_CONVERSIONS */ while(head) { - if(checkprefix(head->data, s)) { - rc = TRUE; + if(checkprefixmax(head->data, s, len)) { + rc = onmatch; break; } head = head->next; } - if(!rc && (checkprefix("HTTP/", s))) - rc = TRUE; + if((rc != STATUS_DONE) && (checkprefixmax("HTTP/", s, len))) + rc = onmatch; #ifdef CURL_DOES_CONVERSIONS free(scratch); @@ -2882,11 +2965,12 @@ checkhttpprefix(struct Curl_easy *data, } #ifndef CURL_DISABLE_RTSP -static bool +static statusline checkrtspprefix(struct Curl_easy *data, - const char *s) + const char *s, size_t len) { - bool result = FALSE; + statusline result = STATUS_BAD; + statusline onmatch = len >= 5? STATUS_DONE : STATUS_UNKNOWN; #ifdef CURL_DOES_CONVERSIONS /* convert from the network encoding using a scratch area */ @@ -2899,30 +2983,31 @@ checkrtspprefix(struct Curl_easy *data, /* Curl_convert_from_network calls failf if unsuccessful */ result = FALSE; /* can't return CURLE_foobar so return FALSE */ } - else - result = checkprefix("RTSP/", scratch)? TRUE: FALSE; + else if(checkprefixmax("RTSP/", scratch, len)) + result = onmatch; free(scratch); #else (void)data; /* unused */ - result = checkprefix("RTSP/", s)? TRUE: FALSE; + if(checkprefixmax("RTSP/", s, len)) + result = onmatch; #endif /* CURL_DOES_CONVERSIONS */ return result; } #endif /* CURL_DISABLE_RTSP */ -static bool +static statusline checkprotoprefix(struct Curl_easy *data, struct connectdata *conn, - const char *s) + const char *s, size_t len) { #ifndef CURL_DISABLE_RTSP if(conn->handler->protocol & CURLPROTO_RTSP) - return checkrtspprefix(data, s); + return checkrtspprefix(data, s, len); #else (void)conn; #endif /* CURL_DISABLE_RTSP */ - return checkhttpprefix(data, s); + return checkhttpprefix(data, s, len); } /* @@ -2939,7 +3024,7 @@ static CURLcode header_append(struct Curl_easy *data, /* The reason to have a max limit for this is to avoid the risk of a bad server feeding libcurl with a never-ending header that will cause reallocs infinitely */ - failf(data, "Rejected %zd bytes header (max is %d)!", newsize, + failf(data, "Rejected %zu bytes header (max is %d)!", newsize, CURL_MAX_HTTP_HEADER); return CURLE_OUT_OF_MEMORY; } @@ -3036,12 +3121,15 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, if(result) return result; - if(!k->headerline && (k->hbuflen>5)) { - /* make a first check that this looks like a protocol header */ - if(!checkprotoprefix(data, conn, data->state.headerbuff)) { + if(!k->headerline) { + /* check if this looks like a protocol header */ + statusline st = checkprotoprefix(data, conn, data->state.headerbuff, + k->hbuflen); + if(st == STATUS_BAD) { /* this is not the beginning of a protocol first header line */ k->header = FALSE; k->badheader = HEADER_ALLBAD; + streamclose(conn, "bad HTTP: No end-of-message indicator"); break; } } @@ -3070,8 +3158,10 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, if(!k->headerline) { /* the first read header */ - if((k->hbuflen>5) && - !checkprotoprefix(data, conn, data->state.headerbuff)) { + statusline st = checkprotoprefix(data, conn, data->state.headerbuff, + k->hbuflen); + if(st == STATUS_BAD) { + streamclose(conn, "bad HTTP: No end-of-message indicator"); /* this is not the beginning of a protocol first header line */ k->header = FALSE; if(*nread) @@ -3354,7 +3444,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, if(data->set.verbose) Curl_debug(data, CURLINFO_HEADER_IN, - k->str_start, headerlen, conn); + k->str_start, headerlen); break; /* exit header line loop */ } @@ -3440,7 +3530,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, compare header line against list of aliases */ if(!nc) { - if(checkhttpprefix(data, k->p)) { + if(checkhttpprefix(data, k->p, k->hbuflen) == STATUS_DONE) { nc = 1; k->httpcode = 200; conn->httpversion = 10; @@ -3487,21 +3577,18 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, * depending on how authentication is working. Other codes * are definitely errors, so give up here. */ - if(data->set.http_fail_on_error && (k->httpcode >= 400) && + if(data->state.resume_from && data->set.httpreq == HTTPREQ_GET && + k->httpcode == 416) { + /* "Requested Range Not Satisfiable", just proceed and + pretend this is no error */ + k->ignorebody = TRUE; /* Avoid appending error msg to good data. */ + } + else if(data->set.http_fail_on_error && (k->httpcode >= 400) && ((k->httpcode != 401) || !conn->bits.user_passwd) && ((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) { - - if(data->state.resume_from && - (data->set.httpreq == HTTPREQ_GET) && - (k->httpcode == 416)) { - /* "Requested Range Not Satisfiable", just proceed and - pretend this is no error */ - } - else { - /* serious error, go home! */ - print_http_error(data); - return CURLE_HTTP_RETURNED_ERROR; - } + /* serious error, go home! */ + print_http_error(data); + return CURLE_HTTP_RETURNED_ERROR; } if(conn->httpversion == 10) { @@ -3812,8 +3899,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data, writetype |= CLIENTWRITE_BODY; if(data->set.verbose) - Curl_debug(data, CURLINFO_HEADER_IN, - k->p, (size_t)k->hbuflen, conn); + Curl_debug(data, CURLINFO_HEADER_IN, k->p, (size_t)k->hbuflen); result = Curl_client_write(conn, writetype, k->p, k->hbuflen); if(result) diff --git a/Utilities/cmcurl/lib/http2.c b/Utilities/cmcurl/lib/http2.c index da001df..d769193 100644 --- a/Utilities/cmcurl/lib/http2.c +++ b/Utilities/cmcurl/lib/http2.c @@ -42,7 +42,6 @@ #include "memdebug.h" #define H2_BUFSIZE 32768 -#define MIN(x,y) ((x)<(y)?(x):(y)) #if (NGHTTP2_VERSION_NUM < 0x010000) #error too old nghttp2 version, upgrade! @@ -154,6 +153,11 @@ static void http2_stream_free(struct HTTP *http) } } +/* + * Disconnects *a* connection used for HTTP/2. It might be an old one from the + * connection cache and not the "main" one. Don't touch the easy handle! + */ + static CURLcode http2_disconnect(struct connectdata *conn, bool dead_connection) { @@ -164,8 +168,6 @@ static CURLcode http2_disconnect(struct connectdata *conn, nghttp2_session_del(c->h2); Curl_safefree(c->inbuf); - http2_stream_free(conn->data->req.protop); - conn->data->state.drain = 0; H2BUGF(infof(conn->data, "HTTP/2 DISCONNECT done\n")); @@ -345,7 +347,7 @@ const char *Curl_http2_strerror(uint32_t err) "INADEQUATE_SECURITY", /* 0xC */ "HTTP_1_1_REQUIRED" /* 0xD */ }; - return (err < sizeof str / sizeof str[0]) ? str[err] : "unknown"; + return (err < sizeof(str) / sizeof(str[0])) ? str[err] : "unknown"; #else return nghttp2_http2_strerror(err); #endif @@ -368,6 +370,10 @@ static ssize_t send_callback(nghttp2_session *h2, (void)h2; (void)flags; + if(!c->send_underlying) + /* called before setup properly! */ + return NGHTTP2_ERR_CALLBACK_FAILURE; + written = ((Curl_send*)c->send_underlying)(conn, FIRSTSOCKET, data, length, &result); @@ -441,6 +447,28 @@ char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header) return NULL; } +/* + * This specific transfer on this connection has been "drained". + */ +static void drained_transfer(struct Curl_easy *data, + struct http_conn *httpc) +{ + DEBUGASSERT(httpc->drain_total >= data->state.drain); + httpc->drain_total -= data->state.drain; + data->state.drain = 0; +} + +/* + * Mark this transfer to get "drained". + */ +static void drain_this(struct Curl_easy *data, + struct http_conn *httpc) +{ + data->state.drain++; + httpc->drain_total++; + DEBUGASSERT(httpc->drain_total >= data->state.drain); +} + static struct Curl_easy *duphandle(struct Curl_easy *data) { struct Curl_easy *second = curl_easy_duphandle(data); @@ -520,6 +548,7 @@ static int push_promise(struct Curl_easy *data, if(rv) { /* denied, kill off the new handle again */ http2_stream_free(newhandle->req.protop); + newhandle->req.protop = NULL; (void)Curl_close(newhandle); goto fail; } @@ -535,14 +564,22 @@ static int push_promise(struct Curl_easy *data, if(rc) { infof(data, "failed to add handle to multi\n"); http2_stream_free(newhandle->req.protop); + newhandle->req.protop = NULL; Curl_close(newhandle); rv = 1; goto fail; } httpc = &conn->proto.httpc; - nghttp2_session_set_stream_user_data(httpc->h2, - frame->promised_stream_id, newhandle); + rv = nghttp2_session_set_stream_user_data(httpc->h2, + frame->promised_stream_id, + newhandle); + if(rv) { + infof(data, "failed to set user_data for stream %d\n", + frame->promised_stream_id); + DEBUGASSERT(0); + goto fail; + } } else { H2BUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n")); @@ -581,7 +618,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, if(max_conn != httpc->settings.max_concurrent_streams) { /* only signal change if the value actually changed */ infof(conn->data, - "Connection state changed (MAX_CONCURRENT_STREAMS == %d)!\n", + "Connection state changed (MAX_CONCURRENT_STREAMS == %u)!\n", httpc->settings.max_concurrent_streams); Curl_multi_connchanged(conn->data->multi); } @@ -640,7 +677,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, Curl_add_buffer(stream->header_recvbuf, "\r\n", 2); left = stream->header_recvbuf->size_used - stream->nread_header_recvbuf; - ncopy = MIN(stream->len, left); + ncopy = CURLMIN(stream->len, left); memcpy(&stream->mem[stream->memlen], stream->header_recvbuf->buffer + stream->nread_header_recvbuf, @@ -653,8 +690,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, stream->len -= ncopy; stream->memlen += ncopy; - data_s->state.drain++; - httpc->drain_total++; + drain_this(data_s, httpc); { /* get the pointer from userp again since it was re-assigned above */ struct connectdata *conn_s = (struct connectdata *)userp; @@ -683,25 +719,6 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, return 0; } -static int on_invalid_frame_recv(nghttp2_session *session, - const nghttp2_frame *frame, - int lib_error_code, void *userp) -{ - struct Curl_easy *data_s = NULL; - (void)userp; -#if !defined(DEBUG_HTTP2) || defined(CURL_DISABLE_VERBOSE_STRINGS) - (void)lib_error_code; -#endif - - data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); - if(data_s) { - H2BUGF(infof(data_s, - "on_invalid_frame_recv() was called, error=%d:%s\n", - lib_error_code, nghttp2_strerror(lib_error_code))); - } - return 0; -} - static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags, int32_t stream_id, const uint8_t *data, size_t len, void *userp) @@ -727,14 +744,13 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags, if(!stream) return NGHTTP2_ERR_CALLBACK_FAILURE; - nread = MIN(stream->len, len); + nread = CURLMIN(stream->len, len); memcpy(&stream->mem[stream->memlen], data, nread); stream->len -= nread; stream->memlen += nread; - data_s->state.drain++; - conn->proto.httpc.drain_total++; + drain_this(data_s, &conn->proto.httpc); /* if we receive data for another handle, wake that up */ if(conn->data != data_s) @@ -768,58 +784,13 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags, return 0; } -static int before_frame_send(nghttp2_session *session, - const nghttp2_frame *frame, - void *userp) -{ - struct Curl_easy *data_s; - (void)userp; - - data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); - if(data_s) { - H2BUGF(infof(data_s, "before_frame_send() was called\n")); - } - - return 0; -} -static int on_frame_send(nghttp2_session *session, - const nghttp2_frame *frame, - void *userp) -{ - struct Curl_easy *data_s; - (void)userp; - - data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); - if(data_s) { - H2BUGF(infof(data_s, "on_frame_send() was called, length = %zd\n", - frame->hd.length)); - } - return 0; -} -static int on_frame_not_send(nghttp2_session *session, - const nghttp2_frame *frame, - int lib_error_code, void *userp) -{ - struct Curl_easy *data_s; - (void)userp; -#if !defined(DEBUG_HTTP2) || defined(CURL_DISABLE_VERBOSE_STRINGS) - (void)lib_error_code; -#endif - - data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id); - if(data_s) { - H2BUGF(infof(data_s, - "on_frame_not_send() was called, lib_error_code = %d\n", - lib_error_code)); - } - return 0; -} static int on_stream_close(nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *userp) { struct Curl_easy *data_s; struct HTTP *stream; struct connectdata *conn = (struct connectdata *)userp; + int rv; (void)session; (void)stream_id; @@ -840,14 +811,19 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id, return NGHTTP2_ERR_CALLBACK_FAILURE; stream->closed = TRUE; - data_s->state.drain++; httpc = &conn->proto.httpc; - httpc->drain_total++; + drain_this(data_s, httpc); httpc->error_code = error_code; /* remove the entry from the hash as the stream is now gone */ - nghttp2_session_set_stream_user_data(session, stream_id, 0); + rv = nghttp2_session_set_stream_user_data(session, stream_id, 0); + if(rv) { + infof(data_s, "http/2: failed to clear user_data for stream %d!\n", + stream_id); + DEBUGASSERT(0); + } H2BUGF(infof(data_s, "Removed stream %u hash!\n", stream_id)); + stream->stream_id = 0; /* cleared */ } return 0; } @@ -1052,7 +1028,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session, else return NGHTTP2_ERR_INVALID_ARGUMENT; - nread = MIN(stream->upload_len, length); + nread = CURLMIN(stream->upload_len, length); if(nread > 0) { memcpy(buf, stream->upload_mem, nread); stream->upload_mem += nread; @@ -1109,6 +1085,12 @@ void Curl_http2_done(struct connectdata *conn, bool premature) struct HTTP *http = data->req.protop; struct http_conn *httpc = &conn->proto.httpc; + if(!httpc->h2) /* not HTTP/2 ? */ + return; + + if(data->state.drain) + drained_transfer(data, httpc); + if(http->header_recvbuf) { Curl_add_buffer_free(http->header_recvbuf); http->header_recvbuf = NULL; /* clear the pointer */ @@ -1126,15 +1108,24 @@ void Curl_http2_done(struct connectdata *conn, bool premature) if(premature) { /* RST_STREAM */ - nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE, http->stream_id, - NGHTTP2_STREAM_CLOSED); + if(!nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE, + http->stream_id, NGHTTP2_STREAM_CLOSED)) + (void)nghttp2_session_send(httpc->h2); + if(http->stream_id == httpc->pause_stream_id) { infof(data, "stopped the pause stream!\n"); httpc->pause_stream_id = 0; } } - if(http->stream_id) { - nghttp2_session_set_stream_user_data(httpc->h2, http->stream_id, 0); + /* -1 means unassigned and 0 means cleared */ + if(http->stream_id > 0) { + int rv = nghttp2_session_set_stream_user_data(httpc->h2, + http->stream_id, 0); + if(rv) { + infof(data, "http/2: failed to clear user_data for stream %d!\n", + http->stream_id); + DEBUGASSERT(0); + } http->stream_id = 0; } } @@ -1164,21 +1155,9 @@ CURLcode Curl_http2_init(struct connectdata *conn) /* nghttp2_on_frame_recv_callback */ nghttp2_session_callbacks_set_on_frame_recv_callback (callbacks, on_frame_recv); - /* nghttp2_on_invalid_frame_recv_callback */ - nghttp2_session_callbacks_set_on_invalid_frame_recv_callback - (callbacks, on_invalid_frame_recv); /* nghttp2_on_data_chunk_recv_callback */ nghttp2_session_callbacks_set_on_data_chunk_recv_callback (callbacks, on_data_chunk_recv); - /* nghttp2_before_frame_send_callback */ - nghttp2_session_callbacks_set_before_frame_send_callback - (callbacks, before_frame_send); - /* nghttp2_on_frame_send_callback */ - nghttp2_session_callbacks_set_on_frame_send_callback - (callbacks, on_frame_send); - /* nghttp2_on_frame_not_send_callback */ - nghttp2_session_callbacks_set_on_frame_not_send_callback - (callbacks, on_frame_not_send); /* nghttp2_on_stream_close_callback */ nghttp2_session_callbacks_set_on_stream_close_callback (callbacks, on_stream_close); @@ -1280,7 +1259,7 @@ static int h2_process_pending_input(struct connectdata *conn, if(rv < 0) { failf(data, "h2_process_pending_input: nghttp2_session_mem_recv() returned " - "%d:%s\n", rv, nghttp2_strerror((int)rv)); + "%zd:%s\n", rv, nghttp2_strerror((int)rv)); *err = CURLE_RECV_ERROR; return -1; } @@ -1352,7 +1331,6 @@ CURLcode Curl_http2_done_sending(struct connectdata *conn) return result; } - static ssize_t http2_handle_stream_close(struct connectdata *conn, struct Curl_easy *data, struct HTTP *stream, CURLcode *err) @@ -1365,9 +1343,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn, httpc->pause_stream_id = 0; } - DEBUGASSERT(httpc->drain_total >= data->state.drain); - httpc->drain_total -= data->state.drain; - data->state.drain = 0; + drained_transfer(data, httpc); if(httpc->pause_stream_id == 0) { if(h2_process_pending_input(conn, httpc, err) != 0) { @@ -1388,7 +1364,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn, return -1; } else if(httpc->error_code != NGHTTP2_NO_ERROR) { - failf(data, "HTTP/2 stream %u was not closed cleanly: %s (err %d)", + failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)", stream->stream_id, Curl_http2_strerror(httpc->error_code), httpc->error_code); *err = CURLE_HTTP2_STREAM; @@ -1396,7 +1372,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn, } if(!stream->bodystarted) { - failf(data, "HTTP/2 stream %u was closed cleanly, but before getting " + failf(data, "HTTP/2 stream %d was closed cleanly, but before getting " " all response header fields, treated as error", stream->stream_id); *err = CURLE_HTTP2_STREAM; @@ -1510,7 +1486,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex, /* If there is body data pending for this stream to return, do that */ size_t left = stream->header_recvbuf->size_used - stream->nread_header_recvbuf; - size_t ncopy = MIN(len, left); + size_t ncopy = CURLMIN(len, left); memcpy(mem, stream->header_recvbuf->buffer + stream->nread_header_recvbuf, ncopy); stream->nread_header_recvbuf += ncopy; @@ -1546,13 +1522,13 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex, } else if(stream->pausedata) { DEBUGASSERT(httpc->pause_stream_id == stream->stream_id); - nread = MIN(len, stream->pauselen); + nread = CURLMIN(len, stream->pauselen); memcpy(mem, stream->pausedata, nread); stream->pausedata += nread; stream->pauselen -= nread; - infof(data, "%zu data bytes written\n", nread); + infof(data, "%zd data bytes written\n", nread); if(stream->pauselen == 0) { H2BUGF(infof(data, "Unpaused by stream %u\n", stream->stream_id)); DEBUGASSERT(httpc->pause_stream_id == stream->stream_id); @@ -1635,7 +1611,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex, rv = nghttp2_session_mem_recv(httpc->h2, (const uint8_t *)inbuf, nread); if(nghttp2_is_fatal((int)rv)) { - failf(data, "nghttp2_session_mem_recv() returned %d:%s\n", + failf(data, "nghttp2_session_mem_recv() returned %zd:%s\n", rv, nghttp2_strerror((int)rv)); *err = CURLE_RECV_ERROR; return -1; @@ -1678,9 +1654,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex, stream->stream_id)); } else if(!stream->closed) { - DEBUGASSERT(httpc->drain_total >= data->state.drain); - httpc->drain_total -= data->state.drain; - data->state.drain = 0; /* this stream is hereby drained */ + drained_transfer(data, httpc); } return retlen; @@ -2040,7 +2014,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex, } infof(conn->data, "Using Stream ID: %x (easy handle %p)\n", - stream_id, conn->data); + stream_id, (void *)conn->data); stream->stream_id = stream_id; /* this does not call h2_session_send() since there can not have been any @@ -2154,9 +2128,14 @@ CURLcode Curl_http2_switched(struct connectdata *conn, return CURLE_HTTP2; } - nghttp2_session_set_stream_user_data(httpc->h2, - stream->stream_id, - conn->data); + rv = nghttp2_session_set_stream_user_data(httpc->h2, + stream->stream_id, + data); + if(rv) { + infof(data, "http/2: failed to set user_data for stream %d!\n", + stream->stream_id); + DEBUGASSERT(0); + } } else { populate_settings(conn, httpc); diff --git a/Utilities/cmcurl/lib/http2.h b/Utilities/cmcurl/lib/http2.h index f597c80..21cd9b8 100644 --- a/Utilities/cmcurl/lib/http2.h +++ b/Utilities/cmcurl/lib/http2.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -65,7 +65,7 @@ void Curl_http2_cleanup_dependencies(struct Curl_easy *data); #define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL #define Curl_http2_switched(x,y,z) CURLE_UNSUPPORTED_PROTOCOL -#define Curl_http2_setup_conn(x) +#define Curl_http2_setup_conn(x) Curl_nop_stmt #define Curl_http2_setup_req(x) #define Curl_http2_init_state(x) #define Curl_http2_init_userset(x) diff --git a/Utilities/cmcurl/lib/http_ntlm.c b/Utilities/cmcurl/lib/http_ntlm.c index fd5540b..a9b33f9 100644 --- a/Utilities/cmcurl/lib/http_ntlm.c +++ b/Utilities/cmcurl/lib/http_ntlm.c @@ -228,7 +228,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy) /* connection is already authenticated, * don't send a header in future requests */ ntlm->state = NTLMSTATE_LAST; - /* fall-through */ + /* FALLTHROUGH */ case NTLMSTATE_LAST: Curl_safefree(*allocuserpwd); authp->done = TRUE; diff --git a/Utilities/cmcurl/lib/http_proxy.c b/Utilities/cmcurl/lib/http_proxy.c index e10a488..c8c445b 100644 --- a/Utilities/cmcurl/lib/http_proxy.c +++ b/Utilities/cmcurl/lib/http_proxy.c @@ -188,12 +188,10 @@ static CURLcode CONNECT(struct connectdata *conn, struct SingleRequest *k = &data->req; CURLcode result; curl_socket_t tunnelsocket = conn->sock[sockindex]; - timediff_t check; struct http_connect_state *s = conn->connect_state; #define SELECT_OK 0 #define SELECT_ERROR 1 -#define SELECT_TIMEOUT 2 if(Curl_connect_complete(conn)) return CURLE_OK; /* CONNECT is already completed */ @@ -201,12 +199,13 @@ static CURLcode CONNECT(struct connectdata *conn, conn->bits.proxy_connect_closed = FALSE; do { + timediff_t check; if(TUNNEL_INIT == s->tunnel_state) { /* BEGIN CONNECT PHASE */ char *host_port; Curl_send_buffer *req_buffer; - infof(data, "Establish HTTP proxy tunnel to %s:%hu\n", + infof(data, "Establish HTTP proxy tunnel to %s:%d\n", hostname, remote_port); /* This only happens if we've looped here due to authentication @@ -419,7 +418,7 @@ static CURLcode CONNECT(struct connectdata *conn, /* output debug if that is requested */ if(data->set.verbose) Curl_debug(data, CURLINFO_HEADER_IN, - s->line_start, (size_t)s->perline, conn); + s->line_start, (size_t)s->perline); if(!data->set.suppress_connect_headers) { /* send the header to the callback */ diff --git a/Utilities/cmcurl/lib/imap.c b/Utilities/cmcurl/lib/imap.c index cf278a2..942fe7d 100644 --- a/Utilities/cmcurl/lib/imap.c +++ b/Utilities/cmcurl/lib/imap.c @@ -609,7 +609,6 @@ static CURLcode imap_perform_list(struct connectdata *conn) CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; struct IMAP *imap = data->req.protop; - char *mailbox; if(imap->custom) /* Send the custom request */ @@ -617,7 +616,8 @@ static CURLcode imap_perform_list(struct connectdata *conn) imap->custom_params ? imap->custom_params : ""); else { /* Make sure the mailbox is in the correct atom format if necessary */ - mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) : strdup(""); + char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) + : strdup(""); if(!mailbox) return CURLE_OUT_OF_MEMORY; @@ -854,7 +854,6 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn, struct Curl_easy *data = conn->data; struct imap_conn *imapc = &conn->proto.imapc; const char *line = data->state.buffer; - size_t wordlen; (void)instate; /* no use for this yet */ @@ -864,6 +863,7 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn, /* Loop through the data line */ for(;;) { + size_t wordlen; while(*line && (*line == ' ' || *line == '\t' || *line == '\r' || *line == '\n')) { @@ -1046,12 +1046,12 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, int imapcode, struct IMAP *imap = conn->data->req.protop; struct imap_conn *imapc = &conn->proto.imapc; const char *line = data->state.buffer; - char tmp[20]; (void)instate; /* no use for this yet */ if(imapcode == '*') { /* See if this is an UIDVALIDITY response */ + char tmp[20]; if(sscanf(line + 2, "OK [UIDVALIDITY %19[0123456789]]", tmp) == 1) { Curl_safefree(imapc->mailbox_uidvalidity); imapc->mailbox_uidvalidity = strdup(tmp); @@ -1119,7 +1119,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, } if(parsed) { - infof(data, "Found %" CURL_FORMAT_CURL_OFF_TU " bytes to download\n", + infof(data, "Found %" CURL_FORMAT_CURL_OFF_T " bytes to download\n", size); Curl_pgrsSetDownloadSize(data, size); @@ -1144,10 +1144,8 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, data->req.bytecount += chunk; - infof(data, "Written %" CURL_FORMAT_CURL_OFF_TU - " bytes, %" CURL_FORMAT_CURL_OFF_TU - " bytes are left for transfer\n", (curl_off_t)chunk, - size - chunk); + infof(data, "Written %zu bytes, %" CURL_FORMAT_CURL_OFF_TU + " bytes are left for transfer\n", chunk, size - chunk); /* Have we used the entire cache or just part of it?*/ if(pp->cache_size > chunk) { diff --git a/Utilities/cmcurl/lib/inet_ntop.c b/Utilities/cmcurl/lib/inet_ntop.c index fb91a50..ac5d2d4 100644 --- a/Utilities/cmcurl/lib/inet_ntop.c +++ b/Utilities/cmcurl/lib/inet_ntop.c @@ -49,7 +49,7 @@ */ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size) { - char tmp[sizeof "255.255.255.255"]; + char tmp[sizeof("255.255.255.255")]; size_t len; DEBUGASSERT(size >= 16); diff --git a/Utilities/cmcurl/lib/ldap.c b/Utilities/cmcurl/lib/ldap.c index 89047bc..4d8f4fa 100644 --- a/Utilities/cmcurl/lib/ldap.c +++ b/Utilities/cmcurl/lib/ldap.c @@ -54,15 +54,6 @@ # endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */ #endif -/* These are macros in both <wincrypt.h> (in above <winldap.h>) and typedefs - * in BoringSSL's <openssl/x509.h> - */ -#ifdef HAVE_BORINGSSL -# undef X509_NAME -# undef X509_CERT_PAIR -# undef X509_EXTENSIONS -#endif - #include "urldata.h" #include <curl/curl.h> #include "sendf.h" diff --git a/Utilities/cmcurl/lib/md5.c b/Utilities/cmcurl/lib/md5.c index 3096602..b819d39 100644 --- a/Utilities/cmcurl/lib/md5.c +++ b/Utilities/cmcurl/lib/md5.c @@ -484,29 +484,35 @@ static void MD5_Final(unsigned char *result, MD5_CTX *ctx) #endif /* CRYPTO LIBS */ -/* Disable this picky gcc-8 compiler warning */ -#if defined(__GNUC__) && (__GNUC__ >= 8) -#pragma GCC diagnostic ignored "-Wcast-function-type" -#endif - const HMAC_params Curl_HMAC_MD5[] = { { - (HMAC_hinit_func) MD5_Init, /* Hash initialization function. */ - (HMAC_hupdate_func) MD5_Update, /* Hash update function. */ - (HMAC_hfinal_func) MD5_Final, /* Hash computation end function. */ - sizeof(MD5_CTX), /* Size of hash context structure. */ - 64, /* Maximum key length. */ - 16 /* Result size. */ + /* Hash initialization function. */ + CURLX_FUNCTION_CAST(HMAC_hinit_func, MD5_Init), + /* Hash update function. */ + CURLX_FUNCTION_CAST(HMAC_hupdate_func, MD5_Update), + /* Hash computation end function. */ + CURLX_FUNCTION_CAST(HMAC_hfinal_func, MD5_Final), + /* Size of hash context structure. */ + sizeof(MD5_CTX), + /* Maximum key length. */ + 64, + /* Result size. */ + 16 } }; const MD5_params Curl_DIGEST_MD5[] = { { - (Curl_MD5_init_func) MD5_Init, /* Digest initialization function */ - (Curl_MD5_update_func) MD5_Update, /* Digest update function */ - (Curl_MD5_final_func) MD5_Final, /* Digest computation end function */ - sizeof(MD5_CTX), /* Size of digest context struct */ - 16 /* Result size */ + /* Digest initialization function */ + CURLX_FUNCTION_CAST(Curl_MD5_init_func, MD5_Init), + /* Digest update function */ + CURLX_FUNCTION_CAST(Curl_MD5_update_func, MD5_Update), + /* Digest computation end function */ + CURLX_FUNCTION_CAST(Curl_MD5_final_func, MD5_Final), + /* Size of digest context struct */ + sizeof(MD5_CTX), + /* Result size */ + 16 } }; @@ -527,7 +533,7 @@ MD5_context *Curl_MD5_init(const MD5_params *md5params) MD5_context *ctxt; /* Create MD5 context */ - ctxt = malloc(sizeof *ctxt); + ctxt = malloc(sizeof(*ctxt)); if(!ctxt) return ctxt; diff --git a/Utilities/cmcurl/lib/memdebug.h b/Utilities/cmcurl/lib/memdebug.h index 6fb8b68..233de65 100644 --- a/Utilities/cmcurl/lib/memdebug.h +++ b/Utilities/cmcurl/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -137,13 +137,6 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif #endif /* HAVE_GETADDRINFO */ -#ifdef HAVE_GETNAMEINFO -#undef getnameinfo -#define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ - curl_dogetnameinfo(sa, salen, host, hostlen, serv, servlen, flags, \ - __LINE__, __FILE__) -#endif /* HAVE_GETNAMEINFO */ - #ifdef HAVE_FREEADDRINFO #undef freeaddrinfo #define freeaddrinfo(data) \ diff --git a/Utilities/cmcurl/lib/mime.c b/Utilities/cmcurl/lib/mime.c index 4c0d2eeb..ca492d1 100644 --- a/Utilities/cmcurl/lib/mime.c +++ b/Utilities/cmcurl/lib/mime.c @@ -505,9 +505,6 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof, mime_encoder_state *st = &part->encstate; char *ptr = buffer; size_t cursize = 0; - int i; - size_t len; - size_t consumed; int softlinebreak; char buf[4]; @@ -516,9 +513,9 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof, character constants that can be interpreted as non-ascii on some platforms. Preserve ASCII encoding on output too. */ while(st->bufbeg < st->bufend) { - len = 1; - consumed = 1; - i = st->buf[st->bufbeg]; + size_t len = 1; + size_t consumed = 1; + int i = st->buf[st->bufbeg]; buf[0] = (char) i; buf[1] = aschex[(i >> 4) & 0xF]; buf[2] = aschex[i & 0xF]; @@ -787,10 +784,10 @@ static size_t read_encoded_part_content(curl_mimepart *part, st->bufbeg = 0; st->bufend = len; } - if(st->bufend >= sizeof st->buf) + if(st->bufend >= sizeof(st->buf)) return cursize? cursize: READ_ERROR; /* Buffer full. */ sz = read_part_content(part, st->buf + st->bufend, - sizeof st->buf - st->bufend); + sizeof(st->buf) - st->bufend); switch(sz) { case 0: ateof = TRUE; @@ -813,8 +810,6 @@ static size_t readback_part(curl_mimepart *part, char *buffer, size_t bufsize) { size_t cursize = 0; - size_t sz; - struct curl_slist *hdr; #ifdef CURL_DOES_CONVERSIONS char *convbuf = buffer; #endif @@ -822,8 +817,8 @@ static size_t readback_part(curl_mimepart *part, /* Readback from part. */ while(bufsize) { - sz = 0; - hdr = (struct curl_slist *) part->state.ptr; + size_t sz = 0; + struct curl_slist *hdr = (struct curl_slist *) part->state.ptr; switch(part->state.state) { case MIMESTATE_BEGIN: mimesetstate(&part->state, part->flags & MIME_BODY_ONLY? MIMESTATE_BODY: @@ -918,8 +913,6 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems, { curl_mime *mime = (curl_mime *) instream; size_t cursize = 0; - size_t sz; - curl_mimepart *part; #ifdef CURL_DOES_CONVERSIONS char *convbuf = buffer; #endif @@ -927,8 +920,8 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems, (void) size; /* Always 1. */ while(nitems) { - sz = 0; - part = mime->state.ptr; + size_t sz = 0; + curl_mimepart *part = mime->state.ptr; switch(mime->state.state) { case MIMESTATE_BEGIN: case MIMESTATE_BODY: @@ -1044,7 +1037,6 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence) curl_mime *mime = (curl_mime *) instream; curl_mimepart *part; int result = CURL_SEEKFUNC_OK; - int res; if(whence != SEEK_SET || offset) return CURL_SEEKFUNC_CANTSEEK; /* Only support full rewind. */ @@ -1053,7 +1045,7 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence) return CURL_SEEKFUNC_OK; /* Already rewound. */ for(part = mime->firstpart; part; part = part->nextpart) { - res = mime_part_rewind(part); + int res = mime_part_rewind(part); if(res != CURL_SEEKFUNC_OK) result = res; } @@ -1220,7 +1212,7 @@ curl_mime *curl_mime_init(struct Curl_easy *easy) { curl_mime *mime; - mime = (curl_mime *) malloc(sizeof *mime); + mime = (curl_mime *) malloc(sizeof(*mime)); if(mime) { mime->easy = easy; @@ -1236,8 +1228,13 @@ curl_mime *curl_mime_init(struct Curl_easy *easy) } memset(mime->boundary, '-', 24); - Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24, - MIME_RAND_BOUNDARY_CHARS + 1); + if(Curl_rand_hex(easy, (unsigned char *) mime->boundary + 24, + MIME_RAND_BOUNDARY_CHARS + 1)) { + /* failed to get random separator, bail out */ + free(mime->boundary); + free(mime); + return NULL; + } mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL); } @@ -1247,7 +1244,7 @@ curl_mime *curl_mime_init(struct Curl_easy *easy) /* Initialize a mime part. */ void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy) { - memset((char *) part, 0, sizeof *part); + memset((char *) part, 0, sizeof(*part)); part->easy = easy; mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); } @@ -1260,7 +1257,7 @@ curl_mimepart *curl_mime_addpart(curl_mime *mime) if(!mime) return NULL; - part = (curl_mimepart *) malloc(sizeof *part); + part = (curl_mimepart *) malloc(sizeof(*part)); if(part) { Curl_mime_initpart(part, mime->easy); @@ -1349,7 +1346,6 @@ CURLcode curl_mime_data(curl_mimepart *part, CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) { CURLcode result = CURLE_OK; - char *base; if(!part) return CURLE_BAD_FUNCTION_ARGUMENT; @@ -1357,6 +1353,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) cleanup_part_content(part); if(filename) { + char *base; struct_stat sbuf; if(stat(filename, &sbuf) || access(filename, R_OK)) @@ -1564,7 +1561,6 @@ static size_t slist_size(struct curl_slist *s, static curl_off_t multipart_size(curl_mime *mime) { curl_off_t size; - curl_off_t sz; size_t boundarysize; curl_mimepart *part; @@ -1575,7 +1571,7 @@ static curl_off_t multipart_size(curl_mime *mime) size = boundarysize; /* Final boundary - CRLF after headers. */ for(part = mime->firstpart; part; part = part->nextpart) { - sz = Curl_mime_size(part); + curl_off_t sz = Curl_mime_size(part); if(sz < 0) size = sz; @@ -1643,8 +1639,6 @@ static CURLcode add_content_type(struct curl_slist **slp, const char *Curl_mime_contenttype(const char *filename) { - unsigned int i; - /* * If no content type was specified, we scan through a few well-known * extensions and pick the first we match! @@ -1669,8 +1663,9 @@ const char *Curl_mime_contenttype(const char *filename) if(filename) { size_t len1 = strlen(filename); const char *nameend = filename + len1; + unsigned int i; - for(i = 0; i < sizeof ctts / sizeof ctts[0]; i++) { + for(i = 0; i < sizeof(ctts) / sizeof(ctts[0]); i++) { size_t len2 = strlen(ctts[i].extension); if(len1 >= len2 && strcasecompare(nameend - len2, ctts[i].extension)) diff --git a/Utilities/cmcurl/lib/multi.c b/Utilities/cmcurl/lib/multi.c index f852846..0caf943 100644 --- a/Utilities/cmcurl/lib/multi.c +++ b/Utilities/cmcurl/lib/multi.c @@ -31,6 +31,7 @@ #include "progress.h" #include "easyif.h" #include "share.h" +#include "psl.h" #include "multiif.h" #include "sendf.h" #include "timeval.h" @@ -68,8 +69,8 @@ #define GOOD_MULTI_HANDLE(x) \ ((x) && (x)->type == CURL_MULTI_HANDLE) -static void singlesocket(struct Curl_multi *multi, - struct Curl_easy *data); +static CURLMcode singlesocket(struct Curl_multi *multi, + struct Curl_easy *data); static int update_timer(struct Curl_multi *multi); static CURLMcode add_next_timeout(struct curltime now, @@ -106,6 +107,16 @@ static const char * const statename[]={ /* function pointer called once when switching TO a state */ typedef void (*init_multistate_func)(struct Curl_easy *data); +static void Curl_init_completed(struct Curl_easy *data) +{ + /* this is a completed transfer */ + + /* Important: reset the conn pointer so that we don't point to memory + that could be freed anytime */ + data->easy_conn = NULL; + Curl_expire_clear(data); /* stop all timers */ +} + /* always use this function to change state, to make debugging easier */ static void mstate(struct Curl_easy *data, CURLMstate state #ifdef DEBUGBUILD @@ -115,17 +126,25 @@ static void mstate(struct Curl_easy *data, CURLMstate state { CURLMstate oldstate = data->mstate; static const init_multistate_func finit[CURLM_STATE_LAST] = { - NULL, - NULL, + NULL, /* INIT */ + NULL, /* CONNECT_PEND */ Curl_init_CONNECT, /* CONNECT */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - Curl_connect_free /* DO */ - /* the rest is NULL too */ + NULL, /* WAITRESOLVE */ + NULL, /* WAITCONNECT */ + NULL, /* WAITPROXYCONNECT */ + NULL, /* SENDPROTOCONNECT */ + NULL, /* PROTOCONNECT */ + NULL, /* WAITDO */ + Curl_connect_free, /* DO */ + NULL, /* DOING */ + NULL, /* DO_MORE */ + NULL, /* DO_DONE */ + NULL, /* WAITPERFORM */ + NULL, /* PERFORM */ + NULL, /* TOOFAST */ + NULL, /* DONE */ + Curl_init_completed, /* COMPLETED */ + NULL /* MSGSENT */ }; #if defined(DEBUGBUILD) && defined(CURL_DISABLE_VERBOSE_STRINGS) @@ -409,6 +428,14 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi, else data->state.conn_cache = &multi->conn_cache; +#ifdef USE_LIBPSL + /* Do the same for PSL. */ + if(data->share && (data->share->specifier & (1 << CURL_LOCK_DATA_PSL))) + data->psl = &data->share->psl; + else + data->psl = &multi->psl; +#endif + /* This adds the new entry at the 'end' of the doubly-linked circular list of Curl_easy structs to try and maintain a FIFO queue so the pipelined requests are in order. */ @@ -449,7 +476,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi, happens if the lastcall time is set to the same time when the handle is removed as when the next handle is added, as then the check in update_timer() that prevents calling the application multiple times with - the same timer infor will not trigger and then the new handle's timeout + the same timer info will not trigger and then the new handle's timeout will not be notified to the app. The work-around is thus simply to clear the 'lastcall' variable to force @@ -506,6 +533,11 @@ static CURLcode multi_done(struct connectdata **connp, /* Stop if multi_done() has already been called */ return CURLE_OK; + if(data->mstate == CURLM_STATE_WAITRESOLVE) { + /* still waiting for the resolve to complete */ + (void)Curl_resolver_wait_resolv(conn, NULL); + } + Curl_getoff_all_pipelines(data, conn); /* Cleanup possible redirect junk */ @@ -546,7 +578,7 @@ static CURLcode multi_done(struct connectdata **connp, if(conn->send_pipe.size || conn->recv_pipe.size) { /* Stop if pipeline is not empty . */ data->easy_conn = NULL; - DEBUGF(infof(data, "Connection still in use %d/%d, " + DEBUGF(infof(data, "Connection still in use %zu/%zu, " "no more multi_done now!\n", conn->send_pipe.size, conn->recv_pipe.size)); return CURLE_OK; @@ -560,6 +592,7 @@ static CURLcode multi_done(struct connectdata **connp, conn->dns_entry = NULL; } Curl_hostcache_prune(data); + Curl_safefree(data->state.ulbuf); /* if the transfer was completed in a paused state there can be buffered data left to free */ @@ -590,7 +623,7 @@ static CURLcode multi_done(struct connectdata **connp, #endif ) || conn->bits.close || (premature && !(conn->handler->flags & PROTOPT_STREAM))) { - CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */ + CURLcode res2 = Curl_disconnect(data, conn, premature); /* If we had an error already, make sure we return that one. But if we got a new error, return that. */ @@ -608,7 +641,7 @@ static CURLcode multi_done(struct connectdata **connp, conn->bits.conn_to_host ? conn->conn_to_host.dispname : conn->host.dispname); - /* the connection is no longer in use */ + /* the connection is no longer in use by this transfer */ if(Curl_conncache_return_conn(conn)) { /* remember the most recently used connection */ data->state.lastconnect = conn; @@ -698,6 +731,11 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, Curl_getoff_all_pipelines(data, data->easy_conn); } + if(data->connect_queue.ptr) + /* the handle was in the pending list waiting for an available connection, + so go ahead and remove it */ + Curl_llist_remove(&multi->pending, &data->connect_queue, NULL); + if(data->dns.hostcachetype == HCACHE_MULTI) { /* stop using the multi handle's DNS cache, *after* the possible multi_done() call above */ @@ -727,6 +765,12 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi, data->easy_conn = NULL; } +#ifdef USE_LIBPSL + /* Remove the PSL association. */ + if(data->psl == &multi->psl) + data->psl = NULL; +#endif + data->multi = NULL; /* clear the association to this multi handle */ /* make sure there's no pending message in the queue sent from this easy @@ -831,12 +875,10 @@ static int multi_getsock(struct Curl_easy *data, of sockets */ int numsocks) { - /* If the pipe broke, or if there's no connection left for this easy handle, - then we MUST bail out now with no bitmask set. The no connection case can - happen when this is called from curl_multi_remove_handle() => - singlesocket() => multi_getsock(). + /* The no connection case can happen when this is called from + curl_multi_remove_handle() => singlesocket() => multi_getsock(). */ - if(data->state.pipe_broke || !data->easy_conn) + if(!data->easy_conn) return 0; if(data->mstate > CURLM_STATE_CONNECT && @@ -902,7 +944,6 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi, struct Curl_easy *data; int this_max_fd = -1; curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE]; - int bitmap; int i; (void)exc_fd_set; /* not used */ @@ -914,7 +955,7 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi, data = multi->easyp; while(data) { - bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE); + int bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE); for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) { curl_socket_t s = CURL_SOCKET_BAD; @@ -1068,8 +1109,6 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi, int pollrc; /* wait... */ pollrc = Curl_poll(ufds, nfds, timeout_ms); - DEBUGF(infof(data, "Curl_poll(%d ds, %d ms) == %d\n", - nfds, timeout_ms, pollrc)); if(pollrc > 0) { retcode = pollrc; @@ -1312,24 +1351,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, bool stream_error = FALSE; rc = CURLM_OK; - /* Handle the case when the pipe breaks, i.e., the connection - we're using gets cleaned up and we're left with nothing. */ - if(data->state.pipe_broke) { - infof(data, "Pipe broke: handle %p, url = %s\n", - (void *)data, data->state.path); - - if(data->mstate < CURLM_STATE_COMPLETED) { - /* Head back to the CONNECT state */ - multistate(data, CURLM_STATE_CONNECT); - rc = CURLM_CALL_MULTI_PERFORM; - result = CURLE_OK; - } - - data->state.pipe_broke = FALSE; - data->easy_conn = NULL; - continue; - } - if(!data->easy_conn && data->mstate > CURLM_STATE_CONNECT && data->mstate < CURLM_STATE_DONE) { @@ -1555,6 +1576,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, multistate(data, CURLM_STATE_SENDPROTOCONNECT); } } + else if(result) + stream_error = TRUE; break; #endif @@ -1909,6 +1932,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, CURLcode ret = Curl_retry_request(data->easy_conn, &newurl); if(!ret) retry = (newurl)?TRUE:FALSE; + else if(!result) + result = ret; if(retry) { /* if we are to retry, set the result to OK and consider the @@ -2040,16 +2065,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, break; case CURLM_STATE_COMPLETED: - /* this is a completed transfer, it is likely to still be connected */ - - /* This node should be delinked from the list now and we should post - an information message that we are complete. */ - - /* Important: reset the conn pointer so that we don't point to memory - that could be freed anytime */ - data->easy_conn = NULL; - - Curl_expire_clear(data); /* stop all timers */ break; case CURLM_STATE_MSGSENT: @@ -2071,8 +2086,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* NOTE: no attempt to disconnect connections must be made in the case blocks above - cleanup happens only here */ - data->state.pipe_broke = FALSE; - /* Check if we can move pending requests to send pipe */ process_pending_handles(multi); /* connection */ @@ -2087,7 +2100,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* Don't attempt to send data over a connection that timed out */ bool dead_connection = result == CURLE_OPERATION_TIMEDOUT; /* disconnect properly */ - Curl_disconnect(data->easy_conn, dead_connection); + Curl_disconnect(data, data->easy_conn, dead_connection); /* This is where we make sure that the easy_conn pointer is reset. We don't have to do this in every case block above where a @@ -2101,6 +2114,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } multistate(data, CURLM_STATE_COMPLETED); + rc = CURLM_CALL_MULTI_PERFORM; } /* if there's still a connection to use, call the progress function */ else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) { @@ -2125,14 +2139,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, msg->extmsg.data.result = result; rc = multi_addmsg(multi, msg); - + DEBUGASSERT(!data->easy_conn); multistate(data, CURLM_STATE_MSGSENT); } } while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE)); data->result = result; - - return rc; } @@ -2220,6 +2232,11 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi) data->state.conn_cache = NULL; data->multi = NULL; /* clear the association */ +#ifdef USE_LIBPSL + if(data->psl == &multi->psl) + data->psl = NULL; +#endif + data = nextdata; } @@ -2232,6 +2249,7 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi) Curl_llist_destroy(&multi->pending, NULL); Curl_hash_destroy(&multi->hostcache); + Curl_psl_destroy(&multi->psl); /* Free the blacklists by setting them to NULL */ Curl_pipeline_set_site_blacklist(NULL, &multi->pipelining_site_bl); @@ -2286,8 +2304,8 @@ CURLMsg *curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue) * and if we have a different state in any of those sockets from last time we * call the callback accordingly. */ -static void singlesocket(struct Curl_multi *multi, - struct Curl_easy *data) +static CURLMcode singlesocket(struct Curl_multi *multi, + struct Curl_easy *data) { curl_socket_t socks[MAX_SOCKSPEREASYHANDLE]; int i; @@ -2334,7 +2352,7 @@ static void singlesocket(struct Curl_multi *multi, entry = sh_addentry(&multi->sockhash, s, data); if(!entry) /* fatal */ - return; + return CURLM_OUT_OF_MEMORY; } /* we know (entry != NULL) at this point, see the logic above */ @@ -2422,6 +2440,7 @@ static void singlesocket(struct Curl_multi *multi, memcpy(data->sockets, socks, num*sizeof(curl_socket_t)); data->numsocks = num; + return CURLM_OK; } void Curl_updatesocket(struct Curl_easy *data) @@ -2442,20 +2461,23 @@ void Curl_updatesocket(struct Curl_easy *data) void Curl_multi_closed(struct connectdata *conn, curl_socket_t s) { - struct Curl_multi *multi = conn->data->multi; - if(multi) { - /* this is set if this connection is part of a handle that is added to - a multi handle, and only then this is necessary */ - struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s); - - if(entry) { - if(multi->socket_cb) - multi->socket_cb(conn->data, s, CURL_POLL_REMOVE, - multi->socket_userp, - entry->socketp); + if(conn->data) { + /* if there's still an easy handle associated with this connection */ + struct Curl_multi *multi = conn->data->multi; + if(multi) { + /* this is set if this connection is part of a handle that is added to + a multi handle, and only then this is necessary */ + struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s); + + if(entry) { + if(multi->socket_cb) + multi->socket_cb(conn->data, s, CURL_POLL_REMOVE, + multi->socket_userp, + entry->socketp); - /* now remove it from the socket hash */ - sh_delentry(&multi->sockhash, s); + /* now remove it from the socket hash */ + sh_delentry(&multi->sockhash, s); + } } } } @@ -2535,8 +2557,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi, and callbacks */ if(result != CURLM_BAD_HANDLE) { data = multi->easyp; - while(data) { - singlesocket(multi, data); + while(data && !result) { + result = singlesocket(multi, data); data = data->next; } } @@ -2590,10 +2612,13 @@ static CURLMcode multi_socket(struct Curl_multi *multi, /* clear the bitmask only if not locked */ data->easy_conn->cselect_bits = 0; - if(CURLM_OK >= result) + if(CURLM_OK >= result) { /* get the socket(s) and check if the state has been changed since last */ - singlesocket(multi, data); + result = singlesocket(multi, data); + if(result) + return result; + } /* Now we fall-through and do the timer-based stuff, since we don't want to force the user to have to deal with timeouts as long as at least @@ -2627,10 +2652,13 @@ static CURLMcode multi_socket(struct Curl_multi *multi, result = multi_runsingle(multi, now, data); sigpipe_restore(&pipe_st); - if(CURLM_OK >= result) + if(CURLM_OK >= result) { /* get the socket(s) and check if the state has been changed since last */ - singlesocket(multi, data); + result = singlesocket(multi, data); + if(result) + return result; + } } /* Check if there's one (more) expired timer to deal with! This function @@ -2924,7 +2952,6 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id) { struct Curl_multi *multi = data->multi; struct curltime *nowp = &data->state.expiretime; - int rc; struct curltime set; /* this is only interesting while there is still an associated multi struct @@ -2955,6 +2982,7 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id) Compare if the new time is earlier, and only remove-old/add-new if it is. */ timediff_t diff = Curl_timediff(set, *nowp); + int rc; if(diff > 0) { /* The current splay tree entry is sooner than this new expiry time. @@ -3000,7 +3028,6 @@ void Curl_expire_clear(struct Curl_easy *data) { struct Curl_multi *multi = data->multi; struct curltime *nowp = &data->state.expiretime; - int rc; /* this is only interesting while there is still an associated multi struct remaining! */ @@ -3011,6 +3038,7 @@ void Curl_expire_clear(struct Curl_easy *data) /* Since this is an cleared time, we must remove the previous entry from the splay tree */ struct curl_llist *list = &data->state.timeoutlist; + int rc; rc = Curl_splayremovebyaddr(multi->timetree, &data->state.timenode, @@ -3100,12 +3128,15 @@ static void process_pending_handles(struct Curl_multi *multi) } } -void Curl_set_in_callback(struct Curl_easy *easy, bool value) +void Curl_set_in_callback(struct Curl_easy *data, bool value) { - if(easy->multi_easy) - easy->multi_easy->in_callback = value; - else if(easy->multi) - easy->multi->in_callback = value; + /* might get called when there is no data pointer! */ + if(data) { + if(data->multi_easy) + data->multi_easy->in_callback = value; + else if(data->multi) + data->multi->in_callback = value; + } } bool Curl_is_in_callback(struct Curl_easy *easy) diff --git a/Utilities/cmcurl/lib/multihandle.h b/Utilities/cmcurl/lib/multihandle.h index 1a5017f..ea2bf35 100644 --- a/Utilities/cmcurl/lib/multihandle.h +++ b/Utilities/cmcurl/lib/multihandle.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,6 +23,7 @@ ***************************************************************************/ #include "conncache.h" +#include "psl.h" struct Curl_message { struct curl_llist_element list; @@ -97,6 +98,11 @@ struct Curl_multi { /* Hostname cache */ struct curl_hash hostcache; +#ifdef USE_LIBPSL + /* PSL cache. */ + struct PslCache psl; +#endif + /* timetree points to the splay-tree of time nodes to figure out expire times of all currently set timers */ struct Curl_tree *timetree; diff --git a/Utilities/cmcurl/lib/netrc.c b/Utilities/cmcurl/lib/netrc.c index dbcc59a..a407bda 100644 --- a/Utilities/cmcurl/lib/netrc.c +++ b/Utilities/cmcurl/lib/netrc.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -115,7 +115,7 @@ int Curl_parsenetrc(const char *host, char *tok; char *tok_buf; bool done = FALSE; - char netrcbuffer[256]; + char netrcbuffer[4096]; int netrcbuffsize = (int)sizeof(netrcbuffer); while(!done && fgets(netrcbuffer, netrcbuffsize, file)) { diff --git a/Utilities/cmcurl/lib/pingpong.c b/Utilities/cmcurl/lib/pingpong.c index ad370ee..2e93d20 100644 --- a/Utilities/cmcurl/lib/pingpong.c +++ b/Utilities/cmcurl/lib/pingpong.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -49,7 +49,6 @@ time_t Curl_pp_state_timeout(struct pingpong *pp) struct connectdata *conn = pp->conn; struct Curl_easy *data = conn->data; time_t timeout_ms; /* in milliseconds */ - time_t timeout2_ms; /* in milliseconds */ long response_time = (data->set.server_response_timeout)? data->set.server_response_timeout: pp->response_time; @@ -65,7 +64,7 @@ time_t Curl_pp_state_timeout(struct pingpong *pp) if(data->set.timeout) { /* if timeout is requested, find out how much remaining time we have */ - timeout2_ms = data->set.timeout - /* timeout time */ + time_t timeout2_ms = data->set.timeout - /* timeout time */ Curl_timediff(Curl_now(), conn->now); /* spent time */ /* pick the lowest number */ @@ -222,8 +221,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp, } if(conn->data->set.verbose) - Curl_debug(conn->data, CURLINFO_HEADER_OUT, - s, (size_t)bytes_written, conn); + Curl_debug(conn->data, CURLINFO_HEADER_OUT, s, (size_t)bytes_written); if(bytes_written != (ssize_t)write_len) { /* the whole chunk was not sent, keep it around and adjust sizes */ @@ -371,7 +369,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, #endif if(data->set.verbose) Curl_debug(data, CURLINFO_HEADER_IN, - pp->linestart_resp, (size_t)perline, conn); + pp->linestart_resp, (size_t)perline); /* * We pass all response-lines to the callback function registered diff --git a/Utilities/cmcurl/lib/pipeline.c b/Utilities/cmcurl/lib/pipeline.c index 4d41b04..8de3bab 100644 --- a/Utilities/cmcurl/lib/pipeline.c +++ b/Utilities/cmcurl/lib/pipeline.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2013, Linus Nielsen Feltzing, <linus@haxx.se> - * Copyright (C) 2013 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2013 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -82,7 +82,8 @@ bool Curl_pipeline_penalized(struct Curl_easy *data, penalized = TRUE; infof(data, "Conn: %ld (%p) Receive pipe weight: (%" - CURL_FORMAT_CURL_OFF_T "/%zu), penalized: %s\n", + CURL_FORMAT_CURL_OFF_T "/%" CURL_FORMAT_CURL_OFF_T + "), penalized: %s\n", conn->connection_id, (void *)conn, recv_size, conn->chunk.datasize, penalized?"TRUE":"FALSE"); return penalized; @@ -109,8 +110,8 @@ CURLcode Curl_add_handle_to_pipeline(struct Curl_easy *handle, pipeline = &conn->send_pipe; result = addHandleToPipeline(handle, pipeline); - - if(pipeline == &conn->send_pipe && sendhead != conn->send_pipe.head) { + if((conn->bundle->multiuse == BUNDLE_PIPELINING) && + (pipeline == &conn->send_pipe && sendhead != conn->send_pipe.head)) { /* this is a new one as head, expire it */ Curl_pipeline_leave_write(conn); /* not in use yet */ Curl_expire(conn->send_pipe.head->ptr, 0, EXPIRE_RUN_NOW); diff --git a/Utilities/cmcurl/lib/pop3.c b/Utilities/cmcurl/lib/pop3.c index 78f6afe..cd994f6 100644 --- a/Utilities/cmcurl/lib/pop3.c +++ b/Utilities/cmcurl/lib/pop3.c @@ -613,7 +613,6 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn, struct pop3_conn *pop3c = &conn->proto.pop3c; const char *line = data->state.buffer; size_t len = strlen(line); - size_t i; (void)instate; /* no use for this yet */ @@ -625,6 +624,7 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn, /* Does the server support APOP authentication? */ if(len >= 4 && line[len - 2] == '>') { /* Look for the APOP timestamp */ + size_t i; for(i = 3; i < len - 2; ++i) { if(line[i] == '<') { /* Calculate the length of the timestamp */ @@ -664,7 +664,6 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code, struct pop3_conn *pop3c = &conn->proto.pop3c; const char *line = data->state.buffer; size_t len = strlen(line); - size_t wordlen; (void)instate; /* no use for this yet */ @@ -689,6 +688,7 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code, /* Loop through the data line */ for(;;) { size_t llen; + size_t wordlen; unsigned int mechbit; while(len && diff --git a/Utilities/cmcurl/lib/progress.c b/Utilities/cmcurl/lib/progress.c index f59faa3..a94668d 100644 --- a/Utilities/cmcurl/lib/progress.c +++ b/Utilities/cmcurl/lib/progress.c @@ -35,22 +35,22 @@ byte) */ static void time2str(char *r, curl_off_t seconds) { - curl_off_t d, h, m, s; + curl_off_t h; if(seconds <= 0) { strcpy(r, "--:--:--"); return; } h = seconds / CURL_OFF_T_C(3600); if(h <= CURL_OFF_T_C(99)) { - m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60); - s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60)); + curl_off_t m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60); + curl_off_t s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60)); snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s); } else { /* this equals to more than 99 hours, switch to a more suitable output format to fit within the limits. */ - d = seconds / CURL_OFF_T_C(86400); + curl_off_t d = seconds / CURL_OFF_T_C(86400); h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600); if(d <= CURL_OFF_T_C(999)) snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T @@ -369,25 +369,10 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size) int Curl_pgrsUpdate(struct connectdata *conn) { struct curltime now; - int result; - char max5[6][10]; - curl_off_t dlpercen = 0; - curl_off_t ulpercen = 0; - curl_off_t total_percen = 0; - curl_off_t total_transfer; - curl_off_t total_expected_transfer; curl_off_t timespent; curl_off_t timespent_ms; /* milliseconds */ struct Curl_easy *data = conn->data; int nowindex = data->progress.speeder_c% CURR_TIME; - int checkindex; - int countindex; /* amount of seconds stored in the speeder array */ - char time_left[10]; - char time_total[10]; - char time_spent[10]; - curl_off_t ulestimate = 0; - curl_off_t dlestimate = 0; - curl_off_t total_estimate; bool shownow = FALSE; curl_off_t dl = data->progress.downloaded; curl_off_t ul = data->progress.uploaded; @@ -413,6 +398,7 @@ int Curl_pgrsUpdate(struct connectdata *conn) /* Calculations done at most once a second, unless end is reached */ if(data->progress.lastshow != now.tv_sec) { + int countindex; /* amount of seconds stored in the speeder array */ shownow = TRUE; data->progress.lastshow = now.tv_sec; @@ -438,6 +424,7 @@ int Curl_pgrsUpdate(struct connectdata *conn) /* first of all, we don't do this if there's no counted seconds yet */ if(countindex) { + int checkindex; timediff_t span_ms; /* Get the index position to compare with the 'nowindex' position. @@ -477,8 +464,21 @@ int Curl_pgrsUpdate(struct connectdata *conn) if(!(data->progress.flags & PGRS_HIDE)) { /* progress meter has not been shut off */ + char max5[6][10]; + curl_off_t dlpercen = 0; + curl_off_t ulpercen = 0; + curl_off_t total_percen = 0; + curl_off_t total_transfer; + curl_off_t total_expected_transfer; + char time_left[10]; + char time_total[10]; + char time_spent[10]; + curl_off_t ulestimate = 0; + curl_off_t dlestimate = 0; + curl_off_t total_estimate; if(data->set.fxferinfo) { + int result; /* There's a callback set, call that */ Curl_set_in_callback(data, true); result = data->set.fxferinfo(data->set.progress_client, @@ -492,6 +492,7 @@ int Curl_pgrsUpdate(struct connectdata *conn) return result; } if(data->set.fprogress) { + int result; /* The older deprecated callback is set, call that */ Curl_set_in_callback(data, true); result = data->set.fprogress(data->set.progress_client, diff --git a/Utilities/cmcurl/lib/progress.h b/Utilities/cmcurl/lib/progress.h index 2baa925..92dbcbd 100644 --- a/Utilities/cmcurl/lib/progress.h +++ b/Utilities/cmcurl/lib/progress.h @@ -56,23 +56,10 @@ timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize, struct curltime start, struct curltime now); -/* Don't show progress for sizes smaller than: */ -#define LEAST_SIZE_PROGRESS BUFSIZE - -#define PROGRESS_DOWNLOAD (1<<0) -#define PROGRESS_UPLOAD (1<<1) -#define PROGRESS_DOWN_AND_UP (PROGRESS_UPLOAD | PROGRESS_DOWNLOAD) - -#define PGRS_SHOW_DL (1<<0) -#define PGRS_SHOW_UL (1<<1) -#define PGRS_DONE_DL (1<<2) -#define PGRS_DONE_UL (1<<3) #define PGRS_HIDE (1<<4) #define PGRS_UL_SIZE_KNOWN (1<<5) #define PGRS_DL_SIZE_KNOWN (1<<6) - #define PGRS_HEADERS_OUT (1<<7) /* set when the headers have been written */ - #endif /* HEADER_CURL_PROGRESS_H */ diff --git a/Utilities/cmcurl/lib/psl.c b/Utilities/cmcurl/lib/psl.c new file mode 100644 index 0000000..568baff --- /dev/null +++ b/Utilities/cmcurl/lib/psl.c @@ -0,0 +1,111 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#include <curl/curl.h> + +#ifdef USE_LIBPSL + +#include "psl.h" +#include "share.h" + +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" +#include "curl_memory.h" +#include "memdebug.h" + +void Curl_psl_destroy(struct PslCache *pslcache) +{ + if(pslcache->psl) { + if(pslcache->dynamic) + psl_free((psl_ctx_t *) pslcache->psl); + pslcache->psl = NULL; + pslcache->dynamic = FALSE; + } +} + +static time_t now_seconds(void) +{ + struct curltime now = Curl_now(); + + return now.tv_sec; +} + +const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy) +{ + struct PslCache *pslcache = easy->psl; + const psl_ctx_t *psl; + time_t now; + + if(!pslcache) + return NULL; + + Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED); + now = now_seconds(); + if(!pslcache->psl || pslcache->expires <= now) { + /* Let a chance to other threads to do the job: avoids deadlock. */ + Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); + + /* Update cache: this needs an exclusive lock. */ + Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SINGLE); + + /* Recheck in case another thread did the job. */ + now = now_seconds(); + if(!pslcache->psl || pslcache->expires <= now) { + bool dynamic = FALSE; + time_t expires = TIME_T_MAX; + +#if defined(PSL_VERSION_NUMBER) && PSL_VERSION_NUMBER >= 0x001000 + psl = psl_latest(NULL); + dynamic = psl != NULL; + /* Take care of possible time computation overflow. */ + expires = now < TIME_T_MAX - PSL_TTL? now + PSL_TTL: TIME_T_MAX; + + /* Only get the built-in PSL if we do not already have the "latest". */ + if(!psl && !pslcache->dynamic) +#endif + + psl = psl_builtin(); + + if(psl) { + Curl_psl_destroy(pslcache); + pslcache->psl = psl; + pslcache->dynamic = dynamic; + pslcache->expires = expires; + } + } + Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */ + Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED); + } + psl = pslcache->psl; + if(!psl) + Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); + return psl; +} + +void Curl_psl_release(struct Curl_easy *easy) +{ + Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); +} + +#endif /* USE_LIBPSL */ diff --git a/Utilities/cmcurl/lib/psl.h b/Utilities/cmcurl/lib/psl.h new file mode 100644 index 0000000..e9f99d0 --- /dev/null +++ b/Utilities/cmcurl/lib/psl.h @@ -0,0 +1,47 @@ +#ifndef HEADER_PSL_H +#define HEADER_PSL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#ifdef USE_LIBPSL +#include <libpsl.h> + +#define PSL_TTL (72 * 3600) /* PSL time to live before a refresh. */ + +struct PslCache { + const psl_ctx_t *psl; /* The PSL. */ + time_t expires; /* Time this PSL life expires. */ + bool dynamic; /* PSL should be released when no longer needed. */ +}; + +const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy); +void Curl_psl_release(struct Curl_easy *easy); +void Curl_psl_destroy(struct PslCache *pslcache); + +#else + +#define Curl_psl_use(easy) NULL +#define Curl_psl_release(easy) +#define Curl_psl_destroy(pslcache) + +#endif /* USE_LIBPSL */ +#endif /* HEADER_PSL_H */ diff --git a/Utilities/cmcurl/lib/rand.c b/Utilities/cmcurl/lib/rand.c index 0769ed1..1dc2504 100644 --- a/Utilities/cmcurl/lib/rand.c +++ b/Utilities/cmcurl/lib/rand.c @@ -158,7 +158,7 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, DEBUGASSERT(num > 1); #ifdef __clang_analyzer__ - /* This silences a scan-build warning about accesssing this buffer with + /* This silences a scan-build warning about accessing this buffer with uninitialized memory. */ memset(buffer, 0, sizeof(buffer)); #endif diff --git a/Utilities/cmcurl/lib/rtsp.c b/Utilities/cmcurl/lib/rtsp.c index 41f3000..182ee29 100644 --- a/Utilities/cmcurl/lib/rtsp.c +++ b/Utilities/cmcurl/lib/rtsp.c @@ -218,8 +218,6 @@ static CURLcode rtsp_done(struct connectdata *conn, struct Curl_easy *data = conn->data; struct RTSP *rtsp = data->req.protop; CURLcode httpStatus; - long CSeq_sent; - long CSeq_recv; /* Bypass HTTP empty-reply checks on receive */ if(data->set.rtspreq == RTSPREQ_RECEIVE) @@ -229,8 +227,8 @@ static CURLcode rtsp_done(struct connectdata *conn, if(rtsp) { /* Check the sequence numbers */ - CSeq_sent = rtsp->CSeq_sent; - CSeq_recv = rtsp->CSeq_recv; + long CSeq_sent = rtsp->CSeq_sent; + long CSeq_recv = rtsp->CSeq_recv; if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) { failf(data, "The CSeq of this request %ld did not match the response %ld", diff --git a/Utilities/cmcurl/lib/security.c b/Utilities/cmcurl/lib/security.c index d171985..4034115 100644 --- a/Utilities/cmcurl/lib/security.c +++ b/Utilities/cmcurl/lib/security.c @@ -390,7 +390,7 @@ int Curl_sec_read_msg(struct connectdata *conn, char *buffer, if(conn->data->set.verbose) { buf[decoded_len] = '\n'; - Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1, conn); + Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1); } buf[decoded_len] = '\0'; @@ -488,7 +488,7 @@ static CURLcode choose_mech(struct connectdata *conn) tmp_allocation = realloc(conn->app_data, mech->size); if(tmp_allocation == NULL) { - failf(data, "Failed realloc of size %u", mech->size); + failf(data, "Failed realloc of size %zu", mech->size); mech = NULL; return CURLE_OUT_OF_MEMORY; } diff --git a/Utilities/cmcurl/lib/select.c b/Utilities/cmcurl/lib/select.c index 0406dd2..6e73890 100644 --- a/Utilities/cmcurl/lib/select.c +++ b/Utilities/cmcurl/lib/select.c @@ -80,7 +80,6 @@ int Curl_wait_ms(int timeout_ms) #endif struct curltime initial_tv; int pending_ms; - int error; #endif int r = 0; @@ -98,6 +97,7 @@ int Curl_wait_ms(int timeout_ms) pending_ms = timeout_ms; initial_tv = Curl_now(); do { + int error; #if defined(HAVE_POLL_FINE) r = poll(NULL, 0, pending_ms); #else @@ -160,7 +160,6 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ #endif struct curltime initial_tv = {0, 0}; int pending_ms = 0; - int error; int r; int ret; @@ -210,6 +209,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ } do { + int error; if(timeout_ms < 0) pending_ms = -1; else if(!timeout_ms) @@ -291,6 +291,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ ptimeout = (timeout_ms < 0) ? NULL : &pending_tv; do { + int error; if(timeout_ms > 0) { pending_tv.tv_sec = pending_ms / 1000; pending_tv.tv_usec = (pending_ms % 1000) * 1000; @@ -402,7 +403,6 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms) bool fds_none = TRUE; unsigned int i; int pending_ms = 0; - int error; int r; if(ufds) { @@ -431,6 +431,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms) #ifdef HAVE_POLL_FINE do { + int error; if(timeout_ms < 0) pending_ms = -1; else if(!timeout_ms) @@ -502,6 +503,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms) ptimeout = (timeout_ms < 0) ? NULL : &pending_tv; do { + int error; if(timeout_ms > 0) { pending_tv.tv_sec = pending_ms / 1000; pending_tv.tv_usec = (pending_ms % 1000) * 1000; diff --git a/Utilities/cmcurl/lib/sendf.c b/Utilities/cmcurl/lib/sendf.c index 27c0ccc..d3c10b3 100644 --- a/Utilities/cmcurl/lib/sendf.c +++ b/Utilities/cmcurl/lib/sendf.c @@ -240,7 +240,7 @@ void Curl_infof(struct Curl_easy *data, const char *fmt, ...) vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap); va_end(ap); len = strlen(print_buffer); - Curl_debug(data, CURLINFO_TEXT, print_buffer, len, NULL); + Curl_debug(data, CURLINFO_TEXT, print_buffer, len); } } @@ -265,7 +265,7 @@ void Curl_failf(struct Curl_easy *data, const char *fmt, ...) if(data->set.verbose) { error[len] = '\n'; error[++len] = '\0'; - Curl_debug(data, CURLINFO_TEXT, error, len, NULL); + Curl_debug(data, CURLINFO_TEXT, error, len); } va_end(ap); } @@ -300,7 +300,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn, break; if(data->set.verbose) - Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written, conn); + Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written); if((size_t)bytes_written != write_len) { /* if not all was written at once, we must advance the pointer, decrease @@ -762,8 +762,8 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */ } /* return 0 on success */ -static int showit(struct Curl_easy *data, curl_infotype type, - char *ptr, size_t size) +int Curl_debug(struct Curl_easy *data, curl_infotype type, + char *ptr, size_t size) { static const char s_infotype[CURLINFO_END][3] = { "* ", "< ", "> ", "{ ", "} ", "{ ", "} " }; @@ -834,41 +834,3 @@ static int showit(struct Curl_easy *data, curl_infotype type, #endif return rc; } - -int Curl_debug(struct Curl_easy *data, curl_infotype type, - char *ptr, size_t size, - struct connectdata *conn) -{ - int rc; - if(data->set.printhost && conn && conn->host.dispname) { - char buffer[160]; - const char *t = NULL; - const char *w = "Data"; - switch(type) { - case CURLINFO_HEADER_IN: - w = "Header"; - /* FALLTHROUGH */ - case CURLINFO_DATA_IN: - t = "from"; - break; - case CURLINFO_HEADER_OUT: - w = "Header"; - /* FALLTHROUGH */ - case CURLINFO_DATA_OUT: - t = "to"; - break; - default: - break; - } - - if(t) { - snprintf(buffer, sizeof(buffer), "[%s %s %s]", w, t, - conn->host.dispname); - rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer)); - if(rc) - return rc; - } - } - rc = showit(data, type, ptr, size); - return rc; -} diff --git a/Utilities/cmcurl/lib/sendf.h b/Utilities/cmcurl/lib/sendf.h index 7c9134d..7627fe6 100644 --- a/Utilities/cmcurl/lib/sendf.h +++ b/Utilities/cmcurl/lib/sendf.h @@ -84,9 +84,8 @@ CURLcode Curl_write_plain(struct connectdata *conn, ssize_t *written); /* the function used to output verbose information */ -int Curl_debug(struct Curl_easy *handle, curl_infotype type, - char *data, size_t size, - struct connectdata *conn); +int Curl_debug(struct Curl_easy *data, curl_infotype type, + char *ptr, size_t size); #endif /* HEADER_CURL_SENDF_H */ diff --git a/Utilities/cmcurl/lib/setopt.c b/Utilities/cmcurl/lib/setopt.c index af53ee3..5c5f4b3 100644 --- a/Utilities/cmcurl/lib/setopt.c +++ b/Utilities/cmcurl/lib/setopt.c @@ -142,6 +142,25 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_arg(param, char *)); break; + case CURLOPT_TLS13_CIPHERS: + if(Curl_ssl_tls13_ciphersuites()) { + /* set preferred list of TLS 1.3 cipher suites */ + result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_ORIG], + va_arg(param, char *)); + } + else + return CURLE_NOT_BUILT_IN; + break; + case CURLOPT_PROXY_TLS13_CIPHERS: + if(Curl_ssl_tls13_ciphersuites()) { + /* set preferred list of TLS 1.3 cipher suites for proxy */ + result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_PROXY], + va_arg(param, char *)); + } + else + return CURLE_NOT_BUILT_IN; + break; + case CURLOPT_RANDOM_FILE: /* * This is the path name to a file that contains random data to seed @@ -1584,14 +1603,19 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, * String that holds the SSL crypto engine. */ argptr = va_arg(param, char *); - if(argptr && argptr[0]) - result = Curl_ssl_set_engine(data, argptr); + if(argptr && argptr[0]) { + result = Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], argptr); + if(!result) { + result = Curl_ssl_set_engine(data, argptr); + } + } break; case CURLOPT_SSLENGINE_DEFAULT: /* * flag to set engine as default. */ + Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], NULL); result = Curl_ssl_set_engine_default(data); break; case CURLOPT_CRLF: @@ -1942,6 +1966,11 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, if(data->share->sslsession == data->state.session) data->state.session = NULL; +#ifdef USE_LIBPSL + if(data->psl == &data->share->psl) + data->psl = data->multi? &data->multi->psl: NULL; +#endif + data->share->dirty--; Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); @@ -1973,8 +2002,12 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions; data->state.session = data->share->sslsession; } - Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); +#ifdef USE_LIBPSL + if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL)) + data->psl = &data->share->psl; +#endif + Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); } /* check for host cache not needed, * it will be done by curl_easy_perform */ @@ -2562,6 +2595,10 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, case CURLOPT_DNS_SHUFFLE_ADDRESSES: data->set.dns_shuffle_addresses = (0 != va_arg(param, long)) ? TRUE:FALSE; break; + case CURLOPT_DISALLOW_USERNAME_IN_URL: + data->set.disallow_username_in_url = + (0 != va_arg(param, long)) ? TRUE : FALSE; + break; default: /* unknown tag and its companion, just ignore: */ result = CURLE_UNKNOWN_OPTION; diff --git a/Utilities/cmcurl/lib/sha256.c b/Utilities/cmcurl/lib/sha256.c index 55716c6..f9287af 100644 --- a/Utilities/cmcurl/lib/sha256.c +++ b/Utilities/cmcurl/lib/sha256.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Florin Petriuc, <petriuc.florin@gmail.com> + * Copyright (C) 1998 - 2018, Florin Petriuc, <petriuc.florin@gmail.com> * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -123,15 +123,11 @@ static const unsigned long K[64] = { #define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) #define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) #define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) -#ifndef MIN -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif /* compress 512-bits */ static int sha256_compress(struct sha256_state *md, unsigned char *buf) { - unsigned long S[8], W[64], t0, t1; - unsigned long t; + unsigned long S[8], W[64]; int i; /* copy state into S */ for(i = 0; i < 8; i++) { @@ -146,12 +142,13 @@ static int sha256_compress(struct sha256_state *md, W[i - 16]; } /* Compress */ -#define RND(a,b,c,d,e,f,g,h,i) \ - t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ - t1 = Sigma0(a) + Maj(a, b, c); \ - d += t0; \ +#define RND(a,b,c,d,e,f,g,h,i) \ + unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ + unsigned long t1 = Sigma0(a) + Maj(a, b, c); \ + d += t0; \ h = t0 + t1; for(i = 0; i < 64; ++i) { + unsigned long t; RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i); t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4]; S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t; @@ -200,7 +197,7 @@ static int SHA256_Update(struct sha256_state *md, inlen -= block_size; } else { - n = MIN(inlen, (block_size - md->curlen)); + n = CURLMIN(inlen, (block_size - md->curlen)); memcpy(md->buf + md->curlen, in, n); md->curlen += n; in += n; diff --git a/Utilities/cmcurl/lib/share.c b/Utilities/cmcurl/lib/share.c index 870b191..3d51086 100644 --- a/Utilities/cmcurl/lib/share.c +++ b/Utilities/cmcurl/lib/share.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,6 +25,7 @@ #include <curl/curl.h> #include "urldata.h" #include "share.h" +#include "psl.h" #include "vtls/vtls.h" #include "curl_memory.h" @@ -106,6 +107,12 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...) res = CURLSHE_NOMEM; break; + case CURL_LOCK_DATA_PSL: +#ifndef USE_LIBPSL + res = CURLSHE_NOT_BUILT_IN; +#endif + break; + default: res = CURLSHE_BAD_OPTION; } @@ -205,6 +212,8 @@ curl_share_cleanup(struct Curl_share *share) } #endif + Curl_psl_destroy(&share->psl); + if(share->unlockfunc) share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); free(share); diff --git a/Utilities/cmcurl/lib/share.h b/Utilities/cmcurl/lib/share.h index 4b13406..a7dea41 100644 --- a/Utilities/cmcurl/lib/share.h +++ b/Utilities/cmcurl/lib/share.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,6 +25,7 @@ #include "curl_setup.h" #include <curl/curl.h> #include "cookie.h" +#include "psl.h" #include "urldata.h" #include "conncache.h" @@ -49,6 +50,9 @@ struct Curl_share { #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) struct CookieInfo *cookies; #endif +#ifdef USE_LIBPSL + struct PslCache psl; +#endif struct curl_ssl_session *sslsession; size_t max_ssl_sessions; diff --git a/Utilities/cmcurl/lib/smb.c b/Utilities/cmcurl/lib/smb.c index 9ac6150..e4b18fc 100644 --- a/Utilities/cmcurl/lib/smb.c +++ b/Utilities/cmcurl/lib/smb.c @@ -59,6 +59,7 @@ static CURLcode smb_setup_connection(struct connectdata *conn); static CURLcode smb_connect(struct connectdata *conn, bool *done); static CURLcode smb_connection_state(struct connectdata *conn, bool *done); +static CURLcode smb_do(struct connectdata *conn, bool *done); static CURLcode smb_request_state(struct connectdata *conn, bool *done); static CURLcode smb_done(struct connectdata *conn, CURLcode status, bool premature); @@ -73,7 +74,7 @@ static CURLcode smb_parse_url_path(struct connectdata *conn); const struct Curl_handler Curl_handler_smb = { "SMB", /* scheme */ smb_setup_connection, /* setup_connection */ - ZERO_NULL, /* do_it */ + smb_do, /* do_it */ smb_done, /* done */ ZERO_NULL, /* do_more */ smb_connect, /* connect_it */ @@ -98,7 +99,7 @@ const struct Curl_handler Curl_handler_smb = { const struct Curl_handler Curl_handler_smbs = { "SMBS", /* scheme */ smb_setup_connection, /* setup_connection */ - ZERO_NULL, /* do_it */ + smb_do, /* do_it */ smb_done, /* done */ ZERO_NULL, /* do_more */ smb_connect, /* connect_it */ @@ -173,7 +174,6 @@ enum smb_req_state { /* SMB request data */ struct smb_request { enum smb_req_state state; - char *share; char *path; unsigned short tid; /* Even if we connect to the same tree as another */ unsigned short fid; /* request, the tid will be different */ @@ -182,7 +182,7 @@ struct smb_request { static void conn_state(struct connectdata *conn, enum smb_conn_state newstate) { - struct smb_conn *smb = &conn->proto.smbc; + struct smb_conn *smbc = &conn->proto.smbc; #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) /* For debug purposes */ static const char * const names[] = { @@ -194,12 +194,12 @@ static void conn_state(struct connectdata *conn, enum smb_conn_state newstate) /* LAST */ }; - if(smb->state != newstate) + if(smbc->state != newstate) infof(conn->data, "SMB conn %p state change from %s to %s\n", - (void *)smb, names[smb->state], names[newstate]); + (void *)smbc, names[smbc->state], names[newstate]); #endif - smb->state = newstate; + smbc->state = newstate; } static void request_state(struct connectdata *conn, @@ -228,6 +228,8 @@ static void request_state(struct connectdata *conn, req->state = newstate; } +/* this should setup things in the connection, not in the easy + handle */ static CURLcode smb_setup_connection(struct connectdata *conn) { struct smb_request *req; @@ -253,7 +255,6 @@ static CURLcode smb_connect(struct connectdata *conn, bool *done) return CURLE_LOGIN_DENIED; /* Initialize the connection state */ - memset(smbc, 0, sizeof(*smbc)); smbc->state = SMB_CONNECTING; smbc->recv_buf = malloc(MAX_MESSAGE_SIZE); if(!smbc->recv_buf) @@ -366,7 +367,7 @@ static CURLcode smb_send(struct connectdata *conn, ssize_t len, ssize_t bytes_written; CURLcode result; - result = Curl_write(conn, FIRSTSOCKET, conn->data->state.uploadbuffer, + result = Curl_write(conn, FIRSTSOCKET, conn->data->state.ulbuf, len, &bytes_written); if(result) return result; @@ -392,7 +393,7 @@ static CURLcode smb_flush(struct connectdata *conn) return CURLE_OK; result = Curl_write(conn, FIRSTSOCKET, - conn->data->state.uploadbuffer + smbc->sent, + conn->data->state.ulbuf + smbc->sent, len, &bytes_written); if(result) return result; @@ -408,9 +409,12 @@ static CURLcode smb_flush(struct connectdata *conn) static CURLcode smb_send_message(struct connectdata *conn, unsigned char cmd, const void *msg, size_t msg_len) { - smb_format_message(conn, (struct smb_header *)conn->data->state.uploadbuffer, + CURLcode result = Curl_get_upload_buffer(conn->data); + if(result) + return result; + smb_format_message(conn, (struct smb_header *)conn->data->state.ulbuf, cmd, msg_len); - memcpy(conn->data->state.uploadbuffer + sizeof(struct smb_header), + memcpy(conn->data->state.ulbuf + sizeof(struct smb_header), msg, msg_len); return smb_send(conn, sizeof(struct smb_header) + msg_len, 0); @@ -475,11 +479,11 @@ static CURLcode smb_send_setup(struct connectdata *conn) static CURLcode smb_send_tree_connect(struct connectdata *conn) { - struct smb_request *req = conn->data->req.protop; struct smb_tree_connect msg; + struct smb_conn *smbc = &conn->proto.smbc; char *p = msg.bytes; - size_t byte_count = strlen(conn->host.name) + strlen(req->share); + size_t byte_count = strlen(conn->host.name) + strlen(smbc->share); byte_count += strlen(SERVICENAME) + 5; /* 2 nulls and 3 backslashes */ if(byte_count > sizeof(msg.bytes)) return CURLE_FILESIZE_EXCEEDED; @@ -491,7 +495,7 @@ static CURLcode smb_send_tree_connect(struct connectdata *conn) MSGCAT("\\\\"); MSGCAT(conn->host.name); MSGCAT("\\"); - MSGCATNULL(req->share); + MSGCATNULL(smbc->share); MSGCATNULL(SERVICENAME); /* Match any type of service */ byte_count = p - msg.bytes; msg.byte_count = smb_swap16((unsigned short)byte_count); @@ -571,11 +575,15 @@ static CURLcode smb_send_read(struct connectdata *conn) static CURLcode smb_send_write(struct connectdata *conn) { - struct smb_write *msg = (struct smb_write *)conn->data->state.uploadbuffer; + struct smb_write *msg; struct smb_request *req = conn->data->req.protop; curl_off_t offset = conn->data->req.offset; - curl_off_t upload_size = conn->data->req.size - conn->data->req.bytecount; + CURLcode result = Curl_get_upload_buffer(conn->data); + if(result) + return result; + msg = (struct smb_write *)conn->data->state.ulbuf; + if(upload_size >= MAX_PAYLOAD_SIZE - 1) /* There is one byte of padding */ upload_size = MAX_PAYLOAD_SIZE - 1; @@ -602,9 +610,9 @@ static CURLcode smb_send_and_recv(struct connectdata *conn, void **msg) /* Check if there is data in the transfer buffer */ if(!smbc->send_size && smbc->upload_size) { - int nread = smbc->upload_size > UPLOAD_BUFSIZE ? UPLOAD_BUFSIZE : - (int) smbc->upload_size; - conn->data->req.upload_fromhere = conn->data->state.uploadbuffer; + size_t nread = smbc->upload_size > UPLOAD_BUFSIZE ? UPLOAD_BUFSIZE : + smbc->upload_size; + conn->data->req.upload_fromhere = conn->data->state.ulbuf; result = Curl_fillreadbuffer(conn, nread, &nread); if(result && result != CURLE_AGAIN) return result; @@ -910,55 +918,52 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done) static CURLcode smb_done(struct connectdata *conn, CURLcode status, bool premature) { - struct smb_request *req = conn->data->req.protop; - (void) premature; - - Curl_safefree(req->share); Curl_safefree(conn->data->req.protop); - return status; } static CURLcode smb_disconnect(struct connectdata *conn, bool dead) { struct smb_conn *smbc = &conn->proto.smbc; - struct smb_request *req = conn->data->req.protop; - (void) dead; - + Curl_safefree(smbc->share); Curl_safefree(smbc->domain); Curl_safefree(smbc->recv_buf); - - /* smb_done is not always called, so cleanup the request */ - if(req) { - Curl_safefree(req->share); - } - return CURLE_OK; } static int smb_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks) { - struct smb_conn *smbc = &conn->proto.smbc; - if(!numsocks) return GETSOCK_BLANK; socks[0] = conn->sock[FIRSTSOCKET]; + return GETSOCK_READSOCK(0) | GETSOCK_WRITESOCK(0); +} - if(smbc->send_size || smbc->upload_size) - return GETSOCK_WRITESOCK(0); +static CURLcode smb_do(struct connectdata *conn, bool *done) +{ + struct smb_conn *smbc = &conn->proto.smbc; + struct smb_request *req = conn->data->req.protop; - return GETSOCK_READSOCK(0); + *done = FALSE; + if(smbc->share) { + req->path = strchr(smbc->share, '\0'); + if(req->path) { + req->path++; + return CURLE_OK; + } + } + return CURLE_URL_MALFORMAT; } static CURLcode smb_parse_url_path(struct connectdata *conn) { CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; - struct smb_request *req = data->req.protop; + struct smb_conn *smbc = &conn->proto.smbc; char *path; char *slash; @@ -968,35 +973,29 @@ static CURLcode smb_parse_url_path(struct connectdata *conn) return result; /* Parse the path for the share */ - req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path); - if(!req->share) { - free(path); - + smbc->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path); + free(path); + if(!smbc->share) return CURLE_OUT_OF_MEMORY; - } - slash = strchr(req->share, '/'); + slash = strchr(smbc->share, '/'); if(!slash) - slash = strchr(req->share, '\\'); + slash = strchr(smbc->share, '\\'); /* The share must be present */ if(!slash) { - free(path); - + Curl_safefree(smbc->share); return CURLE_URL_MALFORMAT; } /* Parse the path for the file path converting any forward slashes into backslashes */ *slash++ = 0; - req->path = slash; + for(; *slash; slash++) { if(*slash == '/') *slash = '\\'; } - - free(path); - return CURLE_OK; } diff --git a/Utilities/cmcurl/lib/smb.h b/Utilities/cmcurl/lib/smb.h index c3ee7ae..9ce6b56 100644 --- a/Utilities/cmcurl/lib/smb.h +++ b/Utilities/cmcurl/lib/smb.h @@ -35,6 +35,7 @@ struct smb_conn { enum smb_conn_state state; char *user; char *domain; + char *share; unsigned char challenge[8]; unsigned int session_key; unsigned short uid; diff --git a/Utilities/cmcurl/lib/smtp.c b/Utilities/cmcurl/lib/smtp.c index 3f3b45a..ecf10a4 100644 --- a/Utilities/cmcurl/lib/smtp.c +++ b/Utilities/cmcurl/lib/smtp.c @@ -704,7 +704,6 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode, struct smtp_conn *smtpc = &conn->proto.smtpc; const char *line = data->state.buffer; size_t len = strlen(line); - size_t wordlen; (void)instate; /* no use for this yet */ @@ -739,6 +738,7 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode, /* Loop through the data line */ for(;;) { size_t llen; + size_t wordlen; unsigned int mechbit; while(len && @@ -1563,13 +1563,14 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread) if(!scratch || data->set.crlf) { oldscratch = scratch; - scratch = newscratch = malloc(2 * data->set.buffer_size); + scratch = newscratch = malloc(2 * UPLOAD_BUFSIZE); if(!newscratch) { failf(data, "Failed to alloc scratch buffer!"); return CURLE_OUT_OF_MEMORY; } } + DEBUGASSERT(UPLOAD_BUFSIZE >= nread); /* Have we already sent part of the EOB? */ eob_sent = smtp->eob; diff --git a/Utilities/cmcurl/lib/socks.c b/Utilities/cmcurl/lib/socks.c index ac4270e..81f3eda 100644 --- a/Utilities/cmcurl/lib/socks.c +++ b/Utilities/cmcurl/lib/socks.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -57,10 +57,9 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */ ssize_t nread; ssize_t allread = 0; int result; - timediff_t timeleft; *n = 0; for(;;) { - timeleft = Curl_timeleft(conn->data, NULL, TRUE); + timediff_t timeleft = Curl_timeleft(conn->data, NULL, TRUE); if(timeleft < 0) { /* we already got the timeout */ result = CURLE_OPERATION_TIMEDOUT; @@ -116,7 +115,6 @@ CURLcode Curl_SOCKS4(const char *proxy_user, #define SOCKS4REQLEN 262 unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user id */ - int result; CURLcode code; curl_socket_t sock = conn->sock[sockindex]; struct Curl_easy *data = conn->data; @@ -220,11 +218,12 @@ CURLcode Curl_SOCKS4(const char *proxy_user, * Make connection */ { + int result; ssize_t actualread; ssize_t written; ssize_t hostnamelen = 0; - int packetsize = 9 + - (int)strlen((char *)socksreq + 8); /* size including NUL */ + ssize_t packetsize = 9 + + strlen((char *)socksreq + 8); /* size including NUL */ /* If SOCKS4a, set special invalid IP address 0.0.0.x */ if(protocol4a) { @@ -617,11 +616,11 @@ CURLcode Curl_SOCKS5(const char *proxy_user, if(dns) hp = dns->addr; if(hp) { - int i; char buf[64]; Curl_printable_address(hp, buf, sizeof(buf)); if(hp->ai_family == AF_INET) { + int i; struct sockaddr_in *saddr_in; socksreq[len++] = 1; /* ATYP: IPv4 = 1 */ @@ -634,6 +633,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user, } #ifdef ENABLE_IPV6 else if(hp->ai_family == AF_INET6) { + int i; struct sockaddr_in6 *saddr_in6; socksreq[len++] = 4; /* ATYP: IPv6 = 4 */ diff --git a/Utilities/cmcurl/lib/splay.c b/Utilities/cmcurl/lib/splay.c index 69af446..c54a63b 100644 --- a/Utilities/cmcurl/lib/splay.c +++ b/Utilities/cmcurl/lib/splay.c @@ -41,7 +41,6 @@ struct Curl_tree *Curl_splay(struct curltime i, struct Curl_tree *t) { struct Curl_tree N, *l, *r, *y; - long comp; if(t == NULL) return t; @@ -49,7 +48,7 @@ struct Curl_tree *Curl_splay(struct curltime i, l = r = &N; for(;;) { - comp = compare(i, t->key); + long comp = compare(i, t->key); if(comp < 0) { if(t->smaller == NULL) break; diff --git a/Utilities/cmcurl/lib/ssh-libssh.c b/Utilities/cmcurl/lib/ssh-libssh.c index 34ef490..7d59089 100644 --- a/Utilities/cmcurl/lib/ssh-libssh.c +++ b/Utilities/cmcurl/lib/ssh-libssh.c @@ -204,11 +204,21 @@ static CURLcode sftp_error_to_CURLE(int err) return CURLE_SSH; } +#ifndef DEBUGBUILD +#define state(x,y) mystate(x,y) +#else +#define state(x,y) mystate(x,y, __LINE__) +#endif + /* * SSH State machine related code */ /* This is the ONLY way to change SSH state! */ -static void state(struct connectdata *conn, sshstate nowstate) +static void mystate(struct connectdata *conn, sshstate nowstate +#ifdef DEBUGBUILD + , int lineno +#endif + ) { struct ssh_conn *sshc = &conn->proto.sshc; #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) @@ -278,8 +288,9 @@ static void state(struct connectdata *conn, sshstate nowstate) if(sshc->state != nowstate) { - infof(conn->data, "SSH %p state change from %s to %s\n", - (void *) sshc, names[sshc->state], names[nowstate]); + infof(conn->data, "SSH %p state change from %s to %s (line %d)\n", + (void *) sshc, names[sshc->state], names[nowstate], + lineno); } #endif @@ -418,7 +429,7 @@ cleanup: } #define MOVE_TO_ERROR_STATE(_r) { \ - state(conn, SSH_SESSION_FREE); \ + state(conn, SSH_SESSION_DISCONNECT); \ sshc->actualcode = _r; \ rc = SSH_ERROR; \ break; \ @@ -486,7 +497,7 @@ restart: if(rc < 0) return SSH_ERROR; - /* fallthrough */ + /* FALLTHROUGH */ case 1: sshc->kbd_state = 1; @@ -561,7 +572,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) ssh_set_blocking(sshc->ssh_session, 0); state(conn, SSH_S_STARTUP); - /* fall-through */ + /* FALLTHROUGH */ case SSH_S_STARTUP: rc = ssh_connect(sshc->ssh_session); @@ -575,7 +586,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) state(conn, SSH_HOSTKEY); - /* fall-through */ + /* FALLTHROUGH */ case SSH_HOSTKEY: rc = myssh_is_known(conn); @@ -584,7 +595,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) } state(conn, SSH_AUTHLIST); - /* fall through */ + /* FALLTHROUGH */ case SSH_AUTHLIST:{ sshc->authed = FALSE; @@ -607,6 +618,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) sshc->auth_methods = ssh_userauth_list(sshc->ssh_session, NULL); if(sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) { state(conn, SSH_AUTH_PKEY_INIT); + infof(data, "Authentication using SSH public key file\n"); } else if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) { state(conn, SSH_AUTH_GSSAPI); @@ -651,6 +663,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) if(rc != SSH_OK) { failf(data, "Could not load private key file %s", data->set.str[STRING_SSH_PRIVATE_KEY]); + MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED); break; } @@ -659,8 +672,6 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) } else { - infof(data, "Authentication using SSH public key file\n"); - rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL, data->set.ssl.key_passwd); if(rc == SSH_AUTH_AGAIN) { @@ -748,7 +759,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED); } state(conn, SSH_AUTH_PASS); - /* fall through */ + /* FALLTHROUGH */ case SSH_AUTH_PASS: rc = ssh_userauth_password(sshc->ssh_session, NULL, conn->passwd); @@ -812,7 +823,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) break; } state(conn, SSH_SFTP_REALPATH); - /* fall through */ + /* FALLTHROUGH */ case SSH_SFTP_REALPATH: /* * Get the "home" directory @@ -1279,7 +1290,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) if(sshc->readdir_attrs) { sshc->readdir_filename = sshc->readdir_attrs->name; sshc->readdir_longentry = sshc->readdir_attrs->longname; - sshc->readdir_len = (int)strlen(sshc->readdir_filename); + sshc->readdir_len = strlen(sshc->readdir_filename); if(data->set.ftp_list_only) { char *tmpLine; @@ -1306,11 +1317,11 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) if(data->set.verbose) { Curl_debug(data, CURLINFO_DATA_OUT, (char *)sshc->readdir_filename, - sshc->readdir_len, conn); + sshc->readdir_len); } } else { - sshc->readdir_currLen = (int)strlen(sshc->readdir_longentry); + sshc->readdir_currLen = strlen(sshc->readdir_longentry); sshc->readdir_totalLen = 80 + sshc->readdir_currLen; sshc->readdir_line = calloc(sshc->readdir_totalLen, 1); if(!sshc->readdir_line) { @@ -1371,12 +1382,12 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) if(sshc->readdir_filename == NULL) sshc->readdir_len = 0; else - sshc->readdir_len = (int)strlen(sshc->readdir_tmp); + sshc->readdir_len = strlen(sshc->readdir_tmp); sshc->readdir_longentry = NULL; sshc->readdir_filename = sshc->readdir_tmp; } else { - sshc->readdir_len = (int)strlen(sshc->readdir_link_attrs->name); + sshc->readdir_len = strlen(sshc->readdir_link_attrs->name); sshc->readdir_filename = sshc->readdir_link_attrs->name; sshc->readdir_longentry = sshc->readdir_link_attrs->longname; } @@ -1408,7 +1419,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) sshc->readdir_longentry = NULL; state(conn, SSH_SFTP_READDIR_BOTTOM); - /* fall through */ + /* FALLTHROUGH */ case SSH_SFTP_READDIR_BOTTOM: sshc->readdir_currLen += snprintf(sshc->readdir_line + sshc->readdir_currLen, @@ -1423,7 +1434,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) /* output debug output if that is requested */ if(data->set.verbose) { Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line, - sshc->readdir_currLen, conn); + sshc->readdir_currLen); } data->req.bytecount += sshc->readdir_currLen; } @@ -1740,7 +1751,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT); } state(conn, SSH_SCP_DOWNLOAD); - /* fall through */ + /* FALLTHROUGH */ case SSH_SCP_DOWNLOAD:{ curl_off_t bytecount; @@ -1805,7 +1816,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) ssh_set_blocking(sshc->ssh_session, 0); state(conn, SSH_SESSION_DISCONNECT); - /* fall through */ + /* FALLTHROUGH */ case SSH_SESSION_DISCONNECT: /* during weird times when we've been prematurely aborted, the channel @@ -1822,7 +1833,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block) conn->data->state.most_recent_ftp_entrypath = NULL; state(conn, SSH_SESSION_FREE); - /* fall through */ + /* FALLTHROUGH */ case SSH_SESSION_FREE: if(sshc->ssh_session) { ssh_free(sshc->ssh_session); @@ -2379,7 +2390,8 @@ static CURLcode sftp_done(struct connectdata *conn, CURLcode status, /* Post quote commands are executed after the SFTP_CLOSE state to avoid errors that could happen due to open file handles during POSTQUOTE operation */ - if(!status && !premature && conn->data->set.postquote) { + if(!status && !premature && conn->data->set.postquote && + !conn->bits.retry) { sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT; state(conn, SSH_SFTP_CLOSE); } @@ -2437,7 +2449,7 @@ static ssize_t sftp_recv(struct connectdata *conn, int sockindex, return -1; } - /* fall-through */ + /* FALLTHROUGH */ case 1: conn->proto.sshc.sftp_recv_state = 1; @@ -2500,8 +2512,8 @@ static void sftp_quote(struct connectdata *conn) return; } if(data->set.verbose) { - Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4, conn); - Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn); + Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4); + Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); } /* this sends an FTP-like "header" to the header callback so that the current directory can be read very similar to how it is read when diff --git a/Utilities/cmcurl/lib/ssh.c b/Utilities/cmcurl/lib/ssh.c index bf7bd54..a4b2ca4 100644 --- a/Utilities/cmcurl/lib/ssh.c +++ b/Utilities/cmcurl/lib/ssh.c @@ -659,7 +659,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) libssh2_session_set_blocking(sshc->ssh_session, 0); state(conn, SSH_S_STARTUP); - /* fall-through */ + /* FALLTHROUGH */ case SSH_S_STARTUP: rc = libssh2_session_startup(sshc->ssh_session, (int)sock); @@ -675,7 +675,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) state(conn, SSH_HOSTKEY); - /* fall-through */ + /* FALLTHROUGH */ case SSH_HOSTKEY: /* * Before we authenticate we should check the hostkey's fingerprint @@ -1175,8 +1175,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) break; } if(data->set.verbose) { - Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4, conn); - Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn); + Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4); + Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp)); } /* this sends an FTP-like "header" to the header callback so that the current directory can be read very similar to how it is read when @@ -1933,17 +1933,17 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) break; case SSH_SFTP_READDIR: - sshc->readdir_len = libssh2_sftp_readdir_ex(sshc->sftp_handle, - sshc->readdir_filename, - PATH_MAX, - sshc->readdir_longentry, - PATH_MAX, - &sshc->readdir_attrs); - if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) { - rc = LIBSSH2_ERROR_EAGAIN; + rc = libssh2_sftp_readdir_ex(sshc->sftp_handle, + sshc->readdir_filename, + PATH_MAX, + sshc->readdir_longentry, + PATH_MAX, + &sshc->readdir_attrs); + if(rc == LIBSSH2_ERROR_EAGAIN) { break; } - if(sshc->readdir_len > 0) { + if(rc > 0) { + sshc->readdir_len = (size_t) rc; sshc->readdir_filename[sshc->readdir_len] = '\0'; if(data->set.ftp_list_only) { @@ -1970,11 +1970,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) /* output debug output if that is requested */ if(data->set.verbose) { Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_filename, - sshc->readdir_len, conn); + sshc->readdir_len); } } else { - sshc->readdir_currLen = (int)strlen(sshc->readdir_longentry); + sshc->readdir_currLen = strlen(sshc->readdir_longentry); sshc->readdir_totalLen = 80 + sshc->readdir_currLen; sshc->readdir_line = calloc(sshc->readdir_totalLen, 1); if(!sshc->readdir_line) { @@ -2008,13 +2008,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) break; } } - else if(sshc->readdir_len == 0) { + else if(rc == 0) { Curl_safefree(sshc->readdir_filename); Curl_safefree(sshc->readdir_longentry); state(conn, SSH_SFTP_READDIR_DONE); break; } - else if(sshc->readdir_len <= 0) { + else if(rc < 0) { err = sftp_libssh2_last_error(sshc->sftp_session); result = sftp_libssh2_error_to_CURLE(err); sshc->actualcode = result?result:CURLE_SSH; @@ -2029,16 +2029,16 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) break; case SSH_SFTP_READDIR_LINK: - sshc->readdir_len = + rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->readdir_linkPath, curlx_uztoui(strlen(sshc->readdir_linkPath)), sshc->readdir_filename, PATH_MAX, LIBSSH2_SFTP_READLINK); - if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) { - rc = LIBSSH2_ERROR_EAGAIN; + if(rc == LIBSSH2_ERROR_EAGAIN) { break; } + sshc->readdir_len = (size_t) rc; Curl_safefree(sshc->readdir_linkPath); /* get room for the filename and extra output */ @@ -2079,7 +2079,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block) /* output debug output if that is requested */ if(data->set.verbose) { Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line, - sshc->readdir_currLen, conn); + sshc->readdir_currLen); } data->req.bytecount += sshc->readdir_currLen; } @@ -3219,7 +3219,8 @@ static CURLcode sftp_done(struct connectdata *conn, CURLcode status, /* Post quote commands are executed after the SFTP_CLOSE state to avoid errors that could happen due to open file handles during POSTQUOTE operation */ - if(!status && !premature && conn->data->set.postquote) { + if(!status && !premature && conn->data->set.postquote && + !conn->bits.retry) { sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT; state(conn, SSH_SFTP_CLOSE); } diff --git a/Utilities/cmcurl/lib/ssh.h b/Utilities/cmcurl/lib/ssh.h index 1c13550..0620aac 100644 --- a/Utilities/cmcurl/lib/ssh.h +++ b/Utilities/cmcurl/lib/ssh.h @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -131,7 +131,7 @@ struct ssh_conn { quote command fails) */ char *homedir; /* when doing SFTP we figure out home dir in the connect phase */ - int readdir_len, readdir_totalLen, readdir_currLen; + size_t readdir_len, readdir_totalLen, readdir_currLen; char *readdir_line; char *readdir_linkPath; /* end of READDIR stuff */ diff --git a/Utilities/cmcurl/lib/strcase.h b/Utilities/cmcurl/lib/strcase.h index ea2abc8..6fee384 100644 --- a/Utilities/cmcurl/lib/strcase.h +++ b/Utilities/cmcurl/lib/strcase.h @@ -46,6 +46,5 @@ char Curl_raw_toupper(char in); #define checkprefix(a,b) curl_strnequal(a,b,strlen(a)) void Curl_strntoupper(char *dest, const char *src, size_t n); -char Curl_raw_toupper(char in); #endif /* HEADER_CURL_STRCASE_H */ diff --git a/Utilities/cmcurl/lib/system_win32.c b/Utilities/cmcurl/lib/system_win32.c index cfbbf32..6b8004e 100644 --- a/Utilities/cmcurl/lib/system_win32.c +++ b/Utilities/cmcurl/lib/system_win32.c @@ -26,6 +26,7 @@ #include <curl/curl.h> #include "system_win32.h" +#include "warnless.h" /* The last #include files should be: */ #include "curl_memory.h" @@ -134,8 +135,9 @@ bool Curl_verify_windows_version(const unsigned int majorVersion, break; case VERSION_LESS_THAN_EQUAL: - if(osver.dwMajorVersion <= majorVersion && - osver.dwMinorVersion <= minorVersion) + if(osver.dwMajorVersion < majorVersion || + (osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion <= minorVersion)) matched = TRUE; break; @@ -146,8 +148,9 @@ bool Curl_verify_windows_version(const unsigned int majorVersion, break; case VERSION_GREATER_THAN_EQUAL: - if(osver.dwMajorVersion >= majorVersion && - osver.dwMinorVersion >= minorVersion) + if(osver.dwMajorVersion > majorVersion || + (osver.dwMajorVersion == majorVersion && + osver.dwMinorVersion >= minorVersion)) matched = TRUE; break; @@ -278,7 +281,9 @@ HMODULE Curl_load_library(LPCTSTR filename) /* Attempt to find LoadLibraryEx() which is only available on Windows 2000 and above */ - pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX); + pLoadLibraryEx = + CURLX_FUNCTION_CAST(LOADLIBRARYEX_FN, + (GetProcAddress(hKernel32, LOADLIBARYEX))); /* Detect if there's already a path in the filename and load the library if there is. Note: Both back slashes and forward slashes have been supported diff --git a/Utilities/cmcurl/lib/telnet.c b/Utilities/cmcurl/lib/telnet.c index d71c8e0..05fe744 100644 --- a/Utilities/cmcurl/lib/telnet.c +++ b/Utilities/cmcurl/lib/telnet.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -52,10 +52,6 @@ #include "connect.h" #include "progress.h" #include "system_win32.h" - -#define TELOPTS -#define TELCMDS - #include "arpa_telnet.h" #include "select.h" #include "strcase.h" @@ -74,10 +70,10 @@ x->subend = x->subpointer; \ CURL_SB_CLEAR(x); \ } WHILE_FALSE -#define CURL_SB_ACCUM(x,c) \ - do { \ - if(x->subpointer < (x->subbuffer + sizeof x->subbuffer)) \ - *x->subpointer++ = (c); \ +#define CURL_SB_ACCUM(x,c) \ + do { \ + if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \ + *x->subpointer++ = (c); \ } WHILE_FALSE #define CURL_SB_GET(x) ((*x->subpointer++)&0xff) @@ -92,6 +88,7 @@ #endif #ifdef USE_WINSOCK +typedef WSAEVENT (WINAPI *WSOCK2_EVENT)(void); typedef FARPROC WSOCK2_FUNC; static CURLcode check_wsock2(struct Curl_easy *data); #endif @@ -109,8 +106,10 @@ static void printoption(struct Curl_easy *data, static void negotiate(struct connectdata *); static void send_negotiation(struct connectdata *, int cmd, int option); -static void set_local_option(struct connectdata *, int cmd, int option); -static void set_remote_option(struct connectdata *, int cmd, int option); +static void set_local_option(struct connectdata *conn, + int option, int newstate); +static void set_remote_option(struct connectdata *conn, + int option, int newstate); static void printsub(struct Curl_easy *data, int direction, unsigned char *pointer, @@ -311,9 +310,6 @@ static void negotiate(struct connectdata *conn) static void printoption(struct Curl_easy *data, const char *direction, int cmd, int option) { - const char *fmt; - const char *opt; - if(data->set.verbose) { if(cmd == CURL_IAC) { if(CURL_TELCMD_OK(option)) @@ -322,9 +318,12 @@ static void printoption(struct Curl_easy *data, infof(data, "%s IAC %d\n", direction, option); } else { - fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" : - (cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0; + const char *fmt = (cmd == CURL_WILL) ? "WILL" : + (cmd == CURL_WONT) ? "WONT" : + (cmd == CURL_DO) ? "DO" : + (cmd == CURL_DONT) ? "DONT" : 0; if(fmt) { + const char *opt; if(CURL_TELOPT_OK(option)) opt = CURL_TELOPT(option); else if(option == CURL_TELOPT_EXOPL) @@ -348,7 +347,6 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option) { unsigned char buf[3]; ssize_t bytes_written; - int err; struct Curl_easy *data = conn->data; buf[0] = CURL_IAC; @@ -357,7 +355,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option) bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3); if(bytes_written < 0) { - err = SOCKERRNO; + int err = SOCKERRNO; failf(data,"Sending data failed (%d)",err); } @@ -710,9 +708,8 @@ static void printsub(struct Curl_easy *data, unsigned char *pointer, /* where suboption data is */ size_t length) /* length of suboption data */ { - unsigned int i = 0; - if(data->set.verbose) { + unsigned int i = 0; if(direction) { infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT"); if(length >= 3) { @@ -764,7 +761,7 @@ static void printsub(struct Curl_easy *data, switch(pointer[0]) { case CURL_TELOPT_NAWS: if(length > 4) - infof(data, "Width: %hu ; Height: %hu", (pointer[1]<<8) | pointer[2], + infof(data, "Width: %d ; Height: %d", (pointer[1]<<8) | pointer[2], (pointer[3]<<8) | pointer[4]); break; default: @@ -928,7 +925,6 @@ static void suboption(struct connectdata *conn) unsigned char temp[2048]; ssize_t bytes_written; size_t len; - size_t tmplen; int err; char varname[128] = ""; char varval[128] = ""; @@ -968,7 +964,7 @@ static void suboption(struct connectdata *conn) len = 4; for(v = tn->telnet_vars; v; v = v->next) { - tmplen = (strlen(v->data) + 1); + size_t tmplen = (strlen(v->data) + 1); /* Add the variable only if it fits */ if(len + tmplen < (int)sizeof(temp)-6) { if(sscanf(v->data, "%127[^,],%127s", varname, varval)) { @@ -1017,7 +1013,7 @@ static void sendsuboption(struct connectdata *conn, int option) CURL_SB_ACCUM(tn, CURL_IAC); CURL_SB_ACCUM(tn, CURL_SB); CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS); - /* We must deal either with litte or big endian processors */ + /* We must deal either with little or big endian processors */ /* Window size must be sent according to the 'network order' */ x = htons(tn->subopt_wsx); y = htons(tn->subopt_wsy); @@ -1223,7 +1219,7 @@ CURLcode telrcv(struct connectdata *conn, static CURLcode send_telnet_data(struct connectdata *conn, char *buffer, ssize_t nread) { - ssize_t escapes, i, j, outlen; + ssize_t escapes, i, outlen; unsigned char *outbuf = NULL; CURLcode result = CURLE_OK; ssize_t bytes_written, total_written; @@ -1238,6 +1234,7 @@ static CURLcode send_telnet_data(struct connectdata *conn, if(outlen == nread) outbuf = (unsigned char *)buffer; else { + ssize_t j; outbuf = malloc(nread + escapes + 1); if(!outbuf) return CURLE_OUT_OF_MEMORY; @@ -1306,7 +1303,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) #ifdef USE_WINSOCK HMODULE wsock2; WSOCK2_FUNC close_event_func; - WSOCK2_FUNC create_event_func; + WSOCK2_EVENT create_event_func; WSOCK2_FUNC event_select_func; WSOCK2_FUNC enum_netevents_func; WSAEVENT event_handle; @@ -1315,7 +1312,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) HANDLE objs[2]; DWORD obj_count; DWORD wait_timeout; - DWORD waitret; DWORD readfile_read; int err; #else @@ -1361,7 +1357,9 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) } /* Grab a pointer to WSACreateEvent */ - create_event_func = GetProcAddress(wsock2, "WSACreateEvent"); + create_event_func = + CURLX_FUNCTION_CAST(WSOCK2_EVENT, + (GetProcAddress(wsock2, "WSACreateEvent"))); if(create_event_func == NULL) { failf(data, "failed to find WSACreateEvent function (%u)", GetLastError()); FreeLibrary(wsock2); @@ -1438,7 +1436,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) /* Keep on listening and act on events */ while(keepon) { const DWORD buf_size = (DWORD)data->set.buffer_size; - waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout); + DWORD waitret = WaitForMultipleObjects(obj_count, objs, + FALSE, wait_timeout); switch(waitret) { case WAIT_TIMEOUT: { @@ -1607,7 +1606,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) case 0: /* timeout */ pfd[0].revents = 0; pfd[1].revents = 0; - /* fall through */ + /* FALLTHROUGH */ default: /* read! */ if(pfd[0].revents & POLLIN) { /* read data from network */ diff --git a/Utilities/cmcurl/lib/tftp.c b/Utilities/cmcurl/lib/tftp.c index b32960f..e5bc80b 100644 --- a/Utilities/cmcurl/lib/tftp.c +++ b/Utilities/cmcurl/lib/tftp.c @@ -451,7 +451,6 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) ssize_t senddata; const char *mode = "octet"; char *filename; - char buf[64]; struct Curl_easy *data = state->conn->data; CURLcode result = CURLE_OK; @@ -504,6 +503,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event) /* optional addition of TFTP options */ if(!data->set.tftp_no_options) { + char buf[64]; /* add tsize option */ if(data->set.upload && (data->state.infilesize != -1)) snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T, @@ -710,10 +710,9 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) { struct Curl_easy *data = state->conn->data; ssize_t sbytes; - int rblock; CURLcode result = CURLE_OK; struct SingleRequest *k = &data->req; - int cb; /* Bytes currently read */ + size_t cb; /* Bytes currently read */ switch(event) { @@ -721,7 +720,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) case TFTP_EVENT_OACK: if(event == TFTP_EVENT_ACK) { /* Ack the packet */ - rblock = getrpacketblock(&state->rpacket); + int rblock = getrpacketblock(&state->rpacket); if(rblock != state->block && /* There's a bug in tftpd-hpa that causes it to send us an ack for @@ -766,7 +765,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) state->retries = 0; setpacketevent(&state->spacket, TFTP_EVENT_DATA); setpacketblock(&state->spacket, state->block); - if(state->block > 1 && state->sbytes < (int)state->blksize) { + if(state->block > 1 && state->sbytes < state->blksize) { state->state = TFTP_STATE_FIN; return CURLE_OK; } @@ -782,7 +781,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event) &cb); if(result) return result; - state->sbytes += cb; + state->sbytes += (int)cb; state->conn->data->req.upload_fromhere += cb; } while(state->sbytes < state->blksize && cb != 0); @@ -969,7 +968,7 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection) static CURLcode tftp_connect(struct connectdata *conn, bool *done) { tftp_state_data_t *state; - int blksize, rc; + int blksize; blksize = TFTP_BLKSIZE_DEFAULT; @@ -1028,8 +1027,8 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done) * assume uses the same IP version and thus hopefully this works for both * IPv4 and IPv6... */ - rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr, - conn->ip_addr->ai_addrlen); + int rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr, + conn->ip_addr->ai_addrlen); if(rc) { failf(conn->data, "bind() failed; %s", Curl_strerror(conn, SOCKERRNO)); @@ -1148,8 +1147,11 @@ static CURLcode tftp_receive_packet(struct connectdata *conn) case TFTP_EVENT_ERROR: { unsigned short error = getrpacketblock(&state->rpacket); + char *str = (char *)state->rpacket.data + 4; + size_t strn = state->rbytes - 4; state->error = (tftp_error_t)error; - infof(data, "%s\n", (const char *)state->rpacket.data + 4); + if(Curl_strnlen(str, strn) < strn) + infof(data, "TFTP error: %s\n", str); break; } case TFTP_EVENT_ACK: @@ -1221,7 +1223,6 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event) **********************************************************/ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done) { - int rc; tftp_event_t event; CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; @@ -1245,7 +1246,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done) } else { /* no timeouts to handle, check our socket */ - rc = SOCKET_READABLE(state->sockfd, 0); + int rc = SOCKET_READABLE(state->sockfd, 0); if(rc == -1) { /* bail out */ @@ -1368,7 +1369,6 @@ static CURLcode tftp_setup_connection(struct connectdata * conn) { struct Curl_easy *data = conn->data; char *type; - char command; conn->socktype = SOCK_DGRAM; /* UDP datagram based */ @@ -1380,6 +1380,7 @@ static CURLcode tftp_setup_connection(struct connectdata * conn) type = strstr(conn->host.rawalloc, ";mode="); if(type) { + char command; *type = 0; /* it was in the middle of the hostname */ command = Curl_raw_toupper(type[6]); diff --git a/Utilities/cmcurl/lib/transfer.c b/Utilities/cmcurl/lib/transfer.c index 131f2dc..7159d5c 100644 --- a/Utilities/cmcurl/lib/transfer.c +++ b/Utilities/cmcurl/lib/transfer.c @@ -106,15 +106,26 @@ char *Curl_checkheaders(const struct connectdata *conn, } #endif +CURLcode Curl_get_upload_buffer(struct Curl_easy *data) +{ + if(!data->state.ulbuf) { + data->state.ulbuf = malloc(data->set.upload_buffer_size); + if(!data->state.ulbuf) + return CURLE_OUT_OF_MEMORY; + } + return CURLE_OK; +} + /* * This function will call the read callback to fill our buffer with data * to upload. */ -CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) +CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, + size_t *nreadp) { struct Curl_easy *data = conn->data; - size_t buffersize = (size_t)bytes; - int nread; + size_t buffersize = bytes; + size_t nread; #ifdef CURL_DOES_CONVERSIONS bool sending_http_headers = FALSE; @@ -134,11 +145,9 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) data->req.upload_fromhere += (8 + 2); /* 32bit hex + CRLF */ } - /* this function returns a size_t, so we typecast to int to prevent warnings - with picky compilers */ Curl_set_in_callback(data, true); - nread = (int)data->state.fread_func(data->req.upload_fromhere, 1, - buffersize, data->state.in); + nread = data->state.fread_func(data->req.upload_fromhere, 1, + buffersize, data->state.in); Curl_set_in_callback(data, false); if(nread == CURL_READFUNC_ABORT) { @@ -167,7 +176,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) return CURLE_OK; /* nothing was read */ } - else if((size_t)nread > buffersize) { + else if(nread > buffersize) { /* the read function returned a too large value */ *nreadp = 0; failf(data, "read function returned funny value"); @@ -226,13 +235,13 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) #ifdef CURL_DOES_CONVERSIONS { CURLcode result; - int length; + size_t length; if(data->set.prefer_ascii) /* translate the protocol and data */ length = nread; else /* just translate the protocol portion */ - length = (int)strlen(hexbuffer); + length = strlen(hexbuffer); result = Curl_convert_to_network(data, data->req.upload_fromhere, length); /* Curl_convert_to_network calls failf if unsuccessful */ @@ -247,7 +256,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp) infof(data, "Signaling end of chunked upload via terminating chunk.\n"); } - nread += (int)strlen(endofline_native); /* for the added end of line */ + nread += strlen(endofline_native); /* for the added end of line */ } #ifdef CURL_DOES_CONVERSIONS else if((data->set.prefer_ascii) && (!sending_http_headers)) { @@ -444,7 +453,6 @@ static CURLcode readwrite_data(struct Curl_easy *data, CURLcode result = CURLE_OK; ssize_t nread; /* number of bytes read */ size_t excess = 0; /* excess bytes read */ - bool is_empty_data = FALSE; bool readmore = FALSE; /* used by RTP to signal for more data */ int maxloops = 100; @@ -454,6 +462,7 @@ static CURLcode readwrite_data(struct Curl_easy *data, /* This is where we loop until we have read everything there is to read or we get a CURLE_AGAIN */ do { + bool is_empty_data = FALSE; size_t buffersize = data->set.buffer_size; size_t bytestoread = buffersize; @@ -660,14 +669,14 @@ static CURLcode readwrite_data(struct Curl_easy *data, if(data->set.verbose) { if(k->badheader) { Curl_debug(data, CURLINFO_DATA_IN, data->state.headerbuff, - (size_t)k->hbuflen, conn); + (size_t)k->hbuflen); if(k->badheader == HEADER_PARTHEADER) Curl_debug(data, CURLINFO_DATA_IN, - k->str, (size_t)nread, conn); + k->str, (size_t)nread); } else Curl_debug(data, CURLINFO_DATA_IN, - k->str, (size_t)nread, conn); + k->str, (size_t)nread); } #ifndef CURL_DISABLE_HTTP @@ -797,7 +806,7 @@ static CURLcode readwrite_data(struct Curl_easy *data, nread); } } - else + else if(!k->ignorebody) result = Curl_unencode_write(conn, k->writer_stack, k->str, nread); } k->badheader = HEADER_NORMAL; /* taken care of now */ @@ -869,6 +878,26 @@ static CURLcode done_sending(struct connectdata *conn, return CURLE_OK; } +#ifdef WIN32 +#ifndef SIO_IDEAL_SEND_BACKLOG_QUERY +#define SIO_IDEAL_SEND_BACKLOG_QUERY 0x4004747B +#endif + +static void win_update_buffer_size(curl_socket_t sockfd) +{ + int result; + ULONG ideal; + DWORD ideallen; + result = WSAIoctl(sockfd, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0, + &ideal, sizeof(ideal), &ideallen, 0, 0); + if(result == 0) { + setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, + (const char *)&ideal, sizeof(ideal)); + } +} +#else +#define win_update_buffer_size(x) +#endif /* * Send data to upload to the server, when the socket is writable. @@ -894,13 +923,16 @@ static CURLcode readwrite_upload(struct Curl_easy *data, /* only read more data if there's no upload data already present in the upload buffer */ if(0 == k->upload_present) { + result = Curl_get_upload_buffer(data); + if(result) + return result; /* init the "upload from here" pointer */ - k->upload_fromhere = data->state.uploadbuffer; + k->upload_fromhere = data->state.ulbuf; if(!k->upload_done) { /* HTTP pollution, this should be written nicer to become more protocol agnostic. */ - int fillcount; + size_t fillcount; struct HTTP *http = k->protop; if((k->exp100 == EXP100_SENDING_REQUEST) && @@ -931,7 +963,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data, if(result) return result; - nread = (ssize_t)fillcount; + nread = fillcount; } else nread = 0; /* we're done uploading/reading */ @@ -959,7 +991,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data, (data->set.crlf))) { /* Do we need to allocate a scratch buffer? */ if(!data->state.scratch) { - data->state.scratch = malloc(2 * data->set.buffer_size); + data->state.scratch = malloc(2 * UPLOAD_BUFSIZE); if(!data->state.scratch) { failf(data, "Failed to alloc scratch buffer!"); @@ -1020,14 +1052,15 @@ static CURLcode readwrite_upload(struct Curl_easy *data, k->upload_fromhere, /* buffer pointer */ k->upload_present, /* buffer size */ &bytes_written); /* actually sent */ - if(result) return result; + win_update_buffer_size(conn->writesockfd); + if(data->set.verbose) /* show the data before we change the pointer upload_fromhere */ Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere, - (size_t)bytes_written, conn); + (size_t)bytes_written); k->writebytecount += bytes_written; @@ -1050,7 +1083,10 @@ static CURLcode readwrite_upload(struct Curl_easy *data, } else { /* we've uploaded that buffer now */ - k->upload_fromhere = data->state.uploadbuffer; + result = Curl_get_upload_buffer(data); + if(result) + return result; + k->upload_fromhere = data->state.ulbuf; k->upload_present = 0; /* no more bytes left */ if(k->upload_done) { @@ -1482,7 +1518,7 @@ static size_t strlen_url(const char *url, bool relative) switch(*ptr) { case '?': left = FALSE; - /* fall through */ + /* FALLTHROUGH */ default: if(urlchar_needs_escaping(*ptr)) newlen += 2; @@ -1527,7 +1563,7 @@ static void strcpy_url(char *output, const char *url, bool relative) switch(*iptr) { case '?': left = FALSE; - /* fall through */ + /* FALLTHROUGH */ default: if(urlchar_needs_escaping(*iptr)) { snprintf(optr, 4, "%%%02x", *iptr); diff --git a/Utilities/cmcurl/lib/transfer.h b/Utilities/cmcurl/lib/transfer.h index 9ba398d..9263e5b 100644 --- a/Utilities/cmcurl/lib/transfer.h +++ b/Utilities/cmcurl/lib/transfer.h @@ -51,9 +51,11 @@ int Curl_single_getsock(const struct connectdata *conn, curl_socket_t *socks, int numsocks); CURLcode Curl_readrewind(struct connectdata *conn); -CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp); +CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes, + size_t *nreadp); CURLcode Curl_retry_request(struct connectdata *conn, char **url); bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc); +CURLcode Curl_get_upload_buffer(struct Curl_easy *data); /* This sets up a forthcoming transfer */ void diff --git a/Utilities/cmcurl/lib/url.c b/Utilities/cmcurl/lib/url.c index 701f83a..f159008 100644 --- a/Utilities/cmcurl/lib/url.c +++ b/Utilities/cmcurl/lib/url.c @@ -127,7 +127,6 @@ bool curl_win32_idn_to_ascii(const char *in, char **out); static void conn_free(struct connectdata *conn); static void free_fixed_hostname(struct hostname *host); -static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke); static CURLcode parse_url_login(struct Curl_easy *data, struct connectdata *conn, char **userptr, char **passwdptr, @@ -368,11 +367,9 @@ CURLcode Curl_close(struct Curl_easy *data) Curl_safefree(data->state.buffer); Curl_safefree(data->state.headerbuff); - + Curl_safefree(data->state.ulbuf); Curl_flush_cookies(data, 1); - Curl_digest_cleanup(data); - Curl_safefree(data->info.contenttype); Curl_safefree(data->info.wouldredirect); @@ -535,6 +532,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data) set->expect_100_timeout = 1000L; /* Wait for a second by default. */ set->sep_headers = TRUE; /* separated header lists by default */ set->buffer_size = READBUFFER_SIZE; + set->upload_buffer_size = UPLOAD_BUFSIZE; set->happy_eyeballs_timeout = CURL_HET_DEFAULT; Curl_http2_init_userset(set); @@ -734,20 +732,23 @@ static void conn_free(struct connectdata *conn) * primary connection, like when freeing room in the connection cache or * killing of a dead old connection. * + * A connection needs an easy handle when closing down. We support this passed + * in separately since the connection to get closed here is often already + * disassociated from an easy handle. + * * This function MUST NOT reset state in the Curl_easy struct if that * isn't strictly bound to the life-time of *this* particular connection. * */ -CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection) +CURLcode Curl_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead_connection) { - struct Curl_easy *data; if(!conn) return CURLE_OK; /* this is closed and fine already */ - data = conn->data; if(!data) { - DEBUGF(fprintf(stderr, "DISCONNECT without easy handle, ignoring\n")); + DEBUGF(infof(data, "DISCONNECT without easy handle, ignoring\n")); return CURLE_OK; } @@ -755,13 +756,12 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection) * If this connection isn't marked to force-close, leave it open if there * are other users of it */ - if(!conn->bits.close && - (conn->send_pipe.size + conn->recv_pipe.size)) { - DEBUGF(infof(data, "Curl_disconnect, usecounter: %d\n", - conn->send_pipe.size + conn->recv_pipe.size)); + if(CONN_INUSE(conn) && !dead_connection) { + DEBUGF(infof(data, "Curl_disconnect when inuse: %zu\n", CONN_INUSE(conn))); return CURLE_OK; } + conn->data = data; if(conn->dns_entry != NULL) { Curl_resolv_unlock(data, conn->dns_entry); conn->dns_entry = NULL; @@ -787,16 +787,12 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection) free_fixed_hostname(&conn->http_proxy.host); free_fixed_hostname(&conn->socks_proxy.host); + DEBUGASSERT(conn->data == data); + /* this assumes that the pointer is still there after the connection was + detected from the cache */ Curl_ssl_close(conn, FIRSTSOCKET); - /* Indicate to all handles on the pipe that we're dead */ - if(Curl_pipeline_wanted(data->multi, CURLPIPE_ANY)) { - signalPipeClose(&conn->send_pipe, TRUE); - signalPipeClose(&conn->recv_pipe, TRUE); - } - conn_free(conn); - return CURLE_OK; } @@ -848,6 +844,7 @@ static int IsPipeliningPossible(const struct Curl_easy *handle, return avail; } +/* Returns non-zero if a handle was removed */ int Curl_removeHandleFromPipeline(struct Curl_easy *handle, struct curl_llist *pipeline) { @@ -884,6 +881,16 @@ static void Curl_printPipeline(struct curl_llist *pipeline) static struct Curl_easy* gethandleathead(struct curl_llist *pipeline) { struct curl_llist_element *curr = pipeline->head; +#ifdef DEBUGBUILD + { + struct curl_llist_element *p = pipeline->head; + while(p) { + struct Curl_easy *e = p->ptr; + DEBUGASSERT(GOOD_EASY_HANDLE(e)); + p = p->next; + } + } +#endif if(curr) { return (struct Curl_easy *) curr->ptr; } @@ -896,41 +903,22 @@ static struct Curl_easy* gethandleathead(struct curl_llist *pipeline) void Curl_getoff_all_pipelines(struct Curl_easy *data, struct connectdata *conn) { - bool recv_head = (conn->readchannel_inuse && - Curl_recvpipe_head(data, conn)); - bool send_head = (conn->writechannel_inuse && - Curl_sendpipe_head(data, conn)); - - if(Curl_removeHandleFromPipeline(data, &conn->recv_pipe) && recv_head) - Curl_pipeline_leave_read(conn); - if(Curl_removeHandleFromPipeline(data, &conn->send_pipe) && send_head) - Curl_pipeline_leave_write(conn); -} - -static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke) -{ - struct curl_llist_element *curr; - - if(!pipeline) + if(!conn->bundle) return; + if(conn->bundle->multiuse == BUNDLE_PIPELINING) { + bool recv_head = (conn->readchannel_inuse && + Curl_recvpipe_head(data, conn)); + bool send_head = (conn->writechannel_inuse && + Curl_sendpipe_head(data, conn)); - curr = pipeline->head; - while(curr) { - struct curl_llist_element *next = curr->next; - struct Curl_easy *data = (struct Curl_easy *) curr->ptr; - -#ifdef DEBUGBUILD /* debug-only code */ - if(data->magic != CURLEASY_MAGIC_NUMBER) { - /* MAJOR BADNESS */ - infof(data, "signalPipeClose() found BAAD easy handle\n"); - } -#endif - - if(pipe_broke) - data->state.pipe_broke = TRUE; - Curl_multi_handlePipeBreak(data); - Curl_llist_remove(pipeline, curr, NULL); - curr = next; + if(Curl_removeHandleFromPipeline(data, &conn->recv_pipe) && recv_head) + Curl_pipeline_leave_read(conn); + if(Curl_removeHandleFromPipeline(data, &conn->send_pipe) && send_head) + Curl_pipeline_leave_write(conn); + } + else { + (void)Curl_removeHandleFromPipeline(data, &conn->recv_pipe); + (void)Curl_removeHandleFromPipeline(data, &conn->send_pipe); } } @@ -959,12 +947,13 @@ static bool extract_if_dead(struct connectdata *conn, struct Curl_easy *data) { size_t pipeLen = conn->send_pipe.size + conn->recv_pipe.size; - if(!pipeLen && !conn->inuse) { + if(!pipeLen && !CONN_INUSE(conn)) { /* The check for a dead socket makes sense only if there are no handles in pipeline and the connection isn't already marked in use */ bool dead; + conn->data = data; if(conn->handler->connection_check) { /* The protocol has a special method for checking the state of the connection. Use it to check if the connection is dead. */ @@ -979,9 +968,9 @@ static bool extract_if_dead(struct connectdata *conn, } if(dead) { - conn->data = data; infof(data, "Connection %ld seems to be dead!\n", conn->connection_id); Curl_conncache_remove_conn(conn, FALSE); + conn->data = NULL; /* detach */ return TRUE; } } @@ -1025,7 +1014,7 @@ static void prune_dead_connections(struct Curl_easy *data) while(Curl_conncache_foreach(data, data->state.conn_cache, &prune, call_extract_if_dead)) { /* disconnect it */ - (void)Curl_disconnect(prune.extracted, /* dead_connection */TRUE); + (void)Curl_disconnect(data, prune.extracted, /* dead_connection */TRUE); } data->state.conn_cache->last_cleanup = now; } @@ -1139,7 +1128,7 @@ ConnectionExists(struct Curl_easy *data, if(extract_if_dead(check, data)) { /* disconnect it */ - (void)Curl_disconnect(check, /* dead_connection */TRUE); + (void)Curl_disconnect(data, check, /* dead_connection */TRUE); continue; } @@ -1267,12 +1256,12 @@ ConnectionExists(struct Curl_easy *data, } } - if(!canpipe && check->inuse) + if(!canpipe && CONN_INUSE(check)) /* this request can't be pipelined but the checked connection is already in use so we skip it */ continue; - if((check->inuse) && (check->data->multi != needle->data->multi)) + if(CONN_INUSE(check) && (check->data->multi != needle->data->multi)) /* this could be subject for pipeline/multiplex use, but only if they belong to the same multi handle */ continue; @@ -1464,7 +1453,7 @@ ConnectionExists(struct Curl_easy *data, if(chosen) { /* mark it as used before releasing the lock */ - chosen->inuse = TRUE; + chosen->data = data; /* own it! */ Curl_conncache_unlock(needle); *usethis = chosen; return TRUE; /* yes, we found one to use! */ @@ -1554,7 +1543,11 @@ int Curl_protocol_getsock(struct connectdata *conn, { if(conn->handler->proto_getsock) return conn->handler->proto_getsock(conn, socks, numsocks); - return GETSOCK_BLANK; + /* Backup getsock logic. Since there is a live socket in use, we must wait + for it or it will be removed from watching when the multi_socket API is + used. */ + socks[0] = conn->sock[FIRSTSOCKET]; + return GETSOCK_READSOCK(0) | GETSOCK_WRITESOCK(0); } int Curl_doing_getsock(struct connectdata *conn, @@ -1999,7 +1992,6 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, char *fragment; char *path = data->state.path; char *query; - int i; int rc; const char *protop = ""; CURLcode result; @@ -2051,6 +2043,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, ; /* do nothing */ } else { /* check for a scheme */ + int i; for(i = 0; i < 16 && data->change.url[i]; ++i) { if(data->change.url[i] == '/') break; @@ -2203,7 +2196,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, size_t s = strlen(slashbuf); protop = protobuf; if(s != 2) { - infof(data, "Unwillingly accepted illegal URL using %d slash%s!\n", + infof(data, "Unwillingly accepted illegal URL using %zu slash%s!\n", s, s>1?"es":""); if(data->change.url_alloc) @@ -2449,7 +2442,7 @@ static CURLcode setup_range(struct Curl_easy *data) free(s->range); if(s->resume_from) - s->range = aprintf("%" CURL_FORMAT_CURL_OFF_TU "-", s->resume_from); + s->range = aprintf("%" CURL_FORMAT_CURL_OFF_T "-", s->resume_from); else s->range = strdup(data->set.str[STRING_SET_RANGE]); @@ -2481,18 +2474,6 @@ static CURLcode setup_connection_internals(struct connectdata *conn) { const struct Curl_handler * p; CURLcode result; - struct Curl_easy *data = conn->data; - - /* in some case in the multi state-machine, we go back to the CONNECT state - and then a second (or third or...) call to this function will be made - without doing a DISCONNECT or DONE in between (since the connection is - yet in place) and therefore this function needs to first make sure - there's no lingering previous data allocated. */ - Curl_free_request_state(data); - - memset(&data->req, 0, sizeof(struct SingleRequest)); - data->req.maxdownload = -1; - conn->socktype = SOCK_STREAM; /* most of them are TCP streams */ /* Perform setup complement if some. */ @@ -2539,14 +2520,13 @@ static bool check_noproxy(const char *name, const char *no_proxy) * not be proxied, or an asterisk to override * all proxy variables) */ - size_t tok_start; - size_t tok_end; - const char *separator = ", "; - size_t no_proxy_len; - size_t namelen; - char *endptr; - if(no_proxy && no_proxy[0]) { + size_t tok_start; + size_t tok_end; + const char *separator = ", "; + size_t no_proxy_len; + size_t namelen; + char *endptr; if(strcasecompare("*", no_proxy)) { return TRUE; } @@ -3166,6 +3146,13 @@ static CURLcode parse_url_login(struct Curl_easy *data, if(userp) { char *newname; + if(data->set.disallow_username_in_url) { + failf(data, "Option DISALLOW_USERNAME_IN_URL is set " + "and url contains username."); + result = CURLE_LOGIN_DENIED; + goto out; + } + /* We have a user in the URL */ conn->bits.userpwd_in_url = TRUE; conn->bits.user_passwd = TRUE; /* enable user+password */ @@ -3982,6 +3969,7 @@ static void reuse_conn(struct connectdata *old_conn, Curl_safefree(old_conn->user); Curl_safefree(old_conn->passwd); + Curl_safefree(old_conn->options); Curl_safefree(old_conn->http_proxy.user); Curl_safefree(old_conn->socks_proxy.user); Curl_safefree(old_conn->http_proxy.passwd); @@ -4297,7 +4285,9 @@ static CURLcode create_conn(struct Curl_easy *data, conn->data = data; conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */ - Curl_conncache_add_conn(data->state.conn_cache, conn); + result = Curl_conncache_add_conn(data->state.conn_cache, conn); + if(result) + goto out; /* * Setup whatever necessary for a resumed transfer @@ -4343,6 +4333,10 @@ static CURLcode create_conn(struct Curl_easy *data, data->set.str[STRING_SSL_CIPHER_LIST_ORIG]; data->set.proxy_ssl.primary.cipher_list = data->set.str[STRING_SSL_CIPHER_LIST_PROXY]; + data->set.ssl.primary.cipher_list13 = + data->set.str[STRING_SSL_CIPHER13_LIST_ORIG]; + data->set.proxy_ssl.primary.cipher_list13 = + data->set.str[STRING_SSL_CIPHER13_LIST_PROXY]; data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG]; data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY]; @@ -4468,13 +4462,11 @@ static CURLcode create_conn(struct Curl_easy *data, conn_candidate = Curl_conncache_extract_bundle(data, bundle); Curl_conncache_unlock(conn); - if(conn_candidate) { - /* Set the connection's owner correctly, then kill it */ - conn_candidate->data = data; - (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); - } + if(conn_candidate) + (void)Curl_disconnect(data, conn_candidate, + /* dead_connection */ FALSE); else { - infof(data, "No more connections allowed to host: %d\n", + infof(data, "No more connections allowed to host: %zu\n", max_host_connections); connections_available = FALSE; } @@ -4491,12 +4483,9 @@ static CURLcode create_conn(struct Curl_easy *data, /* The cache is full. Let's see if we can kill a connection. */ conn_candidate = Curl_conncache_extract_oldest(data); - - if(conn_candidate) { - /* Set the connection's owner correctly, then kill it */ - conn_candidate->data = data; - (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE); - } + if(conn_candidate) + (void)Curl_disconnect(data, conn_candidate, + /* dead_connection */ FALSE); else { infof(data, "No connections available in cache\n"); connections_available = FALSE; @@ -4513,14 +4502,13 @@ static CURLcode create_conn(struct Curl_easy *data, goto out; } else { - /* Mark the connection as used, before we add it */ - conn->inuse = TRUE; - /* * This is a brand new connection, so let's store it in the connection * cache of ours! */ - Curl_conncache_add_conn(data->state.conn_cache, conn); + result = Curl_conncache_add_conn(data->state.conn_cache, conn); + if(result) + goto out; } #if defined(USE_NTLM) @@ -4656,12 +4644,16 @@ CURLcode Curl_connect(struct Curl_easy *data, *asyncp = FALSE; /* assume synchronous resolves by default */ + /* init the single-transfer specific data */ + Curl_free_request_state(data); + memset(&data->req, 0, sizeof(struct SingleRequest)); + data->req.maxdownload = -1; + /* call the stuff that needs to be called */ result = create_conn(data, in_connect, asyncp); if(!result) { - /* no error */ - if((*in_connect)->send_pipe.size || (*in_connect)->recv_pipe.size) + if(CONN_INUSE(*in_connect)) /* pipelining */ *protocol_done = TRUE; else if(!*asyncp) { @@ -4676,12 +4668,11 @@ CURLcode Curl_connect(struct Curl_easy *data, *in_connect = NULL; return result; } - - if(result && *in_connect) { - /* We're not allowed to return failure with memory left allocated - in the connectdata struct, free those here */ - Curl_disconnect(*in_connect, FALSE); /* close the connection */ - *in_connect = NULL; /* return a NULL */ + else if(result && *in_connect) { + /* We're not allowed to return failure with memory left allocated in the + connectdata struct, free those here */ + Curl_disconnect(data, *in_connect, TRUE); + *in_connect = NULL; /* return a NULL */ } return result; @@ -4701,16 +4692,18 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn) { struct SingleRequest *k = &data->req; - conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to - use */ + if(conn) { + conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to + use */ + /* if the protocol used doesn't support wildcards, switch it off */ + if(data->state.wildcardmatch && + !(conn->handler->flags & PROTOPT_WILDCARD)) + data->state.wildcardmatch = FALSE; + } data->state.done = FALSE; /* *_done() is not called yet */ data->state.expect100header = FALSE; - /* if the protocol used doesn't support wildcards, switch it off */ - if(data->state.wildcardmatch && - !(conn->handler->flags & PROTOPT_WILDCARD)) - data->state.wildcardmatch = FALSE; if(data->set.opt_no_body) /* in HTTP lingo, no body means using the HEAD request... */ diff --git a/Utilities/cmcurl/lib/url.h b/Utilities/cmcurl/lib/url.h index a70bd54..ef3ebf0 100644 --- a/Utilities/cmcurl/lib/url.h +++ b/Utilities/cmcurl/lib/url.h @@ -39,7 +39,8 @@ void Curl_freeset(struct Curl_easy * data); CURLcode Curl_close(struct Curl_easy *data); /* opposite of curl_open() */ CURLcode Curl_connect(struct Curl_easy *, struct connectdata **, bool *async, bool *protocol_connect); -CURLcode Curl_disconnect(struct connectdata *, bool dead_connection); +CURLcode Curl_disconnect(struct Curl_easy *data, + struct connectdata *, bool dead_connection); CURLcode Curl_protocol_connect(struct connectdata *conn, bool *done); CURLcode Curl_protocol_connecting(struct connectdata *conn, bool *done); CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done); diff --git a/Utilities/cmcurl/lib/urldata.h b/Utilities/cmcurl/lib/urldata.h index 7fae00f..67db3b2 100644 --- a/Utilities/cmcurl/lib/urldata.h +++ b/Utilities/cmcurl/lib/urldata.h @@ -80,6 +80,7 @@ #define RESP_TIMEOUT (1800*1000) #include "cookie.h" +#include "psl.h" #include "formdata.h" #ifdef HAVE_NETINET_IN_H @@ -142,8 +143,13 @@ typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */ #endif /* HAVE_LIBSSH2_H */ /* The upload buffer size, should not be smaller than CURL_MAX_WRITE_SIZE, as - it needs to hold a full buffer as could be sent in a write callback */ -#define UPLOAD_BUFSIZE CURL_MAX_WRITE_SIZE + it needs to hold a full buffer as could be sent in a write callback. + + The size was 16KB for many years but was bumped to 64KB because it makes + libcurl able to do significantly faster uploads in some circumstances. Even + larger buffers can help further, but this is deemed a fair memory/speed + compromise. */ +#define UPLOAD_BUFSIZE 65536 /* The "master buffer" is for HTTP pipelining */ #define MASTERBUF_SIZE 16384 @@ -156,11 +162,6 @@ typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */ #define GOOD_EASY_HANDLE(x) \ ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) -/* Some convenience macros to get the larger/smaller value out of two given. - We prefix with CURL to prevent name collisions. */ -#define CURLMAX(x,y) ((x)>(y)?(x):(y)) -#define CURLMIN(x,y) ((x)<(y)?(x):(y)) - #ifdef HAVE_GSSAPI /* Types needed for krb5-ftp connections */ struct krb5buffer { @@ -226,6 +227,7 @@ struct ssl_primary_config { char *random_file; /* path to file containing "random" data */ char *egdsocket; /* path to file containing the EGD daemon socket */ char *cipher_list; /* list of ciphers to use */ + char *cipher_list13; /* list of TLS 1.3 cipher suites to use */ }; struct ssl_config_data { @@ -779,11 +781,12 @@ struct connectdata { curl_closesocket_callback fclosesocket; /* function closing the socket(s) */ void *closesocket_client; - bool inuse; /* This is a marker for the connection cache logic. If this is - TRUE this handle is being used by one or more easy handles - and can only used by any other easy handle without careful - consideration (== only for pipelining/multiplexing) and it - cannot be used by another multi handle! */ + /* This is used by the connection cache logic. If this returns TRUE, this + handle is being used by one or more easy handles and can only used by any + other easy handle without careful consideration (== only for + pipelining/multiplexing) and it cannot be used by another multi + handle! */ +#define CONN_INUSE(c) ((c)->send_pipe.size + (c)->recv_pipe.size) /**** Fields set when inited and not modified again */ long connection_id; /* Contains a unique number to make it easier to @@ -1222,7 +1225,7 @@ struct UrlState { size_t headersize; /* size of the allocation */ char *buffer; /* download buffer */ - char uploadbuffer[UPLOAD_BUFSIZE + 1]; /* upload buffer */ + char *ulbuf; /* alloced upload buffer or NULL */ curl_off_t current_speed; /* the ProgressShow() function sets this, bytes / second */ bool this_is_a_follow; /* this is a followed Location: request */ @@ -1265,7 +1268,7 @@ struct UrlState { void *resolver; /* resolver state, if it is used in the URL state - ares_channel f.e. */ -#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) +#if defined(USE_OPENSSL) /* void instead of ENGINE to avoid bleeding OpenSSL into this header */ void *engine; #endif /* USE_OPENSSL */ @@ -1284,9 +1287,6 @@ struct UrlState { involved in this request */ bool expect100header; /* TRUE if we added Expect: 100-continue */ - bool pipe_broke; /* TRUE if the connection we were pipelined on broke - and we need to restart from the beginning */ - #if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \ !defined(__SYMBIAN32__) /* do FTP line-end conversions on most platforms */ @@ -1346,7 +1346,7 @@ struct DynamicStatic { char *url; /* work URL, copied from UserDefined */ bool url_alloc; /* URL string is malloc()'ed */ char *referer; /* referer string */ - bool referer_alloc; /* referer sting is malloc()ed */ + bool referer_alloc; /* referer string is malloc()ed */ struct curl_slist *cookielist; /* list of cookie files set by curl_easy_setopt(COOKIEFILE) calls */ struct curl_slist *resolve; /* set to point to the set.resolve list when @@ -1400,6 +1400,8 @@ enum dupstring { STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */ STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */ STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */ + STRING_SSL_CIPHER13_LIST_ORIG, /* list of TLS 1.3 ciphers to use */ + STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */ STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */ STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */ STRING_USERAGENT, /* User-Agent string */ @@ -1407,6 +1409,7 @@ enum dupstring { STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */ STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */ STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */ + STRING_SSL_ENGINE, /* name of ssl engine */ STRING_USERNAME, /* <username>, if used */ STRING_PASSWORD, /* <password>, if used */ STRING_OPTIONS, /* <options>, if used */ @@ -1559,6 +1562,8 @@ struct UserDefined { curl_proxytype proxytype; /* what kind of proxy that is in use */ long dns_cache_timeout; /* DNS cache timeout */ long buffer_size; /* size of receive buffer to use */ + long upload_buffer_size; /* size of upload buffer to use, + keep it >= CURL_MAX_WRITE_SIZE */ void *private_data; /* application-private data */ struct curl_slist *http200aliases; /* linked list of aliases for http200 */ @@ -1581,8 +1586,6 @@ struct UserDefined { /* Here follows boolean settings that define how to behave during this session. They are STATIC, set by libcurl users or at least initially and they don't change during operations. */ - - bool printhost; /* printing host name in debug info */ bool get_filetime; /* get the time and get of the remote file */ bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */ bool prefer_ascii; /* ASCII rather than binary */ @@ -1676,7 +1679,7 @@ struct UserDefined { bool stream_depends_e; /* set or don't set the Exclusive bit */ int stream_weight; - bool haproxyprotocol; /* whether to send HAProxy PROXY protocol header */ + bool haproxyprotocol; /* whether to send HAProxy PROXY protocol v1 header */ struct Curl_http2_dep *stream_dependents; @@ -1685,6 +1688,7 @@ struct UserDefined { curl_resolver_start_callback resolver_start; /* optional callback called before resolver start */ void *resolver_start_client; /* pointer to pass to resolver start callback */ + bool disallow_username_in_url; /* disallow username in url */ }; struct Names { @@ -1736,6 +1740,9 @@ struct Curl_easy { struct to which this "belongs" when used by the easy interface */ struct Curl_share *share; /* Share, handles global variable mutexing */ +#ifdef USE_LIBPSL + struct PslCache *psl; /* The associated PSL cache. */ +#endif struct SingleRequest req; /* Request-specific data */ struct UserDefined set; /* values set by the libcurl user */ struct DynamicStatic change; /* possibly modified userdefined data */ diff --git a/Utilities/cmcurl/lib/vauth/digest.c b/Utilities/cmcurl/lib/vauth/digest.c index 131d9da..cc6f169 100644 --- a/Utilities/cmcurl/lib/vauth/digest.c +++ b/Utilities/cmcurl/lib/vauth/digest.c @@ -158,7 +158,7 @@ static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */ /* Perform quoted-string escaping as described in RFC2616 and its errata */ static char *auth_digest_string_quoted(const char *source) { - char *dest, *d; + char *dest; const char *s = source; size_t n = 1; /* null terminator */ @@ -173,8 +173,8 @@ static char *auth_digest_string_quoted(const char *source) dest = malloc(n); if(dest) { + char *d = dest; s = source; - d = dest; while(*s) { if(*s == '"' || *s == '\\') { *d++ = '\\'; @@ -696,7 +696,6 @@ static CURLcode _Curl_auth_create_digest_http_message( unsigned char ha1[65]; /* 64 digits and 1 zero byte */ unsigned char ha2[65]; /* 64 digits and 1 zero byte */ char userh[65]; - char cnoncebuf[33]; char *cnonce = NULL; size_t cnonce_sz = 0; char *userp_quoted; @@ -707,6 +706,7 @@ static CURLcode _Curl_auth_create_digest_http_message( digest->nc = 1; if(!digest->cnonce) { + char cnoncebuf[33]; result = Curl_rand_hex(data, (unsigned char *)cnoncebuf, sizeof(cnoncebuf)); if(result) diff --git a/Utilities/cmcurl/lib/version.c b/Utilities/cmcurl/lib/version.c index 5b0d05a..05c2cd8 100644 --- a/Utilities/cmcurl/lib/version.c +++ b/Utilities/cmcurl/lib/version.c @@ -445,7 +445,7 @@ curl_version_info_data *curl_version_info(CURLversion stamp) #ifdef HAVE_BROTLI version_info.brotli_ver_num = BrotliDecoderVersion(); - brotli_version(brotli_buffer, sizeof brotli_buffer); + brotli_version(brotli_buffer, sizeof(brotli_buffer)); version_info.brotli_version = brotli_buffer; #endif diff --git a/Utilities/cmcurl/lib/vtls/axtls.c b/Utilities/cmcurl/lib/vtls/axtls.c index 5ed898b..b262392 100644 --- a/Utilities/cmcurl/lib/vtls/axtls.c +++ b/Utilities/cmcurl/lib/vtls/axtls.c @@ -29,6 +29,11 @@ #include "curl_setup.h" #ifdef USE_AXTLS + +#error axTLS support has been disabled in curl due to doubts about quality, +#error user dedication and a lack of use/testing. We urge users to consider +#error using a more established TLS backend instead. + #include <axTLS/config.h> #include <axTLS/ssl.h> #include "axtls.h" diff --git a/Utilities/cmcurl/lib/vtls/cyassl.c b/Utilities/cmcurl/lib/vtls/cyassl.c index 20ce460..e10398a 100644 --- a/Utilities/cmcurl/lib/vtls/cyassl.c +++ b/Utilities/cmcurl/lib/vtls/cyassl.c @@ -569,7 +569,7 @@ cyassl_connect_step2(struct connectdata *conn, return CURLE_SSL_PINNEDPUBKEYNOTMATCH; } - memset(&x509_parsed, 0, sizeof x509_parsed); + memset(&x509_parsed, 0, sizeof(x509_parsed)); if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len)) return CURLE_SSL_PINNEDPUBKEYNOTMATCH; @@ -968,6 +968,8 @@ static CURLcode Curl_cyassl_random(struct Curl_easy *data, return CURLE_FAILED_INIT; if(RNG_GenerateBlock(&rng, entropy, (unsigned)length)) return CURLE_FAILED_INIT; + if(FreeRng(&rng)) + return CURLE_FAILED_INIT; return CURLE_OK; } diff --git a/Utilities/cmcurl/lib/vtls/darwinssl.c b/Utilities/cmcurl/lib/vtls/darwinssl.c index 45fe49d..1aea0dc 100644 --- a/Utilities/cmcurl/lib/vtls/darwinssl.c +++ b/Utilities/cmcurl/lib/vtls/darwinssl.c @@ -1252,14 +1252,13 @@ static CURLcode darwinssl_version_from_curl(SSLProtocol *darwinver, return CURLE_OK; case CURL_SSLVERSION_TLSv1_3: /* TLS 1.3 support first appeared in iOS 11 and macOS 10.13 */ -#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 - /* We can assume __builtin_available() will always work in the - 10.13/11.0 SDK: */ +#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1 if(__builtin_available(macOS 10.13, iOS 11.0, *)) { *darwinver = kTLSProtocol13; return CURLE_OK; } -#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */ +#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && + HAVE_BUILTIN_AVAILABLE == 1 */ break; } return CURLE_SSL_CONNECT_ERROR; @@ -1278,7 +1277,7 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex) /* macOS 10.5-10.7 supported TLS 1.0 only. macOS 10.8 and later, and iOS 5 and later, added TLS 1.1 and 1.2. macOS 10.13 and later, and iOS 11 and later, added TLS 1.3. */ -#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 +#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1 if(__builtin_available(macOS 10.13, iOS 11.0, *)) { max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_3; } @@ -1287,7 +1286,8 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex) } #else max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_2; -#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */ +#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && + HAVE_BUILTIN_AVAILABLE == 1 */ switch(ssl_version) { case CURL_SSLVERSION_DEFAULT: @@ -1430,7 +1430,7 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, case CURL_SSLVERSION_DEFAULT: case CURL_SSLVERSION_TLSv1: (void)SSLSetProtocolVersionMin(BACKEND->ssl_ctx, kTLSProtocol1); -#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 +#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1 if(__builtin_available(macOS 10.13, iOS 11.0, *)) { (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol13); } @@ -1439,7 +1439,8 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, } #else (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol12); -#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */ +#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && + HAVE_BUILTIN_AVAILABLE == 1 */ break; case CURL_SSLVERSION_TLSv1_0: case CURL_SSLVERSION_TLSv1_1: @@ -1572,6 +1573,35 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, } #endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */ +#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1 + if(conn->bits.tls_enable_alpn) { + if(__builtin_available(macOS 10.13.4, iOS 11, *)) { + CFMutableArrayRef alpnArr = CFArrayCreateMutable(NULL, 0, + &kCFTypeArrayCallBacks); + +#ifdef USE_NGHTTP2 + if(data->set.httpversion >= CURL_HTTP_VERSION_2 && + (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) { + CFArrayAppendValue(alpnArr, CFSTR(NGHTTP2_PROTO_VERSION_ID)); + infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID); + } +#endif + + CFArrayAppendValue(alpnArr, CFSTR(ALPN_HTTP_1_1)); + infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1); + + /* expects length prefixed preference ordered list of protocols in wire + * format + */ + err = SSLSetALPNProtocols(BACKEND->ssl_ctx, alpnArr); + if(err != noErr) + infof(data, "WARNING: failed to set ALPN protocols; OSStatus %d\n", + err); + CFRelease(alpnArr); + } + } +#endif + if(SSL_SET_OPTION(key)) { infof(data, "WARNING: SSL: CURLOPT_SSLKEY is ignored by Secure " "Transport. The private key must be in the Keychain.\n"); @@ -2466,6 +2496,39 @@ darwinssl_connect_step2(struct connectdata *conn, int sockindex) break; } +#if(CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1 + if(conn->bits.tls_enable_alpn) { + if(__builtin_available(macOS 10.13.4, iOS 11, *)) { + CFArrayRef alpnArr = NULL; + CFStringRef chosenProtocol = NULL; + err = SSLCopyALPNProtocols(BACKEND->ssl_ctx, &alpnArr); + + if(err == noErr && alpnArr && CFArrayGetCount(alpnArr) >= 1) + chosenProtocol = CFArrayGetValueAtIndex(alpnArr, 0); + +#ifdef USE_NGHTTP2 + if(chosenProtocol && + !CFStringCompare(chosenProtocol, CFSTR(NGHTTP2_PROTO_VERSION_ID), + 0)) { + conn->negnpn = CURL_HTTP_VERSION_2; + } + else +#endif + if(chosenProtocol && + !CFStringCompare(chosenProtocol, CFSTR(ALPN_HTTP_1_1), 0)) { + conn->negnpn = CURL_HTTP_VERSION_1_1; + } + else + infof(data, "ALPN, server did not agree to a protocol\n"); + + /* chosenProtocol is a reference to the string within alpnArr + and doesn't need to be freed separately */ + if(alpnArr) + CFRelease(alpnArr); + } + } +#endif + return CURLE_OK; } } diff --git a/Utilities/cmcurl/lib/vtls/gskit.c b/Utilities/cmcurl/lib/vtls/gskit.c index b0856cd..a0b4960 100644 --- a/Utilities/cmcurl/lib/vtls/gskit.c +++ b/Utilities/cmcurl/lib/vtls/gskit.c @@ -328,7 +328,7 @@ static CURLcode set_ciphers(struct connectdata *conn, GSKit tokens are always shorter than their cipher names, allocated buffers will always be large enough to accommodate the result. */ l = strlen(cipherlist) + 1; - memset((char *) ciphers, 0, sizeof ciphers); + memset((char *) ciphers, 0, sizeof(ciphers)); for(i = 0; i < CURL_GSKPROTO_LAST; i++) { ciphers[i].buf = malloc(l); if(!ciphers[i].buf) { @@ -536,18 +536,18 @@ inetsocketpair(int sv[2]) lfd = socket(AF_INET, SOCK_STREAM, 0); if(lfd < 0) return -1; - memset((char *) &addr1, 0, sizeof addr1); + memset((char *) &addr1, 0, sizeof(addr1)); addr1.sin_family = AF_INET; addr1.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr1.sin_port = 0; - if(bind(lfd, (struct sockaddr *) &addr1, sizeof addr1) || + if(bind(lfd, (struct sockaddr *) &addr1, sizeof(addr1)) || listen(lfd, 2) < 0) { close(lfd); return -1; } /* Get the allocated port. */ - len = sizeof addr1; + len = sizeof(addr1); if(getsockname(lfd, (struct sockaddr *) &addr1, &len) < 0) { close(lfd); return -1; @@ -562,7 +562,7 @@ inetsocketpair(int sv[2]) /* Request unblocking connection to the listening socket. */ curlx_nonblock(cfd, TRUE); - if(connect(cfd, (struct sockaddr *) &addr1, sizeof addr1) < 0 && + if(connect(cfd, (struct sockaddr *) &addr1, sizeof(addr1)) < 0 && errno != EINPROGRESS) { close(lfd); close(cfd); @@ -570,7 +570,7 @@ inetsocketpair(int sv[2]) } /* Get the client dynamic port for intrusion check below. */ - len = sizeof addr2; + len = sizeof(addr2); if(getsockname(cfd, (struct sockaddr *) &addr2, &len) < 0) { close(lfd); close(cfd); @@ -580,7 +580,7 @@ inetsocketpair(int sv[2]) /* Accept the incoming connection and get the server socket. */ curlx_nonblock(lfd, TRUE); for(;;) { - len = sizeof addr1; + len = sizeof(addr1); sfd = accept(lfd, (struct sockaddr *) &addr1, &len); if(sfd < 0) { close(lfd); @@ -644,7 +644,7 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex, /* Try getting data from HTTPS proxy and pipe it upstream. */ n = 0; i = gsk_secure_soc_read(connproxyssl->backend->handle, - buf, sizeof buf, &n); + buf, sizeof(buf), &n); switch(i) { case GSK_OK: if(n) { @@ -665,7 +665,7 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex, if(FD_ISSET(BACKEND->remotefd, &fds_read) && FD_ISSET(conn->sock[sockindex], &fds_write)) { /* Pipe data to HTTPS proxy. */ - n = read(BACKEND->remotefd, buf, sizeof buf); + n = read(BACKEND->remotefd, buf, sizeof(buf)); if(n < 0) return -1; if(n) { @@ -864,13 +864,13 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) BACKEND->localfd = sockpair[0]; BACKEND->remotefd = sockpair[1]; setsockopt(BACKEND->localfd, SOL_SOCKET, SO_RCVBUF, - (void *) sobufsize, sizeof sobufsize); + (void *) sobufsize, sizeof(sobufsize)); setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_RCVBUF, - (void *) sobufsize, sizeof sobufsize); + (void *) sobufsize, sizeof(sobufsize)); setsockopt(BACKEND->localfd, SOL_SOCKET, SO_SNDBUF, - (void *) sobufsize, sizeof sobufsize); + (void *) sobufsize, sizeof(sobufsize)); setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_SNDBUF, - (void *) sobufsize, sizeof sobufsize); + (void *) sobufsize, sizeof(sobufsize)); curlx_nonblock(BACKEND->localfd, TRUE); curlx_nonblock(BACKEND->remotefd, TRUE); } @@ -977,7 +977,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex) if(!result) { /* Start handshake. Try asynchronous first. */ - memset(&commarea, 0, sizeof commarea); + memset(&commarea, 0, sizeof(commarea)); BACKEND->iocport = QsoCreateIOCompletionPort(); if(BACKEND->iocport != -1) { result = gskit_status(data, @@ -1333,11 +1333,11 @@ static int Curl_gskit_check_cxn(struct connectdata *cxn) return 0; /* connection has been closed */ err = 0; - errlen = sizeof err; + errlen = sizeof(err); if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR, (unsigned char *) &err, &errlen) || - errlen != sizeof err || err) + errlen != sizeof(err) || err) return 0; /* connection has been closed */ return -1; /* connection status unknown */ diff --git a/Utilities/cmcurl/lib/vtls/nss.c b/Utilities/cmcurl/lib/vtls/nss.c index 7cd450c..89f8183 100644 --- a/Utilities/cmcurl/lib/vtls/nss.c +++ b/Utilities/cmcurl/lib/vtls/nss.c @@ -394,7 +394,7 @@ static PK11SlotInfo* nss_find_slot_by_name(const char *slot_name) /* wrap 'ptr' as list node and tail-insert into 'list' */ static CURLcode insert_wrapped_ptr(struct curl_llist *list, void *ptr) { - struct ptr_list_wrap *wrap = malloc(sizeof *wrap); + struct ptr_list_wrap *wrap = malloc(sizeof(*wrap)); if(!wrap) return CURLE_OUT_OF_MEMORY; @@ -914,11 +914,11 @@ static CURLcode display_conn_info(struct connectdata *conn, PRFileDesc *sock) PRTime now; int i; - if(SSL_GetChannelInfo(sock, &channel, sizeof channel) == - SECSuccess && channel.length == sizeof channel && + if(SSL_GetChannelInfo(sock, &channel, sizeof(channel)) == + SECSuccess && channel.length == sizeof(channel) && channel.cipherSuite) { if(SSL_GetCipherSuiteInfo(channel.cipherSuite, - &suite, sizeof suite) == SECSuccess) { + &suite, sizeof(suite)) == SECSuccess) { infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName); } } @@ -1345,7 +1345,8 @@ static CURLcode nss_init(struct Curl_easy *data) return CURLE_OUT_OF_MEMORY; /* the default methods just call down to the lower I/O layer */ - memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(), sizeof nspr_io_methods); + memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(), + sizeof(nspr_io_methods)); /* override certain methods in the table by our wrappers */ nspr_io_methods.recv = nspr_io_recv; diff --git a/Utilities/cmcurl/lib/vtls/openssl.c b/Utilities/cmcurl/lib/vtls/openssl.c index f6a4bd3..a487f55 100644 --- a/Utilities/cmcurl/lib/vtls/openssl.c +++ b/Utilities/cmcurl/lib/vtls/openssl.c @@ -50,9 +50,6 @@ #include "hostcheck.h" #include "curl_printf.h" #include <openssl/ssl.h> -#ifdef HAVE_OPENSSL_ENGINE_H -#include <openssl/engine.h> -#endif #include <openssl/rand.h> #include <openssl/x509v3.h> #ifndef OPENSSL_NO_DSA @@ -72,6 +69,12 @@ #include <openssl/ocsp.h> #endif +#if (OPENSSL_VERSION_NUMBER >= 0x10000000L) && /* 1.0.0 or later */ \ + !defined(OPENSSL_NO_ENGINE) +#define USE_OPENSSL_ENGINE +#include <openssl/engine.h> +#endif + #include "warnless.h" #include "non-ascii.h" /* for Curl_convert_from_utf8 prototype */ @@ -83,7 +86,7 @@ #error "OPENSSL_VERSION_NUMBER not defined" #endif -#if defined(HAVE_OPENSSL_ENGINE_H) +#ifdef USE_OPENSSL_ENGINE #include <openssl/ui.h> #endif @@ -166,6 +169,17 @@ static unsigned long OpenSSL_version_num(void) #define HAVE_KEYLOG_CALLBACK #endif +/* Whether SSL_CTX_set_ciphersuites is available. + * OpenSSL: supported since 1.1.1 (commit a53b5be6a05) + * BoringSSL: no + * LibreSSL: no + */ +#if ((OPENSSL_VERSION_NUMBER >= 0x10101000L) && \ + !defined(LIBRESSL_VERSION_NUMBER) && \ + !defined(OPENSSL_IS_BORINGSSL)) +#define HAVE_SSL_CTX_SET_CIPHERSUITES +#endif + #if defined(LIBRESSL_VERSION_NUMBER) #define OSSL_PACKAGE "LibreSSL" #elif defined(OPENSSL_IS_BORINGSSL) @@ -504,7 +518,7 @@ static int do_file_type(const char *type) return -1; } -#if defined(HAVE_OPENSSL_ENGINE_H) +#ifdef USE_OPENSSL_ENGINE /* * Supply default password to the engine user interface conversation. * The password is passed by OpenSSL engine from ENGINE_load_private_key() @@ -544,8 +558,20 @@ static int ssl_ui_writer(UI *ui, UI_STRING *uis) } return (UI_method_get_writer(UI_OpenSSL()))(ui, uis); } + +/* + * Check if a given string is a PKCS#11 URI + */ +static bool is_pkcs11_uri(const char *string) +{ + return (string && strncasecompare(string, "pkcs11:", 7)); +} + #endif +static CURLcode Curl_ossl_set_engine(struct Curl_easy *data, + const char *engine); + static int cert_stuff(struct connectdata *conn, SSL_CTX* ctx, @@ -606,8 +632,18 @@ int cert_stuff(struct connectdata *conn, } break; case SSL_FILETYPE_ENGINE: -#if defined(HAVE_OPENSSL_ENGINE_H) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME) +#if defined(USE_OPENSSL_ENGINE) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME) { + /* Implicitly use pkcs11 engine if none was provided and the + * cert_file is a PKCS#11 URI */ + if(!data->state.engine) { + if(is_pkcs11_uri(cert_file)) { + if(Curl_ossl_set_engine(data, "pkcs11") != CURLE_OK) { + return 0; + } + } + } + if(data->state.engine) { const char *cmd_name = "LOAD_CERT_CTRL"; struct { @@ -781,9 +817,20 @@ int cert_stuff(struct connectdata *conn, } break; case SSL_FILETYPE_ENGINE: -#ifdef HAVE_OPENSSL_ENGINE_H +#ifdef USE_OPENSSL_ENGINE { /* XXXX still needs some work */ EVP_PKEY *priv_key = NULL; + + /* Implicitly use pkcs11 engine if none was provided and the + * key_file is a PKCS#11 URI */ + if(!data->state.engine) { + if(is_pkcs11_uri(key_file)) { + if(Curl_ossl_set_engine(data, "pkcs11") != CURLE_OK) { + return 0; + } + } + } + if(data->state.engine) { UI_METHOD *ui_method = UI_create_method((char *)"curl user interface"); @@ -1088,7 +1135,7 @@ static int Curl_ossl_check_cxn(struct connectdata *conn) static CURLcode Curl_ossl_set_engine(struct Curl_easy *data, const char *engine) { -#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) +#ifdef USE_OPENSSL_ENGINE ENGINE *e; #if OPENSSL_VERSION_NUMBER >= 0x00909000L @@ -1133,7 +1180,7 @@ static CURLcode Curl_ossl_set_engine(struct Curl_easy *data, */ static CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data) { -#ifdef HAVE_OPENSSL_ENGINE_H +#ifdef USE_OPENSSL_ENGINE if(data->state.engine) { if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) { infof(data, "set default crypto engine '%s'\n", @@ -1156,7 +1203,7 @@ static CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data) static struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data) { struct curl_slist *list = NULL; -#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H) +#ifdef USE_OPENSSL_ENGINE struct curl_slist *beg; ENGINE *e; @@ -1312,7 +1359,7 @@ static void Curl_ossl_session_free(void *ptr) */ static void Curl_ossl_close_all(struct Curl_easy *data) { -#ifdef HAVE_OPENSSL_ENGINE_H +#ifdef USE_OPENSSL_ENGINE if(data->state.engine) { ENGINE_finish(data->state.engine); ENGINE_free(data->state.engine); @@ -1922,7 +1969,15 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type, } else #endif - { + if(content_type == SSL3_RT_CHANGE_CIPHER_SPEC) { + msg_type = *(char *)buf; + msg_name = "Change cipher spec"; + } + else if(content_type == SSL3_RT_ALERT) { + msg_type = (((char *)buf)[0] << 8) + ((char *)buf)[1]; + msg_name = SSL_alert_desc_string_long(msg_type); + } + else { msg_type = *(char *)buf; msg_name = ssl_msg_type(ssl_ver, msg_type); } @@ -1931,12 +1986,12 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type, verstr, direction?"OUT":"IN", tls_rt_name, msg_name, msg_type); if(0 <= txt_len && (unsigned)txt_len < sizeof(ssl_buf)) { - Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len, NULL); + Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len); } } Curl_debug(data, (direction == 1) ? CURLINFO_SSL_DATA_OUT : - CURLINFO_SSL_DATA_IN, (char *)buf, len, NULL); + CURLINFO_SSL_DATA_IN, (char *)buf, len); (void) ssl; } #endif @@ -2064,10 +2119,6 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn, long ssl_version = SSL_CONN_CONFIG(version); long ssl_version_max = SSL_CONN_CONFIG(version_max); - if(ssl_version_max == CURL_SSLVERSION_MAX_NONE) { - ssl_version_max = ssl_version << 16; - } - switch(ssl_version) { case CURL_SSLVERSION_TLSv1_3: #ifdef TLS1_3_VERSION @@ -2099,8 +2150,7 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn, #endif /* FALLTHROUGH */ case CURL_SSLVERSION_TLSv1_0: - *ctx_options |= SSL_OP_NO_SSLv2; - *ctx_options |= SSL_OP_NO_SSLv3; + case CURL_SSLVERSION_TLSv1: break; } @@ -2116,12 +2166,12 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn, #endif /* FALLTHROUGH */ case CURL_SSLVERSION_MAX_TLSv1_2: - case CURL_SSLVERSION_MAX_DEFAULT: #ifdef TLS1_3_VERSION *ctx_options |= SSL_OP_NO_TLSv1_3; #endif break; case CURL_SSLVERSION_MAX_TLSv1_3: + case CURL_SSLVERSION_MAX_DEFAULT: #ifdef TLS1_3_VERSION break; #else @@ -2305,11 +2355,6 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex) switch(ssl_version) { case CURL_SSLVERSION_SSLv3: -#ifdef USE_TLS_SRP - if(ssl_authtype == CURL_TLSAUTH_SRP) { - infof(data, "Set version TLSv1.x for SRP authorisation\n"); - } -#endif ctx_options |= SSL_OP_NO_SSLv2; ctx_options |= SSL_OP_NO_TLSv1; #if OPENSSL_VERSION_NUMBER >= 0x1000100FL @@ -2323,21 +2368,20 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex) case CURL_SSLVERSION_DEFAULT: case CURL_SSLVERSION_TLSv1: - ctx_options |= SSL_OP_NO_SSLv2; - ctx_options |= SSL_OP_NO_SSLv3; - break; - case CURL_SSLVERSION_TLSv1_0: case CURL_SSLVERSION_TLSv1_1: case CURL_SSLVERSION_TLSv1_2: case CURL_SSLVERSION_TLSv1_3: + /* asking for any TLS version as the minimum, means no SSL versions + allowed */ + ctx_options |= SSL_OP_NO_SSLv2; + ctx_options |= SSL_OP_NO_SSLv3; result = set_ssl_version_min_max(&ctx_options, conn, sockindex); if(result != CURLE_OK) return result; break; case CURL_SSLVERSION_SSLv2: -#ifndef OPENSSL_NO_SSL2 ctx_options |= SSL_OP_NO_SSLv3; ctx_options |= SSL_OP_NO_TLSv1; #if OPENSSL_VERSION_NUMBER >= 0x1000100FL @@ -2348,10 +2392,6 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex) #endif #endif break; -#else - failf(data, OSSL_PACKAGE " was built without SSLv2 support"); - return CURLE_NOT_BUILT_IN; -#endif default: failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION"); @@ -2414,6 +2454,19 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex) infof(data, "Cipher selection: %s\n", ciphers); } +#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES + { + char *ciphers13 = SSL_CONN_CONFIG(cipher_list13); + if(ciphers13) { + if(!SSL_CTX_set_ciphersuites(BACKEND->ctx, ciphers13)) { + failf(data, "failed setting TLS 1.3 cipher suite: %s", ciphers); + return CURLE_SSL_CIPHER; + } + infof(data, "TLS 1.3 cipher selection: %s\n", ciphers13); + } + } +#endif + #ifdef USE_TLS_SRP if(ssl_authtype == CURL_TLSAUTH_SRP) { char * const ssl_username = SSL_SET_OPTION(username); @@ -3754,6 +3807,9 @@ const struct Curl_ssl Curl_ssl_openssl = { SSLSUPP_CERTINFO | SSLSUPP_PINNEDPUBKEY | SSLSUPP_SSL_CTX | +#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES + SSLSUPP_TLS13_CIPHERSUITES | +#endif SSLSUPP_HTTPS_PROXY, sizeof(struct ssl_backend_data), diff --git a/Utilities/cmcurl/lib/vtls/schannel.c b/Utilities/cmcurl/lib/vtls/schannel.c index 2cfd5c1..8f6c301 100644 --- a/Utilities/cmcurl/lib/vtls/schannel.c +++ b/Utilities/cmcurl/lib/vtls/schannel.c @@ -90,11 +90,17 @@ #endif #endif +#if defined(CryptStringToBinary) && defined(CRYPT_STRING_HEX) +#define HAS_CLIENT_CERT_PATH +#endif + +#ifdef HAS_CLIENT_CERT_PATH #ifdef UNICODE #define CURL_CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_W #else #define CURL_CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_A #endif +#endif #ifndef SP_PROT_SSL2_CLIENT #define SP_PROT_SSL2_CLIENT 0x00000008 @@ -199,6 +205,155 @@ set_ssl_version_min_max(SCHANNEL_CRED *schannel_cred, struct connectdata *conn) return CURLE_OK; } +/*longest is 26, buffer is slightly bigger*/ +#define LONGEST_ALG_ID 32 +#define CIPHEROPTION(X) \ +if(strcmp(#X, tmp) == 0) \ + return X + +static int +get_alg_id_by_name(char *name) +{ + char tmp[LONGEST_ALG_ID] = { 0 }; + char *nameEnd = strchr(name, ':'); + size_t n = nameEnd ? min((size_t)(nameEnd - name), LONGEST_ALG_ID - 1) : \ + min(strlen(name), LONGEST_ALG_ID - 1); + strncpy(tmp, name, n); + tmp[n] = 0; + CIPHEROPTION(CALG_MD2); + CIPHEROPTION(CALG_MD4); + CIPHEROPTION(CALG_MD5); + CIPHEROPTION(CALG_SHA); + CIPHEROPTION(CALG_SHA1); + CIPHEROPTION(CALG_MAC); + CIPHEROPTION(CALG_RSA_SIGN); + CIPHEROPTION(CALG_DSS_SIGN); +/*ifdefs for the options that are defined conditionally in wincrypt.h*/ +#ifdef CALG_NO_SIGN + CIPHEROPTION(CALG_NO_SIGN); +#endif + CIPHEROPTION(CALG_RSA_KEYX); + CIPHEROPTION(CALG_DES); +#ifdef CALG_3DES_112 + CIPHEROPTION(CALG_3DES_112); +#endif + CIPHEROPTION(CALG_3DES); + CIPHEROPTION(CALG_DESX); + CIPHEROPTION(CALG_RC2); + CIPHEROPTION(CALG_RC4); + CIPHEROPTION(CALG_SEAL); +#ifdef CALG_DH_SF + CIPHEROPTION(CALG_DH_SF); +#endif + CIPHEROPTION(CALG_DH_EPHEM); +#ifdef CALG_AGREEDKEY_ANY + CIPHEROPTION(CALG_AGREEDKEY_ANY); +#endif +#ifdef CALG_HUGHES_MD5 + CIPHEROPTION(CALG_HUGHES_MD5); +#endif + CIPHEROPTION(CALG_SKIPJACK); +#ifdef CALG_TEK + CIPHEROPTION(CALG_TEK); +#endif + CIPHEROPTION(CALG_CYLINK_MEK); + CIPHEROPTION(CALG_SSL3_SHAMD5); +#ifdef CALG_SSL3_MASTER + CIPHEROPTION(CALG_SSL3_MASTER); +#endif +#ifdef CALG_SCHANNEL_MASTER_HASH + CIPHEROPTION(CALG_SCHANNEL_MASTER_HASH); +#endif +#ifdef CALG_SCHANNEL_MAC_KEY + CIPHEROPTION(CALG_SCHANNEL_MAC_KEY); +#endif +#ifdef CALG_SCHANNEL_ENC_KEY + CIPHEROPTION(CALG_SCHANNEL_ENC_KEY); +#endif +#ifdef CALG_PCT1_MASTER + CIPHEROPTION(CALG_PCT1_MASTER); +#endif +#ifdef CALG_SSL2_MASTER + CIPHEROPTION(CALG_SSL2_MASTER); +#endif +#ifdef CALG_TLS1_MASTER + CIPHEROPTION(CALG_TLS1_MASTER); +#endif +#ifdef CALG_RC5 + CIPHEROPTION(CALG_RC5); +#endif +#ifdef CALG_HMAC + CIPHEROPTION(CALG_HMAC); +#endif +#if !defined(__W32API_MAJOR_VERSION) || \ + !defined(__W32API_MINOR_VERSION) || \ + defined(__MINGW64_VERSION_MAJOR) || \ + (__W32API_MAJOR_VERSION > 5) || \ + ((__W32API_MAJOR_VERSION == 5) && (__W32API_MINOR_VERSION > 0)) + /* CALG_TLS1PRF has a syntax error in MinGW's w32api up to version 5.0, + see https://osdn.net/projects/mingw/ticket/38391 */ + CIPHEROPTION(CALG_TLS1PRF); +#endif +#ifdef CALG_HASH_REPLACE_OWF + CIPHEROPTION(CALG_HASH_REPLACE_OWF); +#endif +#ifdef CALG_AES_128 + CIPHEROPTION(CALG_AES_128); +#endif +#ifdef CALG_AES_192 + CIPHEROPTION(CALG_AES_192); +#endif +#ifdef CALG_AES_256 + CIPHEROPTION(CALG_AES_256); +#endif +#ifdef CALG_AES + CIPHEROPTION(CALG_AES); +#endif +#ifdef CALG_SHA_256 + CIPHEROPTION(CALG_SHA_256); +#endif +#ifdef CALG_SHA_384 + CIPHEROPTION(CALG_SHA_384); +#endif +#ifdef CALG_SHA_512 + CIPHEROPTION(CALG_SHA_512); +#endif +#ifdef CALG_ECDH + CIPHEROPTION(CALG_ECDH); +#endif +#ifdef CALG_ECMQV + CIPHEROPTION(CALG_ECMQV); +#endif +#ifdef CALG_ECDSA + CIPHEROPTION(CALG_ECDSA); +#endif + return 0; +} + +static CURLcode +set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers) +{ + char *startCur = ciphers; + int algCount = 0; + static ALG_ID algIds[45]; /*There are 45 listed in the MS headers*/ + while(startCur && (0 != *startCur) && (algCount < 45)) { + long alg = strtol(startCur, 0, 0); + if(!alg) + alg = get_alg_id_by_name(startCur); + if(alg) + algIds[algCount++] = alg; + else + return CURLE_SSL_CIPHER; + startCur = strchr(startCur, ':'); + if(startCur) + startCur++; + } + schannel_cred->palgSupportedAlgs = algIds; + schannel_cred->cSupportedAlgs = algCount; + return CURLE_OK; +} + +#ifdef HAS_CLIENT_CERT_PATH static CURLcode get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, TCHAR **thumbprint) @@ -248,6 +403,7 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, return CURLE_OK; } +#endif static CURLcode schannel_connect_step1(struct connectdata *conn, int sockindex) @@ -299,10 +455,15 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) #endif #ifdef _WIN32_WCE +#ifdef HAS_MANUAL_VERIFY_API /* certificate validation on CE doesn't seem to work right; we'll * do it following a more manual process. */ BACKEND->use_manual_cred_validation = true; #else +#error "compiler too old to support requisite manual cert verify for Win CE" +#endif +#else +#ifdef HAS_MANUAL_VERIFY_API if(SSL_CONN_CONFIG(CAfile)) { if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_GREATER_THAN_EQUAL)) { @@ -316,6 +477,12 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) } else BACKEND->use_manual_cred_validation = false; +#else + if(SSL_CONN_CONFIG(CAfile)) { + failf(data, "schannel: CA cert support not built in"); + return CURLE_NOT_BUILT_IN; + } +#endif #endif BACKEND->cred = NULL; @@ -341,9 +508,11 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) schannel_cred.dwVersion = SCHANNEL_CRED_VERSION; if(conn->ssl_config.verifypeer) { +#ifdef HAS_MANUAL_VERIFY_API if(BACKEND->use_manual_cred_validation) schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION; else +#endif schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION; /* TODO s/data->set.ssl.no_revoke/SSL_SET_OPTION(no_revoke)/g */ @@ -401,6 +570,16 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) return CURLE_SSL_CONNECT_ERROR; } + if(SSL_CONN_CONFIG(cipher_list)) { + result = set_ssl_ciphers(&schannel_cred, SSL_CONN_CONFIG(cipher_list)); + if(CURLE_OK != result) { + failf(data, "Unable to set ciphers to passed via SSL_CONN_CONFIG"); + return result; + } + } + + +#ifdef HAS_CLIENT_CERT_PATH /* client certificate */ if(data->set.ssl.cert) { DWORD cert_store_name; @@ -417,14 +596,21 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) result = get_cert_location(cert_path, &cert_store_name, &cert_store_path, &cert_thumbprint_str); if(result != CURLE_OK) { + failf(data, "schannel: Failed to get certificate location for %s", + cert_path); Curl_unicodefree(cert_path); return result; } - cert_store = CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0, - (HCRYPTPROV)NULL, - cert_store_name, cert_store_path); + cert_store = + CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0, + (HCRYPTPROV)NULL, + CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name, + cert_store_path); if(!cert_store) { + failf(data, "schannel: Failed to open cert store %x %s, " + "last error is %x", + cert_store_name, cert_store_path, GetLastError()); Curl_unicodefree(cert_path); return CURLE_SSL_CONNECT_ERROR; } @@ -453,6 +639,12 @@ schannel_connect_step1(struct connectdata *conn, int sockindex) CertCloseStore(cert_store, 0); } +#else + if(data->set.ssl.cert) { + failf(data, "schannel: client cert support not built in"); + return CURLE_NOT_BUILT_IN; + } +#endif /* allocate memory for the re-usable credential handle */ BACKEND->cred = (struct curl_schannel_cred *) @@ -877,9 +1069,11 @@ schannel_connect_step2(struct connectdata *conn, int sockindex) } } +#ifdef HAS_MANUAL_VERIFY_API if(conn->ssl_config.verifypeer && BACKEND->use_manual_cred_validation) { return verify_certificate(conn, sockindex); } +#endif return CURLE_OK; } @@ -1819,7 +2013,7 @@ static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex, x509_der = (const char *)pCertContextServer->pbCertEncoded; x509_der_len = pCertContextServer->cbCertEncoded; - memset(&x509_parsed, 0, sizeof x509_parsed); + memset(&x509_parsed, 0, sizeof(x509_parsed)); if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len)) break; @@ -1870,7 +2064,8 @@ static void Curl_schannel_checksum(const unsigned char *input, if(!CryptCreateHash(hProv, algId, 0, 0, &hHash)) break; /* failed */ - if(!CryptHashData(hHash, (const BYTE*)input, (DWORD)inputlen, 0)) + /* workaround for original MinGW, should be (const BYTE*) */ + if(!CryptHashData(hHash, (BYTE*)input, (DWORD)inputlen, 0)) break; /* failed */ /* get hash size */ diff --git a/Utilities/cmcurl/lib/vtls/schannel.h b/Utilities/cmcurl/lib/vtls/schannel.h index 4476900..51417af 100644 --- a/Utilities/cmcurl/lib/vtls/schannel.h +++ b/Utilities/cmcurl/lib/vtls/schannel.h @@ -32,12 +32,44 @@ #include "urldata.h" +/* <wincrypt.h> has been included via the above <schnlsp.h>. + * Or in case of ldap.c, it was included via <winldap.h>. + * And since <wincrypt.h> has this: + * #define X509_NAME ((LPCSTR) 7) + * + * And in BoringSSL's <openssl/base.h> there is: + * typedef struct X509_name_st X509_NAME; + * etc. + * + * this wil cause all kinds of C-preprocessing paste errors in + * BoringSSL's <openssl/x509.h>: So just undefine those defines here + * (and only here). + */ +#if defined(HAVE_BORINGSSL) || defined(OPENSSL_IS_BORINGSSL) +# undef X509_NAME +# undef X509_CERT_PAIR +# undef X509_EXTENSIONS +#endif + extern const struct Curl_ssl Curl_ssl_schannel; CURLcode verify_certificate(struct connectdata *conn, int sockindex); /* structs to expose only in schannel.c and schannel_verify.c */ #ifdef EXPOSE_SCHANNEL_INTERNAL_STRUCTS + +#ifdef __MINGW32__ +#include <_mingw.h> +#ifdef __MINGW64_VERSION_MAJOR +#define HAS_MANUAL_VERIFY_API +#endif +#else +#include <wincrypt.h> +#ifdef CERT_CHAIN_REVOCATION_CHECK_CHAIN +#define HAS_MANUAL_VERIFY_API +#endif +#endif + struct curl_schannel_cred { CredHandle cred_handle; TimeStamp time_stamp; @@ -66,7 +98,9 @@ struct ssl_backend_data { bool recv_sspi_close_notify; /* true if connection closed by close_notify */ bool recv_connection_closed; /* true if connection closed, regardless how */ bool use_alpn; /* true if ALPN is used for this connection */ +#ifdef HAS_MANUAL_VERIFY_API bool use_manual_cred_validation; /* true if manual cred validation is used */ +#endif }; #endif /* EXPOSE_SCHANNEL_INTERNAL_STRUCTS */ diff --git a/Utilities/cmcurl/lib/vtls/schannel_verify.c b/Utilities/cmcurl/lib/vtls/schannel_verify.c index db187dd..5a7092a 100644 --- a/Utilities/cmcurl/lib/vtls/schannel_verify.c +++ b/Utilities/cmcurl/lib/vtls/schannel_verify.c @@ -30,14 +30,15 @@ #include "curl_setup.h" #ifdef USE_SCHANNEL - -#define EXPOSE_SCHANNEL_INTERNAL_STRUCTS - #ifndef USE_WINDOWS_SSPI # error "Can't compile SCHANNEL support without SSPI." #endif +#define EXPOSE_SCHANNEL_INTERNAL_STRUCTS #include "schannel.h" + +#ifdef HAS_MANUAL_VERIFY_API + #include "vtls.h" #include "sendf.h" #include "strerror.h" @@ -53,7 +54,7 @@ #define BACKEND connssl->backend #define MAX_CAFILE_SIZE 1048576 /* 1 MiB */ -#define BEGIN_CERT "-----BEGIN CERTIFICATE-----\n" +#define BEGIN_CERT "-----BEGIN CERTIFICATE-----" #define END_CERT "\n-----END CERTIFICATE-----" typedef struct { @@ -71,6 +72,10 @@ typedef struct { HCERTSTORE hExclusiveTrustedPeople; } CERT_CHAIN_ENGINE_CONFIG_WIN7, *PCERT_CHAIN_ENGINE_CONFIG_WIN7; +static int is_cr_or_lf(char c) +{ + return c == '\r' || c == '\n'; +} static CURLcode add_certs_to_store(HCERTSTORE trust_store, const char *ca_file, @@ -177,7 +182,7 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store, current_ca_file_ptr = ca_file_buffer; while(more_certs && *current_ca_file_ptr != '\0') { char *begin_cert_ptr = strstr(current_ca_file_ptr, BEGIN_CERT); - if(!begin_cert_ptr) { + if(!begin_cert_ptr || !is_cr_or_lf(begin_cert_ptr[strlen(BEGIN_CERT)])) { more_certs = 0; } else { @@ -209,7 +214,7 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store, NULL, NULL, NULL, - &cert_context)) { + (const void **)&cert_context)) { failf(data, "schannel: failed to extract certificate from CA file " @@ -548,4 +553,5 @@ CURLcode verify_certificate(struct connectdata *conn, int sockindex) return result; } +#endif /* HAS_MANUAL_VERIFY_API */ #endif /* USE_SCHANNEL */ diff --git a/Utilities/cmcurl/lib/vtls/vtls.c b/Utilities/cmcurl/lib/vtls/vtls.c index ee5bc7a..b61c640 100644 --- a/Utilities/cmcurl/lib/vtls/vtls.c +++ b/Utilities/cmcurl/lib/vtls/vtls.c @@ -96,7 +96,8 @@ Curl_ssl_config_matches(struct ssl_primary_config* data, Curl_safe_strcasecompare(data->clientcert, needle->clientcert) && Curl_safe_strcasecompare(data->random_file, needle->random_file) && Curl_safe_strcasecompare(data->egdsocket, needle->egdsocket) && - Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list)) + Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) && + Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13)) return TRUE; return FALSE; @@ -119,6 +120,7 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source, CLONE_STRING(random_file); CLONE_STRING(egdsocket); CLONE_STRING(cipher_list); + CLONE_STRING(cipher_list13); return TRUE; } @@ -131,6 +133,7 @@ void Curl_free_primary_ssl_config(struct ssl_primary_config* sslc) Curl_safefree(sslc->random_file); Curl_safefree(sslc->egdsocket); Curl_safefree(sslc->cipher_list); + Curl_safefree(sslc->cipher_list13); } #ifdef USE_SSL @@ -980,6 +983,14 @@ bool Curl_ssl_false_start(void) } /* + * Check whether the SSL backend supports setting TLS 1.3 cipher suites + */ +bool Curl_ssl_tls13_ciphersuites(void) +{ + return Curl_ssl->supports & SSLSUPP_TLS13_CIPHERSUITES; +} + +/* * Default implementations for unsupported functions. */ diff --git a/Utilities/cmcurl/lib/vtls/vtls.h b/Utilities/cmcurl/lib/vtls/vtls.h index e7b87c4..40f9d74 100644 --- a/Utilities/cmcurl/lib/vtls/vtls.h +++ b/Utilities/cmcurl/lib/vtls/vtls.h @@ -31,6 +31,7 @@ struct ssl_connect_data; #define SSLSUPP_PINNEDPUBKEY (1<<2) /* supports CURLOPT_PINNEDPUBLICKEY */ #define SSLSUPP_SSL_CTX (1<<3) /* supports CURLOPT_SSL_CTX */ #define SSLSUPP_HTTPS_PROXY (1<<4) /* supports access via HTTPS proxies */ +#define SSLSUPP_TLS13_CIPHERSUITES (1<<5) /* supports TLS 1.3 ciphersuites */ struct Curl_ssl { /* @@ -93,6 +94,7 @@ CURLcode Curl_none_set_engine(struct Curl_easy *data, const char *engine); CURLcode Curl_none_set_engine_default(struct Curl_easy *data); struct curl_slist *Curl_none_engines_list(struct Curl_easy *data); bool Curl_none_false_start(void); +bool Curl_ssl_tls13_ciphersuites(void); CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen, unsigned char *md5sum, size_t md5len); @@ -246,7 +248,7 @@ bool Curl_ssl_false_start(void); #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */ -#else +#else /* if not USE_SSL */ /* When SSL support is not present, just define away these function calls */ #define Curl_ssl_init() 1 @@ -270,6 +272,7 @@ bool Curl_ssl_false_start(void); #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN) #define Curl_ssl_cert_status_request() FALSE #define Curl_ssl_false_start() FALSE +#define Curl_ssl_tls13_ciphersuites() FALSE #endif #endif /* HEADER_CURL_VTLS_H */ diff --git a/Utilities/cmcurl/lib/warnless.h b/Utilities/cmcurl/lib/warnless.h index f6a2d74..284ea1e 100644 --- a/Utilities/cmcurl/lib/warnless.h +++ b/Utilities/cmcurl/lib/warnless.h @@ -26,6 +26,9 @@ #include <curl/curl.h> /* for curl_socket_t */ #endif +#define CURLX_FUNCTION_CAST(target_type, func) \ + (target_type)(void (*) (void))(func) + unsigned short curlx_ultous(unsigned long ulnum); unsigned char curlx_ultouc(unsigned long ulnum); diff --git a/Utilities/cmcurl/lib/x509asn1.c b/Utilities/cmcurl/lib/x509asn1.c index bba2023..72a0b4a 100644 --- a/Utilities/cmcurl/lib/x509asn1.c +++ b/Utilities/cmcurl/lib/x509asn1.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -40,10 +40,6 @@ #include "curl_memory.h" #include "memdebug.h" -/* For overflow checks. */ -#define CURL_SIZE_T_MAX ((size_t)-1) - - /* ASN.1 OIDs. */ static const char cnOID[] = "2.5.4.3"; /* Common name. */ static const char sanOID[] = "2.5.29.17"; /* Subject alternative name. */ @@ -108,8 +104,8 @@ static const curl_OID OIDtable[] = { */ -const char *Curl_getASN1Element(curl_asn1Element *elem, - const char *beg, const char *end) +static const char *getASN1Element(curl_asn1Element *elem, + const char *beg, const char *end) { unsigned char b; unsigned long len; @@ -146,7 +142,7 @@ const char *Curl_getASN1Element(curl_asn1Element *elem, return (const char *) NULL; elem->beg = beg; while(beg < end && *beg) { - beg = Curl_getASN1Element(&lelem, beg, end); + beg = getASN1Element(&lelem, beg, end); if(!beg) return (const char *) NULL; } @@ -206,7 +202,7 @@ static const char *octet2str(const char *beg, const char *end) /* Convert an ASN.1 octet string to a printable string. Return the dynamically allocated string, or NULL if an error occurs. */ - if(n <= (CURL_SIZE_T_MAX - 1) / 3) { + if(n <= (SIZE_T_MAX - 1) / 3) { buf = malloc(3 * n + 1); if(buf) for(n = 0; beg < end; n += 3) @@ -287,7 +283,7 @@ utf8asn1str(char **to, int type, const char *from, const char *end) if(inlength % size) return -1; /* Length inconsistent with character size. */ - if(inlength / size > (CURL_SIZE_T_MAX - 1) / 4) + if(inlength / size > (SIZE_T_MAX - 1) / 4) return -1; /* Too big. */ buf = malloc(4 * (inlength / size) + 1); if(!buf) @@ -306,10 +302,10 @@ utf8asn1str(char **to, int type, const char *from, const char *end) case 4: wc = (wc << 8) | *(const unsigned char *) from++; wc = (wc << 8) | *(const unsigned char *) from++; - /* fallthrough */ + /* FALLTHROUGH */ case 2: wc = (wc << 8) | *(const unsigned char *) from++; - /* fallthrough */ + /* FALLTHROUGH */ default: /* case 1: */ wc = (wc << 8) | *(const unsigned char *) from++; } @@ -546,7 +542,7 @@ static const char *UTime2str(const char *beg, const char *end) tzl, tzp); } -const char *Curl_ASN1tostr(curl_asn1Element *elem, int type) +static const char *ASN1tostr(curl_asn1Element *elem, int type) { /* Convert an ASN.1 element to a printable string. Return the dynamically allocated string, or NULL if an error occurs. */ @@ -605,12 +601,12 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn) Return the total string length, even if larger than `n'. */ for(p1 = dn->beg; p1 < dn->end;) { - p1 = Curl_getASN1Element(&rdn, p1, dn->end); + p1 = getASN1Element(&rdn, p1, dn->end); for(p2 = rdn.beg; p2 < rdn.end;) { - p2 = Curl_getASN1Element(&atv, p2, rdn.end); - p3 = Curl_getASN1Element(&oid, atv.beg, atv.end); - Curl_getASN1Element(&value, p3, atv.end); - str = Curl_ASN1tostr(&oid, 0); + p2 = getASN1Element(&atv, p2, rdn.end); + p3 = getASN1Element(&oid, atv.beg, atv.end); + getASN1Element(&value, p3, atv.end); + str = ASN1tostr(&oid, 0); if(!str) return -1; @@ -640,7 +636,7 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn) l++; /* Generate value. */ - str = Curl_ASN1tostr(&value, 0); + str = ASN1tostr(&value, 0); if(!str) return -1; for(p3 = str; *p3; p3++) { @@ -655,7 +651,7 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn) return l; } -const char *Curl_DNtostr(curl_asn1Element *dn) +static const char *DNtostr(curl_asn1Element *dn) { char *buf = (char *) NULL; ssize_t n = encodeDN(buf, 0, dn); @@ -694,17 +690,17 @@ int Curl_parseX509(curl_X509certificate *cert, cert->certificate.end = end; /* Get the sequence content. */ - if(!Curl_getASN1Element(&elem, beg, end)) + if(!getASN1Element(&elem, beg, end)) return -1; /* Invalid bounds/size. */ beg = elem.beg; end = elem.end; /* Get tbsCertificate. */ - beg = Curl_getASN1Element(&tbsCertificate, beg, end); + beg = getASN1Element(&tbsCertificate, beg, end); /* Skip the signatureAlgorithm. */ - beg = Curl_getASN1Element(&cert->signatureAlgorithm, beg, end); + beg = getASN1Element(&cert->signatureAlgorithm, beg, end); /* Get the signatureValue. */ - Curl_getASN1Element(&cert->signature, beg, end); + getASN1Element(&cert->signature, beg, end); /* Parse TBSCertificate. */ beg = tbsCertificate.beg; @@ -712,29 +708,29 @@ int Curl_parseX509(curl_X509certificate *cert, /* Get optional version, get serialNumber. */ cert->version.header = NULL; cert->version.beg = &defaultVersion; - cert->version.end = &defaultVersion + sizeof defaultVersion;; - beg = Curl_getASN1Element(&elem, beg, end); + cert->version.end = &defaultVersion + sizeof(defaultVersion); + beg = getASN1Element(&elem, beg, end); if(elem.tag == 0) { - Curl_getASN1Element(&cert->version, elem.beg, elem.end); - beg = Curl_getASN1Element(&elem, beg, end); + getASN1Element(&cert->version, elem.beg, elem.end); + beg = getASN1Element(&elem, beg, end); } cert->serialNumber = elem; /* Get signature algorithm. */ - beg = Curl_getASN1Element(&cert->signatureAlgorithm, beg, end); + beg = getASN1Element(&cert->signatureAlgorithm, beg, end); /* Get issuer. */ - beg = Curl_getASN1Element(&cert->issuer, beg, end); + beg = getASN1Element(&cert->issuer, beg, end); /* Get notBefore and notAfter. */ - beg = Curl_getASN1Element(&elem, beg, end); - ccp = Curl_getASN1Element(&cert->notBefore, elem.beg, elem.end); - Curl_getASN1Element(&cert->notAfter, ccp, elem.end); + beg = getASN1Element(&elem, beg, end); + ccp = getASN1Element(&cert->notBefore, elem.beg, elem.end); + getASN1Element(&cert->notAfter, ccp, elem.end); /* Get subject. */ - beg = Curl_getASN1Element(&cert->subject, beg, end); + beg = getASN1Element(&cert->subject, beg, end); /* Get subjectPublicKeyAlgorithm and subjectPublicKey. */ - beg = Curl_getASN1Element(&cert->subjectPublicKeyInfo, beg, end); - ccp = Curl_getASN1Element(&cert->subjectPublicKeyAlgorithm, + beg = getASN1Element(&cert->subjectPublicKeyInfo, beg, end); + ccp = getASN1Element(&cert->subjectPublicKeyAlgorithm, cert->subjectPublicKeyInfo.beg, cert->subjectPublicKeyInfo.end); - Curl_getASN1Element(&cert->subjectPublicKey, ccp, + getASN1Element(&cert->subjectPublicKey, ccp, cert->subjectPublicKeyInfo.end); /* Get optional issuerUiqueID, subjectUniqueID and extensions. */ cert->issuerUniqueID.tag = cert->subjectUniqueID.tag = 0; @@ -745,19 +741,19 @@ int Curl_parseX509(curl_X509certificate *cert, cert->extensions.header = NULL; cert->extensions.beg = cert->extensions.end = ""; if(beg < end) - beg = Curl_getASN1Element(&elem, beg, end); + beg = getASN1Element(&elem, beg, end); if(elem.tag == 1) { cert->issuerUniqueID = elem; if(beg < end) - beg = Curl_getASN1Element(&elem, beg, end); + beg = getASN1Element(&elem, beg, end); } if(elem.tag == 2) { cert->subjectUniqueID = elem; if(beg < end) - beg = Curl_getASN1Element(&elem, beg, end); + beg = getASN1Element(&elem, beg, end); } if(elem.tag == 3) - Curl_getASN1Element(&cert->extensions, elem.beg, elem.end); + getASN1Element(&cert->extensions, elem.beg, elem.end); return 0; } @@ -785,12 +781,12 @@ static const char *dumpAlgo(curl_asn1Element *param, /* Get algorithm parameters and return algorithm name. */ - beg = Curl_getASN1Element(&oid, beg, end); + beg = getASN1Element(&oid, beg, end); param->header = NULL; param->tag = 0; param->beg = param->end = end; if(beg < end) - Curl_getASN1Element(param, beg, end); + getASN1Element(param, beg, end); return OID2str(oid.beg, oid.end, TRUE); } @@ -801,7 +797,7 @@ static void do_pubkey_field(struct Curl_easy *data, int certnum, /* Generate a certificate information record for the public key. */ - output = Curl_ASN1tostr(elem, 0); + output = ASN1tostr(elem, 0); if(output) { if(data->set.ssl.certinfo) Curl_ssl_push_certinfo(data, certnum, label, output); @@ -825,10 +821,10 @@ static void do_pubkey(struct Curl_easy *data, int certnum, /* Generate all information records for the public key. */ /* Get the public key (single element). */ - Curl_getASN1Element(&pk, pubkey->beg + 1, pubkey->end); + getASN1Element(&pk, pubkey->beg + 1, pubkey->end); if(strcasecompare(algo, "rsaEncryption")) { - p = Curl_getASN1Element(&elem, pk.beg, pk.end); + p = getASN1Element(&elem, pk.beg, pk.end); /* Compute key length. */ for(q = elem.beg; !*q && q < elem.end; q++) ; @@ -849,22 +845,22 @@ static void do_pubkey(struct Curl_easy *data, int certnum, } /* Generate coefficients. */ do_pubkey_field(data, certnum, "rsa(n)", &elem); - Curl_getASN1Element(&elem, p, pk.end); + getASN1Element(&elem, p, pk.end); do_pubkey_field(data, certnum, "rsa(e)", &elem); } else if(strcasecompare(algo, "dsa")) { - p = Curl_getASN1Element(&elem, param->beg, param->end); + p = getASN1Element(&elem, param->beg, param->end); do_pubkey_field(data, certnum, "dsa(p)", &elem); - p = Curl_getASN1Element(&elem, p, param->end); + p = getASN1Element(&elem, p, param->end); do_pubkey_field(data, certnum, "dsa(q)", &elem); - Curl_getASN1Element(&elem, p, param->end); + getASN1Element(&elem, p, param->end); do_pubkey_field(data, certnum, "dsa(g)", &elem); do_pubkey_field(data, certnum, "dsa(pub_key)", &pk); } else if(strcasecompare(algo, "dhpublicnumber")) { - p = Curl_getASN1Element(&elem, param->beg, param->end); + p = getASN1Element(&elem, param->beg, param->end); do_pubkey_field(data, certnum, "dh(p)", &elem); - Curl_getASN1Element(&elem, param->beg, param->end); + getASN1Element(&elem, param->beg, param->end); do_pubkey_field(data, certnum, "dh(g)", &elem); do_pubkey_field(data, certnum, "dh(pub_key)", &pk); } @@ -903,7 +899,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, return CURLE_OUT_OF_MEMORY; /* Subject. */ - ccp = Curl_DNtostr(&cert.subject); + ccp = DNtostr(&cert.subject); if(!ccp) return CURLE_OUT_OF_MEMORY; if(data->set.ssl.certinfo) @@ -913,7 +909,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, free((char *) ccp); /* Issuer. */ - ccp = Curl_DNtostr(&cert.issuer); + ccp = DNtostr(&cert.issuer); if(!ccp) return CURLE_OUT_OF_MEMORY; if(data->set.ssl.certinfo) @@ -937,7 +933,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, infof(data, " Version: %lu (0x%lx)\n", version + 1, version); /* Serial number. */ - ccp = Curl_ASN1tostr(&cert.serialNumber, 0); + ccp = ASN1tostr(&cert.serialNumber, 0); if(!ccp) return CURLE_OUT_OF_MEMORY; if(data->set.ssl.certinfo) @@ -958,7 +954,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, free((char *) ccp); /* Start Date. */ - ccp = Curl_ASN1tostr(&cert.notBefore, 0); + ccp = ASN1tostr(&cert.notBefore, 0); if(!ccp) return CURLE_OUT_OF_MEMORY; if(data->set.ssl.certinfo) @@ -968,7 +964,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, free((char *) ccp); /* Expire Date. */ - ccp = Curl_ASN1tostr(&cert.notAfter, 0); + ccp = ASN1tostr(&cert.notAfter, 0); if(!ccp) return CURLE_OUT_OF_MEMORY; if(data->set.ssl.certinfo) @@ -992,7 +988,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn, /* TODO: extensions. */ /* Signature. */ - ccp = Curl_ASN1tostr(&cert.signature, 0); + ccp = ASN1tostr(&cert.signature, 0); if(!ccp) return CURLE_OUT_OF_MEMORY; if(data->set.ssl.certinfo) @@ -1051,7 +1047,7 @@ static const char *checkOID(const char *beg, const char *end, /* Check if first ASN.1 element at `beg' is the given OID. Return a pointer in the source after the OID if found, else NULL. */ - ccp = Curl_getASN1Element(&e, beg, end); + ccp = getASN1Element(&e, beg, end); if(!ccp || e.tag != CURL_ASN1_OBJECT_IDENTIFIER) return (const char *) NULL; @@ -1110,19 +1106,19 @@ CURLcode Curl_verifyhost(struct connectdata *conn, /* Process extensions. */ for(p = cert.extensions.beg; p < cert.extensions.end && matched != 1;) { - p = Curl_getASN1Element(&ext, p, cert.extensions.end); + p = getASN1Element(&ext, p, cert.extensions.end); /* Check if extension is a subjectAlternativeName. */ ext.beg = checkOID(ext.beg, ext.end, sanOID); if(ext.beg) { - ext.beg = Curl_getASN1Element(&elem, ext.beg, ext.end); + ext.beg = getASN1Element(&elem, ext.beg, ext.end); /* Skip critical if present. */ if(elem.tag == CURL_ASN1_BOOLEAN) - ext.beg = Curl_getASN1Element(&elem, ext.beg, ext.end); + ext.beg = getASN1Element(&elem, ext.beg, ext.end); /* Parse the octet string contents: is a single sequence. */ - Curl_getASN1Element(&elem, elem.beg, elem.end); + getASN1Element(&elem, elem.beg, elem.end); /* Check all GeneralNames. */ for(q = elem.beg; matched != 1 && q < elem.end;) { - q = Curl_getASN1Element(&name, q, elem.end); + q = getASN1Element(&name, q, elem.end); switch(name.tag) { case 2: /* DNS name. */ len = utf8asn1str(&dnsname, CURL_ASN1_IA5_STRING, @@ -1162,9 +1158,9 @@ CURLcode Curl_verifyhost(struct connectdata *conn, /* we have to look to the last occurrence of a commonName in the distinguished one to get the most significant one. */ while(q < cert.subject.end) { - q = Curl_getASN1Element(&dn, q, cert.subject.end); + q = getASN1Element(&dn, q, cert.subject.end); for(p = dn.beg; p < dn.end;) { - p = Curl_getASN1Element(&elem, p, dn.end); + p = getASN1Element(&elem, p, dn.end); /* We have a DN's AttributeTypeAndValue: check it in case it's a CN. */ elem.beg = checkOID(elem.beg, elem.end, cnOID); if(elem.beg) @@ -1173,7 +1169,7 @@ CURLcode Curl_verifyhost(struct connectdata *conn, } /* Check the CN if found. */ - if(!Curl_getASN1Element(&elem, name.beg, name.end)) + if(!getASN1Element(&elem, name.beg, name.end)) failf(data, "SSL: unable to obtain common name from peer certificate"); else { len = utf8asn1str(&dnsname, elem.tag, elem.beg, elem.end); |