Skip to content

Commit

Permalink
Make `dependency('foo', static: true, method: 'cmake') link statically
Browse files Browse the repository at this point in the history
Fixes #1709
  • Loading branch information
Volker-Weissmann authored and jpakkane committed May 13, 2023
1 parent 2699fd4 commit a8b144b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions mesonbuild/dependencies/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def _detect_dep(self, name: str, package_version: str, modules: T.List[T.Tuple[s
cmake_opts += ['-DARCHS={}'.format(';'.join(self.cmakeinfo.archs))]
cmake_opts += [f'-DVERSION={package_version}']
cmake_opts += ['-DCOMPS={}'.format(';'.join([x[0] for x in comp_mapped]))]
cmake_opts += [f'-DSTATIC={self.static}']
cmake_opts += args
cmake_opts += self.traceparser.trace_args()
cmake_opts += toolchain.get_cmake_args()
Expand Down
4 changes: 4 additions & 0 deletions mesonbuild/dependencies/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ set(PACKAGE_FOUND FALSE)
set(_packageName "${NAME}")
string(TOUPPER "${_packageName}" PACKAGE_NAME)

if("${STATIC}" STREQUAL "True")
set("${NAME}_USE_STATIC_LIBS" "ON")
endif()

while(TRUE)
if ("${VERSION}" STREQUAL "")
find_package("${NAME}" QUIET COMPONENTS ${COMPS})
Expand Down
3 changes: 2 additions & 1 deletion test cases/rust/13 external c dependencies/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
]
},
"exclude": [
{ "static": true, "method": "pkg-config" }
{ "static": true, "method": "pkg-config" },
{ "static": true, "method": "cmake" }
]
}
}

0 comments on commit a8b144b

Please sign in to comment.