← Back to team overview

maria-developers team mailing list archive

Separate builddir from src dir with cmake

 

Hi people,

Our cmake scripts weren't able to build outside the source dir. This is bad for 3 reasons:

- it's supposed to work
- cmake recommends building outside the src dir
- on Windows, cmake can't build 32 and 64 bit in the same solution, so patches has to be manually copied to test compilation on the other

The attached patch fixes all the issues. I ran a find on the source dir before and after the the build, and they were identical. I didn't actually check that no existing files we're modified, but bzr di claim this isn't the case.

I didn't port the zip creation script, but that shouldn't be a problem. src != blddir is more a development thing, and the buildbot slave producing the zip file will just continue to build in the same dir. The cpack installer builds just fine.

OK to push to 5.1?

Should I send this patch to the Oracle as well to minimize the drift between the cmake files?

Bo Thorsen.
Monty Program AB.

--

MariaDB: MySQL replacement
Community developed. Feature enhanced. Backward compatible.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2010-07-01 13:50:54 +0000
+++ CMakeLists.txt	2010-07-12 11:03:38 +0000
@@ -27,7 +27,7 @@
 SET(WITH_CSV_STORAGE_ENGINE TRUE)
 
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
-               ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY)
+               ${CMAKE_BINARY_DIR}/include/mysql_version.h @ONLY)
 
 # Set standard options
 ADD_DEFINITIONS(-DHAVE_YASSL)
@@ -45,15 +45,15 @@
 
 SET(localstatedir "C:\\mysql\\data")
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh
-               ${CMAKE_SOURCE_DIR}/support-files/my-huge.ini @ONLY)
+               ${CMAKE_BINARY_DIR}/support-files/my-huge.ini @ONLY)
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.cnf.sh
-               ${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.ini @ONLY)
+               ${CMAKE_BINARY_DIR}/support-files/my-innodb-heavy-4G.ini @ONLY)
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-large.cnf.sh
-               ${CMAKE_SOURCE_DIR}/support-files/my-large.ini @ONLY)
+               ${CMAKE_BINARY_DIR}/support-files/my-large.ini @ONLY)
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-medium.cnf.sh
-               ${CMAKE_SOURCE_DIR}/support-files/my-medium.ini @ONLY)
+               ${CMAKE_BINARY_DIR}/support-files/my-medium.ini @ONLY)
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh
-               ${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY)
+               ${CMAKE_BINARY_DIR}/support-files/my-small.ini @ONLY)
 
 
 ADD_DEFINITIONS(-D__NT__)
@@ -294,7 +294,7 @@
 
 # Now write out our mysql_plugin_defs struct
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in 
-               ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc @ONLY)
+               ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc @ONLY)
 
 # Add subdirectories for storage engines
 SET (ENGINE_BUILD_TYPE "STATIC")
@@ -381,12 +381,14 @@
 
 # Add files to the installer
 INSTALL(FILES COPYING EXCEPTIONS-CLIENT DESTINATION .)
-INSTALL(FILES support-files/my-huge.ini support-files/my-innodb-heavy-4G.ini DESTINATION .)
-INSTALL(FILES support-files/my-large.ini support-files/my-medium.ini DESTINATION .)
-INSTALL(FILES support-files/my-small.ini DESTINATION .)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/support-files/my-huge.ini support-files/my-innodb-heavy-4G.ini DESTINATION .)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/support-files/my-large.ini support-files/my-medium.ini DESTINATION .)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/support-files/my-small.ini DESTINATION .)
 INSTALL(FILES Docs/INSTALL-BINARY DESTINATION Docs)
 INSTALL(FILES COPYING DESTINATION Docs)
