diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPackComponent.cmake | 18 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 1137 | ||||
-rw-r--r-- | Modules/FetchContent.cmake | 6 | ||||
-rw-r--r-- | Modules/FindGLUT.cmake | 4 | ||||
-rw-r--r-- | Modules/FindPkgConfig.cmake | 140 | ||||
-rw-r--r-- | Modules/FindVulkan.cmake | 649 | ||||
-rw-r--r-- | Modules/FindZLIB.cmake | 22 | ||||
-rw-r--r-- | Modules/FortranCInterface/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackNuGet.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 2 |
10 files changed, 1525 insertions, 460 deletions
diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index 1f8c38c..8ca9f28 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -327,32 +327,34 @@ OS X. if(NOT CPackComponent_CMake_INCLUDED) set(CPackComponent_CMake_INCLUDED 1) -# Macro that appends a SET command for the given variable name (var) -# to the macro named strvar, but only if the variable named "var" +# Function that appends a SET command for the given variable name (var) +# to the string named strvar, but only if the variable named "var" # has been defined. The string will eventually be appended to a CPack # configuration file. -macro(cpack_append_variable_set_command var strvar) +function(cpack_append_variable_set_command var strvar) if (DEFINED ${var}) string(APPEND ${strvar} "set(${var}") foreach(APPENDVAL ${${var}}) string(APPEND ${strvar} " ${APPENDVAL}") endforeach() string(APPEND ${strvar} ")\n") + set(${strvar} "${${strvar}}" PARENT_SCOPE) endif () -endmacro() +endfunction() -# Macro that appends a SET command for the given variable name (var) -# to the macro named strvar, but only if the variable named "var" +# Function that appends a SET command for the given variable name (var) +# to the string named strvar, but only if the variable named "var" # has been defined and is a string. The string will eventually be # appended to a CPack configuration file. -macro(cpack_append_string_variable_set_command var strvar) +function(cpack_append_string_variable_set_command var strvar) if (DEFINED ${var}) list(LENGTH ${var} CPACK_APP_VALUE_LEN) if(${CPACK_APP_VALUE_LEN} EQUAL 1) string(APPEND ${strvar} "set(${var} \"${${var}}\")\n") endif() + set(${strvar} "${${strvar}}" PARENT_SCOPE) endif () -endmacro() +endfunction() # Macro that appends a SET command for the given list variable name (var) # to the macro named strvar, but only if the variable named "var" diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 707de88..e19b7c9 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -244,9 +244,9 @@ External Project Definition .. versionadded:: 3.11 Specify whether the ``.netrc`` file is to be used for operation. - If this option is not specified, the value of the :variable:`CMAKE_NETRC` - variable will be used instead (see :command:`file(DOWNLOAD)`) - Valid levels are: + If this option is not specified, the value of the + :variable:`CMAKE_NETRC` variable will be used instead + (see :command:`file(DOWNLOAD)`). Valid levels are: ``IGNORED`` The ``.netrc`` file is ignored. @@ -386,8 +386,9 @@ External Project Definition override the default strategy. This variable should not be set by a project, it is intended for the user to set. It is primarily intended for use in continuous integration scripts to ensure that when history - is rewritten on a remote branch, the build doesn't end up with unintended - changes or failed builds resulting from conflicts during rebase operations. + is rewritten on a remote branch, the build doesn't end up with + unintended changes or failed builds resulting from conflicts during + rebase operations. *Subversion* ``SVN_REPOSITORY <url>`` @@ -527,7 +528,8 @@ External Project Definition :manual:`CMake Options <cmake(1)>`). .. versionadded:: 3.3 - Arguments may use :manual:`generator expressions <cmake-generator-expressions(7)>`. + Arguments may use + :manual:`generator expressions <cmake-generator-expressions(7)>`. ``CMAKE_CACHE_ARGS <arg>...`` This is an alternate way of specifying cache variables where command line @@ -538,7 +540,8 @@ External Project Definition using the :manual:`cmake -C <cmake(1)>` command line option. .. versionadded:: 3.3 - Arguments may use :manual:`generator expressions <cmake-generator-expressions(7)>`. + Arguments may use + :manual:`generator expressions <cmake-generator-expressions(7)>`. ``CMAKE_CACHE_DEFAULT_ARGS <arg>...`` .. versionadded:: 3.2 @@ -551,7 +554,7 @@ External Project Definition build directory or re-uses previous build contents. .. versionadded:: 3.15 - If the CMake generator is the ``Green Hills MULTI`` and not overridden then + If the CMake generator is the ``Green Hills MULTI`` and not overridden, the original project's settings for the GHS toolset and target system customization cache variables are propagated into the external project. @@ -1017,9 +1020,9 @@ control needed to implement such step-level capabilities. .. versionadded:: 3.19 If :policy:`CMP0114` is set to ``NEW``, step targets are fully responsible - for holding the custom commands implementing their steps. The primary target - created by ``ExternalProject_Add`` depends on the step targets, and the - step targets depend on each other. The target-level dependencies match + for holding the custom commands implementing their steps. The primary + target created by ``ExternalProject_Add`` depends on the step targets, and + the step targets depend on each other. The target-level dependencies match the file-level dependencies used by the custom commands for each step. The targets for steps created with :command:`ExternalProject_Add_Step`'s ``INDEPENDENT`` option do not depend on the external targets specified @@ -1031,16 +1034,16 @@ control needed to implement such step-level capabilities. * A deprecated ``NO_DEPENDS`` option may be specified immediately after the ``<name>`` and before the first step. - If the ``NO_DEPENDS`` option is specified, the step target will not depend on - the dependencies of the external project (i.e. on any dependencies of the + If the ``NO_DEPENDS`` option is specified, the step target will not depend + on the dependencies of the external project (i.e. on any dependencies of the ``<name>`` custom target created by :command:`ExternalProject_Add`). This is - usually safe for the ``download``, ``update`` and ``patch`` steps, since they - do not typically require that the dependencies are updated and built. Using - ``NO_DEPENDS`` for any of the other pre-defined steps, however, may break - parallel builds. Only use ``NO_DEPENDS`` where it is certain that the named - steps genuinely do not have dependencies. For custom steps, consider whether - or not the custom commands require the dependencies to be configured, built - and installed. + usually safe for the ``download``, ``update`` and ``patch`` steps, since + they do not typically require that the dependencies are updated and built. + Using ``NO_DEPENDS`` for any of the other pre-defined steps, however, may + break parallel builds. Only use ``NO_DEPENDS`` where it is certain that the + named steps genuinely do not have dependencies. For custom steps, consider + whether or not the custom commands require the dependencies to be + configured, built and installed. * The ``INDEPENDENT_STEP_TARGETS`` option for :command:`ExternalProject_Add`, or the ``EP_INDEPENDENT_STEP_TARGETS`` directory property, tells the @@ -1190,7 +1193,13 @@ macro(_ep_get_hash_regex out_var) set(${out_var} "^(${${out_var}})=([0-9A-Fa-f]+)$") endmacro() -function(_ep_parse_arguments f keywords name ns args) +function(_ep_parse_arguments + f + keywords + name + ns + args +) # Transfer the arguments to this function into target properties for the # new custom target we just added so that we can set up all the build steps # correctly based on target properties. @@ -1206,7 +1215,8 @@ function(_ep_parse_arguments f keywords name ns args) set(is_value 1) if(arg MATCHES "^[A-Z][A-Z0-9_][A-Z0-9_]+$" AND - NOT (("x${arg}x" STREQUAL "x${key}x") AND ("x${key}x" STREQUAL "xCOMMANDx")) AND + NOT (("x${arg}x" STREQUAL "x${key}x") AND + ("x${key}x" STREQUAL "xCOMMANDx")) AND NOT arg MATCHES "^(TRUE|FALSE)$") if(arg IN_LIST keywords) set(is_value 0) @@ -1229,7 +1239,9 @@ function(_ep_parse_arguments f keywords name ns args) endif() else() # Missing Keyword - message(AUTHOR_WARNING "value '${arg}' with no previous keyword in ${f}") + message(AUTHOR_WARNING + "value '${arg}' with no previous keyword in ${f}" + ) endif() else() set(key "${arg}") @@ -1238,63 +1250,31 @@ function(_ep_parse_arguments f keywords name ns args) endfunction() -define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED - BRIEF_DOCS "Base directory for External Project storage." - FULL_DOCS - "See documentation of the ExternalProject_Add() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED - BRIEF_DOCS "Top prefix for External Project storage." - FULL_DOCS - "See documentation of the ExternalProject_Add() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED - BRIEF_DOCS - "List of ExternalProject steps that automatically get corresponding targets" - FULL_DOCS - "These targets will be dependent on the main target dependencies. " - "See documentation of the ExternalProject_Add_StepTargets() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED - BRIEF_DOCS - "List of ExternalProject steps that automatically get corresponding targets" - FULL_DOCS - "These targets will not be dependent on the main target dependencies. " - "See documentation of the ExternalProject_Add_StepTargets() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED - BRIEF_DOCS "Never update automatically from the remote repo." - FULL_DOCS - "See documentation of the ExternalProject_Add() function in the " - "ExternalProject module." - ) +define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED) +define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED) +define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED) +define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED) +define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED) function(_ep_write_gitclone_script - script_filename - source_dir - git_EXECUTABLE - git_repository - git_tag - git_remote_name - init_submodules - git_submodules_recurse - git_submodules - git_shallow - git_progress - git_config - src_name - work_dir - gitclone_infofile - gitclone_stampfile - tls_verify) + script_filename + source_dir + git_EXECUTABLE + git_repository + git_tag + git_remote_name + init_submodules + git_submodules_recurse + git_submodules + git_shallow + git_progress + git_config + src_name + work_dir + gitclone_infofile + gitclone_stampfile + tls_verify +) if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5) # Use `git checkout <tree-ish> --` to avoid ambiguity with a local path. @@ -1309,7 +1289,8 @@ function(_ep_write_gitclone_script message(FATAL_ERROR "Tag for git checkout should not be empty.") endif() - if(GIT_VERSION_STRING VERSION_LESS 2.20 OR 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING) + if(GIT_VERSION_STRING VERSION_LESS 2.20 OR + 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING) set(git_clone_options "--no-checkout") else() set(git_clone_options) @@ -1337,7 +1318,8 @@ function(_ep_write_gitclone_script # disable cert checking if explicitly told not to do it if(NOT "x${tls_verify}" STREQUAL "x" AND NOT tls_verify) set(git_options - -c http.sslVerify=false) + -c http.sslVerify=false + ) endif() string (REPLACE ";" " " git_options "${git_options}") @@ -1349,15 +1331,16 @@ function(_ep_write_gitclone_script endfunction() function(_ep_write_hgclone_script - script_filename - source_dir - hg_EXECUTABLE - hg_repository - hg_tag - src_name - work_dir - hgclone_infofile - hgclone_stampfile) + script_filename + source_dir + hg_EXECUTABLE + hg_repository + hg_tag + src_name + work_dir + hgclone_infofile + hgclone_stampfile +) if("${hg_tag}" STREQUAL "") message(FATAL_ERROR "Tag for hg checkout should not be empty.") @@ -1372,16 +1355,17 @@ endfunction() function(_ep_write_gitupdate_script - script_filename - git_EXECUTABLE - git_tag - git_remote_name - init_submodules - git_submodules_recurse - git_submodules - git_repository - work_dir - git_update_strategy) + script_filename + git_EXECUTABLE + git_tag + git_remote_name + init_submodules + git_submodules_recurse + git_submodules + git_repository + work_dir + git_update_strategy +) if("${git_tag}" STREQUAL "") message(FATAL_ERROR "Tag for git checkout should not be empty.") @@ -1403,20 +1387,20 @@ function(_ep_write_gitupdate_script endfunction() function(_ep_write_downloadfile_script - script_filename - REMOTE - LOCAL - timeout - inactivity_timeout - no_progress - hash - tls_verify - tls_cainfo - userpwd - http_headers - netrc - netrc_file) - + script_filename + REMOTE + LOCAL + timeout + inactivity_timeout + no_progress + hash + tls_verify + tls_cainfo + userpwd + http_headers + netrc + netrc_file +) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -1499,9 +1483,8 @@ function(_ep_write_downloadfile_script set(HTTP_HEADERS_ARGS "") if(NOT http_headers STREQUAL "") foreach(header ${http_headers}) - set( - HTTP_HEADERS_ARGS - "HTTPHEADER \"${header}\"\n ${HTTP_HEADERS_ARGS}" + string(PREPEND HTTP_HEADERS_ARGS + "HTTPHEADER \"${header}\"\n " ) endforeach() endif() @@ -1519,13 +1502,17 @@ function(_ep_write_downloadfile_script # * USERPWD_ARGS # * HTTP_HEADERS_ARGS configure_file( - "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/download.cmake.in" - "${script_filename}" - @ONLY + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/download.cmake.in" + "${script_filename}" + @ONLY ) endfunction() -function(_ep_write_verifyfile_script script_filename LOCAL hash) +function(_ep_write_verifyfile_script + script_filename + LOCAL + hash +) _ep_get_hash_regex(_ep_hash_regex) if("${hash}" MATCHES "${_ep_hash_regex}") set(ALGO "${CMAKE_MATCH_1}") @@ -1540,17 +1527,23 @@ function(_ep_write_verifyfile_script script_filename LOCAL hash) # * EXPECT_VALUE # * LOCAL configure_file( - "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/verify.cmake.in" - "${script_filename}" - @ONLY + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/verify.cmake.in" + "${script_filename}" + @ONLY ) endfunction() -function(_ep_write_extractfile_script script_filename name filename directory options) +function(_ep_write_extractfile_script + script_filename + name + filename + directory options +) set(args "") - if(filename MATCHES "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$") + if(filename MATCHES + "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$") set(args xfz) endif() @@ -1559,8 +1552,10 @@ function(_ep_write_extractfile_script script_filename name filename directory op endif() if(args STREQUAL "") - message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip") - return() + message(FATAL_ERROR + "Do not know how to extract '${filename}' -- known types are: " + ".7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip" + ) endif() configure_file( @@ -1604,7 +1599,8 @@ function(_ep_set_directories name) get_property(have_binary_dir TARGET ${name} PROPERTY _EP_BINARY_DIR SET) if(have_binary_dir) message(FATAL_ERROR - "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!") + "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!" + ) endif() endif() set(top "${CMAKE_CURRENT_BINARY_DIR}") @@ -1640,7 +1636,8 @@ function(_ep_set_directories name) set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "") elseif(IS_ABSOLUTE "${source_subdir}") message(FATAL_ERROR - "External project ${name} has non-relative SOURCE_SUBDIR!") + "External project ${name} has non-relative SOURCE_SUBDIR!" + ) else() # Prefix with a slash so that when appended to the source directory, it # behaves as expected. @@ -1650,9 +1647,13 @@ function(_ep_set_directories name) if(build_in_source) get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR) if(source_subdir) - set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}/${source_subdir}") + set_property(TARGET ${name} PROPERTY + _EP_BINARY_DIR "${source_dir}/${source_subdir}" + ) else() - set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}") + set_property(TARGET ${name} PROPERTY + _EP_BINARY_DIR "${source_dir}" + ) endif() endif() @@ -1679,7 +1680,16 @@ macro(_ep_replace_location_tags target_name) set(vars ${ARGN}) foreach(var ${vars}) if(${var}) - foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOAD_DIR DOWNLOADED_FILE LOG_DIR) + foreach(dir + SOURCE_DIR + SOURCE_SUBDIR + BINARY_DIR + INSTALL_DIR + TMP_DIR + DOWNLOAD_DIR + DOWNLOADED_FILE + LOG_DIR + ) get_property(val TARGET ${target_name} PROPERTY _EP_${dir}) string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}") endforeach() @@ -1688,7 +1698,11 @@ macro(_ep_replace_location_tags target_name) endmacro() -function(_ep_command_line_to_initial_cache var args force) +function(_ep_command_line_to_initial_cache + var + args + force +) set(script_initial_cache "") set(regex "^([^:]+):([^=]+)=(.*)$") set(setArg "") @@ -1701,7 +1715,9 @@ function(_ep_command_line_to_initial_cache var args force) set(line "${CMAKE_MATCH_1}") if(NOT "${setArg}" STREQUAL "") # This is required to build up lists in variables, or complete an entry - string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") + string(APPEND setArg + "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})" + ) string(APPEND script_initial_cache "\n${setArg}") set(accumulator "") set(setArg "") @@ -1721,14 +1737,20 @@ function(_ep_command_line_to_initial_cache var args force) endforeach() # Catch the final line of the args if(NOT "${setArg}" STREQUAL "") - string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") + string(APPEND setArg + "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})" + ) string(APPEND script_initial_cache "\n${setArg}") endif() set(${var} ${script_initial_cache} PARENT_SCOPE) endfunction() -function(_ep_write_initial_cache target_name script_filename script_initial_cache) +function(_ep_write_initial_cache + target_name + script_filename + script_initial_cache +) # Write out values into an initial cache, that will be passed to CMake with -C # Replace location tags. _ep_replace_location_tags(${target_name} script_initial_cache) @@ -1756,7 +1778,10 @@ function(ExternalProject_Get_Property name) endfunction() -function(_ep_get_configure_command_id name cfg_cmd_id_var) +function(_ep_get_configure_command_id + name + cfg_cmd_id_var +) get_target_property(cmd ${name} _EP_CONFIGURE_COMMAND) if(cmd STREQUAL "") @@ -1782,7 +1807,11 @@ function(_ep_get_configure_command_id name cfg_cmd_id_var) endfunction() -function(_ep_get_build_command name step cmd_var) +function(_ep_get_build_command + name + step + cmd_var +) set(cmd "") set(args) _ep_get_configure_command_id(${name} cfg_cmd_id) @@ -1820,8 +1849,10 @@ function(_ep_get_build_command name step cmd_var) # BUILD_COMMAND to change the default command instead, but for # compatibility honor the value. set(config ${CMAKE_CFG_INTDIR}) - message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n" - "To get a non-default build command, use the BUILD_COMMAND option.") + message(AUTHOR_WARNING + "CMAKE_CFG_INTDIR should not be set by project code.\n" + "To get a non-default build command, use the BUILD_COMMAND option." + ) else() set(config $<CONFIG>) endif() @@ -1869,7 +1900,11 @@ function(_ep_get_build_command name step cmd_var) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction() -function(_ep_write_log_script name step cmd_var) +function(_ep_write_log_script + name + step + cmd_var +) ExternalProject_Get_Property(${name} log_dir) ExternalProject_Get_Property(${name} stamp_dir) set(command "${${cmd_var}}") @@ -1936,15 +1971,29 @@ endif() endif() endforeach() string(APPEND code "set(command \"${cmd}\")${code_execute_process}") - file(GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" CONTENT "${code}") - set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake) + file(GENERATE + OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" + CONTENT "${code}" + ) + set(command + ${CMAKE_COMMAND} + "-Dmake=\${make}" + "-Dconfig=\${config}" + -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake + ) endif() # Wrap the command in a script to log output to files. set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake) set(logbase ${log_dir}/${name}-${step}) - get_property(log_merged TARGET ${name} PROPERTY _EP_LOG_MERGED_STDOUTERR) - get_property(log_output_on_failure TARGET ${name} PROPERTY _EP_LOG_OUTPUT_ON_FAILURE) + get_property(log_merged + TARGET ${name} + PROPERTY _EP_LOG_MERGED_STDOUTERR + ) + get_property(log_output_on_failure + TARGET ${name} + PROPERTY _EP_LOG_OUTPUT_ON_FAILURE + ) if (log_merged) set(stdout_log "${logbase}.log") set(stderr_log "${logbase}.log") @@ -1965,7 +2014,7 @@ execute_process( RESULT_VARIABLE result OUTPUT_FILE \"\${stdout_log}\" ERROR_FILE \"\${stderr_log}\" - ) +) macro(read_up_to_max_size log_file output_var) file(SIZE \${log_file} determined_size) set(max_size 10240) @@ -2032,7 +2081,11 @@ function(_ep_get_configuration_subdir_suffix suffix_var) endfunction() -function(_ep_get_step_stampfile name step stampfile_var) +function(_ep_get_step_stampfile + name + step + stampfile_var +) ExternalProject_Get_Property(${name} stamp_dir) _ep_get_configuration_subdir_suffix(cfgdir) @@ -2042,7 +2095,10 @@ function(_ep_get_step_stampfile name step stampfile_var) endfunction() -function(_ep_get_complete_stampfile name stampfile_var) +function(_ep_get_complete_stampfile + name + stampfile_var +) set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles) _ep_get_configuration_subdir_suffix(cfgdir) set(stampfile "${cmf_dir}${cfgdir}/${name}-complete") @@ -2051,7 +2107,11 @@ function(_ep_get_complete_stampfile name stampfile_var) endfunction() -function(_ep_step_add_target name step no_deps) +function(_ep_step_add_target + name + step + no_deps +) if(TARGET ${name}-${step}) return() endif() @@ -2063,16 +2123,20 @@ function(_ep_step_add_target name step no_deps) # we need CMP0113 NEW behavior. cmake_policy(SET CMP0113 NEW) endif() - add_custom_target(${name}-${step} - DEPENDS ${stamp_file}) + add_custom_target(${name}-${step} DEPENDS ${stamp_file}) cmake_policy(POP) - set_property(TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP 1) - set_property(TARGET ${name}-${step} PROPERTY LABELS ${name}) - set_property(TARGET ${name}-${step} PROPERTY FOLDER "ExternalProjectTargets/${name}") + set_target_properties(${name}-${step} PROPERTIES + _EP_IS_EXTERNAL_PROJECT_STEP 1 + LABELS "${name}" + FOLDER "ExternalProjectTargets/${name}" + ) if(cmp0114 STREQUAL "NEW") # Add target-level dependencies for the step. - get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + get_property(exclude_from_main + TARGET ${name} + PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN + ) if(NOT exclude_from_main) add_dependencies(${name} ${name}-${step}) endif() @@ -2082,7 +2146,9 @@ function(_ep_step_add_target name step no_deps) get_property(independent TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT) else() if(no_deps AND "${step}" MATCHES "^(configure|build|install|test)$") - message(AUTHOR_WARNING "Using NO_DEPENDS for \"${step}\" step might break parallel builds") + message(AUTHOR_WARNING + "Using NO_DEPENDS for \"${step}\" step might break parallel builds" + ) endif() set(independent ${no_deps}) endif() @@ -2097,12 +2163,25 @@ function(_ep_step_add_target name step no_deps) endfunction() -function(_ep_step_add_target_dependencies name step node) - get_property(dependees TARGET ${name} PROPERTY _EP_${node}_INTERNAL_DEPENDEES) +function(_ep_step_add_target_dependencies + name + step + node +) + get_property(dependees + TARGET ${name} + PROPERTY _EP_${node}_INTERNAL_DEPENDEES + ) list(REMOVE_DUPLICATES dependees) foreach(dependee IN LISTS dependees) - get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) - get_property(dependee_dependers TARGET ${name} PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS) + get_property(exclude_from_main + TARGET ${name} + PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN + ) + get_property(dependee_dependers + TARGET ${name} + PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS + ) if(exclude_from_main OR dependee_dependers MATCHES ";") # The step on which our step target depends itself has # dependents in multiple targes. It needs a step target too @@ -2119,8 +2198,15 @@ function(_ep_step_add_target_dependencies name step node) endfunction() -function(_ep_step_add_target_dependents name step node) - get_property(dependers TARGET ${name} PROPERTY _EP_${node}_INTERNAL_DEPENDERS) +function(_ep_step_add_target_dependents + name + step + node +) + get_property(dependers + TARGET ${name} + PROPERTY _EP_${node}_INTERNAL_DEPENDERS + ) list(REMOVE_DUPLICATES dependers) foreach(depender IN LISTS dependers) if(TARGET ${name}-${depender}) @@ -2147,7 +2233,7 @@ function(ExternalProject_Add_StepTargets name) "The 'NO_DEPENDS' option is no longer allowed. " "It has been superseded by the per-step 'INDEPENDENT' option. " "See policy CMP0114." - ) + ) endif() elseif(cmp0114 STREQUAL "") cmake_policy(GET_WARNING CMP0114 _cmp0114_warning) @@ -2155,11 +2241,11 @@ function(ExternalProject_Add_StepTargets name) "ExternalProject target '${name}' would depend on the targets for " "step(s) '${steps}' under policy CMP0114, but this is being left out " "for compatibility since the policy is not set." - ) + ) if(no_deps) - string(APPEND _cmp0114_warning - " Also, the NO_DEPENDS option is deprecated in favor of policy CMP0114." - ) + string(APPEND _cmp0114_warning " " + "Also, the NO_DEPENDS option is deprecated in favor of policy CMP0114." + ) endif() message(AUTHOR_WARNING "${_cmp0114_warning}") endif() @@ -2188,38 +2274,60 @@ function(ExternalProject_Add_Step name step) LOG USES_TERMINAL ) - _ep_parse_arguments(ExternalProject_Add_Step "${keywords}" - ${name} _EP_${step}_ "${ARGN}") + _ep_parse_arguments( + ExternalProject_Add_Step + "${keywords}" + ${name} + _EP_${step}_ + "${ARGN}" + ) - get_property(independent TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT) + get_property(independent + TARGET ${name} + PROPERTY _EP_${step}_INDEPENDENT + ) if(independent STREQUAL "") set(independent FALSE) - set_property(TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT "${independent}") + set_property(TARGET ${name} PROPERTY + _EP_${step}_INDEPENDENT "${independent}" + ) endif() - get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + get_property(exclude_from_main + TARGET ${name} + PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN + ) if(NOT exclude_from_main) add_custom_command(APPEND OUTPUT ${complete_stamp_file} DEPENDS ${stamp_file} - ) + ) endif() # Steps depending on this step. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS) - set_property(TARGET ${name} APPEND PROPERTY _EP_${step}_INTERNAL_DEPENDERS ${dependers}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${step}_INTERNAL_DEPENDERS ${dependers} + ) foreach(depender IN LISTS dependers) - set_property(TARGET ${name} APPEND PROPERTY _EP_${depender}_INTERNAL_DEPENDEES ${step}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${depender}_INTERNAL_DEPENDEES ${step} + ) _ep_get_step_stampfile(${name} ${depender} depender_stamp_file) add_custom_command(APPEND OUTPUT ${depender_stamp_file} DEPENDS ${stamp_file} - ) + ) if(cmp0114 STREQUAL "NEW" AND NOT independent) - get_property(dep_independent TARGET ${name} PROPERTY _EP_${depender}_INDEPENDENT) + get_property(dep_independent + TARGET ${name} + PROPERTY _EP_${depender}_INDEPENDENT + ) if(dep_independent) - message(FATAL_ERROR "ExternalProject '${name}' step '${depender}' is marked INDEPENDENT " - "but depends on step '${step}' that is not marked INDEPENDENT.") + message(FATAL_ERROR + "ExternalProject '${name}' step '${depender}' is marked INDEPENDENT " + "but depends on step '${step}' that is not marked INDEPENDENT." + ) endif() endif() endforeach() @@ -2232,16 +2340,25 @@ function(ExternalProject_Add_Step name step) # Dependencies on steps. get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES) - set_property(TARGET ${name} APPEND PROPERTY _EP_${step}_INTERNAL_DEPENDEES ${dependees}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${step}_INTERNAL_DEPENDEES ${dependees} + ) foreach(dependee IN LISTS dependees) - set_property(TARGET ${name} APPEND PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS ${step}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${dependee}_INTERNAL_DEPENDERS ${step} + ) _ep_get_step_stampfile(${name} ${dependee} dependee_stamp_file) list(APPEND depends ${dependee_stamp_file}) if(cmp0114 STREQUAL "NEW" AND independent) - get_property(dep_independent TARGET ${name} PROPERTY _EP_${dependee}_INDEPENDENT) + get_property(dep_independent + TARGET ${name} + PROPERTY _EP_${dependee}_INDEPENDENT + ) if(NOT dep_independent) - message(FATAL_ERROR "ExternalProject '${name}' step '${step}' is marked INDEPENDENT " - "but depends on step '${dependee}' that is not marked INDEPENDENT.") + message(FATAL_ERROR + "ExternalProject '${name}' step '${step}' is marked INDEPENDENT " + "but depends on step '${dependee}' that is not marked INDEPENDENT." + ) endif() endif() endforeach() @@ -2253,25 +2370,47 @@ function(ExternalProject_Add_Step name step) else() set(comment "No ${step} step for '${name}'") endif() - get_property(work_dir TARGET ${name} PROPERTY _EP_${step}_WORKING_DIRECTORY) + get_property(work_dir + TARGET ${name} + PROPERTY _EP_${step}_WORKING_DIRECTORY + ) # Replace list separators. - get_property(sep TARGET ${name} PROPERTY _EP_LIST_SEPARATOR) + get_property(sep + TARGET ${name} + PROPERTY _EP_LIST_SEPARATOR + ) if(sep AND command) string(REPLACE "${sep}" "\\;" command "${command}") endif() # Replace location tags. - _ep_replace_location_tags(${name} comment command work_dir byproducts) + _ep_replace_location_tags( + ${name} + comment + command + work_dir + byproducts + ) # Custom comment? - get_property(comment_set TARGET ${name} PROPERTY _EP_${step}_COMMENT SET) + get_property(comment_set + TARGET ${name} + PROPERTY _EP_${step}_COMMENT + SET + ) if(comment_set) - get_property(comment TARGET ${name} PROPERTY _EP_${step}_COMMENT) + get_property(comment + TARGET ${name} + PROPERTY _EP_${step}_COMMENT + ) endif() # Uses terminal? - get_property(uses_terminal TARGET ${name} PROPERTY _EP_${step}_USES_TERMINAL) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_${step}_USES_TERMINAL + ) if(uses_terminal) set(uses_terminal USES_TERMINAL) else() @@ -2279,7 +2418,10 @@ function(ExternalProject_Add_Step name step) endif() # Run every time? - get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS) + get_property(always + TARGET ${name} + PROPERTY _EP_${step}_ALWAYS + ) if(always) set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1) set(touch) @@ -2287,7 +2429,9 @@ function(ExternalProject_Add_Step name step) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) - string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}") + string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" + stamp_file_config "${stamp_file}" + ) file(REMOVE ${stamp_file_config}) endforeach() else() @@ -2332,9 +2476,15 @@ function(ExternalProject_Add_Step name step) set_property(TARGET ${name} APPEND PROPERTY _EP_STEPS ${step}) # Add custom "step target"? - get_property(step_targets TARGET ${name} PROPERTY _EP_STEP_TARGETS) + get_property(step_targets + TARGET ${name} + PROPERTY _EP_STEP_TARGETS + ) if(NOT step_targets) - get_property(step_targets DIRECTORY PROPERTY EP_STEP_TARGETS) + get_property(step_targets + DIRECTORY + PROPERTY EP_STEP_TARGETS + ) endif() foreach(st ${step_targets}) if("${st}" STREQUAL "${step}") @@ -2343,31 +2493,43 @@ function(ExternalProject_Add_Step name step) endif() endforeach() - get_property(independent_step_targets TARGET ${name} PROPERTY _EP_INDEPENDENT_STEP_TARGETS) + get_property(independent_step_targets + TARGET ${name} PROPERTY + _EP_INDEPENDENT_STEP_TARGETS + ) if(NOT independent_step_targets) - get_property(independent_step_targets DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS) + get_property(independent_step_targets + DIRECTORY + PROPERTY EP_INDEPENDENT_STEP_TARGETS + ) endif() if(cmp0114 STREQUAL "NEW") if(independent_step_targets) message(FATAL_ERROR - "ExternalProject '${name}' option 'INDEPENDENT_STEP_TARGETS' is set to\n" - " ${independent_step_targets}\n" + "ExternalProject '${name}' option 'INDEPENDENT_STEP_TARGETS' is set to" + "\n ${independent_step_targets}\n" "but the option is no longer allowed. " "It has been superseded by the per-step 'INDEPENDENT' option. " "See policy CMP0114." - ) + ) endif() else() if(independent_step_targets AND cmp0114 STREQUAL "") - get_property(warned TARGET ${name} PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS) + get_property(warned + TARGET ${name} + PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS + ) if(NOT warned) - set_property(TARGET ${name} PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS 1) + set_property(TARGET ${name} PROPERTY + _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS 1 + ) cmake_policy(GET_WARNING CMP0114 _cmp0114_warning) - string(APPEND _cmp0114_warning "\n" - "ExternalProject '${name}' option INDEPENDENT_STEP_TARGETS is set to\n" - " ${independent_step_targets}\n" + string(APPEND _cmp0114_warning + "\n" + "ExternalProject '${name}' option INDEPENDENT_STEP_TARGETS is set to" + "\n ${independent_step_targets}\n" "but the option is deprecated in favor of policy CMP0114." - ) + ) message(AUTHOR_WARNING "${_cmp0114_warning}") endif() endif() @@ -2386,33 +2548,51 @@ function(ExternalProject_Add_StepDependencies name step) # Sanity checks on "name" and "step". if(NOT TARGET ${name}) - message(FATAL_ERROR "Cannot find target \"${name}\". Perhaps it has not yet been created using ExternalProject_Add.") + message(FATAL_ERROR + "Cannot find target \"${name}\". Perhaps it has not yet been created " + "using ExternalProject_Add." + ) endif() get_property(type TARGET ${name} PROPERTY TYPE) if(NOT type STREQUAL "UTILITY") - message(FATAL_ERROR "Target \"${name}\" was not generated by ExternalProject_Add.") + message(FATAL_ERROR + "Target \"${name}\" was not generated by ExternalProject_Add." + ) endif() get_property(is_ep TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT) if(NOT is_ep) - message(FATAL_ERROR "Target \"${name}\" was not generated by ExternalProject_Add.") + message(FATAL_ERROR + "Target \"${name}\" was not generated by ExternalProject_Add." + ) endif() get_property(steps TARGET ${name} PROPERTY _EP_STEPS) list(FIND steps ${step} is_step) if(is_step LESS 0) - message(FATAL_ERROR "External project \"${name}\" does not have a step \"${step}\".") + message(FATAL_ERROR + "External project \"${name}\" does not have a step \"${step}\"." + ) endif() if(TARGET ${name}-${step}) get_property(type TARGET ${name}-${step} PROPERTY TYPE) if(NOT type STREQUAL "UTILITY") - message(FATAL_ERROR "Target \"${name}-${step}\" was not generated by ExternalProject_Add_StepTargets.") + message(FATAL_ERROR + "Target \"${name}-${step}\" was not generated by " + "ExternalProject_Add_StepTargets." + ) endif() - get_property(is_ep_step TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP) + get_property(is_ep_step + TARGET ${name}-${step} + PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP + ) if(NOT is_ep_step) - message(FATAL_ERROR "Target \"${name}-${step}\" was not generated by ExternalProject_Add_StepTargets.") + message(FATAL_ERROR + "Target \"${name}-${step}\" was not generated by " + "ExternalProject_Add_StepTargets." + ) endif() endif() @@ -2422,7 +2602,8 @@ function(ExternalProject_Add_StepDependencies name step) foreach(dep ${dependencies}) add_custom_command(APPEND OUTPUT ${stamp_file} - DEPENDS ${dep}) + DEPENDS ${dep} + ) if(TARGET ${name}-${step}) foreach(dep ${dependencies}) add_dependencies(${name}-${step} ${dep}) @@ -2455,14 +2636,21 @@ function(_ep_is_dir_empty dir empty_var) endfunction() function(_ep_get_git_submodules_recurse git_submodules_recurse) - # Checks for GIT_SUBMODULES_RECURSE property - # Default is ON, which sets git_submodules_recurse output variable to "--recursive" - # Otherwise, the output variable is set to an empty value "" - get_property(git_submodules_recurse_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE SET) + # Checks for GIT_SUBMODULES_RECURSE property. Default is ON, which sets + # git_submodules_recurse output variable to "--recursive". Otherwise, the + # output variable is set to an empty value "". + get_property(git_submodules_recurse_set + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES_RECURSE + SET + ) if(NOT git_submodules_recurse_set) set(recurseFlag "--recursive") else() - get_property(git_submodules_recurse_value TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE) + get_property(git_submodules_recurse_value + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES_RECURSE + ) if(git_submodules_recurse_value) set(recurseFlag "--recursive") else() @@ -2473,13 +2661,21 @@ function(_ep_get_git_submodules_recurse git_submodules_recurse) # The git submodule update '--recursive' flag requires git >= v1.6.5 if(recurseFlag AND GIT_VERSION_STRING VERSION_LESS 1.6.5) - message(FATAL_ERROR "error: git version 1.6.5 or later required for --recursive flag with 'git submodule ...': GIT_VERSION_STRING='${GIT_VERSION_STRING}'") + message(FATAL_ERROR + "git version 1.6.5 or later required for --recursive flag with " + "'git submodule ...': GIT_VERSION_STRING='${GIT_VERSION_STRING}'" + ) endif() endfunction() function(_ep_add_download_command name) - ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir) + ExternalProject_Get_Property(${name} + source_dir + stamp_dir + download_dir + tmp_dir + ) get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET) get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND) @@ -2517,7 +2713,14 @@ function(_ep_add_download_command name) get_filename_component(src_name "${source_dir}" NAME) get_filename_component(work_dir "${source_dir}" PATH) set(comment "Performing download step (CVS checkout) for '${name}'") - set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module}) + set(cmd + ${CVS_EXECUTABLE} + -d ${cvs_repository} + -q + co ${cvs_tag} + -d ${src_name} + ${cvs_module} + ) elseif(svn_repository) set(method svn) @@ -2530,7 +2733,10 @@ function(_ep_add_download_command name) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) - get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_DOWNLOAD) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_DOWNLOAD + ) if(uses_terminal) set(svn_interactive_args "") else() @@ -2550,9 +2756,16 @@ function(_ep_add_download_command name) if(svn_trust_cert) set(svn_trust_cert_args --trust-server-cert) endif() - set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} - ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args} - ${src_name}) + set(cmd + ${Subversion_SVN_EXECUTABLE} + co + ${svn_repository} + ${svn_revision} + ${svn_interactive_args} + ${svn_trust_cert_args} + ${svn_user_pw_args} + ${src_name} + ) elseif(git_repository) set(method git) @@ -2573,7 +2786,10 @@ function(_ep_add_download_command name) endif() set(git_init_submodules TRUE) - get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET) + get_property(git_submodules_set + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES SET + ) if(git_submodules_set) get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES) if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW") @@ -2622,10 +2838,25 @@ CMP0097=${_EP_CMP0097} # create a cmake script to invoke as download command. # The script will delete the source directory and then call git clone. # - _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} - ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules_recurse}" "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir} - ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}" - ) + _ep_write_gitclone_script( + ${tmp_dir}/${name}-gitclone.cmake + ${source_dir} + ${GIT_EXECUTABLE} + ${git_repository} + ${git_tag} + ${git_remote_name} + ${git_init_submodules} + "${git_submodules_recurse}" + "${git_submodules}" + "${git_shallow}" + "${git_progress}" + "${git_config}" + ${src_name} + ${work_dir} + ${stamp_dir}/${name}-gitinfo.txt + ${stamp_dir}/${name}-gitclone-lastrun.txt + "${tls_verify}" + ) set(comment "Performing download step (git clone) for '${name}'") set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake) @@ -2656,10 +2887,17 @@ CMP0097=${_EP_CMP0097} # create a cmake script to invoke as download command. # The script will delete the source directory and then call hg clone. # - _ep_write_hgclone_script(${tmp_dir}/${name}-hgclone.cmake ${source_dir} - ${HG_EXECUTABLE} ${hg_repository} ${hg_tag} ${src_name} ${work_dir} - ${stamp_dir}/${name}-hginfo.txt ${stamp_dir}/${name}-hgclone-lastrun.txt - ) + _ep_write_hgclone_script( + ${tmp_dir}/${name}-hgclone.cmake + ${source_dir} + ${HG_EXECUTABLE} + ${hg_repository} + ${hg_tag} + ${src_name} + ${work_dir} + ${stamp_dir}/${name}-hginfo.txt + ${stamp_dir}/${name}-hgclone-lastrun.txt + ) set(comment "Performing download step (hg clone) for '${name}'") set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-hgclone.cmake) @@ -2671,13 +2909,21 @@ CMP0097=${_EP_CMP0097} if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}") _ep_get_hash_algos(_ep_hash_algos) list(JOIN _ep_hash_algos "|" _ep_hash_algos) - message(FATAL_ERROR "URL_HASH is set to\n ${hash}\n" - "but must be ALGO=value where ALGO is\n ${_ep_hash_algos}\n" - "and value is a hex string.") + message(FATAL_ERROR + "URL_HASH is set to\n" + " ${hash}\n" + "but must be ALGO=value where ALGO is\n" + " ${_ep_hash_algos}\n" + "and value is a hex string." + ) endif() get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5) if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}") - message(FATAL_ERROR "URL_MD5 is set to\n ${md5}\nbut must be a hex string.") + message(FATAL_ERROR + "URL_MD5 is set to\n" + " ${md5}\n" + "but must be a hex string." + ) endif() if(md5 AND NOT hash) set(hash "MD5=${md5}") @@ -2691,7 +2937,9 @@ hash=${hash} if(NOT "${url_list_length}" STREQUAL "1") foreach(entry ${url}) if(NOT "${entry}" MATCHES "^[a-z]+://") - message(FATAL_ERROR "At least one entry of URL is a path (invalid in a list)") + message(FATAL_ERROR + "At least one entry of URL is a path (invalid in a list)" + ) endif() endforeach() if("x${fname}" STREQUAL "x") @@ -2702,17 +2950,23 @@ hash=${hash} if(IS_DIRECTORY "${url}") get_filename_component(abs_dir "${url}" ABSOLUTE) set(comment "Performing download step (DIR copy) for '${name}'") - set(cmd ${CMAKE_COMMAND} -E rm -rf ${source_dir} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir}) + set(cmd + ${CMAKE_COMMAND} -E rm -rf ${source_dir} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir} + ) else() - get_property(no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT) + get_property(no_extract + TARGET "${name}" + PROPERTY _EP_DOWNLOAD_NO_EXTRACT + ) string(APPEND extra_repo_info "no_extract=${no_extract}\n") if("${url}" MATCHES "^[a-z]+://") # TODO: Should download and extraction be different steps? if("x${fname}" STREQUAL "x") set(fname "${url}") endif() - if("${fname}" MATCHES [[([^/\?#]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]]) + set(ext_regex [[7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip]]) + if("${fname}" MATCHES "([^/\\?#]+(\\.|=)(${ext_regex}))([/?#].*)?$") set(fname "${CMAKE_MATCH_1}") elseif(no_extract) get_filename_component(fname "${fname}" NAME) @@ -2727,8 +2981,14 @@ hash=${hash} string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) - get_property(inactivity_timeout TARGET ${name} PROPERTY _EP_INACTIVITY_TIMEOUT) - get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) + get_property(inactivity_timeout + TARGET ${name} + PROPERTY _EP_INACTIVITY_TIMEOUT + ) + get_property(no_progress + TARGET ${name} + PROPERTY _EP_DOWNLOAD_NO_PROGRESS + ) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) @@ -2752,15 +3012,18 @@ hash=${hash} "${netrc}" "${netrc_file}" ) - set(cmd ${CMAKE_COMMAND} -P "${download_script}" - COMMAND) + set(cmd + ${CMAKE_COMMAND} -P "${download_script}" + COMMAND + ) if (no_extract) set(steps "download and verify") else () set(steps "download, verify and extract") endif () set(comment "Performing download step (${steps}) for '${name}'") - file(WRITE "${stamp_dir}/verify-${name}.cmake" "") # already verified by 'download_script' + # already verified by 'download_script' + file(WRITE "${stamp_dir}/verify-${name}.cmake" "") # Rather than adding everything to the RepositoryInfo.txt file, it is # more robust to just depend on the download script. That way, we will @@ -2781,7 +3044,9 @@ hash=${hash} ) endif() list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake) - get_target_property(extract_timestamp ${name} _EP_DOWNLOAD_EXTRACT_TIMESTAMP) + get_target_property(extract_timestamp ${name} + _EP_DOWNLOAD_EXTRACT_TIMESTAMP + ) if(no_extract) if(NOT extract_timestamp STREQUAL "extract_timestamp-NOTFOUND") message(FATAL_ERROR @@ -2825,14 +3090,16 @@ hash=${hash} "${source_dir}" "${options}" ) - list(APPEND cmd COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake) + list(APPEND cmd + COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake + ) endif () endif() else() set(method source_dir) _ep_is_dir_empty("${source_dir}" empty) if(${empty}) - message(SEND_ERROR + message(FATAL_ERROR "No download info given for '${name}' and its source directory:\n" " ${source_dir}\n" "is not an existing non-empty directory. Please specify one of:\n" @@ -2843,7 +3110,7 @@ hash=${hash} " * SVN_REPOSITORY\n" " * HG_REPOSITORY\n" " * CVS_REPOSITORY and CVS_MODULE" - ) + ) endif() endif() @@ -2858,15 +3125,20 @@ hash=${hash} @ONLY ) - get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_DOWNLOAD + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_DOWNLOAD) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_DOWNLOAD + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -2887,16 +3159,26 @@ hash=${hash} DEPENDEES mkdir ${log} ${uses_terminal} - )" + )" ) endfunction() function(_ep_get_update_disconnected var name) - get_property(update_disconnected_set TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED SET) + get_property(update_disconnected_set + TARGET ${name} + PROPERTY _EP_UPDATE_DISCONNECTED + SET + ) if(update_disconnected_set) - get_property(update_disconnected TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED) + get_property(update_disconnected + TARGET ${name} + PROPERTY _EP_UPDATE_DISCONNECTED + ) else() - get_property(update_disconnected DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED) + get_property(update_disconnected + DIRECTORY + PROPERTY EP_UPDATE_DISCONNECTED + ) endif() set(${var} "${update_disconnected}" PARENT_SCOPE) endfunction() @@ -2957,8 +3239,14 @@ function(_ep_add_update_command name) if(svn_trust_cert) set(svn_trust_cert_args --trust-server-cert) endif() - set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} - ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args}) + set(cmd + ${Subversion_SVN_EXECUTABLE} + up + ${svn_revision} + ${svn_interactive_args} + ${svn_trust_cert_args} + ${svn_user_pw_args} + ) set(always 1) elseif(git_repository) # FetchContent gives us these directly, so don't try to recompute them @@ -2971,25 +3259,43 @@ function(_ep_add_update_command name) endif() set(work_dir ${source_dir}) set(comment "Performing update step for '${name}'") - get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) + + get_property(git_tag + TARGET ${name} + PROPERTY _EP_GIT_TAG + ) if(NOT git_tag) set(git_tag "master") endif() - get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME) + + get_property(git_remote_name + TARGET ${name} + PROPERTY _EP_GIT_REMOTE_NAME + ) if(NOT git_remote_name) set(git_remote_name "origin") endif() set(git_init_submodules TRUE) - get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET) + get_property(git_submodules_set + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES + SET + ) if(git_submodules_set) - get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES) + get_property(git_submodules + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES + ) if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW") set(git_init_submodules FALSE) endif() endif() - get_property(git_update_strategy TARGET ${name} PROPERTY _EP_GIT_REMOTE_UPDATE_STRATEGY) + get_property(git_update_strategy + TARGET ${name} + PROPERTY _EP_GIT_REMOTE_UPDATE_STRATEGY + ) if(NOT git_update_strategy) set(git_update_strategy "${CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY}") endif() @@ -2998,7 +3304,10 @@ function(_ep_add_update_command name) endif() set(strategies CHECKOUT REBASE REBASE_CHECKOUT) if(NOT git_update_strategy IN_LIST strategies) - message(FATAL_ERROR "'${git_update_strategy}' is not one of the supported strategies: ${strategies}") + message(FATAL_ERROR + "'${git_update_strategy}' is not one of the supported strategies: " + "${strategies}" + ) endif() _ep_get_git_submodules_recurse(git_submodules_recurse) @@ -3023,32 +3332,48 @@ function(_ep_add_update_command name) endif() set(work_dir ${source_dir}) set(comment "Performing update step (hg pull) for '${name}'") - get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG) + + get_property(hg_tag + TARGET ${name} + PROPERTY _EP_HG_TAG + ) if(NOT hg_tag) set(hg_tag "tip") endif() + if("${HG_VERSION_STRING}" STREQUAL "2.1") - message(WARNING "Mercurial 2.1 does not distinguish an empty pull from a failed pull: - http://mercurial.selenic.com/wiki/UpgradeNotes#A2.1.1:_revert_pull_return_code_change.2C_compile_issue_on_OS_X + set(notesAnchor + "#A2.1.1:_revert_pull_return_code_change.2C_compile_issue_on_OS_X" + ) + message(WARNING +"Mercurial 2.1 does not distinguish an empty pull from a failed pull: + http://mercurial.selenic.com/wiki/UpgradeNotes${notesAnchor} http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/47656 Update to Mercurial >= 2.1.1. ") endif() - set(cmd ${HG_EXECUTABLE} pull + + set(cmd + ${HG_EXECUTABLE} pull COMMAND ${HG_EXECUTABLE} update ${hg_tag} - ) + ) set(always 1) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_UPDATE + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_UPDATE) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_UPDATE + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3070,7 +3395,7 @@ Update to Mercurial >= 2.1.1. DEPENDEES download ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3088,14 +3413,20 @@ function(_ep_add_patch_command name) set(work_dir ${source_dir}) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_PATCH) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_PATCH + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_PATCH) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_PATCH + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3121,18 +3452,27 @@ function(_ep_add_patch_command name) DEPENDEES \${patch_dep} ${log} ${uses_terminal} - )" + )" ) endfunction() function(_ep_get_file_deps var name) set(file_deps) - get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + get_property(deps + TARGET ${name} + PROPERTY _EP_DEPENDS + ) foreach(dep IN LISTS deps) - get_property(dep_type TARGET ${dep} PROPERTY TYPE) + get_property(dep_type + TARGET ${dep} + PROPERTY TYPE + ) if(dep_type STREQUAL "UTILITY") - get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT) + get_property(is_ep + TARGET ${dep} + PROPERTY _EP_IS_EXTERNAL_PROJECT + ) if(is_ep) _ep_get_step_stampfile(${dep} "done" done_stamp_file) list(APPEND file_deps ${done_stamp_file}) @@ -3144,9 +3484,16 @@ function(_ep_get_file_deps var name) endfunction() function(_ep_extract_configure_command var name) - get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET) + get_property(cmd_set + TARGET ${name} + PROPERTY _EP_CONFIGURE_COMMAND + SET + ) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_CONFIGURE_COMMAND + ) else() get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND) if(cmake_command) @@ -3155,13 +3502,22 @@ function(_ep_extract_configure_command var name) set(cmd "${CMAKE_COMMAND}") endif() - get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS) + get_property(cmake_args + TARGET ${name} + PROPERTY _EP_CMAKE_ARGS + ) list(APPEND cmd ${cmake_args}) # If there are any CMAKE_CACHE_ARGS or CMAKE_CACHE_DEFAULT_ARGS, # write an initial cache and use it - get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS) - get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS) + get_property(cmake_cache_args + TARGET ${name} + PROPERTY _EP_CMAKE_CACHE_ARGS + ) + get_property(cmake_cache_default_args + TARGET ${name} + PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS + ) set(has_cmake_cache_args 0) if(NOT "${cmake_cache_args}" STREQUAL "") @@ -3173,10 +3529,18 @@ function(_ep_extract_configure_command var name) set(has_cmake_cache_default_args 1) endif() - get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - get_target_property(cmake_generator_instance ${name} _EP_CMAKE_GENERATOR_INSTANCE) - get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM) - get_target_property(cmake_generator_toolset ${name} _EP_CMAKE_GENERATOR_TOOLSET) + get_target_property(cmake_generator ${name} + _EP_CMAKE_GENERATOR + ) + get_target_property(cmake_generator_instance ${name} + _EP_CMAKE_GENERATOR_INSTANCE + ) + get_target_property(cmake_generator_platform ${name} + _EP_CMAKE_GENERATOR_PLATFORM + ) + get_target_property(cmake_generator_toolset ${name} + _EP_CMAKE_GENERATOR_TOOLSET + ) if(cmake_generator) list(APPEND cmd "-G${cmake_generator}") if(cmake_generator_platform) @@ -3186,7 +3550,9 @@ function(_ep_extract_configure_command var name) list(APPEND cmd "-T${cmake_generator_toolset}") endif() if(cmake_generator_instance) - list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}") + list(APPEND cmd + "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}" + ) endif() else() if(CMAKE_EXTRA_GENERATOR) @@ -3195,49 +3561,72 @@ function(_ep_extract_configure_command var name) list(APPEND cmd "-G${CMAKE_GENERATOR}") if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") set(has_cmake_cache_default_args 1) - set(cmake_cache_default_args ${cmake_cache_default_args} + list(APPEND cmake_cache_default_args "-DGHS_TARGET_PLATFORM:STRING=${GHS_TARGET_PLATFORM}" "-DGHS_PRIMARY_TARGET:STRING=${GHS_PRIMARY_TARGET}" "-DGHS_TOOLSET_ROOT:STRING=${GHS_TOOLSET_ROOT}" "-DGHS_OS_ROOT:STRING=${GHS_OS_ROOT}" "-DGHS_OS_DIR:STRING=${GHS_OS_DIR}" - "-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}") + "-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}" + ) endif() endif() if(cmake_generator_platform) - message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.") + message(FATAL_ERROR + "Option CMAKE_GENERATOR_PLATFORM not allowed without " + "CMAKE_GENERATOR." + ) endif() if(CMAKE_GENERATOR_PLATFORM) list(APPEND cmd "-A${CMAKE_GENERATOR_PLATFORM}") endif() if(cmake_generator_toolset) - message(FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR.") + message(FATAL_ERROR + "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR." + ) endif() if(CMAKE_GENERATOR_TOOLSET) list(APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}") endif() if(cmake_generator_instance) - message(FATAL_ERROR "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR.") + message(FATAL_ERROR + "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR." + ) endif() if(CMAKE_GENERATOR_INSTANCE) - list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") + list(APPEND cmd + "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}" + ) endif() endif() if(has_cmake_cache_args OR has_cmake_cache_default_args) set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake") if(has_cmake_cache_args) - _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1) + _ep_command_line_to_initial_cache( + script_initial_cache_force + "${cmake_cache_args}" + 1 + ) endif() if(has_cmake_cache_default_args) - _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0) + _ep_command_line_to_initial_cache( + script_initial_cache_default + "${cmake_cache_default_args}" + 0 + ) endif() - _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}") + _ep_write_initial_cache( + ${name} + "${_ep_cache_args_script}" + "${script_initial_cache_force}${script_initial_cache_default}" + ) list(APPEND cmd "-C${_ep_cache_args_script}") _ep_replace_location_tags(${name} _ep_cache_args_script) set(_ep_cache_args_script "${_ep_cache_args_script}" - PARENT_SCOPE) + PARENT_SCOPE + ) endif() list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>") @@ -3251,8 +3640,10 @@ function(_ep_add_configure_command name) ExternalProject_Get_Property(${name} binary_dir tmp_dir) set(file_deps) - get_property(configure_handled_by_build TARGET ${name} - PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD) + get_property(configure_handled_by_build + TARGET ${name} + PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD + ) if(NOT configure_handled_by_build) # Depend on other external projects (file-level) _ep_get_file_deps(file_deps ${name}) @@ -3272,15 +3663,20 @@ function(_ep_add_configure_command name) list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt) list(APPEND file_deps ${_ep_cache_args_script}) - get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_CONFIGURE + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_CONFIGURE) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_CONFIGURE + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3300,7 +3696,7 @@ function(_ep_add_configure_command name) DEPENDS \${file_deps} ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3309,43 +3705,63 @@ function(_ep_add_build_command name) ExternalProject_Get_Property(${name} binary_dir) set(file_deps) - get_property(configure_handled_by_build TARGET ${name} - PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD) + get_property(configure_handled_by_build + TARGET ${name} + PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD + ) if(configure_handled_by_build) # Depend on other external projects (file-level) _ep_get_file_deps(file_deps ${name}) endif() - get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET) + get_property(cmd_set + TARGET ${name} + PROPERTY _EP_BUILD_COMMAND + SET + ) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_BUILD_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_BUILD_COMMAND + ) else() _ep_get_build_command(${name} BUILD cmd) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_BUILD + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_BUILD) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_BUILD + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() set(uses_terminal "") endif() - get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS) + get_property(build_always + TARGET ${name} + PROPERTY _EP_BUILD_ALWAYS + ) if(build_always) set(always 1) else() set(always 0) endif() - get_property(build_byproducts TARGET ${name} PROPERTY _EP_BUILD_BYPRODUCTS) + get_property(build_byproducts + TARGET ${name} + PROPERTY _EP_BUILD_BYPRODUCTS + ) set(__cmdQuoted) foreach(__item IN LISTS cmd) @@ -3362,7 +3778,7 @@ function(_ep_add_build_command name) ALWAYS \${always} ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3370,22 +3786,34 @@ endfunction() function(_ep_add_install_command name) ExternalProject_Get_Property(${name} binary_dir) - get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET) + get_property(cmd_set + TARGET ${name} + PROPERTY _EP_INSTALL_COMMAND + SET + ) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_INSTALL_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_INSTALL_COMMAND + ) else() _ep_get_build_command(${name} INSTALL cmd) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_INSTALL + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_INSTALL) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_INSTALL + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3404,7 +3832,7 @@ function(_ep_add_install_command name) DEPENDEES build ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3422,7 +3850,10 @@ function(_ep_add_test_command name) # if(cmd_set OR before OR after OR exclude) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_TEST_COMMAND + ) else() _ep_get_build_command(${name} TEST cmd) endif() @@ -3445,15 +3876,20 @@ function(_ep_add_test_command name) set(exclude_args "") endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_TEST + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_TEST) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_TEST + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3474,7 +3910,7 @@ function(_ep_add_test_command name) ${exclude_args} ${log} ${uses_terminal} - )" + )" ) endif() endfunction() @@ -3483,11 +3919,12 @@ endfunction() function(ExternalProject_Add name) cmake_policy(GET CMP0097 _EP_CMP0097 PARENT_SCOPE # undocumented, do not use outside of CMake - ) + ) cmake_policy(GET CMP0114 cmp0114 PARENT_SCOPE # undocumented, do not use outside of CMake - ) - if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT cmp0114 STREQUAL "NEW") + ) + if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND + NOT cmp0114 STREQUAL "NEW") message(AUTHOR_WARNING "Policy CMP0114 is not set to NEW. " "In order to support the Xcode \"new build system\", " @@ -3496,12 +3933,12 @@ function(ExternalProject_Add name) "Since CMake is generating for the Xcode \"new build system\", " "ExternalProject_Add will use policy CMP0114's NEW behavior anyway, " "but the generated build system may not match what the project intends." - ) + ) set(cmp0114 "NEW") endif() cmake_policy(GET CMP0135 _EP_CMP0135 PARENT_SCOPE # undocumented, do not use outside of CMake - ) + ) _ep_get_configuration_subdir_suffix(cfgdir) @@ -3520,11 +3957,12 @@ function(ExternalProject_Add name) # argument was passed, we explicitly set it for the target. add_custom_target(${name} ALL DEPENDS ${complete_stamp_file}) cmake_policy(POP) - set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1) - set_property(TARGET ${name} PROPERTY LABELS ${name}) - set_property(TARGET ${name} PROPERTY FOLDER "ExternalProjectTargets/${name}") - - set_property(TARGET ${name} PROPERTY _EP_CMP0114 "${cmp0114}") + set_target_properties(${name} PROPERTIES + _EP_IS_EXTERNAL_PROJECT 1 + LABELS ${name} + FOLDER "ExternalProjectTargets/${name}" + _EP_CMP0114 "${cmp0114}" + ) set(keywords # @@ -3657,13 +4095,22 @@ function(ExternalProject_Add name) # LIST_SEPARATOR ) - _ep_parse_arguments(ExternalProject_Add "${keywords}" ${name} _EP_ "${ARGN}") + _ep_parse_arguments( + ExternalProject_Add + "${keywords}" + ${name} + _EP_ + "${ARGN}" + ) _ep_set_directories(${name}) _ep_get_step_stampfile(${name} "done" done_stamp_file) _ep_get_step_stampfile(${name} "install" install_stamp_file) # Set the EXCLUDE_FROM_ALL target property if required. - get_property(exclude_from_all TARGET ${name} PROPERTY _EP_EXCLUDE_FROM_ALL) + get_property(exclude_from_all + TARGET ${name} + PROPERTY _EP_EXCLUDE_FROM_ALL + ) if(exclude_from_all) set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE) endif() @@ -3690,11 +4137,13 @@ function(ExternalProject_Add name) COMMAND ${CMAKE_COMMAND} -E touch ${done_stamp_file} DEPENDS ${install_stamp_file} VERBATIM - ) - + ) # Depend on other external projects (target-level). - get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + get_property(deps + TARGET ${name} + PROPERTY _EP_DEPENDS + ) foreach(arg IN LISTS deps) add_dependencies(${name} ${arg}) endforeach() diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index e1cc843..5ca296e 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -1431,7 +1431,7 @@ ExternalProject_Add_Step(${contentName}-populate copyfile # and can always request a known configuration further below. get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(is_multi_config) - list(APPEND subCMakeOpts "-DCMAKE_CONFIGURATION_TYPES:STRING=Release") + list(APPEND subCMakeOpts "-DCMAKE_CONFIGURATION_TYPES:STRING=Debug") endif() else() @@ -1479,7 +1479,7 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION # anything to be updated, so extra rebuilds of the project won't occur. # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project # has this set to something not findable on the PATH. We also ensured above - # that the Release config will be defined for multi-config generators. + # that the Debug config will be defined for multi-config generators. configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/FetchContent/CMakeLists.cmake.in" "${ARG_SUBBUILD_DIR}/CMakeLists.txt") execute_process( @@ -1495,7 +1495,7 @@ set_property(GLOBAL PROPERTY _CMAKE_FindGit_GIT_EXECUTABLE_VERSION message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}") endif() execute_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release + COMMAND ${CMAKE_COMMAND} --build . --config Debug RESULT_VARIABLE result ${outputOptions} WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}" diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 72d4db5..320ddad 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -275,8 +275,4 @@ if (GLUT_FOUND) PROPERTY INTERFACE_LINK_LIBRARIES GLUT::Cocoa) endif() endif() - - #The following deprecated settings are for backwards compatibility with CMake1.4 - set (GLUT_LIBRARY ${GLUT_LIBRARIES}) - set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIRS}) endif() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index ab8af3e..854e0e1 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -143,7 +143,9 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") endif() - separate_arguments(_pkgconfig_invoke_result) + # pkg-config can represent "spaces within an argument" by backslash-escaping the space. + # UNIX_COMMAND mode treats backslash-escaped spaces as "not a space that delimits arguments". + separate_arguments(_pkgconfig_invoke_result UNIX_COMMAND "${_pkgconfig_invoke_result}") #message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}") set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result}) @@ -167,13 +169,14 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target) set(${_is_req} 0) set(${_is_silent} 0) set(${_no_cmake_path} 0) set(${_no_cmake_environment_path} 0) set(${_imp_target} 0) set(${_imp_target_global} 0) + set(${_static_target} 0) if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) set(${_no_cmake_path} 1) @@ -203,6 +206,9 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma if (_pkg STREQUAL "GLOBAL") set(${_imp_target_global} 1) endif() + if (_pkg STREQUAL "STATIC_TARGET") + set(${_static_target} 1) + endif() endforeach() if (${_imp_target_global} AND NOT ${_imp_target}) @@ -215,6 +221,7 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") list(REMOVE_ITEM ${_result} "IMPORTED_TARGET") + list(REMOVE_ITEM ${_result} "STATIC_TARGET") list(REMOVE_ITEM ${_result} "GLOBAL") endmacro() @@ -246,7 +253,7 @@ endfunction() # scan the LDFLAGS returned by pkg-config for library directories and # libraries, figure out the absolute paths of that libraries in the # given directories -function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) +function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path _static) unset(_libs) unset(_find_opts) @@ -259,9 +266,23 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) list(APPEND _find_opts "NO_CMAKE_ENVIRONMENT_PATH") endif() + if(_static) + set(var_prefix ${_prefix}_STATIC) + set(pkgcfg_lib_prefix pkgcfg_static_lib_${_prefix}) + # reconfigure library prefixes/suffixes so that only static libraries can be found + set(CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_STATIC_LIBRARY_PREFIX}") + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}") + else() + set(var_prefix ${_prefix}) + set(pkgcfg_lib_prefix pkgcfg_lib_${_prefix}) + # reconfigure library prefixes/suffixes so that only dynamic libraries can be found + set(CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_SHARED_LIBRARY_PREFIX}") + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + unset(_search_paths) unset(_next_is_framework) - foreach (flag IN LISTS ${_prefix}_LDFLAGS) + foreach (flag IN LISTS ${var_prefix}_LDFLAGS) if (_next_is_framework) list(APPEND _libs "-framework ${flag}") unset(_next_is_framework) @@ -280,61 +301,78 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) continue() endif() + set(lib_var_name ${pkgcfg_lib_prefix}_${_pkg_search}) + if(_search_paths) # Firstly search in -L paths - find_library(pkgcfg_lib_${_prefix}_${_pkg_search} + find_library(${lib_var_name} NAMES ${_pkg_search} HINTS ${_search_paths} NO_DEFAULT_PATH) endif() - find_library(pkgcfg_lib_${_prefix}_${_pkg_search} + find_library(${lib_var_name} NAMES ${_pkg_search} ${_find_opts}) - mark_as_advanced(pkgcfg_lib_${_prefix}_${_pkg_search}) - if(pkgcfg_lib_${_prefix}_${_pkg_search}) - list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") + + mark_as_advanced(${lib_var_name}) + if(${lib_var_name}) + list(APPEND _libs "${${lib_var_name}}") else() list(APPEND _libs ${_pkg_search}) endif() endforeach() - set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE) + set(${var_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE) endfunction() # create an imported target from all the information returned by pkg-config -function(_pkg_create_imp_target _prefix _imp_target_global) - if (NOT TARGET PkgConfig::${_prefix}) +function(_pkg_create_imp_target _prefix _imp_target_global _var_qualifier) + set(tgt PkgConfig::${_prefix}) + set(var_prefix ${_prefix}${_var_qualifier}) + + if (NOT TARGET ${tgt}) if(${_imp_target_global}) set(_global_opt "GLOBAL") else() unset(_global_opt) endif() - add_library(PkgConfig::${_prefix} INTERFACE IMPORTED ${_global_opt}) + add_library(${tgt} INTERFACE IMPORTED ${_global_opt}) - if(${_prefix}_INCLUDE_DIRS) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}") + if(${var_prefix}_INCLUDE_DIRS) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${${var_prefix}_INCLUDE_DIRS}") endif() - if(${_prefix}_LINK_LIBRARIES) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}") + if(${var_prefix}_LINK_LIBRARIES) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_LINK_LIBRARIES "${${var_prefix}_LINK_LIBRARIES}") endif() - if(${_prefix}_LDFLAGS_OTHER) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_LINK_OPTIONS "${${_prefix}_LDFLAGS_OTHER}") + if(${var_prefix}_LDFLAGS_OTHER) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_LINK_OPTIONS "${${var_prefix}_LDFLAGS_OTHER}") endif() - if(${_prefix}_CFLAGS_OTHER) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_COMPILE_OPTIONS "${${_prefix}_CFLAGS_OTHER}") + if(${var_prefix}_CFLAGS_OTHER) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_COMPILE_OPTIONS "${${var_prefix}_CFLAGS_OTHER}") endif() endif() endfunction() # recalculate the dynamic output # this is a macro and not a function so the result of _pkg_find_libs is automatically propagated -macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global) - _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path}) +macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target) + # populate unqualified (shared) series of variables + _pkg_find_libs("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} FALSE) + # populate STATIC_ series of variables + _pkg_find_libs("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} TRUE) + if(${_imp_target}) - _pkg_create_imp_target(${_prefix} ${_imp_target_global}) + if (${_static_target}) + set(var_qualifier "_STATIC") + else() + set(var_qualifier "") + endif() + # create unqualified target, sourced from whichever series of variables is preferred. + # default: source target from unqualified (shared) variables. otherwise STATIC_ variables + _pkg_create_imp_target("${_prefix}" ${_imp_target_global} "${var_qualifier}") endif() endmacro() @@ -503,7 +541,7 @@ function(_pkgconfig_extract_isystem _prefix) endfunction() ### -macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -639,20 +677,21 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other ) - - if (APPLE AND "-framework" IN_LIST ${_prefix}_LDFLAGS_OTHER) - _pkgconfig_extract_frameworks("${_prefix}") - endif() - _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )(-I|-isystem ?)" --cflags-only-I ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) - if (${_prefix}_CFLAGS_OTHER MATCHES "-isystem") - _pkgconfig_extract_isystem("${_prefix}") - endif () + foreach (qualifier IN ITEMS "" "_STATIC") + set(qual_prefix ${_prefix}${qualifier}) + if (APPLE AND "-framework" IN_LIST ${qual_prefix}_LDFLAGS_OTHER) + _pkgconfig_extract_frameworks("${qual_prefix}") + endif() + if (${qual_prefix}_CFLAGS_OTHER MATCHES "-isystem") + _pkgconfig_extract_isystem("${qual_prefix}") + endif () + endforeach() - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target}) endif() _pkg_restore_path_internal() @@ -676,7 +715,7 @@ endmacro() [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] - [IMPORTED_TARGET [GLOBAL]] + [IMPORTED_TARGET [GLOBAL] [STATIC_TARGET]] <moduleSpec> [<moduleSpec>...]) When the ``REQUIRED`` argument is given, the command will fail with an error @@ -707,6 +746,13 @@ endmacro() The ``GLOBAL`` argument will make the imported target available in global scope. + .. versionadded:: 3.24 + The ``STATIC_TARGET`` argument will make the + imported target reference the static libraries + reported in ``<XXX>_STATIC_LINK_LIBRARIES``. + Without this option, the imported target + references the ``<XXX>_LINK_LIBRARIES``. + .. versionadded:: 3.15 Non-library linker options reported by ``pkg-config`` are stored in the :prop_tgt:`INTERFACE_LINK_OPTIONS` target property. @@ -738,6 +784,10 @@ endmacro() only the libraries (without the '-l') ``<XXX>_LINK_LIBRARIES`` the libraries and their absolute paths + ``<XXX>_STATIC_LINK_LIBRARIES`` + .. versionadded:: 3.24 + + static libraries and their absolute paths ``<XXX>_LIBRARY_DIRS`` the paths of the libraries (without the '-L') ``<XXX>_LDFLAGS`` @@ -819,12 +869,12 @@ endmacro() XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp #]========================================] macro(pkg_check_modules _prefix _module0) - _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target "${_module0}" ${ARGN}) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR (NOT "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") OR ( "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0}")) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" ${_pkg_modules}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) if (${_prefix}_FOUND) @@ -832,7 +882,7 @@ macro(pkg_check_modules _prefix _module0) endif() else() if (${_prefix}_FOUND) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target}) endif() endif() endmacro() @@ -866,7 +916,7 @@ endmacro() pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) #]========================================] macro(pkg_search_module _prefix _module0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target "${_module0}" ${ARGN}) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) @@ -878,7 +928,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) @@ -895,7 +945,7 @@ macro(pkg_search_module _prefix _module0) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) elseif (${_prefix}_FOUND) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target}) endif() endmacro() diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 527ca8b..8b322ed 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -10,6 +10,16 @@ FindVulkan Find Vulkan, which is a low-overhead, cross-platform 3D graphics and computing API. +Optional COMPONENTS +^^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.24 + +This module respects several optional COMPONENTS: ``glslc``, +``glslangValidator``, ``glslang``, ``shaderc_combined`` and ``SPIRV-Tools``. +On macOS, an additional component ``MoltenVK`` is available. +There are corresponding import targets for each of these flags. + IMPORTED Targets ^^^^^^^^^^^^^^^^ @@ -36,6 +46,30 @@ This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: The glslangValidator tool, if found. It is used to compile GLSL and HLSL shaders into SPIR-V. +``Vulkan::glslang`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V + generator library (glslang). + +``Vulkan::shaderc_combined`` + .. versionadded:: 3.24 + + Defined if SDK has the Google static library for Vulkan shader compilation + (shaderc_combined). + +``Vulkan::SPIRV-Tools`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos library to process SPIR-V modules + (SPIRV-Tools). + +``Vulkan::MoltenVK`` + .. versionadded:: 3.24 + + Defined if SDK has the Khronos library which implement a subset of Vulkan API + over Apple Metal graphics framework. (MoltenVK). + Result Variables ^^^^^^^^^^^^^^^^ @@ -51,6 +85,30 @@ This module defines the following variables: .. versionadded:: 3.23 value from ``vulkan/vulkan_core.h`` +``Vulkan_glslc_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslc executable. +``Vulkan_glslangValidator_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslangValidator executable. +``Vulkan_glslang_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the glslang library. +``Vulkan_shaderc_combined_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the shaderc_combined library. +``Vulkan_SPIRV-Tools_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the SPIRV-Tools library. +``Vulkan_MoltenVK_FOUND`` + .. versionadded:: 3.24 + + True, if the SDK has the MoltenVK library. The module will also defines these cache variables: @@ -62,6 +120,22 @@ The module will also defines these cache variables: the path to the GLSL SPIR-V compiler ``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE`` the path to the glslangValidator tool +``Vulkan_glslang_LIBRARY`` + .. versionadded:: 3.24 + + Path to the glslang library. +``Vulkan_shaderc_combined_LIBRARY`` + .. versionadded:: 3.24 + + Path to the shaderc_combined library. +``Vulkan_SPIRV-Tools_LIBRARY`` + .. versionadded:: 3.24 + + Path to the SPIRV-Tools library. +``Vulkan_MoltenVK_LIBRARY`` + .. versionadded:: 3.24 + + Path to the MoltenVK library. Hints ^^^^^ @@ -76,61 +150,298 @@ environment. #]=======================================================================] -if(WIN32) - find_path(Vulkan_INCLUDE_DIR - NAMES vulkan/vulkan.h - HINTS - "$ENV{VULKAN_SDK}/Include" - ) +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) + +# For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc` +# and `glslangValidator` without requesting the corresponding component. +if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS) + list(APPEND Vulkan_FIND_COMPONENTS glslc) +endif() +if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) + list(APPEND Vulkan_FIND_COMPONENTS glslangValidator) +endif() +if(WIN32) + set(_Vulkan_library_name vulkan-1) + set(_Vulkan_hint_include_search_paths + "$ENV{VULKAN_SDK}/Include" + ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - find_library(Vulkan_LIBRARY - NAMES vulkan-1 - HINTS - "$ENV{VULKAN_SDK}/Lib" - "$ENV{VULKAN_SDK}/Bin" - ) - find_program(Vulkan_GLSLC_EXECUTABLE - NAMES glslc - HINTS - "$ENV{VULKAN_SDK}/Bin" - ) - find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE - NAMES glslangValidator - HINTS - "$ENV{VULKAN_SDK}/Bin" - ) - elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - find_library(Vulkan_LIBRARY - NAMES vulkan-1 - HINTS - "$ENV{VULKAN_SDK}/Lib32" - "$ENV{VULKAN_SDK}/Bin32" + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/Bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/Lib" + "$ENV{VULKAN_SDK}/Bin" + ) + else() + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/Bin32" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/Lib32" + "$ENV{VULKAN_SDK}/Bin32" + ) + endif() +else() + set(_Vulkan_library_name vulkan) + set(_Vulkan_hint_include_search_paths + "$ENV{VULKAN_SDK}/include" + ) + set(_Vulkan_hint_executable_search_paths + "$ENV{VULKAN_SDK}/bin" + ) + set(_Vulkan_hint_library_search_paths + "$ENV{VULKAN_SDK}/lib" + ) +endif() +if(APPLE AND DEFINED ENV{VULKAN_SDK}) + cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK") + if(EXISTS "${_MoltenVK_path}") + list(APPEND _Vulkan_hint_include_search_paths + "${_MoltenVK_path}/include" + ) + if(CMAKE_SYSTEM_NAME STREQUAL "iOS") + list(APPEND _Vulkan_hint_library_search_paths + "${_MoltenVK_path}/dylib/iOS" ) - find_program(Vulkan_GLSLC_EXECUTABLE - NAMES glslc - HINTS - "$ENV{VULKAN_SDK}/Bin32" + elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS") + list(APPEND _Vulkan_hint_library_search_paths + "${_MoltenVK_path}/dylib/tvOS" ) - find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE - NAMES glslangValidator - HINTS - "$ENV{VULKAN_SDK}/Bin32" + else() + list(APPEND _Vulkan_hint_library_search_paths + "${_MoltenVK_path}/dylib/macOS" ) + endif() endif() -else() - find_path(Vulkan_INCLUDE_DIR - NAMES vulkan/vulkan.h - HINTS "$ENV{VULKAN_SDK}/include") - find_library(Vulkan_LIBRARY - NAMES vulkan - HINTS "$ENV{VULKAN_SDK}/lib") + unset(_MoltenVK_path) +endif() + +find_path(Vulkan_INCLUDE_DIR + NAMES vulkan/vulkan.h + HINTS + ${_Vulkan_hint_include_search_paths} + ) +mark_as_advanced(Vulkan_INCLUDE_DIR) + +find_library(Vulkan_LIBRARY + NAMES ${_Vulkan_library_name} + HINTS + ${_Vulkan_hint_library_search_paths} + ) +mark_as_advanced(Vulkan_LIBRARY) + +if(glslc IN_LIST Vulkan_FIND_COMPONENTS) find_program(Vulkan_GLSLC_EXECUTABLE NAMES glslc - HINTS "$ENV{VULKAN_SDK}/bin") + HINTS + ${_Vulkan_hint_executable_search_paths} + ) + mark_as_advanced(Vulkan_GLSLC_EXECUTABLE) +endif() +if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS) find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE NAMES glslangValidator - HINTS "$ENV{VULKAN_SDK}/bin") + HINTS + ${_Vulkan_hint_executable_search_paths} + ) + mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) +endif() +if(glslang IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_glslang-spirv_LIBRARY + NAMES SPIRV + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-spirv_LIBRARY) + + find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY + NAMES SPIRVd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-oglcompiler_LIBRARY + NAMES OGLCompiler + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY) + + find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY + NAMES OGLCompilerd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-osdependent_LIBRARY + NAMES OSDependent + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY) + + find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY + NAMES OSDependentd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-machineindependent_LIBRARY + NAMES MachineIndependent + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY) + + find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY + NAMES MachineIndependentd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) + + find_library(Vulkan_glslang-genericcodegen_LIBRARY + NAMES GenericCodeGen + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY) + + find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY + NAMES GenericCodeGend + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) + + find_library(Vulkan_glslang_LIBRARY + NAMES glslang + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang_LIBRARY) + + find_library(Vulkan_glslang_DEBUG_LIBRARY + NAMES glslangd + HINTS + ${_Vulkan_hint_library_search_paths} + ) + mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY) +endif() +if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_shaderc_combined_LIBRARY + NAMES shaderc_combined + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_shaderc_combined_LIBRARY) + + find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY + NAMES shaderc_combinedd + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY) +endif() +if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_SPIRV-Tools_LIBRARY + NAMES SPIRV-Tools + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY) + + find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY + NAMES SPIRV-Toolsd + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) +endif() +if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_MoltenVK_LIBRARY + NAMES MoltenVK + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_MoltenVK_LIBRARY) + + find_path(Vulkan_MoltenVK_INCLUDE_DIR + NAMES MoltenVK/mvk_vulkan.h + HINTS + ${_Vulkan_hint_include_search_paths} + ) + mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR) +endif() + +if(Vulkan_GLSLC_EXECUTABLE) + set(Vulkan_glslc_FOUND TRUE) +else() + set(Vulkan_glslc_FOUND FALSE) +endif() + +if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) + set(Vulkan_glslangValidator_FOUND TRUE) +else() + set(Vulkan_glslangValidator_FOUND FALSE) +endif() + +function(_Vulkan_set_library_component_found component) + cmake_parse_arguments(PARSE_ARGV 1 _ARG + "NO_WARNING" + "" + "DEPENDENT_COMPONENTS") + + set(all_dependent_component_found TRUE) + foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS) + if(NOT Vulkan_${dependent_component}_FOUND) + set(all_dependent_component_found FALSE) + break() + endif() + endforeach() + + if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY)) + set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE) + + # For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI: + # - Release binaries uses a runtime library + # - Debug binaries uses a debug runtime library + # This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI. + if(WIN32 AND NOT _ARG_NO_WARNING) + if(NOT Vulkan_${component}_LIBRARY) + message(WARNING +"Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.") + endif() + if(NOT Vulkan_${component}_DEBUG_LIBRARY) + message(WARNING +"Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.") + endif() + endif() + else() + set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE) + endif() +endfunction() + +_Vulkan_set_library_component_found(glslang-spirv NO_WARNING) +_Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING) +_Vulkan_set_library_component_found(glslang-osdependent NO_WARNING) +_Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING) +_Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING) +_Vulkan_set_library_component_found(glslang + DEPENDENT_COMPONENTS + glslang-spirv + glslang-oglcompiler + glslang-osdependent + glslang-machineindependent + glslang-genericcodegen) +_Vulkan_set_library_component_found(shaderc_combined) +_Vulkan_set_library_component_found(SPIRV-Tools) + +if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY) + set(Vulkan_MoltenVK_FOUND TRUE) +else() + set(Vulkan_MoltenVK_FOUND FALSE) endif() set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) @@ -155,6 +466,25 @@ if(Vulkan_INCLUDE_DIR) endif() endif() +if(Vulkan_MoltenVK_FOUND) + set(Vulkan_MoltenVK_VERSION "") + if(Vulkan_MoltenVK_INCLUDE_DIR) + set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h) + if(EXISTS ${VK_MVK_MOLTENVK_H}) + file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ") + string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}") + file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ") + string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}") + file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ") + string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}") + set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}") + unset(_Vulkan_MoltenVK_VERSION_MAJOR) + unset(_Vulkan_MoltenVK_VERSION_MINOR) + unset(_Vulkan_MoltenVK_VERSION_PATCH) + endif() + endif() +endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(Vulkan REQUIRED_VARS @@ -162,11 +492,9 @@ find_package_handle_standard_args(Vulkan Vulkan_INCLUDE_DIR VERSION_VAR Vulkan_VERSION + HANDLE_COMPONENTS ) -mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY Vulkan_GLSLC_EXECUTABLE - Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) - if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) add_library(Vulkan::Vulkan UNKNOWN IMPORTED) set_target_properties(Vulkan::Vulkan PROPERTIES @@ -189,3 +517,228 @@ if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::g add_executable(Vulkan::glslangValidator IMPORTED) set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}") endif() + +if(Vulkan_FOUND) + if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv) + add_library(Vulkan::glslang-spirv STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-spirv_LIBRARY) + set_property(TARGET Vulkan::glslang-spirv APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}") + endif() + if(Vulkan_glslang-spirv_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-spirv APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-spirv + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler) + add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-oglcompiler_LIBRARY) + set_property(TARGET Vulkan::glslang-oglcompiler APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}") + endif() + if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-oglcompiler APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-oglcompiler + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent) + add_library(Vulkan::glslang-osdependent STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-osdependent_LIBRARY) + set_property(TARGET Vulkan::glslang-osdependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}") + endif() + if(Vulkan_glslang-osdependent_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-osdependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-osdependent + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent) + add_library(Vulkan::glslang-machineindependent STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-machineindependent_LIBRARY) + set_property(TARGET Vulkan::glslang-machineindependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}") + endif() + if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-machineindependent APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-machineindependent + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen) + add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang-genericcodegen_LIBRARY) + set_property(TARGET Vulkan::glslang-genericcodegen APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}") + endif() + if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang-genericcodegen APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang-genericcodegen + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}") + endif() + endif() + + if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY) + AND TARGET Vulkan::glslang-spirv + AND TARGET Vulkan::glslang-oglcompiler + AND TARGET Vulkan::glslang-osdependent + AND TARGET Vulkan::glslang-machineindependent + AND TARGET Vulkan::glslang-genericcodegen + AND NOT TARGET Vulkan::glslang) + add_library(Vulkan::glslang STATIC IMPORTED) + set_property(TARGET Vulkan::glslang + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_glslang_LIBRARY) + set_property(TARGET Vulkan::glslang APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::glslang + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}") + endif() + if(Vulkan_glslang_DEBUG_LIBRARY) + set_property(TARGET Vulkan::glslang APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::glslang + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}") + endif() + target_link_libraries(Vulkan::glslang + INTERFACE + Vulkan::glslang-spirv + Vulkan::glslang-oglcompiler + Vulkan::glslang-osdependent + Vulkan::glslang-machineindependent + Vulkan::glslang-genericcodegen + ) + endif() + + if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined) + add_library(Vulkan::shaderc_combined STATIC IMPORTED) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_shaderc_combined_LIBRARY) + set_property(TARGET Vulkan::shaderc_combined APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}") + endif() + if(Vulkan_shaderc_combined_DEBUG_LIBRARY) + set_property(TARGET Vulkan::shaderc_combined APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::shaderc_combined + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}") + endif() + + if(UNIX) + find_package(Threads REQUIRED) + target_link_libraries(Vulkan::shaderc_combined + INTERFACE + Threads::Threads) + endif() + endif() + + if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools) + add_library(Vulkan::SPIRV-Tools STATIC IMPORTED) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + if(Vulkan_SPIRV-Tools_LIBRARY) + set_property(TARGET Vulkan::SPIRV-Tools APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}") + endif() + if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY) + set_property(TARGET Vulkan::SPIRV-Tools APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Debug) + set_property(TARGET Vulkan::SPIRV-Tools + PROPERTY + IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}") + endif() + endif() +endif() + +if(Vulkan_MoltenVK_FOUND) + if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK) + add_library(Vulkan::MoltenVK SHARED IMPORTED) + set_target_properties(Vulkan::MoltenVK + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}" + IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}" + ) + endif() +endif() + +unset(_Vulkan_library_name) +unset(_Vulkan_hint_include_search_paths) +unset(_Vulkan_hint_executable_search_paths) +unset(_Vulkan_hint_library_search_paths) + +cmake_policy(POP) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 4af842a..f50116f 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -77,8 +77,13 @@ set(_ZLIB_SEARCH_NORMAL unset(_ZLIB_x86) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) -set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic zlibstat zlibvc) -set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibstatd zlibvcd) +if(ZLIB_USE_STATIC_LIBS) + set(ZLIB_NAMES zlibstatic zlibstat zlib z) + set(ZLIB_NAMES_DEBUG zlibstaticd zlibstatd zlibd zd) +else() + set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic zlibwapi zlibvc zlibstat) + set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibwapid zlibvcd zlibstatd) +endif() # Try each search configuration. foreach(search ${_ZLIB_SEARCHES}) @@ -87,9 +92,15 @@ endforeach() # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library if(NOT ZLIB_LIBRARY) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES}) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # Prefix/suffix of the win32/Makefile.gcc build + if(WIN32) + list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a") + endif() # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES if(ZLIB_USE_STATIC_LIBS) - set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) if(WIN32) set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) else() @@ -103,9 +114,8 @@ if(NOT ZLIB_LIBRARY) endforeach() # Restore the original find library ordering - if(ZLIB_USE_STATIC_LIBS) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_PREFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}) include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(ZLIB) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index ce0bc10..fb35ff0 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -112,6 +112,9 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12) target_compile_options(FortranCInterface PRIVATE "-fno-lto") target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects") +endif() +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12) target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects") endif() diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index fb363f4..056d025 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -332,7 +332,9 @@ endfunction() function(_cpack_nuget_make_files_tag) set(_files) foreach(_comp IN LISTS ARGN) - string(APPEND _files " <file src=\"${_comp}/**\" target=\".\" />\n") + cmake_path(APPEND _comp "**") + cmake_path(NATIVE_PATH _comp _comp) + string(APPEND _files " <file src=\"${_comp}\" target=\".\" />\n") endforeach() set(_CPACK_NUGET_FILES_TAG "<files>\n${_files} </files>" PARENT_SCOPE) endfunction() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 82c4383..3941311 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -191,7 +191,7 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") __windows_compiler_msvc(${lang}) set(CMAKE_${lang}_COMPILE_OPTIONS_WARNING_AS_ERROR "-WX") - set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc ") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-imsvc") endmacro() else() cmake_policy(GET CMP0091 __WINDOWS_CLANG_CMP0091) |