Skip to content

Commit b891f3e

Browse files
committed
docs: add CMake integration examples
NOTE: none of these have been tested, they seem sane enough
1 parent bdff20d commit b891f3e

1 file changed

Lines changed: 88 additions & 4 deletions

File tree

README.md

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,92 @@
1-
SGP4 library
2-
============
1+
# SGP4 library
2+
## CMake support
3+
### External
4+
```cmake
5+
# ./CMakeLists.txt
36
4-
License
5-
-------
7+
find_package(SGP4 1.1 CONFIG REQUIRED)
8+
# ...
9+
add_library(foo ...)
10+
# ...
11+
target_link_libraries(foo PRIVATE libsgp4::sgp4)
12+
# target_link_libraries(foo PRIVATE libsgp4::sgp4-static) # or static
13+
```
14+
15+
### Embedded
16+
```cmake
17+
# ./CMakeLists.txt
18+
19+
# this affects if the libsgp4::sgp4 target is shared or static
20+
set(BUILD_SHARED_LIBS ON)
21+
# this affects if the libsgp4::sgp4-static target is available
22+
set(SGP4_BUILD_STATIC_LIB ON)
23+
24+
add_subdirectory(thirdparty/sgp4)
25+
# ...
26+
add_library(foo ...)
27+
# ...
28+
target_link_libraries(foo PRIVATE libsgp4::sgp4)
29+
# target_link_libraries(foo PRIVATE libsgp4::sgp4-static) # or static
30+
```
31+
32+
### Embedded (FetchContent)
33+
```cmake
34+
# ./CMakeLists.txt
35+
36+
include(FetchContent)
37+
38+
# this affects if the libsgp4::sgp4 target is shared or static
39+
set(BUILD_SHARED_LIBS ON)
40+
# this affects if the libsgp4::sgp4-static target is available
41+
set(SGP4_BUILD_STATIC_LIB ON)
42+
43+
FetchContent_Declare(sgp4
44+
GIT_REPOSITORY https://github.com/dnwrnr/sgp4
45+
# TODO: update this with an actual commit
46+
GIT_TAG bdff20d3eb6f010af95574990a662f8089db93f8 # https://github.com/dnwrnr/sgp4/tree/bdff20d3eb6f010af95574990a662f8089db93f8
47+
)
48+
FetchContent_MakeAvailable(sgp4)
49+
# ...
50+
add_library(foo ...)
51+
# ...
52+
target_link_libraries(foo PRIVATE libsgp4::sgp4)
53+
# target_link_libraries(foo PRIVATE libsgp4::sgp4-static) # or static
54+
```
55+
56+
### External with embedded fallback
57+
```cmake
58+
# ./CMakeLists.txt
59+
60+
# this affects if the libsgp4::sgp4 fallback target is shared or static
61+
set(BUILD_SHARED_LIBS ON)
62+
# this affects if the libsgp4::sgp4-static fallback target is available
63+
set(SGP4_BUILD_STATIC_LIB ON)
64+
65+
# use include instead of add_subdirectory, otherwise targets won't get propagated
66+
include(thirdparty/CMakeLists.txt)
67+
add_subdirectory(src)
68+
```
69+
70+
```cmake
71+
# ./src/CMakeLists.txt
72+
73+
add_library(foo ...)
74+
# ...
75+
target_link_libraries(foo PRIVATE libsgp4::sgp4)
76+
# target_link_libraries(foo PRIVATE libsgp4::sgp4-static) # or static
77+
```
78+
79+
```cmake
80+
# ./thirdparty/CMakeLists.txt
81+
82+
find_package(SGP4 1.1 CONFIG)
83+
if(NOT SGP4_FOUND)
84+
message(STATUS "Using SGP4 submodule")
85+
add_subdirectory("${CMAKE_SOURCE_DIR}/thirdparty/sgp4")
86+
endif()
87+
```
88+
89+
## License
690

791
Copyright 2017 Daniel Warner
892

0 commit comments

Comments
 (0)