-FILE(GLOB headerfiles "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
+FILE(GLOB headerfiles "${CMAKE_SOURCE_DIR}/include/*.h")
+INSTALL(FILES ${headerfiles} DESTINATION include COMPONENT headers)
+FILE(GLOB headerfiles "${CMAKE_BINARY_DIR}/include/*.h")
 INSTALL(FILES ${headerfiles} DESTINATION include COMPONENT headers)
 INSTALL(FILES include/mysql/plugin.h DESTINATION include/mysql COMPONENT headers)
 INSTALL(FILES libmysql/libmysql.def DESTINATION include COMPONENT headers)

=== modified file 'client/CMakeLists.txt'
--- client/CMakeLists.txt	2010-06-25 13:09:45 +0000
+++ client/CMakeLists.txt	2010-07-09 13:23:11 +0000
@@ -27,7 +27,8 @@
                     ${CMAKE_SOURCE_DIR}/libmysql
                     ${CMAKE_SOURCE_DIR}/regex
                     ${CMAKE_SOURCE_DIR}/sql
-                    ${CMAKE_SOURCE_DIR}/strings)
+                    ${CMAKE_SOURCE_DIR}/strings
+                    ${CMAKE_BINARY_DIR}/include)
 
 ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c)
 TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32)

=== modified file 'extra/CMakeLists.txt'
--- extra/CMakeLists.txt	2010-06-25 13:09:45 +0000
+++ extra/CMakeLists.txt	2010-07-12 09:21:11 +0000
@@ -24,19 +24,20 @@
 
 GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION)
 
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
+FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/sql/share)
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h
                    COMMAND ${COMP_ERR_EXE}
-                    --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets 
-                    --out-dir=${PROJECT_SOURCE_DIR}/sql/share/
-                    --header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h 
-                    --name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
-                    --state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h
+                    --charset=${CMAKE_BINARY_DIR}/sql/share/charsets 
+                    --out-dir=${CMAKE_BINARY_DIR}/sql/share/
+                    --header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h 
+                    --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h
+                    --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h
                     --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt
                    DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt)
 
 ADD_CUSTOM_TARGET(GenError
                   ALL
-                  DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h)
+                  DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h)
 
 ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
 TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32)

=== modified file 'extra/libevent/CMakeLists.txt'
--- extra/libevent/CMakeLists.txt	2009-03-12 22:27:35 +0000
+++ extra/libevent/CMakeLists.txt	2010-07-09 12:23:32 +0000
@@ -1,7 +1,8 @@
 INCLUDE_DIRECTORIES(
 	${CMAKE_SOURCE_DIR}/extra/libevent
 	${CMAKE_SOURCE_DIR}/extra/libevent/compat
-	${CMAKE_SOURCE_DIR}/extra/libevent/WIN32-Code)
+	${CMAKE_SOURCE_DIR}/extra/libevent/WIN32-Code
+	${CMAKE_CURRENT_BINARY_DIR})
 	
 IF(MSVC)
 	ADD_DEFINITIONS("-DWIN32 -DHAVE_CONFIG_H")
@@ -28,7 +29,7 @@
 	strlcpy-internal.h
 	)
 
-CONFIGURE_FILE(WIN32-Code/config.h ${CMAKE_SOURCE_DIR}/extra/libevent/event-config.h COPYONLY)
+CONFIGURE_FILE(WIN32-Code/config.h ${CMAKE_CURRENT_BINARY_DIR}/event-config.h COPYONLY)
 IF(NOT SOURCE_SUBLIBS)
 	ADD_LIBRARY(libevent ${LIBEVENT_SOURCES})
 ENDIF(NOT SOURCE_SUBLIBS)

=== modified file 'libmysql/CMakeLists.txt'
--- libmysql/CMakeLists.txt	2010-06-25 13:09:45 +0000
+++ libmysql/CMakeLists.txt	2010-07-09 13:13:25 +0000
@@ -27,7 +27,8 @@
                     ${CMAKE_SOURCE_DIR}/libmysql
                     ${CMAKE_SOURCE_DIR}/regex
                     ${CMAKE_SOURCE_DIR}/sql
-                    ${CMAKE_SOURCE_DIR}/strings)
+                    ${CMAKE_SOURCE_DIR}/strings
+                    ${CMAKE_BINARY_DIR}/include)
 
 # We include the source file listing instead of referencing the
 # libraries. At least with CMake 2.4 and Visual Studio 2005 a static

