forked from reaktoro/reaktoro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
100 lines (84 loc) · 4.29 KB
/
install
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#-------------------------------------------------------------
# This script assumes it is executed from CMAKE_SOURCE_DIR.
# In other words, from the root of the main project.
#-------------------------------------------------------------
# Include this file to define a variable JOBS
include(cmake/ParallelJobs.cmake)
# Include this file to output colored text messages
include(cmake/ColoredText.cmake)
# Set the build type to Release by default, if not provided
if(NOT DEFINED BUILD_TYPE)
set(BUILD_TYPE Release)
endif()
# Set the build path variables BUILD_PATH and ABSOLUTE_BUILD_PATH
if(NOT DEFINED BUILD_PATH)
# Set BUILD_PATH to build if not provided,
set(BUILD_PATH build)
# Create the build directory under CMAKE_SOURCE_DIR
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_PATH})
# Define ABSOLUTE_BUILD_PATH variable
set(ABSOLUTE_BUILD_PATH ${CMAKE_SOURCE_DIR}/${BUILD_PATH})
endif()
# Set the install path variables INSTALL_PATH and ABSOLUTE_INSTALL_PATH
if(NOT DEFINED PREFIX)
# Set INSTALL_PATH to BUILD_PATH/install, if not provided via PREFIX
set(INSTALL_PATH install)
# Define ABSOLUTE_INSTALL_PATH variable
set(ABSOLUTE_INSTALL_PATH ${ABSOLUTE_BUILD_PATH}/install)
else()
# Set INSTALL_PATH to the given PREFIX cmake argument
set(INSTALL_PATH ${PREFIX})
# Define ABSOLUTE_INSTALL_PATH variable
set(ABSOLUTE_INSTALL_PATH ${INSTALL_PATH})
endif()
# Check if ninja and make are installed
find_program(NINJA ninja)
find_program(MAKE make)
# The GENERATOR and ARGS variable used for the building process
set(GENERATOR "")
set(ARGS "")
# If ninja installed, use ninja
if(NOT DEFINED GENERATOR AND NINJA)
message(STATUS "Using ninja as the build tool.")
set(GENERATOR "-DCMAKE_GENERATOR='Ninja'")
set(ARGS "-j${JOBS}")
endif()
# If not, use make
if(NOT DEFINED GENERATOR AND MAKE)
message(STATUS "Using make as the build tool.")
set(GENERATOR "-DCMAKE_GENERATOR='Unix Makefiles'")
set(ARGS "-j${JOBS}")
endif()
# Configure the building and installation of the project
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${BUILD_PATH}
${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} ${GENERATOR}
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${INSTALL_PATH})
# Build and install the library
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${BUILD_PATH} --target install -- ${ARGS})
# Print a summary of the installation
message("${BoldCyan}")
message("====================================================================================================")
message("Summary")
message("====================================================================================================${BoldWhite}")
message("The number of parallel jobs used were: ${BoldYellow}${JOBS}${BoldWhite}")
message("The external dependencies were built and installed in:")
message(" ${BoldYellow}${THIRDPARTY_BUILD_PATH}${BoldWhite}")
message("The library was built in:")
message(" ${BoldYellow}${ABSOLUTE_BUILD_PATH}${BoldWhite}")
message("The library was installed in:")
message(" ${BoldYellow}${ABSOLUTE_INSTALL_PATH}${BoldWhite}")
message("${BoldCyan}----------------------------------------------------------------------------------------------------")
message("How do I change the default build and install paths?")
message("----------------------------------------------------------------------------------------------------${BoldWhite}")
message("Change the default build path to an ${BoldBlue}absolute path${BoldWhite} <build-dir> by executing:")
message(" ${BoldYellow}cmake -DBUILD_PATH=<build-dir> -P install${BoldWhite}")
message("Change the default install path to an ${BoldBlue}absolute path${BoldWhite} <install-dir> by executing:")
message(" ${BoldYellow}cmake -DPREFIX=<install-dir> -P install${BoldWhite}")
message("Linux and Mac users might want to install in a system directory, for example:")
message(" ${BoldYellow}cmake -DPREFIX=/usr/local -P install${BoldWhite}")
message("${BoldCyan}----------------------------------------------------------------------------------------------------")
message("*** The above summary assumes a successfull build/installation for all components ***")
message("====================================================================================================")
message("${ColourReset}")