git repos / PlatformFolders

commit 5b487573

sum01 · 2019-03-06 19:14
5b48757364ae75d879de7808256b40af5ab103d9 patch · browse files
parent f0488f271be4ea5a214dd27dd45989c345080055

Add a library alias for linkage when built in-tree

This lets the end-user link against the same sago::platform_folders as if they had used find_package..
Even when they build the code in-tree, versus using find_package, which actually imports the lib.

Changed files

M CMakeLists.txt before
M README.md before
diff --git a/CMakeLists.txt b/CMakeLists.txt index d82991e..61dcfed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -9,6 +9,10 @@ add_library(platform_folders
sago/platform_folders.cpp
)
+# Creates an alias so that people building in-tree (instead of using find_package)...
+# can still link against the same target
+add_library(sago::platform_folders ALIAS platform_folders)
+
# Defines standardized defaults for install paths
include(GNUInstallDirs)
# Where to search for the header while building
diff --git a/README.md b/README.md index 3185a8c..8488b9a 100644 --- a/README.md +++ b/README.md
@@ -55,6 +55,8 @@ target_link_libraries(EXEORLIBNAME PRIVATE sago::platform_folders)
Alternatively, you can just copy the [sago](https://github.com/sago007/PlatformFolders/tree/master/sago) folder into your program and manually link everything.
If you use the last option and are using a library version from before 4.0.0: Remember to link to the CoreServices lib when compiling on Mac. This typically means passing "-framework CoreServices" during the linking phase.
+Note that if you build in-tree, you can link against the Cmake alias `sago::platform_folders` just like if you had used find_package.
+
### Building
**Notes:**