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
|
#
# Copyright (C) 2005-2020 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
if(NOT SRC_DIR)
message(FATAL_ERROR "SRC_DIR is not set")
endif()
set(PKG_DIR)
get_filename_component(PKG_DIR ${CMAKE_CURRENT_LIST_DIR} PATH)
set(TEST_DIR ${PKG_DIR}/ex_build)
if(EXISTS "${TEST_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR})
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_DIR})
endif()
message("TEST_DIR=${TEST_DIR}")
message("PKG_DIR=${PKG_DIR}")
message("SRC_DIR=${SRC_DIR}")
set(cmake_gen)
if(WIN32)
set(cmake_gen "-GNinja")
endif()
message( "CMAKE_PREFIX_PATH: '${CMAKE_PREFIX_PATH}'" )
execute_process(
COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${PKG_DIR}
-DCMAKE_BUILD_TYPE=RelWithDebInfo
${cmake_gen}
${SRC_DIR}
WORKING_DIRECTORY ${TEST_DIR}
RESULT_VARIABLE configure_rv
OUTPUT_VARIABLE configure_ov
ERROR_VARIABLE configure_ov
)
if( configure_rv )
message(FATAL_ERROR "Configure FAILED. configure_ov:\n${configure_ov}")
return()
else()
message("Configure PASSED. configure_ov:\n${configure_ov}")
endif()
# If you want to test building a third targert, use foreach.
# the code is written in a way that it is easy to stuff these two
# into a cmake foreach
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${TEST_DIR}
--config RelWithDebInfo
--target HelloWorldOTB
WORKING_DIRECTORY ${TEST_DIR}
RESULT_VARIABLE build_HelloWorldOTB_rv
OUTPUT_VARIABLE build_HelloWorldOTB_ov
ERROR_VARIABLE build_HelloWorldOTB_ov
)
if( build_HelloWorldOTB_rv )
message(FATAL_ERROR "Build FAILED. build_HelloWorldOTB_ov:\n${build_HelloWorldOTB_ov}")
return()
else()
message("Build PASSED. build_HelloWorldOTB_ov:\n${build_HelloWorldOTB_ov}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND}
--build ${TEST_DIR}
--config RelWithDebInfo
--target Pipeline
WORKING_DIRECTORY ${TEST_DIR}
RESULT_VARIABLE build_Pipeline_rv
OUTPUT_VARIABLE build_Pipeline_ov
ERROR_VARIABLE build_Pipeline_ov
)
if( build_Pipeline_rv )
message(FATAL_ERROR "Build FAILED. build_Pipeline_ov=${build_Pipeline_ov}")
return()
else()
message("Build PASSED. build_Pipeline_ov=${build_Pipeline_ov}")
endif()
|