2
2
# --------------------------------------------------------------------------
3
3
# Sanity checks
4
4
5
- foreach (varname TEST_CMAKE_DIR TEST_BINARY_DIR TEST_INSTALL_DIR)
5
+ foreach (varname
6
+ CMAKE_BUILD_TYPE
7
+ CMAKE_GENERATOR
8
+ ModuleDescriptionParser_DIR
9
+ TCLAP_DIR
10
+ TEST_CMAKE_DIR
11
+ TEST_SOURCE_DIR
12
+ TEST_BINARY_DIR
13
+ TEST_INSTALL_DIR
14
+ )
6
15
if (NOT DEFINED ${varname} )
7
16
message (FATAL_ERROR "Variable ${varname} is not DEFINED" )
8
17
endif ()
@@ -11,28 +20,68 @@ endforeach()
11
20
include (${TEST_CMAKE_DIR} /GenerateCLPTestMacros.cmake)
12
21
13
22
# --------------------------------------------------------------------------
14
- # Delete install directory if it exists
23
+ # Delete build and install directory if they exists
15
24
execute_process (
25
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_BINARY_DIR}
16
26
COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_INSTALL_DIR}
17
27
)
18
28
19
29
# --------------------------------------------------------------------------
20
- # Create install directory
30
+ # Create build and install directories
21
31
execute_process (
32
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
22
33
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
23
34
)
24
35
25
36
# --------------------------------------------------------------------------
26
37
# Debug flags - Set to True to display the command as string
27
38
set (PRINT_COMMAND 0)
28
39
40
+ # --------------------------------------------------------------------------
41
+ # Configure
42
+ set (command ${CMAKE_COMMAND}
43
+ -DCMAKE_BUILD_TYPE:STRING =${CMAKE_BUILD_TYPE}
44
+ -DCMAKE_INSTALL_PREFIX:PATH =${TEST_INSTALL_DIR}
45
+ -DModuleDescriptionParser_DIR:PATH =${ModuleDescriptionParser_DIR}
46
+ -DTCLAP_DIR:PATH =${TCLAP_DIR}
47
+ -G ${CMAKE_GENERATOR} ${TEST_SOURCE_DIR} )
48
+ execute_process (
49
+ COMMAND ${command}
50
+ WORKING_DIRECTORY ${TEST_BINARY_DIR}
51
+ OUTPUT_VARIABLE ov
52
+ RESULT_VARIABLE rv
53
+ )
54
+
55
+ print_command_as_string("${command} " )
56
+
57
+ if (rv)
58
+ message (FATAL_ERROR "Failed to configure Test:\n ${ov} " )
59
+ endif ()
60
+
61
+ # --------------------------------------------------------------------------
62
+ # Build
63
+
64
+ set (command ${CMAKE_COMMAND} --build ${TEST_BINARY_DIR} --config ${CMAKE_BUILD_TYPE} )
65
+ execute_process (
66
+ COMMAND ${command}
67
+ WORKING_DIRECTORY ${TEST_BINARY_DIR}
68
+ OUTPUT_VARIABLE ov
69
+ RESULT_VARIABLE rv
70
+ )
71
+
72
+ print_command_as_string("${command} " )
73
+
74
+ if (rv)
75
+ message (FATAL_ERROR "Failed to build Test:\n ${ov} " )
76
+ endif ()
77
+
29
78
# --------------------------------------------------------------------------
30
79
# Install
31
80
set (install_target install )
32
81
if (WIN32 )
33
82
set (install_target INSTALL )
34
83
endif ()
35
- set (command ${CMAKE_COMMAND} --build ${TEST_BINARY_DIR} --config Release --target ${install_target} )
84
+ set (command ${CMAKE_COMMAND} --build ${TEST_BINARY_DIR} --config ${CMAKE_BUILD_TYPE} --target ${install_target} )
36
85
execute_process (
37
86
COMMAND ${command}
38
87
WORKING_DIRECTORY ${TEST_BINARY_DIR}
0 commit comments