How to build OpenCL examples? (no CMakeLists.txt)

Post Reply
przecze
Posts: 3
Joined: Mon Jun 17, 2019 12:15 pm

How to build OpenCL examples? (no CMakeLists.txt)

Post by przecze »

Hi,
so, according to README and docs you just need to pass `--enable_experimental_opencl` to `App_ExampleBrowser` to see the examples. But I tried that, and examples were still missing from the browser. I checked the source code and found this:

Code: Select all

void ExampleEntriesAll::initOpenCLExampleEntries()
{
#ifdef B3_USE_CLEW
#ifndef NO_OPENGL3
	int numDefaultEntries = sizeof(gOpenCLExamples) / sizeof(ExampleEntry);
	for (int i = 0; i < numDefaultEntries; i++)
	{
		m_data->m_allExamples.push_back(gOpenCLExamples[i]);
	}
#endif
#endif  //B3_USE_CLEW
}
And I discovered taht `B3_USE_CLEW` was not defined in my case. I tried to check when CMake adds this definition, and there's a `ADD_DEFINITIONS(-DB3_USE_CLEW)` in src/Bullet3OpenCL/CMakeLists.txt. But according to CMake docs, this cannot affect the examples directory.
So I tried adding `ADD_DEFINITIONS(-DB3_USE_CLEW)` to examples/CMakeLists.txt but this results in undefined references, because the code in examples/OpenCL directory is not being build at all. I tried adding `OpenCL/broadphase` etc. to `SUBDIRS` in examples/CMakeLists.txt but this didn't change anything because, as I realized, there's no CMakeLists.txt in examples/OpenCL

So my question is: documentation gives the impression that all OpenCL examples are build by default, you just need to enable them in the Browser by passing a flag. Yet from what I see, building them requires messing with CMake files and even writing some of them single-handedly. Am I missing something?
Post Reply