Re: [CMake] Linking C program to external C++ library

2015-05-28 Thread Lucas . Pettey
The CMAKE_*_COMPILER variables are set correctly.

The CMAKE_*_IMPLICIT_LINK_LIBRARIES have a whole bunch of libraries probably 
generated from the Cray wrapper.

It is interesting to note that the stdc++ library is in 
CMAKE_C_IMPLICIT_LINK_LIBRARIES and CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES but 
not in CMAKE_CXX_IMPLICIT_LINK_LIBRARIES.

Also, when the LINKER_LANGUAGE variable is not set, CMake links with the C 
compiler but does not add the stdc++ library.

On the Cray systems, the wrappers correctly invoke all necessary libraries, 
thus CMake is working harder than it needs to. Is there any way to tell CMake 
not to add these other IMPLICIT_LINK_LIBRARIES when doing  a mixed language 
build?

Thanks,
 
Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com


From: Brad King [brad.k...@kitware.com]
Sent: Wednesday, May 27, 2015 12:36 PM
To: Pettey, Lucas @ EngilityCorp
Cc: cmake@cmake.org; Dan Liew
Subject: Re: [CMake] Linking C program to external C++ library

On 05/21/2015 06:00 PM, lucas.pet...@engilitycorp.com wrote:
 I am trying to compile a code written in C, but using an external
 library that contains C++ functions. I am on a Cray system and
 everything works if I manually link with the cray CC wrapper.
 When I change the linker language with this command:

 set_property(TARGET adh PROPERTY LINKER_LANGUAGE CXX)

 CMake is using the CC wrapper, but adding -lstdc++ to the link line.
 This causes an error. Can anyone tell me how to not get this added library?

CMake detects the libraries implicitly added by the compiler front-end
for each language.  When mixing languages it chooses to link using the
compiler front-end for one of the languages and adds the implicit
libraries needed for other languages and not added by the chosen one.
This case looks strange because you are telling it to link with the
C++ compiler but CMake is still adding the implicit library for C++.

Look at CMakeFiles/${CMAKE_VERSION}/CMake*Compiler.cmake for details
of the compiler detected for each language.  Look for these variables:

 CMAKE_C_COMPILER
 CMAKE_C_IMPLICIT_LINK_LIBRARIES

 CMAKE_CXX_COMPILER
 CMAKE_CXX_IMPLICIT_LINK_LIBRARIES

To what are they set?

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


Re: [CMake] Linking C program to external C++ library

2015-05-28 Thread Lucas . Pettey
Thanks for the very complete answer, Brad.

I will implement your final suggestion since we have no control over the 
compiler scripts and already have some platform dependent variables set.

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com


From: Brad King [brad.k...@kitware.com]
Sent: Thursday, May 28, 2015 12:49 PM
To: Pettey, Lucas @ EngilityCorp
Cc: cmake@cmake.org; Dan Liew
Subject: Re: [CMake] Linking C program to external C++ library

On 05/28/2015 01:32 PM, lucas.pet...@engilitycorp.com wrote:
 It is interesting to note that the stdc++ library is in
 CMAKE_C_IMPLICIT_LINK_LIBRARIES and CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES
 but not in CMAKE_CXX_IMPLICIT_LINK_LIBRARIES.

A similar case was discussed here:

 http://www.cmake.org/Bug/view.php?id=14207#c33256

and deemed to be local misconfiguration of the compilers.
There is no reason a C or Fortran compiler should link to
the C++ runtime library.

 when the LINKER_LANGUAGE variable is not set, CMake
 links with the C compiler but does not add the stdc++ library.

That's because it sees stdc++ in the C implicit library list
so it knows the compiler front-end will add it.

 Is there any way to tell CMake not to add these other
 IMPLICIT_LINK_LIBRARIES when doing  a mixed language build?

Once could add

 set(CMAKE_C_IMPLICIT_LINK_LIBRARIES )
 set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES )
 set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES )

to the project after the respective languages are enabled
(by the project() or enable_language() commands).

-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


Re: [CMake] (no subject)

2015-05-22 Thread Lucas . Pettey
The Cray system requires static libraries, so all symbols are defined during 
the linking process. 

