[CMake] CMake 2.5.20070522: Possible BUG using INSTALL (+ GLOB) for ADD_CUSTOM_TARGET/ADD_CUSTOM_COMMAND

Guilherme Balena Versiani guibv at comunip.com.br
Tue May 29 13:50:17 EDT 2007


Hello all,

I have OpenSSL bundled with my software distribution, and I need to 
compile it during the build process. I am using CMake 2.5.20070522 (CVS 
version from date 05-22-2007). Then I have the following in my 
'CMakeLists.txt':

  ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Makefile
    COMMAND chmod 0755 config
    COMMAND ./config shared
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  )

  ADD_CUSTOM_COMMAND(
    OUTPUT ${LIBRARY_OUTPUT_PATH}/libcrypto.so
           ${LIBRARY_OUTPUT_PATH}/libssl.so
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Makefile
    COMMAND make build_libs
    COMMAND cp -dp libssl.so* libcrypto.so* ${LIBRARY_OUTPUT_PATH}
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  )

  ADD_CUSTOM_TARGET(openssl ALL
    DEPENDS ${LIBRARY_OUTPUT_PATH}/libcrypto.so
            ${LIBRARY_OUTPUT_PATH}/libssl.so
  )

  FILE(GLOB _libs "${LIBRARY_OUTPUT_PATH}/libcrypto.so*" 
"${LIBRARY_OUTPUT_PATH}/libssl.so*")
  INSTALL(FILES ${_libs} DESTINATION lib)

The build process includes CPack to create a package at the end:

  $ mkdir bundle-build
  $ cmake ../bundle # 'out-of-source' build
  $ make
  $ make package

After this process, I get no libssl.so nor libcrypto.so within the 
generated package. So, I tried 'make install', and yet no 
libssl.so/libcrypto.so appeared in the installation.

Trying to inspect what was wrong, I simply reissued the 'cmake' command, 
and this time all worked fine. So, the overall build process seems like:

  $ mkdir bundle-build
  $ cmake ../bundle
  $ make
  $ cmake . # (!) I need to reissue cmake here
  $ make package

Is that behavior a BUG, or is it an expected one?

Regards,

Guilherme Balena Versiani.


More information about the CMake mailing list