=== modified file 'libmysqld/CMakeLists.txt'
--- libmysqld/CMakeLists.txt	2010-07-01 14:35:50 +0000
+++ libmysqld/CMakeLists.txt	2010-07-12 10:01:51 +0000
@@ -30,14 +30,15 @@
                     ${CMAKE_SOURCE_DIR}/sql
                     ${CMAKE_SOURCE_DIR}/regex
                     ${CMAKE_SOURCE_DIR}/extra/yassl/include 
-                    ${CMAKE_SOURCE_DIR}/zlib)
+                    ${CMAKE_SOURCE_DIR}/zlib
+                    ${CMAKE_BINARY_DIR}/sql)
 
-SET(GEN_SOURCES     ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
-                    ${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
+SET(GEN_SOURCES     ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+                    ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
                     ${CMAKE_SOURCE_DIR}/sql/message.h
                     ${CMAKE_SOURCE_DIR}/sql/message.rc
-                    ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc
-                    ${CMAKE_SOURCE_DIR}/sql/lex_hash.h)
+                    ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
+                    ${CMAKE_BINARY_DIR}/sql/lex_hash.h)
 
 SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
 
@@ -145,7 +146,9 @@
 
 # Seems we cannot make a library without at least one source file. So use a
 # dummy empty file
-FILE(WRITE cmake_dummy.c " ")
+IF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.c)
+  FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.c " ")
+ENDIF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.c)
 
 # Tried use the correct ${GEN_SOURCES} as dependency, worked on Unix
 # but not on Windows and Visual Studio generators. Likely because they
@@ -163,7 +166,7 @@
   ENDIF(${ENGINE_LIB_UPPER}_LIBS)
 ENDFOREACH(ENGINE_LIB)
 
-ADD_LIBRARY(libmysqld SHARED cmake_dummy.c libmysqld.def)
+ADD_LIBRARY(libmysqld SHARED ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.c libmysqld.def)
 ADD_DEPENDENCIES(libmysqld mysqlserver)
 TARGET_LINK_LIBRARIES(libmysqld mysqlserver wsock32)
 

=== modified file 'libmysqld/examples/CMakeLists.txt'
--- libmysqld/examples/CMakeLists.txt	2009-03-17 22:28:24 +0000
+++ libmysqld/examples/CMakeLists.txt	2010-07-09 13:26:41 +0000
@@ -17,7 +17,8 @@
                     ${CMAKE_SOURCE_DIR}/libmysqld/include
                     ${CMAKE_SOURCE_DIR}/regex
                     ${CMAKE_SOURCE_DIR}/zlib                   
-                    ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+                    ${CMAKE_SOURCE_DIR}/extra/yassl/include
+                    ${CMAKE_BINARY_DIR}/include)
 
 # Currently does not work with DBUG, there are missing symbols reported.
 IF(WIN32)

=== modified file 'scripts/CMakeLists.txt'
--- scripts/CMakeLists.txt	2010-06-28 13:31:47 +0000
+++ scripts/CMakeLists.txt	2010-07-12 11:46:17 +0000
@@ -14,13 +14,15 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 # Build mysql_fix_privilege_tables.sql
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql
-                   COMMAND copy /b
-                   mysql_system_tables.sql + mysql_system_tables_fix.sql
-                   mysql_fix_privilege_tables.sql
+SET(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+
+FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql" FIX_FILE1)
+FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_fix.sql" FIX_FILE2)
+ADD_CUSTOM_COMMAND(OUTPUT mysql_fix_privilege_tables.sql
+                   COMMAND copy /b \"${FIX_FILE1}\" + \"${FIX_FILE2}\" mysql_fix_privilege_tables.sql
                    DEPENDS
-                   ${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables.sql
-                   ${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables_fix.sql)
+                   ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
+                   ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_fix.sql)
 
 # Build comp_sql - used for embedding SQL in C or C++ programs
 ADD_EXECUTABLE(comp_sql comp_sql.c)
@@ -29,17 +31,17 @@
 # Use comp_sql to build mysql_fix_privilege_tables_sql.c
 GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
 
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c
+ADD_CUSTOM_COMMAND(OUTPUT mysql_fix_privilege_tables_sql.c
                    COMMAND ${COMP_SQL_EXE}
                    mysql_fix_privilege_tables
                    mysql_fix_privilege_tables.sql
                    mysql_fix_privilege_tables_sql.c
-                   DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql)
+                   DEPENDS comp_sql mysql_fix_privilege_tables.sql)
 
 # Add dummy target for the above to be built
 ADD_CUSTOM_TARGET(GenFixPrivs
                   ALL
-                  DEPENDS ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c)
+                  DEPENDS mysql_fix_privilege_tables_sql.c)
 
 # ----------------------------------------------------------------------
 # Replace some variables @foo@ in the .in/.sh file, and write the new script
