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 254 forks source link

Disabling examples breaks build #15

Closed photex closed 6 years ago

photex commented 6 years ago

Howdy!

Looks like texturev depend on common.h in bgfx/examples/common. When you configure the project without examples the path is no longer part of the included header search paths.

C:\projects\bgfx.cmake\.build>cmake -GNinja ..-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
.....<snip>....
C:\projects\bgfx.cmake\.build>rg texturev.cpp compile_commands.json
82:  "command": "C:\\PROGRA~2\\MICROS~3\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1411~1.255\\bin\\HostX64\\x64\\cl.exe  /nologo /TP -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I..\\bgfx\\examples\\common -I..\\bgfx\\include -I..\\bx\\include -I..\\bx\\include\\compat\\msvc -I..\\bimg\\include -I..\\bimg\\3rdparty -I..\\bimg\\3rdparty\\iqa\\include -I..\\bimg\\3rdparty\\nvtt -I..\\bgfx\\3rdparty  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   /FoCMakeFiles\\texturev.dir\\bgfx\\tools\\texturev\\texturev.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\projects\\bgfx.cmake\\bgfx\\tools\\texturev\\texturev.cpp",
83:  "file": "C:/projects/bgfx.cmake/bgfx/tools/texturev/texturev.cpp"

C:\projects\bgfx.cmake\.build>cmake -GNinja .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBGFX_BUILD_EXAMPLES=OFF
-- Configuring done
-- Generating done
-- Build files have been written to: C:/projects/bgfx.cmake/.build

C:\projects\bgfx.cmake\.build>rg texturev.cpp compile_commands.json
58:  "command": "C:\\PROGRA~2\\MICROS~3\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1411~1.255\\bin\\HostX64\\x64\\cl.exe  /nologo /TP   /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   /FoCMakeFiles\\texturev.dir\\bgfx\\tools\\texturev\\texturev.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\projects\\bgfx.cmake\\bgfx\\tools\\texturev\\texturev.cpp",
59:  "file": "C:/projects/bgfx.cmake/bgfx/tools/texturev/texturev.cpp"
photex commented 6 years ago

This seems to fix this particular problem.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05ab376..4a267de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,9 +51,7 @@ if( BGFX_BUILD_TOOLS )
        include( cmake/tools.cmake )
 endif()

-if( BGFX_BUILD_EXAMPLES )
-       include( cmake/examples.cmake )
-endif()
+include( cmake/examples.cmake )

 if( BGFX_INSTALL )
        # install bx
diff --git a/bx b/bx
index cf9acbf..b7f1772 160000
--- a/bx
+++ b/bx
@@ -1 +1 @@
-Subproject commit cf9acbfdb09e929b22f698eeb63a48618d6cb3ef
+Subproject commit b7f1772545ee5c5220ecbcff258761372d75ea43
diff --git a/cmake/examples.cmake b/cmake/examples.cmake
index 15e7b14..e70a3cb 100755
--- a/cmake/examples.cmake
+++ b/cmake/examples.cmake
@@ -198,6 +198,8 @@ set(
        36-sky
 )

-foreach( EXAMPLE ${BGFX_EXAMPLES} )
-       add_example( ${EXAMPLE} )
-endforeach()
+if( BGFX_BUILD_EXAMPLES )
+  foreach( EXAMPLE ${BGFX_EXAMPLES} )
+         add_example( ${EXAMPLE} )
+  endforeach()
+endif()
JoshuaBrookover commented 6 years ago

Should be fixed with #16. If not, let me know.

photex commented 6 years ago

Awesome. Everything works well. Thanks @JoshuaBrookover @jaynus