Fixed library building for windows
This commit is contained in:
+56
-11
@@ -109,6 +109,10 @@ contains_element () {
|
||||
return 1
|
||||
}
|
||||
|
||||
#Set env variable 'make_targets' as array to specify specific targets
|
||||
#Possible actions:
|
||||
# - _run_before_build="command"
|
||||
# - _run_before_install="command"
|
||||
function cmake_build() {
|
||||
if [[ -z "${build_os_type}" ]]; then
|
||||
echo "Could not build cmake file because build os type has not been specified!"
|
||||
@@ -183,7 +187,9 @@ function cmake_build() {
|
||||
#Cut of the start space
|
||||
[[ ! -z ${definition_string} ]] && definition_string=${definition_string:1}
|
||||
|
||||
local cmake_command="cmake $base_path$base_path_suffix ${final_parms[*]} ${definition_string} ${CMAKE_OPTIONS}"
|
||||
local _cmake_generator=""
|
||||
[[ "${build_os_type}" == "win32" ]] && _cmake_generator=" -G\"Visual Studio 14 2015 Win64\""
|
||||
local cmake_command="cmake $base_path$base_path_suffix ${_cmake_generator} ${final_parms[*]} ${definition_string} ${CMAKE_OPTIONS}"
|
||||
|
||||
local origin_directory=$(pwd)
|
||||
cd ${build_path}
|
||||
@@ -197,27 +203,66 @@ function cmake_build() {
|
||||
|
||||
echo "Executing cmake command:"
|
||||
echo "> $cmake_command"
|
||||
eval "${cmake_command}"
|
||||
eval ${cmake_command}
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to generate build file with cmake! Status code: $?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local make_command="make ${CMAKE_MAKE_OPTIONS}"
|
||||
echo "Executing make command:"
|
||||
echo "> $make_command"
|
||||
eval "${make_command}"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to build project with make! Status code: $?"
|
||||
local make_command=""
|
||||
local make_command_target=""
|
||||
local make_install_command=""
|
||||
if [[ "${build_os_type}" == "linux" ]]; then
|
||||
make_command="make ${CMAKE_MAKE_OPTIONS}"
|
||||
make_command_target="make ${CMAKE_MAKE_OPTIONS} %target%"
|
||||
make_install_command="make install"
|
||||
elif [[ "${build_os_type}" == "win32" ]]; then
|
||||
_config=""
|
||||
[[ ! -z "${final_definitions["CMAKE_BUILD_TYPE"]}" ]] && _config="--config ${final_definitions["CMAKE_BUILD_TYPE"]}"
|
||||
|
||||
make_command="cmake --build . -j8 ${_config}"
|
||||
make_command_target="cmake --build . --target %target% -j8 ${_config}"
|
||||
make_install_command="cmake --build . ${_config} --target install -j8"
|
||||
else
|
||||
echo "OS type unknown"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local make_install_command="make install"
|
||||
echo "Executing make install command:"
|
||||
[[ ! -z "${_run_before_build}" ]] && {
|
||||
eval "${_run_before_build}"
|
||||
check_err_exit $1 "Failed to execute prebuild command"
|
||||
}
|
||||
|
||||
if [[ ! -z "${make_targets}" ]]; then
|
||||
for target in ${make_targets[@]}; do
|
||||
make_command=$(echo "${make_command_target}" | sed "s:%target%:$target:g")
|
||||
echo "Executing build command for target ${target}:"
|
||||
echo "> $make_command"
|
||||
eval "${make_command}"
|
||||
if [[ $? -ne 0 && "$?" != "0" ]]; then
|
||||
echo "Failed to build project! Status code: $?"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Executing build command:"
|
||||
echo "> $make_command"
|
||||
eval "${make_command}"
|
||||
if [[ $? -ne 0 && "$?" != "0" ]]; then
|
||||
echo "Failed to build project! Status code: $?"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
[[ ! -z "${_run_before_install}" ]] && {
|
||||
eval "${_run_before_install}"
|
||||
check_err_exit $1 "Failed to execute preinstall command"
|
||||
}
|
||||
|
||||
echo "Executing install command:"
|
||||
echo "> $make_install_command"
|
||||
eval "${make_install_command}"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to install project build! Status code: $?"
|
||||
echo "Failed to install project! Status code: $?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user