22# --------------------------------------------------------------------------
33# Sanity checks
44
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+ )
615 if (NOT DEFINED ${varname} )
716 message (FATAL_ERROR "Variable ${varname} is not DEFINED" )
817 endif ()
@@ -11,28 +20,68 @@ endforeach()
1120include (${TEST_CMAKE_DIR} /GenerateCLPTestMacros.cmake)
1221
1322# --------------------------------------------------------------------------
14- # Delete install directory if it exists
23+ # Delete build and install directory if they exists
1524execute_process (
25+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_BINARY_DIR}
1626 COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_INSTALL_DIR}
1727 )
1828
1929# --------------------------------------------------------------------------
20- # Create install directory
30+ # Create build and install directories
2131execute_process (
32+ COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
2233 COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_INSTALL_DIR}
2334 )
2435
2536# --------------------------------------------------------------------------
2637# Debug flags - Set to True to display the command as string
2738set (PRINT_COMMAND 0)
2839
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+
2978# --------------------------------------------------------------------------
3079# Install
3180set (install_target install )
3281if (WIN32 )
3382 set (install_target INSTALL )
3483endif ()
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} )
3685execute_process (
3786 COMMAND ${command}
3887 WORKING_DIRECTORY ${TEST_BINARY_DIR}
0 commit comments