[cmake][array][vs] Trying develop and test a single library
Hi, I'm learning about the boostorg/cmake infrastructure offered by Peter. I picked Boost.Array as a library with simple build setup. I replaced the existing (hand-rolled?) CMakeLists.txt files with the generated ones: b2 tools\boostdep\build dist\bin\boostdep.exe --cmake array Then, learning form boostorg/cmake itself how to use it https://github.com/boostorg/cmake/blob/develop/.travis.yml#L228 cd BOOST_ROOT mkdir __build__ && cd __build__ cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=array .. cmake --build . ctest --output-on-failure -R boost_array Visual Studio solution is nicely generated, all expected .vcxproj files too, but, AFAICT, neither the last two commands nor these do anything: cmake --build . --config Release cmake --build . --config Debug I loaded the Boost.sln in VS 2019 and Build > Build Solution worked. I also noticed this 'unusual' project-as-target called check. I'm back in the CLI mode and run: cmake --build . --target check this time all the tests build and run. Interestingly, if I feed the ctest with the build configuration, then it also builds the tests, and runs them too, of course: ctest --output-on-failure -R boost_array -C Release ctest --output-on-failure -R boost_array -C Debug Is this `cmake --build .` doing nothing specific Boost.CMake? Is that `check` target supposed to be used explicitly? Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
Gesendet: Freitag, 27. März 2020 um 22:52 Uhr Von: "Mateusz Loskot via Boost"
Hi,
I'm learning about the boostorg/cmake infrastructure offered by Peter.
I picked Boost.Array as a library with simple build setup. I replaced the existing (hand-rolled?) CMakeLists.txt files with the generated ones:
b2 tools\boostdep\build dist\bin\boostdep.exe --cmake array
Then, learning form boostorg/cmake itself how to use it https://github.com/boostorg/cmake/blob/develop/.travis.yml#L228
cd BOOST_ROOT mkdir __build__ && cd __build__ cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=array .. cmake --build . ctest --output-on-failure -R boost_array
Visual Studio solution is nicely generated, all expected .vcxproj files too, but, AFAICT, neither the last two commands nor these do anything:
cmake --build . --config Release cmake --build . --config Debug
BoostArray is a header only library. What is that command supposed to build?
On Fri, 27 Mar 2020 at 23:24, Mike via Boost
Gesendet: Freitag, 27. März 2020 um 22:52 Uhr Von: "Mateusz Loskot via Boost"
Hi,
I'm learning about the boostorg/cmake infrastructure offered by Peter.
I picked Boost.Array as a library with simple build setup. I replaced the existing (hand-rolled?) CMakeLists.txt files with the generated ones:
b2 tools\boostdep\build dist\bin\boostdep.exe --cmake array
Then, learning form boostorg/cmake itself how to use it https://github.com/boostorg/cmake/blob/develop/.travis.yml#L228
cd BOOST_ROOT mkdir __build__ && cd __build__ cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=array .. cmake --build . ctest --output-on-failure -R boost_array
Visual Studio solution is nicely generated, all expected .vcxproj files too, but, AFAICT, neither the last two commands nor these do anything:
cmake --build . --config Release cmake --build . --config Debug
BoostArray is a header only library.
I'm aware
What is that command supposed to build?
Build all targets, in this particular case, the tests. Well, I see that I have not mentioned everything. The generated array/CMakeLists.txt includes this if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") add_subdirectory(test) endif() and I added array/test/CMakeLists.txt based on https://github.com/boostorg/assert/blob/develop/test/CMakeLists.txt which seems Boost.CMake common if not canonical. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
Mateusz Loskot wrote:
What is that command supposed to build?
Build all targets, in this particular case, the tests.
If you use BoostTest for the tests, `cmake --build .` doesn't build them. They are built by `ctest`. (This is necessary in order to support compile and link tests, but is used for run tests as well, so that you get a test failure when a test fails to compile, instead of a build failure.)
On Fri, 27 Mar 2020 at 23:47, Peter Dimov via Boost
Mateusz Loskot wrote:
What is that command supposed to build?
Build all targets, in this particular case, the tests.
If you use BoostTest for the tests, `cmake --build .` doesn't build them. They are built by `ctest`. (This is necessary in order to support compile and link tests, but is used for run tests as well, so that you get a test failure when a test fails to compile, instead of a build failure.)
It makes sense, thanks! Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
cd BOOST_ROOT mkdir __build__ && cd __build__ cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=array .. cmake --build . ctest --output-on-failure -R boost_array
Visual Studio solution is nicely generated, all expected .vcxproj files too, but, AFAICT, neither the last two commands nor these do anything:
cmake --build . --config Release cmake --build . --config Debug
FWIW: These commands are incomplete. The correct CMake template workflow is: mkdir __build__ && cd __build__ cmake -DCMAKE_BUILD_TYPE=Debug .. cmake --build . --config Debug ctest --output-on-failure -C Debug This is to support both Make/Ninja and Visual Studio as the "generator" (="build system"). Of course other defines (`-DFOO=bar`) can be passed to the first cmake command and "Debug" can be replaced by e.g. Release (in all 3 commands!)
On Mon, 30 Mar 2020 at 10:24, Alexander Grund via Boost
cd BOOST_ROOT mkdir __build__ && cd __build__ cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=ON -DBOOST_INCLUDE_LIBRARIES=array .. cmake --build . ctest --output-on-failure -R boost_array
Visual Studio solution is nicely generated, all expected .vcxproj files too, but, AFAICT, neither the last two commands nor these do anything:
cmake --build . --config Release cmake --build . --config Debug
FWIW: These commands are incomplete. The correct CMake template workflow is:
mkdir __build__ && cd __build__ cmake -DCMAKE_BUILD_TYPE=Debug ..
AFAIK, this is not necessary for multi-configuration generators. Here I used VS.
cmake --build . --config Debug ctest --output-on-failure -C Debug
Yes, I did present those, in the second part of my post https://lists.boost.org/Archives/boost/2020/03/248533.php Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
AFAIK, this is not necessary for multi-configuration generators. Here I used VS.
cmake --build . --config Debug ctest --output-on-failure -C Debug Yes, I did present those, in the second part of my post https://lists.boost.org/Archives/boost/2020/03/248533.php
You wrote "Interestingly, if I feed the ctest with the build configuration, [...]" Hence my answer for a "CMake template workflow", aka a workflow that works everywhere independent of the generator. So no surprises and you did seem surprised. The initially showed commands to not set the build type at all, which is usually wrong. That is another issue is solved by following this "template workflow". I'm not even sure what `cmake --build .` is supposed to do for multi-config generators. I'd expect it to error out. Hope that helps, Alex
On Mon, 30 Mar 2020 at 11:15, Alexander Grund via Boost
AFAIK, this is not necessary for multi-configuration generators. Here I used VS.
cmake --build . --config Debug ctest --output-on-failure -C Debug Yes, I did present those, in the second part of my post https://lists.boost.org/Archives/boost/2020/03/248533.php
You wrote "Interestingly, if I feed the ctest with the build configuration, [...]"
Hence my answer for a "CMake template workflow", aka a workflow that works everywhere independent of the generator. So no surprises and you did seem surprised.
Correct, as I did expect `cmake --build .` to build all tests for the Debug configuration, which is the VS default.
I'm not even sure what `cmake --build .` is supposed to do for multi-config generators. I'd expect it to error out.
or that, yes. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net
participants (4)
-
Alexander Grund
-
Mateusz Loskot
-
Mike
-
Peter Dimov