Leaving out the LINKER_LANGUAGE CXX statement, CMake sees all the source files 
as C files, uses the C linker and I get undefined symbol errors. Manually 
linking with the C++ linker but excluding the -lstdc++ flag generates an 
executable.

I really just need CMake to use the C++ linker without adding that flag.

Thanks,

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com


From: Dan Liew [d...@su-root.co.uk]
Sent: Friday, May 22, 2015 7:19 AM
To: Pettey, Lucas @ EngilityCorp
Cc: cmake@cmake.org
Subject: Re: [CMake] (no subject)

Hi,

On 21 May 2015 at 23:00,  lucas.pet...@engilitycorp.com wrote:
 Hello,

 I am trying to compile a code written in C, but using an external library
 that contains C++ functions. I am on a Cray system and everything works if I
 manually link with the cray CC wrapper. When I change the linker language
 with this command:

 set_property(TARGET adh PROPERTY LINKER_LANGUAGE CXX)

 CMake is using the CC wrapper, but adding -lstdc++ to the link line. This
 causes an error. Can anyone tell me how to not get this added library?

Why are you telling CMake that the linker language is C++ in the
target you are building is C code? The C code you are compiling be
must calling into extern C functions in the external library you
mention which means the linker (at compile time) should not need to
know about C++ at all. At runtime the linker needs to know that your
external library depends on C++ but you don't need to be concerned
with this because when your external library was built those
dependencies end up in the shared library.

E.g.

```
$ readelf -d /usr/lib/libboost_program_options.so
...
  TagType Name/Value
...
0x0001 (NEEDED) Shared library: [libstdc++.so.6]
...
```

Does your target build if you just leave  LINKER_LANGUAGE alone (i.e.
set C)? I would expect that it would.

Thanks,
Dan.
-- 

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


[CMake] (no subject)

2015-05-21 Thread Lucas . Pettey
Hello,

I am trying to compile a code written in C, but using an external library that 
contains C++ functions. I am on a Cray system and everything works if I 
manually link with the cray CC wrapper. When I change the linker language with 
this command:

set_property(TARGET adh PROPERTY LINKER_LANGUAGE CXX)

CMake is using the CC wrapper, but adding -lstdc++ to the link line. This 
causes an error. Can anyone tell me how to not get this added library?

Thanks,

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com
-- 

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

[CMake] Cray wrappers and Intel compilers

2015-05-05 Thread Lucas . Pettey
Hello,

I have been trying to use Cmake 3.2.2 on a Cray XC30 with the Intel compilers 
loaded. I encounter the following error:

  /opt/cray/craype/2.2.0/bin/cc -o
  CMakeFiles/cmTryCompileExec2303156381.dir/testCCompiler.c.o -c
  
