-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
61 lines (52 loc) · 1.66 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
cmake_minimum_required(VERSION 3.10)
project(uc VERSION 1.7.1)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED True)
add_compile_options(-Wall -Wextra -Wpedantic)
# Download and configure Unity
include(FetchContent)
FetchContent_Declare(
unity
GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
GIT_TAG v2.5.2
)
FetchContent_MakeAvailable(unity)
# Enable double precision in Unity
target_compile_definitions(unity PUBLIC
UNITY_INCLUDE_DOUBLE
UNITY_DOUBLE_PRECISION=1e-12
)
find_library(READLINE_LIBRARY readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
if(READLINE_LIBRARY AND READLINE_INCLUDE_DIR)
message(STATUS "Readline library found: ${READLINE_LIBRARY}")
message(STATUS "Readline include directory found: ${READLINE_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Readline library not found!")
endif()
# Main executable
add_executable(uc uc.c conv_str_to_math_res.c handle_arguments.c exponent_mode.c)
target_link_libraries(uc m)
target_link_libraries(uc ${READLINE_LIBRARY})
target_include_directories(uc PRIVATE ${READLINE_INCLUDE_DIR})
target_compile_definitions(uc PUBLIC UC_VERSION="${PROJECT_VERSION}")
# Test executable
add_executable(test_uc
tests/test_uc.c
conv_str_to_math_res.c
exponent_mode.c
)
target_link_libraries(test_uc PRIVATE unity m)
target_include_directories(test_uc PRIVATE
${unity_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(test_uc PRIVATE
UNITY_INCLUDE_DOUBLE
UNITY_DOUBLE_PRECISION=1e-12
)
# Installation rules
include(GNUInstallDirs)
install(TARGETS uc DESTINATION ${CMAKE_INSTALL_BINDIR})
enable_testing()
add_test(NAME UnitTests COMMAND test_uc)