View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008778CMakeCMakepublic2009-03-22 18:532016-06-10 14:30
Reportertron_thomas 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0008778: Clean does not remove out of source generated files
DescriptionI am using cxxtest for unit testing in a project that is configured with CMake. The configuration contains the following macro for generating the unit test target:

# Defines a macro that creates a cxxtest unit test application
# Name - the base name of the unit test
macro(AddCxxTest Name)
    # Specify the directory to place the generated, out of source cxxtest
    # runner file
    set(TestRunnerDirectory ${BuildPath}/${Name}Source)

    # Specify the fully qualified path the source code file for the cxxtest
    # runner
    set(TestRunner ${TestRunnerDirectory}/${Name}.cpp)
    
    # Add the command target that will generate the test runner source file
    add_custom_command(OUTPUT ${TestRunner}
        COMMAND ${CMAKE_COMMAND} -E make_directory ${TestRunnerDirectory}
        COMMAND ${PERL_EXECUTABLE} ${CxxTestGen} ${CxxTestGenFlags}
            -o ${TestRunner} ${ARGN}
        DEPENDS ${ARGN}
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

    # Create the unit test application target
    add_executable(${Name} ${TestRunner} ${ARGN})

    set(CompileFlags "-I${CxxTestDirectory}")
    
    # Configure the test target to successfully find cxxtest header files
    set_target_properties(${Name} PROPERTIES COMPILE_FLAGS ${CompileFlags})

    # Make sure the unit test is built before all the tests are run
    add_dependencies(TestAll ${Name})
endmacro(AddCxxTest)

This macro creates the C++ file generated by the cxxtest test harness as an out of source file. When a new test is added, this file needs to be regenerated to pick up the test. When I attempt to clean the unit test target in Xcode on Mac OS X, the generated unit test C++ file does not get deleted. This is in conflict with what is stated in the CMake FAQ which states:

  Running "make clean" does not remove custom command outputs. Why?

In CMake 2.2 and higher custom command outputs should be removed by make clean. Make sure you are using at least this version. Prior to CMake 2.2 custom command outputs were not automatically added to the list of files to clean. In CMake 2.0 the developer can specify a list of files to be deleted. This can be done using SET_DIRECTORY_PROPERTIES setting property ADDITIONAL_MAKE_CLEAN_FILES to the list of files.

We however strongly recommend using an "out-of-source" build which never writes any files to the source tree. Using a separate source and build tree greatly reduces the need for "make clean" and "make distclean" targets to clean away files that differ between builds.


According to the FAQ, since the file was created with a custom command as an out of source file, the generated file should be deleted during a clean, yet the file doesn't get deleted.

TagsNo tags attached.
Attached Fileszip file icon TestRunner.zip [^] (72,459 bytes) 2009-03-23 23:39

 Relationships

  Notes
(0015749)
Bill Hoffman (manager)
2009-03-22 21:50

Should work, can you create a simple example that shows the problem.
(0015780)
tron_thomas (reporter)
2009-03-23 23:40

I have attached a ZIP file to provide as simple of an example as I could make.

Use CMake to configure the project for Xcode
Build the project in Xcode
Clean the project in Xcode.

The out of source TestRunner.cpp generate by the cxxtest test harness will still exits after the clean operation.
(0041525)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2009-03-22 18:53 tron_thomas New Issue
2009-03-22 21:50 Bill Hoffman Note Added: 0015749
2009-03-22 21:51 Bill Hoffman Status new => assigned
2009-03-22 21:51 Bill Hoffman Assigned To => Bill Hoffman
2009-03-23 23:39 tron_thomas File Added: TestRunner.zip
2009-03-23 23:40 tron_thomas Note Added: 0015780
2010-08-29 01:35 Kovarththanan Rajaratnam Category CCMake => CMake
2016-06-10 14:27 Kitware Robot Note Added: 0041525
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team