update
This commit is contained in:
parent
583c07ad29
commit
8dce040cd9
257
utils.cmake
257
utils.cmake
|
@ -1516,7 +1516,7 @@ BEGIN
|
|||
END
|
||||
END
|
||||
")
|
||||
file(WRITE "${RC_ARGS_PATH}" ${__contents})
|
||||
file(GENERATE OUTPUT "${RC_ARGS_PATH}" CONTENT "${__contents}")
|
||||
endfunction()
|
||||
|
||||
function(generate_win32_manifest_file)
|
||||
|
@ -1669,7 +1669,7 @@ function(generate_win32_manifest_file)
|
|||
</application>
|
||||
</assembly>
|
||||
")
|
||||
file(WRITE "${MF_ARGS_PATH}" ${__contents})
|
||||
file(GENERATE OUTPUT "${MF_ARGS_PATH}" CONTENT "${__contents}")
|
||||
endfunction()
|
||||
|
||||
function(query_qt_paths)
|
||||
|
@ -2055,7 +2055,7 @@ ${__modify_lost_warning}
|
|||
${__options}
|
||||
#endif // ${__inc_guard}
|
||||
")
|
||||
file(WRITE "${arg_PATH}" "${__config_content}")
|
||||
file(GENERATE OUTPUT "${arg_PATH}" CONTENT "${__config_content}")
|
||||
endfunction()
|
||||
|
||||
function(query_git_information)
|
||||
|
@ -2128,52 +2128,107 @@ function(query_compiler_information)
|
|||
if(arg_UNPARSED_ARGUMENTS)
|
||||
message(AUTHOR_WARNING "query_compiler_information: Unrecognized arguments: ${arg_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
set(__lang "C")
|
||||
set(__lang "CXX")
|
||||
set(__id "${CMAKE_${__lang}_COMPILER_ID}")
|
||||
if("x${__id}" STREQUAL "x")
|
||||
set(__lang "CXX")
|
||||
set(__lang "C")
|
||||
set(__id "${CMAKE_${__lang}_COMPILER_ID}")
|
||||
endif()
|
||||
if("x${__id}" STREQUAL "x")
|
||||
message(AUTHOR_WARNING "query_compiler_information: Can't find a valid C/C++ toolchain!")
|
||||
return()
|
||||
endif()
|
||||
set(__sim_id "${CMAKE_${__lang}_SIMULATE_ID}")
|
||||
set(__native FALSE)
|
||||
if("x${__sim_id}" STREQUAL "x")
|
||||
set(__native TRUE)
|
||||
endif()
|
||||
set(__msvc_like FALSE)
|
||||
if("x${__sim_id}" STREQUAL "xMSVC")
|
||||
set(__msvc_like TRUE)
|
||||
endif()
|
||||
set(__gnu_like FALSE)
|
||||
if("x${__sim_id}" STREQUAL "xGNU")
|
||||
set(__gnu_like TRUE)
|
||||
endif()
|
||||
# Is this better than the simulate ID ?
|
||||
set(__frontend "${CMAKE_${__lang}_COMPILER_FRONTEND_VARIANT}")
|
||||
# The target for cross-compiling, if supported.
|
||||
set(__triple "${CMAKE_${__lang}_COMPILER_TARGET}")
|
||||
if(arg_VERSION)
|
||||
set(${arg_VERSION} "${CMAKE_${__lang}_COMPILER_VERSION}" PARENT_SCOPE)
|
||||
if("x${${arg_VERSION}}" STREQUAL "x")
|
||||
set(${arg_VERSION} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
if(__id MATCHES "Clang")
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Clang" PARENT_SCOPE)
|
||||
endif()
|
||||
if(__id STREQUAL "AppleClang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Apple" PARENT_SCOPE)
|
||||
if(__native)
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Clang" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://opensource.apple.com/source/clang/" PARENT_SCOPE)
|
||||
if(__id STREQUAL "AppleClang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Apple®" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://opensource.apple.com/source/clang/" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id STREQUAL "ARMClang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Arm®" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://developer.arm.com/documentation/100748/latest/" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id STREQUAL "IBMClang" OR __id STREQUAL "XLClang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "IBM®" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://www.ibm.com/docs/en/openxl-c-and-cpp-aix" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id STREQUAL "Clang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "LLVM" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://clang.llvm.org/" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Unknown Clang Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
elseif(__id STREQUAL "ARMClang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Arm" PARENT_SCOPE)
|
||||
elseif(__msvc_like)
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "clang-cl" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://developer.arm.com/documentation/100748/latest/" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id STREQUAL "IBMClang" OR __id STREQUAL "XLClang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "IBM" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://www.ibm.com/docs/en/openxl-c-and-cpp-aix" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id STREQUAL "Clang")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "LLVM" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://clang.llvm.org/" PARENT_SCOPE)
|
||||
set(${arg_HOMEPAGE} "https://clang.llvm.org/docs/UsersManual.html#clang-cl" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__gnu_like)
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "LLVM MinGW" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Martin Storsjö" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://github.com/mstorsjo/llvm-mingw/" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Unknown Clang Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
|
@ -2182,21 +2237,90 @@ function(query_compiler_information)
|
|||
endif()
|
||||
endif()
|
||||
elseif(__id STREQUAL "GNU")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "GNU Compiler Collection" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://gcc.gnu.org/" PARENT_SCOPE)
|
||||
if(MINGW)
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "MinGW-w64" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "The MinGW-w64 Project" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://www.mingw-w64.org/" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "GNU Compiler Collection" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "GNU" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://gcc.gnu.org/" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
elseif(__id STREQUAL "MSVC")
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Microsoft® Visual C/C++ Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Microsoft" PARENT_SCOPE)
|
||||
set(${arg_VENDOR} "Microsoft®" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://visualstudio.microsoft.com/" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id MATCHES "Intel")
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "Intel®" PARENT_SCOPE)
|
||||
endif()
|
||||
if(__native)
|
||||
if(__id STREQUAL "IntelLLVM")
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Intel® oneAPI DPC++/C++ Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler.html" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__id STREQUAL "Intel")
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Intel® C++ Compiler Classic" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-10/overview.html" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Unknown Intel Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
elseif(__msvc_like)
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "intel-cl" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(__gnu_like)
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "intel-gcc" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Unknown Intel Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_HOMEPAGE)
|
||||
set(${arg_HOMEPAGE} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(arg_NAME)
|
||||
set(${arg_NAME} "Unknown C/C++ Compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
if(arg_VENDOR)
|
||||
set(${arg_VENDOR} "UNKNOWN" PARENT_SCOPE)
|
||||
endif()
|
||||
|
@ -2212,7 +2336,7 @@ function(generate_project_version)
|
|||
message(AUTHOR_WARNING "generate_project_version: You need to call setup_project() first!")
|
||||
return()
|
||||
endif()
|
||||
cmake_parse_arguments(arg "OVERWRITE;COMMIT_HASH;COMMIT_SUBJECT;COMMIT_AUTHOR;COMMIT_DATETIME;COMMIT_BRANCH;COMPILER_NAME;COMPILER_VENDOR;COMPILER_VERSION;COMPILER_HOMEPAGE" "PATH" "" ${ARGN})
|
||||
cmake_parse_arguments(arg "OVERWRITE;COMMIT_HASH;COMMIT_SUBJECT;COMMIT_AUTHOR;COMMIT_DATETIME;COMMIT_BRANCH;COMPILER_NAME;COMPILER_VENDOR;COMPILER_VERSION;COMPILER_HOMEPAGE;BUILD_DATETIME;ARCHITECTURE" "PATH" "" ${ARGN})
|
||||
if(NOT arg_PATH)
|
||||
message(AUTHOR_WARNING "generate_project_version: You need to specify the file path!")
|
||||
return()
|
||||
|
@ -2236,23 +2360,50 @@ function(generate_project_version)
|
|||
set(__prefix "")
|
||||
get_target_property(__prefix ${__target} __PROJECT_VERSION_PREFIX)
|
||||
if("x${__prefix}" STREQUAL "x")
|
||||
set(__prefix "${PROJECT_NAME}_FEATURE")
|
||||
set(__prefix "${PROJECT_NAME}")
|
||||
message(AUTHOR_WARNING "generate_project_version: config prefix is not set, using ${__prefix} as default.")
|
||||
endif()
|
||||
set(__major "${PROJECT_VERSION_MAJOR}")
|
||||
if("x${__major}" STREQUAL "x")
|
||||
message(AUTHOR_WARNING "generate_project_version: PROJECT_VERSION_MAJOR is not set!")
|
||||
set(__major "0")
|
||||
endif()
|
||||
set(__minor "${PROJECT_VERSION_MINOR}")
|
||||
if("x${__minor}" STREQUAL "x")
|
||||
message(AUTHOR_WARNING "generate_project_version: PROJECT_VERSION_MINOR is not set!")
|
||||
set(__minor "0")
|
||||
endif()
|
||||
set(__patch "${PROJECT_VERSION_PATCH}")
|
||||
if("x${__patch}" STREQUAL "x")
|
||||
message(AUTHOR_WARNING "generate_project_version: PROJECT_VERSION_PATCH is not set!")
|
||||
set(__patch "0")
|
||||
endif()
|
||||
set(__tweak "${PROJECT_VERSION_TWEAK}")
|
||||
if("x${__tweak}" STREQUAL "x")
|
||||
message(AUTHOR_WARNING "generate_project_version: PROJECT_VERSION_TWEAK is not set!")
|
||||
set(__tweak "0")
|
||||
endif()
|
||||
set(__full_ver "${PROJECT_VERSION}")
|
||||
if("x${__full_ver}" STREQUAL "x")
|
||||
set(__full_ver "0.0.0.0")
|
||||
endif()
|
||||
set(__full_ver_hex "0x00000000")
|
||||
math(EXPR __full_ver_hex "((${__major} & 0xff) << 24) | ((${__minor} & 0xff) << 16) | ((${__patch} & 0xff) << 8) | (${__tweak} & 0xff)" OUTPUT_FORMAT HEXADECIMAL)
|
||||
set(__inc_guard "_${PROJECT_NAME}_VERSION_INCLUDE_GUARD_")
|
||||
set(__versions "")
|
||||
set(__common_num "[[maybe_unused]] inline constexpr const unsigned long")
|
||||
set(__common_str "[[maybe_unused]] inline constexpr const char")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_MAJOR = ${PROJECT_VERSION_MAJOR};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_MINOR = ${PROJECT_VERSION_MINOR};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_PATCH = ${PROJECT_VERSION_PATCH};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_TWEAK = ${PROJECT_VERSION_TWEAK};\n")
|
||||
string(APPEND __versions "${__common_str} ${__prefix}_VERSION_STR[] = \"${PROJECT_VERSION}\";\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_MAJOR__ ${PROJECT_VERSION_MAJOR}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_MINOR__ ${PROJECT_VERSION_MINOR}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_PATCH__ ${PROJECT_VERSION_PATCH}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_TWEAK__ ${PROJECT_VERSION_TWEAK}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION__ ${PROJECT_VERSION_MINOR}\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_MAJOR = ${__major};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_MINOR = ${__minor};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_PATCH = ${__patch};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION_TWEAK = ${__tweak};\n")
|
||||
string(APPEND __versions "${__common_num} ${__prefix}_VERSION = ${__full_ver_hex};\n")
|
||||
string(APPEND __versions "${__common_str} ${__prefix}_VERSION_STR[] = \"${__full_ver}\";\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_MAJOR__ ${__major}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_MINOR__ ${__minor}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_PATCH__ ${__patch}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION_TWEAK__ ${__tweak}\n")
|
||||
string(APPEND __versions "#define __${__prefix}_VERSION__ ${__full_ver_hex}\n")
|
||||
if(arg_COMMIT_HASH)
|
||||
set(__hash "")
|
||||
query_git_information(HASH __hash)
|
||||
|
@ -2298,6 +2449,18 @@ function(generate_project_version)
|
|||
query_compiler_information(NAME __homepage)
|
||||
string(APPEND __versions "${__common_str} ${__prefix}_COMPILER_HOMEPAGE_STR[] = \"${__homepage}\";\n")
|
||||
endif()
|
||||
if(arg_BUILD_DATETIME)
|
||||
set(__datetime "")
|
||||
string(TIMESTAMP __datetime UTC)
|
||||
string(APPEND __versions "${__common_str} ${__prefix}_BUILD_DATETIME_STR[] = \"${__datetime}\";\n")
|
||||
endif()
|
||||
if(arg_ARCHITECTURE)
|
||||
set(__arch "x86")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(__arch "x64")
|
||||
endif()
|
||||
string(APPEND __versions "${__common_str} ${__prefix}_ARCHITECTURE_STR[] = \"${__arch}\";\n")
|
||||
endif()
|
||||
set(__version_content "${__license_header}
|
||||
|
||||
${__modify_lost_warning}
|
||||
|
@ -2310,5 +2473,5 @@ ${__modify_lost_warning}
|
|||
${__versions}
|
||||
#endif // ${__inc_guard}
|
||||
")
|
||||
file(WRITE "${arg_PATH}" "${__version_content}")
|
||||
file(GENERATE OUTPUT "${arg_PATH}" CONTENT "${__version_content}")
|
||||
endfunction()
|
||||
|
|
Loading…
Reference in New Issue