Re: [cmake-developers] New module to verify that python libraries are available on the system

2016-05-03 Thread Florent Castelli

"exec(\"import sys\\ntry:\\n  import numpy\\nexcept:\\n  
sys.exit(0)\\nsys.exit(1)\")"

This seems to be great to check that numpy exists! You're probably 
missing a variable somewhere ;)


/Florent

On 03/05/2016 20:37, Francois Budin wrote:

Hello everyone,

I wrote a short macro for one project I work on to verify at 
configuration time that a python library is available on the system on 
which the project is configured. I have attached a patch to 
potentially integrate this new macro to CMake. I saw other people 
doing similar things in other projects, so it might be of interest to 
the community.

Hope this helps,

Francois




-- 

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] New module to verify that python libraries are available on the system

2016-05-03 Thread Francois Budin
Hello everyone,

I wrote a short macro for one project I work on to verify at configuration
time that a python library is available on the system on which the project
is configured. I have attached a patch to potentially integrate this new
macro to CMake. I saw other people doing similar things in other projects,
so it might be of interest to the community.
Hope this helps,

Francois
From 2c3225a2770f9628d11ab240f1b150df6ff095d9 Mon Sep 17 00:00:00 2001
From: Francois Budin 
Date: Tue, 3 May 2016 14:27:45 -0400
Subject: [PATCH] ENH: Module to check that Python libraries are available.

This new file contains a macro that verifies if a python
library is available on the system. The macro sets two variables:
${library}_ERROR and ${library}_FOUND with ${library} being the
name of the library given as the first argument of the macro.
This allows the developer to verify that the necessary libraries
are available on the system and potentially print a message
if it is not the case.
---
 Modules/CMakeCheckPythonLibrary.cmake | 57 +++
 1 file changed, 57 insertions(+)
 create mode 100644 Modules/CMakeCheckPythonLibrary.cmake

diff --git a/Modules/CMakeCheckPythonLibrary.cmake b/Modules/CMakeCheckPythonLibrary.cmake
new file mode 100644
index 000..736820b
--- /dev/null
+++ b/Modules/CMakeCheckPythonLibrary.cmake
@@ -0,0 +1,57 @@
+# - Find python libraries
+# returns:
+# - ${library}_ERROR - TRUE if more than one argument is given to the macro
+# - ${library}_FOUND - TRUE if the library could be found
+#=
+# Copyright 2001-2009 Kitware, Inc.
+# Copyright 2012 Continuum Analytics, Inc.
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+# nor the names of their contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=
+
+macro(CMakeCheckPythonLibrary library)
+  set(${library}_ERROR TRUE)
+  set(${library}_FOUND FALSE)
+  #Sanity check: Make sure only one library name is given
+  if(${ARGC} EQUAL 1)
+set(list_var "${ARGN}")
+find_package(PythonInterp REQUIRED)
+
+execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
+  "exec(\"import sys\\ntry:\\n  import numpy\\nexcept:\\n  sys.exit(0)\\nsys.exit(1)\")"
+  RESULT_VARIABLE ${library}_FOUND
+  OUTPUT_VARIABLE _PYTHON_VALUES
+  ERROR_VARIABLE _PYTHON_ERROR_VALUE
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+set(${library}_ERROR FALSE)
+  endif()
+endmacro()
-- 
2.5.0

-- 

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] [CMake 0016092]: Module CheckIncludeFile should notify in case of compiler flag errors

2016-05-03 Thread Mantis Bug Tracker

The following issue has been SUBMITTED. 
== 
https://cmake.org/Bug/view.php?id=16092 
== 
Reported By:Antonio
Assigned To:
== 
Project:CMake
Issue ID:   16092
Category:   CMake
Reproducibility:always
Severity:   minor
Priority:   normal
Status: new
== 
Date Submitted: 2016-05-03 05:10 EDT
Last Modified:  2016-05-03 05:10 EDT
== 
Summary:Module CheckIncludeFile should notify in case of
compiler flag errors
Description: 
(Problem was first mentioned in mailing list 2 weeks ago, although there was no
feedback)

CheckIncludeFile will return "header not found" if some wrong compiler flags is
set (not accepted by the compiler).

I noticed the problem when having a "check include" failure even if I was
certain the include file should be found in the include paths I had set.
When I hacked into:
CheckIncludeFile.cmake
this line:
message(STATUS "OUTPUT=${OUTPUT}")
it turned out the problem was not in including file, but in the flags that
were passed to the compiler, causing a failure that the module interprets as
"the header could not be found".

I think an error message should be printed instead in this case.
This could be handled in 2 ways:
a) Either checking first of all if, with the given flags, the compiler will
succeed in compiling a source file containing JUST an empty main function.
For efficiency, this check might even be done AFTER the first try_compile
fails.
b) Or, in case of failure, checking that the error returned is JUST the
cannot find error message.

Option a) seems to have the advantage of being extremely easy to implement,
although might introduce some overhead.
== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2016-05-03 05:10 AntonioNew Issue
==

-- 

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] Integration of clang-tidy

2016-05-03 Thread Daniel Pfeifer
FYI: I have set up a dashboard build that shows the integration in
action: https://open.cdash.org/buildSummary.php?buildid=4349265

Most of the issues have fix-it hints which can be applied
automatically by clang-tidy.

On Thu, Apr 28, 2016 at 3:44 PM, Brad King  wrote:
> On 04/27/2016 06:48 PM, Daniel Pfeifer wrote:
>> It is unrelated. Clang-Tidy picks the interesting pieces from the
>> compiler command line and ignores the rest. Whether cc is given or not
>> makes no difference.
>> But maybe we should leave the decision what to pick to Clang-Tidy? It
>> may be clearer to forward the original command line unmodified.
>
> Applied, thanks!
>
>  Clang-Tidy: Give entire compiler command line to clant-tidy tool
>  https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=304ab71d
>
> -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