CMakeLists.txt
2.23 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
# Build the examples...
# Loop over all the examples, specifying the source and library.
add_custom_target (examples ALL)
add_definitions (${PROJECT_DEFINITIONS})
foreach (EXAMPLE ${EXAMPLES})
add_executable (${EXAMPLE} ${EXAMPLE}.cpp)
add_dependencies (examples ${EXAMPLE})
target_link_libraries (${EXAMPLE} ${PROJECT_LIBRARIES})
endforeach ()
if (MSVC OR CMAKE_CONFIGURATION_TYPES)
# Add _d suffix for your debug versions of the tools
set_target_properties (${EXAMPLES} PROPERTIES
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
endif ()
# RandomSave uses boost serialization if it's available
if (Boost_FOUND AND Boost_SERIALIZATION_FOUND)
include_directories (${Boost_INCLUDE_DIRS})
set_target_properties (RandomSave PROPERTIES
COMPILE_DEFINITIONS HAVE_BOOST_SERIALIZATION=1)
target_link_libraries (RandomSave ${Boost_LIBRARIES})
endif ()
# RandomThread uses OpenMP if it's available
if (OPENMP_FOUND)
set_target_properties (RandomThread PROPERTIES
COMPILE_FLAGS ${OpenMP_CXX_FLAGS} COMPILE_DEFINITIONS HAVE_OPENMP=1)
if (NOT MSVC)
set_target_properties (RandomThread
PROPERTIES LINK_FLAGS ${OpenMP_CXX_FLAGS})
endif ()
endif ()
if (HAVE_MPFR)
add_executable (MPFRExample MPFRExample.cpp)
add_dependencies (examples MPFRExample)
target_link_libraries (MPFRExample ${MPFR_LIBRARIES} ${GMP_LIBRARIES})
endif ()
if (MSVC)
get_target_property (_LIBTYPE ${PROJECT_LIBRARIES} TYPE)
if (_LIBTYPE STREQUAL "SHARED_LIBRARY")
# Copy the shared library on Windows systems to this directory
# (examples) so that the tests can be run.
add_custom_command (TARGET examples POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy $<TARGET_FILE:${PROJECT_LIBRARIES}> ${CMAKE_CFG_INTDIR}
COMMENT "Copying shared library to examples directory")
endif ()
endif ()
if (MSVC)
# Only install RandomExample and only on Windows systems
install (TARGETS RandomExample DESTINATION bin)
endif ()
# Put all the tools into a folder in the IDE
set_property (TARGET examples ${EXAMPLES} PROPERTY FOLDER examples)
# Turn on testing
enable_testing ()
# Here are the tests.
add_test (NAME RandomExample0 COMMAND RandomExample)
add_test (NAME RandomSave0 COMMAND RandomSave)
add_test (NAME RandomCoverage0 COMMAND RandomCoverage)