[CMake] Cmake make clean

Mike Commeau commeaum at se-core.net
Thu Mar 22 13:51:53 EST 2007


I'm having a problem with the "make clean". My intention was to add
"ADDITIONAL_MAKE_CLEAN_FILES" to remove files that were not being removed
during a make clean. I added the line in the cmake file. Ran cmake and then
ran a make in the "UUID" directory. After running the make, I wanted to test
to make sure the files would delete so I ran make clean in the "UUID"
directory

 

OUTPUT:

rm -f libuuid.la uuid.lo uuid_md5.lo uuid_sha1.lo uuid_prng.lo uuid_mac.lo
uuid_ui64.lo uuid_ui128.lo uuid_str.lo

rm -f libuuid++.la uuid++.lo uuid.lo uuid_md5.lo uuid_sha1.lo uuid_prng.lo
uuid_mac.lo uuid_ui64.lo uuid_ui128.lo uuid_str.lo

rm -f uuid uuid_cli.o

rm -f -r .libs >/dev/null 2>&1 || true

rm -f *.o *.lo

 

When I inspected the directories with the files I had specified to be
deleted in the CMakeList.txt file where still there, however if I did the
same make clean one directory above the make clean would delete the files
that I had specified. However, to get the make clean to work after the make
in the UUID I would have to goto the root and do a cmake. I would have to do
a cmake after a make to get the make clean to work and I would have to do a
cmake after doing a make clean to get the make to work.

 

My CMakeLists.txt file:

 

MAKE_DIRECTORY(${INTERFACE_DIR})

 

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/uuid++.hh

    ${INTERFACE_DIR} COPYONLY)

 

# Compile the Library

#

ADD_CUSTOM_COMMAND(

    OUTPUT ${UUID_CPP_LIB_DIR}/${UUID_CPP_LIB}

    COMMAND ${CMAKE_COMMAND}

    ARGS -E echo "*****Begin compile of UUID C++ *****"

    ARGS -E echo "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}"

    ARGS -E echo "DATA_SERVICES_CPlusPlus_LIB_DIR:
${DATA_SERVICES_CPlusPlus_LIB_DIR}"

    COMMAND . ${CMAKE_CURRENT_SOURCE_DIR}/configure

        --quiet

        --prefix=${DATA_SERVICES_CPlusPlus_LIB_DIR}

        --exec-prefix=${DATA_SERVICES_CPlusPlus_LIB_DIR}

        --srcdir=${CMAKE_CURRENT_SOURCE_DIR}

        --with-cxx

    COMMAND ${CMAKE_COMMAND}

    ARGS -E copy ${CMAKE_CURRENT_BINARY_DIR}/uuid.h
${CMAKE_CURRENT_SOURCE_DIR}

    COMMAND chmod a+rw ${CMAKE_CURRENT_SOURCE_DIR}/uuid.h

        COMMAND make

    COMMAND cp -a ${CMAKE_CURRENT_BINARY_DIR}/.libs/*.so*
${DATA_SERVICES_CPlusPlus_LIB_DIR}/

    COMMAND ${CMAKE_COMMAND}

    ARGS -E echo "*****End compile of UUID C++ *****"

    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

 

ADD_CUSTOM_TARGET(uuid_cpp ALL

    DEPENDS ${UUID_CPP_LIB_DIR}/${UUID_CPP_LIB})

 

 

SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES

"${UUID_CPP_LIB_DIR}/libuuid.so;${CMAKE_CURRENT_SOURCE_DIR}/uuid.h;${UUID_CP
P_LIB_DIR}/${UUID_CPP_LIB};${UUID_CPP_LIB_DIR}/libuuid.so.15;${UUID_CPP_LIB_
DIR}/libuuid++.so.15;${UUID_CPP_LIB_DIR}/libuuid.so.15.0.21;${UUID_CPP_LIB_D
IR}/libuuid++.so.15.0.21;${INTERFACE_DIR}/uuid++.hh")

 

I have tried another directory with complete success. I'm able to run make
clean and make with no needing to run cmake each time. Here is the
CMakeLists.txt file for the one that works.

 

# Compile the logger2 C++ version

SET(LOGGER2_CPP_SRCS

    event_appender.cpp

    extended_xml_layout.cpp

    logger_event.cpp

    logger_listener.cpp

    repository_file_appender.cpp

    repository_invoker.cpp

    secore_logger.cpp

    secore_logger_factory.cpp)

 

 

SET(LIBRARY_OUTPUT_PATH ${LOGGER2_CPlus_Plus_LIB_DIR})

INCLUDE_DIRECTORIES(

    ${LOG4CXX_INC_DIR}

    ${DATA_SERVICES_CPlusPlus_INC_DIR})

 

# Compile the Library

#

ADD_LIBRARY(${LOGGER2_CPlus_Plus_LIB} SHARED ${LOGGER2_CPP_SRCS})

 

# Helpful logging

ADD_CUSTOM_COMMAND(

        TARGET ${LOGGER2_CPlus_Plus_LIB}

        PRE_BUILD

        COMMAND ${CMAKE_COMMAND}

        ARGS -E echo "*****Begin compile of Logger2 C++ *****")

 

ADD_CUSTOM_COMMAND(

        TARGET ${LOGGER2_CPlus_Plus_LIB}

        POST_BUILD

        COMMAND ${CMAKE_COMMAND}

        ARGS -E echo "***** End compile of Logger2 C++ *****")

 

# Add a target to remove the library and the other generated files

ADD_CUSTOM_TARGET( allclean

    COMMAND ${CMAKE_COMMAND} -E remove
${LOGGER2_CPlus_Plus_LIB_DIR}/lib${LOGGER2_CPlus_Plus_LIB}.so)

 

SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
"${LOGGER2_CPlus_Plus_LIB_DIR}/lib${LOGGER2_CPlus_Plus_LIB}.so")

 

I tried to do this using 2.4.4 and 2.4.6 with the same result.

 

Build Manager - SE-Core

 <mailto:commeaum at se-core.net> commeaum at se-core.net

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070322/a04d3b7c/attachment.html


More information about the CMake mailing list