[Cmake-commits] CMake branch, next, updated. v3.1.0-rc1-219-g0d58a36
Daniele E. Domenichelli
daniele.domenichelli at gmail.com
Thu Oct 30 13:46:54 EDT 2014
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 0d58a36ede819753219c5f417db001182ade3ff9 (commit)
via fdbfbaaa3297b5a7f32a52822d9d80319ccfe7ff (commit)
via 8c951a35da6bc6554e596a6e07d3db1e61cd7877 (commit)
via ff7da72d3271cb9d4b1760c9c5a45b326027ee3c (commit)
via b3bd0fb10ce3a449477913278646997bef23a988 (commit)
from 2d1d312f9812366f5a84edfc3aecd3566f62b60a (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0d58a36ede819753219c5f417db001182ade3ff9
commit 0d58a36ede819753219c5f417db001182ade3ff9
Merge: 2d1d312 fdbfbaa
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
AuthorDate: Thu Oct 30 13:46:53 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Oct 30 13:46:53 2014 -0400
Merge topic 'ExternalProject_CMAKE_CACHE_DEFAULT_ARGS' into next
fdbfbaaa Extend ExternalProjectLocal test to cover CMAKE_CACHE_DEFAULT_ARGS
8c951a35 Fix Tutorial tests when USE_MYMATH is OFF
ff7da72d ExternalProject: Add unit tests for CMAKE_CACHE_DEFAULT_ARGS
b3bd0fb1 ExternalProject: Add CMAKE_CACHE_DEFAULT_ARGS arguments
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fdbfbaaa3297b5a7f32a52822d9d80319ccfe7ff
commit fdbfbaaa3297b5a7f32a52822d9d80319ccfe7ff
Author: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Thu Oct 30 12:34:34 2014 +0100
Commit: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
CommitDate: Thu Oct 30 18:24:15 2014 +0100
Extend ExternalProjectLocal test to cover CMAKE_CACHE_DEFAULT_ARGS
diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt
index f942197..cbbb555 100644
--- a/Tests/ExternalProjectLocal/CMakeLists.txt
+++ b/Tests/ExternalProjectLocal/CMakeLists.txt
@@ -66,6 +66,7 @@ if(can_build_tutorial_step5)
ExternalProject_Add(${proj}
URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+ CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
TEST_AFTER_INSTALL 1
LOG_TEST 1
)
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c951a35da6bc6554e596a6e07d3db1e61cd7877
commit 8c951a35da6bc6554e596a6e07d3db1e61cd7877
Author: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Thu Oct 30 12:23:27 2014 +0100
Commit: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
CommitDate: Thu Oct 30 18:24:14 2014 +0100
Fix Tutorial tests when USE_MYMATH is OFF
Unit tests for the square root of "-25" currently fail when USE_MYMATH
is disabled. The "mysqrt" method in the tutorials, returns "0" for a
negative value, while "sqrt" returns "NaN", and therefore the output is
not accepted by the test.
This patch checks if the number is negative and eventually returns "0"
before calling "sqrt" or "mysqrt" to fix this issue.
Printing a NaN might cause issues with the string catched by the tests
on some platform. Therefore assume that "0" is correct and "fix" the
USE_MYMATH=OFF version by checking if the number is negative and
eventually returning "0" before calling "sqrt" or "mysqrt".
diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx
index 82b416f..c27da0b 100644
--- a/Tests/Tutorial/Step2/tutorial.cxx
+++ b/Tests/Tutorial/Step2/tutorial.cxx
@@ -21,12 +21,16 @@ int main (int argc, char *argv[])
}
double inputValue = atof(argv[1]);
+ double outputValue = 0;
+ if(inputValue >= 0)
+ {
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ outputValue = sqrt(inputValue);
#endif
+ }
fprintf(stdout,"The square root of %g is %g\n",
inputValue, outputValue);
diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx
index 82b416f..c27da0b 100644
--- a/Tests/Tutorial/Step3/tutorial.cxx
+++ b/Tests/Tutorial/Step3/tutorial.cxx
@@ -21,12 +21,16 @@ int main (int argc, char *argv[])
}
double inputValue = atof(argv[1]);
+ double outputValue = 0;
+ if(inputValue >= 0)
+ {
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ outputValue = sqrt(inputValue);
#endif
+ }
fprintf(stdout,"The square root of %g is %g\n",
inputValue, outputValue);
diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx
index 82b416f..c27da0b 100644
--- a/Tests/Tutorial/Step4/tutorial.cxx
+++ b/Tests/Tutorial/Step4/tutorial.cxx
@@ -21,12 +21,16 @@ int main (int argc, char *argv[])
}
double inputValue = atof(argv[1]);
+ double outputValue = 0;
+ if(inputValue >= 0)
+ {
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ outputValue = sqrt(inputValue);
#endif
+ }
fprintf(stdout,"The square root of %g is %g\n",
inputValue, outputValue);
diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx
index 82b416f..c27da0b 100644
--- a/Tests/Tutorial/Step5/tutorial.cxx
+++ b/Tests/Tutorial/Step5/tutorial.cxx
@@ -21,12 +21,16 @@ int main (int argc, char *argv[])
}
double inputValue = atof(argv[1]);
+ double outputValue = 0;
+ if(inputValue >= 0)
+ {
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ outputValue = sqrt(inputValue);
#endif
+ }
fprintf(stdout,"The square root of %g is %g\n",
inputValue, outputValue);
diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx
index 82b416f..c27da0b 100644
--- a/Tests/Tutorial/Step6/tutorial.cxx
+++ b/Tests/Tutorial/Step6/tutorial.cxx
@@ -21,12 +21,16 @@ int main (int argc, char *argv[])
}
double inputValue = atof(argv[1]);
+ double outputValue = 0;
+ if(inputValue >= 0)
+ {
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ outputValue = sqrt(inputValue);
#endif
+ }
fprintf(stdout,"The square root of %g is %g\n",
inputValue, outputValue);
diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx
index 82b416f..c27da0b 100644
--- a/Tests/Tutorial/Step7/tutorial.cxx
+++ b/Tests/Tutorial/Step7/tutorial.cxx
@@ -21,12 +21,16 @@ int main (int argc, char *argv[])
}
double inputValue = atof(argv[1]);
+ double outputValue = 0;
+ if(inputValue >= 0)
+ {
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ outputValue = sqrt(inputValue);
#endif
+ }
fprintf(stdout,"The square root of %g is %g\n",
inputValue, outputValue);
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff7da72d3271cb9d4b1760c9c5a45b326027ee3c
commit ff7da72d3271cb9d4b1760c9c5a45b326027ee3c
Author: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Tue Oct 28 11:05:57 2014 +0100
Commit: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
CommitDate: Thu Oct 30 14:15:02 2014 +0100
ExternalProject: Add unit tests for CMAKE_CACHE_DEFAULT_ARGS
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index fd3bb03..a99b46f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -153,3 +153,4 @@ add_RunCMake_test(CommandLine)
add_RunCMake_test(install)
add_RunCMake_test(CPackInstallProperties)
+add_RunCMake_test(ExternalProject)
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
new file mode 100644
index 0000000..bf9b12d
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
@@ -0,0 +1,21 @@
+include(ExternalProject)
+
+set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp")
+set(_cache_file "${_tmp_dir}/FOO-cache.cmake")
+
+ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}"
+ DOWNLOAD_COMMAND ""
+ CMAKE_CACHE_ARGS "-DFOO:STRING=BAR")
+
+if(NOT EXISTS "${_cache_file}")
+ message(FATAL_ERROR "Initial cache not created")
+endif()
+
+file(READ "${_cache_file}" _cache)
+
+if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\)
+ message(FATAL_ERROR "Cannot find FOO argument in cache")
+endif()
+if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
+ message(FATAL_ERROR "Expected forced FOO argument")
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
new file mode 100644
index 0000000..c216664
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
@@ -0,0 +1,21 @@
+include(ExternalProject)
+
+set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp")
+set(_cache_file "${_tmp_dir}/FOO-cache.cmake")
+
+ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}"
+ DOWNLOAD_COMMAND ""
+ CMAKE_CACHE_DEFAULT_ARGS "-DFOO:STRING=BAR")
+
+if(NOT EXISTS "${_cache_file}")
+ message(FATAL_ERROR "Initial cache not created")
+endif()
+
+file(READ "${_cache_file}" _cache)
+
+if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\)
+ message(FATAL_ERROR "Cannot find FOO argument in cache")
+endif()
+if("${CMAKE_MATCH_0}" MATCHES FORCE)
+ message(FATAL_ERROR "Expected not forced FOO argument")
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake
new file mode 100644
index 0000000..894e183
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake
@@ -0,0 +1,29 @@
+include(ExternalProject)
+
+set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp")
+set(_cache_file "${_tmp_dir}/FOO-cache.cmake")
+
+ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}"
+ DOWNLOAD_COMMAND ""
+ CMAKE_CACHE_ARGS "-DFOO:STRING=BAR"
+ CMAKE_CACHE_DEFAULT_ARGS "-DBAR:STRING=BAZ")
+
+if(NOT EXISTS "${_cache_file}")
+ message(FATAL_ERROR "Initial cache not created")
+endif()
+
+file(READ "${_cache_file}" _cache)
+
+if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\)
+ message(FATAL_ERROR "Cannot find FOO argument in cache")
+endif()
+if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
+ message(FATAL_ERROR "Expected forced FOO argument")
+endif()
+
+if(NOT "${_cache}" MATCHES "set\\(BAR \"BAZ\".+\\)") # \(\)
+ message(FATAL_ERROR "Cannot find BAR argument in cache")
+endif()
+if("${CMAKE_MATCH_0}" MATCHES FORCE)
+ message(FATAL_ERROR "Expected not forced BAR argument")
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMakeLists.txt b/Tests/RunCMake/ExternalProject/CMakeLists.txt
new file mode 100644
index 0000000..c585733
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
new file mode 100644
index 0000000..1614ecc
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMAKE_CACHE_ARGS)
+run_cmake(CMAKE_CACHE_DEFAULT_ARGS)
+run_cmake(CMAKE_CACHE_mix)
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3bd0fb10ce3a449477913278646997bef23a988
commit b3bd0fb10ce3a449477913278646997bef23a988
Author: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
AuthorDate: Tue Oct 28 10:52:16 2014 +0100
Commit: Daniele E. Domenichelli <daniele.domenichelli at iit.it>
CommitDate: Thu Oct 30 14:15:02 2014 +0100
ExternalProject: Add CMAKE_CACHE_DEFAULT_ARGS arguments
This argument allows to set default arguments that are written in the
initial cache file, but that are not forced, and therefore allows the
user to change these values later (CMAKE_ARGS and CMAKE_CACHE_ARGS
always overwrite the values).
Also add some documentation to explain the differences between these 3
arguments.
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index a92f20c..3d1ab34 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -98,9 +98,27 @@ Create custom targets to build projects in external trees
``CMAKE_GENERATOR_TOOLSET <toolset>``
Generator-specific toolset name
``CMAKE_ARGS <arg>...``
- Arguments to CMake command line
+ Arguments to CMake command line.
+ These arguments are passed to CMake command line, and can contain
+ arguments other than cache values, see also
+ :manual:`CMake Options <cmake(1)>`. Arguments in the form
+ ``-Dvar:string=on`` are always passed to the command line, and
+ therefore cannot be changed by the user.
``CMAKE_CACHE_ARGS <arg>...``
- Initial cache arguments, of the form ``-Dvar:string=on``
+ Initial cache arguments, of the form ``-Dvar:string=on``.
+ These arguments are written in a pre-load a script that populates
+ CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows to
+ overcome command line length limits.
+ These arguments are :command:`set` using the ``FORCE`` argument,
+ and therefore cannot be changed by the user.
+ ``CMAKE_CACHE_DEFAULT_ARGS <arg>...``
+ Initial default cache arguments, of the form ``-Dvar:string=on``.
+ These arguments are written in a pre-load a script that populates
+ CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows to
+ overcome command line length limits.
+ These arguments can be used as default value that will be set if no
+ previous value is found in the cache, and that the user can change
+ later.
Build step options are:
@@ -986,17 +1004,20 @@ macro(_ep_replace_location_tags target_name)
endmacro()
-function(_ep_write_initial_cache target_name script_filename args)
- # Write out values into an initial cache, that will be passed to CMake with -C
+function(_ep_command_line_to_initial_cache var args force)
set(script_initial_cache "")
set(regex "^([^:]+):([^=]+)=(.*)$")
set(setArg "")
+ set(forceArg "")
+ if(force)
+ set(forceArg "FORCE")
+ endif()
foreach(line ${args})
if("${line}" MATCHES "^-D(.*)")
set(line "${CMAKE_MATCH_1}")
if(setArg)
# This is required to build up lists in variables, or complete an entry
- set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
+ set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
set(script_initial_cache "${script_initial_cache}\n${setArg}")
set(accumulator "")
set(setArg "")
@@ -1016,9 +1037,15 @@ function(_ep_write_initial_cache target_name script_filename args)
endforeach()
# Catch the final line of the args
if(setArg)
- set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
+ set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
set(script_initial_cache "${script_initial_cache}\n${setArg}")
endif()
+ set(${var} ${script_initial_cache} PARENT_SCOPE)
+endfunction()
+
+
+function(_ep_write_initial_cache target_name script_filename script_initial_cache)
+ # Write out values into an initial cache, that will be passed to CMake with -C
# Replace location tags.
_ep_replace_location_tags(${target_name} script_initial_cache)
# Write out the initial cache file to the location specified.
@@ -1833,11 +1860,20 @@ function(_ep_add_configure_command name)
get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS)
list(APPEND cmd ${cmake_args})
- # If there are any CMAKE_CACHE_ARGS, write an initial cache and use it
+ # If there are any CMAKE_CACHE_ARGS or CMAKE_CACHE_DEFAULT_ARGS,
+ # write an initial cache and use it
get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS)
- if(cmake_cache_args)
+ get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS)
+
+ if(cmake_cache_args OR cmake_cache_default_args)
set(_ep_cache_args_script "${tmp_dir}/${name}-cache.cmake")
- _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${cmake_cache_args}")
+ if(cmake_cache_args)
+ _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1)
+ endif()
+ if(cmake_cache_default_args)
+ _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0)
+ endif()
+ _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}")
list(APPEND cmd "-C${_ep_cache_args_script}")
endif()
-----------------------------------------------------------------------
Summary of changes:
Modules/ExternalProject.cmake | 54 ++++++++++++++++----
Tests/ExternalProjectLocal/CMakeLists.txt | 1 +
Tests/RunCMake/CMakeLists.txt | 1 +
.../ExternalProject/CMAKE_CACHE_ARGS.cmake | 21 ++++++++
.../ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake | 21 ++++++++
.../RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake | 29 +++++++++++
.../{CMP0004 => ExternalProject}/CMakeLists.txt | 2 +-
Tests/RunCMake/ExternalProject/RunCMakeTest.cmake | 5 ++
Tests/Tutorial/Step2/tutorial.cxx | 8 ++-
Tests/Tutorial/Step3/tutorial.cxx | 8 ++-
Tests/Tutorial/Step4/tutorial.cxx | 8 ++-
Tests/Tutorial/Step5/tutorial.cxx | 8 ++-
Tests/Tutorial/Step6/tutorial.cxx | 8 ++-
Tests/Tutorial/Step7/tutorial.cxx | 8 ++-
14 files changed, 160 insertions(+), 22 deletions(-)
create mode 100644 Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
create mode 100644 Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
create mode 100644 Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake
copy Tests/RunCMake/{CMP0004 => ExternalProject}/CMakeLists.txt (56%)
create mode 100644 Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list