Closed Scindix closed 6 years ago
CMRC uses a global table (unforuntate. I've thought about changing this approach) to store the resource file pointers. The CMRC_INIT
call initializes the table entries for the named resource library so that cmrc::open
will load them correctly.
There are a few potential problems, and I'd be curious to see what's gone wrong. My biggest hypothesis: There isn't a single global table that it is using. If the table
in table.emplace
is not the same table used in cmrc::open
, they won't be able to see each other. This might happen if the linker is doing something unexpected.
Might you be able to attach a debugger and break into the CMRC_INIT
call?
In the future, a better approach might involve not using a global table.
I found the source of the error.
Android Studio uses gradle scripts to compile an app. However these scripts don't output any messages from CMake (which is extremely annoying). If you want to see messages and warnings you have to invoke "cmake ." and "make" by hand in a terminal. Which is what I did and which created mentioned files that are totally correct. However if I want to create an executable apk for android I need to run the gradle scripts and they are using their own copy of cmake. It seems that "3.6.0-rc2" is the maximum allowed version. However that version of cmake doesn't support the "PARSE_ARGV" signature of "cmake_parse_arguments". (See cmake documentation)
So changing this line:
cmake_parse_arguments(PARSE_ARGV 1 ARG "${options}" "${args}" "${list_args}")
to
cmake_parse_arguments(ARG "${options}" "${args}" "${list_args}" "${ARGN}")
fixed it for me.
Interesting...
I'll keep this issue open so that I can go back and commit the fix, and also set cmake_minimum_required
to a reasonable version so that this can be avoided in the future.
It's been a while, but this should work now in older CMake versions. I've added a cmake_minimum_required()
to enforce a minimum version.
I'm currently writing a C++ app for android and accessing assets from native code is far from trivial in Android. On my search for alternatives I stumbled upon your resource compiler. It looks fantastic and would solve a lot of problems for me. However when I try to access resources it just returns null pointers as iterators. Have a look at the following: Inside CMakeLists.txt:
Inside C++:
The code compiles without errors and prints two zeros when executed. However the vertex shader file definitely contains data. In order to get behind this I added the following line to the cmake script:
This prints "infile: /home/<...>/ProjectPath/app/src/main/assets/shader/standard.vs" (and respectively "*.fs") which are the valid paths to my files I want to include. (Tested using "cat") The table entries in "/home/<...>/ProjectPath/app/shaderFiles/lib_.cpp" are the following:
So I'm using the correct keys and the script uses the correct file paths. What could have gone wrong? How can I further investigate this problem? I'm not exactly a CMake expert...