File: build.cmake

package info (click to toggle)
fastcdr 2.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,412 kB
  • sloc: cpp: 38,058; ansic: 80; xml: 22; makefile: 19; sh: 16
file content (51 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (2)
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
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# 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.

# Script that builds an external dummy project to check standard enforcement
include(CMakePrintHelpers)

# generate a per-test directory test to allow parallel execution
string(MD5 TEST_DIR "${FORCE_CXX} ${TEST_FALLBACK} ${BUILD_DIR}")
get_filename_component(BUILD_DIR ${BUILD_DIR} ABSOLUTE)
string(JOIN "/" BUILD_DIR ${BUILD_DIR} ${TEST_DIR})

# clean build dir if exits
if(EXISTS "${BUILD_DIR}")
    file(REMOVE_RECURSE "${BUILD_DIR}" )
endif()

execute_process(COMMAND ${CMAKE_COMMAND} 
                        -DFORCE_CXX=${FORCE_CXX} -DTEST_FALLBACK=${TEST_FALLBACK}
                        -DEPROSIMA_MODULE_PATH=${EPROSIMA_MODULE_PATH}
                        -B${BUILD_DIR} .
                WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} 
                OUTPUT_VARIABLE my_output
                ERROR_VARIABLE error_log
                RESULT_VARIABLE fail_to_build)

if(fail_to_build)
    message(FATAL_ERROR "The dummy test fail to generate!!!")
    cmake_print_variables(my_output error_log)
endif()

execute_process(COMMAND ${CMAKE_COMMAND}
                        --build ${BUILD_DIR} --target std_force_test
                OUTPUT_VARIABLE my_output
                ERROR_VARIABLE error_log
                RESULT_VARIABLE fail_to_build)

if(fail_to_build OR (error_log MATCHES "[Ww][Aa][Rr][Nn][Ii][Nn][Gg]"))
    message(FATAL_ERROR "The dummy test fail to build!!!")
    cmake_print_variables(my_output error_log)
endif()