Forcing out-of-source builds
This is code forcing out-of-source builds. Credit goes to the llvm project where I got this. I don't know if there's any way to keep it from getting as far as creating the CMakeCache.txt and CMakeFiles before failing.
Code:
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
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.")
endif()
Config.h files
This is in the CMakeLists.txt file:
Code:
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
This is what the config.h.cmake file should look like:
Code:
#cmakedefine HAVE_SYS_WAIT_H
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H
/* Name of package */
#cmakedefine PACKAGE "${PACKAGE_NAME}"
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}"
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}"
/* If setnetgrent returns void like AIX systems, set this */
#cmakedefine SETNETGRENT_RETURNS_VOID
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS
/* Version number of package */
#cmakedefine VERSION "${PACKAGE_VERSION}"
Notice that VERSION and PACKAGE are quoted. This was to prevent build errors when this was used in printf.
Bookmarks