[cmake] prevent in source builds

This commit is contained in:
akallabeth 2023-11-07 15:41:01 +01:00 committed by akallabeth
parent 1b31852d32
commit 615fcc4370
12 changed files with 56 additions and 9 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
**/CMakeCache.txt
**/CMakeFiles

View File

@ -62,6 +62,7 @@ endif()
# Include our extra modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
include(PreventInSourceBuilds)
if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0"))
set(UWP 1)

View File

@ -9,6 +9,9 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
set(MODULE_NAME "MacFreeRDP-library")
set(MODULE_OUTPUT_NAME "MacFreeRDP")
set(MODULE_PREFIX "FREERDP_CLIENT_MAC_LIBRARY")

View File

@ -1,6 +1,9 @@
project(MacFreeRDP)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/)
include(PreventInSourceBuilds)
set(MODULE_NAME "MacFreeRDP")
set(MODULE_OUTPUT_NAME "MacFreeRDP")
set(MODULE_PREFIX "FREERDP_CLIENT_MAC_CLIENT")

View File

@ -26,7 +26,9 @@ set(CMAKE_CXX_EXTENSIONS ON)
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
include(ConfigureFreeRDP)

View File

@ -25,7 +25,9 @@ set(CMAKE_C_EXTENSIONS ON)
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
include(MSVCRuntime)

View File

@ -26,7 +26,9 @@ set(CMAKE_C_EXTENSIONS ON)
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)

View File

@ -20,6 +20,9 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
set(MODULE_NAME "iFreeRDP")
set(MODULE_PREFIX "IFREERDP_CLIENT")
set(APP_TYPE MACOSX_BUNDLE)

View File

@ -0,0 +1,26 @@
# PreventInSourceBuilds
# ---------------------
#
# Prevent in-source builds
#
# It is generally acknowledged that it is preferable to run CMake out of source,
# in a dedicated build directory. To prevent users from accidentally running
# CMake in the source directory, just include this module.
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
# disallow in-source builds
if("${srcdir}" STREQUAL "${bindir}")
message(FATAL_ERROR "\
CMake must not to be run in the source directory. \
Rather create a dedicated build directory and run CMake there. \
CMake now already created some files, to clean up after this aborted in-source compilation:
rm -r CMakeCache.txt CMakeFiles
or
git clean -xdf
")
endif()

View File

@ -65,6 +65,7 @@ endif()
# Include our extra modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
include(PreventInSourceBuilds)
# Include cmake modules
include(CheckIncludeFiles)

View File

@ -58,6 +58,7 @@ option(UWAC_HAVE_PIXMAN_REGION "Use PIXMAN or FreeRDP for region calculations" "
# Include our extra modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
include(PreventInSourceBuilds)
# Check for cmake compatibility (enable/disable features)
include(FindFeature)

View File

@ -115,6 +115,8 @@ include(CheckSymbolExists)
include(CheckStructHasMember)
include(TestBigEndian)
include(PreventInSourceBuilds)
# Check for cmake compatibility (enable/disable features)
include(CheckCmakeCompat)
include(FindFeature)
@ -355,4 +357,3 @@ install(EXPORT WinPRTargets DESTINATION ${WINPR_CMAKE_INSTALL_DIR})
include(pkg-config-install-prefix)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/winpr.pc.in ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/winpr${WINPR_VERSION_MAJOR}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)