how to link .cmake files with Unreal Engine?

Hi,

I want to link a library which is being generated using CMake. After building the project it generated .cmake files in the bin folder.
To link with .cmake files find_target() and target_link_libraries() methods are used and these are cmake commands and cannot be used in Unreal.
is there a way I can link the library with unreal?

UE4CMake might work for you. It will compile the cmake project and automatically link the libraries. It is not using find_target() but since it is controlling the build/install it should work with most cmake projects.

You might find “PreBuildSteps” in your project or plugin file useful. You can run arbitrary batch commands before UBT compiles your project. In our plugin we check for a build.bat file’s existence, and run it if it’s there. Note you have to clean/rebuild to get changes to the PreBuildSteps to be recognized, which is why we call a .bat file (which can change) rather than just writing the commands out in PreBuildSteps.

UE4CMake also adds the cmake target’s source and CMakeLists file to the ModuleRules.ExternalDependencies so that if any of them change the cmake project should be rebuilt when the UE4 project is built.