[CMake] FindMPI.cmake in 3.11.4

2018-09-13 Thread Burlen Loring

Hi,

I'm trying to transition from cmake 3.8.2 to cmake 3.11.4. There are a 
number of changes the way FindMPI.cmake behaves in 3.11 that are making 
this difficult.


In 3.11 how do I override the settings? For instance I want to set 
MPI_C_LIBRARIES, MPI_C_INCLUDE_DIRS? In 3.8 all I had to do was set 
those variables myself, before find_package(MPI), and my setting were 
used. in 3.11 find_package(MPI) ignores, and wipes out my settings, and 
then fails.


Isn't it a defacto standard of cmake to be able to override find modules 
by setting the libraries and include dirs before the module runs?


Burlen


--

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:
https://cmake.org/mailman/listinfo/cmake


[CMake] Good way to add arguments to CMAKE_STRIP on macOS

2018-09-13 Thread Rafe Hedley via CMake
Hello,
I am trying to override CMAKE_STRIP to do this command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip
 -x mylib.dylib

so I tried a basic :
set(CMAKE_STRIP "${CMAKE_STRIP} -x")
and 
set(CMAKE_STRIP ${CMAKE_STRIP} -x)
Unfortunately, this overriding does not work and there is the final command 
that I get in cmake_install.cmake :
    if(CMAKE_INSTALL_DO_STRIP)      execute_process(COMMAND 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip
 -x" "$ENV{DESTDIR}/Users/user/mylib.dylib")    endif()
or
    if(CMAKE_INSTALL_DO_STRIP)      execute_process(COMMAND 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip;-x"
 "$ENV{DESTDIR}/Users/user/mylib.dylib")    endif()
This does not work and the final command must be :
      execute_process(COMMAND 
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip"
 "-x" "$ENV{DESTDIR}/Users/user/mylib.dylib")

What is the best way to override this ?
I found a really dirty trick that I can add for each target but I don't want to 
do that:
add_custom_command(TARGET myTarget POST_BUILD COMMAND 
$<$:${CMAKE_STRIP}> $<$:-x> 
$<$:$>)
Thank you for your help.-- 

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:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] [cmake-developers] libc++ usage in CMake with Clang?

2018-09-13 Thread Stephen McDowell
Hello,

I wanted to revisit this topic.  Craig gave a great answer for using
add_{compile,link}_options which mostly answers the question -- this is the
most modern way at this time.

However, I believe that CMake would really benefit from standardizing
this.  For example, CMAKE_CXX_STL_TYPE.  I would argue that this should
also be a public "compile feature" in some form, so that it propagates to
consuming targets.

Some projects I work with do what Craig suggested and when Clang is
detected, default to using libc++ and also usually libc++-abi.  While kind
of nice, it's mostly annoying to me.  You're forcing an incompatible ABI on
me for Linux, when there's no reason to.  If I want to install to /usr/local
and use this with other dependencies say from my package manager installs,
I cannot because libc++ and libstdc++ are not compatible.  Instead of
asking projects to do some kind of option(MYLIB_USE_LIBCXX ...) and do
their own detection logic, setting the default to ON when Clang is the
compiler or whatever, if CMake supports this natively it would be a great
feature.

For example, I can compile with clang and use libstdc++ on Linux no
problem.  Similarly, when compiling with gcc, I *can* also use libc++
(assuming it's installed of course).  A rough prototype of the values
accepted (modelled after the android module):

- gnustl_shared (GNU libstdc++ shared)
- gnustl_static (GNU libstdc++ static)
- c++_shared (LLVM libc++ shared)
- c++_shared (LLVM libc++ static)
- c++_abi_shared (LLVM libc++-abi sharedi)
- c++_abi_static (LLVM libc++-abi static)

Where I do not have answers is how to make libc++ and libc++-abi more
ubiquitous.  As far as I know (which is not very far), libc++-abi cannot be
used unless you are also using libc++.  So I guess c++_abi_shared implies
c++_abi?

What about default values?

Linux: gnustl_shared seems like a reasonable choice, regardless of compiler
(e.g., don't always default to libc++ with clang [???]).
MacOS: ???
Windows: ???

I don't feel there is an immediate need for this, but long term I think
having CMAKE_CXX_STL_TYPE as well as a compile feature cxx_stl_type would
be really useful.  I started looking at possible implementation (hence the
long pause here), but ultimately gave up because I always try and implement
things for CMake that are beyond my capabilities of doing correctly.

Just soliciting feedback as to what people think about having this kind of
cmake-level STL type support, especially with respect to choosing defaults,
and in extra-specific case of Windows, ummm, what to do in general.

-Stephen

P.S. I think if CMAKE_CROSSCOMPILING is set then if the user sets either
CMAKE_CXX_STL_TYPE or cxx_stl_type this should be an error (informing them
to possibly instead set CMAKE_ANDROID_STL_TYPE if applicable)?  I don't
know what to do about cross compiling in general, but an agreement should
be reached on what to do when these proposed new variable / features are
used in conjunction with cross compiling.


On Wed, Aug 22, 2018 at 2:05 AM, Craig Scott 
wrote:

>
>
> On Wed, Aug 22, 2018 at 1:39 PM, Ian Henriksen  gmail.com> wrote:
>
>>
>>
>> On Tue, Aug 21, 2018 at 6:40 PM Craig Scott 
>> wrote:
>>
>>>
>>> On Wed, Aug 22, 2018 at 7:18 AM, Robert Dailey >> > wrote:
>>>
 On Tue, Aug 21, 2018 at 3:47 PM Craig Scott 
 wrote:
 > Excuse the brevity, but it sounds like you might be looking for the
 CXX_EXTENSIONS target property (sorry if I've misunderstood your problem,
 let me know why it isn't appropriate if so). See the following article for
 a more complete overview of this and related properties:
 >
 > https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/

 Unfortunately that's not the same. Extensions manage C++ language
 features and STL capabilities, but -stdlib is for selecting an STL
 implementation, AFAIK. Such as GNU STL and LLVM STL (which is libc++
 to clang).

>>>
>>> Sorry, yes I misunderstood your problem. After a little digging, it
>>> seems like you probably shouldn't be using the -stdlib option on Linux
>>>  anyway. FWIW, for
>>> Android, the roadmap
>>> 
>>> is converging on a single STL implementation too.
>>>
>>
>> All that first link says is that -stdlib is a flag that is specific to
>> clang and that it shouldn't be used with gcc. You can use clang on Linux
>> with either libstdc++ or libc++. I often use libc++ on Linux by setting
>> CMAKE_CXX_FLAGS on the command line, though I'll admit that for me it's
>> usually just to check if problems that come up are OS dependent, compiler
>> dependent, or standard library dependent. You have to be careful since
>> libstdc++ and libc++ have incompatible ABIs, but it's a useful feature.
>> That said, I have no idea if specifying the standard library implementation
>> merits handling at the CMake level since only clang supports switching
>>