-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
79 lines (78 loc) · 1.86 KB
/
CMakeLists.txt
File metadata and controls
79 lines (78 loc) · 1.86 KB
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
73
74
75
76
77
78
79
cmake_minimum_required(VERSION 3.14)
# Project information
project(Units
VERSION 5.0.0
DESCRIPTION "Constants and unit conversions."
LANGUAGES CXX
)
# Add the library target
add_library(units
src/units.h
src/constants.h
src/convacc.h
src/convang.h
src/convangacc.h
src/convangvel.h
src/convdensity.h
src/convforce.h
src/convlength.h
src/convmass.h
src/convpres.h
src/convtemp.h
src/convvel.h
src/convacc.cpp
src/convang.cpp
src/convangacc.cpp
src/convangvel.cpp
src/convdensity.cpp
src/convforce.cpp
src/convlength.cpp
src/convmass.cpp
src/convpres.cpp
src/convtemp.cpp
src/convvel.cpp
)
# Setup include directories
target_include_directories(units INTERFACE src/)
# Example and unit testing if this project is built separately
if (PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
# Add the example target
add_executable(units_example examples/cmake/units_example.cc)
# Add the includes
target_include_directories(units_example PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Link libraries to the test target
target_link_libraries(units_example
PRIVATE
units
)
# Fetch google test
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)
enable_testing()
include(GoogleTest)
# Add the test target
add_executable(units_test tests/units_test.cc)
# Add the includes
target_include_directories(units_test PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Link libraries to the test target
target_link_libraries(units_test
PRIVATE
units
gtest_main
gtest
gmock
)
# Discover unit tests
gtest_discover_tests(units_test)
endif()