-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
47 lines (38 loc) · 1.45 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
cmake_minimum_required (VERSION 3.10)
project (Bint
VERSION "0.1.0"
DESCRIPTION "Bint is an arbitrary-precision arithmetic library."
LANGUAGES CXX
)
enable_testing()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
if(MSVC)
#add_compile_options(/Wall)
else()
add_compile_options(-Wall -Wextra -pedantic)
endif()
# sources
include_directories(include)
aux_source_directory(src/Bint BINT_SRC)
aux_source_directory(src/Brat BRAT_SRC)
set(BINT_SRC ${BINT_SRC} ${BRAT_SRC} src/Bint.cpp src/Brat.cpp)
set(MATH_SRC src/Math.cpp)
add_library(shareobjects OBJECT ${BINT_SRC} ${MATH_SRC})
# libraries
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
add_library(BeeNum SHARED ${BINT_SRC} ${MATH_SRC})
add_library(BeeNum_static STATIC $<TARGET_OBJECTS:shareobjects>)
set_target_properties(BeeNum_static PROPERTIES OUTPUT_NAME BeeNum)
# tests
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
add_executable(test-main-fast tests/main.cpp ${BINT_SRC} ${MATH_SRC})
set_target_properties(test-main-fast PROPERTIES COMPILE_FLAGS -Ofast)
add_test(NAME tst-main-fast COMMAND ./tests/test-main-fast)
aux_source_directory(tests TESTS)
foreach(tstfile ${TESTS})
string(REGEX MATCH "\/(.*)\\.[^.]*$" dummy ${tstfile})
add_executable(test-${CMAKE_MATCH_1} ${tstfile} $<TARGET_OBJECTS:shareobjects>)
add_test(NAME tst-${CMAKE_MATCH_1} COMMAND ./tests/test-${CMAKE_MATCH_1})
endforeach()