This commit is contained in:
Yuhang Zhao 2023-08-18 12:02:35 +08:00
parent 8196c88d89
commit 7215bd692b
1 changed files with 6 additions and 2 deletions

View File

@ -118,6 +118,12 @@ function(setup_project)
if(PROJ_ARGS_UNPARSED_ARGUMENTS) if(PROJ_ARGS_UNPARSED_ARGUMENTS)
message(AUTHOR_WARNING "setup_project: Unrecognized arguments: ${PROJ_ARGS_UNPARSED_ARGUMENTS}") message(AUTHOR_WARNING "setup_project: Unrecognized arguments: ${PROJ_ARGS_UNPARSED_ARGUMENTS}")
endif() endif()
set(__in_source_build FALSE)
are_paths_equal(PROJECT_BINARY_DIR PROJECT_SOURCE_DIR __in_source_build)
if(__in_source_build)
message(FATAL_ERROR "In-source builds are not allowed. You must build this project out-of-source.")
return()
endif()
# AUTOMOC include directory is a system include directory by default. # AUTOMOC include directory is a system include directory by default.
if(POLICY CMP0151) if(POLICY CMP0151)
cmake_policy(SET CMP0151 NEW) cmake_policy(SET CMP0151 NEW)
@ -298,8 +304,6 @@ function(setup_project)
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE) if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE) set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
endif() endif()
include(CheckPIESupported)
check_pie_supported() # This function must be called to ensure CMake adds -fPIE to the linker flags.
if(NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN) if(NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON PARENT_SCOPE) set(CMAKE_VISIBILITY_INLINES_HIDDEN ON PARENT_SCOPE)
endif() endif()