-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
72 lines (72 loc) · 1.67 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# v3.14 required for FetchContent_MakeAvailable
cmake_minimum_required(VERSION 3.14)
# Project information
project(Wmm
VERSION 1.1.0
DESCRIPTION "World Magnetic Model"
LANGUAGES CXX
)
include(FetchContent)
if (DEFINED DEPS)
string(TOUPPER ${DEPS} DEPS)
if (DEPS STREQUAL "BFS")
# Fetch global defs
FetchContent_Declare(
units
GIT_REPOSITORY [email protected]:bolderflight/software/units.git
GIT_TAG v5.0.0
)
elseif(DEPS STREQUAL "LOCAL")
# Fetch global defs
FetchContent_Declare(
units
GIT_REPOSITORY ${CMAKE_SOURCE_DIR}/../units
GIT_TAG v5.0.0
)
else()
# Fetch global defs
FetchContent_Declare(
units
GIT_REPOSITORY https://github.com/bolderflight/units.git
GIT_TAG v5.0.0
)
endif()
else()
# Fetch global defs
FetchContent_Declare(
units
GIT_REPOSITORY https://github.com/bolderflight/units.git
GIT_TAG v5.0.0
)
endif()
FetchContent_MakeAvailable(units)
# Add the library target
add_library(wmm
src/wmm.h
src/wmm.cpp
src/XYZgeomag.h
)
target_link_libraries(wmm
PUBLIC
units
)
# Setup include directories
target_include_directories(wmm PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
# Example and test if this project is built separately
if (PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
# Add the example target
add_executable(wmm_example examples/cmake/wmm_ex.cc)
# Add the includes
target_include_directories(wmm_example PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Link libraries to the example target
target_link_libraries(wmm_example
PRIVATE
wmm
)
endif()