Merge branch 'bugfix/cmake_project_vars_not_set_by_redefinition' into 'master'

cmake: set variables set by project call

See merge request idf/esp-idf!5187
This commit is contained in:
Angus Gratton 2019-06-28 15:31:10 +08:00
commit d9ca915fa4

View file

@ -264,6 +264,31 @@ macro(project project_name)
function(project) function(project)
set(project_ARGV ARGV) set(project_ARGV ARGV)
__project(${${project_ARGV}}) __project(${${project_ARGV}})
# Set the variables that project() normally sets, documented in the
# command's docs.
#
# https://cmake.org/cmake/help/v3.5/command/project.html
#
# There is some nuance when it comes to setting version variables in terms of whether
# CMP0048 is set to OLD or NEW. However, the proper behavior should have bee already handled by the original
# project call, and we're just echoing the values those variables were set to.
set(PROJECT_NAME "${PROJECT_NAME}" PARENT_SCOPE)
set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}" PARENT_SCOPE)
set(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" PARENT_SCOPE)
set(PROJECT_VERSION "${PROJECT_VERSION}" PARENT_SCOPE)
set(PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}" PARENT_SCOPE)
set(PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}" PARENT_SCOPE)
set(PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}" PARENT_SCOPE)
set(PROJECT_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}" PARENT_SCOPE)
set(${PROJECT_NAME}_BINARY_DIR "${${PROJECT_NAME}_BINARY_DIR}" PARENT_SCOPE)
set(${PROJECT_NAME}_SOURCE_DIR "${${PROJECT_NAME}_SOURCE_DIR}" PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}" PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}" PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}" PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION_PATCH "${${PROJECT_NAME}_VERSION_PATCH}" PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION_TWEAK "${${PROJECT_NAME}_VERSION_TWEAK}" PARENT_SCOPE)
endfunction() endfunction()
# Prepare the following arguments for the idf_build_process() call using external # Prepare the following arguments for the idf_build_process() call using external