CMake ctest helper
See original GitHub issueHi!
The awesome feature, cmake helper, made my life easier to write some receipts, but when I need write some test_package conanfile, I have:
cmake = None
def build(self):
self.cmake = CMake(self.settings)
self.cmake.configure(self, source_dir=self.conanfile_directory, build_dir="./")
self.cmake.build(self)
def test(self):
target_test = "RUN_TESTS" if self.settings.os == "Windows" else "test"
self.cmake.build(self, target=target_test)
I use CTest for my unit tests, so, I put enable_testing
and add_test
in my cmake file, but I need select the target word by platform. Maybe, would be a better approach if I have:
cmake = None
def build(self):
self.cmake = CMake(self.settings)
self.cmake.configure(self, source_dir=self.conanfile_directory, build_dir="./")
self.cmake.build(self)
def test(self):
self.cmake.test(self)
This helper will solve the target name by platform and call cmake.build.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
ctest(1) — CMake 3.25.1 Documentation
The ctest executable is the CMake test driver program. CMake-generated build trees created for projects that use the enable_testing() and add_test() commands ...
Read more >CTest - Cross Platform Make - CMake
The "ctest" executable is the CMake test driver program. CMake-generated build trees created for projects that use the ENABLE_TESTING and ADD_TEST commands have ......
Read more >Testing With CMake and CTest
CTest is an executable that comes with CMake; it handles running the tests for the project. While CTest works well with CMake, you...
Read more >add_test — CMake 3.25.1 Documentation
This creates a test mytest whose command runs a testDriver tool passing the configuration name and the full path to the executable file...
Read more >CTest — CMake 3.25.1 Documentation
Configure a project for testing with CTest/CDash. Include this module in the top CMakeLists.txt file of a project to enable testing with CTest...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Right, was merged in Conan 0.22.
Regards.
By default, CMake apply
test
for Linux, orRUN_TESTS
for Visual Studio, as target, whenenable_testing()
is present in CMakeFile.txt.Here is the explanation: Testing_With_CTest
However, anyone can create a custom target instead to run CTest:
And run:
In this case, the better choice is just use
cmake.build(self, target="run-all-tests")
.Great idea, I can implement this little point 😃