On 18.08.2015 20:29, Ette, Anthony (CDS) wrote:

Given that add_library() produces a unique filename per platform (the “actual file name of the library built is constructed based on conventions of the native platform (such as lib<name>.aor<name>.lib”), how does one add the library to the final application without having to deal with the filename difference? In other words, I’ve got one library that, by default, produces ‘libtest.a’ on Linux and ‘test.lib’ on Windows. How can I add this imported library into the final application in a cross platform manner? I know I can specify two different imported locations (see below), but it seems odd to me that Cmake – the cross-platform build env generator – doesn’t have a better native way of dealing with this….



Assuming the project producing the libraries and the project consuming them are distinct you could export targets from your library project with install(EXPORT) and import them in the other project with find_package().

Creation of package configuration files (using target exports) is explained here:
http://www.cmake.org/cmake/help/v3.3/manual/cmake-packages.7.html#creating-packages

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://public.kitware.com/mailman/listinfo/cmake

Reply via email to