Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit fbc2347

Browse files
author
Jamie Snape
committed
Improve CMakeLists.txt to allow installation of composer and dependencies
1 parent b41c50b commit fbc2347

13 files changed

+36
-155
lines changed

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
.buildpath
21
.DS_Store
32
.idea/
4-
.project
53
.sass-cache/
6-
.settings/
74
.vagrant/
8-
.zfproject.xml
95
bower_components/
10-
nbproject/
6+
composer.lock
7+
composer.phar
8+
cron.yaml
119
node_modules/
1210
vendor/

CMakeLists.txt

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,58 @@
1717
# limitations under the License.
1818
#=============================================================================
1919

20-
cmake_minimum_required(VERSION 2.8)
20+
cmake_minimum_required(VERSION 2.8.7)
2121
project(Midas)
2222

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")
2430
if(NOT PHP)
2531
message(FATAL_ERROR "Please set the path to the PHP executable")
2632
endif()
2733

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")
2939
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")
3141
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")
3351
endif()
52+
message(STATUS "Executing composer install")
3453
execute_process(
3554
COMMAND ${PHP} ${COMPOSER_PHAR} install
55+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
3656
RESULT_VARIABLE COMPOSER_INSTALL_RESULT
3757
OUTPUT_VARIABLE COMPOSER_INSTALL_OUTPUT
3858
ERROR_VARIABLE COMPOSER_INSTALL_ERROR)
3959
if(NOT COMPOSER_INSTALL_RESULT EQUAL 0)
4060
message(STATUS "Composer install output: ${COMPOSER_INSTALL_OUTPUT}")
4161
message(FATAL_ERROR "Composer install error: ${COMPOSER_INSTALL_ERROR}")
4262
endif()
43-
message(STATUS "Composer install is complete")
63+
message(STATUS "Executing composer install - done")
4464
endif()
4565

4666
#-----------------------------------------------------------------------------
4767
# Drop all tables from the testing database, then reinstall the database, set
4868
# a default asset store, and install all modules
4969
#-----------------------------------------------------------------------------
5070

51-
message(STATUS "Setting up database(s) for testing, please wait...")
71+
message(STATUS "Setting up database(s) for testing")
5272
execute_process(
5373
COMMAND ${PHP} ${CMAKE_CURRENT_SOURCE_DIR}/tests/DatabaseSetup.php
5474
RESULT_VARIABLE DATABASE_SETUP_RESULT
@@ -58,15 +78,14 @@ if(NOT DATABASE_SETUP_RESULT EQUAL 0)
5878
message(STATUS "Database setup output: ${DATABASE_SETUP_OUTPUT}")
5979
message(FATAL_ERROR "Database setup error: ${DATABASE_SETUP_ERROR}")
6080
endif()
61-
message(STATUS "Database setup is complete")
81+
message(STATUS "Setting up database(s) for testing - done")
6282

6383
#-----------------------------------------------------------------------------
6484
# Setup testing and required parameters for testing
6585
#-----------------------------------------------------------------------------
6686

6787
include(CTest)
6888
option(MIDAS_RUN_STYLE_TESTS "Run PHP style tests?" ON)
69-
set(SERVER_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
7089

7190
add_subdirectory(tests)
7291
add_subdirectory(core/tests)

app.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ env_variables:
4747

4848
skip_files:
4949
- ^(.*/)?.*/(\.DS_Store|\.htaccess|\.gitignore|CMakeLists\.txt|.*\.java)$
50-
- ^(.*/)?(\.coveralls.yml|\.project|\.travis.yml|\.zfproject\.xml|composer\.json|COPYRIGHT|CTestConfig\.cmake|LICENSE|README\.md|Vagrantfile)$
50+
- ^(.*/)?(\.coveralls.yml|\.travis.yml|composer\.json|composer\.lock|COPYRIGHT|CTestConfig\.cmake|cron-sample\.yaml|LICENSE|README\.md|Vagrantfile)$
5151
- ^(.*/)?core/configs/.*\.local\.ini$
52-
- ^(.*/)?(\.git|\.idea|\.vagrant|data|log|nbproject|provisioning|tests|tmp|utils)/.*
52+
- ^(.*/)?(\.git|\.idea|\.vagrant|data|log|provisioning|tests|tmp|utils)/.*
5353
- ^(.*/)?(core|modules/.*)/(database/pgsql|sqlite|tests)/.*
5454
- ^(.*/)?library/CMake/.*
55-
- ^(.*/)?modules/(batchmake|dicom.*|example|metadataextractor|pvw|remoteprocessing|solr|statistics|thumbnailcreator|visualize)/.*
55+
- ^(.*/)?modules/(batchmake|dicom.*|example|metadataextractor|pvw|remoteprocessing|solr|thumbnailcreator|visualize)/.*

composer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
"/core/configs/*.local.*",
5454
"/data/*/**",
5555
"/log/**",
56-
"/tests/TestsConfig.php",
57-
"!/tests/TestsConfig.php.in",
5856
"/tmp/*/**"
5957
]
6058
}

tests/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
# limitations under the License.
1818
#=============================================================================
1919

20-
configure_file(${CMAKE_SOURCE_DIR}/tests/TestsConfig.php.in ${CMAKE_SOURCE_DIR}/tests/TestsConfig.php)
21-
2220
macro(to_titlecase Arg Result)
2321
string(SUBSTRING ${Arg} 0 1 ArgHead)
2422
string(TOUPPER ${ArgHead} ArgHead)

tests/ControllerTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
=========================================================================*/
2020

2121
require_once dirname(__FILE__).'/TestsBootstrap.php';
22-
require_once dirname(__FILE__).'/TestsConfig.php';
2322
require_once BASE_PATH.'/core/controllers/components/UtilityComponent.php';
2423

2524
/** main controller test element */

tests/DatabaseTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
=========================================================================*/
2020

2121
require_once dirname(__FILE__).'/TestsBootstrap.php';
22-
require_once dirname(__FILE__).'/TestsConfig.php';
2322
require_once BASE_PATH.'/core/controllers/components/UtilityComponent.php';
2423

2524
/** main models test element */

tests/TestsConfig.php.in

Lines changed: 0 additions & 21 deletions
This file was deleted.

utils/NewModule.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
# limitations under the License.
1818
#=============================================================================
1919

20-
# This CMake script should be used to create a new Midas module. Requires CMake v2.8.3+
20+
# This CMake script should be used to create a new Midas module.
2121
# Call as
2222
# cmake -P NewModule.cmake modulename
2323
# Where modulename is the name of your module. It should have no spaces in it.
2424
#
25+
cmake_minimum_required(VERSION 2.8.7)
2526
if(NOT DEFINED CMAKE_ARGV3)
2627
message(FATAL_ERROR "Must pass in module name as an argument: cmake -P NewModule.cmake mymodule")
2728
endif()

0 commit comments

Comments
 (0)