# missing libraries when use self cmake generated package

**URL:** https://discourse.cmake.org/t/missing-libraries-when-use-self-cmake-generated-package/5881
**Category:** Code
**Created:** [June 17, 2022, 1:53am UTC](https://discourse.cmake.org/t/missing-libraries-when-use-self-cmake-generated-package/5881 "2022-06-17T01:53:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zhang-qiang-github](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zhang-qiang-github/32/1913_2.png) [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)
#### Post date: [June 17, 2022, 1:53am UTC](https://discourse.cmake.org/t/missing-libraries-when-use-self-cmake-generated-package/5881/1 "2022-06-17T01:53:19Z")

</div>

I have generated a package by myself, and the CMakeLists.txt looks like:

```auto
...

install(TARGETS pA pB
	EXPORT SustaoBasic
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
)

install(DIRECTORY package/ DESTINATION include
	FILES_MATCHING PATTERN "*.h"
)

install(EXPORT SustaoBasic
	FILE SustaoBasic.cmake
	NAMESPACE SustaoBasic::
	DESTINATION lib/cmake
)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
	SustaoBasicConfigVersion.cmake
	VERSION V1.0
	COMPATIBILITY AnyNewerVersion # 表示该函数库向下兼容
)

configure_package_config_file(
	SustaoBasicConfig.cmake.in ${PROJECT_BINARY_DIR}/SustaoBasicConfig.cmake
	INSTALL_DESTINATION lib/cmake
)

install(FILES "${PROJECT_BINARY_DIR}/SustaoBasicConfig.cmake"
              "${PROJECT_BINARY_DIR}/SustaoBasicConfigVersion.cmake"
        DESTINATION lib/cmake)

```

I need a thirdparty `Algorithm` in my `SustaoBasic` package, which is a pure `dll/lib`. When I import link `SustaoBasic` to `Pro`, it reports `unresolved external symbol Algorithm`. If I link `Algorithm` to `Pro`, everything is OK.

But, I don’t want to link `Algorithm` when I import `SustaoBasic` package each time. I find that `SustaoBasicConfig.cmake` can declare the dependency by:

```auto
find_dependency(VTK REQUIRED)

```

But, my `Algorithm` is a pure `dll/lib`, and it do not support `find_package()`. If I declare `find_dependency(Algorithm REQUIREd)`, the `CMake` would repored:

```auto
By not providing "FindAlgorithm.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Algorithm", but CMake did not find one.

Could not find a package configuration file provided by "Algorithm" with any of the following names:
    AlgorithmConfig.cmake
    algorithm-config.cmake
...

```

How can I declare the dependency `Algorithm` to `SustaoBasic`? Or how to avoid link `Algorithm` to `Pro` when I import `SustaoBasic` in `Pro`?

Any suggestion is appreciated~~~

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 9, 2022, 1:05pm UTC](https://discourse.cmake.org/t/missing-libraries-when-use-self-cmake-generated-package/5881/2 "2022-07-09T13:05:11Z")

</div>

> [@zhang-qiang-github](#):
>
> How can I declare the dependency `Algorithm` to `SustaoBasic`?

There’s no mechanism for this; you’ll need to add a way to get the imported target(s) in your `SustaoBasicConfig.cmake` somehow. If you can reuse the way to construct them during the main build, that would be best (e.g., reusing a `FindAlgorithm.cmake` module).