@@ -81,6 +83,6 @@
 	mysql_secure_installation.pl mysqld_multi.pl
 	DESTINATION scripts COMPONENT scripts)
 
-INSTALL(FILES fill_help_tables.sql mysql_fix_privilege_tables.sql mysql_system_tables.sql
-	mysql_system_tables_data.sql mysql_system_tables_fix.sql mysql_test_data_timezone.sql
-	DESTINATION share COMPONENT scripts)
+INSTALL(FILES fill_help_tables.sql ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql mysql_system_tables.sql
+	mysql_system_tables_data.sql mysql_system_tables_fix.sql mysql_test_data_timezone.sql
+	DESTINATION share COMPONENT scripts)

=== modified file 'server-tools/instance-manager/CMakeLists.txt'
--- server-tools/instance-manager/CMakeLists.txt	2010-06-25 13:09:45 +0000
+++ server-tools/instance-manager/CMakeLists.txt	2010-07-09 13:13:59 +0000
@@ -19,7 +19,8 @@
 
 ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER)
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql
-                    ${PROJECT_SOURCE_DIR}/extra/yassl/include)
+                    ${PROJECT_SOURCE_DIR}/extra/yassl/include
+                    ${CMAKE_BINARY_DIR}/include)
  
 ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc
                             instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc

=== modified file 'sql/CMakeLists.txt'
--- sql/CMakeLists.txt	2010-06-25 13:09:45 +0000
+++ sql/CMakeLists.txt	2010-07-12 11:09:05 +0000
@@ -26,16 +26,16 @@
                     ${CMAKE_SOURCE_DIR}/regex 
                     ${CMAKE_SOURCE_DIR}/zlib
                     ${CMAKE_SOURCE_DIR}/extra/libevent 
+                    ${CMAKE_BINARY_DIR}/include
+                    ${CMAKE_BINARY_DIR}/extra/libevent 
+                    ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/sql_yacc.h 
-                            ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
-                            ${CMAKE_SOURCE_DIR}/include/mysql_version.h
-                            ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc
-                            ${CMAKE_SOURCE_DIR}/sql/lex_hash.h 
-                            ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
-                            ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
-                            ${PROJECT_SOURCE_DIR}/include/sql_state.h 
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/include/mysql_version.h 
+                            ${CMAKE_CURRENT_BINARY_DIR}/sql_builtin.cc
+                            ${CMAKE_BINARY_DIR}/include/mysqld_error.h
+                            ${CMAKE_BINARY_DIR}/include/mysqld_ername.h
+                            ${CMAKE_BINARY_DIR}/include/sql_state.h
                               PROPERTIES GENERATED 1)
 
 ADD_DEFINITIONS(-DMYSQL_SERVER -D_CONSOLE -DHAVE_DLOPEN -DHAVE_EVENT_SCHEDULER)
@@ -77,20 +77,18 @@
                rpl_rli.cc rpl_mi.cc sql_servers.cc
                sql_connect.cc scheduler.cc 
                sql_profile.cc event_parse_data.cc opt_table_elimination.cc
