Bug #47929 cmake generates a file every time cmake is called, causing a wait for re-link
Submitted: 9 Oct 2009 6:22 Modified: 23 Feb 2010 10:27
Reporter: jack andrews Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.0 OS:Microsoft Windows
Assigned to: jack andrews CPU Architecture:Any

[9 Oct 2009 6:22] jack andrews
Description:
this code in storage/ndb/src/CMakeLists.txt causes a re-link of everything dependent on ndbclient after running cmake.

FILE(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/dummy.cpp "")
ADD_LIBRARY(ndbclient STATIC dummy.cpp)

TARGET_LINK_LIBRARIES(ndbclient
                      ndbapi
                      ndbtransport
                      ndbtrace
                      ndbsignaldata
                      ndbmgmapi
                      ndbmgmsrv
                      ndblogger
                      ndbportlib
                      ndbgeneral)

How to repeat:
.

Suggested fix:
turn ndbclient into ${ndb_client_libs} and use that in place of ndbclient
[10 Oct 2009 0:17] Vladislav Vaintroub
The problem here is file(write)

if you generate the file with 

ADD_CUSTOM_COMMAND( 
    OUTPUT  dummy.c
    COMMAND ${CMAKE_COMMAND} ARGS -E touch dummy.c)

this rebuild/relink will not happen
[12 Oct 2009 3:56] jack andrews
> ADD_CUSTOM_COMMAND( 
>    OUTPUT  dummy.c
>    COMMAND ${CMAKE_COMMAND} ARGS -E touch dummy.c)

as i read it, this will touch dummy.c every run of cmake.
this leaves me in the same situation.

but i think for ndb, we will want to release the ndbclient
convenience library, so longer term, we need to fix this.
  http://www.cmake.org/pipermail/cmake/2009-January/026745.html
[16 Oct 2009 11:23] Magnus BlÄudd
Whey not do it like sql/CMakeLists.txt and only generate the file if it does not already exist.

IF (NOT EXISTS cmake_dummy.cc)
  FILE (WRITE cmake_dummy.cc "")
ENDIF (NOT EXISTS cmake_dummy.cc)
ADD_EXECUTABLE(mysqld cmake_dummy.cc)
[19 Oct 2009 0:42] jack andrews
actually, this doesn't even work in (ndb 5.1 version of) mysqld.
if you build the entire solution (F7), then hit F7 again, it will
re-link mysqld.

i know it doesn't make sense, but there you are.
[17 Feb 2010 4:24] jack andrews
the patch hides the dummy .c file creation by using wlad's macros

it has the added benefit of creating a usable ndbclient lib
which is necessary for users to write their own API clients

there is no more re-linking after a full build succeeds
[23 Feb 2010 10:27] Jon Stephens
Doesn't appear to have any immediate impact on users, so closing without further action.