diff options
| author | RichardYCJ <[email protected]> | 2023-03-10 20:02:56 +0800 |
|---|---|---|
| committer | RichardYCJ <[email protected]> | 2023-03-10 20:02:56 +0800 |
| commit | e22cfe2d6205983623a227be5ca563157beced80 (patch) | |
| tree | ff2f4ae9f34860be3a712b8d6178a42a77fd9571 | |
| parent | fdb8bc00233b61f17390f2ac60ae18d710a7a535 (diff) | |
improve cmake::find_package
add extra `find_name` to configurations.
| -rw-r--r-- | xmake/modules/package/manager/cmake/configurations.lua | 1 | ||||
| -rw-r--r-- | xmake/modules/package/manager/cmake/find_package.lua | 11 |
2 files changed, 7 insertions, 5 deletions
diff --git a/xmake/modules/package/manager/cmake/configurations.lua b/xmake/modules/package/manager/cmake/configurations.lua index ae69199ba..fdb34907b 100644 --- a/xmake/modules/package/manager/cmake/configurations.lua +++ b/xmake/modules/package/manager/cmake/configurations.lua @@ -28,6 +28,7 @@ function main() moduledirs = {description = "Set the cmake modules directories."}, presets = {description = "Set the preset values, e.g. {Boost_USE_STATIC_LIB = true}"}, envs = {description = "Set the run environments of cmake, e.g. {CMAKE_PREFIX_PATH = \"xxx\"}"}, + find_name = {description = "Set the name used for ${find_name}_LIBS/_INCLUDE_DIRS in cmake"}, } end diff --git a/xmake/modules/package/manager/cmake/find_package.lua b/xmake/modules/package/manager/cmake/find_package.lua index b42acabc2..686739e28 100644 --- a/xmake/modules/package/manager/cmake/find_package.lua +++ b/xmake/modules/package/manager/cmake/find_package.lua @@ -78,19 +78,20 @@ function _find_package(cmake, name, opt) end end local testname = "test_" .. name + local findname = configs.find_name or name cmakefile:print("find_package(%s REQUIRED %s)", requirestr, componentstr) cmakefile:print("if(%s_FOUND)", name) cmakefile:print(" add_executable(%s test.cpp)", testname) cmakefile:print(" target_include_directories(%s PRIVATE ${%s_INCLUDE_DIR} ${%s_INCLUDE_DIRS})", - testname, name, name) + testname, findname, findname) cmakefile:print(" target_include_directories(%s PRIVATE ${%s_INCLUDE_DIR} ${%s_INCLUDE_DIRS})", - testname, name:upper(), name:upper()) + testname, findname:upper(), findname:upper()) cmakefile:print(" target_include_directories(%s PRIVATE ${%s_CXX_INCLUDE_DIRS})", - testname, name) + testname, findname) cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})", - testname, name, name, name) + testname, findname, findname, findname) cmakefile:print(" target_link_libraries(%s ${%s_LIBRARY} ${%s_LIBRARIES} ${%s_LIBS})", - testname, name:upper(), name:upper(), name:upper()) + testname, findname:upper(), findname:upper(), findname:upper()) if configs.link_libraries then cmakefile:print(" target_link_libraries(%s %s)", testname, table.concat(table.wrap(configs.link_libraries), " ")) |
