On 12.03.2014 09:58, Lloyd wrote:
My cross platform project has a main module and a custom library. The main module depends on the custom library. Both these projects need to be built with cmake. At present the option I find to set this is to using the "target_link_library(MyExe ${CMAKE_CURRENT_BINARY_DIR}/myLib.lib)". But this code makes my cmake file platform dependent, that is on windows I need to use the "MyLib.lib" in CMake and on Linux I need to use "MyLib.a" ! Is there a better alternative? (I went through the doc of find_library(), but it doesn't seem to be suitable in this scenatio)

Assuming your library is being build by the project and not manually being copied into the binary directory you can use the target name instead of the filename of the library.

If you created the target with add_library(mylibrary ...)
target_link_library(MyExe mylibrary) should work.

CMake will fill in the actual full path to the library.

Nils
--

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