/p/home/lpettey/adh/parmetis-4.0.3/build/Linux-x86_64/CMakeFiles/CMakeTmp/testCCompiler.c


  Linking C executable cmTryCompileExec2303156381

  /p/home/lpettey/cmake-3.2.2/install/bin/cmake -E cmake_link_script
  CMakeFiles/cmTryCompileExec2303156381.dir/link.txt --verbose=1

  /opt/cray/craype/2.2.0/bin/cc
  CMakeFiles/cmTryCompileExec2303156381.dir/testCCompiler.c.o -o
  cmTryCompileExec2303156381 -rdynamic

  ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in
  `/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../lib64/libc.a(strcmp.o)'
  can not be used when making an executable; recompile with -fPIE and relink
  with -pie

Is there any way to ask Cmake not to add the -rdynamic to the link line? I 
believe this is what is causing the error.

Thanks,

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com
-- 

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

[CMake] CMake configuration hangs with TAU on Mac OSX

2014-10-09 Thread Lucas . Pettey
Hello,

I cannot seem to get CMake to work with TAU on a Mac. I have tried Mountain 
Lion and Mavericks.

I have tried CC=tau_cc.sh CXX=tau_cxx.sh ccmake but the configuration step 
hangs at 6%.

I know my tau installation is working because it was able to build the program 
using a handwritten makefile.

I know the CMake files are good because the program will configure, generate 
and build using CMake and the gcc compilers.

Any ides?


Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com
-- 

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

[CMake] FindBLAS not always finding CBLAS

2014-10-02 Thread Lucas . Pettey
Hello everyone,

I am having a strange issue with CMake version 2.8.11.2 on my Mac running 
Mavericks.

I have two different projects, both of which use find_package(BLAS REQUIRED).

The project which finds CBLAS and adds the correct -framework Accelerate to the 
link step has this in the CMakeCache.txt:

//Path to a library.
BLAS_Accelerate_LIBRARY:FILEPATH=/System/Library/Frameworks/Accelerate.framework

//Path to a library.
BLAS_acml_LIBRARY:FILEPATH=BLAS_acml_LIBRARY-NOTFOUND

//Path to a library.
BLAS_cblas_LIBRARY:FILEPATH=/usr/lib/libcblas.dylib

//Path to a library.
BLAS_complib.sgimath_LIBRARY:FILEPATH=BLAS_complib.sgimath_LIBRARY-NOTFOUND

//Path to a library.
BLAS_cxml_LIBRARY:FILEPATH=BLAS_cxml_LIBRARY-NOTFOUND

//Path to a library.
BLAS_dxml_LIBRARY:FILEPATH=BLAS_dxml_LIBRARY-NOTFOUND

//Path to a library.
BLAS_essl_LIBRARY:FILEPATH=BLAS_essl_LIBRARY-NOTFOUND

//Path to a library.
BLAS_f77blas_LIBRARY:FILEPATH=BLAS_f77blas_LIBRARY-NOTFOUND

//Path to a library.
BLAS_scsl_LIBRARY:FILEPATH=BLAS_scsl_LIBRARY-NOTFOUND

//Path to a library.
BLAS_sgemm_LIBRARY:FILEPATH=BLAS_sgemm_LIBRARY-NOTFOUND

//Path to a library.
BLAS_sunperf_LIBRARY:FILEPATH=BLAS_sunperf_LIBRARY-NOTFOUND

The non working project that does not find CBLAS or add -framework Accelerate 
has this in the CMakeCache.txt:

//Path to a library.
BLAS_Accelerate_LIBRARY:FILEPATH=/System/Library/Frameworks/Accelerate.framework

//Path to a library.
BLAS_acml_LIBRARY:FILEPATH=BLAS_acml_LIBRARY-NOTFOUND

//Path to a library.
BLAS_acml_mp_LIBRARY:FILEPATH=BLAS_acml_mp_LIBRARY-NOTFOUND

//Path to a library.
BLAS_complib.sgimath_LIBRARY:FILEPATH=BLAS_complib.sgimath_LIBRARY-NOTFOUND

//Path to a library.
BLAS_cxml_LIBRARY:FILEPATH=BLAS_cxml_LIBRARY-NOTFOUND

//Path to a library.
BLAS_dxml_LIBRARY:FILEPATH=BLAS_dxml_LIBRARY-NOTFOUND

//Path to a library.
BLAS_essl_LIBRARY:FILEPATH=BLAS_essl_LIBRARY-NOTFOUND

//Path to a library.
BLAS_f77blas_LIBRARY:FILEPATH=BLAS_f77blas_LIBRARY-NOTFOUND

//Path to a library.
BLAS_goto2_LIBRARY:FILEPATH=BLAS_goto2_LIBRARY-NOTFOUND

//Path to a library.
BLAS_scsl_LIBRARY:FILEPATH=BLAS_scsl_LIBRARY-NOTFOUND

//Path to a library.
BLAS_sgemm_LIBRARY:FILEPATH=BLAS_sgemm_LIBRARY-NOTFOUND

//Path to a library.
BLAS_sunperf_LIBRARY:FILEPATH=BLAS_sunperf_LIBRARY-NOTFOUND


Any help is appreciated.

Thanks,

Lucas Pettey, PhD
HPCMP PETTT EQM CTA Lead
ERDC-DSRC OnSite
Vicksburg, MS
512-297-9833 Mobile (preferred)
601-634-2980 Office
lucas.pet...@engilitycorp.com
-- 

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