widberg / bgfx.cmake

https://github.com/bkaradzic/bgfx.cmake. Independently maintained CMake build scripts for bgfx. Released under public domain.
https://github.com/bkaradzic/bgfx.cmake
Creative Commons Zero v1.0 Universal
286 stars 252 forks source link

Generate modern CMake package config files on INSTALL. #82

Closed handsomematt closed 4 years ago

handsomematt commented 4 years ago

Modifies the installation slightly to generate a modern CMake configuration installation target that can be included in a project like so:

# bgfx_DIR = bgfx_install/lib/cmake/bgfx
find_package(bgfx)
target_link_libraries(my_exe bgfx::bgfx)

We also change the hard coded "bin", "lib", "include" paths to the CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_LIBDIR, counterparts.

An example of the generated install directory:

An example of building both Debug/Release binaries on Windows:

cmake -A "$(buildPlatform)" -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=./install -DBGFX_BUILD_EXAMPLES=OFF -DBGFX_BUILD_TOOLS=ON -DBGFX_INSTALL=ON ..
cmake --build . --target install --config Debug
cmake --build . --target install --config Release

Depends on #80 #81

pezcode commented 4 years ago

Great change 👌 This should also make it fairly simple to create a package on vcpkg

handsomematt commented 4 years ago

Great change 👌 This should also make it fairly simple to create a package on vcpkg

That's the plan!

I have previously tested these changes on Linux with them working perfectly, however I've not tested it on upstream in 4 months so would be great if someone could make sure it works.

pezcode commented 4 years ago

Gave it a test on Windows 10 with MSVC 2019, and it works fine! 💯 Just called find_package and added a cpp that simply calls bgfx::init(). (This could probably be done on CI as well, to test the installing step.)

I manually applied https://github.com/widberg/bgfx.cmake/pull/80 for testing this, but that works as expected, too.