forked from stillwater-sc/universal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
56 lines (43 loc) · 1.87 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
project (universal)
cmake_minimum_required(VERSION 2.8)
option(UNIVERSAL_CMAKE_TRACE "Tracing CMake results, i.e. printing variable settings." OFF)
option(UNIVERSAL_ENABLE_TESTS "Enable the build and run of tests." ON)
option(UNIVERSAL_VERBOSE_TESTS "Always print test output, otherwise only errors. Only relevant when tests enabled." OFF)
macro(trace_variable variable)
if (UNIVERSAL_CMAKE_TRACE)
message(STATUS "${variable} = ${${variable}}")
endif()
endmacro()
# TODO: Check whether this is needed for old CMake versions
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
trace_variable(CMAKE_MODULE_PATH)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
trace_variable(CMAKE_PREFIX_PATH)
# Must be located in root dir, doesn't work in tests
if (UNIVERSAL_ENABLE_TESTS)
enable_testing()
# include(Dart)
endif()
# Possibly not under Windows
add_compile_options ( -std=c++11 )
macro (compile_all testing prefix)
# cycle through the sources
# For the according directories, we assume that each cpp file is a separate test
# so, create a executable target and an associated test target
foreach (source ${ARGN})
get_filename_component (test ${source} NAME_WE)
string(REPLACE " " ";" new_source ${source})
set(test_name ${prefix}_${test})
# message(STATUS "Add test ${test_name} from source ${new_source}.")
add_executable (${test_name} ${new_source})
if (${testing} STREQUAL "true")
if (UNIVERSAL_CMAKE_TRACE)
message(STATUS "testing: ${test_name} ${RUNTIME_OUTPUT_DIRECTORY}/${test_name}")
endif()
add_test(${test_name} ${RUNTIME_OUTPUT_DIRECTORY}/${test_name})
endif()
endforeach (source)
endmacro (compile_all)
add_subdirectory("unum")
add_subdirectory("unum2")
add_subdirectory("posit")