-               ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
-               ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
-               ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
-               ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h 
-               ${PROJECT_SOURCE_DIR}/include/sql_state.h
-               ${PROJECT_SOURCE_DIR}/include/mysql_version.h 
-               ${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc
-               ${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
+               sql_yacc.cc sql_yacc.h 
+               ${CMAKE_BINARY_DIR}/include/mysqld_error.h
+               ${CMAKE_BINARY_DIR}/include/mysqld_ername.h 
+               ${CMAKE_BINARY_DIR}/include/sql_state.h
+               ${CMAKE_BINARY_DIR}/include/mysql_version.h 
+               sql_builtin.cc lex_hash.h)
 ADD_LIBRARY(sql ${SQL_SOURCE})
 
-IF (NOT EXISTS cmake_dummy.cc)
-  FILE (WRITE cmake_dummy.cc "")
-ENDIF (NOT EXISTS cmake_dummy.cc)
-ADD_EXECUTABLE(mysqld cmake_dummy.cc message.rc)
+IF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.cc)
+  FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.cc "")
+ENDIF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.cc)
+ADD_EXECUTABLE(mysqld ${CMAKE_CURRENT_BINARY_DIR}/cmake_dummy.cc message.rc)
 
 SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX})
 SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
@@ -113,18 +111,17 @@
  
   ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK
     COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
-                  ${PLATFORM}  ${LIB_LOCATIONS} > mysqld.def 
-    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/sql)
+                  ${PLATFORM}  ${LIB_LOCATIONS} > mysqld.def)
 ENDIF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
 
 ADD_DEPENDENCIES(sql GenError)
 
 # Sql Parser custom command
+FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy" BISON_SRC)
 ADD_CUSTOM_COMMAND(
-        OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
-               ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
+        OUTPUT sql_yacc.h sql_yacc.cc
         COMMAND bison ARGS -y -p MYSQL --defines=sql_yacc.h
-                               --output=sql_yacc.cc sql_yacc.yy
+                               --output=sql_yacc.cc \"${BISON_SRC}\"
         DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy)
 
 
@@ -133,23 +130,21 @@
 TARGET_LINK_LIBRARIES(gen_lex_hash debug dbug mysqlclient strings wsock32)
 GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION)
 ADD_CUSTOM_COMMAND(
-        OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h
+        OUTPUT lex_hash.h
         COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h
         DEPENDS ${GEN_LEX_HASH_EXE})
 
 ADD_CUSTOM_TARGET(
         GenServerSource ALL
-        DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
-                ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
+        DEPENDS sql_yacc.h sql_yacc.cc
                 ${PROJECT_SOURCE_DIR}/sql/message.h
                 ${PROJECT_SOURCE_DIR}/sql/message.rc
-                ${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
+                lex_hash.h)
 
 ADD_DEPENDENCIES(mysqld GenServerSource)
 
 # Remove the auto-generated files as part of 'Clean Solution'
-SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES 
-  "lex_hash.h;sql_yacc.h;sql_yacc.cc;mysqld.def")
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "mysqld.def")
 
 ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def)
 ADD_DEPENDENCIES(udf_example strings GenError)

=== modified file 'storage/mysql_storage_engine.cmake'
--- storage/mysql_storage_engine.cmake	2010-06-28 14:05:34 +0000
+++ storage/mysql_storage_engine.cmake	2010-07-09 13:08:37 +0000
@@ -9,6 +9,7 @@
 # calling this macro
 # ${engine}_LIBS variable containing extra libraries to link with may be set
 
+INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
 
 MACRO(MYSQL_STORAGE_ENGINE engine)
 IF(NOT SOURCE_SUBLIBS)

=== modified file 'storage/pbxt/CMakeLists.txt'
--- storage/pbxt/CMakeLists.txt	2009-10-06 18:26:11 +0000
+++ storage/pbxt/CMakeLists.txt	2010-07-09 13:11:59 +0000
@@ -30,7 +30,8 @@
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql
                     ${CMAKE_SOURCE_DIR}/regex
-                    ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+                    ${CMAKE_SOURCE_DIR}/extra/yassl/include
+                    ${CMAKE_BINARY_DIR}/include)
 
 SET(PBXT_SOURCES
 src/bsearch_xt.cc

=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt	2010-06-25 13:09:45 +0000
+++ tests/CMakeLists.txt	2010-07-09 13:25:08 +0000
@@ -18,7 +18,7 @@
 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
 ADD_DEFINITIONS("-DMYSQL_CLIENT")
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)
 
 ADD_EXECUTABLE(mysql_client_test mysql_client_test.c ../mysys/my_memmem.c)
 TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient_notls wsock32)