Thanks, it works.

Since the library is found in Find* script, I have to check if it is static.
So I ended up with this:

if("${MMDB_LIBRARY}" MATCHES "\\.a$")
  # it cannot be just "UNKNOWN IMPORTED", because
  # IMPORTED_LINK_INTERFACE_LANGUAGES is respected only for "STATIC IMPORTED"
  add_library(mmdb_cxxlib STATIC IMPORTED)
else()
  add_library(mmdb_cxxlib UNKNOWN IMPORTED)
endif()
set_target_properties(mmdb_cxxlib PROPERTIES
                      IMPORTED_LOCATION ${MMDB_LIBRARY}
                      IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")

...

foreach(p ...)
  set_property(TARGET ${p} PROPERTY LINKER_LANGUAGE Fortran)
endforeach(p)

Two feature requests come to my mind:
- IMHO it would be better if the language of external library didn't
change linker language,
- and a function that tells if the library is static would also be nice

Cheers
Marcin

On 3 September 2013 19:08, Brad King <brad.k...@kitware.com> wrote:
> On 09/03/2013 01:57 PM, Marcin Wojdyr wrote:
>> On 3 September 2013 15:46, Brad King <brad.k...@kitware.com> wrote:
>>> One way to do this is to tell CMake that the library uses C++
>>> using the IMPORTED_LINK_INTERFACE_LANGUAGES property on an
>>
>> That's what I was looking for, but for me instead of adding C++
>> runtime, C++ compiler (icpc) is used for linking.
>> So I have the same problem:
>> undefined reference to `main'
>
> Now set LINKER_LANGUAGE to "Fortran" to tell it that your main
> is there.  I think the LINKER_PREFERENCE infrastructure may be
> outdated.
>
> -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://www.cmake.org/mailman/listinfo/cmake

Reply via email to