Bug #45843 cmake error if configuring an out of source build
Submitted: 30 Jun 2009 7:40 Modified: 16 Jul 2009 9:02
Reporter: Matthias Brantner Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:1.0.5 OS:MacOS
Assigned to: Ulf Wendel CPU Architecture:Any
Tags: cmake, Contribution, cpack

[30 Jun 2009 7:40] Matthias Brantner
Description:
CMake 2.6-patch 3 returns an error if configuring an out of source build. For instance, I got the following error:

CMake Error at /opt/local/share/cmake-2.6/Modules/CPack.cmake:686 (message):
  CPack license resource file:
  "C/Users/sausalito/mysql-connector-c++-1.0.5/OPYING" could not be found.
Call Stack (most recent call first):
  /opt/local/share/cmake-2.6/Modules/CPack.cmake:691 (cpack_check_file_exists)
  CMakeLists.txt:137 (INCLUDE)

CMake Error at /opt/local/share/cmake-2.6/Modules/CPack.cmake:686 (message):
  CPack readme resource file: "README" could not be found.
Call Stack (most recent call first):
  /opt/local/share/cmake-2.6/Modules/CPack.cmake:692 (cpack_check_file_exists)
  CMakeLists.txt:137 (INCLUDE)

How to repeat:
Create a build directory (e.g. build) within the source tree and configure it by executing 'cmake ..'

Suggested fix:
For configuring CPack, absolute paths should be used. Please find a suggested solution in the following patch for the top-level CMakeLists.txt file:

90,96c90,95
< 
< IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
<   SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
< ELSE(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
<   SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
< ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
< SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
---
> IF(EXISTS "COPYING")
>   SET(CPACK_RESOURCE_FILE_LICENSE "COPYING")
> ELSE(EXISTS "COPYING")
>   SET(CPACK_RESOURCE_FILE_LICENSE "LICENSE.mysql")
> ENDIF(EXISTS "COPYING")
> SET(CPACK_RESOURCE_FILE_README "README")
115c114
<   SET( LICENSE_FILENAME "${CPACK_RESOURCE_FILE_LICENSE}")")
---
> SET( LICENSE_FILENAME "${CPACK_RESOURCE_FILE_LICENSE}")")
118c117
< INSTALL(FILES ${CPACK_RESOURCE_FILE_README} ${CPACK_RESOURCE_FILE_LICENSE} "${CMAKE_SOURCE_DIR}/ANNOUNCEMENT" DESTINATION "." OPTIONAL)
---
> INSTALL(FILES "README" "COPYING" "LICENSE.mysql" "ANNOUNCEMENT" DESTINATION "." OPTIONAL)
[13 Jul 2009 16:27] Ulf Wendel
Interesting idea to run cmake not in the root directory.

Hmm, I see that CMakeLists.txt has been changed in the latest development version. However, I am about to revert the change and add ${CMAKE_SOURCE_DIR} again. Without ${CMAKE_SOURCE_DIR} it breaks the build with CMake 2.6.4 on Linux. ${CMAKE_SOURCE_DIR} holds the correct directory, regardless of my current working directory when calling cmake. 

Can you try the development tree on your system?

This looks suspicious:
"CMake Error at /opt/local/share/cmake-2.6/Modules/CPack.cmake:686 (message):
  CPack license resource file:
  "C/Users/sausalito/mysql-connector-c++-1.0.5/OPYING" could not be found."

Why does CPack complain about OPYING and not COPYING? Is that a cut&paste error in the message?

Thanks!
Ulf
[13 Jul 2009 16:30] Ulf Wendel
The code is at https://code.launchpad.net/~mysql/mysql-connector-cpp/trunk . To clone the code, run "bzr clone lp:~mysql/mysql-connector-cpp/trunk".
[14 Jul 2009 13:19] Matthias Brantner
I tried to compile the current trunk (revision 680) but I still get the following errors:

CMake Error at /opt/local/share/cmake-2.6/Modules/CPack.cmake:686 (message):
  CPack license resource file: "LICENSE.mysql" could not be found.
Call Stack (most recent call first):
  /opt/local/share/cmake-2.6/Modules/CPack.cmake:691 (cpack_check_file_exists)
  CMakeLists.txt:218 (INCLUDE)

CMake Error at /opt/local/share/cmake-2.6/Modules/CPack.cmake:686 (message):
  CPack readme resource file: "README" could not be found.
Call Stack (most recent call first):
  /opt/local/share/cmake-2.6/Modules/CPack.cmake:692 (cpack_check_file_exists)
  CMakeLists.txt:218 (INCLUDE)

I think that the variables CPACK_RESOURCE_FILE_LICENSE and CPACK_RESOURCE_FILE_README need to contain the full path to the source directory. That is, with the variable CMAKE_SOURCE_DIR prepended.
[14 Jul 2009 14:24] Ulf Wendel
Thanks for the feedback! I agree, we should use ${CMAKE_SOURCE_DIR}. What puzzled me is that the suggested patch looked like ${CMAKE_SOURCE_DIR} should be removed... 

Anyway, I should soon have time to fix it. I'll let you know when it is fixed.

Ulf
[14 Jul 2009 14:45] Ulf Wendel
I've pushed a change. Works for me now. 

nixnutz@ulflinux:~/src/connector-cpp-bzr> cd trunk/
nixnutz@ulflinux:~/src/connector-cpp-bzr/trunk> cmake .
-- ICU::CONFIG: /usr/bin/icu-config
[...]
-- Build files have been written to: /home/nixnutz/src/connector-cpp-bzr/trunk
[16 Jul 2009 9:02] Ulf Wendel
Fix should make it into in 1.0.6 (scheduled for September 2009).