-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Description
I hope this is the correct place to ask this question.
I have a library Foo which I install and a program Bar which requires this library.
In my library foo I create a FooConfig:
include("${CMAKE_CURRENT_LIST_DIR}/FooTargets.cmake")
Which imports the targets I generated in my CMakeLists.txt.
install(TARGETS Foo EXPORT FooTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(DIRECTORY include/foo DESTINATION include)
install(EXPORT FooTargets
FILE FooTargets.cmake
NAMESPACE Foo::
DESTINATION lib/cmake/Foo
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("FooConfigVersion.cmake"
VERSION ${Foo_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
"FooConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake"
DESTINATION lib/cmake/Foo
)
When I use simply cmake, I can run find_package(Foo REQUIRED)
in the CMakeLists.txt of Bar,
and the library will be imported.
This however does not work if I run emcmake cmake ..
. I get the following error message:
CMake Error at CMakeLists.txt:8 (find_package):
By not providing "FindFoo.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Foo", but
CMake did not find one.
Could not find a package configuration file provided by "Foo" with any of
the following names:
FooConfig.cmake
foo-config.cmake
Add the installation prefix of "Foo" to CMAKE_PREFIX_PATH or set
"Foo_DIR" to a directory containing one of the above files. If "Foo"
provides a separate development package or SDK, be sure it has been
installed.
tw-git, nowakowsk, lwyj123 and fuyb1992