|
1 | 1 | include(GNUInstallDirs) |
2 | 2 |
|
3 | | -add_library(unmoving STATIC) |
| 3 | +add_library(unmoving INTERFACE) # use INTERFACE for a header-only library |
4 | 4 | # ALIAS target to export a namespaced target even when building in-tree |
5 | 5 | add_library(Unmoving::unmoving ALIAS unmoving) |
6 | | -# add source files |
7 | | -add_subdirectory(src) |
8 | 6 | # library public header files location |
9 | 7 | target_include_directories( |
10 | | - unmoving PUBLIC |
| 8 | + unmoving INTERFACE |
11 | 9 | # different include directory path depending on if using the local or installed version of library |
12 | 10 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
13 | 11 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
14 | 12 | ) |
15 | | -# pass in version of project as preprocessor definitions |
16 | | -target_compile_definitions( |
17 | | - unmoving PRIVATE |
18 | | - -DUNMOVING_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} |
19 | | - -DUNMOVING_VERSION_MINOR=${PROJECT_VERSION_MINOR} |
20 | | - -DUNMOVING_VERSION_PATCH=${PROJECT_VERSION_PATCH} |
21 | | - -DUNMOVING_VERSION_STRING=${UNMOVING_ESCAPED_VERSION_STRING} |
22 | | -) |
23 | | -# set up version and soversion for the main library object |
24 | | -set_target_properties( |
25 | | - unmoving PROPERTIES |
26 | | - VERSION ${UNMOVING_VERSION_STRING} |
27 | | - SOVERSION ${PROJECT_VERSION_MAJOR} |
28 | | - INTERFACE_unmoving_MAJOR_VERSION ${PROJECT_VERSION_MAJOR} |
29 | | - INTERFACE_unmoving_MINOR_VERSION ${PROJECT_VERSION_MINOR} |
30 | | -) |
| 13 | +# not 100% sure if this is still needed, but it appears in the package-config output so best to keep |
31 | 14 | set_property( |
32 | 15 | TARGET unmoving |
33 | | - APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "${Unmoving_MAJOR_VERSION}.${Unmoving_MINOR_VERSION}" |
34 | | -) |
35 | | -# inherit common project compiler options |
36 | | -target_link_libraries( |
37 | | - unmoving |
38 | | - PRIVATE |
39 | | - $<BUILD_INTERFACE:unmoving-compiler-options> |
| 16 | + APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}" |
40 | 17 | ) |
41 | 18 |
|
42 | 19 | # install if we're not being built as a sub-project |
|
0 commit comments