-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
66 lines (58 loc) · 2.22 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
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(asciiTeX C)
set(CMAKE_C_STANDARD 11)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug
CACHE STRING "Set build type (default Debug)" FORCE)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -pedantic -Werror) # -Weverything
string(APPEND CMAKE_C_FLAGS_DEBUG " -fno-omit-frame-pointer -fsanitize=address")
string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -fsanitize=address")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.5)
string(APPEND CMAKE_C_FLAGS_DEBUG ",undefined")
string(APPEND CMAKE_LINKER_FLAGS_DEBUG ",undefined")
endif()
endif()
endif()
add_executable(asciitex
src/array.c
src/asciiTeX.c
src/brace.c
src/binom.c
src/dim.c
src/draw.c
src/frac.c
src/limit.c
src/main.c
src/ouline.c
src/sqrt.c
src/sscript.c
src/symbols.c
src/text.c
src/utils.c
)
file(GLOB test_inputs "examples/*.tex")
install(TARGETS asciitex RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
install(FILES ${test_inputs} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/doc/asciitex")
install(FILES man/asciitex.1 DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1")
if(NOT DISABLE_TESTING)
enable_testing()
foreach(test_input ${test_inputs})
file(RELATIVE_PATH test_file ${CMAKE_CURRENT_SOURCE_DIR}/examples ${test_input})
string(REPLACE ".tex" "" test ${test_file})
string(REPLACE ".tex" ".txt" expected_result ${test_input})
add_custom_command(TARGET asciitex
POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND $<TARGET_FILE:asciitex> -f ${test_input} > ${test}.txt
)
add_test(NAME ${test}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E compare_files ${expected_result} ${test}.txt
)
endforeach()
endif()