-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
56 lines (45 loc) · 1.24 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
cmake_minimum_required(VERSION 3.14)
# ---- In-source guard ----
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not supported")
endif()
# ---- Project -----
project(
magneto
VERSION 0.0.0
DESCRIPTION "A portable & embedded C library for geomagnetic models"
HOMEPAGE_URL "https://github.com/gunvirranu/magneto"
LANGUAGES C
)
option(
magneto_SINGLE_PRECISION_FLOAT
"Use single-precision floating point instead of the default double"
OFF
)
include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)
# ---- Declare library ----
add_library(
magneto
src/magneto.c src/model.c src/wmm.c
)
target_include_directories(
magneto ${warning_guard}
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
)
target_compile_features(magneto PUBLIC c_std_99)
if(magneto_SINGLE_PRECISION_FLOAT)
target_compile_definitions(magneto PUBLIC MAGNETO_SINGLE_PRECISION)
endif()
# ---- Developer mode ----
if(NOT magneto_DEVELOPER_MODE)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
message(AUTHOR_WARNING "Developer mode enabled")
endif()
# Anything below this is purely for developer mode
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()