Allow prefix builds with developer-build as feature enabled

Just like with qmake, separate the two "features".

Change-Id: Idf2a796c7c4aaa740c471688b2221d7041fed643
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Simon Hausmann 2019-06-25 12:09:10 +02:00
parent 6290efc4eb
commit e5b62e9607
2 changed files with 15 additions and 10 deletions

View File

@ -289,7 +289,7 @@ function(remove_install_target)
add_custom_target(remove_cmake_install ALL DEPENDS ${file_generated}) add_custom_target(remove_cmake_install ALL DEPENDS ${file_generated})
endfunction() endfunction()
function(qt_set_up_developer_build) function(qt_set_up_nonprefix_build)
if(NOT QT_WILL_INSTALL) if(NOT QT_WILL_INSTALL)
remove_install_target() remove_install_target()
endif() endif()

View File

@ -40,14 +40,10 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if(FEATURE_developer_build) # Detect non-prefix builds, either when the install prefix is set to the binary dir
if(DEFINED QT_CMAKE_EXPORT_COMPILE_COMMANDS) # or when enabling developer builds and no prefix is specified.
set(CMAKE_EXPORT_COMPILE_COMMANDS ${QT_CMAKE_EXPORT_COMPILE_COMMANDS}) if((CMAKE_INSTALL_PREFIX STREQUAL CMAKE_BINARY_DIR) OR (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build))
else()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
set(QT_WILL_INSTALL OFF) set(QT_WILL_INSTALL OFF)
set(QT_BUILD_TESTING ON)
# Handle non-prefix builds by setting the cmake install prefix to the project binary dir. # Handle non-prefix builds by setting the cmake install prefix to the project binary dir.
if(PROJECT_NAME STREQUAL "QtBase") if(PROJECT_NAME STREQUAL "QtBase")
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH
@ -61,6 +57,15 @@ else()
set(QT_BUILD_TESTING OFF) set(QT_BUILD_TESTING OFF)
endif() endif()
if(FEATURE_developer_build)
if(DEFINED QT_CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_EXPORT_COMPILE_COMMANDS ${QT_CMAKE_EXPORT_COMPILE_COMMANDS})
else()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
set(QT_BUILD_TESTING ON)
endif()
## Set up testing ## Set up testing
option(BUILD_TESTING "Build the testing tree." ${QT_BUILD_TESTING}) option(BUILD_TESTING "Build the testing tree." ${QT_BUILD_TESTING})
include(CTest) include(CTest)
@ -86,8 +91,8 @@ include(QtCompilerOptimization)
## Compiler flags: ## Compiler flags:
include(QtCompilerFlags) include(QtCompilerFlags)
## Set up developer build: ## Set up non-prefix build:
qt_set_up_developer_build() qt_set_up_nonprefix_build()
## Find host tools (if non native): ## Find host tools (if non native):
set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.") set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.")