Am 18. März 2015 07:23:12 MEZ, schrieb Damian Philipp <damian.phil...@gmx.net>:
>Hello cmake-experts,
>
>I am working on a project that uses a third-party library delivered in
>binary form (TeamSpeak 3 SDK). My project is supposed to build on Win,
>Linux, and OSX, so I decided to use cmake as a build tool. I have
>started work on a Findts3sdk.cmake (find_package() in module mode) to
>let cmake detect the library in the CMAKE_PREFIX_PATH on any of my
>machines - file attached at the end of this mail.
>
>My (current) problem is that a call to find_path() in my
>Findts3sdk.cmake will not pick up the bin directory containing the
>libraries, while another call did work to find the include directory.
>
>WORKS (ts3sdk_INCLUDE_DIR == /path/to/ts3_sdk_3.0.3/include):
>> find_path(ts3sdk_INCLUDE_DIR NAMES clientlib.h HINTS
>${CMAKE_PREFIX_PATH}/include)
>
>BROKEN (ts3sdk_LIBRARY_DIR == ts3sdk_LIBRARY_DIR-NOTFOUND):
>> find_path(ts3sdk_LIBRARY_DIR NAMES libts3client_mac.dylib HINTS
>${CMAKE_PREFIX_PATH}/bin)


CMAKE_PREFIX_PATH is possibly a list so the above does not always work.
IIRC Just use
     PATH_SUFFIXES bin
instead.
And use find_ library() instead.

>I deduce from this that CMAKE_PREFIX_PATH is set correctly. I have
>tried
>the broken command with other names of the library file as well
>(ts3client_mac, libts3client_mac, libts3client_mac.dylib,
>ts3client_mac.dylib).
>
>What do I have to fix to make find_path() pick up the library file?
>
>I am currently on a Mac, using cmake 3.1.3 installed from MacPorts.
>cmake is called with -DCMAKE_PREFIX_PATH="/path/to/ts3_sdk_3.0.3".
>The layout of the library delivery is as follows:
>
>> ts3_sdk_3.0.3
>> ├── bin
>> │   ├── libts3client_linux_amd64.so
>> │   ├── libts3client_linux_x86.so
>> │   ├── libts3client_mac.dylib
>> │   ├── libts3server_freebsd_amd64.so
>> │   ├── libts3server_freebsd_x86.so
>> │   ├── libts3server_linux_amd64.so
>> │   ├── libts3server_linux_x86.so
>> │   ├── libts3server_mac.dylib
>> │   ├── soundbackends
>> │   ├── ts3client_win32.dll
>> │   ├── ts3client_win64.dll
>> │   ├── ts3server_win32.dll
>> │   └── ts3server_win64.dll

Maybe you should start telling the makers of the SDK to fix their directory 
layout as .so and .dylib files do not belong to the bin folder but to the 
library folder. That would also make find_library() work more easily.
And naming the library differently for every case is just...strange.

>> ├── include
>> │   ├── clientlib.h
>> │   ├── clientlib_publicdefinitions.h
>> │   ├── public_definitions.h
>> │   ├── public_errors.h
>> │   ├── serverlib.h
>> │   └── serverlib_publicdefinitions.h
>> └── lib
>>     ├── ts3client_win32.lib
>>     ├── ts3client_win64.lib
>>     ├── ts3server_win32.lib
>>     └── ts3server_win64.lib
>
>My current Findts3sdk.conf looks as follows:
>
>> # Find the INCLULDE and LIBRARY path
>> find_path(ts3sdk_INCLUDE_DIR NAMES clientlib.h HINTS
>${CMAKE_PREFIX_PATH}/include)
>> 
>> if (WIN32)
>>      set(ts3sdk_client_LIBRARIES ts3client_win32 ts3client_amd64)
>>      set(ts3sdk_server_LIBRARIES ts3server_win32 ts3server_amd64)
>> elseif (APPLE)
>>      set(ts3sdk_client_LIBRARIES ts3client_mac)
>>      set(ts3sdk_server_LIBRARIES ts3server_mac)
>> elseif (UNIX)
>>      set(ts3sdk_client_LIBRARIES ts3client_linux_x86
>ts3client_linux_amd64)
>>      set(ts3sdk_server_LIBRARIES ts3server_linux_x86
>ts3server_linux_amd64)
>> endif()
>> 
>> #find_path(ts3sdk_LIBRARY_DIR NAMES ${ts3sdk_client_LIBRARIES} HINTS
>${CMAKE_PREFIX_PATH}/bin)
>> find_path(ts3sdk_LIBRARY_DIR NAMES ts3client_mac.dylib HINTS
>${CMAKE_PREFIX_PATH}/bin)
>> #find_path(ts3sdk_LIBRARY_DIR NAMES ${ts3sdk_client_LIBRARIES}
>${ts3sdk_server_LIBRARIES} HINTS ${CMAKE_PREFIX_PATH}/bin)
>>
>> # Combine into output information
>> set(ts3sdk_INCLUDE_DIRS ${ts3sdk_INCLUDE_DIR})
>> set(ts3sdk_LIBRARY_DIRS ${ts3sdk_LIBRARY_DIR})
>> 
>> message(STATUS "ts3sdk headers found in " ${ts3sdk_INCLUDE_DIRS})
>> message(STATUS "ts3sdk libraries used: " ${ts3sdk_client_LIBRARIES})
>> message(STATUS "ts3sdk libraries found in " ${ts3sdk_LIBRARY_DIR})
>
>Regards,
>Damian Philipp
>-- 
>
>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

-- 

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

Reply via email to