Using target_link_libraries in CMake with only the library name, for example
target_link_library( myProject SomeLibrary )
will extend SomeLibrary to SomeLibrary.lib, libSomeLibrary.so, etc. depending on the platform. However, if the full path is specified, the library name does not expand based on the platform, for example.
target_link_library( myProject ${myProject_SOURCE_DIR}/libs/SomeLibrary )
How to get the library name for the extension on the platform? I am currently discovering the platform in a script and setting up library names myself that seem a little ugly.
(Background: over on this question I recommend using absolute paths when specifying libraries, and not using link_directories)
source
share