Bug #47929 cmake generates a file every time cmake is called, causing a wait for re-link
Submitted: 9 Oct 8:22
Reporter: jack andrews
Status: In progress
Category:Server: Cluster Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.0 OS:Microsoft Windows
Assigned to: jack andrews Target Version:
Triage: Triaged: D4 (Minor) / R6 (Needs Assessment) / E6 (Needs Assessment)

[9 Oct 8: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 2: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 5: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 13:23] Magnus Blaudd
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 2: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.