# HG changeset patch # User SokoL_SD # Date 1248078455 0 # Node ID 4716eaf4a67eff81e673d5a63fc4a65b5ed07445 # Parent 1349940724ebb20217839e551d1764d3ad7d6591 Hack for building in a source directory diff -r 1349940724eb -r 4716eaf4a67e CMakeLists.txt --- a/CMakeLists.txt Mon Jul 20 06:04:17 2009 +0000 +++ b/CMakeLists.txt Mon Jul 20 08:27:35 2009 +0000 @@ -6,6 +6,19 @@ ########################################################## if(NOT SECOND_RUN) +option(FORCE_IN_SOURCE_BUILD "Force the in-source building" "OFF") +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT FORCE_IN_SOURCE_BUILD) + message(FATAL_ERROR "In-source builds are not allowed. +Please create a directory and run cmake from there, passing the path +to this source directory as the last argument. +This process created the file `CMakeCache.txt` and the directory `CMakeFiles'. +Please delete them. +Or you can restart cmake with `-DFORCE_IN_SOURCE_BUILD=1`, but it is not +recomended. +") +endif() + + FIND_PACKAGE(Qt4 REQUIRED) set (QT_USE_QTMAIN false) set (QT_USE_QTGUI false) @@ -98,7 +111,12 @@ message(FATAL_ERROR "${CMAKE_GENERATOR} isn't supported") endif(${CMAKE_GENERATOR} STREQUAL "NMake Makefiles") -set(cd_path ${CMAKE_BINARY_DIR}/build) +if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set(cd_path ${CMAKE_SOURCE_DIR}) +else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set(cd_path ${CMAKE_BINARY_DIR}/build) +endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + make_native_path(cd_path) add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/build @@ -109,7 +127,7 @@ ## Make commands. set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build) add_custom_target(install - COMMAND cd ${CMAKE_BINARY_DIR}/build && ${make_util} install + COMMAND cd ${CMAKE_BINARY_DIR}/CMakeFiles/build && ${make_util} install COMMENT "" ) add_dependencies(install preinstall) @@ -144,7 +162,7 @@ else(NOT SECOND_RUN) PROJECT(qtd CXX C) -load_cache(${CMAKE_BINARY_DIR}/.. INCLUDE_INTERNALS all_packages QTD_VERSION_STR QTD_VERSION) +load_cache(${CMAKE_BINARY_DIR} INCLUDE_INTERNALS all_packages QTD_VERSION_STR QTD_VERSION) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) FIND_PACKAGE(D REQUIRED) FIND_PACKAGE(Qt4 REQUIRED) @@ -550,5 +568,6 @@ endif(BUILD_EXAMPLES) #execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/CMakeCache.txt) +set(SECOND_RUN 0 CACHE INTERNAL "") endif(NOT SECOND_RUN) \ No newline at end of file diff -r 1349940724eb -r 4716eaf4a67e build/gui.txt --- a/build/gui.txt Mon Jul 20 06:04:17 2009 +0000 +++ b/build/gui.txt Mon Jul 20 08:27:35 2009 +0000 @@ -1,6 +1,6 @@ set(required Core) qt4_generate_moc(cpp/qt_gui/UrlHandler_shell.h - ${CMAKE_CURRENT_BINARY_DIR}/cpp/qt_gui/UrlHandler_shell_moc.cpp + ${CMAKE_BINARY_DIR}/cpp/qt_gui/UrlHandler_shell_moc.cpp ) set (cpp_files qt_gui/UrlHandler_shell ) set (cpp_generated_files qt_gui/UrlHandler_shell_moc) diff -r 1349940724eb -r 4716eaf4a67e generator/CMakeLists.txt --- a/generator/CMakeLists.txt Mon Jul 20 06:04:17 2009 +0000 +++ b/generator/CMakeLists.txt Mon Jul 20 08:27:35 2009 +0000 @@ -229,7 +229,6 @@ mark_as_advanced(d_inc_file_found) set(d_inc_file_found 1) -set(dgen_impl ${CMAKE_BINARY_DIR}/build/cpp/qt_core/ArrayOps_shell.cpp) if(CMAKE_HOST_WIN32) set(sep ";") else(CMAKE_HOST_WIN32) @@ -238,11 +237,17 @@ foreach(path ${QT_INCLUDES}) set(inc_paths ${path}${sep}) endforeach(path ${QT_INCLUDES}) +if(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set(out_dir ${CMAKE_SOURCE_DIR}) +else(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) + set(out_dir ${CMAKE_BINARY_DIR}/build) +endif(${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) +set(dgen_impl ${out_dir}/cpp/qt_core/ArrayOps_shell.cpp) add_custom_command(OUTPUT ${dgen_impl} COMMAND ${CMAKE_COMMAND} -E remove -f ${dgen_impl} COMMAND "generator" ARGS ${GEN_OPT} --include-paths=${inc_paths} - --output-directory=${CMAKE_BINARY_DIR}/build + --output-directory=${out_dir} --source-directory=${CMAKE_SOURCE_DIR}/generator qtjambi_masterinclude.h ${CMAKE_BINARY_DIR}/CMakeFiles/build.txt