mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
Add `EXPORT bgfx-config` with `bgfx::` namespace to auto generate a
`bgfx-config.cmake` file at install time (INSTALL on `visual studio` or `make
install` on MakeFile projects).
The file is for use with `find_package` and installs itself in the
lib directory under `cmake/bgfx/bgfx-config.cmake`.
If installed on a linux system, `find_package` will find this config
file without any configuration.
This config file allows dependent projects to use commands such as
linking with bgfx:
```
find_package(bgfx REQUIRED COMPONENTS bgfx)
target_link_libraries(dependent PUBLIC bgfx::bgfx)
```
or compiling a shader at build time:
```
find_package(bgfx REQUIRED COMPONENTS shaderc)
add_custom_command(OUTPUT compiled_shader.glsl
COMMAND
bgfx::shaderc
-f vs_input_shader.sc
-o compiled_shader.glsl
--type vertex)
```
50 lines
1.6 KiB
CMake
50 lines
1.6 KiB
CMake
# bgfx.cmake - bgfx building in cmake
|
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
|
|
|
# To the extent possible under law, the author(s) have dedicated all copyright
|
|
# and related and neighboring rights to this software to the public domain
|
|
# worldwide. This software is distributed without any warranty.
|
|
|
|
# You should have received a copy of the CC0 Public Domain Dedication along with
|
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
# Third party libs
|
|
include( cmake/3rdparty/astc-codec.cmake )
|
|
include( cmake/3rdparty/astc.cmake )
|
|
include( cmake/3rdparty/edtaa3.cmake )
|
|
include( cmake/3rdparty/etc1.cmake )
|
|
include( cmake/3rdparty/etc2.cmake )
|
|
include( cmake/3rdparty/iqa.cmake )
|
|
include( cmake/3rdparty/libsquish.cmake )
|
|
include( cmake/3rdparty/nvtt.cmake )
|
|
include( cmake/3rdparty/pvrtc.cmake )
|
|
|
|
# Ensure the directory exists
|
|
if( NOT IS_DIRECTORY ${BIMG_DIR} )
|
|
message( SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}" )
|
|
return()
|
|
endif()
|
|
|
|
# Grab the bimg source files
|
|
file( GLOB BIMG_SOURCES ${BIMG_DIR}/src/*.cpp )
|
|
|
|
# Create the bimg target
|
|
add_library( bimg STATIC ${BIMG_SOURCES} )
|
|
|
|
# Add include directory of bimg
|
|
target_include_directories( bimg
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${BIMG_DIR}/include>
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
|
|
# bimg dependencies
|
|
target_link_libraries( bimg bx astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc )
|
|
|
|
# Put in a "bgfx" folder in Visual Studio
|
|
set_target_properties( bimg PROPERTIES FOLDER "bgfx" )
|
|
|
|
# Export debug build as "bimgd"
|
|
if( BGFX_USE_DEBUG_SUFFIX )
|
|
set_target_properties( bimg PROPERTIES OUTPUT_NAME_DEBUG "bimgd" )
|
|
endif()
|