mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-25 11:26:22 +00:00
Migrate build system to CMake
See #5895 for details. This commit does not include CI or documentation changes.
This commit is contained in:
parent
9d0cdb8551
commit
9b087b4aa7
207 changed files with 5202 additions and 2294 deletions
43
cmake/PkgConfig.cmake
Normal file
43
cmake/PkgConfig.cmake
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Syntax:
|
||||
#
|
||||
# pkg_config_import(<package>)
|
||||
#
|
||||
# To use this command, `find_package(PkgConfig)` must be used beforehand, but it does
|
||||
# not have to succeed. If the `PkgConfig` package is not found, all imports silently fail.
|
||||
#
|
||||
# Imports `<package>` as a CMake `IMPORTED` target `PkgConfig::<package>`.
|
||||
# Updates the global `PACKAGES_FOUND` and `PACKAGES_NOT_FOUND` properties and defines
|
||||
# the `<package>_FOUND` variable.
|
||||
#
|
||||
function(pkg_config_import arg_PREFIX)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "MODULES")
|
||||
if (NOT arg_MODULES)
|
||||
set(arg_MODULES ${arg_PREFIX})
|
||||
endif()
|
||||
|
||||
if (PkgConfig_FOUND)
|
||||
# Once CMake 4.1 is available, this call should be replaced with `cmake_pkg_config()`.
|
||||
pkg_check_modules(${arg_PREFIX} IMPORTED_TARGET ${arg_MODULES})
|
||||
if (${arg_PREFIX}_FOUND)
|
||||
# We found the pkgconfig file, but is it actually a usable package?
|
||||
# The main cause of failure here would be cross-compiling, which pkg-config does not
|
||||
# handle very well (especially pre-`cmake_pkg_config()`).
|
||||
try_compile(is_usable
|
||||
SOURCE_FROM_CONTENT "main.cc" "int main() {}"
|
||||
LINK_LIBRARIES PkgConfig::${arg_PREFIX}
|
||||
LOG_DESCRIPTION "Checking if PkgConfig::${arg_PREFIX} is usable"
|
||||
)
|
||||
if (NOT is_usable)
|
||||
message(STATUS "Modules '${arg_MODULES}' unusable (bad \$PKG_CONFIG_LIBDIR?)")
|
||||
set(${arg_PREFIX}_FOUND 0)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (${arg_PREFIX}_FOUND)
|
||||
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND ${arg_PREFIX})
|
||||
else()
|
||||
set_property(GLOBAL APPEND PROPERTY PACKAGES_NOT_FOUND ${arg_PREFIX})
|
||||
endif()
|
||||
return (PROPAGATE ${arg_PREFIX}_FOUND)
|
||||
endfunction()
|
||||
Loading…
Add table
Add a link
Reference in a new issue