Reputation: 2689
At the moment I believe I need to get the location of a target's output from the command line of Cmake (after it's built).
Or, maybe I need to script CMake to allow a process to be run on a target (after it's built).
Our basic flow will be:
and I want to make this more easily done from one place on the command line.
At the moment, we're planning on putting a python front end to our build stuff (since it's a heterogenous SoC with multiple processors, we can't have a single configuration due to multiple compilers required) so some scripting on the outside isn't a big deal.
I'd like to be able to do something like:
cmake <configuration stuff>
build.py <target>
debug.py <target>
profile.py <target>
without the developer having to know exactly where the target's binary is. (FYI, these things are more complicated than just calling gdb or whatever, so they do require a script to make it happen from the command line via 3rd party tools)
Is this easily accomplishable? Or do I need to script up some stuff in Cmake to output the required information to a file during configuration and query that file after the fact?
Any guidance or help accomplishing my goal is greatly appreciated.
edit: trying to be more pointed in my questioning:
After I've configured using cmake. is there a way from the build directory to run cmake again to query the cache/buildsystem/whatever to find out where a target's output would be.
for example:
./source
/modules
/module1
/submodule1
/test1
/submodule2
/test1
/module2
/test1
/module3
/test1
I go into my build directory, do cmake -S .. -B . <etc>
I now have a tree filled with makefiles and other stuff.
If i do make, that tree gets populated with build artifacts that roughly mirrors the source tree (at least it does in my experience)
if I do make help
it outputs a bunch of targets by name.
module1
submodule1
submodule1_test1
submodule2
submodule2_test1
etc.
Now, I want to know where submodule1_test1's executable is without having to know that its parent is module1. Can I, at this point, run cmake and query the cache/buildsystem to get the location of that named target?
If I can't, I can manage it myself by forming a "database" at configure time. It's not a problem. I just was hoping cmake kept that information around for querying at a later time in its cache or whatever.
Upvotes: 2
Views: 1745
Reputation: 667
When you first generate your project with CMake, it creates a CMakeCache.txt file which has all the variables cache variables from your project. You can use Python to parse it and find the project_name_BINARY_DIR variable. That will be your build destination root. From that point on, you can use Python to recursively check the subdirectories for test executables if they all have a standard naming pattern such as FooTests.exe.
Alternatively, if you use the set cache command, it should also get added to the CMakeCache.txt.
Upvotes: 2