[Cmake-commits] CMake branch, next, updated. v3.6.1-1257-g7a4d351
Brad King
brad.king at kitware.com
Mon Aug 15 16:13:59 EDT 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 7a4d3516aedece0736be4c1ad1702522a3526dd6 (commit)
via eaccde1e472baaadce7f8417dbc46ee41cde09ad (commit)
from 7d693f72615cdef461fc3f22b5aefc7c5d6a93f1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a4d3516aedece0736be4c1ad1702522a3526dd6
commit 7a4d3516aedece0736be4c1ad1702522a3526dd6
Merge: 7d693f7 eaccde1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 15 16:13:57 2016 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Aug 15 16:13:57 2016 -0400
Merge topic 'ExternalProject-SOURCE_SUBDIR' into next
eaccde1e Add SOURCE_SUBDIR option to ExternalProject
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eaccde1e472baaadce7f8417dbc46ee41cde09ad
commit eaccde1e472baaadce7f8417dbc46ee41cde09ad
Author: Matthew Woehlke <matthew.woehlke at kitware.com>
AuthorDate: Mon Aug 15 14:42:22 2016 -0400
Commit: Matthew Woehlke <matthew.woehlke at kitware.com>
CommitDate: Mon Aug 15 14:42:22 2016 -0400
Add SOURCE_SUBDIR option to ExternalProject
Add a new SOURCE_SUBDIR option to ExternalProject_Add that allows
specifying the location of the CMakeLists.txt to use as the project root
relative to the SOURCE_DIR.
This is helpful for projects that have odd layouts, or projects that
provide both a superbuild and project-only build depending on which
CMakeLists.txt is used.
See also http://stackoverflow.com/questions/30028117.
Fixes #15118.
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 2ff18fc..634ef42 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -98,6 +98,8 @@ Create custom targets to build projects in external trees
``SOURCE_DIR <dir>``
Source dir to be used for build
+ ``SOURCE_SUBDIR <dir>``
+ Path to source CMakeLists.txt relative to ``SOURCE_DIR``
``CONFIGURE_COMMAND <cmd>...``
Build tree configuration command
``CMAKE_COMMAND /.../cmake``
@@ -236,6 +238,11 @@ Create custom targets to build projects in external trees
interpreted with respect to the build directory corresponding to the
source directory in which ``ExternalProject_Add`` is invoked.
+ If ``SOURCE_SUBDIR`` is set and no ``CONFIGURE_COMMAND`` is specified, the
+ configure command will run CMake using the ``CMakeLists.txt`` located in the
+ relative path specified by ``SOURCE_SUBDIR``, relative to the ``SOURCE_DIR``.
+ If no ``SOURCE_SUBDIR`` is given, ``SOURCE_DIR`` is used.
+
If ``SOURCE_DIR`` is explicitly set to an existing directory the project
will be built from it. Otherwise a download step must be specified
using one of the ``DOWNLOAD_COMMAND``, ``CVS_*``, ``SVN_*``, or ``URL``
@@ -287,8 +294,8 @@ Create custom targets to build projects in external trees
The command line, comment, working directory, and byproducts of every
standard and custom step are processed to replace tokens ``<SOURCE_DIR>``,
- ``<BINARY_DIR>``, ``<INSTALL_DIR>``, and ``<TMP_DIR>`` with
- corresponding property values.
+ ``<SOURCE_SUBDIR>``, ``<BINARY_DIR>``, ``<INSTALL_DIR>``, and ``<TMP_DIR>``
+ with corresponding property values.
Any builtin step that specifies a ``<step>_COMMAND cmd...`` or custom
step that specifies a ``COMMAND cmd...`` may specify additional command
@@ -1064,6 +1071,13 @@ function(_ep_set_directories name)
endif()
set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
endforeach()
+ get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR)
+ if(NOT source_subdir)
+ set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR ".")
+ elseif(IS_ABSOLUTE "${source_subdir}")
+ message(FATAL_ERROR
+ "External project ${name} has non-relative SOURCE_SUBDIR!")
+ endif()
if(build_in_source)
get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}")
@@ -1095,7 +1109,7 @@ macro(_ep_replace_location_tags target_name)
set(vars ${ARGN})
foreach(var ${vars})
if(${var})
- foreach(dir SOURCE_DIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOADED_FILE)
+ foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOADED_FILE)
get_property(val TARGET ${target_name} PROPERTY _EP_${dir})
string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
endforeach()
@@ -2131,7 +2145,7 @@ endfunction()
# TODO: Make sure external projects use the proper compiler
function(_ep_add_configure_command name)
- ExternalProject_Get_Property(${name} source_dir binary_dir tmp_dir)
+ ExternalProject_Get_Property(${name} source_dir source_subdir binary_dir tmp_dir)
# Depend on other external projects (file-level).
set(file_deps)
@@ -2209,7 +2223,11 @@ function(_ep_add_configure_command name)
endif()
endif()
- list(APPEND cmd "${source_dir}")
+ if(source_subdir STREQUAL ".")
+ list(APPEND cmd "${source_dir}")
+ else()
+ list(APPEND cmd "${source_dir}/${source_subdir}")
+ endif()
endif()
# If anything about the configure command changes, (command itself, cmake
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index f21e430..071da41 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1441,6 +1441,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSubdir")
+ add_test(NAME ExternalProjectSourceSubdir
+ COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/ExternalProjectSourceSubdir"
+ "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir"
+ ${build_generator_args}
+ --build-project ExternalProjectSourceSubdir
+ --force-new-ctest-process
+ --build-options ${build_options}
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir")
+
add_test(ExternalProjectLocal ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal"
diff --git a/Tests/ExternalProjectSourceSubdir/CMakeLists.txt b/Tests/ExternalProjectSourceSubdir/CMakeLists.txt
new file mode 100644
index 0000000..4688acf
--- /dev/null
+++ b/Tests/ExternalProjectSourceSubdir/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.6)
+project(ExternalProjectSourceSubdir NONE)
+include(ExternalProject)
+
+ExternalProject_Add(Example
+ SOURCE_SUBDIR subdir
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Example
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Example
+ INSTALL_COMMAND ""
+ )
diff --git a/Tests/ExternalProjectSourceSubdir/Example/subdir/CMakeLists.txt b/Tests/ExternalProjectSourceSubdir/Example/subdir/CMakeLists.txt
new file mode 100644
index 0000000..bbc3ca0
--- /dev/null
+++ b/Tests/ExternalProjectSourceSubdir/Example/subdir/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 3.0)
+project(empty)
-----------------------------------------------------------------------
Summary of changes:
Modules/ExternalProject.cmake | 28 ++++++++++++++++----
Tests/CMakeLists.txt | 12 +++++++++
Tests/ExternalProjectSourceSubdir/CMakeLists.txt | 10 +++++++
.../Example/subdir/CMakeLists.txt} | 2 +-
4 files changed, 46 insertions(+), 6 deletions(-)
create mode 100644 Tests/ExternalProjectSourceSubdir/CMakeLists.txt
copy Tests/{RunCMake/Syntax/UnterminatedBrace0.cmake => ExternalProjectSourceSubdir/Example/subdir/CMakeLists.txt} (70%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list