diff --git a/CMakeLists.txt b/CMakeLists.txt index 65ffe44..c3a74df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ endif() option( BGFX_BUILD_TOOLS "Build bgfx tools." ON ) option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON ) +include( cmake/shared.cmake ) include( cmake/bx.cmake ) include( cmake/bgfx.cmake ) diff --git a/cmake/3rdparty/fcpp.cmake b/cmake/3rdparty/fcpp.cmake index a5220f7..98a4c5d 100755 --- a/cmake/3rdparty/fcpp.cmake +++ b/cmake/3rdparty/fcpp.cmake @@ -8,6 +8,10 @@ # You should have received a copy of the CC0 Public Domain Dedication along with # this software. If not, see . +if( TARGET fcpp ) + return() +endif() + file( GLOB FCPP_SOURCES ${BGFX_DIR}/3rdparty/fcpp/*.c ${BGFX_DIR}/3rdparty/fcpp/*.h ) add_library( fcpp STATIC ${FCPP_SOURCES} ) diff --git a/cmake/3rdparty/forsyth-too.cmake b/cmake/3rdparty/forsyth-too.cmake new file mode 100644 index 0000000..0cd1a56 --- /dev/null +++ b/cmake/3rdparty/forsyth-too.cmake @@ -0,0 +1,19 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2016 by Joshua Brookover + +# 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 . + +if( TARGET forsyth-too ) + return() +endif() + +file( GLOB FORSYTH-TOO_SOURCES ${BGFX_DIR}/3rdparty/forsyth-too/*.cpp ${BGFX_DIR}/3rdparty/forsyth-too/*.h ) + +add_library( forsyth-too STATIC ${FORSYTH-TOO_SOURCES} ) +target_include_directories( forsyth-too PUBLIC ${BGFX_DIR}/3rdparty ) +set_target_properties( forsyth-too PROPERTIES FOLDER "bgfx/3rdparty" ) diff --git a/cmake/3rdparty/glsl-optimizer.cmake b/cmake/3rdparty/glsl-optimizer.cmake index 6e5f8fe..dabf304 100755 --- a/cmake/3rdparty/glsl-optimizer.cmake +++ b/cmake/3rdparty/glsl-optimizer.cmake @@ -8,6 +8,10 @@ # You should have received a copy of the CC0 Public Domain Dedication along with # this software. If not, see . +if( TARGET glsl-optimizer ) + return() +endif() + set( GLSL-OPTIMIZER_INCLUDES ${BGFX_DIR}/3rdparty/glsl-optimizer/include ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa diff --git a/cmake/3rdparty/ib-compress.cmake b/cmake/3rdparty/ib-compress.cmake index 9363951..a487c5f 100644 --- a/cmake/3rdparty/ib-compress.cmake +++ b/cmake/3rdparty/ib-compress.cmake @@ -8,6 +8,10 @@ # You should have received a copy of the CC0 Public Domain Dedication along with # this software. If not, see . +if( TARGET ib-compress ) + return() +endif() + file( GLOB IB_COMPRESS_SOURCES ${BGFX_DIR}/3rdparty/ib-compress/*.cpp ${BGFX_DIR}/3rdparty/ib-compress/*.h ) add_library( ib-compress STATIC ${IB_COMPRESS_SOURCES} ) diff --git a/cmake/3rdparty/ocornut-imgui.cmake b/cmake/3rdparty/ocornut-imgui.cmake index ecee099..b7cc51c 100644 --- a/cmake/3rdparty/ocornut-imgui.cmake +++ b/cmake/3rdparty/ocornut-imgui.cmake @@ -8,6 +8,10 @@ # You should have received a copy of the CC0 Public Domain Dedication along with # this software. If not, see . +if( TARGET ocornut-imgui ) + return() +endif() + file( GLOB OCORNUT_IMGUI_SOURCES ${BGFX_DIR}/3rdparty/ocornut-imgui/*.cpp ${BGFX_DIR}/3rdparty/ocornut-imgui/*.h ${BGFX_DIR}/3rdparty/ocornut-imgui/*.inl ) add_library( ocornut-imgui STATIC ${OCORNUT_IMGUI_SOURCES} ) diff --git a/cmake/examples.cmake b/cmake/examples.cmake index 750f4a7..1b2dc5d 100755 --- a/cmake/examples.cmake +++ b/cmake/examples.cmake @@ -123,7 +123,7 @@ function( add_example ARG_NAME ) endif() # Directory name - set_target_properties( example-${ARG_NAME} PROPERTIES FOLDER "examples" ) + set_target_properties( example-${ARG_NAME} PROPERTIES FOLDER "bgfx/examples" ) endfunction() # Add common library for examples diff --git a/cmake/shared.cmake b/cmake/shared.cmake new file mode 100644 index 0000000..7cbc1ec --- /dev/null +++ b/cmake/shared.cmake @@ -0,0 +1,18 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2016 by Joshua Brookover + +# 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 . + +add_library( bgfx-vertexdecl INTERFACE ) +target_sources( bgfx-vertexdecl INTERFACE ${BGFX_DIR}/src/vertexdecl.cpp ) +target_include_directories( bgfx-vertexdecl INTERFACE ${BGFX_DIR}/include ) + +add_library( bgfx-bounds INTERFACE ) +target_sources( bgfx-bounds INTERFACE ${BGFX_DIR}/examples/common/bounds.cpp ) +target_include_directories( bgfx-bounds INTERFACE ${BGFX_DIR}/include ) +target_include_directories( bgfx-bounds INTERFACE ${BGFX_DIR}/examples/common ) diff --git a/cmake/tools.cmake b/cmake/tools.cmake index 97858f9..48defa5 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -8,4 +8,5 @@ # You should have received a copy of the CC0 Public Domain Dedication along with # this software. If not, see . +include( cmake/tools/geometryc.cmake ) include( cmake/tools/shaderc.cmake ) diff --git a/cmake/tools/geometryc.cmake b/cmake/tools/geometryc.cmake new file mode 100644 index 0000000..0e9927c --- /dev/null +++ b/cmake/tools/geometryc.cmake @@ -0,0 +1,19 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2016 by Joshua Brookover + +# 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 . + +include( CMakeParseArguments ) + +include( cmake/3rdparty/forsyth-too.cmake ) +include( cmake/3rdparty/ib-compress.cmake ) + +add_executable( geometryc bgfx/tools/geometryc/geometryc.cpp ) +target_compile_definitions( geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" ) +set_target_properties( geometryc PROPERTIES FOLDER "bgfx/tools" ) +target_link_libraries( geometryc bx bgfx-bounds bgfx-vertexdecl forsyth-too ib-compress ) diff --git a/cmake/tools/shaderc.cmake b/cmake/tools/shaderc.cmake index d4d7d3b..5711819 100644 --- a/cmake/tools/shaderc.cmake +++ b/cmake/tools/shaderc.cmake @@ -16,7 +16,7 @@ include( cmake/3rdparty/glsl-optimizer.cmake ) add_executable( shaderc bgfx/tools/shaderc/shaderc.cpp bgfx/tools/shaderc/shaderc.h bgfx/tools/shaderc/shaderc_glsl.cpp bgfx/tools/shaderc/shaderc_hlsl.cpp ) target_compile_definitions( shaderc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" ) set_target_properties( shaderc PROPERTIES FOLDER "bgfx/tools" ) -target_link_libraries( shaderc bx bgfx fcpp glsl-optimizer ) +target_link_libraries( shaderc bx bgfx-vertexdecl fcpp glsl-optimizer ) function( add_shader ARG_FILE ) # Parse arguments