|
| 1 | +# |
| 2 | +# Copyright(c) 2006 to 2021 ADLINK Technology Limited and others |
| 3 | +# |
| 4 | +# This program and the accompanying materials are made available under the |
| 5 | +# terms of the Eclipse Public License v. 2.0 which is available at |
| 6 | +# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License |
| 7 | +# v. 1.0 which is available at |
| 8 | +# http://www.eclipse.org/org/documents/edl-v10.php. |
| 9 | +# |
| 10 | +# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
| 11 | +# |
| 12 | + |
| 13 | +set(_sources |
| 14 | + test_basic.idl |
| 15 | + test_union.idl |
| 16 | + test_alias.idl) |
| 17 | + |
| 18 | +set(_includes "${_includes}\\;${CMAKE_SOURCE_DIR}/src/core/ddsc/include") |
| 19 | +set(_includes "${_includes}\\;${CMAKE_SOURCE_DIR}/src/core/ddsi/include") |
| 20 | +set(_includes "${_includes}\\;${CMAKE_SOURCE_DIR}/src/ddsrt/include") |
| 21 | +set(_includes "${_includes}\\;${CMAKE_BINARY_DIR}/src/core/include") |
| 22 | + |
| 23 | +set(CMAKE_VERBOSE_MAKEFILE ON) |
| 24 | + |
| 25 | +if(MSVC) |
| 26 | + if(CMAKE_CL_64) |
| 27 | + if(MSVC_VERSION GREATER 1599) |
| 28 | + # VS 10 and later: |
| 29 | + set(CMAKE_MSVC_ARCH x64) |
| 30 | + else() |
| 31 | + # VS 9 and earlier: |
| 32 | + set(CMAKE_MSVC_ARCH amd64) |
| 33 | + endif() |
| 34 | + else() |
| 35 | + set(CMAKE_MSVC_ARCH x86) |
| 36 | + endif() |
| 37 | + |
| 38 | + # Add the include dir from the Windows Kits directory |
| 39 | + # code from https://gitlab.kitware.com/cmake/cmake/-/blob/v3.17.3/Modules/InstallRequiredSystemLibraries.cmake |
| 40 | + get_filename_component(windows_kits_dir |
| 41 | + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE) |
| 42 | + set(programfilesx86 "ProgramFiles(x86)") |
| 43 | + if(";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;(10\.[0-9.]+)[;\]]=]) |
| 44 | + set(__ucrt_version "${CMAKE_MATCH_1}/") |
| 45 | + else() |
| 46 | + set(__ucrt_version "") |
| 47 | + endif() |
| 48 | + find_path(WINDOWS_KITS_DIR |
| 49 | + NAMES |
| 50 | + Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll |
| 51 | + Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll |
| 52 | + PATHS |
| 53 | + $ENV{CMAKE_WINDOWS_KITS_10_DIR} |
| 54 | + "${windows_kits_dir}" |
| 55 | + "$ENV{ProgramFiles}/Windows Kits/10" |
| 56 | + "$ENV{${programfilesx86}}/Windows Kits/10" |
| 57 | + ) |
| 58 | + set(_windows_kit_includes "${WINDOWS_KITS_DIR}/include/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") |
| 59 | + set(_windows_kit_libs "${WINDOWS_KITS_DIR}/lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") |
| 60 | + |
| 61 | + # get msvc root |
| 62 | + get_filename_component(_msvc_dir ${CMAKE_C_COMPILER} DIRECTORY) |
| 63 | + set(_msvc_dir "${_msvc_dir}/../../..") |
| 64 | + |
| 65 | + # Add include directory VC/Tools/MSVC/[version]/include |
| 66 | + set(_includes "${_includes}\\;${_msvc_dir}/include") |
| 67 | + set(_includes "${_includes}\\;${_windows_kit_includes}/ucrt") |
| 68 | + set(_includes "${_includes}\\;${_windows_kit_includes}/um") |
| 69 | + set(_includes "${_includes}\\;${_windows_kit_includes}/shared") |
| 70 | + |
| 71 | + # Add library paths |
| 72 | + set(_libs "${_msvc_dir}/lib/${CMAKE_MSVC_ARCH}") |
| 73 | + set(_libs "${_libs}\\;${_windows_kit_libs}/ucrt/${CMAKE_MSVC_ARCH}") |
| 74 | + set(_libs "${_libs}\\;${_windows_kit_libs}/um/${CMAKE_MSVC_ARCH}") |
| 75 | +endif() |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +set(_dir "${CMAKE_CURRENT_SOURCE_DIR}") |
| 80 | +foreach(_source ${_sources}) |
| 81 | + set(_source "${_dir}/${_source}") |
| 82 | + get_filename_component(_base "${_source}" NAME_WE) |
| 83 | + add_test( |
| 84 | + NAME "idlc_${_base}" |
| 85 | + COMMAND ${CMAKE_COMMAND} -P "${_dir}/Compile.cmake" ${_source}) |
| 86 | + set_property( |
| 87 | + TEST "idlc_${_base}" |
| 88 | + APPEND PROPERTY ENVIRONMENT |
| 89 | + "CC=${CMAKE_C_COMPILER}" |
| 90 | + "IDLC=$<TARGET_FILE:CycloneDDS::idlc>" |
| 91 | + "MAINC=${CMAKE_CURRENT_SOURCE_DIR}/main.c" |
| 92 | + "TEST_INCLUDE_PATHS=${_includes}" |
| 93 | + "TEST_LIB_PATHS=${_libs}" |
| 94 | + "CDDS_LIB_PATH=$<TARGET_LINKER_FILE_DIR:CycloneDDS::ddsc>" |
| 95 | + "CDDS_BIN_PATH=$<TARGET_FILE_DIR:CycloneDDS::ddsc>" |
| 96 | + "SANITIZER=${SANITIZER}") |
| 97 | + if(APPLE) |
| 98 | + set_property( |
| 99 | + TEST "idlc_${_base}" |
| 100 | + APPEND PROPERTY ENVIRONMENT |
| 101 | + "OSX_SYSROOT=${CMAKE_OSX_SYSROOT}") |
| 102 | + endif() |
| 103 | +endforeach() |
0 commit comments