[cmake-developers] A CMAKE_EMULATOR variable

2015-03-03 Thread Matt McCormick
Hi,

I have pushed to stage [1] support for a CMAKE_EMULATOR variable to
help when cross-compiling.  The goal is to improve cross compiling
with CMake by making it easier to build and run tests.  In principle,
the commands

  cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake
-DCMAKE_EMULATOR=/path/to/emulator ~/src/project
  cmake -D Experimental

are all that is needed generate a dashboard report, complete with test
results.  This should inch C/C++ closer to being the "write once, run
anywhere" languages :-).

The emulator is used to run try_run results, which avoids manual
population of TryRunResults.cmake.  This can be a painful,
time-consuming process otherwise.

It is also used to run tests on executables that are built for the
target system.  Without this approach, it is difficult to know which
tests should be executed on the target system.  Tests are often passed
absolute paths to input on the host system.  The use of an emulator is
a way to avoid complexities and transfer overhead related to
reproducing the host filesystem on the target filesystem to run the
tests.


With some fixes to ITK [2], this was used to build and test for four
cases of interest.

The emulator approach works best with MinGW and WINE to build and test
on Linux for Windows [3].

The qemu-arm emulator provided by QEMU User Mode can be used with the
Android NDK toolchain [4]. A gotcha is that Android tries to be fancy
and uses its own dynamic loader.  To get around this, I tested with
completely static executables.  Also, QEMU User Mode does not
currently support multi-threading well, so tests were run
single-threaded. An alternative approach may be to use an emulator
script that is a wrapper around adb.

The qemu-arm emulator was used again with the Raspberry Pi toolchain
[5].  A symbolic link was created in the expected location for
ld-linux-armhf.so.3, and dynamic loading works.  To run the tests,
LD_LIBRARY_PATH was populated with the path to libc and libstdcxx.

One of the most interesting combinations is the Emscripten toolchain
with NodeJS as the emulator [6]. There are some WIP workarounds to get
Emscripten to configure cleanly for scientific libraries [7], and code
had to be injected into the test driver to mount local filesystems for
node, but this works surprisingly well.


Testing and feedback are appreciated.

Thanks,
Matt


[1] 
http://www.cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/emulator

[2] https://github.com/thewtex/ITK/tree/cmake-emulator

[3] https://open.cdash.org/buildSummary.php?buildid=3694578

[4] https://open.cdash.org/buildSummary.php?buildid=3694810

[5] https://open.cdash.org/buildSummary.php?buildid=3694810

[6] https://open.cdash.org/buildSummary.php?buildid=3705525

[7] https://github.com/thewtex/emscripten/tree/test-big-endian
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] [PATCH] CPack: change cpack_set_if_not_set into a function

2015-03-03 Thread Brad King
On 03/03/2015 01:33 PM, Роман Донченко wrote:
> Since it's currently a macro, then due to macro processing rules, special
> characters inside the value are interpreted by the parser, which can
> result in syntax errors or a mismatch between the given default and the
> value the variable is actually set to.
> 
> Remove existing local workarounds for this issue, which are no longer
> required.

Thanks.  As nice as it would be to do that, the reason it has not been
done is that this API is exposed publicly.  Any existing calls within
other projects would also have such workarounds and they would be broken
by this change.

Instead one could introduce a new API function for this, e.g.

 cpack_maybe_set(...)

Existing calls to cpack_set_if_not_set within CMake itself can be
ported in an immediately following patch.  The macro can be documented
as deprecated with a suggestion to use the function instead.

If you work on that, please include tests (perhaps in the form of a
new Tests/RunCMake/CPack directory), documentation updates, and a
release note in a file such as 'Help/release/dev/cpack-maybe-set.rst'.

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

[cmake-developers] [PATCH] CPack: change cpack_set_if_not_set into a function

2015-03-03 Thread Роман Донченко
Since it's currently a macro, then due to macro processing rules, special
characters inside the value are interpreted by the parser, which can
result in syntax errors or a mismatch between the given default and the
value the variable is actually set to.

Remove existing local workarounds for this issue, which are no longer
required.
---
 Modules/CPack.cmake | 14 ++
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index 532596d..4b10723 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -298,12 +298,12 @@ endif()
 # Include CPackComponent macros if it has not already been included before.
 include(CPackComponent)
 
-# Macro for setting values if a user did not overwrite them
-macro(cpack_set_if_not_set name value)
+# Function for setting values if a user did not overwrite them
+function(cpack_set_if_not_set name value)
   if(NOT DEFINED "${name}")
-set(${name} "${value}")
+set(${name} "${value}" PARENT_SCOPE)
   endif()
-endmacro()
+endfunction()
 
 # cpack_encode_variables - Macro to encode variables for the configuration file
 # find any variable that starts with CPACK and create a variable
@@ -534,9 +534,7 @@ endif()
 cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME 
"${CPACK_PACKAGE_INSTALL_DIRECTORY}")
 
 if(CPACK_NSIS_DISPLAY_NAME_SET)
-  string(REPLACE "\\" ""
-_NSIS_DISPLAY_NAME_TMP  "${CPACK_NSIS_DISPLAY_NAME}")
-  cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${_NSIS_DISPLAY_NAME_TMP}")
+  cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}")
 else()
   cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME 
"${CPACK_PACKAGE_INSTALL_DIRECTORY}")
 endif()
@@ -604,7 +602,7 @@ cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG 
"${CPACK_SYSTEM_NAME}-Source")
 cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME
   "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
 cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
-  
"/CVS/;/.svn/;/.bzr/;/.hg/;/.git/;.swp$;.#;/#")
+  "/CVS/;/.svn/;/.bzr/;/.hg/;/.git/;.swp$;.#;/#")
 set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
 set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
 set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
-- 
2.1.4

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] RFC: CMake precompiled header support and custom compiler based implementation

2015-03-03 Thread Adam Strzelecki
> Could we rename this? Currently target_* functions are all related to
> usage requirements and these are not usage requirements.

Honestly I don't understand your request. What would be then the name that 
better represents what the function does.

Also please note this is proposed API to be handled directly by CMake, once 
there is a green light I'll propose patches to CMake itself.


In meantime https://github.com/nanoant/CMakePCHCompiler is just an 
implementation that "emulates" desired behavior using many tricks. But I don't 
want this to be a part of CMake, but instead I want this to be handled natively 
adding some extra variables:

CMAKE__PRECOMPILE_HEADER

GCC, Clang: same as CMAKE__COMPILE_OBJECT
MSVC: CMAKE__COMPILE_OBJECT with "-c" replaced with 
"/FoNUL /Yc /Fp"

CMAKE__PRECOMPILED_HEADER_EXTENSION

GCC: .gch
MSVC, Clang: .pch

CMAKE_PRECOMPILED_HEADER_FLAG_

GCC, Clang: -include 
MSVC: /Yu /Fp /FI$

And extending CMake to generate proper build commands for Makefile, Ninja 
targets, and also Xcode, MSVC generators.

-- Adam
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers