17
17
# limitations under the License.
18
18
#=============================================================================
19
19
20
- cmake_minimum_required (VERSION 2.8)
20
+ cmake_minimum_required (VERSION 2.8.7 )
21
21
project (Midas)
22
22
23
- find_program (PHP "php" CACHE STRING "PHP executable" )
23
+ get_filename_component (REAL_SOURCE_DIR ${CMAKE_SOURCE_DIR} REALPATH)
24
+ get_filename_component (REAL_BINARY_DIR "${CMAKE_BINARY_DIR} " REALPATH)
25
+ if (${REAL_SOURCE_DIR} STREQUAL ${REAL_BINARY_DIR} )
26
+ message (FATAL_ERROR "Binary directory must not be same as the source directory" )
27
+ endif ()
28
+
29
+ find_program (PHP "php" DOC "Path to the PHP executable" )
24
30
if (NOT PHP)
25
31
message (FATAL_ERROR "Please set the path to the PHP executable" )
26
32
endif ()
27
33
28
- find_file (COMPOSER_LOCK "composer.lock" PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
34
+ #-----------------------------------------------------------------------------
35
+ # Download and run composer to install third-party dependencies, if necessary
36
+ #-----------------------------------------------------------------------------
37
+
38
+ find_file (COMPOSER_LOCK "composer.lock" PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH DOC "Path to the composer lock file" )
29
39
if (NOT COMPOSER_LOCK)
30
- find_file (COMPOSER_PHAR "composer.phar" )
40
+ find_file (COMPOSER_PHAR "composer.phar" PATHS ${CMAKE_CURRENT_SOURCE_DIR} DOC "Path to the composer PHP archive" )
31
41
if (NOT COMPOSER_PHAR)
32
- message (FATAL_ERROR "Please set the path to composer.phar" )
42
+ message (STATUS "Downloading composer" )
43
+ file (DOWNLOAD https://getcomposer.org/composer.phar ${CMAKE_CURRENT_SOURCE_DIR} /composer.phar STATUS DOWNLOAD_COMPOSER_PHAR_STATUS)
44
+ list (GET DOWNLOAD_COMPOSER_PHAR_STATUS 0 DOWNLOAD_COMPOSER_PHAR_RESULT)
45
+ list (GET DOWNLOAD_COMPOSER_PHAR_STATUS 1 DOWNLOAD_COMPOSER_PHAR_ERROR)
46
+ if (NOT DOWNLOAD_COMPOSER_PHAR_RESULT EQUAL 0)
47
+ message (FATAL_ERROR "Error downloading composer: ${DOWNLOAD_COMPOSER_PHAR_ERROR} " )
48
+ endif ()
49
+ message (STATUS "Downloading composer - done" )
50
+ set (COMPOSER_PHAR ${CMAKE_CURRENT_SOURCE_DIR} /composer.phar CACHE FILEPATH "Path to the composer PHP archive" )
33
51
endif ()
52
+ message (STATUS "Executing composer install" )
34
53
execute_process (
35
54
COMMAND ${PHP} ${COMPOSER_PHAR} install
55
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
36
56
RESULT_VARIABLE COMPOSER_INSTALL_RESULT
37
57
OUTPUT_VARIABLE COMPOSER_INSTALL_OUTPUT
38
58
ERROR_VARIABLE COMPOSER_INSTALL_ERROR)
39
59
if (NOT COMPOSER_INSTALL_RESULT EQUAL 0)
40
60
message (STATUS "Composer install output: ${COMPOSER_INSTALL_OUTPUT} " )
41
61
message (FATAL_ERROR "Composer install error: ${COMPOSER_INSTALL_ERROR} " )
42
62
endif ()
43
- message (STATUS "Composer install is complete " )
63
+ message (STATUS "Executing composer install - done " )
44
64
endif ()
45
65
46
66
#-----------------------------------------------------------------------------
47
67
# Drop all tables from the testing database, then reinstall the database, set
48
68
# a default asset store, and install all modules
49
69
#-----------------------------------------------------------------------------
50
70
51
- message (STATUS "Setting up database(s) for testing, please wait... " )
71
+ message (STATUS "Setting up database(s) for testing" )
52
72
execute_process (
53
73
COMMAND ${PHP} ${CMAKE_CURRENT_SOURCE_DIR} /tests/DatabaseSetup.php
54
74
RESULT_VARIABLE DATABASE_SETUP_RESULT
@@ -58,15 +78,14 @@ if(NOT DATABASE_SETUP_RESULT EQUAL 0)
58
78
message (STATUS "Database setup output: ${DATABASE_SETUP_OUTPUT} " )
59
79
message (FATAL_ERROR "Database setup error: ${DATABASE_SETUP_ERROR} " )
60
80
endif ()
61
- message (STATUS "Database setup is complete " )
81
+ message (STATUS "Setting up database(s) for testing - done " )
62
82
63
83
#-----------------------------------------------------------------------------
64
84
# Setup testing and required parameters for testing
65
85
#-----------------------------------------------------------------------------
66
86
67
87
include (CTest)
68
88
option (MIDAS_RUN_STYLE_TESTS "Run PHP style tests?" ON )
69
- set (SERVER_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR} )
70
89
71
90
add_subdirectory (tests)
72
91
add_subdirectory (core/tests)
0 commit comments