Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Generate modern CMake package config files on INSTALL. #82

Merged
merged 1 commit into from
May 11, 2020

Conversation

handsomematt
Copy link
Contributor

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:

  • bin
  • lib
    • cmake/bgfx
      • bgfxConfig.cmake
      • bgfxConfigVersion.cmake
      • bgfxTargets.cmake
      • bgfxTargets-debug.cmake
    • bgfx.lib
    • bgfxd.lib (debug)
    • ...
  • share/doc/bgfx
    • LICENSE
    • readme.md

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
Copy link
Contributor

pezcode commented May 10, 2020

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

@handsomematt
Copy link
Contributor Author

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
Copy link
Contributor

pezcode commented May 10, 2020

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 #80 for testing this, but that works as expected, too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants