As an extension to my previous question: Does the boost test framework provide an integrated mechanism to get the binary directory (the directory where the currently running test executable is placed) and/or the source directory (where the jam-file resides that defined the test)? Best Mike
On 28.09.18 13:31, Mike Dev via Boost wrote:
As an extension to my previous question: Does the boost test framework provide an integrated mechanism to get the binary directory (the directory where the currently running test executable is placed) and/or the source directory (where the jam-file resides that defined the test)?
Nope, but you can pass them on the command line. PR to boost.test welcome! R.
OK, what I got from the documentation is that I can do something like
notfile run_cmake_self_test : @echo ;
actions echo
{
mkdir __build__
cd __build__
cmake ..
cmake --build .
}
but
1) this will create __build__ in whatever directory b2 is called from and
require the test cmake file to be in the parent directory of the current
2) mkdir will fail if the directory already esists and the flags necessary
to circumvent that are different on powershell (--force) and bash (-p)
To fix 1) I'd need a way to get the current build directory (that is where
I want to create the __build__ directory) and the director of the current
jam file (which is where the CMakeLists.txt file resides).
That would result in something like this:
notfile run_cmake_self_test : @echo ;
actions echo
{
mkdir $(b2-build-dir)/__build__
cd $(b2-build-dir)/__build__
cmake $(b2-source-dir)
cmake --build .
}
For 2 it would be nice, if b2 had a platform agnostic way to create a directory
if it doesn't already exist so that I can just write
"
Hi Mike, first thing is that you got the wrong mailing list and the wrong [library] tag. This really is a Boost.Build question and belongs on its mailing list. So I crossposted your question there. And as this is not a Boost.Test question, [test] is also misleading. Beyond that, I can at least answer how to get the current Jamfile directory, see below. Am Mittwoch, 17. Oktober 2018, 12:34:42 CEST schrieb Mike Dev via Boost:
OK, what I got from the documentation is that I can do something like
notfile run_cmake_self_test : @echo ; actions echo { mkdir __build__ cd __build__ cmake .. cmake --build . }
but 1) this will create __build__ in whatever directory b2 is called from and require the test cmake file to be in the parent directory of the current 2) mkdir will fail if the directory already esists and the flags necessary to circumvent that are different on powershell (--force) and bash (-p)
To fix 1) I'd need a way to get the current build directory (that is where I want to create the __build__ directory) and the director of the current jam file (which is where the CMakeLists.txt file resides).
In the current Jamfile you can use path-constant CWD : . ; to store the current directory "." into a variable named CWD. Or whatever name you like.
That would result in something like this:
notfile run_cmake_self_test : @echo ; actions echo { mkdir $(b2-build-dir)/__build__ cd $(b2-build-dir)/__build__ cmake $(b2-source-dir) cmake --build . }
I see what you want.
For 2 it would be nice, if b2 had a platform agnostic way to create a directory if it doesn't already exist so that I can just write
"
" notfile run_cmake_self_test : @echo ; actions echo { cd $(b2-build-dir)/__build__ cmake $(b2-source-dir) cmake --build . }
Could someone tell me how to achieve those two goals?
I hope someone with more active b2 knowledge can. Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! * voice: ++49 4257 300 ! Fährstraße 1 * fax : ++49 4257 300 ! 31609 Balge/Sebbenhausen * jhunold@gmx.eu ! Germany
AMDG On 10/17/2018 04:34 AM, Mike Dev via Boost wrote:
OK, what I got from the documentation is that I can do something like
notfile run_cmake_self_test : @echo ; actions echo { mkdir __build__ cd __build__ cmake .. cmake --build . }
but 1) this will create __build__ in whatever directory b2 is called from and require the test cmake file to be in the parent directory of the current 2) mkdir will fail if the directory already esists and the flags necessary to circumvent that are different on powershell (--force) and bash (-p)
I would recommend using a make target (warning untested): make CMakeCache.txt : CMakeLists.txt : @echo ; always CMakeCache.txt ; actions echo { cmake -S "$(>:D)" -B $(<:D) cmake --build "$(<:D)" } Note 1: The directory will be created automatically. Note 2: Avoiding cd simplifies the path handling a lot. Note 3: This could probably be split into two separate actions. In Christ, Steven Watanabe
-----Original Message----- From: Boost
On Behalf Of Steven Watanabe via Boost Sent: Wednesday, October 17, 2018 7:19 PM I would recommend using a make target (warning untested):
make CMakeCache.txt : CMakeLists.txt : @echo ; always CMakeCache.txt ;
actions echo { cmake -S "$(>:D)" -B $(<:D) cmake --build "$(<:D)" }
Note 1: The directory will be created automatically. Note 2: Avoiding cd simplifies the path handling a lot. Note 3: This could probably be split into two separate actions.
Thanks you very much, that got me mostly there. In cmake versions older than 3.13 this apparently has to be actions echo { cmake -H"$(>:D)" -B$(<:D) cmake --build "$(<:D)" } (no space between B and the path and -H instead of -S). Now I only need a way to properly hook this up, so it gets only re-run, if one of the cmake files change. Best Mike
participants (4)
-
Jürgen Hunold
-
Mike Dev
-
Raffi Enficiaud
-
Steven Watanabe